... | ... |
@@ -43,7 +43,7 @@ skip_cfg_install?= |
43 | 43 |
skip_modules?= |
44 | 44 |
|
45 | 45 |
# if not set on the cmd. line or the env, exclude this modules: |
46 |
-exclude_modules?= cpl cpl-c ext extcmd \ |
|
46 |
+exclude_modules?= cpl ext extcmd \ |
|
47 | 47 |
postgres snmp \ |
48 | 48 |
im radius_acc radius_auth \ |
49 | 49 |
jabber mysql \ |
... | ... |
@@ -56,6 +56,7 @@ |
56 | 56 |
#include "mem/mem.h" |
57 | 57 |
#include "globals.h" |
58 | 58 |
#include "dset.h" |
59 |
+#include "usr_avp.h" |
|
59 | 60 |
#ifdef USE_TCP |
60 | 61 |
#include "tcp_server.h" |
61 | 62 |
#endif |
... | ... |
@@ -657,6 +658,21 @@ int do_action(struct action* a, struct sip_msg* msg) |
657 | 658 |
#endif |
658 | 659 |
ret=1; /* continue processing */ |
659 | 660 |
break; |
661 |
+ case LOAD_AVP_T: |
|
662 |
+ if (a->p1_type!=NUMBER_ST || a->p2_type!=STRING_ST || |
|
663 |
+ a->p3_type!=NUMBER_ST) { |
|
664 |
+ LOG(L_CRIT,"BUG: do_action: bad load_avp(%d,%d,%d) params " |
|
665 |
+ "types\n",a->p1_type,a->p2_type,a->p3_type); |
|
666 |
+ ret=E_BUG; |
|
667 |
+ break; |
|
668 |
+ } |
|
669 |
+ /* load the attribute(s)*/ |
|
670 |
+ if ( load_avp( msg, (int)a->p1.number, a->p2.string, |
|
671 |
+ (int)a->p3.number)!=0 ) { |
|
672 |
+ LOG(L_ERR,"ERROR:do_action: load avp failed\n"); |
|
673 |
+ ret=E_UNSPEC; |
|
674 |
+ } |
|
675 |
+ break; |
|
660 | 676 |
default: |
661 | 677 |
LOG(L_CRIT, "BUG: do_action: unknown type %d\n", a->type); |
662 | 678 |
} |
... | ... |
@@ -114,6 +114,7 @@ IF "if" |
114 | 114 |
ELSE "else" |
115 | 115 |
SET_ADV_ADDRESS "set_advertised_address" |
116 | 116 |
SET_ADV_PORT "set_advertised_port" |
117 |
+LOAD_AVP "load_avp" |
|
117 | 118 |
|
118 | 119 |
/*ACTION LVALUES*/ |
119 | 120 |
URIHOST "uri:host" |
... | ... |
@@ -168,8 +169,9 @@ MEMLOG "memlog"|"mem_log" |
168 | 169 |
SIP_WARNING sip_warning |
169 | 170 |
FIFO fifo |
170 | 171 |
FIFO_DIR fifo_dir |
171 |
-FIFO_DB_URL fifo_db_url |
|
172 | 172 |
FIFO_MODE fifo_mode |
173 |
+FIFO_DB_URL fifo_db_url |
|
174 |
+AVP_DB_URL avp_db_url |
|
173 | 175 |
SERVER_SIGNATURE server_signature |
174 | 176 |
REPLY_TO_VIA reply_to_via |
175 | 177 |
USER "user"|"uid" |
... | ... |
@@ -285,6 +287,7 @@ EAT_ABLE [\ \t\b\r] |
285 | 287 |
<INITIAL>{FORCE_RPORT} { count(); yylval.strval=yytext; return FORCE_RPORT; } |
286 | 288 |
<INITIAL>{FORCE_TCP_ALIAS} { count(); yylval.strval=yytext; |
287 | 289 |
return FORCE_TCP_ALIAS; } |
290 |
+<INITIAL>{LOAD_AVP} { count(); yylval.strval=yytext; return LOAD_AVP; } |
|
288 | 291 |
|
289 | 292 |
<INITIAL>{IF} { count(); yylval.strval=yytext; return IF; } |
290 | 293 |
<INITIAL>{ELSE} { count(); yylval.strval=yytext; return ELSE; } |
... | ... |
@@ -358,6 +361,7 @@ EAT_ABLE [\ \t\b\r] |
358 | 361 |
<INITIAL>{FIFO_DIR} { count(); yylval.strval=yytext; return FIFO_DIR; } |
359 | 362 |
<INITIAL>{FIFO_DB_URL} { count(); yylval.strval=yytext; return FIFO_DB_URL; } |
360 | 363 |
<INITIAL>{FIFO_MODE} { count(); yylval.strval=yytext; return FIFO_MODE; } |
364 |
+<INITIAL>{AVP_DB_URL} { count(); yylval.strval=yytext; return AVP_DB_URL; } |
|
361 | 365 |
<INITIAL>{SERVER_SIGNATURE} { count(); yylval.strval=yytext; return SERVER_SIGNATURE; } |
362 | 366 |
<INITIAL>{REPLY_TO_VIA} { count(); yylval.strval=yytext; return REPLY_TO_VIA; } |
363 | 367 |
<INITIAL>{ADVERTISED_ADDRESS} { count(); yylval.strval=yytext; |
... | ... |
@@ -72,6 +72,7 @@ |
72 | 72 |
#include "ip_addr.h" |
73 | 73 |
#include "socket_info.h" |
74 | 74 |
#include "name_alias.h" |
75 |
+#include "usr_avp.h" |
|
75 | 76 |
#include "ut.h" |
76 | 77 |
|
77 | 78 |
|
... | ... |
@@ -174,6 +175,7 @@ static struct id_list* mk_listen_id(char*, int, int); |
174 | 175 |
%token UDP |
175 | 176 |
%token TCP |
176 | 177 |
%token TLS |
178 |
+%token LOAD_AVP |
|
177 | 179 |
|
178 | 180 |
/* config vars. */ |
179 | 181 |
%token DEBUG |
... | ... |
@@ -194,6 +196,7 @@ static struct id_list* mk_listen_id(char*, int, int); |
194 | 196 |
%token FIFO_DIR |
195 | 197 |
%token FIFO_MODE |
196 | 198 |
%token FIFO_DB_URL |
199 |
+%token AVP_DB_URL |
|
197 | 200 |
%token SERVER_SIGNATURE |
198 | 201 |
%token REPLY_TO_VIA |
199 | 202 |
%token LOADMODULE |
... | ... |
@@ -394,7 +397,9 @@ assign_stm: DEBUG EQUAL NUMBER { debug=$3; } |
394 | 397 |
| FIFO_MODE EQUAL NUMBER { fifo_mode=$3; } |
395 | 398 |
| FIFO_MODE EQUAL error { yyerror("int value expected"); } |
396 | 399 |
| FIFO_DB_URL EQUAL STRING { fifo_db_url=$3; } |
397 |
- | FIFO_DB_URL EQUAL error { yyerror("string value expected"); } |
|
400 |
+ | FIFO_DB_URL EQUAL error { yyerror("string value expected"); } |
|
401 |
+ | AVP_DB_URL EQUAL STRING { avp_db_url=$3; } |
|
402 |
+ | AVP_DB_URL EQUAL error { yyerror("string value expected"); } |
|
398 | 403 |
| USER EQUAL STRING { user=$3; } |
399 | 404 |
| USER EQUAL ID { user=$3; } |
400 | 405 |
| USER EQUAL error { yyerror("string value expected"); } |
... | ... |
@@ -1461,9 +1466,29 @@ cmd: FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, |
1461 | 1466 |
#endif |
1462 | 1467 |
} |
1463 | 1468 |
| FORCE_TCP_ALIAS LPAREN error RPAREN {$$=0; |
1464 |
- yyerror("bad argument," |
|
1465 |
- " number expected"); |
|
1466 |
- } |
|
1469 |
+ yyerror("bad argument, number expected"); |
|
1470 |
+ } |
|
1471 |
+ | LOAD_AVP LPAREN STRING COMMA NUMBER RPAREN { |
|
1472 |
+ $$=(void*)get_user_type( $3 ); |
|
1473 |
+ if ($$==(void*)-1) { |
|
1474 |
+ yyerror("unknown user type in arg 1 for " |
|
1475 |
+ "load_avp(x,x)"); |
|
1476 |
+ } else { |
|
1477 |
+ $$=mk_action3( LOAD_AVP_T, NUMBER_ST, STRING_ST, |
|
1478 |
+ NUMBER_ST, $$, 0,(void*)$5); |
|
1479 |
+ } |
|
1480 |
+ } |
|
1481 |
+ | LOAD_AVP LPAREN STRING COMMA STRING COMMA NUMBER RPAREN { |
|
1482 |
+ $$=(void*)get_user_type( $3 ); |
|
1483 |
+ if ($$==(void*)-1) { |
|
1484 |
+ yyerror("unknown user type in arg 1 for " |
|
1485 |
+ "load_avp(x,x,x)"); |
|
1486 |
+ } else { |
|
1487 |
+ $$=mk_action3( LOAD_AVP_T, NUMBER_ST, STRING_ST, |
|
1488 |
+ NUMBER_ST, $$, $5, (void*)$7); |
|
1489 |
+ } |
|
1490 |
+ } |
|
1491 |
+ | LOAD_AVP error { $$=0; yyerror("missing '(' or ')' ?"); } |
|
1467 | 1492 |
| SET_ADV_ADDRESS LPAREN listen_id RPAREN { |
1468 | 1493 |
$$=0; |
1469 | 1494 |
if ((str_tmp=pkg_malloc(sizeof(str)))==0){ |
... | ... |
@@ -107,6 +107,9 @@ extern int fifo_mode; |
107 | 107 |
char extern *fifo_dir; /* dir. where reply fifos are allowed */ |
108 | 108 |
extern char *fifo_db_url; /* db url used by db_fifo interface */ |
109 | 109 |
|
110 |
+/* AVP configuration */ |
|
111 |
+extern char *avp_db_url; /* db url used by user preferences (AVPs) */ |
|
112 |
+ |
|
110 | 113 |
/* moved to pt.h |
111 | 114 |
extern int *pids; |
112 | 115 |
extern int process_no; |
... | ... |
@@ -45,6 +45,7 @@ |
45 | 45 |
* 2003-06-29 replaced port_no_str snprintf w/ int2str (andrei) |
46 | 46 |
* 2003-10-10 added switch for config check (-c) (andrei) |
47 | 47 |
* 2003-10-24 converted to the new socket_info lists (andrei) |
48 |
+ * 2004-02-06 added support for user pref. - init_avp_child() (bogdan) |
|
48 | 49 |
* |
49 | 50 |
*/ |
50 | 51 |
|
... | ... |
@@ -93,6 +94,7 @@ |
93 | 94 |
#include "parser/parse_hname2.h" |
94 | 95 |
#include "parser/digest/digest_parser.h" |
95 | 96 |
#include "fifo_server.h" |
97 |
+#include "usr_avp.h" |
|
96 | 98 |
#include "name_alias.h" |
97 | 99 |
#include "hash_func.h" |
98 | 100 |
#include "pt.h" |
... | ... |
@@ -843,6 +845,10 @@ int main_loop() |
843 | 845 |
LOG(L_ERR, "main_dontfork: init_child failed\n"); |
844 | 846 |
goto error; |
845 | 847 |
} |
848 |
+ if (init_avp_child(1)<0) { |
|
849 |
+ LOG(L_ERR, "init_avp_child failed\n"); |
|
850 |
+ goto error; |
|
851 |
+ } |
|
846 | 852 |
|
847 | 853 |
is_main=1; /* hack 42: call init_child with is_main=0 in case |
848 | 854 |
some modules wants to fork a child */ |
... | ... |
@@ -924,6 +930,10 @@ int main_loop() |
924 | 930 |
} |
925 | 931 |
#endif |
926 | 932 |
bind_address=si; /* shortcut */ |
933 |
+ if (init_avp_child(i + 1)<0) { |
|
934 |
+ LOG(L_ERR, "init_avp_child failed\n"); |
|
935 |
+ goto error; |
|
936 |
+ } |
|
927 | 937 |
if (init_child(i + 1) < 0) { |
928 | 938 |
LOG(L_ERR, "init_child failed\n"); |
929 | 939 |
goto error; |
... | ... |
@@ -54,6 +54,7 @@ |
54 | 54 |
* 2003-11-11: build_lump_rpl() removed, add_lump_rpl() has flags (bogdan) |
55 | 55 |
* 2003-12-04 global TM callbacks switched to per transaction callbacks |
56 | 56 |
* (bogdan) |
57 |
+ * 2004-02-06: support for user pref. added - destroy_avps (bogdan) |
|
57 | 58 |
*/ |
58 | 59 |
|
59 | 60 |
|
... | ... |
@@ -76,6 +77,7 @@ |
76 | 77 |
#include "../../tags.h" |
77 | 78 |
#include "../../data_lump.h" |
78 | 79 |
#include "../../data_lump_rpl.h" |
80 |
+#include "../../usr_avp.h" |
|
79 | 81 |
|
80 | 82 |
#include "t_hooks.h" |
81 | 83 |
#include "t_funcs.h" |
... | ... |
@@ -515,12 +517,14 @@ static inline int run_failure_handlers(struct cell *t, struct sip_msg *rpl, |
515 | 517 |
/* avoid recursion -- if failure_route forwards, and does not |
516 | 518 |
* set next failure route, failure_route will not be rentered |
517 | 519 |
* on failure */ |
518 |
- //goto_on_negative = 0; |
|
519 | 520 |
on_failure = t->on_negative; |
520 | 521 |
t->on_negative=0; |
521 | 522 |
/* run a reply_route action if some was marked */ |
522 | 523 |
if (run_actions(failure_rlist[on_failure], &fake_req)<0) |
523 | 524 |
LOG(L_ERR, "ERROR: run_failure_handlers: Error in do_action\n"); |
525 |
+ /* destroy any eventual avps */ |
|
526 |
+ if (users_avps) |
|
527 |
+ destroy_avps(); |
|
524 | 528 |
} |
525 | 529 |
|
526 | 530 |
/* restore original environment and free the fake msg */ |
... | ... |
@@ -1150,6 +1154,9 @@ int reply_received( struct sip_msg *p_msg ) |
1150 | 1154 |
if (t->uas.request) p_msg->flags=t->uas.request->flags; |
1151 | 1155 |
if (run_actions(onreply_rlist[t->on_reply], p_msg)<0) |
1152 | 1156 |
LOG(L_ERR, "ERROR: on_reply processing failed\n"); |
1157 |
+ /* destroy any eventual avps */ |
|
1158 |
+ if (users_avps) |
|
1159 |
+ destroy_avps(); |
|
1153 | 1160 |
/* transfer current message context back to t */ |
1154 | 1161 |
if (t->uas.request) t->uas.request->flags=p_msg->flags; |
1155 | 1162 |
} |
... | ... |
@@ -33,6 +33,7 @@ |
33 | 33 |
* 2003-02-10 moved zero-term in the calling functions (udp_receive & |
34 | 34 |
* tcp_read_req) |
35 | 35 |
* 2003-08-13 fixed exec_pre_cb returning 0 (backported from stable) (andrei) |
36 |
+ * 2004-02-06 added user preferences support - destroy_avps() (bogdan) |
|
36 | 37 |
*/ |
37 | 38 |
|
38 | 39 |
|
... | ... |
@@ -52,6 +53,7 @@ |
52 | 53 |
#include "ip_addr.h" |
53 | 54 |
#include "script_cb.h" |
54 | 55 |
#include "dset.h" |
56 |
+#include "usr_avp.h" |
|
55 | 57 |
|
56 | 58 |
#include "tcp_server.h" /* for tcpconn_add_alias */ |
57 | 59 |
|
... | ... |
@@ -153,13 +155,15 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info) |
153 | 155 |
#ifdef STATS |
154 | 156 |
gettimeofday( & tvb, &tz ); |
155 | 157 |
#endif |
156 |
- if (run_actions(rlist[0], msg)<0){ |
|
157 |
- |
|
158 |
+ if (run_actions(rlist[0], msg)<0) { |
|
158 | 159 |
LOG(L_WARN, "WARNING: receive_msg: " |
159 | 160 |
"error while trying script\n"); |
160 | 161 |
goto error; |
161 | 162 |
} |
162 | 163 |
|
164 |
+ /* ... free posible loaded avps */ |
|
165 |
+ if (users_avps) |
|
166 |
+ destroy_avps(); |
|
163 | 167 |
|
164 | 168 |
#ifdef STATS |
165 | 169 |
gettimeofday( & tve, &tz ); |
... | ... |
@@ -72,7 +72,8 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T, |
72 | 72 |
FORCE_RPORT_T, |
73 | 73 |
SET_ADV_ADDR_T, |
74 | 74 |
SET_ADV_PORT_T, |
75 |
- FORCE_TCP_ALIAS_T |
|
75 |
+ FORCE_TCP_ALIAS_T, |
|
76 |
+ LOAD_AVP_T |
|
76 | 77 |
}; |
77 | 78 |
enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST, |
78 | 79 |
EXPR_ST, ACTIONS_ST, CMDF_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST, |