- added force rport (force_rport command in script, FL_FORCE_RPORT flags,
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Sat, 12 Apr 2003 19:26:15 +0000 (19:26 +0000)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Sat, 12 Apr 2003 19:26:15 +0000 (19:26 +0000)
msg->msg_flags)
- added chroot and wdir in script (to bring it in line with the cmd. line
  options)

TODO
action.c
cfg.lex
cfg.y
forward.c
forward.h
globals.h
msg_translator.c
parser/msg_parser.h
route_struct.c
route_struct.h

diff --git a/TODO b/TODO
index 07b623b..b6bca2f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -2,6 +2,18 @@ $Id$
 
 ( - todo, x - done)
 
+release:
+- resolver should resolve [ipv6]
+- remove parse_uri debugging info
+- fix DBG("<%.*s>", len, _null_)
+- add -t, -w, -u -g equivalents to the config file
+x force add rport : force_rport()
+- kill all the fprintf
+see also tcp & tm
+
+
+
+not so critical:
 x replace  remaining mallocs/frees at least in msg_translator.c
 - add $(INCLUDES) to the Makefiles
 x make ser suncc ready
@@ -15,15 +27,12 @@ x (different way) add request header bitmap field for the modules
 - introduce variables & function in the script language (cfg. file)
 - ? variable number of params functions in script (no longer limited to 2)?
 - kill bind_idx
-- fix bind_address for tcp (in some  way)
+x fix bind_address for tcp (in some  way)
 - add conflict in debs/rpms/etc (conflict w/ older ser-mysql, ser-jabber)
 - new packages ser-radius etc
 - tcp_destroy (called on ser exit)
 - BUG:?? ipv6 only and try to send to ipv4 => getsendsocket=>0 (send_ipv6=0)
   the reverse is also true
-- resolver should resolve [ipv6]
-- remove parse_uri debugging info
-- fix DBG("<%.*s>", len, _null_)
 
 
 High priority:
@@ -47,7 +56,6 @@ x forward to received= if present
 - make it easier to register a statically linkable module.
 x add support for -u user and -g group (not only -u uid, -g uid)
 - change uid/gid after opening the sockets
-- add -t, -w, -u -g equivalents to the config file
 - exec improvments (add format strings to it)
 - command line switch for checking the config file syntax
 - config file version (a la sendmail)
@@ -79,8 +87,6 @@ x freopen stdin, stdout, stderr to /dev/null
 x add src_port, dst_port, proto to cfg.{y,lex}
 x generic locking lib
 x convert tm to use new locking lib
-- force add rport (setflag(rport)???)
-- kill all the fprintf
 
 optimizations:
 - better timer interface with hashes (a la openbsd)
index cd55b76..620bb36 100644 (file)
--- a/action.c
+++ b/action.c
  *
  * History:
  * ---------
- * 2003-02-28  scratchpad compatibility abandoned (jiri)
- * 2003-01-29  removed scratchpad (jiri)
- * 2003-03-19  fixed set* len calculation bug & simplified a little the code
+ *  2003-02-28  scratchpad compatibility abandoned (jiri)
+ *  2003-01-29  removed scratchpad (jiri)
+ *  2003-03-19  fixed set* len calculation bug & simplified a little the code
  *              (should be a little faster now) (andrei)
- *             replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
- * 2003-04-01  Added support for loose routing in forward (janakj)
+ *              replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
+ *  2003-04-01  Added support for loose routing in forward (janakj)
+ *  2003-04-12  FORCE_RPORT_T added (andrei)
  */
 
 
@@ -569,6 +570,10 @@ int do_action(struct action* a, struct sip_msg* msg)
                                LOG(L_CRIT,"BUG: do_action: bad module call\n");
                        }
                        break;
+               case FORCE_RPORT_T:
+                       msg->msg_flags|=FL_FORCE_RPORT;
+                       ret=1; /* continue processing */
+                       break;
                default:
                        LOG(L_CRIT, "BUG: do_action: unknown type %d\n", a->type);
        }
