- rewritten module function parsing and call processing (mk_action, struct action...
authorTomas Mandys <tomas.mandys@iptel.org>
Mon, 9 Jan 2006 19:42:35 +0000 (19:42 +0000)
committerTomas Mandys <tomas.mandys@iptel.org>
Mon, 9 Jan 2006 19:42:35 +0000 (19:42 +0000)
- API to get other fixup params from fixup
- full function overloading
- optional NUMBER/STRING param in config for module functions
- added oveloaded functions to print_stdout (demostrates overloading)

action.c
cfg.y
modparam.c
modules/tm/tm.c
route.c
route_struct.c
route_struct.h
sr_module.c
sr_module.h

index 858142c..da7efcc 100644 (file)
--- a/action.c
+++ b/action.c
@@ -21,8 +21,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * History:
@@ -88,7 +88,7 @@ struct onsend_info* p_onsend=0; /* onsend route send info */
 static unsigned int run_flags=0;
 int last_retcode=0; /* last return from a route() */
 
-/* ret= 0! if action -> end of list(e.g DROP), 
+/* ret= 0! if action -> end of list(e.g DROP),
       > 0 to continue processing next actions
    and <0 on error */
 int do_action(struct action* a, struct sip_msg* msg)
@@ -119,11 +119,11 @@ int do_action(struct action* a, struct sip_msg* msg)
        ret=E_BUG;
        switch ((unsigned char)a->type){
                case DROP_T:
-                               if (a->p1_type==RETCODE_ST)
+                               if (a->val[0].type==RETCODE_ST)
                                        ret=last_retcode;
                                else
-                                       ret=(int)a->p1.number;
-                               run_flags|=(unsigned int)a->p2.number;
+                                       ret=(int) a->val[0].u.number;
+                               run_flags|=(unsigned int)a->val[1].u.number;
                        break;
                case FORWARD_T:
 #ifdef USE_TCP
@@ -142,7 +142,7 @@ int do_action(struct action* a, struct sip_msg* msg)
                        else if (a->type==FORWARD_TLS_T) proto= PROTO_TLS;
 #endif
                        else proto= PROTO_NONE;
-                       if (a->p1_type==URIHOST_ST){
+                       if (a->val[0].type==URIHOST_ST){
                                /*parse uri*/
 
                                if (msg->dst_uri.len) {
@@ -158,17 +158,17 @@ int do_action(struct action* a, struct sip_msg* msg)
                                                                " dropping packet\n");
                                        break;
                                }
-                               
-                               switch (a->p2_type){
+
+                               switch (a->val[1].type){
                                        case URIPORT_ST:
                                                                        port=u->port_no;
                                                                        break;
                                        case NUMBER_ST:
-                                                                       port=a->p2.number;
+                                                                       port=a->val[1].u.number;
                                                                        break;
                                        default:
                                                        LOG(L_CRIT, "BUG: do_action bad forward 2nd"
-                                                                               " param type (%d)\n", a->p2_type);
+                                                                               " param type (%d)\n", a->val[1].type);
                                                        ret=E_UNSPEC;
                                                        goto error_fwd_uri;
                                }
@@ -219,22 +219,22 @@ int do_action(struct action* a, struct sip_msg* msg)
                                free_proxy(p); /* frees only p content, not p itself */
                                pkg_free(p);
                                if (ret>=0) ret=1;
-                       }else if ((a->p1_type==PROXY_ST) && (a->p2_type==NUMBER_ST)){
+                       }else if ((a->val[0].type==PROXY_ST) && (a->val[1].type==NUMBER_ST)){
                                if (proto==PROTO_NONE)
                                        proto=msg->rcv.proto;
-                               ret=forward_request(msg,(struct proxy_l*)a->p1.data, proto);
+                               ret=forward_request(msg,(struct proxy_l*)a->val[0].u.data, proto);
                                if (ret>=0) ret=1;
                        }else{
                                LOG(L_CRIT, "BUG: do_action: bad forward() types %d, %d\n",
-                                               a->p1_type, a->p2_type);
+                                               a->val[0].type, a->val[1].type);
                                ret=E_BUG;
                        }
                        break;
                case SEND_T:
                case SEND_TCP_T:
-                       if ((a->p1_type!= PROXY_ST)|(a->p2_type!=NUMBER_ST)){
+                       if ((a->val[0].type!= PROXY_ST)|(a->val[1].type!=NUMBER_ST)){
                                LOG(L_CRIT, "BUG: do_action: bad send() types %d, %d\n",
-                                               a->p1_type, a->p2_type);
+                                               a->val[0].type, a->val[1].type);
                                ret=E_BUG;
                                break;
                        }
@@ -246,13 +246,13 @@ int do_action(struct action* a, struct sip_msg* msg)
                                ret=E_OUT_OF_MEM;
                                break;
                        }
-                       
-                       p=(struct proxy_l*)a->p1.data;
-                       
+
+                       p=(struct proxy_l*)a->val[0].u.data;
+
                        if (p->ok==0){
                                if (p->host.h_addr_list[p->addr_idx+1])
                                        p->addr_idx++;
-                               else 
+                               else
                                        p->addr_idx=0;
                                p->ok=1;
                        }
@@ -289,132 +289,132 @@ int do_action(struct action* a, struct sip_msg* msg)
                                p->errors++;
                                p->ok=0;
                        }else ret=1;
-                       
+
                        break;
                case LOG_T:
-                       if ((a->p1_type!=NUMBER_ST)|(a->p2_type!=STRING_ST)){
+                       if ((a->val[0].type!=NUMBER_ST)|(a->val[1].type!=STRING_ST)){
                                LOG(L_CRIT, "BUG: do_action: bad log() types %d, %d\n",
-                                               a->p1_type, a->p2_type);
+                                               a->val[0].type, a->val[1].type);
                                ret=E_BUG;
                                break;
                        }
-                       LOG(a->p1.number, "%s", a->p2.string);
+                       LOG(a->val[0].u.number, "%s", a->val[1].u.string);
                        ret=1;
                        break;
 
                /* jku -- introduce a new branch */
                case APPEND_BRANCH_T:
-                       if ((a->p1_type!=STRING_ST)) {
+                       if ((a->val[0].type!=STRING_ST)) {
                                LOG(L_CRIT, "BUG: do_action: bad append_branch_t %d\n",
-                                       a->p1_type );
+                                       a->val[0].type );
                                ret=E_BUG;
                                break;
                        }
-                       ret=append_branch( msg, a->p1.string, 
-                                          a->p1.string ? strlen(a->p1.string):0,
-                                          0, 0, a->p2.number, 0);
+                       ret=append_branch( msg, a->val[0].u.string,
+                                          a->val[0].u.string ? strlen(a->val[0].u.string):0,
+                                          0, 0, a->val[1].u.number, 0);
                        break;
 
                /* jku begin: is_length_greater_than */
                case LEN_GT_T:
-                       if (a->p1_type!=NUMBER_ST) {
+                       if (a->val[0].type!=NUMBER_ST) {
                                LOG(L_CRIT, "BUG: do_action: bad len_gt type %d\n",
-                                       a->p1_type );
+                                       a->val[0].type );
                                ret=E_BUG;
                                break;
                        }
-                       /* DBG("XXX: message length %d, max %d\n", 
-                               msg->len, a->p1.number ); */
-                       ret = msg->len >= a->p1.number ? 1 : -1;
+                       /* DBG("XXX: message length %d, max %d\n",
+                               msg->len, a->val[0].u.number ); */
+                       ret = msg->len >= a->val[0].u.number ? 1 : -1;
                        break;
                /* jku end: is_length_greater_than */
-                       
+
                /* jku - begin : flag processing */
 
                case SETFLAG_T:
-                       if (a->p1_type!=NUMBER_ST) {
+                       if (a->val[0].type!=NUMBER_ST) {
                                LOG(L_CRIT, "BUG: do_action: bad setflag() type %d\n",
-                                       a->p1_type );
+                                       a->val[0].type );
                                ret=E_BUG;
                                break;
                        }
-                       if (!flag_in_range( a->p1.number )) {
+                       if (!flag_in_range( a->val[0].u.number )) {
                                ret=E_CFG;
                                break;
                        }
-                       setflag( msg, a->p1.number );
+                       setflag( msg, a->val[0].u.number );
                        ret=1;
                        break;
 
                case RESETFLAG_T:
-                       if (a->p1_type!=NUMBER_ST) {
+                       if (a->val[0].type!=NUMBER_ST) {
                                LOG(L_CRIT, "BUG: do_action: bad resetflag() type %d\n",
-                                       a->p1_type );
+                                       a->val[0].type );
                                ret=E_BUG;
                                break;
                        }
-                       if (!flag_in_range( a->p1.number )) {
+                       if (!flag_in_range( a->val[0].u.number )) {
                                ret=E_CFG;
                                break;
                        }
-                       resetflag( msg, a->p1.number );
+                       resetflag( msg, a->val[0].u.number );
                        ret=1;
                        break;
-                       
+
                case ISFLAGSET_T:
-                       if (a->p1_type!=NUMBER_ST) {
+                       if (a->val[0].type!=NUMBER_ST) {
                                LOG(L_CRIT, "BUG: do_action: bad isflagset() type %d\n",
-                                       a->p1_type );
+                                       a->val[0].type );
                                ret=E_BUG;
                                break;
                        }
-                       if (!flag_in_range( a->p1.number )) {
+                       if (!flag_in_range( a->val[0].u.number )) {
                                ret=E_CFG;
                                break;
                        }
-                       ret=isflagset( msg, a->p1.number );
+                       ret=isflagset( msg, a->val[0].u.number );
                        break;
                /* jku - end : flag processing */
 
                case ERROR_T:
-                       if ((a->p1_type!=STRING_ST)|(a->p2_type!=STRING_ST)){
+                       if ((a->val[0].type!=STRING_ST)|(a->val[1].type!=STRING_ST)){
                                LOG(L_CRIT, "BUG: do_action: bad error() types %d, %d\n",
-                                               a->p1_type, a->p2_type);
+                                               a->val[0].type, a->val[1].type);
                                ret=E_BUG;
                                break;
                        }
                        LOG(L_NOTICE, "WARNING: do_action: error(\"%s\", \"%s\") "
-                                       "not implemented yet\n", a->p1.string, a->p2.string);
+                                       "not implemented yet\n", a->val[0].u.string, a->val[1].u.string);
                        ret=1;
                        break;
                case ROUTE_T:
-                       if (a->p1_type!=NUMBER_ST){
+                       if (a->val[0].type!=NUMBER_ST){
                                LOG(L_CRIT, "BUG: do_action: bad route() type %d\n",
-                                               a->p1_type);
+                                               a->val[0].type);
                                ret=E_BUG;
                                break;
                        }
-                       if ((a->p1.number>RT_NO)||(a->p1.number<0)){
+                       if ((a->val[0].u.number>RT_NO)||(a->val[0].u.number<0)){
                                LOG(L_ERR, "ERROR: invalid routing table number in"
-                                                       "route(%lu)\n", a->p1.number);
+                                                       "route(%lu)\n", a->val[0].u.number);
                                ret=E_CFG;
                                break;
                        }
-                       /*ret=((ret=run_actions(rlist[a->p1.number], msg))<0)?ret:1;*/
-                       ret=run_actions(rlist[a->p1.number], msg);
+                       /*ret=((ret=run_actions(rlist[a->val[0].u.number], msg))<0)?ret:1;*/
+                       ret=run_actions(rlist[a->val[0].u.number], msg);
                        last_retcode=ret;
                        run_flags&=~RETURN_R_F; /* absorb returns */
                        break;
                case EXEC_T:
-                       if (a->p1_type!=STRING_ST){
+                       if (a->val[0].type!=STRING_ST){
                                LOG(L_CRIT, "BUG: do_action: bad exec() type %d\n",
-                                               a->p1_type);
+                                               a->val[0].type);
                                ret=E_BUG;
                                break;
                        }
                        LOG(L_NOTICE, "WARNING: exec(\"%s\") not fully implemented,"
-                                               " using dumb version...\n", a->p1.string);
-                       ret=system(a->p1.string);
+                                               " using dumb version...\n", a->val[0].u.string);
+                       ret=system(a->val[0].u.string);
                        if (ret!=0){
                                LOG(L_NOTICE, "WARNING: exec() returned %d\n", ret);
                        }
@@ -440,14 +440,14 @@ int do_action(struct action* a, struct sip_msg* msg)
                case STRIP_TAIL_T:
                                user=0;
                                if (a->type==STRIP_T || a->type==STRIP_TAIL_T) {
-                                       if (a->p1_type!=NUMBER_ST) {
+                                       if (a->val[0].type!=NUMBER_ST) {
                                                LOG(L_CRIT, "BUG: do_action: bad set*() type %d\n",
-                                                       a->p1_type);
+                                                       a->val[0].type);
                                                break;
                                        }
-                               } else if (a->p1_type!=STRING_ST){
+                               } else if (a->val[0].type!=STRING_ST){
                                        LOG(L_CRIT, "BUG: do_action: bad set*() type %d\n",
-                                                       a->p1_type);
+                                                       a->val[0].type);
                                        ret=E_BUG;
                                        break;
                                }
@@ -457,7 +457,7 @@ int do_action(struct action* a, struct sip_msg* msg)
                                                        msg->new_uri.len=0;
                                        }
                                        msg->parsed_uri_ok=0;
-                                       len=strlen(a->p1.string);
+                                       len=strlen(a->val[0].u.string);
                                        msg->new_uri.s=pkg_malloc(len+1);
                                        if (msg->new_uri.s==0){
                                                LOG(L_ERR, "ERROR: do_action: memory allocation"
@@ -465,10 +465,10 @@ int do_action(struct action* a, struct sip_msg* msg)
                                                ret=E_OUT_OF_MEM;
                                                break;
                                        }
-                                       memcpy(msg->new_uri.s, a->p1.string, len);
+                                       memcpy(msg->new_uri.s, a->val[0].u.string, len);
                                        msg->new_uri.s[len]=0;
                                        msg->new_uri.len=len;
-                                       
+
                                        ret=1;
                                        break;
                                }
@@ -485,7 +485,7 @@ int do_action(struct action* a, struct sip_msg* msg)
                                        ret=E_UNSPEC;
                                        break;
                                }
