Browse code

modules/registrar: store user-agent string retrieved from usrloc in msg and branch structures

Peter Dunkley authored on 17/05/2013 23:15:21
Showing 3 changed files
... ...
@@ -280,6 +280,13 @@ int lookup(struct sip_msg* _m, udomain_t* _d, str* _uri)
280 280
 		    }
281 281
 		}
282 282
 
283
+		if (ptr->user_agent.len) {
284
+		    if (set_ua(_m, &(ptr->user_agent)) < 0) {
285
+				ret = -3;
286
+				goto done;
287
+		    }
288
+		}
289
+
283 290
 		set_ruri_q(ptr->q);
284 291
 
285 292
 		old_bflags = 0;
... ...
@@ -324,7 +331,7 @@ int lookup(struct sip_msg* _m, udomain_t* _d, str* _uri)
324 324
 					  ptr->sock,
325 325
 					  ptr->instance.len?&(ptr->instance):0,
326 326
 				          ptr->instance.len?ptr->reg_id:0,
327
-					  &ptr->ruid)
327
+					  &ptr->ruid, &ptr->user_agent)
328 328
 			    == -1) {
329 329
 				LM_ERR("failed to append a branch\n");
330 330
 				/* Also give a chance to the next branches*/
... ...
@@ -360,6 +367,7 @@ int reset_ruri_branch(sip_msg_t *msg)
360 360
 	reset_instance(msg);
361 361
 	msg->reg_id = 0;
362 362
 	reset_ruid(msg);
363
+	reset_ua(msg);
363 364
 	return 0;
364 365
 }
365 366
 
... ...
@@ -385,6 +393,7 @@ int lookup_branches(sip_msg_t *msg, udomain_t *d)
385 385
 	str ruri_b_instance = {0};
386 386
 	unsigned int ruri_b_reg_id = 0;
387 387
 	str ruri_b_ruid = {0};
388
+	str ruri_b_ua = {0};
388 389
 	branch_t *crt = NULL;
389 390
 
390 391
 	ret = 1;
... ...
@@ -410,6 +419,7 @@ int lookup_branches(sip_msg_t *msg, udomain_t *d)
410 410
 	ruri_b_instance = msg->instance;
411 411
 	ruri_b_reg_id = msg->reg_id;
412 412
 	ruri_b_ruid = msg->ruid;
413
+	ruri_b_ua = msg->location_ua;
413 414
 	reset_ruri_branch(msg);
414 415
 
415 416
 	for(i=0; i<nr_branches_start; i++) {
... ...
@@ -490,6 +500,7 @@ done:
490 490
 	msg->instance = ruri_b_instance;
491 491
 	msg->reg_id = ruri_b_reg_id;
492 492
 	msg->ruid = ruri_b_ruid;
493
+	msg->location_ua = ruri_b_ua;
493 494
 
494 495
 	return (found)?1:ret;
495 496
 }
... ...
@@ -56,7 +56,6 @@
56 56
 #define USERNAME_MAX_SIZE      64
57 57
 #define DOMAIN_MAX_SIZE        128
58 58
 #define CALLID_MAX_SIZE        255
59
-#define UA_MAX_SIZE            255
60 59
 
61 60
 #define PATH_MODE_STRICT	2
62 61
 #define PATH_MODE_LAZY		1
... ...
@@ -265,7 +265,7 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t* _c, unsig
265 265
 
266 266
 		/* additional info from message */
267 267
 		if (parse_headers(_m, HDR_USERAGENT_F, 0) != -1 && _m->user_agent &&
268
-		_m->user_agent->body.len>0 && _m->user_agent->body.len<UA_MAX_SIZE) {
268
+		_m->user_agent->body.len>0 && _m->user_agent->body.len<MAX_UA_SIZE) {
269 269
 			ci.user_agent = &_m->user_agent->body;
270 270
 		} else {
271 271
 			ci.user_agent = &no_ua;