diff --git a/cfg.lex b/cfg.lex
index ce1c8a9..4e3128e 100644 (file)
--- a/cfg.lex
+++ b/cfg.lex
@@ -33,6 +33,7 @@
  *  2003-03-19  replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei)
  *  2003-04-01  added dst_port, proto (tcp, udp, tls), af(inet, inet6) (andrei)
  *  2003-04-05  s/reply_route/failure_route, onreply_route introduced (jiri)
+ *  2003-04-12  added force_rport, chdir and wdir (andrei)
  */
 
 
@@ -82,6 +83,7 @@ ROUTE route
 ROUTE_FAILURE failure_route
 ROUTE_ONREPLY onreply_route
 EXEC   exec
+FORCE_RPORT            "force_rport"|"add_rport"
 SETFLAG                setflag
 RESETFLAG      resetflag
 ISFLAGSET      isflagset
@@ -150,6 +152,8 @@ SERVER_SIGNATURE server_signature
 REPLY_TO_VIA reply_to_via
 USER           "user"|"uid"
 GROUP          "group"|"gid"
+CHROOT         "chroot"
+WDIR           "workdir"|"wdir"
 MHOMED         mhomed
 
 LOADMODULE     loadmodule
@@ -226,7 +230,10 @@ EAT_ABLE   [\ \t\b\r]
 <INITIAL>{REVERT_URI}  { count(); yylval.strval=yytext; return REVERT_URI; }
 <INITIAL>{PREFIX}      { count(); yylval.strval=yytext; return PREFIX; }
 <INITIAL>{STRIP}       { count(); yylval.strval=yytext; return STRIP; }
-<INITIAL>{APPEND_BRANCH}       { count(); yylval.strval=yytext; return APPEND_BRANCH; }
+<INITIAL>{APPEND_BRANCH}       { count(); yylval.strval=yytext; 
+                                                               return APPEND_BRANCH; }
+<INITIAL>{FORCE_RPORT} { count(); yylval.strval=yytext; return FORCE_RPORT; }
+       
 <INITIAL>{IF}  { count(); yylval.strval=yytext; return IF; }
 <INITIAL>{ELSE}        { count(); yylval.strval=yytext; return ELSE; }
 
@@ -262,6 +269,8 @@ EAT_ABLE    [\ \t\b\r]
 <INITIAL>{SIP_WARNING} { count(); yylval.strval=yytext; return SIP_WARNING; }
 <INITIAL>{USER}                { count(); yylval.strval=yytext; return USER; }
 <INITIAL>{GROUP}       { count(); yylval.strval=yytext; return GROUP; }
+<INITIAL>{CHROOT}      { count(); yylval.strval=yytext; return CHROOT; }
+<INITIAL>{WDIR}        { count(); yylval.strval=yytext; return WDIR; }
 <INITIAL>{MHOMED}      { count(); yylval.strval=yytext; return MHOMED; }
 <INITIAL>{FIFO}        { count(); yylval.strval=yytext; return FIFO; }
 <INITIAL>{FIFO_MODE}   { count(); yylval.strval=yytext; return FIFO_MODE; }
diff --git a/cfg.y b/cfg.y
index 283f8ac..98bb393 100644 (file)
--- a/cfg.y
+++ b/cfg.y
@@ -36,6 +36,7 @@
  * 2003-03-20  Regex support in modparam (janakj)
  * 2003-04-01  added dst_port, proto , af (andrei)
  * 2003-04-05  s/reply_route/failure_route, onreply_route introduced (jiri)
+ * 2003-04-12  added force_rport, chroot and wdir (andrei)
  */
 
 
@@ -120,6 +121,7 @@ int rt;  /* Type of route block for find_export */
 %token SET_PORT
 %token SET_URI
 %token REVERT_URI
+%token FORCE_RPORT
 %token IF
 %token ELSE
 %token URIHOST