-                               
+
                                new_uri=pkg_malloc(MAX_URI_SIZE);
                                if (new_uri==0){
                                        LOG(L_ERR, "ERROR: do_action: memory allocation "
@@ -503,40 +503,40 @@ int do_action(struct action* a, struct sip_msg* msg)
 
                                /* prefix (-jiri) */
                                if (a->type==PREFIX_T) {
-                                       tmp=a->p1.string;
+                                       tmp=a->val[0].u.string;
                                        len=strlen(tmp); if(crt+len>end) goto error_uri;
                                        memcpy(crt,tmp,len);crt+=len;
-                                       /* whatever we had before, with prefix we have username 
+                                       /* whatever we had before, with prefix we have username
                                           now */
                                        user=1;
                                }
 
                                if ((a->type==SET_USER_T)||(a->type==SET_USERPASS_T)) {
-                                       tmp=a->p1.string;
+                                       tmp=a->val[0].u.string;
                                        len=strlen(tmp);
                                } else if (a->type==STRIP_T) {
-                                       if (a->p1.number>uri.user.len) {
+                                       if (a->val[0].u.number>uri.user.len) {
                                                LOG(L_WARN, "Error: too long strip asked; "
                                                                        " deleting username: %lu of <%.*s>\n",
-                                                                       a->p1.number, uri.user.len, uri.user.s );
+                                                                       a->val[0].u.number, uri.user.len, uri.user.s );
                                                len=0;
-                                       } else if (a->p1.number==uri.user.len) {
+                                       } else if (a->val[0].u.number==uri.user.len) {
                                                len=0;
                                        } else {
-                                               tmp=uri.user.s + a->p1.number;
-                                               len=uri.user.len - a->p1.number;
+                                               tmp=uri.user.s + a->val[0].u.number;
+                                               len=uri.user.len - a->val[0].u.number;
                                        }
                                } else if (a->type==STRIP_TAIL_T) {
-                                       if (a->p1.number>uri.user.len) {
+                                       if (a->val[0].u.number>uri.user.len) {
                                                LOG(L_WARN, "WARNING: too long strip_tail asked; "
                                                                        " deleting username: %lu of <%.*s>\n",
-                                                                       a->p1.number, uri.user.len, uri.user.s );
+                                                                       a->val[0].u.number, uri.user.len, uri.user.s );
                                                len=0;
-                                       } else if (a->p1.number==uri.user.len) {
+                                       } else if (a->val[0].u.number==uri.user.len) {
                                                len=0;
                                        } else {
                                                tmp=uri.user.s;
-                                               len=uri.user.len - a->p1.number;
+                                               len=uri.user.len - a->val[0].u.number;
                                        }
                                } else {
                                        tmp=uri.user.s;
@@ -563,7 +563,7 @@ int do_action(struct action* a, struct sip_msg* msg)
                                        *crt='@'; crt++;
                                }
                                if ((a->type==SET_HOST_T) ||(a->type==SET_HOSTPORT_T)) {
-                                       tmp=a->p1.string;
+                                       tmp=a->val[0].u.string;
                                        if (tmp) len = strlen(tmp);
                                        else len=0;
                                } else {
@@ -577,7 +577,7 @@ int do_action(struct action* a, struct sip_msg* msg)
                                /* port */
                                if (a->type==SET_HOSTPORT_T) tmp=0;
                                else if (a->type==SET_PORT_T) {
-                                       tmp=a->p1.string;
+                                       tmp=a->val[0].u.string;
                                        if (tmp) len = strlen(tmp);
                                        else len = 0;
                                } else {
@@ -613,8 +613,8 @@ int do_action(struct action* a, struct sip_msg* msg)
                                break;
                case IF_T:
                                /* if null expr => ignore if? */
-                               if ((a->p1_type==EXPR_ST)&&a->p1.data){
-                                       v=eval_expr((struct expr*)a->p1.data, msg);
+                               if ((a->val[0].type==EXPR_ST)&&a->val[0].u.data){
+                                       v=eval_expr((struct expr*)a->val[0].u.data, msg);
 #if 0
                                        if (v<0){
                                                if (v==EXPR_DROP){ /* hack to quit on DROP*/
@@ -633,21 +633,22 @@ int do_action(struct action* a, struct sip_msg* msg)
                                        run_flags &= ~RETURN_R_F; /* catch returns in expr */
                                        ret=1;  /*default is continue */
                                        if (v>0) {
-                                               if ((a->p2_type==ACTIONS_ST)&&a->p2.data){
-                                                       ret=run_actions((struct action*)a->p2.data, msg);
+                                               if ((a->val[1].type==ACTIONS_ST)&&a->val[1].u.data){
+                                                       ret=run_actions((struct action*)a->val[1].u.data, msg);
                                                }
-                                       }else if ((a->p3_type==ACTIONS_ST)&&a->p3.data){
-                                                       ret=run_actions((struct action*)a->p3.data, msg);
+                                       }else if ((a->val[2].type==ACTIONS_ST)&&a->val[2].u.data){
+                                                       ret=run_actions((struct action*)a->val[2].u.data, msg);
                                        }
                                }
                        break;
                case MODULE_T:
-                       if ( ((a->p1_type==CMDF_ST)&&a->p1.data)/*&&
-                                       ((a->p2_type==STRING_ST)&&a->p2.data)*/ ){
-                               ret=((cmd_function)(a->p1.data))(msg, (char*)a->p2.data,
-                                                                                                         (char*)a->p3.data);
+                       if ( a->val[0].type==MODEXP_ST && a->val[0].u.data && ((cmd_export_t*)a->val[0].u.data)->function ){
+                               ret=((cmd_export_t*)a->val[0].u.data)->function(msg,
+                                       (char*)a->val[2].u.data,
+                                       (char*)a->val[3].u.data
+                               );
                                if (ret==0) run_flags|=EXIT_R_F;
-                       }else{
+                       } else {
                                LOG(L_CRIT,"BUG: do_action: bad module call\n");
                        }
                        break;
@@ -656,23 +657,23 @@ int do_action(struct action* a, struct sip_msg* msg)
                        ret=1; /* continue processing */
                        break;
                case SET_ADV_ADDR_T:
-                       if (a->p1_type!=STR_ST){
+                       if (a->val[0].type!=STR_ST){
                                LOG(L_CRIT, "BUG: do_action: bad set_advertised_address() "
-                                               "type %d\n", a->p1_type);
+                                               "type %d\n", a->val[0].type);
                                ret=E_BUG;
                                break;
                        }
-                       msg->set_global_address=*((str*)a->p1.data);
+                       msg->set_global_address=*((str*)a->val[0].u.data);
                        ret=1; /* continue processing */
                        break;
                case SET_ADV_PORT_T:
-                       if (a->p1_type!=STR_ST){
+                       if (a->val[0].type!=STR_ST){
                                LOG(L_CRIT, "BUG: do_action: bad set_advertised_port() "
-                                               "type %d\n", a->p1_type);
+                                               "type %d\n", a->val[0].type);
                                ret=E_BUG;
                                break;
                        }
-                       msg->set_global_port=*((str*)a->p1.data);
+                       msg->set_global_port=*((str*)a->val[0].u.data);
                        ret=1; /* continue processing */
                        break;
 #ifdef USE_TCP
@@ -682,16 +683,16 @@ int do_action(struct action* a, struct sip_msg* msg)
                                        || msg->rcv.proto==PROTO_TLS
 #endif
                           ){
-                               
-                               if (a->p1_type==NOSUBTYPE)      port=msg->via1->port;
-                               else if (a->p1_type==NUMBER_ST) port=(int)a->p1.number;
+
+                               if (a->val[0].type==NOSUBTYPE)  port=msg->via1->port;
+                               else if (a->val[0].type==NUMBER_ST) port=(int)a->val[0].u.number;
                                else{
                                        LOG(L_CRIT, "BUG: do_action: bad force_tcp_alias"
-                                                       " port type %d\n", a->p1_type);
+                                                       " port type %d\n", a->val[0].type);
                                        ret=E_BUG;
                                        break;
                                }
-                                               
+
                                if (tcpconn_add_alias(msg->rcv.proto_reserved1, port,
                                                                        msg->rcv.proto)!=0){
                                        LOG(L_ERR, " ERROR: receive_msg: tcp alias failed\n");
@@ -703,45 +704,45 @@ int do_action(struct action* a, struct sip_msg* msg)
                        ret=1; /* continue processing */
                        break;
                case FORCE_SEND_SOCKET_T:
-                       if (a->p1_type!=SOCKETINFO_ST){
+                       if (a->val[0].type!=SOCKETINFO_ST){
                                LOG(L_CRIT, "BUG: do_action: bad force_send_socket argument"
-                                               " type: %d\n", a->p1_type);
+                                               " type: %d\n", a->val[0].type);
                                ret=E_BUG;
                                break;
                        }
-                       msg->force_send_socket=(struct socket_info*)a->p1.data;
+                       msg->force_send_socket=(struct socket_info*)a->val[0].u.data;
                        ret=1; /* continue processing */
                        break;
 
                case ADD_T:
                case ASSIGN_T:
-               
+
                        /* If the left attr was specified withou indexing brackets delete
                         * existing AVPs before adding new ones
                         */
-                       if ((a->p1.attr->type & AVP_INDEX_ALL) != AVP_INDEX_ALL) delete_avp(a->p1.attr->type, a->p1.attr->name);
-                       
-                       if (a->p2_type == STRING_ST) {
-                               value.s = a->p2.str;
-                               flags = a->p1.attr->type | AVP_VAL_STR;
-                               name = a->p1.attr->name;
+                       if ((a->val[0].u.attr->type & AVP_INDEX_ALL) != AVP_INDEX_ALL) delete_avp(a->val[0].u.attr->type, a->val[0].u.attr->name);
+
+                       if (a->val[1].type == STRING_ST) {
+                               value.s = a->val[1].u.str;
+                               flags = a->val[0].u.attr->type | AVP_VAL_STR;
+                               name = a->val[0].u.attr->name;
                                ret = 1;
-                       } else if (a->p2_type == NUMBER_ST) {
-                               value.n = a->p2.number;
-                               flags = a->p1.attr->type;
-                               name = a->p1.attr->name;
+                       } else if (a->val[1].type == NUMBER_ST) {
+                               value.n = a->val[1].u.number;
+                               flags = a->val[0].u.attr->type;
+                               name = a->val[0].u.attr->name;
                                ret = 1;
-                       } else if (a->p2_type == ACTION_ST) {
-                               flags = a->p1.attr->type;
-                               name = a->p1.attr->name;
-                               if (a->p2.data) {
-                                       value.n = run_actions((struct action*)a->p2.data, msg);
+                       } else if (a->val[1].type == ACTION_ST) {
+                               flags = a->val[0].u.attr->type;
+                               name = a->val[0].u.attr->name;
+                               if (a->val[1].u.data) {
+                                       value.n = run_actions((struct action*)a->val[1].u.data, msg);
                                } else {
                                        value.n = -1;
                                }
                                ret = value.n;
-                       } else if(a->p2_type == EXPR_ST && a->p2.data) {
-                               v = eval_expr((struct expr*)a->p2.data, msg);
+                       } else if(a->val[1].type == EXPR_ST && a->val[1].u.data) {
+                               v = eval_expr((struct expr*)a->val[1].u.data, msg);
                                if (v < 0) {
                                        if (v == EXPR_DROP){ /* hack to quit on DROP*/
                                                ret = 0;
@@ -750,55 +751,55 @@ int do_action(struct action* a, struct sip_msg* msg)
                                                LOG(L_WARN,"WARNING: do_action: error in expression\n");
                                        }
                                }
-                               
-                               flags = a->p1.attr->type;
-                               name = a->p1.attr->name;
+
+                               flags = a->val[0].u.attr->type;
+                               name = a->val[0].u.attr->name;
                                value.n = v;
-                       } else if (a->p2_type == AVP_ST) {
+                       } else if (a->val[1].type == AVP_ST) {
                                struct search_state st;
-                               avp_t* avp; 
+                               avp_t* avp;
                                avp_t* avp_mark;
-                               
+
                                avp_mark = NULL;
-                               if ((a->p2.attr->type & AVP_INDEX_ALL) == AVP_INDEX_ALL) {
-                                       avp = search_first_avp(a->p2.attr->type, a->p2.attr->name, &value, &st);
+                               if ((a->val[1].u.attr->type & AVP_INDEX_ALL) == AVP_INDEX_ALL) {
+                                       avp = search_first_avp(a->val[1].u.attr->type, a->val[1].u.attr->name, &value, &st);
                                        while(avp) {
                                                     /* We take only the type of value and name from the source avp
                                                      * and reset class and track flags
                                                      */
-                                               flags = (a->p1.attr->type & ~AVP_INDEX_ALL) | (avp->flags & ~(AVP_CLASS_ALL|AVP_TRACK_ALL));
-                                               
-                                               if (add_avp_before(avp_mark, flags, a->p1.attr->name, value) < 0) {
+                                               flags = (a->val[0].u.attr->type & ~AVP_INDEX_ALL) | (avp->flags & ~(AVP_CLASS_ALL|AVP_TRACK_ALL));
+
+                                               if (add_avp_before(avp_mark, flags, a->val[0].u.attr->name, value) < 0) {
                                                        LOG(L_CRIT, "ERROR: Failed to assign value to attribute\n");
                                                        ret=E_UNSPEC;
                                                        break;
                                                }
-                                               
+
                                                /* move the mark, so the next found AVP will come before the one currently added
                                                 * so they will have the same order as in the source list
                                                 */
                                                if (avp_mark) {
                                                        avp_mark=avp_mark->next;
                                                } else {
-                                                       avp_mark=search_first_avp(flags, a->p1.attr->name, NULL, NULL);
+                                                       avp_mark=search_first_avp(flags, a->val[0].u.attr->name, NULL, NULL);
                                                }
-                                                       
+
                                                avp = search_next_avp(&st, &value);
                                        }
                                        ret = 1;
                                        break;
                                } else {
-                                       avp = search_avp_by_index(a->p2.attr->type, a->p2.attr->name, &value, a->p2.attr->index);
+                                       avp = search_avp_by_index(a->val[1].u.attr->type, a->val[1].u.attr->name, &value, a->val[1].u.attr->index);
                                        if (avp) {
-                                               flags = a->p1.attr->type | (avp->flags & ~(AVP_CLASS_ALL|AVP_TRACK_ALL));
+                                               flags = a->val[0].u.attr->type | (avp->flags & ~(AVP_CLASS_ALL|AVP_TRACK_ALL));
                                        } else {
                                                ret = E_UNSPEC;
                                                break;
                                        }
                                }
-                       } else if (a->p2_type == SELECT_ST) {
+                       } else if (a->val[1].type == SELECT_ST) {
                                int r;
-                               r = run_select(&value.s, a->p2.select, msg);
+                               r = run_select(&value.s, a->val[1].u.select, msg);
                                if (r < 0) {
                                        ret=E_UNSPEC;
                                        break;
@@ -807,8 +808,8 @@ int do_action(struct action* a, struct sip_msg* msg)
                                        value.s.len = 0;
                                }
 
-                               flags = a->p1.attr->type | AVP_VAL_STR;
-                               name = a->p1.attr->name;
+                               flags = a->val[0].u.attr->type | AVP_VAL_STR;
+                               name = a->val[0].u.attr->name;
                                ret = 1;
                        } else {
                                LOG(L_CRIT, "BUG: do_action: Bad right side of avp assignment\n");
@@ -831,7 +832,7 @@ int do_action(struct action* a, struct sip_msg* msg)
        }
 /*skip:*/
        return ret;
-       
+
 error_uri:
        LOG(L_ERR, "ERROR: do_action: set*: uri too long\n");
        if (new_uri) pkg_free(new_uri);
@@ -869,9 +870,9 @@ int run_actions(struct action* a, struct sip_msg* msg)
                        goto end;
                }
        }
-               
+
        if (a==0){
-               LOG(L_ERR, "WARNING: run_actions: null action list (rec_level=%d)\n", 
+               LOG(L_ERR, "WARNING: run_actions: null action list (rec_level=%d)\n",
                        rec_lev);
                ret=0;
        }
@@ -887,18 +888,18 @@ int run_actions(struct action* a, struct sip_msg* msg)
                }
                /* ignore error returns */
        }
-       
+
        rec_lev--;
 end:
        /* process module onbreak handlers if present */
-       if (rec_lev==0 && ret==0) 
-               for (mod=modules;mod;mod=mod->next) 
+       if (rec_lev==0 && ret==0)
+               for (mod=modules;mod;mod=mod->next)
                        if (mod->exports && mod->exports->onbreak_f) {
                                mod->exports->onbreak_f( msg );
                                DBG("DEBUG: %s onbreak handler called\n", mod->exports->name);
                        }
        return ret;
-       
+
 
 error:
        rec_lev--;
diff --git a/cfg.y b/cfg.y
index 6b25787..77fb63a 100644 (file)
--- a/cfg.y
+++ b/cfg.y
@@ -117,7 +117,6 @@ extern int yylex();
 static void yyerror(char* s);
 static char* tmp;
 static int i_tmp;
-static void* f_tmp;
 static struct socket_id* lst_tmp;
 static int rt;  /* Type of route block for find_export */
 static str* str_tmp;
@@ -126,7 +125,7 @@ static struct ip_addr* ip_tmp;
 static struct avp_spec* s_attr;
 static select_t sel;
 static select_t* sel_ptr;
-
+static struct action *mod_func_action;
 
 static void warn(char* s);
 static struct socket_id* mk_listen_id(char*, int, int);
@@ -349,1700 +348,1282 @@ static struct socket_id* mk_listen_id(char*, int, int);
   %type <route_el> rule;
 */
 
-
-
 %%
 
 
-cfg:   statements
+cfg:
+       statements
        ;
-
-statements:    statements statement {}
-               | statement {}
-               | statements error { yyerror(""); YYABORT;}
+statements:
+       statements statement {}
+       | statement {}
+       | statements error { yyerror(""); YYABORT;}
        ;
-
-statement:     assign_stm
-               | module_stm
-               | {rt=REQUEST_ROUTE;} route_stm
-               | {rt=FAILURE_ROUTE;} failure_route_stm
-               | {rt=ONREPLY_ROUTE;} onreply_route_stm
-               | {rt=BRANCH_ROUTE;} branch_route_stm
-               | {rt=ONSEND_ROUTE;}   send_route_stm
-               | SEMICOLON     /* null statement */
-               | CR    /* null statement*/
+statement:
+       assign_stm
+       | module_stm
+       | {rt=REQUEST_ROUTE;} route_stm
+       | {rt=FAILURE_ROUTE;} failure_route_stm
+       | {rt=ONREPLY_ROUTE;} onreply_route_stm
+       | {rt=BRANCH_ROUTE;} branch_route_stm
+       | {rt=ONSEND_ROUTE;}   send_route_stm
+       | SEMICOLON     /* null statement */
+       | CR    /* null statement*/
        ;
-
-listen_id:     ip                      {       tmp=ip_addr2a($1);
-                                                       if(tmp==0){
-                                                               LOG(L_CRIT, "ERROR: cfg. parser: bad ip "
-                                                                               "address.\n");
-                                                               $$=0;
-                                                       }else{
-                                                               $$=pkg_malloc(strlen(tmp)+1);
-                                                               if ($$==0){
-                                                                       LOG(L_CRIT, "ERROR: cfg. parser: out of "
-                                                                                       "memory.\n");
-                                                               }else{
-                                                                       strncpy($$, tmp, strlen(tmp)+1);
-                                                               }
-                                                       }
-                                               }
-                |      STRING                  {       $$=pkg_malloc(strlen($1)+1);
-                                                       if ($$==0){
-                                                                       LOG(L_CRIT, "ERROR: cfg. parser: out of "
-                                                                                       "memory.\n");
-                                                       }else{
-                                                                       strncpy($$, $1, strlen($1)+1);
-                                                       }
-                                               }
-                |      host            {       $$=pkg_malloc(strlen($1)+1);
-                                                       if ($$==0){
-                                                                       LOG(L_CRIT, "ERROR: cfg. parser: out of "
-                                                                                       "memory.\n");
-                                                       }else{
-                                                                       strncpy($$, $1, strlen($1)+1);
-                                                       }
-                                               }
+listen_id:
+       ip {
+               tmp=ip_addr2a($1);
+               if (tmp==0) {
+                       LOG(L_CRIT, "ERROR: cfg. parser: bad ip "
+                                       "address.\n");
+                       $$=0;
+               } else {
+                       $$=pkg_malloc(strlen(tmp)+1);
+                       if ($$==0) {
+                               LOG(L_CRIT, "ERROR: cfg. parser: out of "
+                                               "memory.\n");
+                       } else {
+                               strncpy($$, tmp, strlen(tmp)+1);
+                       }
+               }
+       }
+       | STRING {
+               $$=pkg_malloc(strlen($1)+1);
+               if ($$==0) {
+                               LOG(L_CRIT, "ERROR: cfg. parser: out of "
+                                               "memory.\n");
+               } else {
+                               strncpy($$, $1, strlen($1)+1);
+               }
+       }
+       | host {
+               $$=pkg_malloc(strlen($1)+1);
+               if ($$==0) {
+                               LOG(L_CRIT, "ERROR: cfg. parser: out of "
+                                               "memory.\n");
+               } else {
+                               strncpy($$, $1, strlen($1)+1);
+               }
+       }
        ;
-
-proto:   UDP   { $$=PROTO_UDP; }
-               | TCP   { $$=PROTO_TCP; }
-               | TLS   { $$=PROTO_TLS; }
-               | STAR  { $$=0; }
-               ;
-
-port:    NUMBER        { $$=$1; }
-               | STAR          { $$=0; }
+proto:
+       UDP     { $$=PROTO_UDP; }
+       | TCP   { $$=PROTO_TCP; }
+       | TLS   { $$=PROTO_TLS; }
+       | STAR  { $$=0; }
+       ;
+port:
+       NUMBER  { $$=$1; }
+       | STAR  { $$=0; }
 ;
-
-phostport:     listen_id                               { $$=mk_listen_id($1, 0, 0); }
-                       | listen_id COLON port  { $$=mk_listen_id($1, 0, $3); }
-                       | proto COLON listen_id { $$=mk_listen_id($3, $1, 0); }
-                       | proto COLON listen_id COLON port      { $$=mk_listen_id($3, $1, $5);}
-                       | listen_id COLON error { $$=0; yyerror(" port number expected"); }
-                       ;
-
-id_lst:                phostport               {  $$=$1 ; }
-               | phostport id_lst      { $$=$1; $$->next=$2; }
-               ;
-
-
-assign_stm:    DEBUG_V EQUAL NUMBER { debug=$3; }
-               | DEBUG_V EQUAL error  { yyerror("number  expected"); }
-               | FORK  EQUAL NUMBER { dont_fork= ! $3; }
-               | FORK  EQUAL error  { yyerror("boolean value expected"); }
-               | LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }
-               | LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
-               | LOGFACILITY EQUAL ID {
-                                       if ( (i_tmp=str2facility($3))==-1)
-                                               yyerror("bad facility (see syslog(3) man page)");
-                                       if (!config_check)
-                                               log_facility=i_tmp;
-                                                                       }
-               | LOGFACILITY EQUAL error { yyerror("ID expected"); }
-               | DNS EQUAL NUMBER   { received_dns|= ($3)?DO_DNS:0; }
-               | DNS EQUAL error { yyerror("boolean value expected"); }
-               | REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
-               | REV_DNS EQUAL error { yyerror("boolean value expected"); }
-               | DNS_TRY_IPV6 EQUAL NUMBER   { dns_try_ipv6=$3; }
-               | DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
-               | DNS_RETR_TIME EQUAL NUMBER   { dns_retr_time=$3; }
-               | DNS_RETR_TIME error { yyerror("number expected"); }
-               | DNS_RETR_NO EQUAL NUMBER   { dns_retr_no=$3; }
-               | DNS_RETR_NO error { yyerror("number expected"); }
-               | DNS_SERVERS_NO EQUAL NUMBER   { dns_servers_no=$3; }
-               | DNS_SERVERS_NO error { yyerror("number expected"); }
-               | DNS_USE_SEARCH EQUAL NUMBER   { dns_search_list=$3; }
-               | DNS_USE_SEARCH error { yyerror("boolean value expected"); }
-               | PORT EQUAL NUMBER   { port_no=$3; }
-               | STAT EQUAL STRING {
-                                       #ifdef STATS
-                                                       stat_file=$3;
-                                       #endif
-                                                       }
-               | MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
-               | MAXBUFFER EQUAL error { yyerror("number expected"); }
-               | PORT EQUAL error    { yyerror("number expected"); }
-               | CHILDREN EQUAL NUMBER { children_no=$3; }
-               | CHILDREN EQUAL error { yyerror("number expected"); }
-               | CHECK_VIA EQUAL NUMBER { check_via=$3; }
-               | CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
-               | SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
-               | SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
-               | MEMLOG EQUAL NUMBER { memlog=$3; }
-               | MEMLOG EQUAL error { yyerror("int value expected"); }
-               | SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
-               | SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
-               | USER EQUAL STRING     { user=$3; }
-               | USER EQUAL ID         { user=$3; }
-               | USER EQUAL error      { yyerror("string value expected"); }
-               | 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"); }
-               | DISABLE_TCP EQUAL NUMBER {
-                                                                       #ifdef USE_TCP
-                                                                               tcp_disable=$3;
-                                                                       #else
-                                                                               warn("tcp support not compiled in");
-                                                                       #endif
-                                                                       }
-               | DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
-               | TCP_ACCEPT_ALIASES EQUAL NUMBER {
-                                                                       #ifdef USE_TCP
-                                                                               tcp_accept_aliases=$3;
-                                                                       #else
-                                                                               warn("tcp support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
-               | TCP_CHILDREN EQUAL NUMBER {
-                                                                       #ifdef USE_TCP
-                                                                               tcp_children_no=$3;
-                                                                       #else
-                                                                               warn("tcp support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TCP_CHILDREN EQUAL error { yyerror("number expected"); }
-               | TCP_CONNECT_TIMEOUT EQUAL NUMBER {
-                                                                       #ifdef USE_TCP
-                                                                               tcp_connect_timeout=$3;
-                                                                       #else
-                                                                               warn("tcp support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
-               | TCP_SEND_TIMEOUT EQUAL NUMBER {
-                                                                       #ifdef USE_TCP
-                                                                               tcp_send_timeout=$3;
-                                                                       #else
-                                                                               warn("tcp support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
-               | TCP_CON_LIFETIME EQUAL NUMBER {
-                                                                       #ifdef USE_TCP
-                                                                               tcp_con_lifetime=$3;
-                                                                       #else
-                                                                               warn("tcp support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
-               | TCP_POLL_METHOD EQUAL ID {
-                                                                       #ifdef USE_TCP
-                                                                               tcp_poll_method=get_poll_type($3);
-                                                                               if (tcp_poll_method==POLL_NONE){
-                                                                                       LOG(L_CRIT, "bad poll method name:"
-                                                                                                       " %s\n, try one of %s.\n",
-                                                                                                       $3, poll_support);
-                                                                                       yyerror("bad tcp_poll_method "
-                                                                                                       "value");
-                                                                               }
-                                                                       #else
-                                                                               warn("tcp support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TCP_POLL_METHOD EQUAL STRING {
-                                                                       #ifdef USE_TCP
-                                                                               tcp_poll_method=get_poll_type($3);
-                                                                               if (tcp_poll_method==POLL_NONE){
-                                                                                       LOG(L_CRIT, "bad poll method name:"
-                                                                                                       " %s\n, try one of %s.\n",
-                                                                                                       $3, poll_support);
-                                                                                       yyerror("bad tcp_poll_method "
-                                                                                                       "value");
-                                                                               }
-                                                                       #else
-                                                                               warn("tcp support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
-               | TCP_MAX_CONNECTIONS EQUAL NUMBER {
-                                                                       #ifdef USE_TCP
-                                                                               tcp_max_connections=$3;
-                                                                       #else
-                                                                               warn("tcp support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
-               | DISABLE_TLS EQUAL NUMBER {
-                                                                       #ifdef USE_TLS
-                                                                               tls_disable=$3;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
-               | TLSLOG EQUAL NUMBER           {
-                                                                       #ifdef USE_TLS
-                                                                               tls_log=$3;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLSLOG EQUAL error { yyerror("int value expected"); }
-               | TLS_PORT_NO EQUAL NUMBER {
-                                                                       #ifdef USE_TLS
-                                                                               tls_port_no=$3;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLS_PORT_NO EQUAL error { yyerror("number expected"); }
-               | TLS_METHOD EQUAL SSLv23 {
-                                                                       #ifdef USE_TLS
-                                                                               tls_method=TLS_USE_SSLv23;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLS_METHOD EQUAL SSLv2 {
-                                                                       #ifdef USE_TLS
-                                                                               tls_method=TLS_USE_SSLv2;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLS_METHOD EQUAL SSLv3 {
-                                                                       #ifdef USE_TLS
-                                                                               tls_method=TLS_USE_SSLv3;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLS_METHOD EQUAL TLSv1 {
-                                                                       #ifdef USE_TLS
-                                                                               tls_method=TLS_USE_TLSv1;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLS_METHOD EQUAL error {
-                                                                       #ifdef USE_TLS
-                                                                               yyerror("SSLv23, SSLv2, SSLv3 or TLSv1"
-                                                                                                       " expected");
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-
-               | TLS_VERIFY EQUAL NUMBER {
-                                                                       #ifdef USE_TLS
-                                                                               tls_verify_cert=$3;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
-               | TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
-                                                                       #ifdef USE_TLS
-                                                                               tls_require_cert=$3;
-                                                                       #else
-                                                                               warn( "tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value"
-                                                                                                                               " expected"); }
-               | TLS_CERTIFICATE EQUAL STRING {
-                                                                       #ifdef USE_TLS
-                                                                                       tls_cert_file=$3;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
-               | TLS_PRIVATE_KEY EQUAL STRING {
-                                                                       #ifdef USE_TLS
-                                                                                       tls_pkey_file=$3;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
-               | TLS_CA_LIST EQUAL STRING {
-                                                                       #ifdef USE_TLS
-                                                                                       tls_ca_file=$3;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
-               | TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
-                                                                       #ifdef USE_TLS
-                                                                               tls_handshake_timeout=$3;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
-               | TLS_SEND_TIMEOUT EQUAL NUMBER {
-                                                                       #ifdef USE_TLS
-                                                                               tls_send_timeout=$3;
-                                                                       #else
-                                                                               warn("tls support not compiled in");
-                                                                       #endif
-                                                                       }
-               | TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
-               | SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
-               | SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
-               | REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
-               | REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
-               | LISTEN EQUAL id_lst {
-                                                       for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next){
-                                                               if (add_listen_iface(   lst_tmp->name,
-                                                                                                               lst_tmp->port,
-                                                                                                               lst_tmp->proto,
-                                                                                                               0
-                                                                                                       )!=0){
-                                                                       LOG(L_CRIT,  "ERROR: cfg. parser: failed"
-                                                                                       " to add listen address\n");
-                                                                       break;
-                                                               }
-                                                       }
-                                                        }
-               | LISTEN EQUAL  error { yyerror("ip address or hostname"
-                                               "expected"); }
-               | ALIAS EQUAL  id_lst {
-                                                       for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next)
-                                                               add_alias(lst_tmp->name, strlen(lst_tmp->name),
-                                                                                       lst_tmp->port, lst_tmp->proto);
-                                                         }
-               | ALIAS  EQUAL error  { yyerror(" hostname expected"); }
-               | ADVERTISED_ADDRESS EQUAL listen_id {
-                                                               default_global_address.s=$3;
-                                                               default_global_address.len=strlen($3);
-                                                               }
-               |ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname "
-                                                                                               "expected"); }
-               | ADVERTISED_PORT EQUAL NUMBER {
-                                                               tmp=int2str($3, &i_tmp);
-                                                               if ((default_global_port.s=pkg_malloc(i_tmp))
-                                                                               ==0){
-                                                                               LOG(L_CRIT, "ERROR: cfg. parser:"
-                                                                                                       " out of memory.\n");
-                                                                               default_global_port.len=0;
-                                                               }else{
-                                                                       default_global_port.len=i_tmp;
-                                                                       memcpy(default_global_port.s, tmp,
-                                                                                       default_global_port.len);
-                                                               };
-                                                               }
-               |ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname "
-                                                                                               "expected"); }
-               | DISABLE_CORE EQUAL NUMBER {
-                                                                               disable_core_dump=$3;
-                                                                       }
-               | DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
-               | OPEN_FD_LIMIT EQUAL NUMBER {
-                                                                               open_files_limit=$3;
-                                                                       }
-               | OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
-               | MCAST_LOOPBACK EQUAL NUMBER {
-                                                               #ifdef USE_MCAST
-                                                                               mcast_loopback=$3;
-                                                               #else
-                                                                       warn("no multicast support compiled in");
-                                                               #endif
-                 }
-               | MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
-               | MCAST_TTL EQUAL NUMBER {
-                                                               #ifdef USE_MCAST
-                                                                               mcast_ttl=$3;
-                                                               #else
-                                                                       warn("no multicast support compiled in");
-                                                               #endif
-                 }
-               | MCAST_TTL EQUAL error { yyerror("number expected"); }
-               | TOS EQUAL NUMBER { tos=$3; }
-               | TOS EQUAL error { yyerror("number expected"); }
-               | error EQUAL { yyerror("unknown config variable"); }
+phostport:
+       listen_id               { $$=mk_listen_id($1, 0, 0); }
+       | listen_id COLON port  { $$=mk_listen_id($1, 0, $3); }
+       | proto COLON listen_id { $$=mk_listen_id($3, $1, 0); }
+       | proto COLON listen_id COLON port      { $$=mk_listen_id($3, $1, $5);}
+       | listen_id COLON error { $$=0; yyerror(" port number expected"); }
        ;
-
-module_stm:    LOADMODULE STRING       { DBG("loading module %s\n", $2);
-                                                                 if (load_module($2)!=0){
-                                                                               yyerror("failed to load module");
-                                                                 }
-                                                               }
-                | LOADMODULE error     { yyerror("string expected");  }
-                 | MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
-                        if (set_mod_param_regex($3, $5, PARAM_STRING, $7) != 0) {
-                                yyerror("Can't set module parameter");
-                        }
-                  }
-                 | MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN {
-                        if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) {
-                                yyerror("Can't set module parameter");
-                        }
-                  }
-                 | MODPARAM error { yyerror("Invalid arguments"); }
-                ;
-
-
-ip:             ipv4  { $$=$1; }
-               |ipv6  { $$=$1; }
-               ;
-
-ipv4:  NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
-                                                                                       $$=pkg_malloc(
-                                                                                                       sizeof(struct ip_addr));
-                                                                                       if ($$==0){
-                                                                                               LOG(L_CRIT, "ERROR: cfg. "
-                                                                                                       "parser: out of memory.\n"
-                                                                                                       );
-                                                                                       }else{
-                                                                                               memset($$, 0,
-                                                                                                       sizeof(struct ip_addr));
-                                                                                               $$->af=AF_INET;
-                                                                                               $$->len=4;
-                                                                                               if (($1>255) || ($1<0) ||
-                                                                                                       ($3>255) || ($3<0) ||
-                                                                                                       ($5>255) || ($5<0) ||
-                                                                                                       ($7>255) || ($7<0)){
-                                                                                                       yyerror("invalid ipv4"
-                                                                                                                       "address");
-                                                                                                       $$->u.addr32[0]=0;
-                                                                                                       /* $$=0; */
-                                                                                               }else{
-                                                                                                       $$->u.addr[0]=$1;
-                                                                                                       $$->u.addr[1]=$3;
-                                                                                                       $$->u.addr[2]=$5;
-                                                                                                       $$->u.addr[3]=$7;
-                                                                                                       /*
-                                                                                                       $$=htonl( ($1<<24)|
-                                                                                                       ($3<<16)| ($5<<8)|$7 );
-                                                                                                       */
-                                                                                               }
-                                                                                       }
-                                                                                               }
+id_lst:
+       phostport               {  $$=$1 ; }
+       | phostport id_lst      { $$=$1; $$->next=$2; }
        ;
-
-ipv6addr:      IPV6ADDR {
-                                       $$=pkg_malloc(sizeof(struct ip_addr));
-                                       if ($$==0){
-                                               LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
-                                       }else{
-                                               memset($$, 0, sizeof(struct ip_addr));
-                                               $$->af=AF_INET6;
-                                               $$->len=16;
-                                       #ifdef USE_IPV6
-                                               if (inet_pton(AF_INET6, $1, $$->u.addr)<=0){
-                                                       yyerror("bad ipv6 address");
-                                               }
-                                       #else
-                                               yyerror("ipv6 address & no ipv6 support compiled in");
-                                               YYABORT;
-                                       #endif
-                                       }
-                               }
+assign_stm:
+       DEBUG_V EQUAL NUMBER { debug=$3; }
+       | DEBUG_V EQUAL error  { yyerror("number  expected"); }
+       | FORK  EQUAL NUMBER { dont_fork= ! $3; }
+       | FORK  EQUAL error  { yyerror("boolean value expected"); }
+       | LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }
+       | LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
+       | LOGFACILITY EQUAL ID {
+               if ( (i_tmp=str2facility($3))==-1)
+                       yyerror("bad facility (see syslog(3) man page)");
+               if (!config_check)
+                       log_facility=i_tmp;
+       }
+       | LOGFACILITY EQUAL error { yyerror("ID expected"); }
+       | DNS EQUAL NUMBER   { received_dns|= ($3)?DO_DNS:0; }
+       | DNS EQUAL error { yyerror("boolean value expected"); }
+       | REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
+       | REV_DNS EQUAL error { yyerror("boolean value expected"); }
+       | DNS_TRY_IPV6 EQUAL NUMBER   { dns_try_ipv6=$3; }
+       | DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
+       | DNS_RETR_TIME EQUAL NUMBER   { dns_retr_time=$3; }
+       | DNS_RETR_TIME error { yyerror("number expected"); }
+       | DNS_RETR_NO EQUAL NUMBER   { dns_retr_no=$3; }
+       | DNS_RETR_NO error { yyerror("number expected"); }
+       | DNS_SERVERS_NO EQUAL NUMBER   { dns_servers_no=$3; }
+       | DNS_SERVERS_NO error { yyerror("number expected"); }
+       | DNS_USE_SEARCH EQUAL NUMBER   { dns_search_list=$3; }
+       | DNS_USE_SEARCH error { yyerror("boolean value expected"); }
+       | PORT EQUAL NUMBER   { port_no=$3; }
+       | STAT EQUAL STRING {
+               #ifdef STATS
+                               stat_file=$3;
+               #endif
+       }
+       | MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
+       | MAXBUFFER EQUAL error { yyerror("number expected"); }
+       | PORT EQUAL error    { yyerror("number expected"); }
+       | CHILDREN EQUAL NUMBER { children_no=$3; }
+       | CHILDREN EQUAL error { yyerror("number expected"); }
+       | CHECK_VIA EQUAL NUMBER { check_via=$3; }
+       | CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
+       | SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
+       | SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
+       | MEMLOG EQUAL NUMBER { memlog=$3; }
+       | MEMLOG EQUAL error { yyerror("int value expected"); }
+       | SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
+       | SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
+       | USER EQUAL STRING     { user=$3; }
+       | USER EQUAL ID         { user=$3; }
+       | USER EQUAL error      { yyerror("string value expected"); }
+       | 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"); }
+       | DISABLE_TCP EQUAL NUMBER {
+               #ifdef USE_TCP
+                       tcp_disable=$3;
+               #else
+                       warn("tcp support not compiled in");
+               #endif
+       }
+       | DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
+       | TCP_ACCEPT_ALIASES EQUAL NUMBER {
+               #ifdef USE_TCP
+                       tcp_accept_aliases=$3;
+               #else
+                       warn("tcp support not compiled in");
+               #endif
+       }
+       | TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
+       | TCP_CHILDREN EQUAL NUMBER {
+               #ifdef USE_TCP
+                       tcp_children_no=$3;
+               #else
+                       warn("tcp support not compiled in");
+               #endif
+       }
+       | TCP_CHILDREN EQUAL error { yyerror("number expected"); }
+       | TCP_CONNECT_TIMEOUT EQUAL NUMBER {
+               #ifdef USE_TCP
+                       tcp_connect_timeout=$3;
+               #else
+                       warn("tcp support not compiled in");
+               #endif
+       }
+       | TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
+       | TCP_SEND_TIMEOUT EQUAL NUMBER {
+               #ifdef USE_TCP
+                       tcp_send_timeout=$3;
+               #else
+                       warn("tcp support not compiled in");
+               #endif
+       }
+       | TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
+       | TCP_CON_LIFETIME EQUAL NUMBER {
+               #ifdef USE_TCP
+                       tcp_con_lifetime=$3;
+               #else
+                       warn("tcp support not compiled in");
+               #endif
+       }
+       | TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
+       | TCP_POLL_METHOD EQUAL ID {
+               #ifdef USE_TCP
+                       tcp_poll_method=get_poll_type($3);
+                       if (tcp_poll_method==POLL_NONE) {
+                               LOG(L_CRIT, "bad poll method name:"
+                                               " %s\n, try one of %s.\n",
+                                               $3, poll_support);
+                               yyerror("bad tcp_poll_method "
+                                               "value");
+                       }
+               #else
+                       warn("tcp support not compiled in");
+               #endif
+       }
+       | TCP_POLL_METHOD EQUAL STRING {
+               #ifdef USE_TCP
+                       tcp_poll_method=get_poll_type($3);
+                       if (tcp_poll_method==POLL_NONE) {
+                               LOG(L_CRIT, "bad poll method name:"
+                                               " %s\n, try one of %s.\n",
+                                               $3, poll_support);
+                               yyerror("bad tcp_poll_method "
+                                               "value");
+                       }
+               #else
+                       warn("tcp support not compiled in");
+               #endif
+       }
+       | TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
+       | TCP_MAX_CONNECTIONS EQUAL NUMBER {
+               #ifdef USE_TCP
+                       tcp_max_connections=$3;
+               #else
+                       warn("tcp support not compiled in");
+               #endif
+       }
+       | TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
+       | DISABLE_TLS EQUAL NUMBER {
+               #ifdef USE_TLS
+                       tls_disable=$3;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
+       | TLSLOG EQUAL NUMBER {
+               #ifdef USE_TLS
+                       tls_log=$3;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLSLOG EQUAL error { yyerror("int value expected"); }
+       | TLS_PORT_NO EQUAL NUMBER {
+               #ifdef USE_TLS
+                       tls_port_no=$3;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLS_PORT_NO EQUAL error { yyerror("number expected"); }
+       | TLS_METHOD EQUAL SSLv23 {
+               #ifdef USE_TLS
+                       tls_method=TLS_USE_SSLv23;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLS_METHOD EQUAL SSLv2 {
+               #ifdef USE_TLS
+                       tls_method=TLS_USE_SSLv2;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLS_METHOD EQUAL SSLv3 {
+               #ifdef USE_TLS
+                       tls_method=TLS_USE_SSLv3;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLS_METHOD EQUAL TLSv1 {
+               #ifdef USE_TLS
+                       tls_method=TLS_USE_TLSv1;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLS_METHOD EQUAL error {
+               #ifdef USE_TLS
+                       yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected");
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLS_VERIFY EQUAL NUMBER {
+               #ifdef USE_TLS
+                       tls_verify_cert=$3;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
+       | TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
+               #ifdef USE_TLS
+                       tls_require_cert=$3;
+               #else
+                       warn( "tls support not compiled in");
+               #endif
+       }
+       | TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value expected"); }
+       | TLS_CERTIFICATE EQUAL STRING {
+               #ifdef USE_TLS
+                       tls_cert_file=$3;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
+       | TLS_PRIVATE_KEY EQUAL STRING {
+               #ifdef USE_TLS
+                       tls_pkey_file=$3;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
+       | TLS_CA_LIST EQUAL STRING {
+               #ifdef USE_TLS
+                       tls_ca_file=$3;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
+       | TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
+               #ifdef USE_TLS
+                       tls_handshake_timeout=$3;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
+       | TLS_SEND_TIMEOUT EQUAL NUMBER {
+               #ifdef USE_TLS
+                       tls_send_timeout=$3;
+               #else
+                       warn("tls support not compiled in");
+               #endif
+       }
+       | TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
+       | SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
+       | SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
+       | REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
+       | REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
+       | LISTEN EQUAL id_lst {
+               for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
+                       if (add_listen_iface(lst_tmp->name, lst_tmp->port, lst_tmp->proto, 0)!=0) {
+                               LOG(L_CRIT,  "ERROR: cfg. parser: failed to add listen address\n");
+                               break;
+                       }
+               }
+       }
+       | LISTEN EQUAL  error { yyerror("ip address or hostname expected"); }
+       | ALIAS EQUAL  id_lst {
+               for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next)
+                       add_alias(lst_tmp->name, strlen(lst_tmp->name), lst_tmp->port, lst_tmp->proto);
+       }
+       | ALIAS  EQUAL error  { yyerror(" hostname expected"); }
+       | ADVERTISED_ADDRESS EQUAL listen_id {
+               default_global_address.s=$3;
+               default_global_address.len=strlen($3);
+       }
+       | ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname expected"); }
+       | ADVERTISED_PORT EQUAL NUMBER {
+               tmp=int2str($3, &i_tmp);
+               if ((default_global_port.s=pkg_malloc(i_tmp))==0) {
+                       LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
+                       default_global_port.len=0;
+               } else {
+                       default_global_port.len=i_tmp;
+                       memcpy(default_global_port.s, tmp, default_global_port.len);
+               };
+       }
+       |ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname expected"); }
+       | DISABLE_CORE EQUAL NUMBER { disable_core_dump=$3; }
+       | DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
+       | OPEN_FD_LIMIT EQUAL NUMBER { open_files_limit=$3; }
+       | OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
+       | MCAST_LOOPBACK EQUAL NUMBER {
+               #ifdef USE_MCAST
+                       mcast_loopback=$3;
+               #else
+                       warn("no multicast support compiled in");
+               #endif
+       }
+       | MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
+       | MCAST_TTL EQUAL NUMBER {
+               #ifdef USE_MCAST
+                       mcast_ttl=$3;
+               #else
+                       warn("no multicast support compiled in");
+               #endif
+       }
+       | MCAST_TTL EQUAL error { yyerror("number expected"); }
+       | TOS EQUAL NUMBER { tos=$3; }
+       | TOS EQUAL error { yyerror("number expected"); }
+       | error EQUAL { yyerror("unknown config variable"); }
        ;
-
-ipv6:  ipv6addr { $$=$1; }
+module_stm:
+       LOADMODULE STRING {
+               DBG("loading module %s\n", $2);
+                       if (load_module($2)!=0) {
+                               yyerror("failed to load module");
+                       }
+       }
+       | LOADMODULE error      { yyerror("string expected"); }
+       | MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
+               if (set_mod_param_regex($3, $5, PARAM_STRING, $7) != 0) {
+                        yyerror("Can't set module parameter");
+               }
+       }
+        | MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN {
+               if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) {
+                        yyerror("Can't set module parameter");
+               }
+       }
+       | MODPARAM error { yyerror("Invalid arguments"); }
+       ;
+ip:
+       ipv4  { $$=$1; }
+       | ipv6  { $$=$1; }
+       ;
+ipv4:
+       NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
+               $$=pkg_malloc(sizeof(struct ip_addr));
+               if ($$==0) {
+                       LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
+               } else {
+                       memset($$, 0, sizeof(struct ip_addr));
+                       $$->af=AF_INET;
+                       $$->len=4;
+                       if (($1>255) || ($1<0) ||
+                               ($3>255) || ($3<0) ||
+                               ($5>255) || ($5<0) ||
+                               ($7>255) || ($7<0)) {
+                               yyerror("invalid ipv4 address");
+                               $$->u.addr32[0]=0;
+                               /* $$=0; */
+                       } else {
+                               $$->u.addr[0]=$1;
+                               $$->u.addr[1]=$3;
+                               $$->u.addr[2]=$5;
+                               $$->u.addr[3]=$7;
+                               /*
+                               $$=htonl( ($1<<24)|
+                               ($3<<16)| ($5<<8)|$7 );
+                               */
+                       }
+               }
+       }
+       ;
+ipv6addr:
+       IPV6ADDR {
+               $$=pkg_malloc(sizeof(struct ip_addr));
+               if ($$==0) {
+                       LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
+               } else {
+                       memset($$, 0, sizeof(struct ip_addr));
+                       $$->af=AF_INET6;
+                       $$->len=16;
+               #ifdef USE_IPV6
+                       if (inet_pton(AF_INET6, $1, $$->u.addr)<=0) {
+                               yyerror("bad ipv6 address");
+                       }
+               #else
+                       yyerror("ipv6 address & no ipv6 support compiled in");
+                       YYABORT;
+               #endif
+               }
+       }
+       ;
+ipv6:
+       ipv6addr { $$=$1; }
        | LBRACK ipv6addr RBRACK {$$=$2; }
 ;
-
-
-route_stm:  ROUTE LBRACE actions RBRACE { push($3, &rlist[DEFAULT_RT]); }
-
-           | ROUTE LBRACK NUMBER RBRACK LBRACE actions RBRACE {
-                                                                               if (($3<RT_NO) && ($3>=0)){
-                                                                                       push($6, &rlist[$3]);
-                                                                               }else{
-                                                                                       yyerror("invalid routing "
-                                                                                                       "table number");
-                                                                                       YYABORT; }
-                                                                               }
-               | ROUTE error { yyerror("invalid  route  statement"); }
+route_stm:
+       ROUTE LBRACE actions RBRACE { push($3, &rlist[DEFAULT_RT]); }
+       | ROUTE LBRACK NUMBER RBRACK LBRACE actions RBRACE {
+               if (($3<RT_NO) && ($3>=0)) {
+                       push($6, &rlist[$3]);
+               } else {
+                       yyerror("invalid routing table number");
+                       YYABORT;
+               }
+       }
+       | ROUTE error { yyerror("invalid  route  statement"); }
        ;
-
-failure_route_stm: ROUTE_FAILURE LBRACK NUMBER RBRACK LBRACE actions RBRACE {
-                                                                               if (($3<FAILURE_RT_NO)&&($3>=1)){
-                                                                                       push($6, &failure_rlist[$3]);
-                                                                               } else {
-                                                                                       yyerror("invalid reply routing"
-                                                                                               "table number");
-                                                                                       YYABORT; }
-                                                                               }
-               | ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
+failure_route_stm:
+       ROUTE_FAILURE LBRACK NUMBER RBRACK LBRACE actions RBRACE {
+               if (($3<FAILURE_RT_NO)&&($3>=1)) {
+                       push($6, &failure_rlist[$3]);
+               } else {
+                       yyerror("invalid reply routing table number");
+                       YYABORT;
+               }
+       }
+       | ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
        ;
-
-onreply_route_stm: ROUTE_ONREPLY LBRACE actions RBRACE {
-                                                                               push($3, &onreply_rlist[DEFAULT_RT]);
-                                                                                         }
-                               | ROUTE_ONREPLY LBRACK NUMBER RBRACK LBRACE actions RBRACE {
-                                                                               if (($3<ONREPLY_RT_NO)&&($3>=1)){
-                                                                                       push($6, &onreply_rlist[$3]);
-                                                                               } else {
-                                                                                       yyerror("invalid reply routing"
-                                                                                               "table number");
-                                                                                       YYABORT; }
-                                                                               }
-               | ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
+onreply_route_stm:
+       ROUTE_ONREPLY LBRACE actions RBRACE { push($3, &onreply_rlist[DEFAULT_RT]); }
+       | ROUTE_ONREPLY LBRACK NUMBER RBRACK LBRACE actions RBRACE {
+               if (($3<ONREPLY_RT_NO)&&($3>=1)) {
+                       push($6, &onreply_rlist[$3]);
+               } else {
+                       yyerror("invalid reply routing table number");
+                       YYABORT;
+               }
+       }
+       | ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
        ;
-branch_route_stm: ROUTE_BRANCH LBRACE actions RBRACE {
-                                                                               push($3, &branch_rlist[DEFAULT_RT]);
-                                                                                         }
-                               | ROUTE_BRANCH LBRACK NUMBER RBRACK LBRACE actions RBRACE {
-                                                                               if (($3<BRANCH_RT_NO)&&($3>=1)){
-                                                                                       push($6, &branch_rlist[$3]);
-                                                                               } else {
-                                                                                       yyerror("invalid branch routing"
-                                                                                               "table number");
-                                                                                       YYABORT; }
-                                                                               }
-               | ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
+branch_route_stm:
+       ROUTE_BRANCH LBRACE actions RBRACE { push($3, &branch_rlist[DEFAULT_RT]); }
+       | ROUTE_BRANCH LBRACK NUMBER RBRACK LBRACE actions RBRACE {
+               if (($3<BRANCH_RT_NO)&&($3>=1)) {
+                       push($6, &branch_rlist[$3]);
+               } else {
+                       yyerror("invalid branch routing table number");
+                       YYABORT;
+               }
+       }
+       | ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
        ;
-send_route_stm: ROUTE_SEND LBRACE actions RBRACE {
-                                                                       push($3, &onsend_rlist[DEFAULT_RT]);
-                                                                       }
-                       |   ROUTE_SEND LBRACK NUMBER RBRACK LBRACE actions RBRACE {
-                                                                       if (($3<ONSEND_RT_NO)&&($3>=1)){
-                                                                               push($6, &onsend_rlist[$3]);
-                                                                       } else {
-                                                                               yyerror("invalid onsend routing"
-                                                                                               "table number");
-                                                                               YYABORT; }
-                                                               }
-                       | ROUTE_SEND error { yyerror("invalid onsend_route statement"); }
+send_route_stm: ROUTE_SEND LBRACE actions RBRACE {push($3, &onsend_rlist[DEFAULT_RT]); }
+       | ROUTE_SEND LBRACK NUMBER RBRACK LBRACE actions RBRACE {
+               if (($3<ONSEND_RT_NO)&&($3>=1)) {
+                       push($6, &onsend_rlist[$3]);
+               } else {
+                       yyerror("invalid onsend routing table number");
+                       YYABORT;
+               }
+       }
+       | ROUTE_SEND error { yyerror("invalid onsend_route statement"); }
        ;
 /*
-rules: rules rule { push($2, &$1); $$=$1; }
+rules:
+       rules rule { push($2, &$1); $$=$1; }
        | rule {$$=$1; }
        | rules error { $$=0; yyerror("invalid rule"); }
-        ;
-
-rule:  condition       actions CR {
-                                                               $$=0;
-                                                               if (add_rule($1, $2, &$$)<0) {
-                                                                       yyerror("error calling add_rule");
-                                                                       YYABORT;
-                                                               }
-                                                         }
-       | CR            { $$=0;}
+       ;
+rule:
+       condition actions CR {
+               $$=0;
+               if (add_rule($1, $2, &$$)<0) {
+                       yyerror("error calling add_rule");
+                       YYABORT;
+               }
+       }
+       | CR    { $$=0;}
        | condition error { $$=0; yyerror("bad actions in rule"); }
        ;
-
-condition:     exp {$$=$1;}
+condition:
+       exp {$$=$1;}
 */
-
-exp:   exp LOG_AND exp         { $$=mk_exp(LOGAND_OP, $1, $3); }
-       | exp LOG_OR  exp               { $$=mk_exp(LOGOR_OP, $1, $3);  }
-       | NOT exp                       { $$=mk_exp(NOT_OP, $2, 0);  }
+exp:   exp LOG_AND exp         { $$=mk_exp(LOGAND_OP, $1, $3); }
+       | exp LOG_OR exp        { $$=mk_exp(LOGOR_OP, $1, $3);  }
+       | NOT exp               { $$=mk_exp(NOT_OP, $2, 0);  }
        | LPAREN exp RPAREN     { $$=$2; }
-       | exp_elem                      { $$=$1; }
+       | exp_elem              { $$=$1; }
+       ;
+equalop:
+       EQUAL_T {$$=EQUAL_OP; }
+       | DIFF  {$$=DIFF_OP; }
        ;
-
-equalop:         EQUAL_T {$$=EQUAL_OP; }
-                       | DIFF  {$$=DIFF_OP; }
-               ;
-
 intop: equalop {$$=$1; }
-               |  GT   {$$=GT_OP; }
-               | LT    {$$=LT_OP; }
-               | GTE   {$$=GTE_OP; }
-               | LTE   {$$=LTE_OP; }
-               ;
-
-binop : BIN_OR { $$= BINOR_OP; }
-      | BIN_AND { $$ = BINAND_OP; }
-;
-
-strop: equalop {$$=$1; }
-               | MATCH {$$=MATCH_OP; }
-               ;
-
-uri_type:      URI                     {$$=URI_O;}
-               |       FROM_URI        {$$=FROM_URI_O;}
-               |       TO_URI          {$$=TO_URI_O;}
-               ;
-
-exp_elem:      METHOD strop STRING     {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
-                | METHOD strop attr_id_val  {$$ = mk_elem($2, METHOD_O, 0, AVP_ST, $3); }
-                | METHOD strop select_id {$$ = mk_elem($2, METHOD_O, 0, SELECT_ST, $3); }
-               | METHOD strop  ID      {$$ = mk_elem($2, METHOD_O, 0, STRING_ST,$3); }
-               | METHOD strop error { $$=0; yyerror("string expected"); }
-               | METHOD error  { $$=0; yyerror("invalid operator,"
-                                                                               "== , !=, or =~ expected");
-                                               }
-               | uri_type strop STRING {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
-                | uri_type strop host  {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
-                | uri_type strop attr_id_val {$$ = mk_elem($2, $1, 0, AVP_ST, $3); }
-                | uri_type strop select_id {$$ = mk_elem($2, $1, 0, SELECT_ST, $3); }
-                | uri_type equalop MYSELF {$$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
-               | uri_type strop error { $$=0; yyerror("string or MYSELF expected"); }
-               | uri_type error        { $$=0; yyerror("invalid operator,"
-                                                                       " == , != or =~ expected");
-                                       }
-               | SRCPORT intop NUMBER  { $$=mk_elem($2, SRCPORT_O, 0, NUMBER_ST, (void*)$3 ); }
-               | SRCPORT intop attr_id_val { $$=mk_elem($2, SRCPORT_O, 0, AVP_ST, (void*)$3 ); }
-               | SRCPORT intop error { $$=0; yyerror("number expected"); }
-               | SRCPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
+       | GT    {$$=GT_OP; }
+       | LT    {$$=LT_OP; }
+       | GTE   {$$=GTE_OP; }
+       | LTE   {$$=LTE_OP; }
+       ;
+binop :
+       BIN_OR { $$= BINOR_OP; }
+       | BIN_AND { $$ = BINAND_OP; }
+       ;
+strop:
+       equalop {$$=$1; }
+       | MATCH {$$=MATCH_OP; }
+       ;
+uri_type:
+       URI             {$$=URI_O;}
+       | FROM_URI      {$$=FROM_URI_O;}
+       | TO_URI        {$$=TO_URI_O;}
+       ;
 
-               | DSTPORT intop NUMBER  { $$=mk_elem($2, DSTPORT_O, 0, NUMBER_ST, (void*)$3 ); }
-               | DSTPORT intop attr_id_val     { $$=mk_elem($2, DSTPORT_O, 0, AVP_ST, (void*)$3 ); }
-               | DSTPORT intop error { $$=0; yyerror("number expected"); }
-               | DSTPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
+exp_elem:
+       METHOD strop STRING     {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
+       | METHOD strop attr_id_val  {$$ = mk_elem($2, METHOD_O, 0, AVP_ST, $3); }
+       | METHOD strop select_id {$$ = mk_elem($2, METHOD_O, 0, SELECT_ST, $3); }
+       | METHOD strop  ID      {$$ = mk_elem($2, METHOD_O, 0, STRING_ST,$3); }
+       | METHOD strop error { $$=0; yyerror("string expected"); }
+       | METHOD error  { $$=0; yyerror("invalid operator,== , !=, or =~ expected"); }
+       | uri_type strop STRING {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
+       | uri_type strop host   {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
+       | uri_type strop attr_id_val {$$ = mk_elem($2, $1, 0, AVP_ST, $3); }
+       | uri_type strop select_id {$$ = mk_elem($2, $1, 0, SELECT_ST, $3); }
+       | uri_type equalop MYSELF {$$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
+       | uri_type strop error { $$=0; yyerror("string or MYSELF expected"); }
+       | uri_type error        { $$=0; yyerror("invalid operator, == , != or =~ expected"); }
+
+       | SRCPORT intop NUMBER { $$=mk_elem($2, SRCPORT_O, 0, NUMBER_ST, (void*)$3 ); }
+       | SRCPORT intop attr_id_val { $$=mk_elem($2, SRCPORT_O, 0, AVP_ST, (void*)$3 ); }
+       | SRCPORT intop error { $$=0; yyerror("number expected"); }
+       | SRCPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
+
+       | DSTPORT intop NUMBER  { $$=mk_elem($2, DSTPORT_O, 0, NUMBER_ST, (void*)$3 ); }
+       | DSTPORT intop attr_id_val     { $$=mk_elem($2, DSTPORT_O, 0, AVP_ST, (void*)$3 ); }
+       | DSTPORT intop error { $$=0; yyerror("number expected"); }
+       | DSTPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
+
+       | SNDPORT intop NUMBER {
+               onsend_check("snd_port");
+               $$=mk_elem($2, SNDPORT_O, 0, NUMBER_ST, (void*)$3 );
+       }
+       | SNDPORT intop attr_id_val {
+               onsend_check("snd_port");
+               $$=mk_elem($2, SNDPORT_O, 0, AVP_ST, (void*)$3 );
+       }
+       | SNDPORT intop error { $$=0; yyerror("number expected"); }
+       | SNDPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
 
-               | SNDPORT intop NUMBER  {       onsend_check("snd_port");
-                                                                       $$=mk_elem($2, SNDPORT_O, 0, NUMBER_ST,
-                                                                                               (void*)$3 ); }
-               | SNDPORT intop attr_id_val {   onsend_check("snd_port");
-                                                                       $$=mk_elem($2, SNDPORT_O, 0, AVP_ST,
-                                                                                               (void*)$3 ); }
-               | SNDPORT intop error { $$=0; yyerror("number expected"); }
-               | SNDPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
+       | TOPORT intop NUMBER {
+               onsend_check("to_port");
+               $$=mk_elem($2, TOPORT_O, 0, NUMBER_ST, (void*)$3 );
+       }
+       | TOPORT intop attr_id_val {
+               onsend_check("to_port");
+               $$=mk_elem($2, TOPORT_O, 0, AVP_ST, (void*)$3 );
+       }
+       | TOPORT intop error { $$=0; yyerror("number expected"); }
+       | TOPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
 
-               | TOPORT intop NUMBER   {       onsend_check("to_port");
-                                                                       $$=mk_elem($2, TOPORT_O, 0, NUMBER_ST,
-                                                                                               (void*)$3 ); }
-               | TOPORT intop attr_id_val {    onsend_check("to_port");
-                                                                       $$=mk_elem($2, TOPORT_O, 0, AVP_ST,
-                                                                                               (void*)$3 ); }
-               | TOPORT intop error { $$=0; yyerror("number expected"); }
-               | TOPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
+       | PROTO intop proto     { $$=mk_elem($2, PROTO_O, 0, NUMBER_ST, (void*)$3 ); }
+       | PROTO intop attr_id_val       { $$=mk_elem($2, PROTO_O, 0, AVP_ST, (void*)$3 ); }
+       | PROTO intop error { $$=0; yyerror("protocol expected (udp, tcp or tls)"); }
 
-               | PROTO intop proto     { $$=mk_elem($2, PROTO_O, 0, NUMBER_ST, (void*)$3 ); }
-               | PROTO intop attr_id_val       { $$=mk_elem($2, PROTO_O, 0, AVP_ST, (void*)$3 ); }
-               | PROTO intop error { $$=0;
-                                                               yyerror("protocol expected (udp, tcp or tls)");
-                                                       }
-               | PROTO error { $$=0; yyerror("equal/!= operator expected"); }
+       | PROTO error { $$=0; yyerror("equal/!= operator expected"); }
 
-               | SNDPROTO intop proto  {       onsend_check("snd_proto");
-                                                                       $$=mk_elem($2, SNDPROTO_O, 0, NUMBER_ST,
-                                                                               (void*)$3 ); }
-               | SNDPROTO intop attr_id_val {  onsend_check("snd_proto");
-                                                                       $$=mk_elem($2, SNDPROTO_O, 0, AVP_ST,
-                                                                               (void*)$3 ); }
-               | SNDPROTO intop error { $$=0;
-                                                               yyerror("protocol expected (udp, tcp or tls)");
+       | SNDPROTO intop proto  {
+               onsend_check("snd_proto");
+               $$=mk_elem($2, SNDPROTO_O, 0, NUMBER_ST, (void*)$3 );
+       }
+       | SNDPROTO intop attr_id_val {
+               onsend_check("snd_proto");
+               $$=mk_elem($2, SNDPROTO_O, 0, AVP_ST, (void*)$3 );
+       }
+       | SNDPROTO intop error { $$=0; yyerror("protocol expected (udp, tcp or tls)"); }
+       | SNDPROTO error { $$=0; yyerror("equal/!= operator expected"); }
+
+       | AF intop NUMBER       { $$=mk_elem($2, AF_O, 0, NUMBER_ST,(void *) $3 ); }
+       | AF intop attr_id_val  { $$=mk_elem($2, AF_O, 0, AVP_ST,(void *) $3 ); }
+       | AF intop error { $$=0; yyerror("number expected"); }
+       | AF error { $$=0; yyerror("equal/!= operator expected"); }
+
+       | SNDAF intop NUMBER {
+               onsend_check("snd_af");
+               $$=mk_elem($2, SNDAF_O, 0, NUMBER_ST, (void *) $3 ); }
+       | SNDAF intop attr_id_val {
+               onsend_check("snd_af");
+               $$=mk_elem($2, SNDAF_O, 0, AVP_ST, (void *) $3 );
+       }
+       | SNDAF intop error { $$=0; yyerror("number expected"); }
+       | SNDAF error { $$=0; yyerror("equal/!= operator expected"); }
+
+       | MSGLEN intop NUMBER           { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) $3 ); }
+       | MSGLEN intop attr_id_val      { $$=mk_elem($2, MSGLEN_O, 0, AVP_ST, (void *) $3 ); }
+       | MSGLEN intop MAX_LEN          { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) BUF_SIZE); }
+       | MSGLEN intop error { $$=0; yyerror("number expected"); }
+       | MSGLEN error { $$=0; yyerror("equal/!= operator expected"); }
+
+       | RETCODE intop NUMBER  { $$=mk_elem($2, RETCODE_O, 0, NUMBER_ST, (void *) $3 ); }
+       | RETCODE intop attr_id_val     { $$=mk_elem($2, RETCODE_O, 0, AVP_ST, (void *) $3 ); }
+       | RETCODE intop error { $$=0; yyerror("number expected"); }
+       | RETCODE error { $$=0; yyerror("equal/!= operator expected"); }
+
+       | SRCIP equalop ipnet   { $$=mk_elem($2, SRCIP_O, 0, NET_ST, $3); }
+       | SRCIP strop STRING {
+               s_tmp.s=$3;
+               s_tmp.len=strlen($3);
+               ip_tmp=str2ip(&s_tmp);
+               if (ip_tmp==0)
+                       ip_tmp=str2ip6(&s_tmp);
+               if (ip_tmp) {
+                       $$=mk_elem($2, SRCIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
+               } else {
+                       $$=mk_elem($2, SRCIP_O, 0, STRING_ST, $3);
+               }
+       }
+       | SRCIP strop host      { $$=mk_elem($2, SRCIP_O, 0, STRING_ST, $3); }
+       | SRCIP equalop MYSELF  { $$=mk_elem($2, SRCIP_O, 0, MYSELF_ST, 0);
                                                        }
-               | SNDPROTO error { $$=0; yyerror("equal/!= operator expected"); }
-
-               | AF intop NUMBER       { $$=mk_elem($2, AF_O, 0, NUMBER_ST,(void *) $3 ); }
-               | AF intop attr_id_val  { $$=mk_elem($2, AF_O, 0, AVP_ST,(void *) $3 ); }
-               | AF intop error { $$=0; yyerror("number expected"); }
-               | AF error { $$=0; yyerror("equal/!= operator expected"); }
-
-               | SNDAF intop NUMBER    {       onsend_check("snd_af");
-                                                                       $$=mk_elem($2, SNDAF_O, 0, NUMBER_ST,
-                                                                               (void *) $3 ); }
-               | SNDAF intop attr_id_val       {       onsend_check("snd_af");
-                                                                       $$=mk_elem($2, SNDAF_O, 0, AVP_ST,
-                                                                               (void *) $3 ); }
-               | SNDAF intop error { $$=0; yyerror("number expected"); }
-               | SNDAF error { $$=0; yyerror("equal/!= operator expected"); }
-
-               | MSGLEN intop NUMBER   { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) $3 ); }
-               | MSGLEN intop attr_id_val      { $$=mk_elem($2, MSGLEN_O, 0, AVP_ST, (void *) $3 ); }
-               | MSGLEN intop MAX_LEN  { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) BUF_SIZE); }
-               | MSGLEN intop error { $$=0; yyerror("number expected"); }
-               | MSGLEN error { $$=0; yyerror("equal/!= operator expected"); }
-
-               | RETCODE intop NUMBER  { $$=mk_elem($2, RETCODE_O, 0,
-                                                                                               NUMBER_ST, (void *) $3 ); }
-               | RETCODE intop attr_id_val     { $$=mk_elem($2, RETCODE_O, 0,
-                                                                                               AVP_ST, (void *) $3 ); }
-               | RETCODE intop error { $$=0; yyerror("number expected"); }
-               | RETCODE error { $$=0; yyerror("equal/!= operator expected"); }
-
-               | SRCIP equalop ipnet   { $$=mk_elem($2, SRCIP_O, 0, NET_ST, $3); }
-               | SRCIP strop STRING    {       s_tmp.s=$3;
-                                                                       s_tmp.len=strlen($3);
-                                                                       ip_tmp=str2ip(&s_tmp);
-                                                                       if (ip_tmp==0)
-                                                                               ip_tmp=str2ip6(&s_tmp);
-                                                                       if (ip_tmp){
-                                                                               $$=mk_elem(     $2, SRCIP_O, 0, NET_ST,
-                                                                                               mk_net_bitlen(ip_tmp,
-                                                                                                               ip_tmp->len*8) );
-                                                                       }else{
-                                                                               $$=mk_elem(     $2, SRCIP_O, 0, STRING_ST,
-                                                                                               $3);
-                                                                       }
-                                                               }
-               | SRCIP strop host      { $$=mk_elem(   $2, SRCIP_O, 0, STRING_ST, $3); }
-               | SRCIP equalop MYSELF  { $$=mk_elem(   $2, SRCIP_O, 0, MYSELF_ST,
-                                                                                               0);
-                                                               }
-               | SRCIP strop error { $$=0; yyerror( "ip address or hostname"
-                                                "expected" ); }
-               | SRCIP error  { $$=0;
-                                                yyerror("invalid operator, ==, != or =~ expected");}
-               | DSTIP equalop ipnet   { $$=mk_elem(   $2, DSTIP_O, 0, NET_ST,
-                                                                                               (void*)$3);
-                                                               }
-               | DSTIP strop STRING    {       s_tmp.s=$3;
-                                                                       s_tmp.len=strlen($3);
-                                                                       ip_tmp=str2ip(&s_tmp);
-                                                                       if (ip_tmp==0)
-                                                                               ip_tmp=str2ip6(&s_tmp);
-                                                                       if (ip_tmp){
-                                                                               $$=mk_elem(     $2, DSTIP_O, 0, NET_ST,
-                                                                                               mk_net_bitlen(ip_tmp,
-                                                                                                               ip_tmp->len*8) );
-                                                                       }else{
-                                                                               $$=mk_elem(     $2, DSTIP_O, 0, STRING_ST,
-                                                                                               $3);
-                                                                       }
-                                                               }
-               | DSTIP strop host      { $$=mk_elem(   $2, DSTIP_O, 0, STRING_ST,
-                                                                                               $3);
-                                                               }
-               | DSTIP equalop MYSELF  { $$=mk_elem(   $2, DSTIP_O, 0, MYSELF_ST,
-                                                                                               0);
-                                                               }
-               | DSTIP strop error { $$=0; yyerror( "ip address or hostname"
-                                                                       "expected" ); }
-               | DSTIP error { $$=0;
-                                               yyerror("invalid operator, ==, != or =~ expected");}
-               | SNDIP equalop ipnet   { onsend_check("snd_ip");
-                                                                       $$=mk_elem($2, SNDIP_O, 0, NET_ST, $3); }
-               | SNDIP strop STRING    {       onsend_check("snd_ip");
-                                                                       s_tmp.s=$3;
-                                                                       s_tmp.len=strlen($3);
-                                                                       ip_tmp=str2ip(&s_tmp);
-                                                                       if (ip_tmp==0)
-                                                                               ip_tmp=str2ip6(&s_tmp);
-                                                                       if (ip_tmp){
-                                                                               $$=mk_elem(     $2, SNDIP_O, 0, NET_ST,
-                                                                                               mk_net_bitlen(ip_tmp,
-                                                                                                               ip_tmp->len*8) );
-                                                                       }else{
-                                                                               $$=mk_elem(     $2, SNDIP_O, 0, STRING_ST,
-                                                                                               $3);
-                                                                       }
-                                                               }
-               | SNDIP strop host      {       onsend_check("snd_ip");
-                                                               $$=mk_elem(     $2, SNDIP_O, 0, STRING_ST, $3); }
-               | SNDIP equalop MYSELF  {       onsend_check("snd_ip");
-                                                                       $$=mk_elem(     $2, SNDIP_O, 0, MYSELF_ST, 0);
-                                                               }
-               | SNDIP strop error { $$=0; yyerror( "ip address or hostname"
-                                                "expected" ); }
-               | SNDIP error  { $$=0;
-                                                yyerror("invalid operator, ==, != or =~ expected");}
-               | TOIP equalop ipnet    { onsend_check("to_ip");
-                                                                       $$=mk_elem($2, TOIP_O, 0, NET_ST, $3); }
-               | TOIP strop STRING     {       onsend_check("to_ip");
-                                                                       s_tmp.s=$3;
-                                                                       s_tmp.len=strlen($3);
-                                                                       ip_tmp=str2ip(&s_tmp);
-                                                                       if (ip_tmp==0)
-                                                                               ip_tmp=str2ip6(&s_tmp);
-                                                                       if (ip_tmp){
-                                                                               $$=mk_elem(     $2, TOIP_O, 0, NET_ST,
-                                                                                               mk_net_bitlen(ip_tmp,
-                                                                                                               ip_tmp->len*8) );
-                                                                       }else{
-                                                                               $$=mk_elem(     $2, TOIP_O, 0, STRING_ST,
-                                                                                               $3);
-                                                                       }
-                                                               }
-               | TOIP strop host       {       onsend_check("to_ip");
-                                                               $$=mk_elem(     $2, TOIP_O, 0, STRING_ST, $3); }
-               | TOIP equalop MYSELF  {        onsend_check("to_ip");
-                                                                       $$=mk_elem(     $2, TOIP_O, 0, MYSELF_ST, 0);
-                                                               }
-               | TOIP strop error { $$=0; yyerror( "ip address or hostname"
-                                                "expected" ); }
-               | TOIP error  { $$=0;
-                                                yyerror("invalid operator, ==, != or =~ expected");}
-
-               | MYSELF equalop uri_type       { $$=mk_elem(   $2, $3, 0, MYSELF_ST,
-                                                                                                      0);
-                                                               }
-               | MYSELF equalop SRCIP  { $$=mk_elem(   $2, SRCIP_O, 0, MYSELF_ST,
-                                                                                               0);
-                                                               }
-               | MYSELF equalop DSTIP  { $$=mk_elem(   $2, DSTIP_O, 0, MYSELF_ST,
-                                                                                               0);
-                                                               }
-               | MYSELF equalop SNDIP  {       onsend_check("snd_ip");
-                                                                       $$=mk_elem(     $2, SNDIP_O, 0, MYSELF_ST, 0);
-                                                               }
-               | MYSELF equalop TOIP  {        onsend_check("to_ip");
-                                                                       $$=mk_elem(     $2, TOIP_O, 0, MYSELF_ST, 0);
-                                                               }
-               | MYSELF equalop error {        $$=0;
-                                                                       yyerror(" URI, SRCIP or DSTIP expected"); }
-               | MYSELF error  { $$=0;
-                                                       yyerror ("invalid operator, == or != expected");
-                                               }
-               | exp_stm                       { $$=mk_elem( NO_OP, ACTION_O, 0, ACTIONS_ST, $1);  }
-               | NUMBER                {$$=mk_elem( NO_OP, NUMBER_O, 0, NUMBER_ST, (void*)$1 ); }
-
-               | attr_id_val           {$$=mk_elem( NO_OP, AVP_O, (void*)$1, 0, 0); }
-               | attr_id_val strop STRING      {$$=mk_elem( $2, AVP_O, (void*)$1, STRING_ST, $3); }
-               | attr_id_val strop select_id {$$=mk_elem( $2, AVP_O, (void*)$1, SELECT_ST, $3); }
-               | attr_id_val intop NUMBER      {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
-               | attr_id_val binop NUMBER      {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
-                | attr_id_val strop attr_id_val {$$=mk_elem( $2, AVP_O, (void*)$1, AVP_ST, (void*)$3); }
-
-                | select_id                 { $$=mk_elem( NO_OP, SELECT_O, $1, 0, 0); }
-               | select_id strop STRING    { $$=mk_elem( $2, SELECT_O, $1, STRING_ST, $3); }
-               | select_id strop attr_id_val   { $$=mk_elem( $2, SELECT_O, $1, AVP_ST, (void*)$3); }
-               | select_id strop select_id { $$=mk_elem( $2, SELECT_O, $1, SELECT_ST, $3); }
+       | SRCIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
+       | SRCIP error  { $$=0; yyerror("invalid operator, ==, != or =~ expected");}
+       | DSTIP equalop ipnet   { $$=mk_elem(   $2, DSTIP_O, 0, NET_ST, (void*)$3); }
+       | DSTIP strop STRING    {
+               s_tmp.s=$3;
+               s_tmp.len=strlen($3);
+               ip_tmp=str2ip(&s_tmp);
+               if (ip_tmp==0)
+                       ip_tmp=str2ip6(&s_tmp);
+               if (ip_tmp) {
+                       $$=mk_elem($2, DSTIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
+               } else {
+                       $$=mk_elem($2, DSTIP_O, 0, STRING_ST, $3);
+               }
+       }
+       | DSTIP strop host      { $$=mk_elem(   $2, DSTIP_O, 0, STRING_ST, $3); }
+       | DSTIP equalop MYSELF  { $$=mk_elem(   $2, DSTIP_O, 0, MYSELF_ST, 0); }
+       | DSTIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
+       | DSTIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
+       | SNDIP equalop ipnet {
+               onsend_check("snd_ip");
+               $$=mk_elem($2, SNDIP_O, 0, NET_ST, $3);
+       }
+       | SNDIP strop STRING    {
+               onsend_check("snd_ip");
+               s_tmp.s=$3;
+               s_tmp.len=strlen($3);
+               ip_tmp=str2ip(&s_tmp);
+               if (ip_tmp==0)
+                       ip_tmp=str2ip6(&s_tmp);
+               if (ip_tmp) {
+                       $$=mk_elem($2, SNDIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
+               } else {
+                       $$=mk_elem($2, SNDIP_O, 0, STRING_ST, $3);
+               }
+       }
+       | SNDIP strop host      {
+               onsend_check("snd_ip");
+               $$=mk_elem($2, SNDIP_O, 0, STRING_ST, $3);
+       }
+       | SNDIP equalop MYSELF  {
+               onsend_check("snd_ip");
+               $$=mk_elem($2, SNDIP_O, 0, MYSELF_ST, 0);
+       }
+       | SNDIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
+       | SNDIP error  { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
+       | TOIP equalop ipnet    {
+               onsend_check("to_ip");
+               $$=mk_elem($2, TOIP_O, 0, NET_ST, $3);
+       }
+       | TOIP strop STRING     {
+               onsend_check("to_ip");
+               s_tmp.s=$3;
+               s_tmp.len=strlen($3);
+               ip_tmp=str2ip(&s_tmp);
+               if (ip_tmp==0)
+                       ip_tmp=str2ip6(&s_tmp);
+               if (ip_tmp) {
+                       $$=mk_elem($2, TOIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
+               } else {
+                       $$=mk_elem($2, TOIP_O, 0, STRING_ST, $3);
+               }
+       }
+       | TOIP strop host       {
+               onsend_check("to_ip");
+               $$=mk_elem($2, TOIP_O, 0, STRING_ST, $3);
+       }
+       | TOIP equalop MYSELF  {
+               onsend_check("to_ip");
+               $$=mk_elem($2, TOIP_O, 0, MYSELF_ST, 0);
+       }
+       | TOIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
+       | TOIP error  { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
+
+       | MYSELF equalop uri_type       { $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
+       | MYSELF equalop SRCIP  { $$=mk_elem($2, SRCIP_O, 0, MYSELF_ST, 0); }
+       | MYSELF equalop DSTIP  { $$=mk_elem($2, DSTIP_O, 0, MYSELF_ST, 0); }
+       | MYSELF equalop SNDIP  {
+               onsend_check("snd_ip");
+               $$=mk_elem($2, SNDIP_O, 0, MYSELF_ST, 0);
+       }
+       | MYSELF equalop TOIP  {
+               onsend_check("to_ip");
+               $$=mk_elem($2, TOIP_O, 0, MYSELF_ST, 0);
+       }
+       | MYSELF equalop error { $$=0; yyerror(" URI, SRCIP or DSTIP expected"); }
+       | MYSELF error  { $$=0; yyerror ("invalid operator, == or != expected"); }
+       | exp_stm       { $$=mk_elem( NO_OP, ACTION_O, 0, ACTIONS_ST, $1);  }
+       | NUMBER        { $$=mk_elem( NO_OP, NUMBER_O, 0, NUMBER_ST, (void*)$1 ); }
+
+       | attr_id_val                   {$$=mk_elem( NO_OP, AVP_O, (void*)$1, 0, 0); }
+       | attr_id_val strop STRING      {$$=mk_elem( $2, AVP_O, (void*)$1, STRING_ST, $3); }
+       | attr_id_val strop select_id   {$$=mk_elem( $2, AVP_O, (void*)$1, SELECT_ST, $3); }
+       | attr_id_val intop NUMBER      {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
+       | attr_id_val binop NUMBER      {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
+       | attr_id_val strop attr_id_val {$$=mk_elem( $2, AVP_O, (void*)$1, AVP_ST, (void*)$3); }
+
+       | select_id                 { $$=mk_elem( NO_OP, SELECT_O, $1, 0, 0); }
+       | select_id strop STRING    { $$=mk_elem( $2, SELECT_O, $1, STRING_ST, $3); }
+       | select_id strop attr_id_val   { $$=mk_elem( $2, SELECT_O, $1, AVP_ST, (void*)$3); }
+       | select_id strop select_id { $$=mk_elem( $2, SELECT_O, $1, SELECT_ST, $3); }
 ;
-
-
-ipnet: ip SLASH ip     { $$=mk_net($1, $3); }
-       | ip SLASH NUMBER       {       if (($3<0) || ($3>$1->len*8)){
-                                                               yyerror("invalid bit number in netmask");
-                                                               $$=0;
-                                                       }else{
-                                                               $$=mk_net_bitlen($1, $3);
-                                                       /*
-                                                               $$=mk_net($1,
-                                                                               htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
-                                                       */
-                                                       }
-                                               }
-       | ip                            { $$=mk_net_bitlen($1, $1->len*8); }
-       | ip SLASH error        { $$=0;
-                                                yyerror("netmask (eg:255.0.0.0 or 8) expected");
-                                               }
+ipnet:
+       ip SLASH ip     { $$=mk_net($1, $3); }
+       | ip SLASH NUMBER {
+               if (($3<0) || ($3>$1->len*8)) {
+                       yyerror("invalid bit number in netmask");
+                       $$=0;
+               } else {
+                       $$=mk_net_bitlen($1, $3);
+               /*
+                       $$=mk_net($1, htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
+               */
+               }
+       }
+       | ip    { $$=mk_net_bitlen($1, $1->len*8); }
+       | ip SLASH error { $$=0; yyerror("netmask (eg:255.0.0.0 or 8) expected"); }
+       ;
+host_sep:
+       DOT {$$=".";}
+       | MINUS {$$="-"; }
        ;
 
-
-
-host_sep:      DOT {$$=".";}
-               |       MINUS {$$="-"; }
-               ;
-
-host:  ID                              { $$=$1; }
-       | host host_sep ID      { $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
-                                                 if ($$==0){
-                                                       LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
-                                                                               " failure while parsing host\n");
-                                                 }else{
-                                                       memcpy($$, $1, strlen($1));
-                                                       $$[strlen($1)]=*$2;
-                                                       memcpy($$+strlen($1)+1, $3, strlen($3));
-                                                       $$[strlen($1)+1+strlen($3)]=0;
-                                                 }
-                                                 pkg_free($1); pkg_free($3);
-                                               }
+host:
+       ID { $$=$1; }
+       | host host_sep ID {
+               $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
+               if ($$==0) {
+                       LOG(L_CRIT, "ERROR: cfg. parser: memory allocation failure while parsing host\n");
+               } else {
+                       memcpy($$, $1, strlen($1));
+                       $$[strlen($1)]=*$2;
+                       memcpy($$+strlen($1)+1, $3, strlen($3));
+                       $$[strlen($1)+1+strlen($3)]=0;
+               }
+               pkg_free($1);
+               pkg_free($3);
+       }
        | host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
        ;
-
 /* filtered cmd */
-fcmd:  cmd     { /* check if allowed */
-                               if (rt==ONSEND_ROUTE){
-                                       switch($1->type){
-                                               case DROP_T:
-                                               case SEND_T:
-                                               case SEND_TCP_T:
-                                               case LOG_T:
-                                               case SETFLAG_T:
-                                               case RESETFLAG_T:
-                                               case ISFLAGSET_T:
-                                               case IF_T:
-                                               case MODULE_T:
-                                                       $$=$1;
-                                                       break;
-                                               default:
-                                                       $$=0;
-                                                       yyerror("command not allowed in onsend_route\n");
-                                       }
-                               }else{
+fcmd:
+       cmd {
+               /* check if allowed */
+               if (rt==ONSEND_ROUTE) {
+                       switch($1->type) {
+                               case DROP_T:
+                               case SEND_T:
+                               case SEND_TCP_T:
+                               case LOG_T:
+                               case SETFLAG_T:
+                               case RESETFLAG_T:
+                               case ISFLAGSET_T:
+                               case IF_T:
+                               case MODULE_T:
                                        $$=$1;
-                               }
+                                       break;
+                               default:
+                                       $$=0;
+                                       yyerror("command not allowed in onsend_route\n");
                        }
+               } else {
+                       $$=$1;
+               }
+       }
        ;
-
-
-exp_stm:       fcmd                                            { $$=$1; }
-               |       if_cmd                                  { $$=$1; }
-                |       assign_action { $$ = $1; }
-               |       LBRACE actions RBRACE   { $$=$2; }
+exp_stm:
+       fcmd    { $$=$1; }
+       | if_cmd        { $$=$1; }
+       | assign_action { $$ = $1; }
+       | LBRACE actions RBRACE { $$=$2; }
        ;
-
-stm:           action                                  { $$=$1; }
-               |       LBRACE actions  RBRACE  { $$=$2; }
+stm:
+       action  { $$=$1; }
+       | LBRACE actions RBRACE { $$=$2; }
        ;
-
-actions:       actions action  {$$=append_action($1, $2); }
-               | action                        {$$=$1;}
-               | actions error { $$=0; yyerror("bad command"); }
+actions:
+       actions action  {$$=append_action($1, $2); }
+       | action        {$$=$1;}
+       | actions error { $$=0; yyerror("bad command"); }
        ;
-
-action:                fcmd SEMICOLON {$$=$1;}
-               | if_cmd {$$=$1;}
-               | assign_action SEMICOLON {$$=$1;}
-               | SEMICOLON /* null action */ {$$=0;}
-               | fcmd error { $$=0; yyerror("bad command: missing ';'?"); }
+action:
+       fcmd SEMICOLON {$$=$1;}
+       | if_cmd {$$=$1;}
+       | assign_action SEMICOLON {$$=$1;}
+       | SEMICOLON /* null action */ {$$=0;}
+       | fcmd error { $$=0; yyerror("bad command: missing ';'?"); }
        ;
-
-if_cmd:                IF exp stm                              { $$=mk_action3( IF_T,
-                                                                                                        EXPR_ST,
-                                                                                                        ACTIONS_ST,
-                                                                                                        NOSUBTYPE,
-                                                                                                        $2,
-                                                                                                        $3,
-                                                                                                        0);
-                                                                       }
-               |       IF exp stm ELSE stm             { $$=mk_action3( IF_T,
-                                                                                                        EXPR_ST,
-                                                                                                        ACTIONS_ST,
-                                                                                                        ACTIONS_ST,
-                                                                                                        $2,
-                                                                                                        $3,
-                                                                                                        $5);
-                                                                       }
+if_cmd:
+       IF exp stm              { $$=mk_action( IF_T, 3, EXPR_ST, $2, ACTIONS_ST, $3, NOSUBTYPE, 0); }
+       | IF exp stm ELSE stm   { $$=mk_action( IF_T, 3, EXPR_ST, $2, ACTIONS_ST, $3, ACTIONS_ST, $5); }
        ;
-
-//class_id : LBRACK ATTR_USER RBRACK { $$ = AVP_CLASS_USER; }
-//         | LBRACK ATTR_DOMAIN RBRACK { $$ = AVP_CLASS_DOMAIN; }
-//         | LBRACK ATTR_GLOBAL RBRACK { $$ = AVP_CLASS_GLOBAL; }
-//;
-
-select_param : ID {
-                   if (sel.n >= MAX_SELECT_PARAMS-1) {
-                           yyerror("Select identifier too long\n");
-                   }
-                   sel.params[sel.n].type = SEL_PARAM_STR;
-                   sel.params[sel.n].v.s.s = $1;
-                   sel.params[sel.n].v.s.len = strlen($1);
-                   sel.n++;
-                  }
-             | ID LBRACK NUMBER RBRACK {
-                    if (sel.n >= MAX_SELECT_PARAMS-2) {
-                           yyerror("Select identifier too long\n");
-                    }
-                    sel.params[sel.n].type = SEL_PARAM_STR;
-                    sel.params[sel.n].v.s.s = $1;
-                    sel.params[sel.n].v.s.len = strlen($1);
-                    sel.n++;
-                    sel.params[sel.n].type = SEL_PARAM_INT;
-                    sel.params[sel.n].v.i = $3;
-                    sel.n++;
-            }
-;
-
-select_params : select_params DOT select_param
-              | select_param
-;
-
-select_id : SELECT_MARK { sel.n = 0; sel.f = 0; } select_params {
-       sel_ptr = (select_t*)pkg_malloc(sizeof(select_t));
-       if (!sel_ptr) {
-               yyerror("No memory left to allocate select structure\n");
+/* class_id:
+       LBRACK ATTR_USER RBRACK { $$ = AVP_CLASS_USER; }
+       | LBRACK ATTR_DOMAIN RBRACK { $$ = AVP_CLASS_DOMAIN; }
+       | LBRACK ATTR_GLOBAL RBRACK { $$ = AVP_CLASS_GLOBAL; }
+       ;
+*/
+select_param:
+       ID {
+               if (sel.n >= MAX_SELECT_PARAMS-1) {
+                       yyerror("Select identifier too long\n");
+               }
+               sel.params[sel.n].type = SEL_PARAM_STR;
+               sel.params[sel.n].v.s.s = $1;
+               sel.params[sel.n].v.s.len = strlen($1);
+               sel.n++;
        }
-       memcpy(sel_ptr, &sel, sizeof(select_t));
-       $$ = sel_ptr;
-}
-;
-
-attr_class_spec: ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
-               |ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; }
-               |ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; }
-               |ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; }
-               |ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; }
-
-attr_name_spec : ID { s_attr->type |= AVP_NAME_STR; s_attr->name.s.s = $1; s_attr->name.s.len = strlen ($1); }
-;
-
-attr_spec : attr_name_spec |
-           attr_class_spec DOT attr_name_spec
-;
-
-attr_mark : ATTR_MARK
-       {       s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec));
-                if (!s_attr) { yyerror("No memory left"); }
-                s_attr->type = 0;
+       | ID LBRACK NUMBER RBRACK {
+               if (sel.n >= MAX_SELECT_PARAMS-2) {
+                       yyerror("Select identifier too long\n");
+               }
+               sel.params[sel.n].type = SEL_PARAM_STR;
+               sel.params[sel.n].v.s.s = $1;
+               sel.params[sel.n].v.s.len = strlen($1);
+               sel.n++;
+               sel.params[sel.n].type = SEL_PARAM_INT;
+               sel.params[sel.n].v.i = $3;
+               sel.n++;
        }
-;
-
-attr_id : attr_mark attr_spec { $$ = s_attr; }
-;
-
-attr_id_num_idx : attr_mark attr_spec LBRACK NUMBER RBRACK
-               {       s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD));
-                       s_attr->index = ($4<0?-$4:$4);
-                       $$ = s_attr;
-               }
-;
-
-attr_id_no_idx : attr_mark attr_spec LBRACK RBRACK
-               {       s_attr->type|= AVP_INDEX_ALL;
-                       $$ = s_attr;
+       ;
+select_params:
+       select_params DOT select_param
+       | select_param
+       ;
+select_id:
+       SELECT_MARK { sel.n = 0; sel.f = 0; } select_params {
+               sel_ptr = (select_t*)pkg_malloc(sizeof(select_t));
+               if (!sel_ptr) {
+                       yyerror("No memory left to allocate select structure\n");
                }
+               memcpy(sel_ptr, &sel, sizeof(select_t));
+               $$ = sel_ptr;
+       }
+       ;
+attr_class_spec:
+       ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
+       | ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; }
+       | ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; }
+       | ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; }
+       | ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; }
+       ;
+attr_name_spec:
+       ID { s_attr->type |= AVP_NAME_STR; s_attr->name.s.s = $1; s_attr->name.s.len = strlen ($1); }
+       ;
+attr_spec:
+       attr_name_spec
+       | attr_class_spec DOT attr_name_spec
+       ;
+attr_mark:
+       ATTR_MARK {
+               s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec));
+               if (!s_attr) { yyerror("No memory left"); }
+               s_attr->type = 0;
+       }
+       ;
+attr_id:
+       attr_mark attr_spec { $$ = s_attr; }
+       ;
+attr_id_num_idx:
+       attr_mark attr_spec LBRACK NUMBER RBRACK {
+               s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD));
+               s_attr->index = ($4<0?-$4:$4);
+               $$ = s_attr;
+       }
+       ;
+attr_id_no_idx:
+       attr_mark attr_spec LBRACK RBRACK {
+               s_attr->type|= AVP_INDEX_ALL;
+               $$ = s_attr;
+       }
+       ;
+attr_id_ass:
+       attr_id
+       | attr_id_no_idx
+       ;
+attr_id_val:
+       attr_id
+       | attr_id_num_idx
+       ;
+attr_id_any:
+       attr_id
+       | attr_id_no_idx
+       | attr_id_num_idx
 ;
-
-attr_id_ass : attr_id | attr_id_no_idx
-;
-
-attr_id_val : attr_id | attr_id_num_idx
-;
-
-attr_id_any : attr_id | attr_id_no_idx | attr_id_num_idx
-;
-
-//assign_op : ADDEQ { $$ = ADD_T; }
-//          | EQUAL { $$ = ASSIGN_T; }
-assign_op : EQUAL { $$ = ASSIGN_T; }
-;
-
-assign_action:   attr_id_ass assign_op STRING  { $$=mk_action($2, AVP_ST, STRING_ST, $1, $3); }
-               | attr_id_ass assign_op NUMBER  { $$=mk_action($2, AVP_ST, NUMBER_ST, $1, (void*)$3); }
-               | attr_id_ass assign_op fcmd    { $$=mk_action($2, AVP_ST, ACTION_ST, $1, $3); }
-               | attr_id_ass assign_op attr_id_any { $$=mk_action($2, AVP_ST, AVP_ST, $1, $3); }
-               | attr_id_ass assign_op select_id { $$=mk_action($2, AVP_ST, SELECT_ST, (void*)$1, (void*)$3); }
-               | attr_id_ass assign_op LPAREN exp RPAREN { $$ = mk_action($2, AVP_ST, EXPR_ST, $1, $4); }
-;
-
-cmd:           FORWARD LPAREN host RPAREN      { $$=mk_action( FORWARD_T,
-                                                                                                               STRING_ST,
-                                                                                                               NUMBER_ST,
-                                                                                                               $3,
-                                                                                                               0);
-                                                                               }
-               | FORWARD LPAREN STRING RPAREN  { $$=mk_action( FORWARD_T,
-                                                                                                               STRING_ST,
-                                                                                                               NUMBER_ST,
-                                                                                                               $3,
-                                                                                                               0);
-                                                                               }
-               | FORWARD LPAREN ip RPAREN      { $$=mk_action( FORWARD_T,
-                                                                                                               IP_ST,
-                                                                                                               NUMBER_ST,
-                                                                                                               (void*)$3,
-                                                                                                               0);
-                                                                               }
-               | FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T,
-                                                                                                                                STRING_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                               $3,
-                                                                                                                               (void*)$5);
-                                                                                                }
-               | FORWARD LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T,
-                                                                                                                                STRING_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                               $3,
-                                                                                                                               (void*)$5);
-                                                                                                       }
-               | FORWARD LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T,
-                                                                                                                                IP_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                                (void*)$3,
-                                                                                                                               (void*)$5);
-                                                                                                 }
-               | FORWARD LPAREN URIHOST COMMA URIPORT RPAREN {
-                                                                                                       $$=mk_action(FORWARD_T,
-                                                                                                                                URIHOST_ST,
-                                                                                                                                URIPORT_ST,
-                                                                                                                               0,
-                                                                                                                               0);
-                                                                                                       }
-
-
-               | FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {
-                                                                                                       $$=mk_action(FORWARD_T,
-                                                                                                                                URIHOST_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                               0,
-                                                                                                                               (void*)$5);
-                                                                                                       }
-               | FORWARD LPAREN URIHOST RPAREN {
-                                                                                                       $$=mk_action(FORWARD_T,
-                                                                                                                                URIHOST_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                               0,
-                                                                                                                               0);
-                                                                               }
-               | FORWARD error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | FORWARD LPAREN error RPAREN { $$=0; yyerror("bad forward"
-                                                                               "argument"); }
-               | FORWARD_UDP LPAREN host RPAREN        { $$=mk_action( FORWARD_UDP_T,
-                                                                                                               STRING_ST,
-                                                                                                               NUMBER_ST,
-                                                                                                               $3,
-                                                                                                               0);
-                                                                               }
-               | FORWARD_UDP LPAREN STRING RPAREN      { $$=mk_action( FORWARD_UDP_T,
-                                                                                                               STRING_ST,
-                                                                                                               NUMBER_ST,
-                                                                                                               $3,
-                                                                                                               0);
-                                                                               }
-               | FORWARD_UDP LPAREN ip RPAREN  { $$=mk_action( FORWARD_UDP_T,
-                                                                                                               IP_ST,
-                                                                                                               NUMBER_ST,
-                                                                                                               (void*)$3,
-                                                                                                               0);
-                                                                               }
-               | FORWARD_UDP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(
-                                                                                                                               FORWARD_UDP_T,
-                                                                                                                                STRING_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                               $3,
-                                                                                                                               (void*)$5);
-                                                                                                }
-               | FORWARD_UDP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(
-                                                                                                                               FORWARD_UDP_T,
-                                                                                                                                STRING_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                               $3,
-                                                                                                                               (void*)$5);
-                                                                                                       }
-               | FORWARD_UDP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(
-                                                                                                                               FORWARD_UDP_T,
-                                                                                                                                IP_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                                (void*)$3,
-                                                                                                                               (void*)$5);
-                                                                                                 }
-               | FORWARD_UDP LPAREN URIHOST COMMA URIPORT RPAREN {
-                                                                                                       $$=mk_action(FORWARD_UDP_T,
-                                                                                                                                URIHOST_ST,
-                                                                                                                                URIPORT_ST,
-                                                                                                                               0,
-                                                                                                                               0);
-                                                                                                       }
-
-
-               | FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN {
-                                                                                                       $$=mk_action(FORWARD_UDP_T,
-                                                                                                                                URIHOST_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                               0,
-                                                                                                                               (void*)$5);
-                                                                                                       }
-               | FORWARD_UDP LPAREN URIHOST RPAREN {
-                                                                                                       $$=mk_action(FORWARD_UDP_T,
-                                                                                                                                URIHOST_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                               0,
-                                                                                                                               0);
-                                                                               }
-               | FORWARD_UDP error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | FORWARD_UDP LPAREN error RPAREN { $$=0; yyerror("bad forward_udp"
-                                                                               "argument"); }
-               | FORWARD_TCP LPAREN host RPAREN        { $$=mk_action( FORWARD_TCP_T,
-                                                                                                               STRING_ST,
-                                                                                                               NUMBER_ST,
-                                                                                                               $3,
-                                                                                                               0);
-                                                                               }
-               | FORWARD_TCP LPAREN STRING RPAREN      { $$=mk_action( FORWARD_TCP_T,
-                                                                                                               STRING_ST,
-                                                                                                               NUMBER_ST,
-                                                                                                               $3,
-                                                                                                               0);
-                                                                               }
-               | FORWARD_TCP LPAREN ip RPAREN  { $$=mk_action( FORWARD_TCP_T,
-                                                                                                               IP_ST,
-                                                                                                               NUMBER_ST,
-                                                                                                               (void*)$3,
-                                                                                                               0);
-                                                                               }
-               | FORWARD_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(
-                                                                                                                               FORWARD_TCP_T,
-                                                                                                                                STRING_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                               $3,
-                                                                                                                               (void*)$5);
-                                                                                                }
-               | FORWARD_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(
-                                                                                                                               FORWARD_TCP_T,
-                                                                                                                                STRING_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                               $3,
-                                                                                                                               (void*)$5);
-                                                                                                       }
-               | FORWARD_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T,
-                                                                                                                                IP_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                                (void*)$3,
-                                                                                                                               (void*)$5);
-                                                                                                 }
-               | FORWARD_TCP LPAREN URIHOST COMMA URIPORT RPAREN {
-                                                                                                       $$=mk_action(FORWARD_TCP_T,
-                                                                                                                                URIHOST_ST,
-                                                                                                                                URIPORT_ST,
-                                                                                                                               0,
-                                                                                                                               0);
-                                                                                                       }
-
-
-               | FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN {
-                                                                                                       $$=mk_action(FORWARD_TCP_T,
-                                                                                                                                URIHOST_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                               0,
-                                                                                                                               (void*)$5);
-                                                                                                       }
-               | FORWARD_TCP LPAREN URIHOST RPAREN {
-                                                                                                       $$=mk_action(FORWARD_TCP_T,
-                                                                                                                                URIHOST_ST,
-                                                                                                                                NUMBER_ST,
-                                                                                                                               0,
-                                                                                                                               0);
-                                                                               }
-               | FORWARD_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | FORWARD_TCP LPAREN error RPAREN { $$=0; yyerror("bad forward_tcp"
-                                                                               "argument"); }
-               | FORWARD_TLS LPAREN host RPAREN        {
-                                                                               #ifdef USE_TLS
-                                                                                       $$=mk_action(   FORWARD_TLS_T,
-                                                                                                               STRING_ST,
-                                                                                                               NUMBER_ST,
-                                                                                                               $3,
-                                                                                                               0);
-                                                                               #else
-                                                                                       $$=0;
-                                                                                       yyerror("tls support not "
-                                                                                                       "compiled in");
-                                                                               #endif
-                                                                               }
-               | FORWARD_TLS LPAREN STRING RPAREN      {
-                                                                               #ifdef USE_TLS
-                                                                                       $$=mk_action(   FORWARD_TLS_T,
-                                                                                                                       STRING_ST,
-                                                                                                                       NUMBER_ST,
-                                                                                                                       $3,
-                                                                                                                       0);
-                                                                               #else
-                                                                                       $$=0;
-                                                                                       yyerror("tls support not "
-                                                                                                       "compiled in");
-                                                                               #endif
-                                                                               }
-               | FORWARD_TLS LPAREN ip RPAREN  {
-                                                                               #ifdef USE_TLS
-                                                                                       $$=mk_action(   FORWARD_TLS_T,
-                                                                                                                       IP_ST,
-                                                                                                                       NUMBER_ST,
-                                                                                                                       (void*)$3,
-                                                                                                                       0);
-                                                                               #else
-                                                                                       $$=0;
-                                                                                       yyerror("tls support not "
-                                                                                                       "compiled in");
-                                                                               #endif
-                                                                               }
-               | FORWARD_TLS LPAREN host COMMA NUMBER RPAREN {
-                                                                               #ifdef USE_TLS
-                                                                                       $$=mk_action(   FORWARD_TLS_T,
-                                                                                                                        STRING_ST,
-                                                                                                                        NUMBER_ST,
-                                                                                                                       $3,
-                                                                                                                       (void*)$5);
-                                                                               #else
-                                                                                       $$=0;
-                                                                                       yyerror("tls support not "
-                                                                                                       "compiled in");
-                                                                               #endif
-                                                                                                }
-               | FORWARD_TLS LPAREN STRING COMMA NUMBER RPAREN {
-                                                                               #ifdef USE_TLS
-                                                                                       $$=mk_action(   FORWARD_TLS_T,
-                                                                                                                        STRING_ST,
-                                                                                                                        NUMBER_ST,
-                                                                                                                       $3,
-                                                                                                                       (void*)$5);
-                                                                               #else
-                                                                                       $$=0;
-                                                                                       yyerror("tls support not "
-                                                                                                       "compiled in");
-                                                                               #endif
-                                                                                                       }
-               | FORWARD_TLS LPAREN ip COMMA NUMBER RPAREN {
-                                                                               #ifdef USE_TLS
-                                                                                       $$=mk_action(   FORWARD_TLS_T,
-                                                                                                                        IP_ST,
-                                                                                                                        NUMBER_ST,
-                                                                                                                        (void*)$3,
-                                                                                                                       (void*)$5);
-                                                                               #else
-                                                                                       $$=0;
-                                                                                       yyerror("tls support not "
-                                                                                                       "compiled in");
-                                                                               #endif
-                                                                                                 }
-               | FORWARD_TLS LPAREN URIHOST COMMA URIPORT RPAREN {
-                                                                               #ifdef USE_TLS
-                                                                                       $$=mk_action(   FORWARD_TLS_T,
-                                                                                                                        URIHOST_ST,
-                                                                                                                        URIPORT_ST,
-                                                                                                                       0,
-                                                                                                                       0);
-                                                                               #else
-                                                                                       $$=0;
-                                                                                       yyerror("tls support not "
-                                                                                                       "compiled in");
-                                                                               #endif
-                                                                                                       }
-
-
-               | FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN {
-                                                                               #ifdef USE_TLS
-                                                                                       $$=mk_action(   FORWARD_TLS_T,
-                                                                                                                        URIHOST_ST,
-                                                                                                                        NUMBER_ST,
-                                                                                                                       0,
-                                                                                                                       (void*)$5);
-                                                                               #else
-                                                                                       $$=0;
-                                                                                       yyerror("tls support not "
-                                                                                                       "compiled in");
-                                                                               #endif
-                                                                                                       }
-               | FORWARD_TLS LPAREN URIHOST RPAREN {
-                                                                               #ifdef USE_TLS
-                                                                                       $$=mk_action(   FORWARD_TLS_T,
-                                                                                                                        URIHOST_ST,
-                                                                                                                        NUMBER_ST,
-                                                                                                                       0,
-                                                                                                                       0);
-                                                                               #else
-                                                                                       $$=0;
-                                                                                       yyerror("tls support not "
-                                                                                                       "compiled in");
-                                                                               #endif
-                                                                               }
-               | FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | FORWARD_TLS LPAREN error RPAREN { $$=0; yyerror("bad forward_tls"
-                                                                               "argument"); }
-
-               | SEND LPAREN host RPAREN       { $$=mk_action( SEND_T,
-                                                                                                       STRING_ST,
-                                                                                                       NUMBER_ST,
-                                                                                                       $3,
-                                                                                                       0);
-                                                                       }
-               | SEND LPAREN STRING RPAREN { $$=mk_action(     SEND_T,
-                                                                                                       STRING_ST,
-                                                                                                       NUMBER_ST,
-                                                                                                       $3,
-                                                                                                       0);
-                                                                       }
-               | SEND LPAREN ip RPAREN         { $$=mk_action( SEND_T,
-                                                                                                       IP_ST,
-                                                                                                       NUMBER_ST,
-                                                                                                       (void*)$3,
-                                                                                                       0);
-                                                                       }
-               | SEND LPAREN host COMMA NUMBER RPAREN  { $$=mk_action( SEND_T,
-                                                                                                                               STRING_ST,
-                                                                                                                               NUMBER_ST,
-                                                                                                                               $3,
-                                                                                                                               (void*)$5);
-                                                                                               }
-               | SEND LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action( SEND_T,
-                                                                                                                               STRING_ST,
-                                                                                                                               NUMBER_ST,
-                                                                                                                               $3,
-                                                                                                                               (void*)$5);
-                                                                                               }
-               | SEND LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(    SEND_T,
-                                                                                                                               IP_ST,
-                                                                                                                               NUMBER_ST,
-                                                                                                                               (void*)$3,
-                                                                                                                               (void*)$5);
-                                                                                          }
-               | SEND error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | SEND LPAREN error RPAREN { $$=0; yyerror("bad send"
-                                                                                                       "argument"); }
-               | SEND_TCP LPAREN host RPAREN   { $$=mk_action( SEND_TCP_T,
-                                                                                                       STRING_ST,
-                                                                                                       NUMBER_ST,
-                                                                                                       $3,
-                                                                                                       0);
-                                                                       }
-               | SEND_TCP LPAREN STRING RPAREN { $$=mk_action( SEND_TCP_T,
-                                                                                                       STRING_ST,
-                                                                                                       NUMBER_ST,
-                                                                                                       $3,
-                                                                                                       0);
-                                                                       }
-               | SEND_TCP LPAREN ip RPAREN             { $$=mk_action( SEND_TCP_T,
-                                                                                                       IP_ST,
-                                                                                                       NUMBER_ST,
-                                                                                                       (void*)$3,
-                                                                                                       0);
-                                                                       }
-               | SEND_TCP LPAREN host COMMA NUMBER RPAREN      { $$=mk_action( SEND_TCP_T,
-                                                                                                                               STRING_ST,
-                                                                                                                               NUMBER_ST,
-                                                                                                                               $3,
-                                                                                                                               (void*)$5);
-                                                                                               }
-               | SEND_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(     SEND_TCP_T,
-                                                                                                                               STRING_ST,
-                                                                                                                               NUMBER_ST,
-                                                                                                                               $3,
-                                                                                                                               (void*)$5);
-                                                                                               }
-               | SEND_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(        SEND_TCP_T,
-                                                                                                                               IP_ST,
-                                                                                                                               NUMBER_ST,
-                                                                                                                               (void*)$3,
-                                                                                                                               (void*)$5);
-                                                                                          }
-               | SEND_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | SEND_TCP LPAREN error RPAREN { $$=0; yyerror("bad send_tcp"
-                                                                                                       "argument"); }
-               | DROP LPAREN RPAREN    {$$=mk_action(DROP_T,0, 0,
-                                                                                               0, (void*)EXIT_R_F); }
-               | DROP LPAREN NUMBER RPAREN     {$$=mk_action(DROP_T,0, 0,
-                                                                                               (void*)$3, (void*)EXIT_R_F); }
-               | DROP NUMBER                   {$$=mk_action(DROP_T,0, 0,
-                                                                                               (void*)$2, (void*)EXIT_R_F); }
-               | DROP RETCODE                  {$$=mk_action(DROP_T, RETCODE_ST, 0,
-                                                                                                       0, (void*)EXIT_R_F); }
-               | DROP                                  {$$=mk_action(DROP_T,0, 0,
-                                                                                               0, (void*)EXIT_R_F); }
-               | RETURN                                {$$=mk_action(DROP_T,0, 0,
-                                                                                               (void*)1, (void*)RETURN_R_F); }
-               | RETURN NUMBER                 {$$=mk_action(DROP_T,0, 0,
-                                                                                               (void*)$2, (void*)RETURN_R_F);}
-               | RETURN RETCODE                {$$=mk_action(DROP_T, RETCODE_ST, 0,
-                                                                                                               0, (void*)RETURN_R_F);}
-               | BREAK                                 {$$=mk_action(DROP_T,0, 0,
-                                                                                               0, (void*)RETURN_R_F); }
-               | LOG_TOK LPAREN STRING RPAREN  {$$=mk_action(  LOG_T, NUMBER_ST,
-                                                                                                       STRING_ST,(void*)4,$3);
-                                                                       }
-               | LOG_TOK LPAREN NUMBER COMMA STRING RPAREN     {$$=mk_action(  LOG_T,
-                                                                                                                               NUMBER_ST,
-                                                                                                                               STRING_ST,
-                                                                                                                               (void*)$3,
-                                                                                                                               $5);
-                                                                                               }
-               | LOG_TOK error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | LOG_TOK LPAREN error RPAREN { $$=0; yyerror("bad log"
-                                                                       "argument"); }
-               | SETFLAG LPAREN NUMBER RPAREN {$$=mk_action( SETFLAG_T, NUMBER_ST, 0,
-                                                                                                       (void *)$3, 0 ); }
-               | SETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
-               | RESETFLAG LPAREN NUMBER RPAREN {$$=mk_action( RESETFLAG_T, NUMBER_ST, 0,
-                                                                                                       (void *)$3, 0 ); }
-               | RESETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
-               | ISFLAGSET LPAREN NUMBER RPAREN {$$=mk_action( ISFLAGSET_T, NUMBER_ST, 0,
-                                                                                                       (void *)$3, 0 ); }
-               | ISFLAGSET error { $$=0; yyerror("missing '(' or ')'?"); }
-               | ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T,
-                                                                                                                               STRING_ST,
-                                                                                                                               STRING_ST,
-                                                                                                                               $3,
-                                                                                                                               $5);
-                                                                                                 }
-               | ERROR error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | ERROR LPAREN error RPAREN { $$=0; yyerror("bad error"
-                                                                                                               "argument"); }
-               | ROUTE LPAREN NUMBER RPAREN    { $$=mk_action(ROUTE_T, NUMBER_ST,
-                                                                                                               0, (void*)$3, 0);
-                                                                               }
-               | ROUTE error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | ROUTE LPAREN error RPAREN { $$=0; yyerror("bad route"
-                                               "argument"); }
-               | EXEC LPAREN STRING RPAREN     { $$=mk_action( EXEC_T, STRING_ST, 0,
-                                                                                                       $3, 0);
-                                                                       }
-               | SET_HOST LPAREN STRING RPAREN { $$=mk_action(SET_HOST_T, STRING_ST,
-                                                                                                               0, $3, 0); }
-               | SET_HOST error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | SET_HOST LPAREN error RPAREN { $$=0; yyerror("bad argument, "
-                                                                                                               "string expected"); }
-
-               | PREFIX LPAREN STRING RPAREN { $$=mk_action(PREFIX_T, STRING_ST,
-                                                                                                               0, $3, 0); }
-               | PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, "
-                                                                                                               "string expected"); }
-               | STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T,
-                                                                       NUMBER_ST, 0, (void *) $3, 0); }
-               | STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, "
-                                                                                                               "number expected"); }
-
-               | STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, NUMBER_ST,
-                                                                                                               0, (void *) $3, 0); }
-               | STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, "
-                                                                                                               "number expected"); }
-                | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN {
-                   {   qvalue_t q;
-                       if (str2q(&q, $5, strlen($5)) < 0) {
-                               yyerror("bad argument, q value expected");
+/*
+assign_op:
+       ADDEQ { $$ = ADD_T; }
+       | EQUAL { $$ = ASSIGN_T; }
+       ;
+*/
+assign_op:
+       EQUAL { $$ = ASSIGN_T; }
+       ;
+assign_action:
+       attr_id_ass assign_op STRING  { $$=mk_action($2, 2, AVP_ST, $1, STRING_ST, $3); }
+       | attr_id_ass assign_op NUMBER  { $$=mk_action($2, 2, AVP_ST, $1, NUMBER_ST, (void*)$3); }
+       | attr_id_ass assign_op fcmd    { $$=mk_action($2, 2, AVP_ST, $1, ACTION_ST, $3); }
+       | attr_id_ass assign_op attr_id_any { $$=mk_action($2, 2, AVP_ST, $1, AVP_ST, $3); }
+       | attr_id_ass assign_op select_id { $$=mk_action($2, 2, AVP_ST, (void*)$1, SELECT_ST, (void*)$3); }
+       | attr_id_ass assign_op LPAREN exp RPAREN { $$ = mk_action($2, 2, AVP_ST, $1, EXPR_ST, $4); }
+       ;
+cmd:
+       FORWARD LPAREN host RPAREN      { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
+       | FORWARD LPAREN STRING RPAREN  { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
+       | FORWARD LPAREN ip RPAREN      { $$=mk_action( FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
+       | FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
+       | FORWARD LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
+       | FORWARD LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
+       | FORWARD LPAREN URIHOST COMMA URIPORT RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
+       | FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
+       | FORWARD LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
+       | FORWARD error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | FORWARD LPAREN error RPAREN { $$=0; yyerror("bad forward argument"); }
+       | FORWARD_UDP LPAREN host RPAREN        { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
+       | FORWARD_UDP LPAREN STRING RPAREN      { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
+       | FORWARD_UDP LPAREN ip RPAREN  { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
+       | FORWARD_UDP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
+       | FORWARD_UDP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
+       | FORWARD_UDP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
+       | FORWARD_UDP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
+       | FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
+       | FORWARD_UDP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
+       | FORWARD_UDP error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | FORWARD_UDP LPAREN error RPAREN { $$=0; yyerror("bad forward_udp argument"); }
+       | FORWARD_TCP LPAREN host RPAREN        { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
+       | FORWARD_TCP LPAREN STRING RPAREN      { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
+       | FORWARD_TCP LPAREN ip RPAREN  { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
+       | FORWARD_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
+       | FORWARD_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
+       | FORWARD_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
+       | FORWARD_TCP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
+       | FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
+       | FORWARD_TCP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
+       | FORWARD_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | FORWARD_TCP LPAREN error RPAREN { $$=0; yyerror("bad forward_tcp argument"); }
+       | FORWARD_TLS LPAREN host RPAREN {
+               #ifdef USE_TLS
+                       $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0);
+               #else
+                       $$=0;
+                       yyerror("tls support not compiled in");
+               #endif
+       }
+       | FORWARD_TLS LPAREN STRING RPAREN {
+               #ifdef USE_TLS
+                       $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0);
+               #else
+                       $$=0;
+                       yyerror("tls support not compiled in");
+               #endif
+       }
+       | FORWARD_TLS LPAREN ip RPAREN  {
+               #ifdef USE_TLS
+                       $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0);
+               #else
+                       $$=0;
+                       yyerror("tls support not compiled in");
+               #endif
+       }
+       | FORWARD_TLS LPAREN host COMMA NUMBER RPAREN {
+               #ifdef USE_TLS
+                       $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);
+               #else
+                       $$=0;
+                       yyerror("tls support not compiled in");
+               #endif
+       }
+       | FORWARD_TLS LPAREN STRING COMMA NUMBER RPAREN {
+               #ifdef USE_TLS
+                       $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);
+               #else
+                       $$=0;
+                       yyerror("tls support not compiled in");
+               #endif
+       }
+       | FORWARD_TLS LPAREN ip COMMA NUMBER RPAREN {
+               #ifdef USE_TLS
+                       $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5);
+               #else
+                       $$=0;
+                       yyerror("tls support not compiled in");
+               #endif
+                                       }
+       | FORWARD_TLS LPAREN URIHOST COMMA URIPORT RPAREN {
+               #ifdef USE_TLS
+                       $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, URIPORT_ST, 0);
+               #else
+                       $$=0;
+                       yyerror("tls support not compiled in");
+               #endif
+       }
+       | FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN {
+               #ifdef USE_TLS
+                       $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5);
+               #else
+                       $$=0;
+                       yyerror("tls support not compiled in");
+               #endif
+       }
+       | FORWARD_TLS LPAREN URIHOST RPAREN {
+               #ifdef USE_TLS
+                       $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, 0);
+               #else
+                       $$=0;
+                       yyerror("tls support not compiled in");
+               #endif
+       }
+       | FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | FORWARD_TLS LPAREN error RPAREN { $$=0; yyerror("bad forward_tls argument"); }
+       | SEND LPAREN host RPAREN       { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
+       | SEND LPAREN STRING RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
+       | SEND LPAREN ip RPAREN         { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
+       | SEND LPAREN host COMMA NUMBER RPAREN  { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
+       | SEND LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
+       | SEND LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
+       | SEND error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | SEND LPAREN error RPAREN { $$=0; yyerror("bad send argument"); }
+       | SEND_TCP LPAREN host RPAREN   { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
+       | SEND_TCP LPAREN STRING RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
+       | SEND_TCP LPAREN ip RPAREN     { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
+       | SEND_TCP LPAREN host COMMA NUMBER RPAREN      { $$=mk_action( SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);}
+       | SEND_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
+       | SEND_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
+       | SEND_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | SEND_TCP LPAREN error RPAREN { $$=0; yyerror("bad send_tcp argument"); }
+       | DROP LPAREN RPAREN    {$$=mk_action(DROP_T,0, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
+       | DROP LPAREN NUMBER RPAREN     {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$3, NUMBER_ST, (void*)EXIT_R_F); }
+       | DROP NUMBER                   {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$2, NUMBER_ST, (void*)EXIT_R_F); }
+       | DROP RETCODE                  {$$=mk_action(DROP_T, 2, RETCODE_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
+       | DROP                          {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
+       | RETURN                        {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST, (void*)RETURN_R_F); }
+       | RETURN NUMBER                 {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$2, NUMBER_ST, (void*)RETURN_R_F);}
+       | RETURN RETCODE                {$$=mk_action(DROP_T, 2, RETCODE_ST, 0, NUMBER_ST, (void*)RETURN_R_F);}
+       | BREAK                         {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)RETURN_R_F); }
+       | LOG_TOK LPAREN STRING RPAREN  {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)4, STRING_ST, $3); }
+       | LOG_TOK LPAREN NUMBER COMMA STRING RPAREN     {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)$3, STRING_ST, $5); }
+       | LOG_TOK error                 { $$=0; yyerror("missing '(' or ')' ?"); }
+       | LOG_TOK LPAREN error RPAREN   { $$=0; yyerror("bad log argument"); }
+       | SETFLAG LPAREN NUMBER RPAREN  {$$=mk_action(SETFLAG_T, 1, NUMBER_ST, (void*)$3); }
+       | SETFLAG error                 { $$=0; yyerror("missing '(' or ')'?"); }
+       | RESETFLAG LPAREN NUMBER RPAREN {$$=mk_action(RESETFLAG_T, 1, NUMBER_ST, (void*)$3); }
+       | RESETFLAG error               { $$=0; yyerror("missing '(' or ')'?"); }
+       | ISFLAGSET LPAREN NUMBER RPAREN {$$=mk_action(ISFLAGSET_T, 1, NUMBER_ST, (void*)$3); }
+       | ISFLAGSET error { $$=0; yyerror("missing '(' or ')'?"); }
+       | ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T, 2, STRING_ST, $3, STRING_ST, $5); }
+       | ERROR error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | ERROR LPAREN error RPAREN { $$=0; yyerror("bad error argument"); }
+       | ROUTE LPAREN NUMBER RPAREN    { $$=mk_action(ROUTE_T, 1, NUMBER_ST, (void*)$3); }
+       | ROUTE error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | ROUTE LPAREN error RPAREN { $$=0; yyerror("bad route argument"); }
+       | EXEC LPAREN STRING RPAREN     { $$=mk_action(EXEC_T, 1, STRING_ST, $3); }
+       | SET_HOST LPAREN STRING RPAREN { $$=mk_action(SET_HOST_T, 1, STRING_ST, $3); }
+       | SET_HOST error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | SET_HOST LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
+       | PREFIX LPAREN STRING RPAREN { $$=mk_action(PREFIX_T, 1, STRING_ST,  $3); }
+       | PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
+       | STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, 1, NUMBER_ST, (void*)$3); }
+       | STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
+       | STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, 1, NUMBER_ST, (void*) $3); }
+       | STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
+       | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN {
+               qvalue_t q;
+               if (str2q(&q, $5, strlen($5)) < 0) {
+                       yyerror("bad argument, q value expected");
+               }
+               $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)(long)q);
+       }
+       | APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)Q_UNSPECIFIED); }
+       | APPEND_BRANCH LPAREN RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, 0, NUMBER_ST, (void *)Q_UNSPECIFIED); }
+       | APPEND_BRANCH {  $$=mk_action( APPEND_BRANCH_T, 1, STRING_ST, 0); }
+       | SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORT_T, 1, STRING_ST, $3); }
+       | SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
+       | SET_PORT LPAREN STRING RPAREN { $$=mk_action(SET_PORT_T, 1, STRING_ST, $3); }
+       | SET_PORT error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | SET_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
+       | SET_USER LPAREN STRING RPAREN { $$=mk_action(SET_USER_T, 1, STRING_ST, $3); }
+       | SET_USER error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | SET_USER LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
+       | SET_USERPASS LPAREN STRING RPAREN { $$=mk_action(SET_USERPASS_T, 1, STRING_ST, $3); }
+       | SET_USERPASS error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | SET_USERPASS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
+       | SET_URI LPAREN STRING RPAREN { $$=mk_action(SET_URI_T, 1, STRING_ST,$3); }
+       | SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); }
+       | SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
+       | REVERT_URI LPAREN RPAREN { $$=mk_action(REVERT_URI_T, 0); }
+       | REVERT_URI { $$=mk_action(REVERT_URI_T, 0); }
+       | FORCE_RPORT LPAREN RPAREN     { $$=mk_action(FORCE_RPORT_T, 0); }
+       | FORCE_RPORT   {$$=mk_action(FORCE_RPORT_T, 0); }
+       | FORCE_TCP_ALIAS LPAREN NUMBER RPAREN  {
+               #ifdef USE_TCP
+                       $$=mk_action(FORCE_TCP_ALIAS_T, 1, NUMBER_ST, (void*)$3);
+               #else
+                       yyerror("tcp support not compiled in");
+               #endif
+       }
+       | FORCE_TCP_ALIAS LPAREN RPAREN {
+               #ifdef USE_TCP
+                       $$=mk_action(FORCE_TCP_ALIAS_T, 0);
+               #else
+                       yyerror("tcp support not compiled in");
+               #endif
+       }
+       | FORCE_TCP_ALIAS                               {
+               #ifdef USE_TCP
+                       $$=mk_action(FORCE_TCP_ALIAS_T, 0);
+               #else
+                       yyerror("tcp support not compiled in");
+               #endif
+       }
+       | FORCE_TCP_ALIAS LPAREN error RPAREN   {$$=0; yyerror("bad argument, number expected"); }
+       | SET_ADV_ADDRESS LPAREN listen_id RPAREN {
+               $$=0;
+               if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
+                       LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
+               } else {
+                       str_tmp->s=$3;
+                       str_tmp->len=strlen($3);
+                       $$=mk_action(SET_ADV_ADDR_T, 1, STR_ST, str_tmp);
+               }
+       }
+       | SET_ADV_ADDRESS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
+       | SET_ADV_ADDRESS error {$$=0; yyerror("missing '(' or ')' ?"); }
+       | SET_ADV_PORT LPAREN NUMBER RPAREN {
+               $$=0;
+               tmp=int2str($3, &i_tmp);
+               if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
+                       LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
+               } else {
+                       if ((str_tmp->s=pkg_malloc(i_tmp))==0) {
+                               LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
+                       } else {
+                               memcpy(str_tmp->s, tmp, i_tmp);
+                               str_tmp->len=i_tmp;
+                               $$=mk_action(SET_ADV_PORT_T, 1, STR_ST, str_tmp);
                        }
-                       $$=mk_action(APPEND_BRANCH_T, STRING_ST, NUMBER_ST, $3,
-                                                       (void *)(long)q); }
                }
