diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-12-02 07:25:29 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-12-02 07:25:29 +0000 |
commit | c33192776b301fcbb00feee4f67cf29bf619f318 (patch) | |
tree | 4691fe763210f7389c4cb414b5038ebdf74166c8 /pjsip | |
parent | 91c9480e8356af4079be043ffe4eb2c32f8edac8 (diff) |
Fixed ticket #36: pjsip_regc_unregister() SHOULD NOT unregister all contacts but rather only contact that was previously sent in the registration. In addition, added function pjsip_regc_unregister_all() to unregister all contacts
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@843 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/include/pjsip-ua/sip_regc.h | 18 | ||||
-rw-r--r-- | pjsip/src/pjsip-ua/sip_reg.c | 27 |
2 files changed, 44 insertions, 1 deletions
diff --git a/pjsip/include/pjsip-ua/sip_regc.h b/pjsip/include/pjsip-ua/sip_regc.h index 81aa07ed..04f2752d 100644 --- a/pjsip/include/pjsip-ua/sip_regc.h +++ b/pjsip/include/pjsip-ua/sip_regc.h @@ -230,7 +230,8 @@ PJ_DECL(pj_status_t) pjsip_regc_register(pjsip_regc *regc, pj_bool_t autoreg, /** - * Create REGISTER request to unregister all contacts from server records. + * Create REGISTER request to unregister the contacts that were previously + * registered by this client registration. * * @param regc The client registration structure. * @param p_tdata Pointer to receive the REGISTER request. @@ -241,6 +242,21 @@ PJ_DECL(pj_status_t) pjsip_regc_unregister(pjsip_regc *regc, pjsip_tx_data **p_tdata); /** + * Create REGISTER request to unregister all contacts from server records. + * Note that this will unregister all registered contact for the AOR + * including contacts registered by other user agents. To only unregister + * contact registered by this client registration instance, use + * #pjsip_regc_unregister() instead. + * + * @param regc The client registration structure. + * @param p_tdata Pointer to receive the REGISTER request. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_regc_unregister_all(pjsip_regc *regc, + pjsip_tx_data **p_tdata); + +/** * Update Contact details in the client registration structure. * * @param regc The client registration structure. diff --git a/pjsip/src/pjsip-ua/sip_reg.c b/pjsip/src/pjsip-ua/sip_reg.c index 2054c27e..5cba23ee 100644 --- a/pjsip/src/pjsip-ua/sip_reg.c +++ b/pjsip/src/pjsip-ua/sip_reg.c @@ -443,6 +443,33 @@ PJ_DEF(pj_status_t) pjsip_regc_unregister(pjsip_regc *regc, return status; msg = tdata->msg; + pjsip_msg_add_hdr(msg, pjsip_hdr_shallow_clone(tdata->pool, + regc->contact_hdr)); + pjsip_msg_add_hdr( msg, (pjsip_hdr*)regc->unreg_expires_hdr); + + *p_tdata = tdata; + return PJ_SUCCESS; +} + +PJ_DEF(pj_status_t) pjsip_regc_unregister_all(pjsip_regc *regc, + pjsip_tx_data **p_tdata) +{ + pjsip_tx_data *tdata; + pjsip_msg *msg; + pj_status_t status; + + PJ_ASSERT_RETURN(regc && p_tdata, PJ_EINVAL); + + if (regc->timer.id != 0) { + pjsip_endpt_cancel_timer(regc->endpt, ®c->timer); + regc->timer.id = 0; + } + + status = create_request(regc, &tdata); + if (status != PJ_SUCCESS) + return status; + + msg = tdata->msg; pjsip_msg_add_hdr( msg, (pjsip_hdr*)regc->unreg_contact_hdr); pjsip_msg_add_hdr( msg, (pjsip_hdr*)regc->unreg_expires_hdr); |