|
@@ -1,5 +1,5 @@
|
|
/*
|
|
/*
|
|
- * transaction maintenance functions
|
|
|
|
|
|
+ * tm - transaction management module
|
|
*
|
|
*
|
|
* Copyright (C) 2001-2003 FhG Fokus
|
|
* Copyright (C) 2001-2003 FhG Fokus
|
|
*
|
|
*
|
|
@@ -15,8 +15,8 @@
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
* GNU General Public License for more details.
|
|
*
|
|
*
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
|
- * along with this program; if not, write to the Free Software
|
|
|
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
|
+ * along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
@@ -65,7 +65,7 @@
|
|
/* solaris doesn't have SUN_LEN */
|
|
/* solaris doesn't have SUN_LEN */
|
|
#ifndef SUN_LEN
|
|
#ifndef SUN_LEN
|
|
#define SUN_LEN(sa) ( strlen((sa)->sun_path) + \
|
|
#define SUN_LEN(sa) ( strlen((sa)->sun_path) + \
|
|
- (size_t)(((struct sockaddr_un*)0)->sun_path) )
|
|
|
|
|
|
+ (size_t)(((struct sockaddr_un*)0)->sun_path) )
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
|
|
@@ -77,7 +77,7 @@
|
|
#define eol_line_len(_i_) ( iov_lines_eol[2*(_i_)].iov_len )
|
|
#define eol_line_len(_i_) ( iov_lines_eol[2*(_i_)].iov_len )
|
|
|
|
|
|
#define eol_line(_i_,_s_) { eol_line_s(_i_) = (_s_).s; \
|
|
#define eol_line(_i_,_s_) { eol_line_s(_i_) = (_s_).s; \
|
|
- eol_line_len(_i_) = (_s_).len; }
|
|
|
|
|
|
+ eol_line_len(_i_) = (_s_).len; }
|
|
|
|
|
|
#define IDBUF_LEN 128
|
|
#define IDBUF_LEN 128
|
|
#define ROUTE_BUFFER_MAX 512
|
|
#define ROUTE_BUFFER_MAX 512
|
|
@@ -87,7 +87,7 @@
|
|
#define copy_route(s,len,rs,rlen) \
|
|
#define copy_route(s,len,rs,rlen) \
|
|
do {\
|
|
do {\
|
|
if(rlen+len+3 >= ROUTE_BUFFER_MAX){\
|
|
if(rlen+len+3 >= ROUTE_BUFFER_MAX){\
|
|
- LOG(L_ERR,"vm: buffer overflow while copying new route\n");\
|
|
|
|
|
|
+ LM_ERR("buffer overflow while copying new route\n");\
|
|
goto error;\
|
|
goto error;\
|
|
}\
|
|
}\
|
|
if(len){\
|
|
if(len){\
|
|
@@ -148,20 +148,20 @@ static void print_tw_append( struct tw_append *append)
|
|
if (!append)
|
|
if (!append)
|
|
return;
|
|
return;
|
|
|
|
|
|
- DBG("DEBUG:tm:print_tw_append: tw_append name=<%.*s>\n",
|
|
|
|
|
|
+ LM_DBG("tw_append name=<%.*s>\n",
|
|
append->name.len,append->name.s);
|
|
append->name.len,append->name.s);
|
|
for( ha=append->elems ; ha ; ha=ha->next ) {
|
|
for( ha=append->elems ; ha ; ha=ha->next ) {
|
|
- DBG("\ttitle=<%.*s>\n",ha->title.len,ha->title.s);
|
|
|
|
- DBG("\t\tttype=<%d>\n",ha->type);
|
|
|
|
- DBG("\t\tsval=<%.*s>\n",ha->sval.len,ha->sval.s);
|
|
|
|
- DBG("\t\tival=<%d>\n",ha->ival);
|
|
|
|
|
|
+ LM_DBG("\ttitle=<%.*s>\n",ha->title.len,ha->title.s);
|
|
|
|
+ LM_DBG("\t\tttype=<%d>\n",ha->type);
|
|
|
|
+ LM_DBG("\t\tsval=<%.*s>\n",ha->sval.len,ha->sval.s);
|
|
|
|
+ LM_DBG("\t\tival=<%d>\n",ha->ival);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/* tw_append syntax:
|
|
/* tw_append syntax:
|
|
* tw_append = name:element[;element]
|
|
* tw_append = name:element[;element]
|
|
- * element = [title=]value
|
|
|
|
|
|
+ * element = [title=]value
|
|
* value = avp[avp_spec] | hdr[hdr_name] | msg[body] */
|
|
* value = avp[avp_spec] | hdr[hdr_name] | msg[body] */
|
|
int parse_tw_append( modparam_t type, void* val)
|
|
int parse_tw_append( modparam_t type, void* val)
|
|
{
|
|
{
|
|
@@ -175,7 +175,7 @@ int parse_tw_append( modparam_t type, void* val)
|
|
str foo;
|
|
str foo;
|
|
int n;
|
|
int n;
|
|
int index;
|
|
int index;
|
|
-
|
|
|
|
|
|
+
|
|
if (val==0 || ((char*)val)[0]==0)
|
|
if (val==0 || ((char*)val)[0]==0)
|
|
return 0;
|
|
return 0;
|
|
s = (char*)val;
|
|
s = (char*)val;
|
|
@@ -201,20 +201,19 @@ int parse_tw_append( modparam_t type, void* val)
|
|
/* check for name duplication */
|
|
/* check for name duplication */
|
|
for(app=tw_appends;app;app=app->next)
|
|
for(app=tw_appends;app;app=app->next)
|
|
if (app->name.len==foo.len && !strncasecmp(app->name.s,foo.s,foo.len)){
|
|
if (app->name.len==foo.len && !strncasecmp(app->name.s,foo.s,foo.len)){
|
|
- LOG(L_ERR,"ERROR:tm:parse_tw_append: duplicated tw_append name "
|
|
|
|
- "<%.*s>\n",foo.len,foo.s);
|
|
|
|
|
|
+ LM_ERR("duplicated tw_append name <%.*s>\n",foo.len,foo.s);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
/* new tw_append structure */
|
|
/* new tw_append structure */
|
|
app = (struct tw_append*)pkg_malloc( sizeof(struct tw_append) );
|
|
app = (struct tw_append*)pkg_malloc( sizeof(struct tw_append) );
|
|
if (app==0) {
|
|
if (app==0) {
|
|
- LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg memory\n");
|
|
|
|
|
|
+ LM_ERR("no more pkg memory\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
app->name.s = (char*)pkg_malloc( foo.len+1 );
|
|
app->name.s = (char*)pkg_malloc( foo.len+1 );
|
|
if (app->name.s==0) {
|
|
if (app->name.s==0) {
|
|
- LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg memory\n");
|
|
|
|
|
|
+ LM_ERR("no more pkg memory\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
memcpy( app->name.s, foo.s, foo.len);
|
|
memcpy( app->name.s, foo.s, foo.len);
|
|
@@ -235,7 +234,7 @@ int parse_tw_append( modparam_t type, void* val)
|
|
/* new hdr_avp structure */
|
|
/* new hdr_avp structure */
|
|
ha = (struct hdr_avp*)pkg_malloc( sizeof(struct hdr_avp) );
|
|
ha = (struct hdr_avp*)pkg_malloc( sizeof(struct hdr_avp) );
|
|
if (ha==0) {
|
|
if (ha==0) {
|
|
- LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg memory\n");
|
|
|
|
|
|
+ LM_ERR("no more pkg memory\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
memset( ha, 0, sizeof(struct hdr_avp));
|
|
memset( ha, 0, sizeof(struct hdr_avp));
|
|
@@ -251,7 +250,7 @@ int parse_tw_append( modparam_t type, void* val)
|
|
/* set the title */
|
|
/* set the title */
|
|
ha->title.s = (char*)pkg_malloc( foo.len+1 );
|
|
ha->title.s = (char*)pkg_malloc( foo.len+1 );
|
|
if (ha->title.s==0) {
|
|
if (ha->title.s==0) {
|
|
- LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg memory\n");
|
|
|
|
|
|
+ LM_ERR("no more pkg memory\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
memcpy( ha->title.s, foo.s, foo.len);
|
|
memcpy( ha->title.s, foo.s, foo.len);
|
|
@@ -276,8 +275,7 @@ int parse_tw_append( modparam_t type, void* val)
|
|
!strncasecmp( foo.s, ELEM_TYPE_MSG, foo.len) ) {
|
|
!strncasecmp( foo.s, ELEM_TYPE_MSG, foo.len) ) {
|
|
ha->type = ELEM_IS_MSG;
|
|
ha->type = ELEM_IS_MSG;
|
|
} else {
|
|
} else {
|
|
- LOG(L_ERR,"ERROR:tm:parse_tw_append: unknown type <%.*s>\n",
|
|
|
|
- foo.len, foo.s);
|
|
|
|
|
|
+ LM_ERR("unknown type <%.*s>\n", foo.len, foo.s);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
/* parse the element name */
|
|
/* parse the element name */
|
|
@@ -292,15 +290,14 @@ int parse_tw_append( modparam_t type, void* val)
|
|
if (ha->type==ELEM_IS_AVP) {
|
|
if (ha->type==ELEM_IS_AVP) {
|
|
/* element is AVP */
|
|
/* element is AVP */
|
|
if ( parse_avp_spec( &foo, &n, &avp_name, &index)!=0 ) {
|
|
if ( parse_avp_spec( &foo, &n, &avp_name, &index)!=0 ) {
|
|
- LOG(L_ERR,"ERROR:tm:parse_tw_append: bad alias spec "
|
|
|
|
- "<%.*s>\n",foo.len, foo.s);
|
|
|
|
|
|
+ LM_ERR("bad alias spec <%.*s>\n",foo.len, foo.s);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
if (n&AVP_NAME_STR) {
|
|
if (n&AVP_NAME_STR) {
|
|
/* string name */
|
|
/* string name */
|
|
ha->sval.s = (char*)pkg_malloc(avp_name.s.len+1);
|
|
ha->sval.s = (char*)pkg_malloc(avp_name.s.len+1);
|
|
if (ha->sval.s==0) {
|
|
if (ha->sval.s==0) {
|
|
- LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg mem\n");
|
|
|
|
|
|
+ LM_ERR("no more pkg mem\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
memcpy( ha->sval.s, avp_name.s.s, avp_name.s.len);
|
|
memcpy( ha->sval.s, avp_name.s.s, avp_name.s.len);
|
|
@@ -316,8 +313,7 @@ int parse_tw_append( modparam_t type, void* val)
|
|
foo.s=int2str((unsigned long)ha->ival, &foo.len);
|
|
foo.s=int2str((unsigned long)ha->ival, &foo.len);
|
|
ha->title.s = (char*)pkg_malloc( n+1 );
|
|
ha->title.s = (char*)pkg_malloc( n+1 );
|
|
if (ha->title.s==0) {
|
|
if (ha->title.s==0) {
|
|
- LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg "
|
|
|
|
- "memory\n");
|
|
|
|
|
|
+ LM_ERR("no more pkg memory\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
memcpy( ha->title.s, foo.s, foo.len);
|
|
memcpy( ha->title.s, foo.s, foo.len);
|
|
@@ -331,7 +327,7 @@ int parse_tw_append( modparam_t type, void* val)
|
|
foo.s[foo.len] = ':';
|
|
foo.s[foo.len] = ':';
|
|
/* parse header name */
|
|
/* parse header name */
|
|
if (parse_hname2( foo.s, foo.s+foo.len+1, &hdr)==0) {
|
|
if (parse_hname2( foo.s, foo.s+foo.len+1, &hdr)==0) {
|
|
- LOG(L_ERR,"BUG:tm_parse_tw_append: parse header failed\n");
|
|
|
|
|
|
+ LM_ERR("BUG: parse header failed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
foo.s[foo.len] = bar;
|
|
foo.s[foo.len] = bar;
|
|
@@ -340,7 +336,7 @@ int parse_tw_append( modparam_t type, void* val)
|
|
/* duplicate hdr name */
|
|
/* duplicate hdr name */
|
|
ha->sval.s = (char*)pkg_malloc(foo.len+1);
|
|
ha->sval.s = (char*)pkg_malloc(foo.len+1);
|
|
if (ha->sval.s==0) {
|
|
if (ha->sval.s==0) {
|
|
- LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg mem\n");
|
|
|
|
|
|
+ LM_ERR("no more pkg mem\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
memcpy( ha->sval.s, foo.s, foo.len);
|
|
memcpy( ha->sval.s, foo.s, foo.len);
|
|
@@ -353,8 +349,7 @@ int parse_tw_append( modparam_t type, void* val)
|
|
/* element is MSG */
|
|
/* element is MSG */
|
|
if ( !(foo.len==ELEM_VAL_BODY_LEN &&
|
|
if ( !(foo.len==ELEM_VAL_BODY_LEN &&
|
|
!strncasecmp(ELEM_VAL_BODY,foo.s,foo.len)) ) {
|
|
!strncasecmp(ELEM_VAL_BODY,foo.s,foo.len)) ) {
|
|
- LOG(L_ERR,"ERROR:tm:parse_tw_append: unsupported value <%.*s>"
|
|
|
|
- " for msg type\n",foo.len,foo.s);
|
|
|
|
|
|
+ LM_ERR("unsupported value <%.*s> for msg type\n",foo.len,foo.s);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
app->add_body = 1;
|
|
app->add_body = 1;
|
|
@@ -390,8 +385,8 @@ int parse_tw_append( modparam_t type, void* val)
|
|
pkg_free(val);
|
|
pkg_free(val);
|
|
return 0;
|
|
return 0;
|
|
parse_error:
|
|
parse_error:
|
|
- LOG(L_ERR,"ERROR:tm:parse_tw_append: parse error in <%s> around "
|
|
|
|
- "position %ld\n", (char*)val, (long)(s-(char*)val));
|
|
|
|
|
|
+ LM_ERR("parse error in <%s> around position %ld\n",
|
|
|
|
+ (char*)val, (long)(s-(char*)val));
|
|
error:
|
|
error:
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -416,7 +411,7 @@ int fixup_t_write( void** param, int param_no)
|
|
if (param_no==2) {
|
|
if (param_no==2) {
|
|
twi = (struct tw_info*)pkg_malloc( sizeof(struct tw_info) );
|
|
twi = (struct tw_info*)pkg_malloc( sizeof(struct tw_info) );
|
|
if (twi==0) {
|
|
if (twi==0) {
|
|
- LOG(L_ERR,"ERROR:tm:fixup_t_write: no more pkg memory\n");
|
|
|
|
|
|
+ LM_ERR("no more pkg memory\n");
|
|
return E_OUT_OF_MEM;
|
|
return E_OUT_OF_MEM;
|
|
}
|
|
}
|
|
memset( twi, 0 , sizeof(struct tw_info));
|
|
memset( twi, 0 , sizeof(struct tw_info));
|
|
@@ -425,18 +420,17 @@ int fixup_t_write( void** param, int param_no)
|
|
if ( (s=strchr(s,'/'))!=0) {
|
|
if ( (s=strchr(s,'/'))!=0) {
|
|
twi->action.len = s - twi->action.s;
|
|
twi->action.len = s - twi->action.s;
|
|
if (twi->action.len==0) {
|
|
if (twi->action.len==0) {
|
|
- LOG(L_ERR,"ERROR:tm:fixup_t_write: empty action name\n");
|
|
|
|
|
|
+ LM_ERR("empty action name\n");
|
|
return E_CFG;
|
|
return E_CFG;
|
|
}
|
|
}
|
|
s++;
|
|
s++;
|
|
if (*s==0) {
|
|
if (*s==0) {
|
|
- LOG(L_ERR,"ERROR:tm:fixup_t_write: empty append name\n");
|
|
|
|
|
|
+ LM_ERR("empty append name\n");
|
|
return E_CFG;
|
|
return E_CFG;
|
|
}
|
|
}
|
|
twi->append = search_tw_append( s, strlen(s));
|
|
twi->append = search_tw_append( s, strlen(s));
|
|
if (twi->append==0) {
|
|
if (twi->append==0) {
|
|
- LOG(L_ERR,"ERROR:tm:fixup_t_write: unknown append name "
|
|
|
|
- "<%s>\n",s);
|
|
|
|
|
|
+ LM_ERR("unknown append name <%s>\n",s);
|
|
return E_CFG;
|
|
return E_CFG;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -449,32 +443,26 @@ int fixup_t_write( void** param, int param_no)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
int init_twrite_sock(void)
|
|
int init_twrite_sock(void)
|
|
{
|
|
{
|
|
int flags;
|
|
int flags;
|
|
|
|
|
|
sock = socket(PF_LOCAL, SOCK_DGRAM, 0);
|
|
sock = socket(PF_LOCAL, SOCK_DGRAM, 0);
|
|
if (sock == -1) {
|
|
if (sock == -1) {
|
|
- LOG(L_ERR, "init_twrite_sock: Unable to create socket: %s\n", strerror(errno));
|
|
|
|
|
|
+ LM_ERR("unable to create socket: %s\n", strerror(errno));
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
- /* Turn non-blocking mode on */
|
|
|
|
|
|
+ /* Turn non-blocking mode on */
|
|
flags = fcntl(sock, F_GETFL);
|
|
flags = fcntl(sock, F_GETFL);
|
|
if (flags == -1){
|
|
if (flags == -1){
|
|
- LOG(L_ERR, "init_twrite_sock: fcntl failed: %s\n",
|
|
|
|
- strerror(errno));
|
|
|
|
|
|
+ LM_ERR("fcntl failed: %s\n", strerror(errno));
|
|
close(sock);
|
|
close(sock);
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) == -1) {
|
|
if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) == -1) {
|
|
- LOG(L_ERR, "init_twrite_sock: fcntl: set non-blocking failed:"
|
|
|
|
- " %s\n", strerror(errno));
|
|
|
|
|
|
+ LM_ERR("fcntl: set non-blocking failed: %s\n", strerror(errno));
|
|
close(sock);
|
|
close(sock);
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -509,11 +497,9 @@ static int inline write_to_fifo(char *fifo, int cnt )
|
|
if((fd_fifo = open(fifo,O_WRONLY | O_NONBLOCK)) == -1){
|
|
if((fd_fifo = open(fifo,O_WRONLY | O_NONBLOCK)) == -1){
|
|
switch(errno){
|
|
switch(errno){
|
|
case ENXIO:
|
|
case ENXIO:
|
|
- LOG(L_ERR,"ERROR:tm:write_to_fifo: nobody listening on "
|
|
|
|
- " [%s] fifo for reading!\n",fifo);
|
|
|
|
|
|
+ LM_ERR("nobody listening on [%s] fifo for reading!\n",fifo);
|
|
default:
|
|
default:
|
|
- LOG(L_ERR,"ERROR:tm:write_to_fifo: failed to open [%s] "
|
|
|
|
- "fifo : %s\n", fifo, strerror(errno));
|
|
|
|
|
|
+ LM_ERR("failed to open [%s] fifo: %s\n", fifo, strerror(errno));
|
|
}
|
|
}
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
@@ -522,8 +508,7 @@ static int inline write_to_fifo(char *fifo, int cnt )
|
|
repeat:
|
|
repeat:
|
|
if (writev(fd_fifo, iov_lines_eol, 2*cnt)<0) {
|
|
if (writev(fd_fifo, iov_lines_eol, 2*cnt)<0) {
|
|
if (errno!=EINTR) {
|
|
if (errno!=EINTR) {
|
|
- LOG(L_ERR, "ERROR:tm:write_to_fifo: writev failed: %s\n",
|
|
|
|
- strerror(errno));
|
|
|
|
|
|
+ LM_ERR("writev failed: %s\n", strerror(errno));
|
|
close(fd_fifo);
|
|
close(fd_fifo);
|
|
goto error;
|
|
goto error;
|
|
} else {
|
|
} else {
|
|
@@ -532,7 +517,7 @@ repeat:
|
|
}
|
|
}
|
|
close(fd_fifo);
|
|
close(fd_fifo);
|
|
|
|
|
|
- DBG("DEBUG:tm:write_to_fifo: write completed\n");
|
|
|
|
|
|
+ LM_DBG("write completed\n");
|
|
return 1; /* OK */
|
|
return 1; /* OK */
|
|
|
|
|
|
error:
|
|
error:
|
|
@@ -541,7 +526,7 @@ error:
|
|
|
|
|
|
|
|
|
|
static inline char* add2buf(char *buf, char *end, char *title, int title_len,
|
|
static inline char* add2buf(char *buf, char *end, char *title, int title_len,
|
|
- char *value , int value_len)
|
|
|
|
|
|
+ char *value , int value_len)
|
|
{
|
|
{
|
|
if (buf+title_len+value_len+2+1>=end)
|
|
if (buf+title_len+value_len+2+1>=end)
|
|
return 0;
|
|
return 0;
|
|
@@ -556,8 +541,8 @@ static inline char* add2buf(char *buf, char *end, char *title, int title_len,
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static inline char* append2buf( char *buf, int len, struct sip_msg *req,
|
|
|
|
- struct hdr_avp *ha)
|
|
|
|
|
|
+static inline char* append2buf( char *buf, int len, struct sip_msg *req,
|
|
|
|
+ struct hdr_avp *ha)
|
|
{
|
|
{
|
|
struct hdr_field *hdr;
|
|
struct hdr_field *hdr;
|
|
struct usr_avp *avp;
|
|
struct usr_avp *avp;
|
|
@@ -576,11 +561,11 @@ static inline char* append2buf( char *buf, int len, struct sip_msg *req,
|
|
if (ha->sval.s) {
|
|
if (ha->sval.s) {
|
|
avp_name.s=ha->sval;
|
|
avp_name.s=ha->sval;
|
|
avp = search_first_avp( AVP_NAME_STR, avp_name, &avp_val, 0);
|
|
avp = search_first_avp( AVP_NAME_STR, avp_name, &avp_val, 0);
|
|
- DBG("AVP <%.*s>: %p\n",avp_name.s.len, avp_name.s.s, avp);
|
|
|
|
|
|
+ LM_DBG("AVP <%.*s>: %p\n",avp_name.s.len, avp_name.s.s, avp);
|
|
} else {
|
|
} else {
|
|
avp_name.n=ha->ival;
|
|
avp_name.n=ha->ival;
|
|
avp = search_first_avp( 0, avp_name, &avp_val, 0);
|
|
avp = search_first_avp( 0, avp_name, &avp_val, 0);
|
|
- DBG("AVP <%i>: %p\n",avp_name.n,avp);
|
|
|
|
|
|
+ LM_DBG("AVP <%i>: %p\n",avp_name.n,avp);
|
|
}
|
|
}
|
|
if (avp) {
|
|
if (avp) {
|
|
if (avp->flags&AVP_VAL_STR) {
|
|
if (avp->flags&AVP_VAL_STR) {
|
|
@@ -600,7 +585,7 @@ static inline char* append2buf( char *buf, int len, struct sip_msg *req,
|
|
/* parse the HDRs */
|
|
/* parse the HDRs */
|
|
if (!msg_parsed) {
|
|
if (!msg_parsed) {
|
|
if (parse_headers( req, HDR_EOH_F, 0)!=0) {
|
|
if (parse_headers( req, HDR_EOH_F, 0)!=0) {
|
|
- LOG(L_ERR,"ERROR:tm:append2buf: parsing hdrs failed\n");
|
|
|
|
|
|
+ LM_ERR("parsing hdrs failed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
msg_parsed = 1;
|
|
msg_parsed = 1;
|
|
@@ -624,8 +609,7 @@ static inline char* append2buf( char *buf, int len, struct sip_msg *req,
|
|
goto overflow_err;
|
|
goto overflow_err;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- LOG(L_ERR,"BUG:tm:append2buf: unknown element type %d\n",
|
|
|
|
- ha->type);
|
|
|
|
|
|
+ LM_ERR("BUG: unknown element type %d\n", ha->type);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -634,7 +618,7 @@ static inline char* append2buf( char *buf, int len, struct sip_msg *req,
|
|
|
|
|
|
return buf;
|
|
return buf;
|
|
overflow_err:
|
|
overflow_err:
|
|
- LOG(L_ERR,"ERROR:tm:append2buf: overflow -> append exceeded %d len\n",len);
|
|
|
|
|
|
+ LM_ERR("overflow -> append exceeded %d len\n",len);
|
|
error:
|
|
error:
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -660,34 +644,33 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
|
str route, next_hop, append, tmp_s, body, str_uri;
|
|
str route, next_hop, append, tmp_s, body, str_uri;
|
|
|
|
|
|
if(msg->first_line.type != SIP_REQUEST){
|
|
if(msg->first_line.type != SIP_REQUEST){
|
|
- LOG(L_ERR,"assemble_msg: called for something else then"
|
|
|
|
- "a SIP request\n");
|
|
|
|
|
|
+ LM_ERR("called for something else thena SIP request\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
/* parse all -- we will need every header field for a UAS */
|
|
/* parse all -- we will need every header field for a UAS */
|
|
if ( parse_headers(msg, HDR_EOH_F, 0)==-1) {
|
|
if ( parse_headers(msg, HDR_EOH_F, 0)==-1) {
|
|
- LOG(L_ERR,"assemble_msg: parse_headers failed\n");
|
|
|
|
|
|
+ LM_ERR("parse_headers failed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
- /* find index and hash; (the transaction can be safely used due
|
|
|
|
|
|
+ /* find index and hash; (the transaction can be safely used due
|
|
* to refcounting till script completes) */
|
|
* to refcounting till script completes) */
|
|
if( t_get_trans_ident(msg,&hash_index,&label) == -1 ) {
|
|
if( t_get_trans_ident(msg,&hash_index,&label) == -1 ) {
|
|
- LOG(L_ERR,"assemble_msg: t_get_trans_ident failed\n");
|
|
|
|
|
|
+ LM_ERR("assemble_msg: t_get_trans_ident failed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
- /* parse from header */
|
|
|
|
|
|
+ /* parse from header */
|
|
if (msg->from==0 || (msg->from->parsed==0 && parse_from_header(msg)==-1)) {
|
|
if (msg->from==0 || (msg->from->parsed==0 && parse_from_header(msg)==-1)) {
|
|
- LOG(L_ERR,"assemble_msg: while parsing <From:> header\n");
|
|
|
|
|
|
+ LM_ERR("while parsing <From:> header\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
/* parse the RURI (doesn't make any malloc) */
|
|
/* parse the RURI (doesn't make any malloc) */
|
|
msg->parsed_uri_ok = 0; /* force parsing */
|
|
msg->parsed_uri_ok = 0; /* force parsing */
|
|
if (parse_sip_msg_uri(msg)<0) {
|
|
if (parse_sip_msg_uri(msg)<0) {
|
|
- LOG(L_ERR,"assemble_msg: uri has not been parsed\n");
|
|
|
|
|
|
+ LM_ERR("uri has not been parsed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -696,8 +679,7 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
|
str_uri.len = 0;
|
|
str_uri.len = 0;
|
|
if(msg->contact) {
|
|
if(msg->contact) {
|
|
if (msg->contact->parsed==0 && parse_contact(msg->contact)==-1) {
|
|
if (msg->contact->parsed==0 && parse_contact(msg->contact)==-1) {
|
|
- LOG(L_ERR,"assemble_msg: error while parsing "
|
|
|
|
- "<Contact:> header\n");
|
|
|
|
|
|
+ LM_ERR("error while parsing 'Contact' header\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
cb = (contact_body_t*)msg->contact->parsed;
|
|
cb = (contact_body_t*)msg->contact->parsed;
|
|
@@ -723,8 +705,7 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
|
p_hdr = msg->record_route;
|
|
p_hdr = msg->record_route;
|
|
if(p_hdr) {
|
|
if(p_hdr) {
|
|
if (p_hdr->parsed==0 && parse_rr(p_hdr)!=0 ) {
|
|
if (p_hdr->parsed==0 && parse_rr(p_hdr)!=0 ) {
|
|
- LOG(L_ERR,"assemble_msg: while parsing "
|
|
|
|
- "'Record-Route:' header\n");
|
|
|
|
|
|
+ LM_ERR("while parsing 'Record-Route' header\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
record_route = (rr_t*)p_hdr->parsed;
|
|
record_route = (rr_t*)p_hdr->parsed;
|
|
@@ -741,18 +722,17 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
|
/* Parse all parameters */
|
|
/* Parse all parameters */
|
|
tmp_s.len = record_route->nameaddr.uri.len - (tmp_s.s-
|
|
tmp_s.len = record_route->nameaddr.uri.len - (tmp_s.s-
|
|
record_route->nameaddr.uri.s);
|
|
record_route->nameaddr.uri.s);
|
|
- if (parse_params( &tmp_s, CLASS_URI, &hooks,
|
|
|
|
|
|
+ if (parse_params( &tmp_s, CLASS_URI, &hooks,
|
|
&record_route->params) < 0) {
|
|
&record_route->params) < 0) {
|
|
- LOG(L_ERR,"assemble_msg: error while parsing "
|
|
|
|
- "record route uri params\n");
|
|
|
|
|
|
+ LM_ERR("error while parsing record route uri params\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
fproxy_lr = (hooks.uri.lr != 0);
|
|
fproxy_lr = (hooks.uri.lr != 0);
|
|
- DBG("assemble_msg: record_route->nameaddr.uri: %.*s\n",
|
|
|
|
|
|
+ LM_DBG("record_route->nameaddr.uri: %.*s\n",
|
|
record_route->nameaddr.uri.len,record_route->nameaddr.uri.s);
|
|
record_route->nameaddr.uri.len,record_route->nameaddr.uri.s);
|
|
if(fproxy_lr){
|
|
if(fproxy_lr){
|
|
first_rr = 0;
|
|
first_rr = 0;
|
|
- DBG("assemble_msg: first proxy has loose routing.\n");
|
|
|
|
|
|
+ LM_DBG("first proxy has loose routing.\n");
|
|
copy_route(s,route.len,record_route->nameaddr.uri.s,
|
|
copy_route(s,route.len,record_route->nameaddr.uri.s,
|
|
record_route->nameaddr.uri.len);
|
|
record_route->nameaddr.uri.len);
|
|
}
|
|
}
|
|
@@ -763,20 +743,19 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
|
continue;
|
|
continue;
|
|
|
|
|
|
if(p_hdr->parsed==0 && parse_rr(p_hdr)!=0 ){
|
|
if(p_hdr->parsed==0 && parse_rr(p_hdr)!=0 ){
|
|
- LOG(L_ERR,"assemble_msg: "
|
|
|
|
- "while parsing <Record-route:> header\n");
|
|
|
|
|
|
+ LM_ERR("while parsing 'Record-route' header\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
for(record_route=p_hdr->parsed; record_route;
|
|
for(record_route=p_hdr->parsed; record_route;
|
|
- record_route=record_route->next){
|
|
|
|
- DBG("assemble_msg: record_route->nameaddr.uri: "
|
|
|
|
- "<%.*s>\n", record_route->nameaddr.uri.len,
|
|
|
|
- record_route->nameaddr.uri.s);
|
|
|
|
- if (!first_rr) {
|
|
|
|
- copy_route(s,route.len,record_route->nameaddr.uri.s,
|
|
|
|
- record_route->nameaddr.uri.len);
|
|
|
|
- }
|
|
|
|
- first_rr=0;
|
|
|
|
|
|
+ record_route=record_route->next){
|
|
|
|
+ LM_DBG("record_route->nameaddr.uri: <%.*s>\n",
|
|
|
|
+ record_route->nameaddr.uri.len,
|
|
|
|
+ record_route->nameaddr.uri.s);
|
|
|
|
+ if (!first_rr) {
|
|
|
|
+ copy_route(s,route.len,record_route->nameaddr.uri.s,
|
|
|
|
+ record_route->nameaddr.uri.len);
|
|
|
|
+ }
|
|
|
|
+ first_rr=0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -788,17 +767,15 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- DBG("assemble_msg: calculated route: %.*s\n",
|
|
|
|
- route.len,route.len ? route.s : "");
|
|
|
|
- DBG("assemble_msg: next r-uri: %.*s\n",
|
|
|
|
- str_uri.len,str_uri.len ? str_uri.s : "");
|
|
|
|
-
|
|
|
|
- if ( REQ_LINE(msg).method_value==METHOD_INVITE ||
|
|
|
|
- REQ_LINE(msg).method_value==METHOD_INFO ||
|
|
|
|
|
|
+ LM_DBG("calculated route: %.*s\n", route.len,route.len ? route.s : "");
|
|
|
|
+ LM_DBG("next r-uri: %.*s\n", str_uri.len,str_uri.len ? str_uri.s : "");
|
|
|
|
+
|
|
|
|
+ if ( REQ_LINE(msg).method_value==METHOD_INVITE ||
|
|
|
|
+ REQ_LINE(msg).method_value==METHOD_INFO ||
|
|
(twi->append && twi->append->add_body) ) {
|
|
(twi->append && twi->append->add_body) ) {
|
|
/* get body */
|
|
/* get body */
|
|
if( (body.s = get_body(msg)) == 0 ){
|
|
if( (body.s = get_body(msg)) == 0 ){
|
|
- LOG(L_ERR, "assemble_msg: get_body failed\n");
|
|
|
|
|
|
+ LM_ERR("get_body failed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
body.len = msg->len - (body.s - msg->buf);
|
|
body.len = msg->len - (body.s - msg->buf);
|
|
@@ -809,16 +786,14 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
|
/* additional headers */
|
|
/* additional headers */
|
|
append.s = s = append_buf;
|
|
append.s = s = append_buf;
|
|
if (sizeof(flag_t)*2+12+1 >= APPEND_BUFFER_MAX) {
|
|
if (sizeof(flag_t)*2+12+1 >= APPEND_BUFFER_MAX) {
|
|
- LOG(L_ERR,"assemble_msg: buffer overflow "
|
|
|
|
- "while copying optional header\n");
|
|
|
|
|
|
+ LM_ERR("buffer overflow while copying optional header\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
append_str(s,"P-MsgFlags: ",12);
|
|
append_str(s,"P-MsgFlags: ",12);
|
|
l = APPEND_BUFFER_MAX - (12+1); /* include trailing `\n'*/
|
|
l = APPEND_BUFFER_MAX - (12+1); /* include trailing `\n'*/
|
|
|
|
|
|
if (int2reverse_hex(&s, &l, (int)msg->msg_flags) == -1) {
|
|
if (int2reverse_hex(&s, &l, (int)msg->msg_flags) == -1) {
|
|
- LOG(L_ERR,"assemble_msg: buffer overflow "
|
|
|
|
- "while copying optional header\n");
|
|
|
|
|
|
+ LM_ERR("buffer overflow while copying optional header\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
append_chr(s,'\n');
|
|
append_chr(s,'\n');
|
|
@@ -833,8 +808,7 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
|
|
|
|
|
eol_line_s(1) = s = cmd_buf;
|
|
eol_line_s(1) = s = cmd_buf;
|
|
if(twi->action.len+12 >= CMD_BUFFER_MAX){
|
|
if(twi->action.len+12 >= CMD_BUFFER_MAX){
|
|
- LOG(L_ERR,"assemble_msg: buffer overflow while "
|
|
|
|
- "copying command name\n");
|
|
|
|
|
|
+ LM_ERR("buffer overflow while copying command name\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
append_str(s,"sip_request.",12);
|
|
append_str(s,"sip_request.",12);
|
|
@@ -866,7 +840,7 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
|
eol_line_s(15)=id_buf; /* hash:label */
|
|
eol_line_s(15)=id_buf; /* hash:label */
|
|
s = int2str(hash_index, &l);
|
|
s = int2str(hash_index, &l);
|
|
if (l+1>=IDBUF_LEN) {
|
|
if (l+1>=IDBUF_LEN) {
|
|
- LOG(L_ERR, "assemble_msg: too big hash\n");
|
|
|
|
|
|
+ LM_ERR("too big hash\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
memcpy(id_buf, s, l);
|
|
memcpy(id_buf, s, l);
|
|
@@ -874,7 +848,7 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
|
eol_line_len(15)=l+1;
|
|
eol_line_len(15)=l+1;
|
|
s = int2str(label, &l);
|
|
s = int2str(label, &l);
|
|
if (l+1+eol_line_len(15)>=IDBUF_LEN) {
|
|
if (l+1+eol_line_len(15)>=IDBUF_LEN) {
|
|
- LOG(L_ERR, "assemble_msg: too big label\n");
|
|
|
|
|
|
+ LM_ERR("too big label\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
memcpy(id_buf+eol_line_len(15), s, l);
|
|
memcpy(id_buf+eol_line_len(15), s, l);
|
|
@@ -900,16 +874,16 @@ static int write_to_unixsock(char* sockname, int cnt)
|
|
struct sockaddr_un dest;
|
|
struct sockaddr_un dest;
|
|
|
|
|
|
if (!sockname) {
|
|
if (!sockname) {
|
|
- LOG(L_ERR, "write_to_unixsock: Invalid parameter\n");
|
|
|
|
|
|
+ LM_ERR("Invalid parameter\n");
|
|
return E_UNSPEC;
|
|
return E_UNSPEC;
|
|
}
|
|
}
|
|
|
|
|
|
len = strlen(sockname);
|
|
len = strlen(sockname);
|
|
if (len == 0) {
|
|
if (len == 0) {
|
|
- DBG("write_to_unixsock: Error - empty socket name\n");
|
|
|
|
|
|
+ LM_DBG("Error - empty socket name\n");
|
|
return -1;
|
|
return -1;
|
|
} else if (len > 107) {
|
|
} else if (len > 107) {
|
|
- LOG(L_ERR, "write_to_unixsock: Socket name too long\n");
|
|
|
|
|
|
+ LM_ERR("Socket name too long\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -932,13 +906,13 @@ static int write_to_unixsock(char* sockname, int cnt)
|
|
e = 0;
|
|
e = 0;
|
|
#endif
|
|
#endif
|
|
if (e == -1) {
|
|
if (e == -1) {
|
|
- LOG(L_ERR, "write_to_unixsock: Error in connect: %s\n", strerror(errno));
|
|
|
|
|
|
+ LM_ERR("error in connect: %s\n", strerror(errno));
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
if (tsend_dgram_ev(sock, iov_lines_eol, 2 * cnt,
|
|
if (tsend_dgram_ev(sock, iov_lines_eol, 2 * cnt,
|
|
cfg_get(tm, tm_cfg, tm_unix_tx_timeout)) < 0) {
|
|
cfg_get(tm, tm_cfg, tm_unix_tx_timeout)) < 0) {
|
|
- LOG(L_ERR, "write_to_unixsock: writev failed: %s\n", strerror(errno));
|
|
|
|
|
|
+ LM_ERR("writev failed: %s\n", strerror(errno));
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -949,19 +923,19 @@ static int write_to_unixsock(char* sockname, int cnt)
|
|
int t_write_req(struct sip_msg* msg, char* vm_fifo, char* info)
|
|
int t_write_req(struct sip_msg* msg, char* vm_fifo, char* info)
|
|
{
|
|
{
|
|
if (assemble_msg(msg, (struct tw_info*)info) < 0) {
|
|
if (assemble_msg(msg, (struct tw_info*)info) < 0) {
|
|
- LOG(L_ERR, "ERROR:tm:t_write_req: Error int assemble_msg\n");
|
|
|
|
|
|
+ LM_ERR("error int assemble_msg\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (write_to_fifo(vm_fifo, TWRITE_PARAMS) == -1) {
|
|
if (write_to_fifo(vm_fifo, TWRITE_PARAMS) == -1) {
|
|
- LOG(L_ERR, "ERROR:tm:t_write_req: write_to_fifo failed\n");
|
|
|
|
|
|
+ LM_ERR("write_to_fifo failed\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /* make sure that if voicemail does not initiate a reply
|
|
|
|
- * timely, a SIP timeout will be sent out */
|
|
|
|
|
|
+
|
|
|
|
+ /* make sure that if voicemail does not initiate a reply
|
|
|
|
+ * timely, a SIP timeout will be sent out */
|
|
if (add_blind_uac() == -1) {
|
|
if (add_blind_uac() == -1) {
|
|
- LOG(L_ERR, "ERROR:tm:t_write_req: add_blind failed\n");
|
|
|
|
|
|
+ LM_ERR("add_blind failed\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
return 1;
|
|
return 1;
|
|
@@ -971,19 +945,19 @@ int t_write_req(struct sip_msg* msg, char* vm_fifo, char* info)
|
|
int t_write_unix(struct sip_msg* msg, char* socket, char* info)
|
|
int t_write_unix(struct sip_msg* msg, char* socket, char* info)
|
|
{
|
|
{
|
|
if (assemble_msg(msg, (struct tw_info*)info) < 0) {
|
|
if (assemble_msg(msg, (struct tw_info*)info) < 0) {
|
|
- LOG(L_ERR, "ERROR:tm:t_write_unix: Error in assemble_msg\n");
|
|
|
|
|
|
+ LM_ERR("error in assemble_msg\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
if (write_to_unixsock(socket, TWRITE_PARAMS) == -1) {
|
|
if (write_to_unixsock(socket, TWRITE_PARAMS) == -1) {
|
|
- LOG(L_ERR, "ERROR:tm:t_write_unix: write_to_unixsock failed\n");
|
|
|
|
|
|
+ LM_ERR("write_to_unixsock failed\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
- /* make sure that if voicemail does not initiate a reply
|
|
|
|
- * timely, a SIP timeout will be sent out */
|
|
|
|
|
|
+ /* make sure that if voicemail does not initiate a reply
|
|
|
|
+ * timely, a SIP timeout will be sent out */
|
|
if (add_blind_uac() == -1) {
|
|
if (add_blind_uac() == -1) {
|
|
- LOG(L_ERR, "ERROR:tm:t_write_unix: add_blind failed\n");
|
|
|
|
|
|
+ LM_ERR("add_blind failed\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
return 1;
|
|
return 1;
|