@@ -163,6 +165,8 @@ int rt;  /* Type of route block for find_export */
 %token MAXBUFFER
 %token USER
 %token GROUP
+%token CHROOT
+%token WDIR
 %token MHOMED
 
 
@@ -332,6 +336,12 @@ assign_stm:        DEBUG EQUAL NUMBER { debug=$3; }
                | GROUP EQUAL STRING     { group=$3; }
                | GROUP EQUAL ID         { group=$3; }
                | GROUP EQUAL error      { yyerror("string value expected"); }
+               | CHROOT EQUAL STRING     { chroot_dir=$3; }
+               | CHROOT EQUAL ID         { chroot_dir=$3; }
+               | CHROOT EQUAL error      { yyerror("string value expected"); }
+               | WDIR EQUAL STRING     { working_dir=$3; }
+               | WDIR EQUAL ID         { working_dir=$3; }
+               | WDIR EQUAL error      { yyerror("string value expected"); }
                | MHOMED EQUAL NUMBER { mhomed=$3; }
                | MHOMED EQUAL error { yyerror("boolean value expected"); }
                | SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
@@ -1063,6 +1073,8 @@ cmd:              FORWARD LPAREN host RPAREN      { $$=mk_action( FORWARD_T,
                                                                                "string expected"); }
                | REVERT_URI LPAREN RPAREN { $$=mk_action( REVERT_URI_T, 0,0,0,0); }
                | REVERT_URI { $$=mk_action( REVERT_URI_T, 0,0,0,0); }
