- added instance and reg_id fields to branch_t
- added instance and reg_id arguments to append_branch function
- modified append_branch calls in core and several modules
- did not touch obsolete or modules_s modules (which are to be
removed from next release)
... | ... |
@@ -507,8 +507,9 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg) |
507 | 507 |
} |
508 | 508 |
getbflagsval(0, (flag_t*)&flags); |
509 | 509 |
ret=append_branch(msg, &a->val[0].u.str, &msg->dst_uri, |
510 |
- &msg->path_vec, a->val[1].u.number, |
|
511 |
- (flag_t)flags, msg->force_send_socket); |
|
510 |
+ &msg->path_vec, a->val[1].u.number, |
|
511 |
+ (flag_t)flags, msg->force_send_socket, |
|
512 |
+ 0, 0); |
|
512 | 513 |
/* if the uri is the ruri and q was also not changed, mark |
513 | 514 |
ruri as consumed, to avoid having an identical branch */ |
514 | 515 |
if ((a->val[0].u.str.s == 0 || a->val[0].u.str.len == 0) && |
... | ... |
@@ -73,6 +73,8 @@ |
73 | 73 |
|
74 | 74 |
#define MAX_PATH_SIZE 256 /*!< Maximum length of path header buffer */ |
75 | 75 |
|
76 |
+#define MAX_INSTANCE_SIZE 256 /*!< Maximum length of +sip.instance contact header param value buffer */ |
|
77 |
+ |
|
76 | 78 |
#define MY_VIA "Via: SIP/2.0/UDP " |
77 | 79 |
#define MY_VIA_LEN (sizeof(MY_VIA) - 1) |
78 | 80 |
|
... | ... |
@@ -85,11 +87,11 @@ |
85 | 85 |
#define CONTENT_LENGTH "Content-Length: " |
86 | 86 |
#define CONTENT_LENGTH_LEN (sizeof(CONTENT_LENGTH)-1) |
87 | 87 |
|
88 |
-#define USER_AGENT "User-Agent: " NAME \ |
|
88 |
+#define USER_AGENT "User-Agent: OpenXg SIP Proxy "\ |
|
89 | 89 |
" (" VERSION " (" ARCH "/" OS_QUOTED "))" |
90 | 90 |
#define USER_AGENT_LEN (sizeof(USER_AGENT)-1) |
91 | 91 |
|
92 |
-#define SERVER_HDR "Server: " NAME \ |
|
92 |
+#define SERVER_HDR "Server: OpenXg SIP Proxy "\ |
|
93 | 93 |
" (" VERSION " (" ARCH "/" OS_QUOTED "))" |
94 | 94 |
#define SERVER_HDR_LEN (sizeof(SERVER_HDR)-1) |
95 | 95 |
|
... | ... |
@@ -214,8 +214,8 @@ void set_branch_iterator(int n) |
214 | 214 |
* more branches |
215 | 215 |
*/ |
216 | 216 |
char* get_branch(unsigned int i, int* len, qvalue_t* q, str* dst_uri, |
217 |
- str* path, unsigned int *flags, |
|
218 |
- struct socket_info** force_socket) |
|
217 |
+ str* path, unsigned int *flags, |
|
218 |
+ struct socket_info** force_socket) |
|
219 | 219 |
{ |
220 | 220 |
if (i < nr_branches) { |
221 | 221 |
*len = branches[i].len; |
... | ... |
@@ -258,12 +258,12 @@ char* get_branch(unsigned int i, int* len, qvalue_t* q, str* dst_uri, |
258 | 258 |
* 0 is returned if there are no more branches |
259 | 259 |
*/ |
260 | 260 |
char* next_branch(int* len, qvalue_t* q, str* dst_uri, str* path, |
261 |
- unsigned int* flags, struct socket_info** force_socket) |
|
261 |
+ unsigned int* flags, struct socket_info** force_socket) |
|
262 | 262 |
{ |
263 | 263 |
char* ret; |
264 | 264 |
|
265 | 265 |
ret=get_branch(branch_iterator, len, q, dst_uri, path, flags, |
266 |
- force_socket); |
|
266 |
+ force_socket); |
|
267 | 267 |
if (likely(ret)) |
268 | 268 |
branch_iterator++; |
269 | 269 |
return ret; |
... | ... |
@@ -295,7 +295,9 @@ void clear_branches(void) |
295 | 295 |
* @return <0 (-1) on failure, 1 on success (script convention). |
296 | 296 |
*/ |
297 | 297 |
int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path, |
298 |
- qvalue_t q, unsigned int flags, struct socket_info* force_socket) |
|
298 |
+ qvalue_t q, unsigned int flags, |
|
299 |
+ struct socket_info* force_socket, |
|
300 |
+ str* instance, unsigned int reg_id) |
|
299 | 301 |
{ |
300 | 302 |
str luri; |
301 | 303 |
|
... | ... |
@@ -360,6 +362,25 @@ int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path, |
360 | 360 |
branches[nr_branches].force_send_socket = force_socket; |
361 | 361 |
branches[nr_branches].flags = flags; |
362 | 362 |
|
363 |
+ /* copy instance string */ |
|
364 |
+ if (unlikely(instance && instance->len && instance->s)) { |
|
365 |
+ if (unlikely(instance->len > MAX_INSTANCE_SIZE - 1)) { |
|
366 |
+ LOG(L_ERR, "too long instance: %.*s\n", |
|
367 |
+ instance->len, instance->s); |
|
368 |
+ return -1; |
|
369 |
+ } |
|
370 |
+ memcpy(branches[nr_branches].instance, instance->s, |
|
371 |
+ instance->len); |
|
372 |
+ branches[nr_branches].instance[instance->len] = 0; |
|
373 |
+ branches[nr_branches].instance_len = instance->len; |
|
374 |
+ } else { |
|
375 |
+ branches[nr_branches].instance[0] = '\0'; |
|
376 |
+ branches[nr_branches].instance_len = 0; |
|
377 |
+ } |
|
378 |
+ |
|
379 |
+ /* copy reg_id */ |
|
380 |
+ branches[nr_branches].reg_id = reg_id; |
|
381 |
+ |
|
363 | 382 |
nr_branches++; |
364 | 383 |
return 1; |
365 | 384 |
} |
... | ... |
@@ -59,6 +59,13 @@ struct branch |
59 | 59 |
* contact within the array */ |
60 | 60 |
struct socket_info* force_send_socket; |
61 | 61 |
|
62 |
+ /* +sip.instance contact header param value */ |
|
63 |
+ char instance[MAX_INSTANCE_SIZE]; |
|
64 |
+ unsigned int instance_len; |
|
65 |
+ |
|
66 |
+ /* reg-id contact header param value */ |
|
67 |
+ unsigned int reg_id; |
|
68 |
+ |
|
62 | 69 |
/* Branch flags */ |
63 | 70 |
flag_t flags; |
64 | 71 |
}; |
... | ... |
@@ -79,29 +86,30 @@ int drop_sip_branch(int idx); |
79 | 79 |
* Add a new branch to current transaction |
80 | 80 |
*/ |
81 | 81 |
int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path, |
82 |
- qvalue_t q, unsigned int flags, |
|
83 |
- struct socket_info* force_socket); |
|
82 |
+ qvalue_t q, unsigned int flags, |
|
83 |
+ struct socket_info* force_socket, |
|
84 |
+ str* instance, unsigned int reg_id); |
|
84 | 85 |
|
85 | 86 |
/*! \brief kamailio compatible version */ |
86 | 87 |
#define km_append_branch(msg, uri, dst_uri, path, q, flags, force_socket) \ |
87 |
- append_branch(msg, uri, dst_uri, path, q, flags, force_socket) |
|
88 |
+ append_branch(msg, uri, dst_uri, path, q, flags, force_socket, 0, 0); |
|
88 | 89 |
|
89 | 90 |
/*! \brief ser compatible append_branch version. |
90 | 91 |
* append_branch version compatible with ser: no path or branch flags support |
91 | 92 |
* and no str parameters. |
92 | 93 |
*/ |
93 | 94 |
static inline int ser_append_branch(struct sip_msg* msg, |
94 |
- char* uri, int uri_len, |
|
95 |
- char* dst_uri, int dst_uri_len, |
|
96 |
- qvalue_t q, |
|
97 |
- struct socket_info* force_socket) |
|
95 |
+ char* uri, int uri_len, |
|
96 |
+ char* dst_uri, int dst_uri_len, |
|
97 |
+ qvalue_t q, |
|
98 |
+ struct socket_info* force_socket) |
|
98 | 99 |
{ |
99 |
- str s_uri, s_dst_uri; |
|
100 |
- s_uri.s=uri; |
|
101 |
- s_uri.len=uri_len; |
|
102 |
- s_dst_uri.s=dst_uri; |
|
103 |
- s_dst_uri.len=dst_uri_len; |
|
104 |
- return append_branch(msg, &s_uri, &s_dst_uri, 0, q, 0, force_socket); |
|
100 |
+ str s_uri, s_dst_uri; |
|
101 |
+ s_uri.s=uri; |
|
102 |
+ s_uri.len=uri_len; |
|
103 |
+ s_dst_uri.s=dst_uri; |
|
104 |
+ s_dst_uri.len=dst_uri_len; |
|
105 |
+ return append_branch(msg, &s_uri, &s_dst_uri, 0, q, 0, force_socket, 0, 0); |
|
105 | 106 |
} |
106 | 107 |
|
107 | 108 |
|
... | ... |
@@ -126,14 +134,11 @@ void set_branch_iterator(int n); |
126 | 126 |
* *len) or 0 if there are no more branches. |
127 | 127 |
*/ |
128 | 128 |
char* next_branch(int* len, qvalue_t* q, str* dst_uri, str* path, |
129 |
- unsigned int* flags, struct socket_info** force_socket); |
|
130 |
- |
|
129 |
+ unsigned int* flags, struct socket_info** force_socket); |
|
131 | 130 |
|
132 | 131 |
char* get_branch( unsigned int i, int* len, qvalue_t* q, str* dst_uri, |
133 |
- str* path, unsigned int *flags, |
|
134 |
- struct socket_info** force_socket); |
|
135 |
- |
|
136 |
- |
|
132 |
+ str* path, unsigned int *flags, |
|
133 |
+ struct socket_info** force_socket); |
|
137 | 134 |
|
138 | 135 |
/*! \brief |
139 | 136 |
* Empty the array of branches |
... | ... |
@@ -998,7 +998,8 @@ int ops_pushto_avp (struct sip_msg* msg, struct fis_param* dst, |
998 | 998 |
{ |
999 | 999 |
/* if is not the first modification, push the current uri as |
1000 | 1000 |
* branch */ |
1001 |
- if (append_branch( msg, 0, 0, 0, Q_UNSPECIFIED, 0, 0)!=1 ) |
|
1001 |
+ if (append_branch( msg, 0, 0, 0, Q_UNSPECIFIED, |
|
1002 |
+ 0, 0, 0, 0) != 1) |
|
1002 | 1003 |
{ |
1003 | 1004 |
LM_ERR("append_branch action failed\n"); |
1004 | 1005 |
goto error; |
... | ... |
@@ -1025,7 +1026,7 @@ int ops_pushto_avp (struct sip_msg* msg, struct fis_param* dst, |
1025 | 1025 |
ruri_mark_new(); /* re-use uri for serial forking */ |
1026 | 1026 |
} else if (dst->opd&AVPOPS_USE_BRANCH) { |
1027 | 1027 |
if (append_branch( msg, &val, 0, 0, Q_UNSPECIFIED, 0, |
1028 |
- msg->force_send_socket)!=1 ) |
|
1028 |
+ msg->force_send_socket, 0, 0) != 1) |
|
1029 | 1029 |
{ |
1030 | 1030 |
LM_ERR("append_branch action failed\n"); |
1031 | 1031 |
goto error; |
... | ... |
@@ -70,8 +70,8 @@ int corex_append_branch(sip_msg_t *msg, gparam_t *pu, gparam_t *pq) |
70 | 70 |
|
71 | 71 |
getbflagsval(0, &branch_flags); |
72 | 72 |
ret = append_branch(msg, (uri.len>0)?&uri:0, &msg->dst_uri, |
73 |
- &msg->path_vec, q, branch_flags, |
|
74 |
- msg->force_send_socket); |
|
73 |
+ &msg->path_vec, q, branch_flags, |
|
74 |
+ msg->force_send_socket, 0, 0); |
|
75 | 75 |
|
76 | 76 |
|
77 | 77 |
if(uri.len<=0) |
... | ... |
@@ -295,7 +295,7 @@ static int dp_update(struct sip_msg * msg, pv_spec_t * src, pv_spec_t * dest, |
295 | 295 |
|
296 | 296 |
if(is_route_type(FAILURE_ROUTE) |
297 | 297 |
&& (dest->type==PVT_RURI || dest->type==PVT_RURI_USERNAME)) { |
298 |
- if (append_branch(msg, 0, 0, 0, Q_UNSPECIFIED, 0, 0)!=1 ){ |
|
298 |
+ if (append_branch(msg, 0, 0, 0, Q_UNSPECIFIED, 0, 0, 0, 0) != 1) { |
|
299 | 299 |
LM_ERR("append_branch action failed\n"); |
300 | 300 |
return -1; |
301 | 301 |
} |
... | ... |
@@ -687,7 +687,7 @@ int do_query(struct sip_msg* _msg, char *user, char *name, str *service) { |
687 | 687 |
q = q - 10; |
688 | 688 |
curr_prio = priority; |
689 | 689 |
} |
690 |
- if (append_branch(_msg, &result, 0, 0, q, 0, 0) == -1) { |
|
690 |
+ if (append_branch(_msg, &result, 0, 0, q, 0, 0, 0, 0) == -1) { |
|
691 | 691 |
goto done; |
692 | 692 |
} |
693 | 693 |
} |
... | ... |
@@ -1137,7 +1137,8 @@ int enum_pv_query_3(struct sip_msg* _msg, char* _sp, char* _suffix, |
1137 | 1137 |
q = q - 10; |
1138 | 1138 |
curr_prio = priority; |
1139 | 1139 |
} |
1140 |
- if (append_branch(_msg, &result, 0, 0, q, 0, 0) == -1) { |
|
1140 |
+ if (append_branch(_msg, &result, 0, 0, q, 0, 0, 0, 0) |
|
1141 |
+ == -1) { |
|
1141 | 1142 |
goto done; |
1142 | 1143 |
} |
1143 | 1144 |
} |
... | ... |
@@ -444,7 +444,7 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value) |
444 | 444 |
return -1; |
445 | 445 |
} |
446 | 446 |
|
447 |
- if (append_branch(msg, &uri, &dst, &path, 0, flags, sock) != 1) { |
|
447 |
+ if (append_branch(msg, &uri, &dst, &path, 0, flags, sock, 0, 0) != 1) { |
|
448 | 448 |
LM_ERR("appending branch failed\n"); |
449 | 449 |
destroy_avp(avp); |
450 | 450 |
return -1; |
... | ... |
@@ -201,7 +201,8 @@ int alias_db_lookup(struct sip_msg* _msg, str table_s) |
201 | 201 |
break; |
202 | 202 |
} else { |
203 | 203 |
user_s.s = useruri_buf; |
204 |
- if (append_branch(_msg, &user_s, 0, 0, MIN_Q, 0, 0) == -1) |
|
204 |
+ if (append_branch(_msg, &user_s, 0, 0, MIN_Q, 0, 0, |
|
205 |
+ 0, 0) == -1) |
|
205 | 206 |
{ |
206 | 207 |
LM_ERR("error while appending branches\n"); |
207 | 208 |
goto err_server; |
... | ... |
@@ -90,9 +90,11 @@ int cpl_proxy_to_loc_set( struct sip_msg *msg, struct location **locs, |
90 | 90 |
bflags = ((*locs)->flags&CPL_LOC_NATED) ? cpl_fct.ulb.nat_flag : 0 ; |
91 | 91 |
LM_DBG("appending branch <%.*s>, flags %d\n", |
92 | 92 |
(*locs)->addr.uri.len, (*locs)->addr.uri.s, bflags); |
93 |
- if(append_branch(msg, &(*locs)->addr.uri, &(*locs)->addr.received, 0, |
|
94 |
- Q_UNSPECIFIED, bflags, 0)==-1){ |
|
95 |
- LM_ERR("failed when appending branch <%s>\n",(*locs)->addr.uri.s); |
|
93 |
+ if(append_branch(msg, &(*locs)->addr.uri, |
|
94 |
+ &(*locs)->addr.received, 0, |
|
95 |
+ Q_UNSPECIFIED, bflags, 0, 0, 0)==-1){ |
|
96 |
+ LM_ERR("failed when appending branch <%s>\n", |
|
97 |
+ (*locs)->addr.uri.s); |
|
96 | 98 |
goto error; |
97 | 99 |
} |
98 | 100 |
/* free the location and point to the next one */ |
... | ... |
@@ -167,7 +167,8 @@ int exec_str(struct sip_msg *msg, char *cmd, char *param, int param_len) { |
167 | 167 |
goto error02; |
168 | 168 |
} |
169 | 169 |
} else { |
170 |
- if (append_branch(msg, &uri, 0, 0, Q_UNSPECIFIED, 0, 0)==-1) { |
|
170 |
+ if (append_branch(msg, &uri, 0, 0, Q_UNSPECIFIED, 0, 0, |
|
171 |
+ 0, 0) == -1) { |
|
171 | 172 |
LM_ERR("append_branch failed; too many or too long URIs?\n"); |
172 | 173 |
goto error02; |
173 | 174 |
} |