Commit cadb3c00 authored by Pekka Pessi's avatar Pekka Pessi

nua: added NUTAG_DIALOG(), mainly usable with nua_method()

NUTAG_DIALOG(0): nua_method() reqest does not change dialog state
NUTAG_DIALOG(1): nua_method() is target-refresh request
NUTAG_DIALOG(2): nua_method() request creates a dialog

darcs-hash:20070411133849-65a35-cb4f3646fd53797b9646cc2f61fdf1d0b2e0949d.gz
parent 6f464494
......@@ -112,6 +112,7 @@ struct nua_server_request {
unsigned sr_event:1; /**< Reported to application */
unsigned sr_initial:1; /**< Handle was created by this request */
unsigned sr_add_contact:1; /**< Add Contact header to the response */
unsigned sr_target_refresh:1; /**< Refresh target */
unsigned sr_terminating:1; /**< Terminate usage after final response */
unsigned sr_gracefully:1; /**< Terminate usage gracefully */
......@@ -299,6 +300,7 @@ struct nua_client_request
unsigned cr_auto:1; /**< Request was generated by stack */
unsigned cr_has_contact:1; /**< Request has user Contact */
unsigned cr_contactize:1; /**< Request needs Contact */
unsigned cr_dialog:1; /**< Request can initiate dialog */
/* Current state */
unsigned cr_challenged:1; /**< Request was challenged */
......
......@@ -75,7 +75,7 @@ static nua_client_methods_t const nua_method_client_methods = {
{
/* create_dialog */ 0,
/* in_dialog */ 0,
/* target_refresh */ 0
/* target_refresh */ 1,
},
/* nua_method_client_template */ NULL,
/* nua_method_client_init */ NULL,
......@@ -146,7 +146,7 @@ nua_server_methods_t const nua_extension_server_methods =
SIP_METHOD_UNKNOWN,
nua_i_method, /* Event */
{
0, /* Do not create dialog */
1, /* Do create dialog */
0, /* Can be an initial request */
1, /* Perhaps a target refresh request? */
1, /* Add a contact? */
......
......@@ -1049,6 +1049,7 @@ int nua_stack_process_request(nua_handle_t *nh,
nua_server_methods_t const *sm;
nua_server_request_t *sr, sr0[1];
int status, initial = 1;
int create_dialog;
char const *user_agent = NH_PGET(nh, user_agent);
sip_supported_t const *supported = NH_PGET(nh, supported);
......@@ -1135,11 +1136,15 @@ int nua_stack_process_request(nua_handle_t *nh,
return 481;
}
create_dialog = sm->sm_flags.create_dialog;
if (method == sip_method_message && NH_PGET(nh, win_messenger_enable))
create_dialog = 1;
sr = memset(sr0, 0, (sizeof sr0));
sr->sr_methods = sm;
sr->sr_method = method = sip->sip_request->rq_method;
sr->sr_add_contact = sm->sm_flags.add_contact;
sr->sr_target_refresh = sm->sm_flags.target_refresh;
sr->sr_owner = nh;
sr->sr_initial = initial;
......@@ -1171,12 +1176,12 @@ int nua_stack_process_request(nua_handle_t *nh,
}
if (sr->sr_status < 300 && sm->sm_preprocess && sm->sm_preprocess(sr)) {
if (sr->sr_status < 200) /* Preprocess may have set response status */
if (sr->sr_status < 200) /* Set response status if preprocess did not */
SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
}
if (sr->sr_status < 300) {
if (sm->sm_flags.target_refresh)
if (sr->sr_target_refresh)
nua_dialog_uas_route(nh, nh->nh_ds, sip, 1); /* Set route and tags */
nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
}
......@@ -1696,6 +1701,7 @@ int nua_client_create(nua_handle_t *nh,
cr->cr_method = method;
cr->cr_method_name = name;
cr->cr_contactize = methods->crm_flags.target_refresh;
cr->cr_dialog = methods->crm_flags.create_dialog;
cr->cr_auto = 1;
if (su_msg_is_non_null(nh->nh_nua->nua_signal)) {
......@@ -1927,6 +1933,10 @@ int nua_client_init_request(nua_client_request_t *cr)
has_contact = 1;
else if (t->t_tag == nutag_url)
url = (url_string_t const *)t->t_value;
else if (t->t_tag == nutag_dialog) {
cr->cr_dialog = t->t_value > 1;
cr->cr_contactize = t->t_value >= 1;
}
else if (t->t_tag == nutag_auth && t->t_value) {
/* XXX ignoring errors */
if (nh->nh_auth)
......@@ -1965,7 +1975,7 @@ int nua_client_init_request(nua_client_request_t *cr)
sip_add_dup(msg, sip, (sip_header_t *)nua->nua_from) < 0)
goto error;
if (cr->cr_methods->crm_flags.create_dialog) {
if (cr->cr_dialog) {
ds->ds_leg = nta_leg_tcreate(nua->nua_nta,
nua_stack_process_request, nh,
SIPTAG_CALL_ID(sip->sip_call_id),
......@@ -2337,7 +2347,7 @@ int nua_client_response(nua_client_request_t *cr,
}
else {
if (sip) {
if (cr->cr_methods->crm_flags.target_refresh)
if (cr->cr_contactize)
nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
}
......
......@@ -336,8 +336,6 @@ nua_handle_t *nua_stack_incoming_handle(nua_t *nua,
sip_t const *sip,
int create_dialog);
enum { create_dialog = 1 };
int nua_stack_init_handle(nua_t *nua, nua_handle_t *nh,
tag_type_t tag, tag_value_t value, ...);
......
......@@ -149,3 +149,4 @@ tag_typedef_t nutag_auth_cache = INTTAG_TYPEDEF(auth_cache);
tag_typedef_t nutag_detect_network_updates = UINTTAG_TYPEDEF(detect_network_updates);
tag_typedef_t nutag_with = PTRTAG_TYPEDEF(with);
tag_typedef_t nutag_dialog = UINTTAG_TYPEDEF(dialog);
......@@ -174,6 +174,26 @@ SOFIAPUBVAR tag_typedef_t nutag_with;
*/
#define NUTAG_WITH_SAVED(e) nutag_with, tag_ptr_v(nua_saved_event_request((e)))
/**An (extension) method is used to create dialog or refresh target.
*
* @par Used with
* nua_method()
*
* @par Parameter type
* unsigned int (0, 1, 2)
*
* @par Values
* - 0 if dialog target is not refreshed
* - 1 if dialog target is refreshed
* - > 1 if dialog is to be created
*
* @NEW_1_12_6.
*
* @sa nua_method(), #nua_i_method
*/
#define NUTAG_DIALOG(b) nutag_dialog, tag_uint_v((b))
SOFIAPUBVAR tag_typedef_t nutag_dialog;
/**Set request retry count.
*
* Retry count determines how many times stack will automatically retry
......
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