Commit 16988658 authored by Pekka Pessi's avatar Pekka Pessi

Changed internal nua error responses to use 9XX status codes.

darcs-hash:20060417043228-88462-67cd8fb78e440ce45d0a1948f93e513940af2761.gz
parent 13505174
......@@ -79,8 +79,8 @@ nua_stack_notifier(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *ta
url_string_t const *url = NULL;
char const *event_s = NULL, *ct_s = NULL, *pl_s = NULL;
nea_event_t *ev;
int status = 500;
char const *phrase = nua_500_error;
int status = 900;
char const *phrase = nua_internal_error;
nua_stack_init_handle(nua, nh, nh_has_nothing, NULL, TAG_NEXT(tags));
......@@ -106,19 +106,20 @@ nua_stack_notifier(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *ta
NH_PGET(nh, max_subscriptions),
NULL, nh,
TAG_NEXT(tags))))
status = 500, phrase = nua_500_error;
status = 900, phrase = nua_internal_error;
else if (!event && !(event = sip_event_make(home, event_s)))
status = 500, phrase = "Could not create an event header";
status = 900, phrase = "Could not create an event header";
else if (!(ev = nh_notifier_event(nh, home, event, tags)))
status = 500, phrase = "Could not create an event view";
status = 900, phrase = "Could not create an event view";
else if (nea_server_update(nh->nh_notifier, ev, TAG_NEXT(tags)) < 0)
status = 500, phrase = "No content for event";
status = 900, phrase = "No content for event";
else if (nea_server_notify(nh->nh_notifier, ev) < 0)
status = 500, phrase = "Error when notifying watchers";
status = 900, phrase = "Error when notifying watchers";
else
nua_stack_event(nua, nh, NULL, e, status = SIP_200_OK,
SIPTAG_EVENT(event),
......@@ -264,7 +265,7 @@ void nua_stack_authorize(nua_t *nua,
nua_stack_event(nua, nh, NULL, e, SIP_200_OK, TAG_END());
}
else {
nua_stack_event(nua, nh, NULL, e, SIP_500_INTERNAL_SERVER_ERROR, TAG_END());
nua_stack_event(nua, nh, NULL, e, NUA_INTERNAL_ERROR, TAG_END());
}
return;
}
......@@ -322,7 +323,7 @@ void nua_stack_terminate(nua_t *nua,
nea_event_t *nev = NULL;
if (nh->nh_notifier == NULL) {
UA_EVENT2(e, 500, "No event server to terminate");
UA_EVENT2(e, 900, "No event server to terminate");
return;
}
......
......@@ -63,10 +63,10 @@ nua_stack_message(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tag
sip_t *sip;
if (nh_is_special(nh)) {
return UA_EVENT2(e, 500, "Invalid handle for MESSAGE");
return UA_EVENT2(e, 900, "Invalid handle for MESSAGE");
}
else if (cr->cr_orq) {
return UA_EVENT2(e, 500, "Request already in progress");
return UA_EVENT2(e, 900, "Request already in progress");
}
nua_stack_init_handle(nua, nh, nh_has_nothing, NULL, TAG_NEXT(tags));
......@@ -115,7 +115,7 @@ nua_stack_message(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tag
SIPTAG_END(), TAG_NEXT(tags));
if (!cr->cr_orq) {
msg_destroy(msg);
return UA_EVENT1(e, NUA_500_ERROR);
return UA_EVENT1(e, NUA_INTERNAL_ERROR);
}
return cr->cr_event = e;
......@@ -149,7 +149,7 @@ int nua_stack_process_message(nua_t *nua,
if (nh == NULL)
if (!(nh = nua_stack_incoming_handle(nua, irq, sip, nh_has_nothing, 0)))
return 500;
return 500; /* respond with 500 Internal Server Error */
msg = nta_incoming_getrequest(irq);
......
......@@ -62,10 +62,10 @@ nua_stack_options(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tag
msg_t *msg;
if (nh_is_special(nh)) {
return UA_EVENT2(e, 500, "Invalid handle for OPTIONS");
return UA_EVENT2(e, 900, "Invalid handle for OPTIONS");
}
else if (cr->cr_orq) {
return UA_EVENT2(e, 500, "Request already in progress");
return UA_EVENT2(e, 900, "Request already in progress");
}
nua_stack_init_handle(nua, nh, nh_has_nothing, NULL, TAG_NEXT(tags));
......@@ -80,7 +80,7 @@ nua_stack_options(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tag
SIPTAG_END(), TAG_NEXT(tags));
if (!cr->cr_orq) {
msg_destroy(msg);
return UA_EVENT1(e, NUA_500_ERROR);
return UA_EVENT1(e, NUA_INTERNAL_ERROR);
}
return cr->cr_event = e;
......
......@@ -632,10 +632,10 @@ int nua_stack_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
su_home_deinit(tmphome);
if (error)
return UA_EVENT2(e, 500, "Error storing parameters"), -1;
return UA_EVENT2(e, 900, "Error storing parameters"), -1;
if (nh->nh_soa && soa_set_params(nh->nh_soa, TAG_NEXT(tags)) < 0)
return UA_EVENT2(e, 400, "Error setting SOA parameters"), -1;
return UA_EVENT2(e, 900, "Error setting SOA parameters"), -1;
#if 0
reinit_contact =
......@@ -647,7 +647,7 @@ int nua_stack_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
return e == nua_r_set_params ? UA_EVENT2(e, 200, "OK") : 0;
if (nta_agent_set_params(nua->nua_nta, TAG_NEXT(tags)) < 0)
return UA_EVENT2(e, 400, "Error setting NTA parameters"), -1;
return UA_EVENT2(e, 900, "Error setting NTA parameters"), -1;
/* ---------------------------------------------------------------------- */
/* Set stack-specific things below */
......
......@@ -120,10 +120,10 @@ nua_stack_publish(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tag
sip_t *sip;
if (nh->nh_special && nh->nh_special != nua_r_publish) {
return UA_EVENT2(e, 500, "Invalid handle for PUBLISH");
return UA_EVENT2(e, 900, "Invalid handle for PUBLISH");
}
else if (cr->cr_orq) {
return UA_EVENT2(e, 500, "Request already in progress");
return UA_EVENT2(e, 900, "Request already in progress");
}
nua_stack_init_handle(nua, nh, nh_has_nothing, NULL, TAG_NEXT(tags));
......@@ -131,7 +131,7 @@ nua_stack_publish(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tag
du = nua_dialog_usage_add(nh, nh->nh_ds, nua_publish_usage, NULL);
if (!du)
return UA_EVENT1(e, NUA_500_ERROR);
return UA_EVENT1(e, NUA_INTERNAL_ERROR);
pu = nua_dialog_usage_private(du);
msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
......@@ -156,7 +156,7 @@ nua_stack_publish(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tag
msg_destroy(msg);
if (!du->du_ready)
nua_dialog_usage_remove(nh, nh->nh_ds, du);
return UA_EVENT1(e, NUA_500_ERROR);
return UA_EVENT1(e, NUA_INTERNAL_ERROR);
}
nh->nh_special = nua_r_publish;
......@@ -225,7 +225,7 @@ int nua_stack_process_publish(nua_t *nua,
{
if (nh == NULL)
if (!(nh = nua_stack_incoming_handle(nua, irq, sip, nh_has_nothing, 0)))
return 500;
return 500; /* Respond with 500 Internal Server Error */
nua_stack_event(nh->nh_nua, nh, nta_incoming_getrequest(irq),
nua_i_publish, SIP_501_NOT_IMPLEMENTED, TAG_END());
......
......@@ -424,16 +424,16 @@ nua_stack_register(nua_t *nua, nua_handle_t *nh, nua_event_t e,
int terminating = e != nua_r_register;
if (nh->nh_special && nh->nh_special != nua_r_register)
return UA_EVENT2(e, 500, "Invalid handle for REGISTER");
return UA_EVENT2(e, 900, "Invalid handle for REGISTER");
if (cr->cr_orq)
return UA_EVENT2(e, 500, "Request already in progress");
return UA_EVENT2(e, 900, "Request already in progress");
nua_stack_init_handle(nua, nh, nh_has_register, "", TAG_NEXT(tags));
nh->nh_special = nua_r_register;
du = nua_dialog_usage_add(nh, nh->nh_ds, nua_outbound_connect, NULL);
if (!du)
return UA_EVENT1(e, NUA_500_ERROR);
return UA_EVENT1(e, NUA_INTERNAL_ERROR);
oc = nua_dialog_usage_private(du); assert(oc);
outbound_connect_init(oc, &nua_stack_register_callbacks,
......@@ -494,7 +494,7 @@ nua_stack_register(nua_t *nua, nua_handle_t *nh, nua_event_t e,
if (!cr->cr_orq) {
msg_destroy(msg);
msg_destroy(cr->cr_msg), cr->cr_msg = NULL;
return UA_EVENT1(e, NUA_500_ERROR);
return UA_EVENT1(e, NUA_INTERNAL_ERROR);
}
cr->cr_usage = du;
......@@ -577,7 +577,7 @@ int process_response_to_register(nua_handle_t *nh,
reregister = outbound_connect_check_for_nat(oc, orq, sip);
if (reregister < 0)
SET_STATUS2(500, nua_500_error);
SET_STATUS1(NUA_INTERNAL_ERROR);
else if (reregister > 0) {
msg_t *msg = msg_ref_create(cr->cr_msg);
if (nua_creq_check_restart(nh, cr, orq, sip, restart_register)) {
......@@ -773,7 +773,7 @@ refresh_register(nua_handle_t *nh, nua_dialog_usage_t *du, sip_time_t now)
nua_dialog_usage_remove(nh, nh->nh_ds, du);
msg_destroy(msg);
msg_destroy(cr->cr_msg);
UA_EVENT2(e, NUA_500_ERROR, TAG_END());
UA_EVENT2(e, NUA_INTERNAL_ERROR, TAG_END());
return;
}
......
......@@ -192,9 +192,9 @@ nua_stack_invite(nua_t *nua, nua_handle_t *nh, nua_event_t e,
else
return ua_invite2(nua, nh, e, 0, tags);
UA_EVENT2(e, 500, what);
UA_EVENT2(e, 900, what);
signal_call_state_change(nh, 500, what, nua_callstate_init, 0, 0);
signal_call_state_change(nh, 900, what, nua_callstate_init, 0, 0);
return e;
}
......@@ -217,7 +217,7 @@ ua_invite2(nua_t *nua, nua_handle_t *nh, nua_event_t e, int restarted,
ss->ss_state = nua_callstate_init;
du = nua_dialog_usage_add(nh, nh->nh_ds, nua_session_usage, NULL);
what = nua_500_error; /* Internal error */
what = nua_internal_error; /* Internal error */
msg = du ? nua_creq_msg(nua, nh, cr, restarted,
SIP_METHOD_INVITE,
......@@ -297,8 +297,8 @@ ua_invite2(nua_t *nua, nua_handle_t *nh, nua_event_t e, int restarted,
if (du && !du->du_ready)
nua_dialog_usage_remove(nh, nh->nh_ds, du);
UA_EVENT2(e, 500, what);
signal_call_state_change(nh, 500, what, nua_callstate_init, 0, 0);
UA_EVENT2(e, 900, what);
signal_call_state_change(nh, 900, what, nua_callstate_init, 0, 0);
return e;
}
......@@ -390,7 +390,7 @@ static int process_response_to_invite(nua_handle_t *nh,
return 0;
}
status = 500, phrase = "Malformed Session in Response";
status = 900, phrase = "Malformed Session in Response";
nua_stack_ack(nua, nh, nua_r_ack, NULL);
gracefully = 1;
......@@ -455,7 +455,7 @@ int nua_stack_ack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
char const *received = ss->ss_ack_needed;
if (!ss->ss_ack_needed)
return UA_EVENT2(nua_i_error, 500, "No response to ACK");
return UA_EVENT2(nua_i_error, 900, "No response to ACK");
ss->ss_ack_needed = 0;
......@@ -481,7 +481,7 @@ int nua_stack_ack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
session_include_description(nh->nh_soa, msg, sip) < 0) {
reason = soa_error_as_sip_reason(nh->nh_soa);
/* XXX */
status = 500, phrase = "Internal media error";
status = 900, phrase = "Internal media error";
reason = "SIP;cause=500;text=\"Internal media error\"";
}
else {
......@@ -497,8 +497,8 @@ int nua_stack_ack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
/* ss->ss_offer_sent && !ss->ss_answer_recv */
!soa_is_complete(nh->nh_soa)) {
/* No SDP answer in 2XX response -> terminate call */
status = 488, phrase = "Incomplete offer/answer";
reason = "SIP;cause=488;text=\"Incomplete offer/answer\"p";
status = 988, phrase = "Incomplete offer/answer";
reason = "SIP;cause=488;text=\"Incomplete offer/answer\"";
}
}
......@@ -508,7 +508,7 @@ int nua_stack_ack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
if (!ack) {
if (!reason) {
status = 500, phrase = "Internal Error";
status = 900, phrase = "Cannot send ACK";
reason = "SIP;cause=500;text=\"Internal Error\"";
}
msg_destroy(msg);
......@@ -615,7 +615,7 @@ process_100rel(nua_handle_t *nh,
else {
/* XXX - call state? */
nua_stack_event(nh->nh_nua, nh, NULL, nua_i_error,
500, "Cannot PRACK",
900, "Cannot PRACK",
TAG_END());
}
......@@ -650,7 +650,7 @@ process_response_to_prack(nua_handle_t *nh,
if (status < 300) {
if (session_process_response(nh, cr, orq, sip, &recv) < 0) {
status = 500, phrase = "Malformed Session in Response";
status = 900, phrase = "Malformed Session in Response";
reason = "SIP;status=400;phrase=\"Malformed Session in Response\"";
}
}
......@@ -857,7 +857,7 @@ int process_invite1(nua_t *nua,
min_se,
SIPTAG_USER_AGENT(user_agent),
TAG_END()))
return 500;
return 500; /* respond with 500 Internal Server Error */
}
if (!nh) {
......@@ -1015,7 +1015,7 @@ void respond_to_invite(nua_t *nua, nua_handle_t *nh,
if (ss->ss_srequest->sr_irq == NULL ||
nta_incoming_status(ss->ss_srequest->sr_irq) >= 200) {
nua_stack_event(nh->nh_nua, nh, NULL,
nua_i_error, 500, "No INVITE request to response", TAG_END());
nua_i_error, 900, "No INVITE request to response", TAG_END());
return;
}
......@@ -1079,7 +1079,7 @@ void respond_to_invite(nua_t *nua, nua_handle_t *nh,
if (offer || answer) {
if (session_include_description(nh->nh_soa, msg, sip) < 0)
status = 500, phrase = sip_500_Internal_server_error;
SET_STATUS1(SIP_500_INTERNAL_SERVER_ERROR);
}
}
......@@ -1111,7 +1111,7 @@ void respond_to_invite(nua_t *nua, nua_handle_t *nh,
rel = nta_reliable_mreply(ss->ss_srequest->sr_irq,
process_prack, nh, msg);
if (!rel)
status = 500, phrase = sip_500_Internal_server_error;
SET_STATUS1(SIP_500_INTERNAL_SERVER_ERROR);
}
if (reliable && status < 200)
......@@ -1289,7 +1289,7 @@ int process_prack(nua_handle_t *nh,
SIPTAG_PAYLOAD(pl),
TAG_END()) < 0)
/* Respond with 500 if nta_incoming_treply() failed */
status = 500, phrase = sip_500_Internal_server_error;
SET_STATUS1(SIP_500_INTERNAL_SERVER_ERROR);
su_home_deinit(home);
}
......@@ -1680,10 +1680,10 @@ nua_stack_info(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
msg_t *msg;
if (nh_is_special(nh)) {
return UA_EVENT2(e, 500, "Invalid handle for INFO");
return UA_EVENT2(e, 900, "Invalid handle for INFO");
}
else if (cr->cr_orq) {
return UA_EVENT2(e, 500, "Request already in progress");
return UA_EVENT2(e, 900, "Request already in progress");
}
nua_stack_init_handle(nua, nh, nh_has_nothing, NULL, TAG_NEXT(tags));
......@@ -1699,7 +1699,7 @@ nua_stack_info(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
SIPTAG_END(), TAG_NEXT(tags));
if (!cr->cr_orq) {
msg_destroy(msg);
return UA_EVENT1(e, NUA_500_ERROR);
return UA_EVENT1(e, NUA_INTERNAL_ERROR);
}
return cr->cr_event = e;
......@@ -1750,9 +1750,9 @@ nua_stack_update(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags
char const *offer_sent = 0;
if (!nh_has_session(nh))
return UA_EVENT2(e, 500, "Invalid handle for UPDATE");
return UA_EVENT2(e, 900, "Invalid handle for UPDATE");
else if (cr->cr_orq)
return UA_EVENT2(e, 500, "Request already in progress");
return UA_EVENT2(e, 900, "Request already in progress");
nua_stack_init_handle(nua, nh, nh_has_nothing, NULL, TAG_NEXT(tags));
......@@ -1777,7 +1777,7 @@ nua_stack_update(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags
/* XXX */
}
msg_destroy(msg);
return UA_EVENT2(e, 500, "Local media failed");
return UA_EVENT2(e, 900, "Local media failed");
}
offer_sent = "offer";
......@@ -1807,7 +1807,7 @@ nua_stack_update(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags
}
msg_destroy(msg);
return UA_EVENT1(e, NUA_500_ERROR);
return UA_EVENT1(e, NUA_INTERNAL_ERROR);
}
void restart_update(nua_handle_t *nh, tagi_t *tags)
......@@ -1948,8 +1948,9 @@ int nua_stack_process_update(nua_t *nua,
status = soa_error_as_sip_response(nh->nh_soa, &phrase);
}
else if (soa_activate(nh->nh_soa, NULL) < 0) {
SU_DEBUG_5(("nua(%p): error activating media after %s\n",
nh, "UPDATE"));
/* XXX */
status = 500, phrase = sip_500_Internal_server_error;
}
else {
answer_sent = "answer";
......@@ -2019,11 +2020,11 @@ nua_stack_bye(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
nta_outgoing_t *orq;
if (nh_is_special(nh))
return UA_EVENT2(e, 500, "Invalid handle for BYE");
return UA_EVENT2(e, 900, "Invalid handle for BYE");
if (!nua_dialog_is_established(nh->nh_ds)) {
if (cr_invite->cr_orq == NULL)
return UA_EVENT2(e, 400, "Internal error");
return UA_EVENT2(e, 900, "No session to BYE");
/* No (early) dialog. BYE is invalid action, do CANCEL instead */
orq = nta_outgoing_tcancel(cr_invite->cr_orq,
......@@ -2409,7 +2410,7 @@ int session_process_response(nua_handle_t *nh,
else {
/* note: case 2: answer to our offer */
if (soa_activate(nh->nh_soa, NULL) < 0) {
SU_DEBUG_5(("nua(%p): %s: error activating media after %u %s\n",
SU_DEBUG_3(("nua(%p): %s: error activating media after %u %s\n",
nh, method,
sip->sip_status->st_status,
sip->sip_status->st_phrase));
......
......@@ -99,7 +99,7 @@ static void nua_stack_timer(nua_t *nua, su_timer_t *t, su_timer_arg_t *a);
/* Constant data */
/**@internal Default internal error. */
char const nua_500_error[] = "Internal NUA Error";
char const nua_internal_error[] = "Internal NUA Error";
char const nua_application_sdp[] = "application/sdp";
......@@ -358,7 +358,9 @@ void nua_stack_signal(nua_t *nua, su_msg_r msg, nua_event_data_t *e)
if (nua->nua_shutdown && !e->e_always) {
/* Shutting down */
nua_stack_event(nua, nh, NULL, e->e_event, 500, "Stack is going down", TAG_END());
nua_stack_event(nua, nh, NULL, e->e_event,
901, "Stack is going down",
TAG_END());
}
else switch (e->e_event) {
case nua_r_get_params:
......
......@@ -273,9 +273,9 @@ int nh_has_session(nua_handle_t const *nh)
}
extern char const nua_500_error[];
extern char const nua_internal_error[];
#define NUA_500_ERROR 500, nua_500_error
#define NUA_INTERNAL_ERROR 900, nua_internal_error
struct nua_s {
su_home_t nua_home[1];
......
......@@ -230,7 +230,8 @@ nua_stack_subscribe(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *t
msg_destroy(msg);
return UA_EVENT3(e, NUA_500_ERROR, NUTAG_SUBSTATE(substate), TAG_END());
return UA_EVENT3(e, NUA_INTERNAL_ERROR,
NUTAG_SUBSTATE(substate), TAG_END());
}
du->du_terminating = e != nua_r_subscribe; /* Unsubscribe or destroy */
......@@ -388,7 +389,8 @@ refresh_subscribe(nua_handle_t *nh, nua_dialog_usage_t *du, sip_time_t now)
if (du->du_terminating)
nua_dialog_usage_remove(nh, nh->nh_ds, du);
msg_destroy(msg);
UA_EVENT3(e, NUA_500_ERROR, NUTAG_SUBSTATE(eu->eu_substate), TAG_END());
UA_EVENT3(e, NUA_INTERNAL_ERROR,
NUTAG_SUBSTATE(eu->eu_substate), TAG_END());
return;
}
......@@ -546,7 +548,7 @@ nua_stack_notify(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags
sip = sip_object(msg);
if (!sip)
return UA_EVENT1(e, NUA_500_ERROR);
return UA_EVENT1(e, NUA_INTERNAL_ERROR);
du = nua_dialog_usage_get(nh->nh_ds, nua_notify_usage, sip->sip_event);
eu = nua_dialog_usage_private(du);
......@@ -640,7 +642,7 @@ nua_stack_notify(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags
if (!cr->cr_orq) {
msg_destroy(msg);
return UA_EVENT1(e, NUA_500_ERROR);
return UA_EVENT1(e, NUA_INTERNAL_ERROR);
}
cr->cr_usage = du;
......@@ -859,7 +861,7 @@ nua_stack_refer(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
nua_dialog_usage_remove(nh, nh->nh_ds, du);
su_free(nh->nh_home, event);
msg_destroy(msg);
return UA_EVENT1(e, NUA_500_ERROR);
return UA_EVENT1(e, NUA_INTERNAL_ERROR);
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment