[SR-Users] 3rd party REGISTER body
Jyaim Jyaim
jyaime at gmail.com
Wed Jan 7 15:25:07 CET 2015
Hello all,
Just to share the solution I use to get the initial register into 3rd party
register, I attached the diff file on modified code.
Maybe useful one day to someone ;)
Regards
2014-12-30 15:03 GMT+01:00 Olle E. Johansson <oej at edvina.net>:
>
> On 30 Dec 2014, at 13:58, Jyaim Jyaim <jyaime at gmail.com> wrote:
>
> Hello,
>
> I'm using Kamailio with a SIP Application Server: when a user registers on
> the IMS Core, Kamailio is configured to send a 3rd Party REGISTER request
> to the application server.
> This 3rd party REGISTER request starts some logic on the AS.
>
> I'm trying to add the initial REGISTER request sent by user device in the
> 3rd party register request body.
>
> Do you think it is possible to configure Kamailio to get that?
>
> Yes. start looking at the UAC module.
>
> /O
>
>
> Thank you!
>
> 2014-12-30 11:10 GMT+01:00 Olle E. Johansson <oej at edvina.net>:
>
>>
>> On 30 Dec 2014, at 10:26, Jyaim Jyaim <jyaime at gmail.com> wrote:
>>
>> > Hello,
>> >
>> > I'm wondering if I can configure Kamailio to get in 3rd party REGISTER
>> request's body the initial REGISTER request received from user ?
>> >
>> Sorry, but I don't understand. Who's getting the initial REGISTER and who
>> wants it?
>> Please explain a bit more.
>>
>> /O
>>
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users at lists.sip-router.org
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20150107/e4d37892/attachment.html>
-------------- next part --------------
Index: ser_ims/modules/isc/third_party_reg.c
===================================================================
--- ser_ims/modules/isc/third_party_reg.c (revision 11549)
+++ ser_ims/modules/isc/third_party_reg.c (revision 13364)
@@ -132,8 +132,8 @@
r.cv = cv;
r.service_info = m->service_info;
- if (expires<=0) r_send_third_party_reg(&r,0);
- else r_send_third_party_reg(&r,expires+isc_expires_grace);
+ if (expires<=0) r_send_third_party_reg(&r,0, msg);
+ else r_send_third_party_reg(&r,expires+isc_expires_grace, msg);
return ISC_RETURN_TRUE;
}else{
return ISC_RETURN_FALSE;
@@ -162,6 +162,9 @@
static str body_s={"<ims-3gpp version=\"1\"><service-info>",36};
static str body_e={"</service-info></ims-3gpp>",26};
+static str content_type_message_sip={"Content-Type: message/sip\r\n",27};
#ifdef WITH_IMS_PM
static str zero={0,0};
@@ -173,7 +176,7 @@
* @returns true if OK, false if not
*/
-int r_send_third_party_reg(r_third_party_registration *r,int expires)
+int r_send_third_party_reg(r_third_party_registration *r,int expires, struct sip_msg *msg)
{
str h={0,0};
str b={0,0};
@@ -198,6 +201,10 @@
if (r->cv.len) h.len += p_charging_vector_s.len +
p_charging_vector_e.len + r->cv.len;
+ h.len += content_type_message_sip.len;
+
h.s = pkg_malloc(h.len);
if (!h.s){
LOG(L_ERR,"ERR:"M_NAME":r_send_third_party_reg: Error allocating %d bytes\n",h.len);
@@ -237,21 +244,34 @@
STR_APPEND(h,p_charging_vector_e);
}
LOG(L_CRIT,"SRV INFO:<%.*s>\n",r->service_info.len, r->service_info.s);
- if (r->service_info.len){
- b.len = body_s.len+r->service_info.len+body_e.len;
- b.s = pkg_malloc(b.len);
- if (!b.s){
- LOG(L_ERR,"ERR:"M_NAME":r_send_third_party_reg: Error allocating %d bytes\n",b.len);
- b.len = 0;
- return 0;
- }
-
- b.len = 0;
- STR_APPEND(b,body_s);
- STR_APPEND(b,r->service_info);
- STR_APPEND(b,body_e);
+ if (r->service_info.len){
+ b.len = body_s.len+r->service_info.len+body_e.len;
+ b.s = pkg_malloc(b.len);
+ if (!b.s){
+ LOG(L_ERR,"ERR:"M_NAME":r_send_third_party_reg: Error allocating %d bytes\n",b.len);
+ b.len = 0;
+ return 0;
}
-
+
+ b.len = 0;
+ STR_APPEND(b,body_s);
+ STR_APPEND(b,r->service_info);
+ STR_APPEND(b,body_e);
+ }
+ else if(expires > 0) {
+ STR_APPEND(h,content_type_message_sip);
+ b.len = msg->len;
+ b.s = pkg_malloc(b.len);
+ if (!b.s){
+ LOG(L_ERR,"ERR:"M_NAME":r_send_third_party_reg: Error allocating %d bytes\n",b.len);
+ b.len = 0;
+ return 0;
+ }
+ memcpy(b.s, msg->buf, msg->len);
+ }
+
#ifdef SER_MOD_INTERFACE
set_uac_req(&req,
&method,
Index: ser_ims/modules/isc/third_party_reg.h
===================================================================
--- ser_ims/modules/isc/third_party_reg.h (revision 11549)
+++ ser_ims/modules/isc/third_party_reg.h (revision 13364)
@@ -80,7 +80,7 @@
r_third_party_registration* new_r_third_party_reg(str req_uri, str to, str from, str pvni, str cv);
-int r_send_third_party_reg(r_third_party_registration *r,int duration);
+int r_send_third_party_reg(r_third_party_registration *r,int duration, struct sip_msg *msg);
void r_third_party_reg_response(struct cell *t,int type,struct tmcb_params *ps);
More information about the sr-users
mailing list