-
-               | APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action( APPEND_BRANCH_T,
-                                                                                                       STRING_ST, NUMBER_ST, $3, (void *)Q_UNSPECIFIED) ; }
-               | APPEND_BRANCH LPAREN RPAREN { $$=mk_action( APPEND_BRANCH_T,
-                                                                                                       STRING_ST, NUMBER_ST, 0, (void *)Q_UNSPECIFIED ) ; }
-               | APPEND_BRANCH {  $$=mk_action( APPEND_BRANCH_T, STRING_ST, 0, 0, 0 ) ; }
-
-               | SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action( SET_HOSTPORT_T,
-                                                                                                               STRING_ST, 0, $3, 0); }
-               | SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument,"
-                                                                                               " string expected"); }
-               | SET_PORT LPAREN STRING RPAREN { $$=mk_action( SET_PORT_T, STRING_ST,
-                                                                                                               0, $3, 0); }
-               | SET_PORT error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | SET_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, "
-                                                                                                               "string expected"); }
-               | SET_USER LPAREN STRING RPAREN { $$=mk_action( SET_USER_T, STRING_ST,
-                                                                                                               0, $3, 0); }
-               | SET_USER error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | SET_USER LPAREN error RPAREN { $$=0; yyerror("bad argument, "
-                                                                                                               "string expected"); }
-               | SET_USERPASS LPAREN STRING RPAREN { $$=mk_action( SET_USERPASS_T,
-                                                                                                               STRING_ST, 0, $3, 0); }
-               | SET_USERPASS error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | SET_USERPASS LPAREN error RPAREN { $$=0; yyerror("bad argument, "
-                                                                                                               "string expected"); }
-               | SET_URI LPAREN STRING RPAREN { $$=mk_action( SET_URI_T, STRING_ST,
-                                                                                                               0, $3, 0); }
-               | SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); }
-               | SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, "
-                                                                               "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); }
-               | FORCE_TCP_ALIAS LPAREN NUMBER RPAREN  {
-                                       #ifdef USE_TCP
-                                               $$=mk_action(FORCE_TCP_ALIAS_T,NUMBER_ST, 0,
-                                                                               (void*)$3, 0);
-                                       #else
-                                               yyerror("tcp support not compiled in");
-                                       #endif
-                                                                                               }
-               | FORCE_TCP_ALIAS LPAREN RPAREN {
-                                       #ifdef USE_TCP
-                                               $$=mk_action(FORCE_TCP_ALIAS_T,0, 0, 0, 0);
-                                       #else
-                                               yyerror("tcp support not compiled in");
-                                       #endif
-                                                                               }
-               | FORCE_TCP_ALIAS                               {
-                                       #ifdef USE_TCP
-                                               $$=mk_action(FORCE_TCP_ALIAS_T,0, 0, 0, 0);
-                                       #else
-                                               yyerror("tcp support not compiled in");
-                                       #endif
-                                                                               }
-               | FORCE_TCP_ALIAS LPAREN error RPAREN   {$$=0;
-                                       yyerror("bad argument, number expected");
-                                       }
-               | SET_ADV_ADDRESS LPAREN listen_id RPAREN {
-                                                               $$=0;
-                                                               if ((str_tmp=pkg_malloc(sizeof(str)))==0){
-                                                                               LOG(L_CRIT, "ERROR: cfg. parser:"
-                                                                                                       " out of memory.\n");
-                                                               }else{
-                                                                               str_tmp->s=$3;
-                                                                               str_tmp->len=strlen($3);
-                                                                               $$=mk_action(SET_ADV_ADDR_T, STR_ST,
-                                                                                            0, str_tmp, 0);
-                                                               }
-                                                                                                 }
-               | SET_ADV_ADDRESS LPAREN error RPAREN { $$=0; yyerror("bad argument, "
-                                                                                                               "string expected"); }
-               | SET_ADV_ADDRESS error {$$=0; yyerror("missing '(' or ')' ?"); }
-               | SET_ADV_PORT LPAREN NUMBER RPAREN {
-                                                               $$=0;
-                                                               tmp=int2str($3, &i_tmp);
-                                                               if ((str_tmp=pkg_malloc(sizeof(str)))==0){
-                                                                               LOG(L_CRIT, "ERROR: cfg. parser:"
-                                                                                                       " out of memory.\n");
-                                                               }else{
-                                                                       if ((str_tmp->s=pkg_malloc(i_tmp))==0){
-                                                                               LOG(L_CRIT, "ERROR: cfg. parser:"
-                                                                                                       " out of memory.\n");
-                                                                       }else{
-