... | ... |
@@ -22,8 +22,8 @@ |
22 | 22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | 23 |
* GNU General Public License for more details. |
24 | 24 |
* |
25 |
- * You should have received a copy of the GNU General Public License |
|
26 |
- * along with this program; if not, write to the Free Software |
|
25 |
+ * You should have received a copy of the GNU General Public License |
|
26 |
+ * along with this program; if not, write to the Free Software |
|
27 | 27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 | 28 |
*/ |
29 | 29 |
/* |
... | ... |
@@ -39,7 +39,7 @@ |
39 | 39 |
* 2003-04-12 added force_rport, chroot and wdir (andrei) |
40 | 40 |
* 2003-04-15 added tcp_children, disable_tcp (andrei) |
41 | 41 |
* 2003-04-22 strip_tail added (jiri) |
42 |
- * 2003-07-03 tls* (disable, certificate, private_key, ca_list, verify, |
|
42 |
+ * 2003-07-03 tls* (disable, certificate, private_key, ca_list, verify, |
|
43 | 43 |
* require_certificate added (andrei) |
44 | 44 |
* 2003-07-06 more tls config. vars added: tls_method, tls_port_no (andrei) |
45 | 45 |
* 2003-10-02 added {,set_}advertised_{address,port} (andrei) |
... | ... |
@@ -68,7 +68,7 @@ |
68 | 68 |
* snd_{ip,port,proto,af}, to_{ip,proto} (andrei) |
69 | 69 |
* 2005-12-19 select framework (mma) |
70 | 70 |
* 2006-01-06 AVP index support (mma) |
71 |
- * |
|
71 |
+ * 2005-01-07 optional semicolon in statement, PARAM_STR&PARAM_STRING |
|
72 | 72 |
*/ |
73 | 73 |
|
74 | 74 |
%{ |
... | ... |
@@ -157,7 +157,7 @@ static struct socket_id* mk_listen_id(char*, int, int); |
157 | 157 |
%token SEND |
158 | 158 |
%token SEND_TCP |
159 | 159 |
%token DROP |
160 |
-%token RETURN |
|
160 |
+%token RETURN |
|
161 | 161 |
%token BREAK |
162 | 162 |
%token LOG_TOK |
163 | 163 |
%token ERROR |
... | ... |
@@ -208,8 +208,8 @@ static struct socket_id* mk_listen_id(char*, int, int); |
208 | 208 |
%token PROTO |
209 | 209 |
%token AF |
210 | 210 |
%token MYSELF |
211 |
-%token MSGLEN |
|
212 |
-%token RETCODE |
|
211 |
+%token MSGLEN |
|
212 |
+%token RETCODE |
|
213 | 213 |
%token UDP |
214 | 214 |
%token TCP |
215 | 215 |
%token TLS |
... | ... |
@@ -297,7 +297,7 @@ static struct socket_id* mk_listen_id(char*, int, int); |
297 | 297 |
%left LOG_OR |
298 | 298 |
%left LOG_AND |
299 | 299 |
%left BIN_OR |
300 |
-%left BIN_AND |
|
300 |
+%left BIN_AND |
|
301 | 301 |
%left PLUS MINUS |
302 | 302 |
%right NOT |
303 | 303 |
|
... | ... |
@@ -362,13 +362,14 @@ statements: statements statement {} |
362 | 362 |
| statements error { yyerror(""); YYABORT;} |
363 | 363 |
; |
364 | 364 |
|
365 |
-statement: assign_stm |
|
365 |
+statement: assign_stm |
|
366 | 366 |
| module_stm |
367 |
- | {rt=REQUEST_ROUTE;} route_stm |
|
367 |
+ | {rt=REQUEST_ROUTE;} route_stm |
|
368 | 368 |
| {rt=FAILURE_ROUTE;} failure_route_stm |
369 | 369 |
| {rt=ONREPLY_ROUTE;} onreply_route_stm |
370 | 370 |
| {rt=BRANCH_ROUTE;} branch_route_stm |
371 | 371 |
| {rt=ONSEND_ROUTE;} send_route_stm |
372 |
+ | SEMICOLON /* null statement */ |
|
372 | 373 |
| CR /* null statement*/ |
373 | 374 |
; |
374 | 375 |
|
... | ... |
@@ -462,9 +463,9 @@ assign_stm: DEBUG_V EQUAL NUMBER { debug=$3; } |
462 | 463 |
} |
463 | 464 |
| MAXBUFFER EQUAL NUMBER { maxbuffer=$3; } |
464 | 465 |
| MAXBUFFER EQUAL error { yyerror("number expected"); } |
465 |
- | PORT EQUAL error { yyerror("number expected"); } |
|
466 |
+ | PORT EQUAL error { yyerror("number expected"); } |
|
466 | 467 |
| CHILDREN EQUAL NUMBER { children_no=$3; } |
467 |
- | CHILDREN EQUAL error { yyerror("number expected"); } |
|
468 |
+ | CHILDREN EQUAL error { yyerror("number expected"); } |
|
468 | 469 |
| CHECK_VIA EQUAL NUMBER { check_via=$3; } |
469 | 470 |
| CHECK_VIA EQUAL error { yyerror("boolean value expected"); } |
470 | 471 |
| SYN_BRANCH EQUAL NUMBER { syn_branch=$3; } |
... | ... |
@@ -580,7 +581,7 @@ assign_stm: DEBUG_V EQUAL NUMBER { debug=$3; } |
580 | 581 |
#endif |
581 | 582 |
} |
582 | 583 |
| DISABLE_TLS EQUAL error { yyerror("boolean value expected"); } |
583 |
- | TLSLOG EQUAL NUMBER { |
|
584 |
+ | TLSLOG EQUAL NUMBER { |
|
584 | 585 |
#ifdef USE_TLS |
585 | 586 |
tls_log=$3; |
586 | 587 |
#else |
... | ... |
@@ -632,7 +633,7 @@ assign_stm: DEBUG_V EQUAL NUMBER { debug=$3; } |
632 | 633 |
warn("tls support not compiled in"); |
633 | 634 |
#endif |
634 | 635 |
} |
635 |
- |
|
636 |
+ |
|
636 | 637 |
| TLS_VERIFY EQUAL NUMBER { |
637 | 638 |
#ifdef USE_TLS |
638 | 639 |
tls_verify_cert=$3; |
... | ... |
@@ -650,7 +651,7 @@ assign_stm: DEBUG_V EQUAL NUMBER { debug=$3; } |
650 | 651 |
} |
651 | 652 |
| TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value" |
652 | 653 |
" expected"); } |
653 |
- | TLS_CERTIFICATE EQUAL STRING { |
|
654 |
+ | TLS_CERTIFICATE EQUAL STRING { |
|
654 | 655 |
#ifdef USE_TLS |
655 | 656 |
tls_cert_file=$3; |
656 | 657 |
#else |
... | ... |
@@ -658,7 +659,7 @@ assign_stm: DEBUG_V EQUAL NUMBER { debug=$3; } |
658 | 659 |
#endif |
659 | 660 |
} |
660 | 661 |
| TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); } |
661 |
- | TLS_PRIVATE_KEY EQUAL STRING { |
|
662 |
+ | TLS_PRIVATE_KEY EQUAL STRING { |
|
662 | 663 |
#ifdef USE_TLS |
663 | 664 |
tls_pkey_file=$3; |
664 | 665 |
#else |
... | ... |
@@ -666,7 +667,7 @@ assign_stm: DEBUG_V EQUAL NUMBER { debug=$3; } |
666 | 667 |
#endif |
667 | 668 |
} |
668 | 669 |
| TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); } |
669 |
- | TLS_CA_LIST EQUAL STRING { |
|
670 |
+ | TLS_CA_LIST EQUAL STRING { |
|
670 | 671 |
#ifdef USE_TLS |
671 | 672 |
tls_ca_file=$3; |
672 | 673 |
#else |
... | ... |
@@ -709,7 +710,7 @@ assign_stm: DEBUG_V EQUAL NUMBER { debug=$3; } |
709 | 710 |
} |
710 | 711 |
| LISTEN EQUAL error { yyerror("ip address or hostname" |
711 | 712 |
"expected"); } |
712 |
- | ALIAS EQUAL id_lst { |
|
713 |
+ | ALIAS EQUAL id_lst { |
|
713 | 714 |
for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) |
714 | 715 |
add_alias(lst_tmp->name, strlen(lst_tmp->name), |
715 | 716 |
lst_tmp->port, lst_tmp->proto); |
... | ... |
@@ -772,12 +773,12 @@ module_stm: LOADMODULE STRING { DBG("loading module %s\n", $2); |
772 | 773 |
} |
773 | 774 |
| LOADMODULE error { yyerror("string expected"); } |
774 | 775 |
| MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN { |
775 |
- if (set_mod_param_regex($3, $5, STR_PARAM, $7) != 0) { |
|
776 |
+ if (set_mod_param_regex($3, $5, PARAM_STR|PARAM_STRING, $7) != 0) { |
|
776 | 777 |
yyerror("Can't set module parameter"); |
777 | 778 |
} |
778 | 779 |
} |
779 | 780 |
| MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN { |
780 |
- if (set_mod_param_regex($3, $5, INT_PARAM, (void*)$7) != 0) { |
|
781 |
+ if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) { |
|
781 | 782 |
yyerror("Can't set module parameter"); |
782 | 783 |
} |
783 | 784 |
} |
... | ... |
@@ -789,7 +790,7 @@ ip: ipv4 { $$=$1; } |
789 | 790 |
|ipv6 { $$=$1; } |
790 | 791 |
; |
791 | 792 |
|
792 |
-ipv4: NUMBER DOT NUMBER DOT NUMBER DOT NUMBER { |
|
793 |
+ipv4: NUMBER DOT NUMBER DOT NUMBER DOT NUMBER { |
|
793 | 794 |
$$=pkg_malloc( |
794 | 795 |
sizeof(struct ip_addr)); |
795 | 796 |
if ($$==0){ |
... | ... |
@@ -797,7 +798,7 @@ ipv4: NUMBER DOT NUMBER DOT NUMBER DOT NUMBER { |
797 | 798 |
"parser: out of memory.\n" |
798 | 799 |
); |
799 | 800 |
}else{ |
800 |
- memset($$, 0, |
|
801 |
+ memset($$, 0, |
|
801 | 802 |
sizeof(struct ip_addr)); |
802 | 803 |
$$->af=AF_INET; |
803 | 804 |
$$->len=4; |
... | ... |
@@ -850,7 +851,7 @@ ipv6: ipv6addr { $$=$1; } |
850 | 851 |
|
851 | 852 |
route_stm: ROUTE LBRACE actions RBRACE { push($3, &rlist[DEFAULT_RT]); } |
852 | 853 |
|
853 |
- | ROUTE LBRACK NUMBER RBRACK LBRACE actions RBRACE { |
|
854 |
+ | ROUTE LBRACK NUMBER RBRACK LBRACE actions RBRACE { |
|
854 | 855 |
if (($3<RT_NO) && ($3>=0)){ |
855 | 856 |
push($6, &rlist[$3]); |
856 | 857 |
}else{ |
... | ... |
@@ -941,7 +942,7 @@ exp: exp LOG_AND exp { $$=mk_exp(LOGAND_OP, $1, $3); } |
941 | 942 |
equalop: EQUAL_T {$$=EQUAL_OP; } |
942 | 943 |
| DIFF {$$=DIFF_OP; } |
943 | 944 |
; |
944 |
- |
|
945 |
+ |
|
945 | 946 |
intop: equalop {$$=$1; } |
946 | 947 |
| GT {$$=GT_OP; } |
947 | 948 |
| LT {$$=LT_OP; } |
... | ... |
@@ -952,7 +953,7 @@ intop: equalop {$$=$1; } |
952 | 953 |
binop : BIN_OR { $$= BINOR_OP; } |
953 | 954 |
| BIN_AND { $$ = BINAND_OP; } |
954 | 955 |
; |
955 |
- |
|
956 |
+ |
|
956 | 957 |
strop: equalop {$$=$1; } |
957 | 958 |
| MATCH {$$=MATCH_OP; } |
958 | 959 |
; |
... | ... |
@@ -1060,7 +1061,7 @@ exp_elem: METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);} |
1060 | 1061 |
ip_tmp=str2ip6(&s_tmp); |
1061 | 1062 |
if (ip_tmp){ |
1062 | 1063 |
$$=mk_elem( $2, SRCIP_O, 0, NET_ST, |
1063 |
- mk_net_bitlen(ip_tmp, |
|
1064 |
+ mk_net_bitlen(ip_tmp, |
|
1064 | 1065 |
ip_tmp->len*8) ); |
1065 | 1066 |
}else{ |
1066 | 1067 |
$$=mk_elem( $2, SRCIP_O, 0, STRING_ST, |
... | ... |
@@ -1073,7 +1074,7 @@ exp_elem: METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);} |
1073 | 1074 |
} |
1074 | 1075 |
| SRCIP strop error { $$=0; yyerror( "ip address or hostname" |
1075 | 1076 |
"expected" ); } |
1076 |
- | SRCIP error { $$=0; |
|
1077 |
+ | SRCIP error { $$=0; |
|
1077 | 1078 |
yyerror("invalid operator, ==, != or =~ expected");} |
1078 | 1079 |
| DSTIP equalop ipnet { $$=mk_elem( $2, DSTIP_O, 0, NET_ST, |
1079 | 1080 |
(void*)$3); |
... | ... |
@@ -1085,7 +1086,7 @@ exp_elem: METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);} |
1085 | 1086 |
ip_tmp=str2ip6(&s_tmp); |
1086 | 1087 |
if (ip_tmp){ |
1087 | 1088 |
$$=mk_elem( $2, DSTIP_O, 0, NET_ST, |
1088 |
- mk_net_bitlen(ip_tmp, |
|
1089 |
+ mk_net_bitlen(ip_tmp, |
|
1089 | 1090 |
ip_tmp->len*8) ); |
1090 | 1091 |
}else{ |
1091 | 1092 |
$$=mk_elem( $2, DSTIP_O, 0, STRING_ST, |
... | ... |
@@ -1100,7 +1101,7 @@ exp_elem: METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);} |
1100 | 1101 |
} |
1101 | 1102 |
| DSTIP strop error { $$=0; yyerror( "ip address or hostname" |
1102 | 1103 |
"expected" ); } |
1103 |
- | DSTIP error { $$=0; |
|
1104 |
+ | DSTIP error { $$=0; |
|
1104 | 1105 |
yyerror("invalid operator, ==, != or =~ expected");} |
1105 | 1106 |
| SNDIP equalop ipnet { onsend_check("snd_ip"); |
1106 | 1107 |
$$=mk_elem($2, SNDIP_O, 0, NET_ST, $3); } |
... | ... |
@@ -1112,7 +1113,7 @@ exp_elem: METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);} |
1112 | 1113 |
ip_tmp=str2ip6(&s_tmp); |
1113 | 1114 |
if (ip_tmp){ |
1114 | 1115 |
$$=mk_elem( $2, SNDIP_O, 0, NET_ST, |
1115 |
- mk_net_bitlen(ip_tmp, |
|
1116 |
+ mk_net_bitlen(ip_tmp, |
|
1116 | 1117 |
ip_tmp->len*8) ); |
1117 | 1118 |
}else{ |
1118 | 1119 |
$$=mk_elem( $2, SNDIP_O, 0, STRING_ST, |
... | ... |
@@ -1126,7 +1127,7 @@ exp_elem: METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);} |
1126 | 1127 |
} |
1127 | 1128 |
| SNDIP strop error { $$=0; yyerror( "ip address or hostname" |
1128 | 1129 |
"expected" ); } |
1129 |
- | SNDIP error { $$=0; |
|
1130 |
+ | SNDIP error { $$=0; |
|
1130 | 1131 |
yyerror("invalid operator, ==, != or =~ expected");} |
1131 | 1132 |
| TOIP equalop ipnet { onsend_check("to_ip"); |
1132 | 1133 |
$$=mk_elem($2, TOIP_O, 0, NET_ST, $3); } |
... | ... |
@@ -1138,7 +1139,7 @@ exp_elem: METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);} |
1138 | 1139 |
ip_tmp=str2ip6(&s_tmp); |
1139 | 1140 |
if (ip_tmp){ |
1140 | 1141 |
$$=mk_elem( $2, TOIP_O, 0, NET_ST, |
1141 |
- mk_net_bitlen(ip_tmp, |
|
1142 |
+ mk_net_bitlen(ip_tmp, |
|
1142 | 1143 |
ip_tmp->len*8) ); |
1143 | 1144 |
}else{ |
1144 | 1145 |
$$=mk_elem( $2, TOIP_O, 0, STRING_ST, |
... | ... |
@@ -1152,7 +1153,7 @@ exp_elem: METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);} |
1152 | 1153 |
} |
1153 | 1154 |
| TOIP strop error { $$=0; yyerror( "ip address or hostname" |
1154 | 1155 |
"expected" ); } |
1155 |
- | TOIP error { $$=0; |
|
1156 |
+ | TOIP error { $$=0; |
|
1156 | 1157 |
yyerror("invalid operator, ==, != or =~ expected");} |
1157 | 1158 |
|
1158 | 1159 |
| MYSELF equalop uri_type { $$=mk_elem( $2, $3, 0, MYSELF_ST, |
... | ... |
@@ -1170,9 +1171,9 @@ exp_elem: METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);} |
1170 | 1171 |
| MYSELF equalop TOIP { onsend_check("to_ip"); |
1171 | 1172 |
$$=mk_elem( $2, TOIP_O, 0, MYSELF_ST, 0); |
1172 | 1173 |
} |
1173 |
- | MYSELF equalop error { $$=0; |
|
1174 |
+ | MYSELF equalop error { $$=0; |
|
1174 | 1175 |
yyerror(" URI, SRCIP or DSTIP expected"); } |
1175 |
- | MYSELF error { $$=0; |
|
1176 |
+ | MYSELF error { $$=0; |
|
1176 | 1177 |
yyerror ("invalid operator, == or != expected"); |
1177 | 1178 |
} |
1178 | 1179 |
| exp_stm { $$=mk_elem( NO_OP, ACTION_O, 0, ACTIONS_ST, $1); } |
... | ... |
@@ -1192,14 +1193,14 @@ exp_elem: METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);} |
1192 | 1193 |
; |
1193 | 1194 |
|
1194 | 1195 |
|
1195 |
-ipnet: ip SLASH ip { $$=mk_net($1, $3); } |
|
1196 |
+ipnet: ip SLASH ip { $$=mk_net($1, $3); } |
|
1196 | 1197 |
| ip SLASH NUMBER { if (($3<0) || ($3>$1->len*8)){ |
1197 | 1198 |
yyerror("invalid bit number in netmask"); |
1198 | 1199 |
$$=0; |
1199 | 1200 |
}else{ |
1200 | 1201 |
$$=mk_net_bitlen($1, $3); |
1201 | 1202 |
/* |
1202 |
- $$=mk_net($1, |
|
1203 |
+ $$=mk_net($1, |
|
1203 | 1204 |
htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) ); |
1204 | 1205 |
*/ |
1205 | 1206 |
} |
... | ... |
@@ -1303,11 +1304,11 @@ if_cmd: IF exp stm { $$=mk_action3( IF_T, |
1303 | 1304 |
// | LBRACK ATTR_GLOBAL RBRACK { $$ = AVP_CLASS_GLOBAL; } |
1304 | 1305 |
//; |
1305 | 1306 |
|
1306 |
-select_param : ID { |
|
1307 |
+select_param : ID { |
|
1307 | 1308 |
if (sel.n >= MAX_SELECT_PARAMS-1) { |
1308 | 1309 |
yyerror("Select identifier too long\n"); |
1309 | 1310 |
} |
1310 |
- sel.params[sel.n].type = SEL_PARAM_STR; |
|
1311 |
+ sel.params[sel.n].type = SEL_PARAM_STR; |
|
1311 | 1312 |
sel.params[sel.n].v.s.s = $1; |
1312 | 1313 |
sel.params[sel.n].v.s.len = strlen($1); |
1313 | 1314 |
sel.n++; |
... | ... |
@@ -1340,40 +1341,40 @@ select_id : SELECT_MARK { sel.n = 0; sel.f = 0; } select_params { |
1340 | 1341 |
} |
1341 | 1342 |
; |
1342 | 1343 |
|
1343 |
-attr_class_spec: ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; } |
|
1344 |
- |ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; } |
|
1345 |
- |ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; } |
|
1346 |
- |ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; } |
|
1347 |
- |ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; } |
|
1344 |
+attr_class_spec: ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; } |
|
1345 |
+ |ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; } |
|
1346 |
+ |ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; } |
|
1347 |
+ |ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; } |
|
1348 |
+ |ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; } |
|
1348 | 1349 |
|
1349 | 1350 |
attr_name_spec : ID { s_attr->type |= AVP_NAME_STR; s_attr->name.s.s = $1; s_attr->name.s.len = strlen ($1); } |
1350 | 1351 |
; |
1351 |
- |
|
1352 |
+ |
|
1352 | 1353 |
attr_spec : attr_name_spec | |
1353 | 1354 |
attr_class_spec DOT attr_name_spec |
1354 | 1355 |
; |
1355 | 1356 |
|
1356 |
-attr_mark : ATTR_MARK |
|
1357 |
+attr_mark : ATTR_MARK |
|
1357 | 1358 |
{ s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec)); |
1358 | 1359 |
if (!s_attr) { yyerror("No memory left"); } |
1359 |
- s_attr->type = 0; |
|
1360 |
+ s_attr->type = 0; |
|
1360 | 1361 |
} |
1361 | 1362 |
; |
1362 | 1363 |
|
1363 |
-attr_id : attr_mark attr_spec { $$ = s_attr; } |
|
1364 |
+attr_id : attr_mark attr_spec { $$ = s_attr; } |
|
1364 | 1365 |
; |
1365 | 1366 |
|
1366 | 1367 |
attr_id_num_idx : attr_mark attr_spec LBRACK NUMBER RBRACK |
1367 |
- { s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD)); |
|
1368 |
+ { s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD)); |
|
1368 | 1369 |
s_attr->index = ($4<0?-$4:$4); |
1369 |
- $$ = s_attr; |
|
1370 |
- } |
|
1370 |
+ $$ = s_attr; |
|
1371 |
+ } |
|
1371 | 1372 |
; |
1372 | 1373 |
|
1373 | 1374 |
attr_id_no_idx : attr_mark attr_spec LBRACK RBRACK |
1374 |
- { s_attr->type|= AVP_INDEX_ALL; |
|
1375 |
+ { s_attr->type|= AVP_INDEX_ALL; |
|
1375 | 1376 |
$$ = s_attr; |
1376 |
- } |
|
1377 |
+ } |
|
1377 | 1378 |
; |
1378 | 1379 |
|
1379 | 1380 |
attr_id_ass : attr_id | attr_id_no_idx |
... | ... |
@@ -1441,8 +1442,8 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1441 | 1442 |
0, |
1442 | 1443 |
0); |
1443 | 1444 |
} |
1444 |
- |
|
1445 |
- |
|
1445 |
+ |
|
1446 |
+ |
|
1446 | 1447 |
| FORWARD LPAREN URIHOST COMMA NUMBER RPAREN { |
1447 | 1448 |
$$=mk_action(FORWARD_T, |
1448 | 1449 |
URIHOST_ST, |
... | ... |
@@ -1506,8 +1507,8 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1506 | 1507 |
0, |
1507 | 1508 |
0); |
1508 | 1509 |
} |
1509 |
- |
|
1510 |
- |
|
1510 |
+ |
|
1511 |
+ |
|
1511 | 1512 |
| FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN { |
1512 | 1513 |
$$=mk_action(FORWARD_UDP_T, |
1513 | 1514 |
URIHOST_ST, |
... | ... |
@@ -1570,8 +1571,8 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1570 | 1571 |
0, |
1571 | 1572 |
0); |
1572 | 1573 |
} |
1573 |
- |
|
1574 |
- |
|
1574 |
+ |
|
1575 |
+ |
|
1575 | 1576 |
| FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN { |
1576 | 1577 |
$$=mk_action(FORWARD_TCP_T, |
1577 | 1578 |
URIHOST_ST, |
... | ... |
@@ -1615,7 +1616,7 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1615 | 1616 |
"compiled in"); |
1616 | 1617 |
#endif |
1617 | 1618 |
} |
1618 |
- | FORWARD_TLS LPAREN ip RPAREN { |
|
1619 |
+ | FORWARD_TLS LPAREN ip RPAREN { |
|
1619 | 1620 |
#ifdef USE_TLS |
1620 | 1621 |
$$=mk_action( FORWARD_TLS_T, |
1621 | 1622 |
IP_ST, |
... | ... |
@@ -1628,7 +1629,7 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1628 | 1629 |
"compiled in"); |
1629 | 1630 |
#endif |
1630 | 1631 |
} |
1631 |
- | FORWARD_TLS LPAREN host COMMA NUMBER RPAREN { |
|
1632 |
+ | FORWARD_TLS LPAREN host COMMA NUMBER RPAREN { |
|
1632 | 1633 |
#ifdef USE_TLS |
1633 | 1634 |
$$=mk_action( FORWARD_TLS_T, |
1634 | 1635 |
STRING_ST, |
... | ... |
@@ -1680,8 +1681,8 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1680 | 1681 |
"compiled in"); |
1681 | 1682 |
#endif |
1682 | 1683 |
} |
1683 |
- |
|
1684 |
- |
|
1684 |
+ |
|
1685 |
+ |
|
1685 | 1686 |
| FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN { |
1686 | 1687 |
#ifdef USE_TLS |
1687 | 1688 |
$$=mk_action( FORWARD_TLS_T, |
... | ... |
@@ -1711,7 +1712,7 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1711 | 1712 |
| FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); } |
1712 | 1713 |
| FORWARD_TLS LPAREN error RPAREN { $$=0; yyerror("bad forward_tls" |
1713 | 1714 |
"argument"); } |
1714 |
- |
|
1715 |
+ |
|
1715 | 1716 |
| SEND LPAREN host RPAREN { $$=mk_action( SEND_T, |
1716 | 1717 |
STRING_ST, |
1717 | 1718 |
NUMBER_ST, |
... | ... |
@@ -1802,17 +1803,17 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1802 | 1803 |
0, (void*)EXIT_R_F); } |
1803 | 1804 |
| RETURN {$$=mk_action(DROP_T,0, 0, |
1804 | 1805 |
(void*)1, (void*)RETURN_R_F); } |
1805 |
- | RETURN NUMBER {$$=mk_action(DROP_T,0, 0, |
|
1806 |
+ | RETURN NUMBER {$$=mk_action(DROP_T,0, 0, |
|
1806 | 1807 |
(void*)$2, (void*)RETURN_R_F);} |
1807 |
- | RETURN RETCODE {$$=mk_action(DROP_T, RETCODE_ST, 0, |
|
1808 |
+ | RETURN RETCODE {$$=mk_action(DROP_T, RETCODE_ST, 0, |
|
1808 | 1809 |
0, (void*)RETURN_R_F);} |
1809 | 1810 |
| BREAK {$$=mk_action(DROP_T,0, 0, |
1810 | 1811 |
0, (void*)RETURN_R_F); } |
1811 |
- | LOG_TOK LPAREN STRING RPAREN {$$=mk_action( LOG_T, NUMBER_ST, |
|
1812 |
+ | LOG_TOK LPAREN STRING RPAREN {$$=mk_action( LOG_T, NUMBER_ST, |
|
1812 | 1813 |
STRING_ST,(void*)4,$3); |
1813 | 1814 |
} |
1814 | 1815 |
| LOG_TOK LPAREN NUMBER COMMA STRING RPAREN {$$=mk_action( LOG_T, |
1815 |
- NUMBER_ST, |
|
1816 |
+ NUMBER_ST, |
|
1816 | 1817 |
STRING_ST, |
1817 | 1818 |
(void*)$3, |
1818 | 1819 |
$5); |
... | ... |
@@ -1830,7 +1831,7 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1830 | 1831 |
(void *)$3, 0 ); } |
1831 | 1832 |
| ISFLAGSET error { $$=0; yyerror("missing '(' or ')'?"); } |
1832 | 1833 |
| ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T, |
1833 |
- STRING_ST, |
|
1834 |
+ STRING_ST, |
|
1834 | 1835 |
STRING_ST, |
1835 | 1836 |
$3, |
1836 | 1837 |
$5); |
... | ... |
@@ -1858,7 +1859,7 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1858 | 1859 |
| PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); } |
1859 | 1860 |
| PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, " |
1860 | 1861 |
"string expected"); } |
1861 |
- | STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, |
|
1862 |
+ | STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, |
|
1862 | 1863 |
NUMBER_ST, 0, (void *) $3, 0); } |
1863 | 1864 |
| STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); } |
1864 | 1865 |
| STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, " |
... | ... |
@@ -1869,22 +1870,22 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1869 | 1870 |
| STRIP error { $$=0; yyerror("missing '(' or ')' ?"); } |
1870 | 1871 |
| STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, " |
1871 | 1872 |
"number expected"); } |
1872 |
- | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN { |
|
1873 |
+ | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN { |
|
1873 | 1874 |
{ qvalue_t q; |
1874 | 1875 |
if (str2q(&q, $5, strlen($5)) < 0) { |
1875 | 1876 |
yyerror("bad argument, q value expected"); |
1876 | 1877 |
} |
1877 |
- $$=mk_action(APPEND_BRANCH_T, STRING_ST, NUMBER_ST, $3, |
|
1878 |
- (void *)(long)q); } |
|
1878 |
+ $$=mk_action(APPEND_BRANCH_T, STRING_ST, NUMBER_ST, $3, |
|
1879 |
+ (void *)(long)q); } |
|
1879 | 1880 |
} |
1880 |
- |
|
1881 |
+ |
|
1881 | 1882 |
| APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action( APPEND_BRANCH_T, |
1882 | 1883 |
STRING_ST, NUMBER_ST, $3, (void *)Q_UNSPECIFIED) ; } |
1883 | 1884 |
| APPEND_BRANCH LPAREN RPAREN { $$=mk_action( APPEND_BRANCH_T, |
1884 | 1885 |
STRING_ST, NUMBER_ST, 0, (void *)Q_UNSPECIFIED ) ; } |
1885 | 1886 |
| APPEND_BRANCH { $$=mk_action( APPEND_BRANCH_T, STRING_ST, 0, 0, 0 ) ; } |
1886 | 1887 |
|
1887 |
- | SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action( SET_HOSTPORT_T, |
|
1888 |
+ | SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action( SET_HOSTPORT_T, |
|
1888 | 1889 |
STRING_ST, 0, $3, 0); } |
1889 | 1890 |
| SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); } |
1890 | 1891 |
| SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument," |
... | ... |
@@ -1899,12 +1900,12 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1899 | 1900 |
| SET_USER error { $$=0; yyerror("missing '(' or ')' ?"); } |
1900 | 1901 |
| SET_USER LPAREN error RPAREN { $$=0; yyerror("bad argument, " |
1901 | 1902 |
"string expected"); } |
1902 |
- | SET_USERPASS LPAREN STRING RPAREN { $$=mk_action( SET_USERPASS_T, |
|
1903 |
+ | SET_USERPASS LPAREN STRING RPAREN { $$=mk_action( SET_USERPASS_T, |
|
1903 | 1904 |
STRING_ST, 0, $3, 0); } |
1904 | 1905 |
| SET_USERPASS error { $$=0; yyerror("missing '(' or ')' ?"); } |
1905 | 1906 |
| SET_USERPASS LPAREN error RPAREN { $$=0; yyerror("bad argument, " |
1906 | 1907 |
"string expected"); } |
1907 |
- | SET_URI LPAREN STRING RPAREN { $$=mk_action( SET_URI_T, STRING_ST, |
|
1908 |
+ | SET_URI LPAREN STRING RPAREN { $$=mk_action( SET_URI_T, STRING_ST, |
|
1908 | 1909 |
0, $3, 0); } |
1909 | 1910 |
| SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); } |
1910 | 1911 |
| SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, " |
... | ... |
@@ -1923,7 +1924,7 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1923 | 1924 |
} |
1924 | 1925 |
| FORCE_TCP_ALIAS LPAREN RPAREN { |
1925 | 1926 |
#ifdef USE_TCP |
1926 |
- $$=mk_action(FORCE_TCP_ALIAS_T,0, 0, 0, 0); |
|
1927 |
+ $$=mk_action(FORCE_TCP_ALIAS_T,0, 0, 0, 0); |
|
1927 | 1928 |
#else |
1928 | 1929 |
yyerror("tcp support not compiled in"); |
1929 | 1930 |
#endif |
... | ... |
@@ -1935,7 +1936,7 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1935 | 1936 |
yyerror("tcp support not compiled in"); |
1936 | 1937 |
#endif |
1937 | 1938 |
} |
1938 |
- | FORCE_TCP_ALIAS LPAREN error RPAREN {$$=0; |
|
1939 |
+ | FORCE_TCP_ALIAS LPAREN error RPAREN {$$=0; |
|
1939 | 1940 |
yyerror("bad argument, number expected"); |
1940 | 1941 |
} |
1941 | 1942 |
| SET_ADV_ADDRESS LPAREN listen_id RPAREN { |
... | ... |
@@ -2017,7 +2018,7 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
2017 | 2018 |
); |
2018 | 2019 |
} |
2019 | 2020 |
} |
2020 |
- | ID LPAREN STRING COMMA STRING RPAREN |
|
2021 |
+ | ID LPAREN STRING COMMA STRING RPAREN |
|
2021 | 2022 |
{ f_tmp=(void*)find_export($1, 2, rt); |
2022 | 2023 |
if (f_tmp==0){ |
2023 | 2024 |
if (find_export($1, 2, 0)) { |
... | ... |
@@ -2049,14 +2050,14 @@ extern int column; |
2049 | 2050 |
extern int startcolumn; |
2050 | 2051 |
static void warn(char* s) |
2051 | 2052 |
{ |
2052 |
- LOG(L_WARN, "cfg. warning: (%d,%d-%d): %s\n", line, startcolumn, |
|
2053 |
+ LOG(L_WARN, "cfg. warning: (%d,%d-%d): %s\n", line, startcolumn, |
|
2053 | 2054 |
column, s); |
2054 | 2055 |
cfg_errors++; |
2055 | 2056 |
} |
2056 | 2057 |
|
2057 | 2058 |
static void yyerror(char* s) |
2058 | 2059 |
{ |
2059 |
- LOG(L_CRIT, "parse error (%d,%d-%d): %s\n", line, startcolumn, |
|
2060 |
+ LOG(L_CRIT, "parse error (%d,%d-%d): %s\n", line, startcolumn, |
|
2060 | 2061 |
column, s); |
2061 | 2062 |
cfg_errors++; |
2062 | 2063 |
} |
... | ... |
@@ -272,9 +272,10 @@ typedef struct param_export_ param_export_t; |
272 | 272 |
<simpara><varname>modparam_t type</varname></simpara> |
273 | 273 |
<simpara> |
274 | 274 |
Type of the parameter. Currently only two types are |
275 |
- defined. INT_PARAM for integer parameters (corresponding |
|
276 |
- variable must be of type int) and STR_PARAM for string |
|
277 |
- parameters (corresponding variable must be of type char*). |
|
275 |
+ defined. PARAM_INT for integer parameters (corresponding |
|
276 |
+ variable must be of type int), PARAM_STR for str parameters |
|
277 |
+ (corresponding variable must be of type char*) and PARAM_STRING |
|
278 |
+ for string parameters (corresponding variable must be of type char*). |
|
278 | 279 |
</simpara> |
279 | 280 |
</listitem> |
280 | 281 |
<listitem> |
... | ... |
@@ -436,10 +437,12 @@ static cmd_export cmds[] = { |
436 | 437 |
<programlisting> |
437 | 438 |
int foo_bar = 0; |
438 | 439 |
char* bar_foo = "default value"; |
440 |
+str bar_bar = STR_STATIC_INIT("default"); |
|
439 | 441 |
|
440 | 442 |
static param_export params[] = { |
441 |
- {"foo_bar", INT_PARAM, &foo_bar}, |
|
442 |
- {"bar_foo", STR_PARAM, bar_foo }, |
|
443 |
+ {"foo_bar", PARAM_INT, &foo_bar}, |
|
444 |
+ {"bar_foo", PARAM_STRING, &bar_foo}, |
|
445 |
+ {"bar_bar", PARAM_STR, &bar_bar.s}, |
|
443 | 446 |
{0, 0, 0} |
444 | 447 |
}; |
445 | 448 |
</programlisting> |
... | ... |
@@ -172,8 +172,8 @@ struct module_exports{ |
172 | 172 |
<listitem> |
173 | 173 |
<para> |
174 | 174 |
<structfield>param_types</structfield> - Array of types of |
175 |
- parameters, each field of the array can be either STR_PARAM or |
|
176 |
- INT_PARAM (currently only two parameter types are defined). |
|
175 |
+ parameters, each field of the array can be either PARAM_STR/PARAM_STRING or |
|
176 |
+ PARAM_INT (currently only three parameter types are defined). |
|
177 | 177 |
</para> |
178 | 178 |
</listitem> |
179 | 179 |
<listitem> |
... | ... |
@@ -444,14 +444,14 @@ module_stm = "loadmodule" STRING |
444 | 444 |
| "loadmodule" error { yyerror("string expected"); } |
445 | 445 |
| "modparam" "(" STRING "," STRING "," STRING ")" |
446 | 446 |
{ |
447 |
- if (set_mod_param($3, $5, STR_PARAM, $7) != 0) { |
|
447 |
+ if (set_mod_param($3, $5, PARAM_STR|PARAM_STRING, $7) != 0) { |
|
448 | 448 |
yyerror("Can't set module parameter"); |
449 | 449 |
} |
450 | 450 |
} |
451 | 451 |
|
452 | 452 |
| "modparam" "(" STRING "," STRING "," NUMBER ")" |
453 | 453 |
{ |
454 |
- if (set_mod_param($3, $5, INT_PARAM, (void*)$7) != 0) { |
|
454 |
+ if (set_mod_param($3, $5, PARAM_INT, (void*)$7) != 0) { |
|
455 | 455 |
yyerror("Can't set module parameter"); |
456 | 456 |
} |
457 | 457 |
} |
... | ... |
@@ -21,8 +21,8 @@ |
21 | 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | 22 |
* GNU General Public License for more details. |
23 | 23 |
* |
24 |
- * You should have received a copy of the GNU General Public License |
|
25 |
- * along with this program; if not, write to the Free Software |
|
24 |
+ * You should have received a copy of the GNU General Public License |
|
25 |
+ * along with this program; if not, write to the Free Software |
|
26 | 26 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
27 | 27 |
* |
28 | 28 |
* History: |
... | ... |
@@ -30,6 +30,7 @@ |
30 | 30 |
* 2003-03-20 regex support in modparam (janakj) |
31 | 31 |
* 2004-03-12 extra flag USE_FUNC_PARAM added to modparam type - |
32 | 32 |
* instead of copying the param value, a func is called (bogdan) |
33 |
+ * 2005-07-01 PARAM_STRING & PARAM_STR support |
|
33 | 34 |
*/ |
34 | 35 |
|
35 | 36 |
|
... | ... |
@@ -44,7 +45,8 @@ |
44 | 45 |
int set_mod_param(char* _mod, char* _name, modparam_t _type, void* _val) |
45 | 46 |
{ |
46 | 47 |
void* ptr; |
47 |
- |
|
48 |
+ modparam_t param_type; |
|
49 |
+ |
|
48 | 50 |
if (!_mod) { |
49 | 51 |
LOG(L_ERR, "set_mod_param(): Invalid _mod parameter value\n"); |
50 | 52 |
return -1; |
... | ... |
@@ -55,22 +57,34 @@ int set_mod_param(char* _mod, char* _name, modparam_t _type, void* _val) |
55 | 57 |
return -2; |
56 | 58 |
} |
57 | 59 |
|
58 |
- ptr = find_param_export(_mod, _name, _type); |
|
60 |
+ |
|
61 |
+ ptr = find_param_export(find_module_by_name(_mod), _name, _type, ¶m_type); |
|
59 | 62 |
if (!ptr) { |
60 | 63 |
LOG(L_ERR, "set_mod_param(): Parameter not found\n"); |
61 | 64 |
return -3; |
62 | 65 |
} |
63 | 66 |
|
64 |
- switch(_type) { |
|
65 |
- case STR_PARAM: |
|
66 |
- *((char**)ptr) = strdup((char*)_val); |
|
67 |
- break; |
|
68 |
- |
|
69 |
- case INT_PARAM: |
|
70 |
- *((int*)ptr) = (int)(long)_val; |
|
71 |
- break; |
|
67 |
+ if (param_type & PARAM_USE_FUNC) { |
|
68 |
+ if ( ((param_func_t)(ptr))(param_type, _val) < 0) { |
|
69 |
+ return -4; |
|
70 |
+ } |
|
71 |
+ } |
|
72 |
+ else { |
|
73 |
+ switch(PARAM_TYPE_MASK(param_type)) { |
|
74 |
+ case PARAM_STRING: |
|
75 |
+ *((char**)ptr) = strdup((char*)_val); |
|
76 |
+ break; |
|
77 |
+ |
|
78 |
+ case PARAM_STR: |
|
79 |
+ ((str*)ptr)->s = strdup((char*)_val); |
|
80 |
+ ((str*)ptr)->len = strlen(((str*)ptr)->s); |
|
81 |
+ break; |
|
82 |
+ |
|
83 |
+ case PARAM_INT: |
|
84 |
+ *((int*)ptr) = (int)(long)_val; |
|
85 |
+ break; |
|
86 |
+ } |
|
72 | 87 |
} |
73 |
- |
|
74 | 88 |
return 0; |
75 | 89 |
} |
76 | 90 |
|
... | ... |
@@ -78,11 +92,11 @@ int set_mod_param(char* _mod, char* _name, modparam_t _type, void* _val) |
78 | 92 |
int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val) |
79 | 93 |
{ |
80 | 94 |
struct sr_module* t; |
81 |
- param_export_t* param; |
|
82 | 95 |
regex_t preg; |
83 | 96 |
int mod_found, len; |
84 | 97 |
char* reg; |
85 |
- int n; |
|
98 |
+ void *ptr; |
|
99 |
+ modparam_t param_type; |
|
86 | 100 |
|
87 | 101 |
len = strlen(regex); |
88 | 102 |
reg = pkg_malloc(len + 2 + 1); |
... | ... |
@@ -94,47 +108,46 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val) |
94 | 108 |
memcpy(reg + 1, regex, len); |
95 | 109 |
reg[len + 1] = '$'; |
96 | 110 |
reg[len + 2] = '\0'; |
97 |
- |
|
111 |
+ |
|
98 | 112 |
if (regcomp(&preg, reg, REG_EXTENDED | REG_NOSUB | REG_ICASE)) { |
99 | 113 |
LOG(L_ERR, "set_mod_param_regex(): Error while compiling regular expression\n"); |
100 | 114 |
pkg_free(reg); |
101 | 115 |
return -2; |
102 | 116 |
} |
103 |
- |
|
104 |
- mod_found = 0; |
|
105 | 117 |
|
118 |
+ mod_found = 0; |
|
106 | 119 |
for(t = modules; t; t = t->next) { |
107 | 120 |
if (regexec(&preg, t->exports->name, 0, 0, 0) == 0) { |
108 |
- DBG("set_mod_param_regex: %s matches module %s\n", |
|
109 |
- regex, t->exports->name); |
|
121 |
+ DBG("set_mod_param_regex: '%s' matches module '%s'\n", regex, t->exports->name); |
|
110 | 122 |
mod_found = 1; |
111 |
- for(param=t->exports->params;param && param->name ; param++) { |
|
112 |
- if ((strcmp(name, param->name) == 0) && |
|
113 |
- ( PARAM_TYPE_MASK(param->type) == type)) { |
|
114 |
- DBG("set_mod_param_regex: found <%s> in module %s [%s]\n", |
|
115 |
- name, t->exports->name, t->path); |
|
116 |
- |
|
117 |
- if (param->type&USE_FUNC_PARAM) { |
|
118 |
- n = ((param_func_t)(param->param_pointer))(type, val ); |
|
119 |
- if (n<0) |
|
120 |
- return -4; |
|
121 |
- } else { |
|
122 |
- switch(type) { |
|
123 |
- case STR_PARAM: |
|
124 |
- *((char**)(param->param_pointer)) = |
|
125 |
- strdup((char*)val); |
|
126 |
- break; |
|
127 |
- case INT_PARAM: |
|
128 |
- *((int*)(param->param_pointer)) = |
|
129 |
- (int)(long)val; |
|
130 |
- break; |
|
131 |
- } |
|
123 |
+ ptr = find_param_export(t, name, type, ¶m_type); |
|
124 |
+ if (ptr) { |
|
125 |
+ DBG("set_mod_param_regex: found <%s> in module %s [%s]\n", name, t->exports->name, t->path); |
|
126 |
+ if (param_type & PARAM_USE_FUNC) { |
|
127 |
+ if ( ((param_func_t)(ptr))(param_type, val) < 0) { |
|
128 |
+ regfree(&preg); |
|
129 |
+ pkg_free(reg); |
|
130 |
+ return -4; |
|
131 |
+ } |
|
132 |
+ } |
|
133 |
+ else { |
|
134 |
+ switch(PARAM_TYPE_MASK(param_type)) { |
|
135 |
+ case PARAM_STRING: |
|
136 |
+ *((char**)ptr) = strdup((char*)val); |
|
137 |
+ break; |
|
138 |
+ |
|
139 |
+ case PARAM_STR: |
|
140 |
+ ((str*)ptr)->s = strdup((char*)val); |
|
141 |
+ ((str*)ptr)->len = strlen(((str*)ptr)->s); |
|
142 |
+ break; |
|
143 |
+ |
|
144 |
+ case PARAM_INT: |
|
145 |
+ *((int*)ptr) = (int)(long)val; |
|
146 |
+ break; |
|
132 | 147 |
} |
133 |
- |
|
134 |
- break; |
|
135 | 148 |
} |
136 | 149 |
} |
137 |
- if (!param || !param->name) { |
|
150 |
+ else { |
|
138 | 151 |
LOG(L_ERR, "set_mod_param_regex: parameter <%s> not found in module <%s>\n", |
139 | 152 |
name, t->exports->name); |
140 | 153 |
regfree(&preg); |
... | ... |
@@ -145,12 +158,10 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val) |
145 | 158 |
} |
146 | 159 |
|
147 | 160 |
regfree(&preg); |
161 |
+ pkg_free(reg); |
|
148 | 162 |
if (!mod_found) { |
149 |
- LOG(L_ERR, "set_mod_param_regex: No module matching %s found\n|", regex); |
|
150 |
- pkg_free(reg); |
|
163 |
+ LOG(L_ERR, "set_mod_param_regex: No module matching <%s> found\n", regex); |
|
151 | 164 |
return -4; |
152 | 165 |
} |
153 |
- |
|
154 |
- pkg_free(reg); |
|
155 | 166 |
return 0; |
156 | 167 |
} |
... | ... |
@@ -19,8 +19,8 @@ |
19 | 19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | 20 |
* GNU General Public License for more details. |
21 | 21 |
* |
22 |
- * You should have received a copy of the GNU General Public License |
|
23 |
- * along with this program; if not, write to the Free Software |
|
22 |
+ * You should have received a copy of the GNU General Public License |
|
23 |
+ * along with this program; if not, write to the Free Software |
|
24 | 24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
25 | 25 |
*/ |
26 | 26 |
/* |
... | ... |
@@ -87,12 +87,12 @@ int register_builtin_modules() |
87 | 87 |
|
88 | 88 |
ret=0; |
89 | 89 |
#ifdef STATIC_TM |
90 |
- ret=register_module(tm_exports,"built-in", 0); |
|
90 |
+ ret=register_module(tm_exports,"built-in", 0); |
|
91 | 91 |
if (ret<0) return ret; |
92 | 92 |
#endif |
93 | 93 |
|
94 | 94 |
#ifdef STATIC_EXEC |
95 |
- ret=register_module(exec_exports,"built-in", 0); |
|
95 |
+ ret=register_module(exec_exports,"built-in", 0); |
|
96 | 96 |
if (ret<0) return ret; |
97 | 97 |
#endif |
98 | 98 |
|
... | ... |
@@ -102,15 +102,15 @@ int register_builtin_modules() |
102 | 102 |
#endif |
103 | 103 |
|
104 | 104 |
#ifdef STATIC_AUTH |
105 |
- ret=register_module(auth_exports, "built-in", 0); |
|
105 |
+ ret=register_module(auth_exports, "built-in", 0); |
|
106 | 106 |
if (ret<0) return ret; |
107 | 107 |
#endif |
108 |
- |
|
108 |
+ |
|
109 | 109 |
#ifdef STATIC_RR |
110 | 110 |
ret=register_module(rr_exports, "built-in", 0); |
111 | 111 |
if (ret<0) return ret; |
112 | 112 |
#endif |
113 |
- |
|
113 |
+ |
|
114 | 114 |
#ifdef STATIC_USRLOC |
115 | 115 |
ret=register_module(usrloc_exports, "built-in", 0); |
116 | 116 |
if (ret<0) return ret; |
... | ... |
@@ -120,7 +120,7 @@ int register_builtin_modules() |
120 | 120 |
ret=register_module(sl_exports, "built-in", 0); |
121 | 121 |
if (ret<0) return ret; |
122 | 122 |
#endif |
123 |
- |
|
123 |
+ |
|
124 | 124 |
return ret; |
125 | 125 |
} |
126 | 126 |
|
... | ... |
@@ -132,7 +132,7 @@ int register_module(struct module_exports* e, char* path, void* handle) |
132 | 132 |
{ |
133 | 133 |
int ret; |
134 | 134 |
struct sr_module* mod; |
135 |
- |
|
135 |
+ |
|
136 | 136 |
ret=-1; |
137 | 137 |
|
138 | 138 |
/* add module to the list */ |
... | ... |
@@ -183,7 +183,7 @@ static inline int version_control(void *handle, char *path) |
183 | 183 |
LOG(L_ERR, "ERROR: no compile flags in module <%s>\n", path ); |
184 | 184 |
return 0; |
185 | 185 |
} |
186 |
- |
|
186 |
+ |
|
187 | 187 |
if (strcmp(SER_FULL_VERSION, *m_ver)==0){ |
188 | 188 |
if (strcmp(SER_COMPILE_FLAGS, *m_flags)==0) |
189 | 189 |
return 1; |
... | ... |
@@ -206,7 +206,7 @@ int load_module(char* path) |
206 | 206 |
char* error; |
207 | 207 |
struct module_exports* exp; |
208 | 208 |
struct sr_module* t; |
209 |
- |
|
209 |
+ |
|
210 | 210 |
#ifndef RTLD_NOW |
211 | 211 |
/* for openbsd */ |
212 | 212 |
#define RTLD_NOW DL_LAZY |
... | ... |
@@ -217,7 +217,7 @@ int load_module(char* path) |
217 | 217 |
path, dlerror() ); |
218 | 218 |
goto error; |
219 | 219 |
} |
220 |
- |
|
220 |
+ |
|
221 | 221 |
for(t=modules;t; t=t->next){ |
222 | 222 |
if (t->handle==handle){ |
223 | 223 |
LOG(L_WARN, "WARNING: load_module: attempting to load the same" |
... | ... |
@@ -248,7 +248,7 @@ skip: |
248 | 248 |
|
249 | 249 |
|
250 | 250 |
/* searches the module list and returns pointer to the "name" function or |
251 |
- * 0 if not found |
|
251 |
+ * 0 if not found |
|
252 | 252 |
* flags parameter is OR value of all flags that must match |
253 | 253 |
*/ |
254 | 254 |
cmd_function find_export(char* name, int param_no, int flags) |
... | ... |
@@ -327,32 +327,41 @@ cmd_function find_mod_export(char* mod, char* name, int param_no, int flags) |
327 | 327 |
} |
328 | 328 |
} |
329 | 329 |
|
330 |
- DBG("find_mod_export: <%s> in module %s not found\n", name, mod); |
|
330 |
+ DBG("find_mod_export: <%s> in module <%s> not found\n", name, mod); |
|
331 | 331 |
return 0; |
332 | 332 |
} |
333 | 333 |
|
334 | 334 |
|
335 |
+struct sr_module* find_module_by_name(char* mod) { |
|
336 |
+ struct sr_module* t; |
|
337 |
+ |
|
338 |
+ for(t = modules; t; t = t->next) { |
|
339 |
+ if (strcmp(mod, t->exports->name) == 0) { |
|
340 |
+ return t; |
|
341 |
+ } |
|
342 |
+ } |
|
343 |
+ DBG("find_module_by_name: module <%s> not found\n", mod); |
|
344 |
+ return 0; |
|
345 |
+} |
|
335 | 346 |
|
336 | 347 |
|
337 |
-void* find_param_export(char* mod, char* name, modparam_t type) |
|
348 |
+void* find_param_export(struct sr_module* mod, char* name, modparam_t type_mask, modparam_t *param_type) |
|
338 | 349 |
{ |
339 |
- struct sr_module* t; |
|
340 | 350 |
param_export_t* param; |
341 | 351 |
|
342 |
- for(t = modules; t; t = t->next) { |
|
343 |
- if (strcmp(mod, t->exports->name) == 0) { |
|
344 |
- for(param=t->exports->params;param && param->name ; param++) { |
|
345 |
- if ((strcmp(name, param->name) == 0) && |
|
346 |
- (param->type == type)) { |
|
347 |
- DBG("find_param_export: found <%s> in module %s [%s]\n", |
|
348 |
- name, t->exports->name, t->path); |
|
349 |
- return param->param_pointer; |
|
350 |
- } |
|
351 |
- } |
|
352 |
+ if (!mod) |
|
353 |
+ return 0; |
|
354 |
+ for(param=mod->exports->params;param && param->name ; param++) { |
|
355 |
+ if ((strcmp(name, param->name) == 0) && |
|
356 |
+ ((param->type & PARAM_TYPE_MASK(type_mask)) != 0)) { |
|
357 |
+ DBG("find_param_export: found <%s> in module %s [%s]\n", |
|
358 |
+ name, mod->exports->name, mod->path); |
|
359 |
+ *param_type = param->type; |
|
360 |
+ return param->param_pointer; |
|
352 | 361 |
} |
353 | 362 |
} |
354 |
- DBG("find_param_export: parameter <%s> or module <%s> not found\n", |
|
355 |
- name, mod); |
|
363 |
+ DBG("find_param_export: parameter <%s> not found in module <%s>\n", |
|
364 |
+ name, mod->exports->name); |
|
356 | 365 |
return 0; |
357 | 366 |
} |
358 | 367 |
|
... | ... |
@@ -364,9 +373,9 @@ struct sr_module* find_module(void* f, cmd_export_t **c) |
364 | 373 |
{ |
365 | 374 |
struct sr_module* t; |
366 | 375 |
cmd_export_t* cmd; |
367 |
- |
|
376 |
+ |
|
368 | 377 |
for (t=modules;t;t=t->next){ |
369 |
- for(cmd=t->exports->cmds; cmd && cmd->name; cmd++) |
|
378 |
+ for(cmd=t->exports->cmds; cmd && cmd->name; cmd++) |
|
370 | 379 |
if (f==(void*)cmd->function) { |
371 | 380 |
if (c) *c=cmd; |
372 | 381 |
return t; |
... | ... |
@@ -400,7 +409,7 @@ void destroy_modules() |
400 | 409 |
int init_modules(void) |
401 | 410 |
{ |
402 | 411 |
struct sr_module* t; |
403 |
- |
|
412 |
+ |
|
404 | 413 |
for(t = modules; t; t = t->next) { |
405 | 414 |
if ((t->exports) && (t->exports->init_f)) |
406 | 415 |
if (t->exports->init_f() != 0) { |
... | ... |
@@ -428,7 +437,7 @@ int init_child(int rank) |
428 | 437 |
default: type = "CHILD"; break; |
429 | 438 |
} |
430 | 439 |
DBG("init_child: initializing %s with rank %d\n", type, rank); |
431 |
- |
|
440 |
+ |
|
432 | 441 |
|
433 | 442 |
for(t = modules; t; t = t->next) { |
434 | 443 |
if (t->exports->init_child_f) { |
... | ... |
@@ -458,7 +467,7 @@ static int init_mod_child( struct sr_module* m, int rank ) |
458 | 467 |
*/ |
459 | 468 |
if (init_mod_child(m->next, rank)!=0) return -1; |
460 | 469 |
if (m->exports && m->exports->init_child_f) { |
461 |
- DBG("DEBUG: init_mod_child (%d): %s\n", |
|
470 |
+ DBG("DEBUG: init_mod_child (%d): %s\n", |
|
462 | 471 |
rank, m->exports->name); |
463 | 472 |
if (m->exports->init_child_f(rank)<0) { |
464 | 473 |
LOG(L_ERR, "init_mod_child(): Error while initializing" |
... | ... |
@@ -538,13 +547,13 @@ int init_modules(void) |
538 | 547 |
int fixup_str_12(void** param, int param_no) |
539 | 548 |
{ |
540 | 549 |
str* s; |
541 |
- |
|
550 |
+ |
|
542 | 551 |
s = (str*)pkg_malloc(sizeof(str)); |
543 | 552 |
if (!s) { |
544 | 553 |
LOG(L_ERR, "fixup_str_12: No memory left\n"); |
545 | 554 |
return E_UNSPEC; |
546 | 555 |
} |
547 |
- |
|
556 |
+ |
|
548 | 557 |
s->s = (char*)*param; |
549 | 558 |
s->len = strlen(s->s); |
550 | 559 |
*param = (void*)s; |
... | ... |
@@ -578,7 +587,7 @@ int fixup_int_12(void** param, int param_no) |
578 | 587 |
int err; |
579 | 588 |
|
580 | 589 |
num = str2s(*param, strlen(*param), &err); |
581 |
- |
|
590 |
+ |
|
582 | 591 |
if (err == 0) { |
583 | 592 |
pkg_free(*param); |
584 | 593 |
*param=(void*)num; |
... | ... |
@@ -607,7 +616,7 @@ int fixup_int_2(void** param, int param_no) |
607 | 616 |
if (param_no == 2) { |
608 | 617 |
return fixup_int_12(param, param_no); |
609 | 618 |
} |
610 |
- |
|
619 |
+ |
|
611 | 620 |
return 0; |
612 | 621 |
} |
613 | 622 |
|
... | ... |
@@ -22,8 +22,8 @@ |
22 | 22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | 23 |
* GNU General Public License for more details. |
24 | 24 |
* |
25 |
- * You should have received a copy of the GNU General Public License |
|
26 |
- * along with this program; if not, write to the Free Software |
|
25 |
+ * You should have received a copy of the GNU General Public License |
|
26 |
+ * along with this program; if not, write to the Free Software |
|
27 | 27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 | 28 |
*/ |
29 | 29 |
/* |
... | ... |
@@ -58,10 +58,16 @@ typedef int (*init_function)(void); |
58 | 58 |
typedef int (*child_init_function)(int rank); |
59 | 59 |
|
60 | 60 |
|
61 |
-#define STR_PARAM (1U<<0) /* String parameter type */ |
|
62 |
-#define INT_PARAM (1U<<1) /* Integer parameter type */ |
|
63 |
-#define USE_FUNC_PARAM (1U<<(8*sizeof(int)-1)) |
|
64 |
-#define PARAM_TYPE_MASK(_x) ((_x)&(~USE_FUNC_PARAM)) |
|
61 |
+#define PARAM_STRING (1U<<0) /* String (char *) parameter type */ |
|
62 |
+#define PARAM_INT (1U<<1) /* Integer parameter type */ |
|
63 |
+#define PARAM_STR (1U<<2) /* struct str parameter type */ |
|
64 |
+#define PARAM_USE_FUNC (1U<<(8*sizeof(int)-1)) |
|
65 |
+#define PARAM_TYPE_MASK(_x) ((_x)&(~PARAM_USE_FUNC)) |
|
66 |
+ |
|
67 |
+/* temporary, for backward compatibility only until all modules adjust it */ |
|
68 |
+#define STR_PARAM PARAM_STRING |
|
69 |
+#define INT_PARAM PARAM_INT |
|
70 |
+#define USE_FUNC_PARAM PARAM_USE_FUNC |
|
65 | 71 |
|
66 | 72 |
typedef unsigned int modparam_t; |
67 | 73 |
|
... | ... |
@@ -108,7 +114,7 @@ typedef struct param_export_ param_export_t; |
108 | 114 |
|
109 | 115 |
struct module_exports{ |
110 | 116 |
char* name; /* null terminated module name */ |
111 |
- |
|
117 |
+ |
|
112 | 118 |
cmd_export_t* cmds; /* null terminated array of the exported |
113 | 119 |
commands */ |
114 | 120 |
rpc_export_t* rpc_methods; /* null terminated array of exported rpc methods */ |
... | ... |
@@ -150,13 +156,14 @@ struct sr_module* find_module(void *f, cmd_export_t** cmd); |
150 | 156 |
void destroy_modules(); |
151 | 157 |
int init_child(int rank); |
152 | 158 |
int init_modules(void); |
159 |
+struct sr_module* find_module_by_name(char* mod); |
|
153 | 160 |
|
154 | 161 |
/* |
155 | 162 |
* Find a parameter with given type and return it's |
156 | 163 |
* address in memory |
157 | 164 |
* If there is no such parameter, NULL is returned |
158 | 165 |
*/ |
159 |
-void* find_param_export(char* mod, char* name, modparam_t type); |
|
166 |
+void* find_param_export(struct sr_module* mod, char* name, modparam_t type_mask, modparam_t *param_type); |
|
160 | 167 |
|
161 | 168 |
/* modules function prototypes: |
162 | 169 |
* struct module_exports* mod_register(); (type module_register) |