+               | FORCE_RPORT LPAREN RPAREN     {$$=mk_action(FORCE_RPORT_T,0, 0, 0, 0); }
+               | FORCE_RPORT                           {$$=mk_action(FORCE_RPORT_T,0, 0, 0, 0); }
                | ID LPAREN RPAREN                      { f_tmp=(void*)find_export($1, 0, rt);
                                                                           if (f_tmp==0){
                                                                                   if (find_export($1, 0, 0)) {
index bba172e..eb9ec81 100644 (file)
--- a/forward.c
+++ b/forward.c
@@ -39,6 +39,8 @@
  *  2003-04-03  added su_setport (andrei)
  *  2003-04-04  update_sock_struct_from_via now differentiates between
  *               local replies  & "normal" replies (andrei)
+ *  2003-04-12  update_sock_struct_form via uses also FL_FORCE_RPORT for
+ *               local replies (andrei)
  */
 
 
@@ -366,7 +368,8 @@ int update_sock_struct_from_via( union sockaddr_union* to,
                /* _local_ reply, we ignore any rport or received value
                 * (but we will send back to the original port if rport is
                 *  present) */
-               if (via->rport) port=msg->rcv.src_port;
+               if ((msg->msg_flags&FL_FORCE_RPORT)||(via->rport))
+                       port=msg->rcv.src_port;
                else port=via->port;
                name=&(via->host); /* received=ip in 1st via is ignored (it's
                                                          not added by us so it's bad) */
index 2e8a433..779be7e 100644 (file)
--- a/forward.h
+++ b/forward.h
 /*
  * History:
  * -------
- * 2001-??-?? created by andrei
- * ????-??-?? lots of changes by a lot of people
- * 2003-02-11 added inline msg_send (andrei)
- * 2003-04-07 changed all ports to host byte order (andrei)
+ *  2001-??-?? created by andrei
+ *  ????-??-?? lots of changes by a lot of people
+ *  2003-02-11 added inline msg_send (andrei)
+ *  2003-04-07 changed all ports to host byte order (andrei)
+ *  2003-04-12  FORCE_RPORT_T added (andrei)
  */
 
 
@@ -61,8 +62,9 @@ int update_sock_struct_from_via( union sockaddr_union* to,
 /* use src_ip, port=src_port if rport, via port if via port, 5060 otherwise */
 #define update_sock_struct_from_ip(  to, msg ) \
        init_su((to), &(msg)->rcv.src_ip, \
-                       ((msg)->via1->rport)?(msg)->rcv.src_port: \
-                       ((msg)->via1->port)?(msg)->via1->port: SIP_PORT )
+                       (((msg)->via1->rport)||((msg)->msg_flags&&FL_FORCE_RPORT))? \
+                                                       (msg)->rcv.src_port: \
+                                                       ((msg)->via1->port)?(msg)->via1->port: SIP_PORT )
 
 int forward_reply( struct sip_msg* msg);
 
index fdc3b71..dfcdefb 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -77,6 +77,9 @@ extern int sip_warning;
 extern int server_signature;
 extern char* user;
 extern char* group;
+extern char* chroot_dir;
+extern char* working_dir;
+
 /*
  * debug & log_stderr moved to dprint.h*/
 
index 24b037a..9a70c9b 100644 (file)
  * 2003-04-01  added opt (conditional) lump support (andrei)
  * 2003-04-02  added more subst lumps: SUBST_{SND,RCV}_ALL  
  *              => ip:port;transport=proto (andrei)
+ * 2003-04-12  added FL_FORCE_RPORT support (andrei)
  *
  */
-
-
+/* Via special params:
+ * requests:
+ * - if the address in via is different from the src_ip or an existing
+ *   received=something is found, received=src_ip is added (and any preexisting
+ *   received is deleted). received is added as the first via parameter if no
+ *   receive is previoulsy present or over the old receive.
+ * - if the original via contains rport / rport=something or msg->msg_flags
+ *   FL_FORCE_RPORT is set (e.g. script force_rport() cmd) rport=src_port
+ *   is added (over previous rport / as first via param or after received
+ *   if no received was present and received is added too)
+ * local replies:
+ *    (see also sl_send_reply)
+ *  - rport and received are added in mostly the same way as for requests, but 
+ *    in the reverse order (first rport and then received). See also 
+ *    limitations.
+ *  - if reply_to_via is set (default off) the local reply will be sent to
+ *    the address in via (received is ignored since it was not set by us). The
+ *    destination port is either the message source port if via contains rport
+ *    or the FL_FORCE_RPORT flag is set or the port from the via. If either
+ *    port or rport are present a normal dns lookup (instead of a srv lookup)
+ *    is performed on the address. If no port is present and a srv lookup is 
+ *    performed the port is taken from the srv lookup. If the srv lookup failed
+ *    or it was not performed, the port is set to the default sip port (5060).
+ *  - if reply_to_via is off (default) the local reply is ent to the message
+ *    source ip address. The destination port is set to the source port if 
+ *    rport is present or FL_FORCE_RPORT flag is set, to the via port or to
+ *    the default sip port (5060) if neither rport or via port are present.
+ * "normal" replies:
+ *  - if received is present the message is sent to the received address else
+ *    if no port is present (neither a normal via port or rport) a dns srv 
+ *    lookup is performed on the host part and the reply is sent to the 
+ *    resulting ip. If a port is present or the host part is an ip address 
+ *    the dns lookup will be a "normal" one (A or AAAA).
+ *  - if rport is present, it's value will be used as the destination port
+ *   (and this will also disable srv lookups)
+ *  - if no port is present the destination port will be taken from the srv
+ *    lookup. If the srv lookup fails or is not performed (e.g. ip address
+ *    in host) the destination port will be set to the default sip port (5060).
+ *  
+ * Known limitations:
+ * - when locally replying to a message, rport and received will be appended to
+ *   the via header parameters (for forwarded requests they are inserted at the
+ *   beginning).
+ * - a locally generated reply might get two received via parameters if a
+ *   received is already present in the original message (this should not
+ *   happen though, but ...)
+ *
+ *--andrei
+*/
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -1093,7 +1141,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
        char* buf;
        unsigned int offset, s_offset, size;
        struct lump* anchor;
-       int r;
+       struct lump* via_insert_param;
        str branch;
        str extra_params;
        
@@ -1109,6 +1157,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
        clen_buf=0;
        clen_len=0;
 #endif
+       via_insert_param=0;
        extra_params.len=0;
        extra_params.s=0;
        uri_len=0;
@@ -1161,9 +1210,9 @@ skip_clen:
                goto error00;
        }
        /* check if received needs to be added */
-       r=check_via_address(&msg->rcv.src_ip, &msg->via1->host, 
-               msg->via1->port, received_dns);
-       if (r!=0){
+       if ( msg->via1->received || 
+                       check_via_address(&msg->rcv.src_ip, &msg->via1->host, 
+                                                                       msg->via1->port, received_dns) ){
                if ((received_buf=received_builder(msg,&received_len))==0){
                        LOG(L_ERR, "ERROR: build_req_buf_from_sip_req:"
                                                        " received_builder failed\n");
@@ -1171,8 +1220,13 @@ skip_clen:
                }
        }
        
-       /* check if rport needs to be updated */
-       if (msg->via1->rport && msg->via1->rport->value.s==0){
+       /* check if rport needs to be updated:
+        *  - if FL_FORCE_RPORT is set add it (and del. any previous version)
+        *  - if via already contains an rport add it and overwrite the previous
+        *  rport value if present (if you don't want to overwrite the previous
+        *  version remove the comments) */
+       if ((msg->msg_flags&FL_FORCE_RPORT)||
+                       (msg->via1->rport /*&& msg->via1->rport->value.s==0*/)){
                if ((rport_buf=rport_builder(msg, &rport_len))==0){
                        LOG(L_ERR, "ERROR: build_req_buf_from_sip_req:"
                                                        " rport_builder failed\n");
@@ -1187,34 +1241,52 @@ skip_clen:
        if (anchor==0) goto error01;
        if (insert_new_lump_before(anchor, line_buf, via_len, HDR_VIA)==0)
                goto error01;
-       /* if received needs to be added, add anchor after host and add it */
+       /* find out where the offset of the first parameter that should be added
+        * (after host:port), needed by add receive & maybe rport */
+       if (msg->via1->params.s){
+                       size= msg->via1->params.s-msg->via1->hdr.s-1; /*compensate
+                                                                                                                 for ';' */
+       }else{
+                       size= msg->via1->host.s-msg->via1->hdr.s+msg->via1->host.len;
+                       if (msg->via1->port!=0){
+                               /*size+=strlen(msg->via1->hdr.s+size+1)+1;*/
+                               size += msg->via1->port_str.len + 1; /* +1 for ':'*/
+                       }
+               #ifdef USE_IPV6
+                       if(send_sock->address.af==AF_INET6) size+=1; /* +1 for ']'*/
+               #endif
+       }
+       /* if received needs to be added, add anchor after host and add it, or 
+        * overwrite the previous one if already present */
        if (received_len){
-               if (msg->via1->params.s){
-                               size= msg->via1->params.s-msg->via1->hdr.s-1; /*compensate
-                                                                                                                         for ';' */
-               }else{
-                               size= msg->via1->host.s-msg->via1->hdr.s+msg->via1->host.len;
-                               if (msg->via1->port!=0){
-                                       /*size+=strlen(msg->via1->hdr.s+size+1)+1;*/
-                                       size += msg->via1->port_str.len + 1; /* +1 for ':'*/
-                               }
-                       #ifdef USE_IPV6
-                               if(send_sock->address.af==AF_INET6) size+=1; /* +1 for ']'*/
-                       #endif
+               if (msg->via1->received){ /* received already present => overwrite it*/
+                       via_insert_param=del_lump(&(msg->add_rm),
+                                                               msg->via1->received->start-buf-1, /*;*/
+                                                               msg->via1->received->size+1, /*;*/ HDR_VIA);
+               }else if (via_insert_param==0){ /* receive not present, ok */
+                       via_insert_param=anchor_lump(&(msg->add_rm),
+                                                                               msg->via1->hdr.s-buf+size,0, HDR_VIA);
                }
-               anchor=anchor_lump(&(msg->add_rm),msg->via1->hdr.s-buf+size,0,
-                               HDR_VIA);
-               if (anchor==0) goto error02; /* free received_buf */
-               if (insert_new_lump_after(anchor, received_buf, received_len, HDR_VIA)
-                               ==0 ) goto error02; /* free received_buf */
+               if (via_insert_param==0) goto error02; /* free received_buf */
+               if (insert_new_lump_after(via_insert_param, received_buf, received_len,
+                                       HDR_VIA) ==0 ) goto error02; /* free received_buf */
        }
-       /* if rport needs to be updated, delete it and add it's value */
+       /* if rport needs to be updated, delete it if present and add it's value */
        if (rport_len){
-               anchor=del_lump(&(msg->add_rm), msg->via1->rport->start-buf-1, /*';'*/
-                                                       msg->via1->rport->size+1 /* ; */, HDR_VIA);
-               if (anchor==0) goto error03; /* free rport_buf*/
-               if (insert_new_lump_after(anchor, rport_buf, rport_len, HDR_VIA)==0)
-                       goto error03; /* free rport_buf*/
+               if (msg->via1->rport){ /* rport already present */
+                       via_insert_param=del_lump(&(msg->add_rm),
+                                                               msg->via1->rport->start-buf-1, /*';'*/
+                                                               msg->via1->rport->size+1 /* ; */, HDR_VIA);
+               }else if (via_insert_param==0){ /*force rport, no rport present */
+                       /* no rport, add it */
+                       via_insert_param=anchor_lump(&(msg->add_rm),
+                                                                               msg->via1->hdr.s-buf+size,0, HDR_VIA);
+               }
+               if (via_insert_param==0) goto error03; /* free rport_buf */
+               if (insert_new_lump_after(via_insert_param, rport_buf, rport_len,
+                                                                       HDR_VIA) ==0 )
+                       goto error03; /* free rport_buf */
+                       
        }
 #ifdef USE_TCP
        /* if clen needs to be added, add it */
@@ -1437,7 +1509,6 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text ,
        char              *warning;
        unsigned int      warning_len;
        unsigned int      text_len;
-       int  r;
        int  content_len_len;
        char *content_len;
        char content_len_buf[MAX_CONTENT_LEN_BUF];
@@ -1470,10 +1541,10 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text ,
        /* check if received needs to be added */
        backup = msg->via1->host.s[msg->via1->host.len];
        msg->via1->host.s[msg->via1->host.len] = 0;
-       r=check_via_address(&msg->rcv.src_ip, &msg->via1->host, 
-               msg->via1->port, received_dns);
+       if (msg->via1->received || 
+                       check_via_address(&msg->rcv.src_ip, &msg->via1->host, 
+                                                               msg->via1->port, received_dns)) {
        msg->via1->host.s[msg->via1->host.len] = backup;
-       if (r!=0) {
                if ((received_buf=received_builder(msg,&received_len))==0) {
                        LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: "
                                "alas, received_builder failed\n");
@@ -1481,13 +1552,15 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text ,
                }
        }
        /* check if rport needs to be updated */
-       if (msg->via1->rport && msg->via1->rport->value.s==0){
+       if ( (msg->msg_flags&FL_FORCE_RPORT)||
+               (msg->via1->rport /*&& msg->via1->rport->value.s==0*/)){
                if ((rport_buf=rport_builder(msg, &rport_len))==0){
                        LOG(L_ERR, "ERROR: build_res_buf_from_sip_req:"
                                                        " rport_builder failed\n");
                        goto error01; /* free everything */
                }
-               delete_len=msg->via1->rport->size+1; /* include ';' */
+               if (msg->via1->rport) 
+                       delete_len=msg->via1->rport->size+1; /* include ';' */
        }
 
        /*computes the lenght of the new response buffer*/
@@ -1587,17 +1660,24 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text ,
                        case HDR_VIA:
                                if (hdr==msg->h_via1){
                                        if (rport_buf){
-                                               /* copy until rport */
-                                               append_str_trans( p, hdr->name.s ,
-                                                       msg->via1->rport->start-hdr->name.s-1,msg);
-                                               /* copy new rport */
-                                               append_str(p, rport_buf, rport_len);
-                                               /* copy the rest of the via */
-                                               append_str_trans(p, msg->via1->rport->start+
-                                                                                       msg->via1->rport->size, 
-                                                                                       hdr->body.s+hdr->body.len-
-                                                                                       msg->via1->rport->start-
-                                                                                       msg->via1->rport->size, msg);
+                                               if (msg->via1->rport){ /* delete the old one */
+                                                       /* copy until rport */
+                                                       append_str_trans( p, hdr->name.s ,
+                                                               msg->via1->rport->start-hdr->name.s-1,msg);
+                                                       /* copy new rport */
+                                                       append_str(p, rport_buf, rport_len);
+                                                       /* copy the rest of the via */
+                                                       append_str_trans(p, msg->via1->rport->start+
+                                                                                               msg->via1->rport->size, 
+                                                                                               hdr->body.s+hdr->body.len-
+                                                                                               msg->via1->rport->start-
+                                                                                               msg->via1->rport->size, msg);
+                                               }else{ /* just append the new one */
+                                                       /* normal whole via copy */
+                                                       append_str_trans( p, hdr->name.s , 
+                                                               (hdr->body.s+hdr->body.len)-hdr->name.s, msg);
+                                                       append_str(p, rport_buf, rport_len);
+                                               }
                                        }else{
                                                /* normal whole via copy */
                                                append_str_trans( p, hdr->name.s , 
index 1d00110..a72fe12 100644 (file)
@@ -34,6 +34,7 @@
  *  2003-04-01  2 macros added: GET_NEXT_HOP and GET_RURI (janakj)
  *  2003-04-04  structure for parsed inbound uri added (jiri)
  *  2003-04-11  updated the  sip_uri structure (lots of fields added) (andrei)
+ *  2003-04-12  added msg_flags to sip_msg (andrei)
  */
 
 
@@ -65,6 +66,8 @@
 enum request_method { METHOD_UNDEF=0, METHOD_INVITE=1, METHOD_CANCEL=2, METHOD_ACK=4, 
        METHOD_BYE=8, METHOD_OTHER=16 };
 
+#define FL_FORCE_RPORT 1 /* force rport */
+
 
 #define IFISMETHOD(methodname,firstchar)                                  \
 if (  (*tmp==(firstchar) || *tmp==((firstchar) | 32)) &&                  \
@@ -207,7 +210,7 @@ struct sip_msg {
        
             /* index to TM hash table; stored in core to avoid unnecessary calcs */
        unsigned int  hash_index;
-       
+       unsigned int msg_flags; /* flags used by core */
             /* allows to set various flags on the message; may be used for 
              * simple inter-module communication or remembering processing state
              * reached 
index 42d645e..8456530 100644 (file)
@@ -30,6 +30,7 @@
  * --------
  *  2003-01-29  src_port introduced (jiri)
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
+ *  2003-04-12  FORCE_RPORT_T added (andrei)
  */
 
 
@@ -313,6 +314,9 @@ void print_action(struct action* a)
                        case MODULE_T:
                                        DBG(" external_module_call(");
                                        break;
+                       case FORCE_RPORT_T:
+                                       DBG("force_rport(");
+                                       break;
                        default:
                                        DBG("UNKNOWN(");
                }
index cc300b5..cd49917 100644 (file)
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+/* History:
+ * --------
+ *
+ *  2003-04-12  FORCE_RPORT_T added (andrei)
+ */
 
 
 #ifndef route_struct_h
@@ -58,7 +63,9 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
                REVERT_URI_T,
                FORWARD_TCP_T,
                FORWARD_UDP_T,
-               SEND_TCP_T};
+               SEND_TCP_T,
+               FORCE_RPORT_T
+};
 enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
                EXPR_ST, ACTIONS_ST, CMDF_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST,
                MYSELF_ST };