... | ... |
@@ -33,6 +33,7 @@ |
33 | 33 |
* replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei) |
34 | 34 |
* 2003-04-01 Added support for loose routing in forward (janakj) |
35 | 35 |
* 2003-04-12 FORCE_RPORT_T added (andrei) |
36 |
+ * 2003-04-22 strip_tail added (jiri) |
|
36 | 37 |
*/ |
37 | 38 |
|
38 | 39 |
|
... | ... |
@@ -376,8 +377,9 @@ int do_action(struct action* a, struct sip_msg* msg) |
376 | 376 |
case SET_URI_T: |
377 | 377 |
case PREFIX_T: |
378 | 378 |
case STRIP_T: |
379 |
+ case STRIP_TAIL_T: |
|
379 | 380 |
user=0; |
380 |
- if (a->type==STRIP_T) { |
|
381 |
+ if (a->type==STRIP_T || a->type==STRIP_TAIL_T) { |
|
381 | 382 |
if (a->p1_type!=NUMBER_ST) { |
382 | 383 |
LOG(L_CRIT, "BUG: do_action: bad set*() type %d\n", |
383 | 384 |
a->p1_type); |
... | ... |
@@ -464,6 +466,18 @@ int do_action(struct action* a, struct sip_msg* msg) |
464 | 464 |
tmp=uri.user.s + a->p1.number; |
465 | 465 |
len=uri.user.len - a->p1.number; |
466 | 466 |
} |
467 |
+ } else if (a->type==STRIP_TAIL_T) { |
|
468 |
+ if (a->p1.number>uri.user.len) { |
|
469 |
+ LOG(L_WARN, "WARNING: too long strip_tail asked; " |
|
470 |
+ " deleting username: %d of <%.*s>\n", |
|
471 |
+ a->p1.number, uri.user.len, uri.user.s ); |
|
472 |
+ len=0; |
|
473 |
+ } else if (a->p1.number==uri.user.len) { |
|
474 |
+ len=0; |
|
475 |
+ } else { |
|
476 |
+ tmp=uri.user.s; |
|
477 |
+ len=uri.user.len - a->p1.number; |
|
478 |
+ } |
|
467 | 479 |
} else { |
468 | 480 |
tmp=uri.user.s; |
469 | 481 |
len=uri.user.len; |
... | ... |
@@ -34,6 +34,7 @@ |
34 | 34 |
* 2003-04-01 added dst_port, proto (tcp, udp, tls), af(inet, inet6) (andrei) |
35 | 35 |
* 2003-04-05 s/reply_route/failure_route, onreply_route introduced (jiri) |
36 | 36 |
* 2003-04-12 added force_rport, chdir and wdir (andrei) |
37 |
+ * 2003-04-22 strip_tail added (jiri) |
|
37 | 38 |
*/ |
38 | 39 |
|
39 | 40 |
|
... | ... |
@@ -97,6 +98,7 @@ SET_URI "rewriteuri"|"seturi" |
97 | 97 |
REVERT_URI "revert_uri" |
98 | 98 |
PREFIX "prefix" |
99 | 99 |
STRIP "strip" |
100 |
+STRIP_TAIL "strip_tail" |
|
100 | 101 |
APPEND_BRANCH "append_branch" |
101 | 102 |
IF "if" |
102 | 103 |
ELSE "else" |
... | ... |
@@ -232,6 +234,7 @@ EAT_ABLE [\ \t\b\r] |
232 | 232 |
<INITIAL>{REVERT_URI} { count(); yylval.strval=yytext; return REVERT_URI; } |
233 | 233 |
<INITIAL>{PREFIX} { count(); yylval.strval=yytext; return PREFIX; } |
234 | 234 |
<INITIAL>{STRIP} { count(); yylval.strval=yytext; return STRIP; } |
235 |
+<INITIAL>{STRIP_TAIL} { count(); yylval.strval=yytext; return STRIP_TAIL; } |
|
235 | 236 |
<INITIAL>{APPEND_BRANCH} { count(); yylval.strval=yytext; |
236 | 237 |
return APPEND_BRANCH; } |
237 | 238 |
<INITIAL>{FORCE_RPORT} { count(); yylval.strval=yytext; return FORCE_RPORT; } |
... | ... |
@@ -38,6 +38,7 @@ |
38 | 38 |
* 2003-04-05 s/reply_route/failure_route, onreply_route introduced (jiri) |
39 | 39 |
* 2003-04-12 added force_rport, chroot and wdir (andrei) |
40 | 40 |
* 2003-04-15 added tcp_children, disable_tcp (andrei) |
41 |
+ * 2003-04-22 strip_tail added (jiri) |
|
41 | 42 |
*/ |
42 | 43 |
|
43 | 44 |
|
... | ... |
@@ -116,6 +117,7 @@ int rt; /* Type of route block for find_export */ |
116 | 116 |
%token SET_HOSTPORT |
117 | 117 |
%token PREFIX |
118 | 118 |
%token STRIP |
119 |
+%token STRIP_TAIL |
|
119 | 120 |
%token APPEND_BRANCH |
120 | 121 |
%token SET_USER |
121 | 122 |
%token SET_USERPASS |
... | ... |
@@ -1056,6 +1058,12 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1056 | 1056 |
| PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); } |
1057 | 1057 |
| PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, " |
1058 | 1058 |
"string expected"); } |
1059 |
+ | STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, |
|
1060 |
+ NUMBER_ST, 0, (void *) $3, 0); } |
|
1061 |
+ | STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); } |
|
1062 |
+ | STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, " |
|
1063 |
+ "number expected"); } |
|
1064 |
+ |
|
1059 | 1065 |
| STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, NUMBER_ST, |
1060 | 1066 |
0, (void *) $3, 0); } |
1061 | 1067 |
| STRIP error { $$=0; yyerror("missing '(' or ')' ?"); } |
... | ... |
@@ -29,6 +29,7 @@ |
29 | 29 |
* -------- |
30 | 30 |
* |
31 | 31 |
* 2003-04-12 FORCE_RPORT_T added (andrei) |
32 |
+ * 2003-04-22 strip_tail added (jiri) |
|
32 | 33 |
*/ |
33 | 34 |
|
34 | 35 |
|
... | ... |
@@ -58,7 +59,7 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T, |
58 | 58 |
SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T, |
59 | 59 |
SET_PORT_T, SET_URI_T, IF_T, MODULE_T, |
60 | 60 |
SETFLAG_T, RESETFLAG_T, ISFLAGSET_T , |
61 |
- LEN_GT_T, PREFIX_T, STRIP_T, |
|
61 |
+ LEN_GT_T, PREFIX_T, STRIP_T,STRIP_TAIL_T, |
|
62 | 62 |
APPEND_BRANCH_T, |
63 | 63 |
REVERT_URI_T, |
64 | 64 |
FORWARD_TCP_T, |