[sr-dev] git:master: registrar: option to take the socket from an xavp
Daniel-Constantin Mierla
miconda at gmail.com
Mon Sep 30 15:55:25 CEST 2013
Module: sip-router
Branch: master
Commit: 308f2920df586065e0bf8ef02d7c77b1c94a4836
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=308f2920df586065e0bf8ef02d7c77b1c94a4836
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: Mon Sep 30 15:49:10 2013 +0200
registrar: option to take the socket from an xavp
- child named "socket" of xavp named by xavp_cfg parameter
---
modules/registrar/save.c | 55 +++++++++++++++++++++++++++++----------------
1 files changed, 35 insertions(+), 20 deletions(-)
diff --git a/modules/registrar/save.c b/modules/registrar/save.c
index fc4a60a..de6610e 100644
--- a/modules/registrar/save.c
+++ b/modules/registrar/save.c
@@ -134,37 +134,50 @@ static inline int star(sip_msg_t *_m, udomain_t* _d, str* _a, str *_h)
/*! \brief
*/
-static struct socket_info *get_sock_hdr(struct sip_msg *msg)
+static struct socket_info *get_sock_val(struct sip_msg *msg)
{
struct socket_info *sock;
struct hdr_field *hf;
+ str xsockname = str_init("socket");
+ sr_xavp_t *vavp = NULL;
str socks;
str hosts;
int port;
int proto;
char c;
- if (parse_headers( msg, HDR_EOH_F, 0) == -1) {
- LM_ERR("failed to parse message\n");
- return 0;
- }
+ if(sock_hdr_name.len>0) {
+ if (parse_headers( msg, HDR_EOH_F, 0) == -1) {
+ LM_ERR("failed to parse message\n");
+ return 0;
+ }
- for (hf=msg->headers; hf; hf=hf->next) {
- if (cmp_hdrname_str(&hf->name, &sock_hdr_name)==0)
- break;
- }
+ for (hf=msg->headers; hf; hf=hf->next) {
+ if (cmp_hdrname_str(&hf->name, &sock_hdr_name)==0)
+ break;
+ }
- /* hdr found? */
- if (hf==0)
- return 0;
+ /* hdr found? */
+ if (hf==0)
+ return 0;
- trim_len( socks.len, socks.s, hf->body );
- if (socks.len==0)
- return 0;
+ trim_len( socks.len, socks.s, hf->body );
+ if (socks.len==0)
+ return 0;
- /*FIXME: This is a hack */
- c = socks.s[socks.len];
- socks.s[socks.len] = '\0';
+ /*FIXME: This is a hack */
+ c = socks.s[socks.len];
+ socks.s[socks.len] = '\0';
+ } else {
+ /* xavp */
+ if(reg_xavp_cfg.s!=NULL)
+ {
+ vavp = xavp_get_child_with_sval(®_xavp_cfg, &xsockname);
+ if(vavp==NULL || vavp->val.v.s.len<=0)
+ return 0;
+ }
+ socks = vavp->val.v.s;
+ }
if (parse_phostport( socks.s, &hosts.s, &hosts.len,
&port, &proto)!=0) {
socks.s[socks.len] = c;
@@ -172,7 +185,9 @@ static struct socket_info *get_sock_hdr(struct sip_msg *msg)
socks.len, socks.s);
return 0;
}
- socks.s[socks.len] = c;
+ if(sock_hdr_name.len>0) {
+ socks.s[socks.len] = c;
+ }
sock = grep_sock_info(&hosts,(unsigned short)port,(unsigned short)proto);
if (sock==0) {
LM_ERR("non-local socket <%.*s>\n", socks.len, socks.s);
@@ -256,7 +271,7 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t* _c, unsig
/* set received socket */
if (_m->flags&sock_flag) {
- ci.sock = get_sock_hdr(_m);
+ ci.sock = get_sock_val(_m);
if (ci.sock==0)
ci.sock = _m->rcv.bind_address;
} else {
More information about the sr-dev
mailing list