Module: sip-router
Branch: master
Commit: 5aeef2c932581a67d535ade10995cc35ff85640a
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5aeef2c…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Sat May 18 00:15:21 2013 +0100
modules/registrar: store user-agent string retrieved from usrloc in msg and branch
structures
---
modules/registrar/lookup.c | 13 ++++++++++++-
modules/registrar/reg_mod.h | 1 -
modules/registrar/save.c | 2 +-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/modules/registrar/lookup.c b/modules/registrar/lookup.c
index f3f74a2..be08056 100644
--- a/modules/registrar/lookup.c
+++ b/modules/registrar/lookup.c
@@ -280,6 +280,13 @@ int lookup(struct sip_msg* _m, udomain_t* _d, str* _uri)
}
}
+ if (ptr->user_agent.len) {
+ if (set_ua(_m, &(ptr->user_agent)) < 0) {
+ ret = -3;
+ goto done;
+ }
+ }
+
set_ruri_q(ptr->q);
old_bflags = 0;
@@ -324,7 +331,7 @@ int lookup(struct sip_msg* _m, udomain_t* _d, str* _uri)
ptr->sock,
ptr->instance.len?&(ptr->instance):0,
ptr->instance.len?ptr->reg_id:0,
- &ptr->ruid)
+ &ptr->ruid, &ptr->user_agent)
== -1) {
LM_ERR("failed to append a branch\n");
/* Also give a chance to the next branches*/
@@ -360,6 +367,7 @@ int reset_ruri_branch(sip_msg_t *msg)
reset_instance(msg);
msg->reg_id = 0;
reset_ruid(msg);
+ reset_ua(msg);
return 0;
}
@@ -385,6 +393,7 @@ int lookup_branches(sip_msg_t *msg, udomain_t *d)
str ruri_b_instance = {0};
unsigned int ruri_b_reg_id = 0;
str ruri_b_ruid = {0};
+ str ruri_b_ua = {0};
branch_t *crt = NULL;
ret = 1;
@@ -410,6 +419,7 @@ int lookup_branches(sip_msg_t *msg, udomain_t *d)
ruri_b_instance = msg->instance;
ruri_b_reg_id = msg->reg_id;
ruri_b_ruid = msg->ruid;
+ ruri_b_ua = msg->location_ua;
reset_ruri_branch(msg);
for(i=0; i<nr_branches_start; i++) {
@@ -490,6 +500,7 @@ done:
msg->instance = ruri_b_instance;
msg->reg_id = ruri_b_reg_id;
msg->ruid = ruri_b_ruid;
+ msg->location_ua = ruri_b_ua;
return (found)?1:ret;
}
diff --git a/modules/registrar/reg_mod.h b/modules/registrar/reg_mod.h
index 0ba6866..6992233 100644
--- a/modules/registrar/reg_mod.h
+++ b/modules/registrar/reg_mod.h
@@ -56,7 +56,6 @@
#define USERNAME_MAX_SIZE 64
#define DOMAIN_MAX_SIZE 128
#define CALLID_MAX_SIZE 255
-#define UA_MAX_SIZE 255
#define PATH_MODE_STRICT 2
#define PATH_MODE_LAZY 1
diff --git a/modules/registrar/save.c b/modules/registrar/save.c
index bef5285..020358f 100644
--- a/modules/registrar/save.c
+++ b/modules/registrar/save.c
@@ -265,7 +265,7 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t*
_c, unsig
/* additional info from message */
if (parse_headers(_m, HDR_USERAGENT_F, 0) != -1 && _m->user_agent
&&
- _m->user_agent->body.len>0 &&
_m->user_agent->body.len<UA_MAX_SIZE) {
+ _m->user_agent->body.len>0 &&
_m->user_agent->body.len<MAX_UA_SIZE) {
ci.user_agent = &_m->user_agent->body;
} else {
ci.user_agent = &no_ua;