... | ... |
@@ -43,7 +43,7 @@ export makefile_defs |
43 | 43 |
VERSION = 0 |
44 | 44 |
PATCHLEVEL = 8 |
45 | 45 |
SUBLEVEL = 12 |
46 |
-EXTRAVERSION = dev-20-lumps |
|
46 |
+EXTRAVERSION = dev-21-sock_info |
|
47 | 47 |
|
48 | 48 |
RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) |
49 | 49 |
OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]") |
... | ... |
@@ -4,7 +4,10 @@ $Id$ |
4 | 4 |
|
5 | 5 |
- fix aliases for tls_port (add_them?) |
6 | 6 |
- fix check_sel_op -- add proto for uri proto checks |
7 |
+- add via alias for tcp port & infinite tcp conn life |
|
7 | 8 |
|
9 |
+- fix 2 different fixups for diff. no of parameter |
|
10 |
+ (add no of params ot struct action?) -- linked to var. no. of params |
|
8 | 11 |
- alias support fot tcp/tls port numbers |
9 | 12 |
- warning builder set_advertised address support |
10 | 13 |
- grep parse_uri & replace with parse_sip_msg_uri (e.g do_action!) |
... | ... |
@@ -47,6 +47,7 @@ |
47 | 47 |
* added msg:len (andrei) |
48 | 48 |
* 2003-10-11 if(){} doesn't require a ';' after it anymore (andrei) |
49 | 49 |
* 2003-10-13 added FIFO_DIR & proto:host:port listen/alias support (andrei) |
50 |
+ * 2003-10-24 converted to the new socket_info lists (andrei) |
|
50 | 51 |
*/ |
51 | 52 |
|
52 | 53 |
|
... | ... |
@@ -67,9 +68,11 @@ |
67 | 68 |
#include "sr_module.h" |
68 | 69 |
#include "modparam.h" |
69 | 70 |
#include "ip_addr.h" |
71 |
+#include "socket_info.h" |
|
70 | 72 |
#include "name_alias.h" |
71 | 73 |
#include "ut.h" |
72 | 74 |
|
75 |
+ |
|
73 | 76 |
#include "config.h" |
74 | 77 |
#ifdef USE_TLS |
75 | 78 |
#include "tls/tls_config.h" |
... | ... |
@@ -84,7 +87,7 @@ |
84 | 87 |
#undef _ALLOCA_H |
85 | 88 |
|
86 | 89 |
struct id_list{ |
87 |
- char* s; |
|
90 |
+ char* name; |
|
88 | 91 |
int proto; |
89 | 92 |
int port; |
90 | 93 |
struct id_list* next; |
... | ... |
@@ -327,6 +330,7 @@ listen_id: ip { tmp=ip_addr2a($1); |
327 | 330 |
proto: UDP { $$=PROTO_UDP; } |
328 | 331 |
| TCP { $$=PROTO_TCP; } |
329 | 332 |
| TLS { $$=PROTO_TLS; } |
333 |
+ | STAR { $$=0; } |
|
330 | 334 |
; |
331 | 335 |
|
332 | 336 |
port: NUMBER { $$=$1; } |
... | ... |
@@ -355,10 +359,7 @@ assign_stm: DEBUG EQUAL NUMBER { debug=$3; } |
355 | 359 |
| DNS EQUAL error { yyerror("boolean value expected"); } |
356 | 360 |
| REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; } |
357 | 361 |
| REV_DNS EQUAL error { yyerror("boolean value expected"); } |
358 |
- | PORT EQUAL NUMBER { port_no=$3; |
|
359 |
- if (sock_no>0) |
|
360 |
- sock_info[sock_no-1].port_no=port_no; |
|
361 |
- } |
|
362 |
+ | PORT EQUAL NUMBER { port_no=$3; } |
|
362 | 363 |
| STAT EQUAL STRING { |
363 | 364 |
#ifdef STATS |
364 | 365 |
stat_file=$3; |
... | ... |
@@ -521,27 +522,13 @@ assign_stm: DEBUG EQUAL NUMBER { debug=$3; } |
521 | 522 |
| REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); } |
522 | 523 |
| LISTEN EQUAL id_lst { |
523 | 524 |
for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next){ |
524 |
- if (sock_no < MAX_LISTEN){ |
|
525 |
- sock_info[sock_no].name.s=(char*) |
|
526 |
- pkg_malloc(strlen(lst_tmp->s)+1); |
|
527 |
- if (sock_info[sock_no].name.s==0){ |
|
528 |
- LOG(L_CRIT, "ERROR: cfg. parser:" |
|
529 |
- " out of memory.\n"); |
|
530 |
- break; |
|
531 |
- }else{ |
|
532 |
- strncpy(sock_info[sock_no].name.s, |
|
533 |
- lst_tmp->s, |
|
534 |
- strlen(lst_tmp->s)+1); |
|
535 |
- sock_info[sock_no].name.len= |
|
536 |
- strlen(lst_tmp->s); |
|
537 |
- sock_info[sock_no].port_no= |
|
538 |
- lst_tmp->port; |
|
539 |
- sock_no++; |
|
540 |
- } |
|
541 |
- }else{ |
|
542 |
- LOG(L_CRIT, "ERROR: cfg. parser: " |
|
543 |
- "too many listen addresses" |
|
544 |
- "(max. %d).\n", MAX_LISTEN); |
|
525 |
+ if (add_listen_iface( lst_tmp->name, |
|
526 |
+ lst_tmp->port, |
|
527 |
+ lst_tmp->proto, |
|
528 |
+ 0 |
|
529 |
+ )!=0){ |
|
530 |
+ LOG(L_CRIT, "ERROR: cfg. parser: failed" |
|
531 |
+ " to add listen address\n"); |
|
545 | 532 |
break; |
546 | 533 |
} |
547 | 534 |
} |
... | ... |
@@ -550,7 +537,7 @@ assign_stm: DEBUG EQUAL NUMBER { debug=$3; } |
550 | 537 |
"expected"); } |
551 | 538 |
| ALIAS EQUAL id_lst { |
552 | 539 |
for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) |
553 |
- add_alias(lst_tmp->s, strlen(lst_tmp->s), |
|
540 |
+ add_alias(lst_tmp->name, strlen(lst_tmp->name), |
|
554 | 541 |
lst_tmp->port, lst_tmp->proto); |
555 | 542 |
} |
556 | 543 |
| ALIAS EQUAL error { yyerror(" hostname expected"); } |
... | ... |
@@ -1509,7 +1496,7 @@ static struct id_list* mk_listen_id(char* host, int proto, int port) |
1509 | 1496 |
if (l==0){ |
1510 | 1497 |
LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n"); |
1511 | 1498 |
}else{ |
1512 |
- l->s=host; |
|
1499 |
+ l->name=host; |
|
1513 | 1500 |
l->port=port; |
1514 | 1501 |
l->proto=proto; |
1515 | 1502 |
l->next=0; |
... | ... |
@@ -43,6 +43,7 @@ |
43 | 43 |
* local replies (andrei) |
44 | 44 |
* 2003-08-21 check_self properly handles ipv6 addresses & refs (andrei) |
45 | 45 |
* 2003-10-21 check_self updated to handle proto (andrei) |
46 |
+ * 2003-10-24 converted to the new socket_info lists (andrei) |
|
46 | 47 |
*/ |
47 | 48 |
|
48 | 49 |
|
... | ... |
@@ -71,6 +72,7 @@ |
71 | 72 |
#include "ip_addr.h" |
72 | 73 |
#include "resolve.h" |
73 | 74 |
#include "name_alias.h" |
75 |
+#include "socket_info.h" |
|
74 | 76 |
|
75 | 77 |
#ifdef DEBUG_DMALLOC |
76 | 78 |
#include <dmalloc.h> |
... | ... |
@@ -87,15 +89,14 @@ struct socket_info* get_out_socket(union sockaddr_union* to, int proto) |
87 | 89 |
{ |
88 | 90 |
int temp_sock; |
89 | 91 |
socklen_t len; |
90 |
- int r; |
|
91 | 92 |
union sockaddr_union from; |
93 |
+ struct socket_info* si; |
|
92 | 94 |
|
93 | 95 |
if (proto!=PROTO_UDP) { |
94 | 96 |
LOG(L_CRIT, "BUG: get_out_socket can only be called for UDP\n"); |
95 | 97 |
return 0; |
96 | 98 |
} |
97 |
- |
|
98 |
- r=-1; |
|
99 |
+ |
|
99 | 100 |
temp_sock=socket(to->s.sa_family, SOCK_DGRAM, 0 ); |
100 | 101 |
if (temp_sock==-1) { |
101 | 102 |
LOG(L_ERR, "ERROR: get_out_socket: socket() failed: %s\n", |
... | ... |
@@ -113,38 +114,39 @@ struct socket_info* get_out_socket(union sockaddr_union* to, int proto) |
113 | 114 |
strerror(errno)); |
114 | 115 |
goto error; |
115 | 116 |
} |
116 |
- for (r=0; r<sock_no; r++) { |
|
117 |
+ for (si=udp_listen; si; si=si->next) { |
|
117 | 118 |
switch(from.s.sa_family) { |
118 | 119 |
case AF_INET: |
119 |
- if (sock_info[r].address.af!=AF_INET) |
|
120 |
+ if (si->address.af!=AF_INET) |
|
120 | 121 |
continue; |
121 |
- if (memcmp(&sock_info[r].address.u, |
|
122 |
+ if (memcmp(&si->address.u, |
|
122 | 123 |
&from.sin.sin_addr, |
123 |
- sock_info[r].address.len)==0) |
|
124 |
- goto error; /* it is actually success */ |
|
124 |
+ si->address.len)==0) |
|
125 |
+ goto found; /* success */ |
|
125 | 126 |
break; |
126 | 127 |
#if defined(USE_IPV6) |
127 | 128 |
case AF_INET6: |
128 |
- if (sock_info[r].address.af!=AF_INET6) |
|
129 |
+ if (si->address.af!=AF_INET6) |
|
129 | 130 |
continue; |
130 |
- if (memcmp(&sock_info[r].address.u, |
|
131 |
+ if (memcmp(&si->address.u, |
|
131 | 132 |
&from.sin6.sin6_addr, len)==0) |
132 |
- goto error; |
|
133 |
+ goto found; |
|
133 | 134 |
continue; |
134 | 135 |
#endif |
135 | 136 |
default: LOG(L_ERR, "ERROR: get_out_socket: " |
136 | 137 |
"unknown family: %d\n", |
137 | 138 |
from.s.sa_family); |
138 |
- r=-1; |
|
139 | 139 |
goto error; |
140 | 140 |
} |
141 | 141 |
} |
142 |
- LOG(L_ERR, "ERROR: get_out_socket: no socket found\n"); |
|
143 |
- r=-1; |
|
144 | 142 |
error: |
143 |
+ LOG(L_ERR, "ERROR: get_out_socket: no socket found\n"); |
|
144 |
+ close(temp_sock); |
|
145 |
+ return 0; |
|
146 |
+found: |
|
145 | 147 |
close(temp_sock); |
146 |
- DBG("DEBUG: get_out_socket: socket determined: %d\n", r ); |
|
147 |
- return r==-1? 0: &sock_info[r]; |
|
148 |
+ DBG("DEBUG: get_out_socket: socket determined: %p\n", si ); |
|
149 |
+ return si; |
|
148 | 150 |
} |
149 | 151 |
|
150 | 152 |
|
... | ... |
@@ -228,10 +230,10 @@ struct socket_info* get_send_socket(union sockaddr_union* to, int proto) |
228 | 230 |
*/ |
229 | 231 |
int check_self(str* host, unsigned short port, unsigned short proto) |
230 | 232 |
{ |
231 |
- int r; |
|
232 | 233 |
char* hname; |
233 | 234 |
int h_len; |
234 | 235 |
struct socket_info* si; |
236 |
+ unsigned short c_proto; |
|
235 | 237 |
#ifdef USE_IPV6 |
236 | 238 |
struct ip_addr* ip6; |
237 | 239 |
#endif |
... | ... |
@@ -245,76 +247,80 @@ int check_self(str* host, unsigned short port, unsigned short proto) |
245 | 247 |
h_len-=2; |
246 | 248 |
} |
247 | 249 |
#endif |
248 |
- /* get teh proper sock list */ |
|
249 |
- switch(proto){ |
|
250 |
- case PROTO_NONE: /* we'll use udp and not all the lists FIXME: */ |
|
251 |
- case PROTO_UDP: |
|
252 |
- si=sock_info; |
|
253 |
- break; |
|
250 |
+ c_proto=proto?proto:PROTO_UDP; |
|
251 |
+ do{ |
|
252 |
+ /* get the proper sock list */ |
|
253 |
+ switch(c_proto){ |
|
254 |
+ case PROTO_NONE: /* we'll use udp and not all the lists FIXME: */ |
|
255 |
+ case PROTO_UDP: |
|
256 |
+ si=udp_listen; |
|
257 |
+ break; |
|
254 | 258 |
#ifdef USE_TCP |
255 |
- case PROTO_TCP: |
|
256 |
- si=tcp_info; |
|
257 |
- break; |
|
259 |
+ case PROTO_TCP: |
|
260 |
+ si=tcp_listen; |
|
261 |
+ break; |
|
258 | 262 |
#endif |
259 | 263 |
#ifdef USE_TLS |
260 |
- case PROTO_TLS: |
|
261 |
- si=tls_info; |
|
262 |
- break; |
|
264 |
+ case PROTO_TLS: |
|
265 |
+ si=tls_listen; |
|
266 |
+ break; |
|
263 | 267 |
#endif |
264 |
- default: |
|
265 |
- /* unknown proto */ |
|
266 |
- LOG(L_WARN, "WARNING: check_self: unknown proto %d\n", proto); |
|
267 |
- return 0; /* false */ |
|
268 |
- } |
|
269 |
- for (r=0; r<sock_no; r++){ |
|
270 |
- DBG("check_self - checking if host==us: %d==%d && " |
|
271 |
- " [%.*s] == [%.*s]\n", |
|
272 |
- h_len, |
|
273 |
- si[r].name.len, |
|
274 |
- h_len, hname, |
|
275 |
- si[r].name.len, si[r].name.s |
|
276 |
- ); |
|
277 |
- if (port) { |
|
278 |
- DBG("check_self - checking if port %d matches port %d\n", |
|
279 |
- si[r].port_no, port); |
|
280 |
- if (si[r].port_no!=port) { |
|
281 |
- continue; |
|
282 |
- } |
|
268 |
+ default: |
|
269 |
+ /* unknown proto */ |
|
270 |
+ LOG(L_WARN, "WARNING: check_self: " |
|
271 |
+ "unknown proto %d\n", c_proto); |
|
272 |
+ return 0; /* false */ |
|
283 | 273 |
} |
284 |
- if ( (h_len==sock_info[r].name.len) && |
|
285 |
- (strncasecmp(hname, sock_info[r].name.s, |
|
286 |
- sock_info[r].name.len)==0) /*slower*/) |
|
287 |
- /* comp. must be case insensitive, host names |
|
288 |
- * can be written in mixed case, it will also match |
|
289 |
- * ipv6 addresses if we are lucky*/ |
|
290 |
- break; |
|
291 |
- /* check if host == ip address */ |
|
274 |
+ for (; si; si=si->next){ |
|
275 |
+ DBG("check_self - checking if host==us: %d==%d && " |
|
276 |
+ " [%.*s] == [%.*s]\n", |
|
277 |
+ h_len, |
|
278 |
+ si->name.len, |
|
279 |
+ h_len, hname, |
|
280 |
+ si->name.len, si->name.s |
|
281 |
+ ); |
|
282 |
+ if (port) { |
|
283 |
+ DBG("check_self - checking if port %d matches port %d\n", |
|
284 |
+ si->port_no, port); |
|
285 |
+ if (si->port_no!=port) { |
|
286 |
+ continue; |
|
287 |
+ } |
|
288 |
+ } |
|
289 |
+ if ( (h_len==si->name.len) && |
|
290 |
+ (strncasecmp(hname, si->name.s, |
|
291 |
+ si->name.len)==0) /*slower*/) |
|
292 |
+ /* comp. must be case insensitive, host names |
|
293 |
+ * can be written in mixed case, it will also match |
|
294 |
+ * ipv6 addresses if we are lucky*/ |
|
295 |
+ goto found; |
|
296 |
+ /* check if host == ip address */ |
|
292 | 297 |
#ifdef USE_IPV6 |
293 |
- /* ipv6 case is uglier, host can be [3ffe::1] */ |
|
294 |
- ip6=str2ip6(host); |
|
295 |
- if (ip6){ |
|
296 |
- if (ip_addr_cmp(ip6, &sock_info[r].address)) |
|
297 |
- break; /* match */ |
|
298 |
- else |
|
299 |
- continue; /* no match, but this is an ipv6 address |
|
300 |
- so no point in trying ipv4 */ |
|
301 |
- } |
|
298 |
+ /* ipv6 case is uglier, host can be [3ffe::1] */ |
|
299 |
+ ip6=str2ip6(host); |
|
300 |
+ if (ip6){ |
|
301 |
+ if (ip_addr_cmp(ip6, &si->address)) |
|
302 |
+ goto found; /* match */ |
|
303 |
+ else |
|
304 |
+ continue; /* no match, but this is an ipv6 address |
|
305 |
+ so no point in trying ipv4 */ |
|
306 |
+ } |
|
302 | 307 |
#endif |
303 |
- /* ipv4 */ |
|
304 |
- if ( (!sock_info[r].is_ip) && |
|
305 |
- (h_len==sock_info[r].address_str.len) && |
|
306 |
- (memcmp(hname, sock_info[r].address_str.s, |
|
307 |
- sock_info[r].address_str.len)==0) |
|
308 |
- ) |
|
309 |
- break; |
|
310 |
- } |
|
311 |
- if (r==sock_no){ |
|
312 |
- /* try to look into the aliases*/ |
|
313 |
- if (grep_aliases(hname, h_len, port, proto)==0){ |
|
314 |
- DBG("check_self: host != me\n"); |
|
315 |
- return 0; |
|
308 |
+ /* ipv4 */ |
|
309 |
+ if ( (!(si->flags&SI_IS_IP)) && |
|
310 |
+ (h_len==si->address_str.len) && |
|
311 |
+ (memcmp(hname, si->address_str.s, |
|
312 |
+ si->address_str.len)==0) |
|
313 |
+ ) |
|
314 |
+ goto found; |
|
316 | 315 |
} |
316 |
+ }while( (proto==0) && (c_proto=next_proto(c_proto)) ); |
|
317 |
+ |
|
318 |
+ /* try to look into the aliases*/ |
|
319 |
+ if (grep_aliases(hname, h_len, port, proto)==0){ |
|
320 |
+ DBG("check_self: host != me\n"); |
|
321 |
+ return 0; |
|
317 | 322 |
} |
323 |
+found: |
|
318 | 324 |
return 1; |
319 | 325 |
} |
320 | 326 |
|
... | ... |
@@ -46,19 +46,10 @@ |
46 | 46 |
extern char * cfg_file; |
47 | 47 |
extern int config_check; |
48 | 48 |
extern char *stat_file; |
49 |
-extern struct socket_info sock_info[]; /* all addresses we listen/send from*/ |
|
50 |
-#ifdef USE_TCP |
|
51 |
-extern struct socket_info tcp_info[]; /* all tcp sockets we listen on*/ |
|
52 |
-#endif |
|
53 |
-#ifdef USE_TLS |
|
54 |
-extern struct socket_info tls_info[]; /* tcp-tls sockets */ |
|
55 |
-#endif |
|
56 |
-extern int sock_no; /* number of addresses/open sockets*/ |
|
57 | 49 |
extern unsigned short port_no; |
58 | 50 |
|
59 | 51 |
extern struct socket_info* bind_address; /* pointer to the crt. proc. |
60 | 52 |
listening address */ |
61 |
-extern int bind_idx; /* same as above but index in the bound[] array */ |
|
62 | 53 |
extern struct socket_info* sendipv4; /* ipv4 socket to use when msg. |
63 | 54 |
comes from ipv6*/ |
64 | 55 |
extern struct socket_info* sendipv6; /* same as above for ipv6 */ |
... | ... |
@@ -77,6 +77,9 @@ union sockaddr_union{ |
77 | 77 |
}; |
78 | 78 |
|
79 | 79 |
|
80 |
+ |
|
81 |
+enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2 }; |
|
82 |
+ |
|
80 | 83 |
struct socket_info{ |
81 | 84 |
int socket; |
82 | 85 |
str name; /* name - eg.: foo.bar or 10.0.0.1 */ |
... | ... |
@@ -84,10 +87,11 @@ struct socket_info{ |
84 | 87 |
str address_str; /* ip address converted to string -- optimization*/ |
85 | 88 |
unsigned short port_no; /* port number */ |
86 | 89 |
str port_no_str; /* port number converted to string -- optimization*/ |
87 |
- int is_ip; /* 1 if name is an ip address, 0 if not -- optimization*/ |
|
88 |
- int is_lo; /* 1 if is a loopback, 0 if not */ |
|
90 |
+ enum si_flags flags; /* SI_IS_IP | SI_IS_LO */ |
|
89 | 91 |
union sockaddr_union su; |
90 | 92 |
int proto; /* tcp or udp*/ |
93 |
+ struct socket_info* next; |
|
94 |
+ struct socket_info* prev; |
|
91 | 95 |
}; |
92 | 96 |
|
93 | 97 |
|
... | ... |
@@ -44,6 +44,7 @@ |
44 | 44 |
* see comment above it for explanations. (andrei) |
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 |
+ * 2003-10-24 converted to the new socket_info lists (andrei) |
|
47 | 48 |
* |
48 | 49 |
*/ |
49 | 50 |
|
... | ... |
@@ -330,17 +331,15 @@ int names_len[MAX_LISTEN]; /* lengths of the names*/ |
330 | 331 |
struct ip_addr addresses[MAX_LISTEN]; /* our ips */ |
331 | 332 |
int addresses_no=0; /* number of names/ips */ |
332 | 333 |
#endif |
333 |
-struct socket_info sock_info[MAX_LISTEN];/*all addresses we listen/send from*/ |
|
334 |
+struct socket_info* udp_listen=0; |
|
334 | 335 |
#ifdef USE_TCP |
335 |
-struct socket_info tcp_info[MAX_LISTEN];/*all tcp addresses we listen on*/ |
|
336 |
+struct socket_info* tcp_listen=0; |
|
336 | 337 |
#endif |
337 | 338 |
#ifdef USE_TLS |
338 |
-struct socket_info tls_info[MAX_LISTEN]; /* all tls addresses we listen on*/ |
|
339 |
+struct socket_info* tls_listen=0; |
|
339 | 340 |
#endif |
340 |
-int sock_no=0; /* number of addresses/open sockets*/ |
|
341 | 341 |
struct socket_info* bind_address=0; /* pointer to the crt. proc. |
342 | 342 |
listening address*/ |
343 |
-int bind_idx; /* same as above but index in the bound[] array */ |
|
344 | 343 |
struct socket_info* sendipv4; /* ipv4 socket to use when msg. comes from ipv6*/ |
345 | 344 |
struct socket_info* sendipv6; /* same as above for ipv6 */ |
346 | 345 |
#ifdef USE_TCP |
... | ... |
@@ -754,8 +753,9 @@ error: |
754 | 753 |
/* main loop */ |
755 | 754 |
int main_loop() |
756 | 755 |
{ |
757 |
- int r, i; |
|
756 |
+ int i; |
|
758 | 757 |
pid_t pid; |
758 |
+ struct socket_info* si; |
|
759 | 759 |
#ifdef USE_TCP |
760 | 760 |
int sockfd[2]; |
761 | 761 |
#endif |
... | ... |
@@ -773,12 +773,11 @@ int main_loop() |
773 | 773 |
setstats( 0 ); |
774 | 774 |
#endif |
775 | 775 |
/* only one address, we ignore all the others */ |
776 |
- if (udp_init(&sock_info[0])==-1) goto error; |
|
777 |
- bind_address=&sock_info[0]; |
|
776 |
+ if (udp_init(udp_listen)==-1) goto error; |
|
777 |
+ bind_address=udp_listen; |
|
778 | 778 |
sendipv4=bind_address; |
779 | 779 |
sendipv6=bind_address; /*FIXME*/ |
780 |
- bind_idx=0; |
|
781 |
- if (sock_no>1){ |
|
780 |
+ if (udp_listen->next){ |
|
782 | 781 |
LOG(L_WARN, "WARNING: using only the first listen address" |
783 | 782 |
" (no fork)\n"); |
784 | 783 |
} |
... | ... |
@@ -853,66 +852,55 @@ int main_loop() |
853 | 852 |
/* process_no now initialized to zero -- increase from now on |
854 | 853 |
as new processes are forked (while skipping 0 reserved for main ) |
855 | 854 |
*/ |
856 |
- for(r=0;r<sock_no;r++){ |
|
855 |
+ for(si=udp_listen;si;si=si->next){ |
|
857 | 856 |
/* create the listening socket (for each address)*/ |
858 | 857 |
/* udp */ |
859 |
- if (udp_init(&sock_info[r])==-1) goto error; |
|
858 |
+ if (udp_init(si)==-1) goto error; |
|
860 | 859 |
/* get first ipv4/ipv6 socket*/ |
861 |
- if ((sock_info[r].address.af==AF_INET)&& |
|
862 |
- ((sendipv4==0)||(sendipv4->is_lo))) |
|
863 |
- sendipv4=&sock_info[r]; |
|
860 |
+ if ((si->address.af==AF_INET)&& |
|
861 |
+ ((sendipv4==0)||(sendipv4->flags&SI_IS_LO))) |
|
862 |
+ sendipv4=si; |
|
864 | 863 |
#ifdef USE_IPV6 |
865 |
- if((sendipv6==0)&&(sock_info[r].address.af==AF_INET6)) |
|
866 |
- sendipv6=&sock_info[r]; |
|
864 |
+ if((sendipv6==0)&&(si->address.af==AF_INET6)) |
|
865 |
+ sendipv6=si; |
|
867 | 866 |
#endif |
867 |
+ } |
|
868 | 868 |
#ifdef USE_TCP |
869 |
- if (!tcp_disable){ |
|
870 |
- tcp_info[r]=sock_info[r]; /* copy the sockets */ |
|
869 |
+ if (!tcp_disable){ |
|
870 |
+ for(si=tcp_listen; si; si=si->next){ |
|
871 | 871 |
/* same thing for tcp */ |
872 |
- if (tcp_init(&tcp_info[r])==-1) goto error; |
|
872 |
+ if (tcp_init(si)==-1) goto error; |
|
873 | 873 |
/* get first ipv4/ipv6 socket*/ |
874 |
- if ((tcp_info[r].address.af==AF_INET)&& |
|
875 |
- ((sendipv4_tcp==0)||(sendipv4_tcp->is_lo))) |
|
876 |
- sendipv4_tcp=&tcp_info[r]; |
|
874 |
+ if ((si->address.af==AF_INET)&& |
|
875 |
+ ((sendipv4_tcp==0)||(sendipv4_tcp->flags&SI_IS_LO))) |
|
876 |
+ sendipv4_tcp=si; |
|
877 | 877 |
#ifdef USE_IPV6 |
878 |
- if((sendipv6_tcp==0)&&(tcp_info[r].address.af==AF_INET6)) |
|
879 |
- sendipv6_tcp=&tcp_info[r]; |
|
878 |
+ if((sendipv6_tcp==0)&&(si->address.af==AF_INET6)) |
|
879 |
+ sendipv6_tcp=si; |
|
880 | 880 |
#endif |
881 | 881 |
} |
882 |
+ } |
|
882 | 883 |
#ifdef USE_TLS |
883 |
- if (!tls_disable){ |
|
884 |
- tls_info[r]=sock_info[r]; /* copy the sockets */ |
|
885 |
- /* fix the port number -- there is no way so far to set-up |
|
886 |
- * individual tls port numbers */ |
|
887 |
- tls_info[r].port_no=tls_port_no; /* FIXME: */ |
|
888 |
- tmp=int2str(tls_info[r].port_no, &len); |
|
889 |
- /* we don't need to free the previous content, is uesd |
|
890 |
- * by tcp & udp! */ |
|
891 |
- tls_info[r].port_no_str.s=(char*)pkg_malloc(len+1); |
|
892 |
- if (tls_info[r].port_no_str.s==0){ |
|
893 |
- LOG(L_CRIT, "memory allocation failure\n"); |
|
894 |
- goto error; |
|
895 |
- } |
|
896 |
- strncpy(tls_info[r].port_no_str.s, tmp, len+1); |
|
897 |
- tls_info[r].port_no_str.len=len; |
|
898 |
- |
|
884 |
+ if (!tls_disable){ |
|
885 |
+ for(si=tls_listen; si; si=si->next){ |
|
899 | 886 |
/* same as for tcp*/ |
900 |
- if (tls_init(&tls_info[r])==-1) goto error; |
|
887 |
+ if (tls_init(si)==-1) goto error; |
|
901 | 888 |
/* get first ipv4/ipv6 socket*/ |
902 |
- if ((tls_info[r].address.af==AF_INET)&& |
|
903 |
- ((sendipv4_tls==0)||(sendipv4_tls->is_lo))) |
|
904 |
- sendipv4_tls=&tls_info[r]; |
|
889 |
+ if ((si->address.af==AF_INET)&& |
|
890 |
+ ((sendipv4_tls==0)||(sendipv4_tls->flags&SI_IS_LO))) |
|
891 |
+ sendipv4_tls=si; |
|
905 | 892 |
#ifdef USE_IPV6 |
906 |
- if((sendipv6_tls==0)&&(tls_info[r].address.af==AF_INET6)) |
|
907 |
- sendipv6_tls=&tls_info[r]; |
|
893 |
+ if((sendipv6_tls==0)&&(si->address.af==AF_INET6)) |
|
894 |
+ sendipv6_tls=si; |
|
908 | 895 |
#endif |
909 | 896 |
} |
897 |
+ } |
|
910 | 898 |
#endif /* USE_TLS */ |
911 | 899 |
#endif /* USE_TCP */ |
912 | 900 |
/* all procs should have access to all the sockets (for sending) |
913 | 901 |
* so we open all first*/ |
914 |
- } |
|
915 |
- for(r=0; r<sock_no;r++){ |
|
902 |
+ /* udp processes */ |
|
903 |
+ for(si=udp_listen; si; si=si->next){ |
|
916 | 904 |
for(i=0;i<children_no;i++){ |
917 | 905 |
process_no++; |
918 | 906 |
#ifdef USE_TCP |
... | ... |
@@ -935,8 +923,7 @@ int main_loop() |
935 | 923 |
unix_tcp_sock=sockfd[1]; |
936 | 924 |
} |
937 | 925 |
#endif |
938 |
- bind_address=&sock_info[r]; /* shortcut */ |
|
939 |
- bind_idx=r; |
|
926 |
+ bind_address=si; /* shortcut */ |
|
940 | 927 |
if (init_child(i + 1) < 0) { |
941 | 928 |
LOG(L_ERR, "init_child failed\n"); |
942 | 929 |
goto error; |
... | ... |
@@ -948,8 +935,8 @@ int main_loop() |
948 | 935 |
}else{ |
949 | 936 |
pt[process_no].pid=pid; /*should be in shared mem.*/ |
950 | 937 |
snprintf(pt[process_no].desc, MAX_PT_DESC, |
951 |
- "receiver child=%d sock=%d @ %s:%s", i, r, |
|
952 |
- sock_info[r].name.s, sock_info[r].port_no_str.s ); |
|
938 |
+ "receiver child=%d sock= %s:%s", i, |
|
939 |
+ si->name.s, si->port_no_str.s ); |
|
953 | 940 |
#ifdef USE_TCP |
954 | 941 |
if (!tcp_disable){ |
955 | 942 |
close(sockfd[1]); |
... | ... |
@@ -967,8 +954,6 @@ int main_loop() |
967 | 954 |
|
968 | 955 |
/*this is the main process*/ |
969 | 956 |
bind_address=0; /* main proc -> it shouldn't send anything, */ |
970 |
- bind_idx=0; /* if it does get_send_sock should return |
|
971 |
- a good socket */ |
|
972 | 957 |
|
973 | 958 |
/* if configured to do so, start a server for accepting FIFO commands */ |
974 | 959 |
if (open_fifo_server()<0) { |
... | ... |
@@ -1068,8 +1053,9 @@ int main_loop() |
1068 | 1053 |
#endif |
1069 | 1054 |
/*DEBUG- remove it*/ |
1070 | 1055 |
#ifdef DEBUG |
1071 |
- fprintf(stderr, "\n% 3d processes (%3d), % 3d children * % 3d listening addresses" |
|
1072 |
- "+ main + fifo %s\n", process_no+1, process_count(), children_no, sock_no, |
|
1056 |
+ fprintf(stderr, "\n% 3d processes (%3d), % 3d children * " |
|
1057 |
+ "listening addresses + tcp listeners + tls listeners" |
|
1058 |
+ "+ main + fifo %s\n", process_no+1, process_count(), children_no, |
|
1073 | 1059 |
(timer_list)?"+ timer":""); |
1074 | 1060 |
for (r=0; r<=process_no; r++){ |
1075 | 1061 |
fprintf(stderr, "% 3d % 5d - %s\n", r, pt[r].pid, pt[r].desc); |
... | ... |
@@ -1095,134 +1081,6 @@ int main_loop() |
1095 | 1081 |
|
1096 | 1082 |
} |
1097 | 1083 |
|
1098 |
-/* add all family type addresses of interface if_name to the socket_info array |
|
1099 |
- * if if_name==0, adds all addresses on all interfaces |
|
1100 |
- * WARNING: it only works with ipv6 addresses on FreeBSD |
|
1101 |
- * return: -1 on error, 0 on success |
|
1102 |
- */ |
|
1103 |
-int add_interfaces(char* if_name, int family, unsigned short port) |
|
1104 |
-{ |
|
1105 |
- struct ifconf ifc; |
|
1106 |
- struct ifreq ifr; |
|
1107 |
- struct ifreq ifrcopy; |
|
1108 |
- char* last; |
|
1109 |
- char* p; |
|
1110 |
- int size; |
|
1111 |
- int lastlen; |
|
1112 |
- int s; |
|
1113 |
- char* tmp; |
|
1114 |
- struct ip_addr addr; |
|
1115 |
- int ret; |
|
1116 |
- |
|
1117 |
-#ifdef HAVE_SOCKADDR_SA_LEN |
|
1118 |
- #ifndef MAX |
|
1119 |
- #define MAX(a,b) ( ((a)>(b))?(a):(b)) |
|
1120 |
- #endif |
|
1121 |
-#endif |
|
1122 |
- /* ipv4 or ipv6 only*/ |
|
1123 |
- s=socket(family, SOCK_DGRAM, 0); |
|
1124 |
- ret=-1; |
|
1125 |
- lastlen=0; |
|
1126 |
- ifc.ifc_req=0; |
|
1127 |
- for (size=10; ; size*=2){ |
|
1128 |
- ifc.ifc_len=size*sizeof(struct ifreq); |
|
1129 |
- ifc.ifc_req=(struct ifreq*) pkg_malloc(size*sizeof(struct ifreq)); |
|
1130 |
- if (ifc.ifc_req==0){ |
|
1131 |
- fprintf(stderr, "memory allocation failure\n"); |
|
1132 |
- goto error; |
|
1133 |
- } |
|
1134 |
- if (ioctl(s, SIOCGIFCONF, &ifc)==-1){ |
|
1135 |
- if(errno==EBADF) return 0; /* invalid descriptor => no such ifs*/ |
|
1136 |
- fprintf(stderr, "ioctl failed: %s\n", strerror(errno)); |
|
1137 |
- goto error; |
|
1138 |
- } |
|
1139 |
- if ((lastlen) && (ifc.ifc_len==lastlen)) break; /*success, |
|
1140 |
- len not changed*/ |
|
1141 |
- lastlen=ifc.ifc_len; |
|
1142 |
- /* try a bigger array*/ |
|
1143 |
- pkg_free(ifc.ifc_req); |
|
1144 |
- } |
|
1145 |
- |
|
1146 |
- last=(char*)ifc.ifc_req+ifc.ifc_len; |
|
1147 |
- for(p=(char*)ifc.ifc_req; p<last; |
|
1148 |
- p+=(sizeof(ifr.ifr_name)+ |
|
1149 |
- #ifdef HAVE_SOCKADDR_SA_LEN |
|
1150 |
- MAX(ifr.ifr_addr.sa_len, sizeof(struct sockaddr)) |
|
1151 |
- #else |
|
1152 |
- ( (ifr.ifr_addr.sa_family==AF_INET)? |
|
1153 |
- sizeof(struct sockaddr_in): |
|
1154 |
- ((ifr.ifr_addr.sa_family==AF_INET6)? |
|
1155 |
- sizeof(struct sockaddr_in6):sizeof(struct sockaddr)) ) |
|
1156 |
- #endif |
|
1157 |
- ) |
|
1158 |
- ) |
|
1159 |
- { |
|
1160 |
- /* copy contents into ifr structure |
|
1161 |
- * warning: it might be longer (e.g. ipv6 address) */ |
|
1162 |
- memcpy(&ifr, p, sizeof(ifr)); |
|
1163 |
- if (ifr.ifr_addr.sa_family!=family){ |
|
1164 |
- /*printf("strange family %d skipping...\n", |
|
1165 |
- ifr->ifr_addr.sa_family);*/ |
|
1166 |
- continue; |
|
1167 |
- } |
|
1168 |
- |
|
1169 |
- /*get flags*/ |
|
1170 |
- ifrcopy=ifr; |
|
1171 |
- if (ioctl(s, SIOCGIFFLAGS, &ifrcopy)!=-1){ /* ignore errors */ |
|
1172 |
- /* ignore down ifs only if listening on all of them*/ |
|
1173 |
- if (if_name==0){ |
|
1174 |
- /* if if not up, skip it*/ |
|
1175 |
- if (!(ifrcopy.ifr_flags & IFF_UP)) continue; |
|
1176 |
- } |
|
1177 |
- } |
|
1178 |
- |
|
1179 |
- |
|
1180 |
- |
|
1181 |
- if ((if_name==0)|| |
|
1182 |
- (strncmp(if_name, ifr.ifr_name, sizeof(ifr.ifr_name))==0)){ |
|
1183 |
- |
|
1184 |
- /*add address*/ |
|
1185 |
- if (sock_no<MAX_LISTEN){ |
|
1186 |
- sockaddr2ip_addr(&addr, |
|
1187 |
- (struct sockaddr*)(p+(long)&((struct ifreq*)0)->ifr_addr)); |
|
1188 |
- if ((tmp=ip_addr2a(&addr))==0) goto error; |
|
1189 |
- /* fill the strings*/ |
|
1190 |
- sock_info[sock_no].name.s=(char*)pkg_malloc(strlen(tmp)+1); |
|
1191 |
- if(sock_info[sock_no].name.s==0){ |
|
1192 |
- fprintf(stderr, "Out of memory.\n"); |
|
1193 |
- goto error; |
|
1194 |
- } |
|
1195 |
- /* fill in the new name and port */ |
|
1196 |
- sock_info[sock_no].name.len=strlen(tmp); |
|
1197 |
- strncpy(sock_info[sock_no].name.s, tmp, |
|
1198 |
- sock_info[sock_no].name.len+1); |
|
1199 |
- sock_info[sock_no].port_no=port; |
|
1200 |
- /* mark if loopback */ |
|
1201 |
- if (ifrcopy.ifr_flags & IFF_LOOPBACK) |
|
1202 |
- sock_info[sock_no].is_lo=1; |
|
1203 |
- sock_no++; |
|
1204 |
- ret=0; |
|
1205 |
- }else{ |
|
1206 |
- fprintf(stderr, "Too many addresses (max %d)\n", MAX_LISTEN); |
|
1207 |
- goto error; |
|
1208 |
- } |
|
1209 |
- } |
|
1210 |
- /* |
|
1211 |
- printf("%s:\n", ifr->ifr_name); |
|
1212 |
- printf(" "); |
|
1213 |
- print_sockaddr(&(ifr->ifr_addr)); |
|
1214 |
- printf(" "); |
|
1215 |
- ls_ifflags(ifr->ifr_name, family, options); |
|
1216 |
- printf("\n");*/ |
|
1217 |
- } |
|
1218 |
- pkg_free(ifc.ifc_req); /*clean up*/ |
|
1219 |
- close(s); |
|
1220 |
- return ret; |
|
1221 |
-error: |
|
1222 |
- if (ifc.ifc_req) pkg_free(ifc.ifc_req); |
|
1223 |
- close(s); |
|
1224 |
- return -1; |
|
1225 |
-} |
|
1226 | 1084 |
|
1227 | 1085 |
|
1228 | 1086 |
|
... | ... |
@@ -1230,14 +1088,9 @@ int main(int argc, char** argv) |
1230 | 1088 |
{ |
1231 | 1089 |
|
1232 | 1090 |
FILE* cfg_stream; |
1233 |
- struct hostent* he; |
|
1234 |
- int c,r,t; |
|
1091 |
+ int c,r; |
|
1235 | 1092 |
char *tmp; |
1236 |
- char** h; |
|
1237 |
- struct host_alias* a; |
|
1238 |
- struct utsname myname; |
|
1239 | 1093 |
char *options; |
1240 |
- int len; |
|
1241 | 1094 |
int ret; |
1242 | 1095 |
struct passwd *pw_entry; |
1243 | 1096 |
struct group *gr_entry; |
... | ... |
@@ -1287,9 +1140,7 @@ int main(int argc, char** argv) |
1287 | 1140 |
fprintf(stderr, "bad port number: -p %s\n", optarg); |
1288 | 1141 |
goto error; |
1289 | 1142 |
} |
1290 |
- if (sock_no>0) sock_info[sock_no-1].port_no=port_no; |
|
1291 | 1143 |
break; |
1292 |
- |
|
1293 | 1144 |
case 'm': |
1294 | 1145 |
shm_mem_size=strtol(optarg, &tmp, 10) * 1024 * 1024; |
1295 | 1146 |
if (tmp &&(*tmp)){ |
... | ... |
@@ -1311,23 +1162,8 @@ int main(int argc, char** argv) |
1311 | 1162 |
break; |
1312 | 1163 |
case 'l': |
1313 | 1164 |
/* add a new addr. to our address list */ |
1314 |
- if (sock_no < MAX_LISTEN){ |
|
1315 |
- sock_info[sock_no].name.s= |
|
1316 |
- (char*)pkg_malloc(strlen(optarg)+1); |
|
1317 |
- if (sock_info[sock_no].name.s==0){ |
|
1318 |
- fprintf(stderr, "Out of memory.\n"); |
|
1319 |
- goto error; |
|
1320 |
- } |
|
1321 |
- strncpy(sock_info[sock_no].name.s, optarg, |
|
1322 |
- strlen(optarg)+1); |
|
1323 |
- sock_info[sock_no].name.len=strlen(optarg); |
|
1324 |
- /* set default port */ |
|
1325 |
- sock_info[sock_no].port_no=port_no; |
|
1326 |
- sock_no++; |
|
1327 |
- }else{ |
|
1328 |
- fprintf(stderr, |
|
1329 |
- "Too many addresses (max. %d).\n", |
|
1330 |
- MAX_LISTEN); |
|
1165 |
+ if (add_listen_iface(optarg, 0, 0, 0)!=0){ |
|
1166 |
+ fprintf(stderr, "failed to add new listen address\n"); |
|
1331 | 1167 |
goto error; |
1332 | 1168 |
} |
1333 | 1169 |
break; |
... | ... |
@@ -1534,188 +1370,23 @@ try_again: |
1534 | 1370 |
gid=gr_entry->gr_gid; |
1535 | 1371 |
} |
1536 | 1372 |
} |
1537 |
- |
|
1538 |
- if (sock_no==0) { |
|
1539 |
- /* try to get all listening ipv4 interfaces */ |
|
1540 |
- if (add_interfaces(0, AF_INET, 0)==-1){ |
|
1541 |
- /* if error fall back to get hostname*/ |
|
1542 |
- /* get our address, only the first one */ |
|
1543 |
- if (uname (&myname) <0){ |
|
1544 |
- fprintf(stderr, "cannot determine hostname, try -l address\n"); |
|
1545 |
- goto error; |
|
1546 |
- } |
|
1547 |
- sock_info[sock_no].name.s= |
|
1548 |
- (char*)pkg_malloc(strlen(myname.nodename)+1); |
|
1549 |
- if (sock_info[sock_no].name.s==0){ |
|
1550 |
- fprintf(stderr, "Out of memory.\n"); |
|
1551 |
- goto error; |
|
1552 |
- } |
|
1553 |
- sock_info[sock_no].name.len=strlen(myname.nodename); |
|
1554 |
- strncpy(sock_info[sock_no].name.s, myname.nodename, |
|
1555 |
- sock_info[sock_no].name.len+1); |
|
1556 |
- sock_no++; |
|
1557 |
- } |
|
1558 |
- } |
|
1559 |
- |
|
1560 |
- /* try to change all the interface names into addresses |
|
1561 |
- * --ugly hack */ |
|
1562 |
- for (r=0; r<sock_no;){ |
|
1563 |
- if (add_interfaces(sock_info[r].name.s, AF_INET, |
|
1564 |
- sock_info[r].port_no)!=-1){ |
|
1565 |
- /* success => remove current entry (shift the entire array)*/ |
|
1566 |
- pkg_free(sock_info[r].name.s); |
|
1567 |
- memmove(&sock_info[r], &sock_info[r+1], |
|
1568 |
- (sock_no-r)*sizeof(struct socket_info)); |
|
1569 |
- sock_no--; |
|
1570 |
- continue; |
|
1571 |
- } |
|
1572 |
- r++; |
|
1573 |
- } |
|
1574 |
- /* get ips & fill the port numbers*/ |
|
1575 |
-#ifdef EXTRA_DEBUG |
|
1576 |
- printf("Listening on \n"); |
|
1577 |
-#endif |
|
1578 |
- for (r=0; r<sock_no;r++){ |
|
1579 |
- /* fix port number, port_no should be !=0 here */ |
|
1580 |
- if (sock_info[r].port_no==0) sock_info[r].port_no=port_no; |
|
1581 |
- tmp=int2str(sock_info[r].port_no, &len); |
|
1582 |
- if (len>=MAX_PORT_LEN){ |
|
1583 |
- fprintf(stderr, "ERROR: bad port number: %d\n", |
|
1584 |
- sock_info[r].port_no); |
|
1585 |
- goto error; |
|
1586 |
- } |
|
1587 |
- sock_info[r].port_no_str.s=(char*)pkg_malloc(len+1); |
|
1588 |
- if (sock_info[r].port_no_str.s==0){ |
|
1589 |
- fprintf(stderr, "Out of memory.\n"); |
|
1590 |
- goto error; |
|
1591 |
- } |
|
1592 |
- strncpy(sock_info[r].port_no_str.s, tmp, len+1); |
|
1593 |
- sock_info[r].port_no_str.len=len; |
|
1594 |
- |
|
1595 |
- /* get "official hostnames", all the aliases etc. */ |
|
1596 |
- he=resolvehost(sock_info[r].name.s); |
|
1597 |
- if (he==0){ |
|
1598 |
- DPrint("ERROR: could not resolve %s\n", sock_info[r].name.s); |
|
1599 |
- goto error; |
|
1600 |
- } |
|
1601 |
- /* check if we got the official name */ |
|
1602 |
- if (strcasecmp(he->h_name, sock_info[r].name.s)!=0){ |
|
1603 |
- if (add_alias(sock_info[r].name.s, sock_info[r].name.len, |
|
1604 |
- sock_info[r].port_no, 0)<0){ |
|
1605 |
- LOG(L_ERR, "ERROR: main: add_alias failed\n"); |
|
1606 |
- } |
|
1607 |
- /* change the oficial name */ |
|
1608 |
- pkg_free(sock_info[r].name.s); |
|
1609 |
- sock_info[r].name.s=(char*)pkg_malloc(strlen(he->h_name)+1); |
|
1610 |
- if (sock_info[r].name.s==0){ |
|
1611 |
- fprintf(stderr, "Out of memory.\n"); |
|
1612 |
- goto error; |
|
1613 |
- } |
|
1614 |
- sock_info[r].name.len=strlen(he->h_name); |
|
1615 |
- strncpy(sock_info[r].name.s, he->h_name, sock_info[r].name.len+1); |
|
1616 |
- } |
|
1617 |
- /* add the aliases*/ |
|
1618 |
- for(h=he->h_aliases; h && *h; h++) |
|
1619 |
- if (add_alias(*h, strlen(*h), sock_info[r].port_no, 0)<0){ |
|
1620 |
- LOG(L_ERR, "ERROR: main: add_alias failed\n"); |
|
1621 |
- } |
|
1622 |
- hostent2ip_addr(&sock_info[r].address, he, 0); /*convert to ip_addr |
|
1623 |
- format*/ |
|
1624 |
- if ((tmp=ip_addr2a(&sock_info[r].address))==0) goto error; |
|
1625 |
- sock_info[r].address_str.s=(char*)pkg_malloc(strlen(tmp)+1); |
|
1626 |
- if (sock_info[r].address_str.s==0){ |
|
1627 |
- fprintf(stderr, "Out of memory.\n"); |
|
1628 |
- goto error; |
|
1629 |
- } |
|
1630 |
- strncpy(sock_info[r].address_str.s, tmp, strlen(tmp)+1); |
|
1631 |
- /* set is_ip (1 if name is an ip address, 0 otherwise) */ |
|
1632 |
- sock_info[r].address_str.len=strlen(tmp); |
|
1633 |
- if ( (sock_info[r].address_str.len==sock_info[r].name.len)&& |
|
1634 |
- (strncasecmp(sock_info[r].address_str.s, sock_info[r].name.s, |
|
1635 |
- sock_info[r].address_str.len)==0) |
|
1636 |
- ){ |
|
1637 |
- sock_info[r].is_ip=1; |
|
1638 |
- /* do rev. dns on it (for aliases)*/ |
|
1639 |
- he=rev_resolvehost(&sock_info[r].address); |
|
1640 |
- if (he==0){ |
|
1641 |
- DPrint("WARNING: could not rev. resolve %s\n", |
|
1642 |
- sock_info[r].name.s); |
|
1643 |
- }else{ |
|
1644 |
- /* add the aliases*/ |
|
1645 |
- if (add_alias(he->h_name, strlen(he->h_name), |
|
1646 |
- sock_info[r].port_no, 0)<0){ |
|
1647 |
- LOG(L_ERR, "ERROR: main: add_alias failed\n"); |
|
1648 |
- } |
|
1649 |
- for(h=he->h_aliases; h && *h; h++) |
|
1650 |
- if (add_alias(*h,strlen(*h),sock_info[r].port_no,0)<0){ |
|
1651 |
- LOG(L_ERR, "ERROR: main: add_alias failed\n"); |
|
1652 |
- } |
|
1653 |
- } |
|
1654 |
- }else{ sock_info[r].is_ip=0; }; |
|
1655 |
- |
|
1656 |
-#ifdef EXTRA_DEBUG |
|
1657 |
- printf(" %.*s [%s]:%s\n", sock_info[r].name.len, |
|
1658 |
- sock_info[r].name.s, |
|
1659 |
- sock_info[r].address_str.s, sock_info[r].port_no_str.s); |
|
1660 |
-#endif |
|
1661 |
- } |
|
1662 |
- /* removing duplicate addresses*/ |
|
1663 |
- for (r=0; r<sock_no; r++){ |
|
1664 |
- for (t=r+1; t<sock_no;){ |
|
1665 |
- if ((sock_info[r].port_no==sock_info[t].port_no) && |
|
1666 |
- (sock_info[r].address.af==sock_info[t].address.af) && |
|
1667 |
- (memcmp(sock_info[r].address.u.addr, |
|
1668 |
- sock_info[t].address.u.addr, |
|
1669 |
- sock_info[r].address.len) == 0) |
|
1670 |
- ){ |
|
1671 |
-#ifdef EXTRA_DEBUG |
|
1672 |
- printf("removing duplicate (%d) %s [%s] == (%d) %s [%s]\n", |
|
1673 |
- r, sock_info[r].name.s, sock_info[r].address_str.s, |
|
1674 |
- t, sock_info[t].name.s, sock_info[t].address_str.s); |
|
1675 |
-#endif |
|
1676 |
- /* add the name to the alias list*/ |
|
1677 |
- if ((!sock_info[t].is_ip) && ( |
|
1678 |
- (sock_info[t].name.len!=sock_info[r].name.len)|| |
|
1679 |
- (strncmp(sock_info[t].name.s, sock_info[r].name.s, |
|
1680 |
- sock_info[r].name.len)!=0)) |
|
1681 |
- ) |
|
1682 |
- add_alias(sock_info[t].name.s, sock_info[t].name.len, |
|
1683 |
- sock_info[t].port_no, 0); |
|
1684 |
- |
|
1685 |
- /* free space*/ |
|
1686 |
- pkg_free(sock_info[t].name.s); |
|
1687 |
- pkg_free(sock_info[t].address_str.s); |
|
1688 |
- pkg_free(sock_info[t].port_no_str.s); |
|
1689 |
- /* shift the array*/ |
|
1690 |
- memmove(&sock_info[t], &sock_info[t+1], |
|
1691 |
- (sock_no-t)*sizeof(struct socket_info)); |
|
1692 |
- sock_no--; |
|
1693 |
- continue; |
|
1694 |
- } |
|
1695 |
- t++; |
|
1696 |
- } |
|
1373 |
+ |
|
1374 |
+ if (fix_all_socket_lists()!=0){ |
|
1375 |
+ fprintf(stderr, "failed to initialize liste addresses\n"); |
|
1376 |
+ goto error; |
|
1697 | 1377 |
} |
1698 | 1378 |
/* print all the listen addresses */ |
1699 | 1379 |
printf("Listening on \n"); |
1700 |
- for (r=0; r<sock_no; r++) |
|
1701 |
- printf(" %s [%s]:%s\n",sock_info[r].name.s, |
|
1702 |
- sock_info[r].address_str.s, sock_info[r].port_no_str.s); |
|
1703 |
- |
|
1704 |
- printf("Aliases: "); |
|
1705 |
- for(a=aliases; a; a=a->next) |
|
1706 |
- if (a->port) |
|
1707 |
- printf("%.*s:%d ", a->alias.len, a->alias.s, a->port); |
|
1708 |
- else |
|
1709 |
- printf("%.*s:* ", a->alias.len, a->alias.s); |
|
1380 |
+ print_all_socket_lists(); |
|
1381 |
+ printf("Aliases: \n"); |
|
1382 |
+ /*print_aliases();*/ |
|
1383 |
+ print_aliases(); |
|
1710 | 1384 |
printf("\n"); |
1711 |
- if (sock_no==0){ |
|
1712 |
- fprintf(stderr, "ERROR: no listening sockets"); |
|
1713 |
- goto error; |
|
1714 |
- } |
|
1385 |
+ |
|
1715 | 1386 |
if (dont_fork){ |
1716 | 1387 |
fprintf(stderr, "WARNING: no fork mode %s\n", |
1717 |
- (sock_no>1)?" and more than one listen address found (will" |
|
1718 |
- " use only the the first one)":""); |
|
1388 |
+ (udp_listen->next)?" and more than one listen address found" |
|
1389 |
+ "(will use only the the first one)":""); |
|
1719 | 1390 |
} |
1720 | 1391 |
if (config_check){ |
1721 | 1392 |
fprintf(stderr, "config file ok, exiting...\n"); |
... | ... |
@@ -123,9 +123,9 @@ |
123 | 123 |
# include <stdlib.h> |
124 | 124 |
# define pkg_malloc(s) \ |
125 | 125 |
( { void *v; v=malloc((s)); \ |
126 |
- DBG("malloc %x size %d end %x\n", v, s, (unsigned int)v+(s));\ |
|
126 |
+ DBG("malloc %p size %d end %p\n", v, s, (char*)v+(s));\ |
|
127 | 127 |
v; } ) |
128 |
-# define pkg_free(p) do{ DBG("free %x\n", (p)); free((p)); }while(0); |
|
128 |
+# define pkg_free(p) do{ DBG("free %p\n", (p)); free((p)); }while(0); |
|
129 | 129 |
# define pkg_status() |
130 | 130 |
#endif |
131 | 131 |
|
... | ... |
@@ -28,13 +28,15 @@ |
28 | 28 |
* |
29 | 29 |
* History: |
30 | 30 |
* ---------- |
31 |
- * 2003-04-09 Created by janakj |
|
31 |
+ * 2003-04-09 Created by janakj |
|
32 |
+ * 2003-10-24 updated to the new socket_info lists (andrei) |
|
32 | 33 |
*/ |
33 | 34 |
|
34 | 35 |
#include <stdio.h> |
35 | 36 |
#include <stdlib.h> |
36 | 37 |
#include "../../dprint.h" |
37 | 38 |
#include "../../pt.h" |
39 |
+#include "../../socket_info.h" |
|
38 | 40 |
#include "callid.h" |
39 | 41 |
|
40 | 42 |
#define CALLID_NR_LEN 20 |
... | ... |
@@ -106,12 +108,21 @@ int init_callid(void) |
106 | 108 |
*/ |
107 | 109 |
int child_init_callid(int rank) |
108 | 110 |
{ |
111 |
+ struct socket_info *si; |
|
112 |
+ |
|
113 |
+ /* on tcp/tls bind_address is 0 so try to get the first address we listen |
|
114 |
+ * on no matter the protocol */ |
|
115 |
+ si=bind_address?bind_address:get_first_socket(); |
|
116 |
+ if (si==0){ |
|
117 |
+ LOG(L_CRIT, "BUG: child_init_callid: null socket list\n"); |
|
118 |
+ return -1; |
|
119 |
+ } |
|
109 | 120 |
callid_suffix.s = callid_buf + callid_prefix.len; |
110 | 121 |
|
111 | 122 |
callid_suffix.len = snprintf(callid_suffix.s, CALLID_SUFFIX_LEN, |
112 | 123 |
"%c%d@%.*s", CID_SEP, my_pid(), |
113 |
- sock_info[bind_idx].address_str.len, |
|
114 |
- sock_info[bind_idx].address_str.s); |
|
124 |
+ si->address_str.len, |
|
125 |
+ si->address_str.s); |
|
115 | 126 |
if ((callid_suffix.len == -1) || (callid_suffix.len > CALLID_SUFFIX_LEN)) { |
116 | 127 |
LOG(L_ERR, "ERROR: child_init_callid: buffer too small\n"); |
117 | 128 |
return -1; |
... | ... |
@@ -44,6 +44,7 @@ |
44 | 44 |
* 2003-04-02 port_no_str does not contain a leading ':' anymore (andrei) |
45 | 45 |
* 2003-07-08 appropriate log messages in check_params(...), |
46 | 46 |
* call calculate_hooks if next_hop==NULL in t_uac (dcm) |
47 |
+ * 2003-10-24 updated to the new socket_info lists (andrei) |
|
47 | 48 |
*/ |
48 | 49 |
|
49 | 50 |
#include <string.h> |
... | ... |
@@ -53,6 +54,7 @@ |
53 | 54 |
#include "../../md5.h" |
54 | 55 |
#include "../../crc.h" |
55 | 56 |
#include "../../ip_addr.h" |
57 |
+#include "../../socket_info.h" |
|
56 | 58 |
#include "ut.h" |
57 | 59 |
#include "h_table.h" |
58 | 60 |
#include "t_hooks.h" |
... | ... |
@@ -75,18 +77,26 @@ char* uac_from = "sip:foo@foo.bar"; /* Module parameter */ |
75 | 77 |
int uac_init(void) |
76 | 78 |
{ |
77 | 79 |
str src[3]; |
80 |
+ struct socket_info *si; |
|
78 | 81 |
|
79 | 82 |
if (RAND_MAX < TABLE_ENTRIES) { |
80 | 83 |
LOG(L_WARN, "Warning: uac does not spread " |
81 | 84 |
"accross the whole hash table\n"); |
82 | 85 |
} |
86 |
+ /* on tcp/tls bind_address is 0 so try to get the first address we listen |
|
87 |
+ * on no matter the protocol */ |
|
88 |
+ si=bind_address?bind_address:get_first_socket(); |
|
89 |
+ if (si==0){ |
|
90 |
+ LOG(L_CRIT, "BUG: child_init_callid: null socket list\n"); |
|
91 |
+ return -1; |
|
92 |
+ } |
|
83 | 93 |
|
84 | 94 |
/* calculate the initial From tag */ |
85 | 95 |
src[0].s = "Long live SER server"; |
86 | 96 |
src[0].len = strlen(src[0].s); |
87 |
- src[1].s = sock_info[bind_idx].address_str.s; |
|
97 |
+ src[1].s = si->address_str.s; |
|
88 | 98 |
src[1].len = strlen(src[1].s); |
89 |
- src[2].s = sock_info[bind_idx].port_no_str.s; |
|
99 |
+ src[2].s = si->port_no_str.s; |
|
90 | 100 |
src[2].len = strlen(src[2].s); |
91 | 101 |
|
92 | 102 |
MDStringArray(from_tag, src, 3); |
... | ... |
@@ -43,6 +43,7 @@ |
43 | 43 |
|
44 | 44 |
#include "globals.h" |
45 | 45 |
#include "timer.h" |
46 |
+#include "socket_info.h" |
|
46 | 47 |
|
47 | 48 |
#define MAX_PT_DESC 128 |
48 | 49 |
|
... | ... |
@@ -63,9 +64,13 @@ extern int process_no; |
63 | 64 |
*/ |
64 | 65 |
inline static int process_count() |
65 | 66 |
{ |
67 |
+ int udp_listeners; |
|
68 |
+ struct socket_info* si; |
|
69 |
+ |
|
70 |
+ for (si=udp_listen, udp_listeners=0; si; si=si->next, udp_listeners++); |
|
66 | 71 |
return |
67 | 72 |
/* receivers and attendant */ |
68 |
- (dont_fork ? 1 : children_no*sock_no + 1) |
|
73 |
+ (dont_fork ? 1 : children_no*udp_listeners + 1) |
|
69 | 74 |
/* timer process */ |
70 | 75 |
+ (timer_list ? 1 : 0 ) |
71 | 76 |
/* fifo server */ |
... | ... |
@@ -284,8 +284,10 @@ static inline struct hostent* resolvehost(char* name) |
284 | 284 |
static struct hostent* he2=0; |
285 | 285 |
#endif |
286 | 286 |
#ifndef DNS_IP_HACK |
287 |
+#ifdef USE_IPV6 |
|
287 | 288 |
int len; |
288 | 289 |
#endif |
290 |
+#endif |
|
289 | 291 |
#ifdef DNS_IP_HACK |
290 | 292 |
struct ip_addr* ip; |
291 | 293 |
str s; |
... | ... |
@@ -304,6 +306,7 @@ static inline struct hostent* resolvehost(char* name) |
304 | 306 |
} |
305 | 307 |
|
306 | 308 |
#else /* DNS_IP_HACK */ |
309 |
+#ifdef USE_IPV6 |
|
307 | 310 |
len=0; |
308 | 311 |
if (*name=='['){ |
309 | 312 |
len=strlen(name); |
... | ... |
@@ -313,6 +316,7 @@ static inline struct hostent* resolvehost(char* name) |
313 | 316 |
goto skip_ipv4; |
314 | 317 |
} |
315 | 318 |
} |
319 |
+#endif |
|
316 | 320 |
#endif |
317 | 321 |
/* ipv4 */ |
318 | 322 |
he=gethostbyname(name); |
... | ... |
@@ -48,6 +48,7 @@ |
48 | 48 |
#include "globals.h" |
49 | 49 |
#include "crc.h" |
50 | 50 |
#include "str.h" |
51 |
+#include "socket_info.h" |
|
51 | 52 |
|
52 | 53 |
#define TOTAG_VALUE_LEN (MD5_LEN+CRC16_LEN+1) |
53 | 54 |
|
... | ... |
@@ -71,12 +72,15 @@ static void inline init_tags( char *tag, char **suffix, |
71 | 72 |
char *signature, char separator ) |
72 | 73 |
{ |
73 | 74 |
str src[3]; |
74 |
- |
|
75 |
+ struct socket_info* si; |
|
76 |
+ |
|
77 |
+ si=get_first_socket(); |
|
75 | 78 |
src[0].s=signature; src[0].len=strlen(signature); |
76 |
- src[1].s=sock_info[0].address_str.s; |
|
77 |
- src[1].len=sock_info[0].address_str.len; |
|
78 |
- src[2].s=sock_info[0].port_no_str.s; |
|
79 |
- src[2].len=sock_info[0].port_no_str.len; |
|
79 |
+ /* if we are not listening on anything we shouldn't be here */ |
|
80 |
+ src[1].s=si?si->address_str.s:""; |
|
81 |
+ src[1].len=si?si->address_str.len:0; |
|
82 |
+ src[2].s=si?si->port_no_str.s:""; |
|
83 |
+ src[2].len=si?si->port_no_str.len:0; |
|
80 | 84 |
|
81 | 85 |
MDStringArray( tag, src, 3 ); |
82 | 86 |
|
... | ... |
@@ -42,6 +42,7 @@ |
42 | 42 |
* 2003-06-30 moved tcp new connect checking & handling to |
43 | 43 |
* handle_new_connect (andrei) |
44 | 44 |
* 2003-07-09 tls_close called before closing the tcp connection (andrei) |
45 |
+ * 2003-10-24 converted to the new socket_info lists (andrei) |
|
45 | 46 |
*/ |
46 | 47 |
|
47 | 48 |
|
... | ... |
@@ -181,14 +182,14 @@ error: |
181 | 182 |
|
182 | 183 |
struct socket_info* find_tcp_si(union sockaddr_union* s) |
183 | 184 |
{ |
184 |
- int r; |
|
185 | 185 |
struct ip_addr ip; |
186 |
+ struct socket_info* si; |
|
186 | 187 |
|
187 | 188 |
su2ip_addr(&ip, s); |
188 |
- for (r=0; r<sock_no; r++) |
|
189 |
- if (ip_addr_cmp(&ip, &tcp_info[r].address)){ |
|
189 |
+ for (si=tcp_listen; si; si=si->next) |
|
190 |
+ if (ip_addr_cmp(&ip, &si->address)){ |
|
190 | 191 |
/* found it, we use first match */ |
191 |
- return &tcp_info[r]; |
|
192 |
+ return si; |
|
192 | 193 |
} |
193 | 194 |
return 0; /* no match */ |
194 | 195 |
} |
... | ... |
@@ -728,24 +729,31 @@ void tcp_main_loop() |
728 | 729 |
int bytes; |
729 | 730 |
struct timeval timeout; |
730 | 731 |
int fd; |
732 |
+ struct socket_info* si; |
|
731 | 733 |
|
732 | 734 |
/*init */ |
733 | 735 |
maxfd=0; |
734 | 736 |
FD_ZERO(&master_set); |
735 | 737 |
/* set all the listen addresses */ |
736 |
- for (r=0; r<sock_no; r++){ |
|
737 |
- if ((tcp_info[r].proto==PROTO_TCP) &&(tcp_info[r].socket!=-1)){ |
|
738 |
- FD_SET(tcp_info[r].socket, &master_set); |
|
739 |
- if (tcp_info[r].socket>maxfd) maxfd=tcp_info[r].socket; |
|
738 |
+ for (si=tcp_listen; si; si=si->next){ |
|
739 |
+ if ((si->proto==PROTO_TCP) &&(si->socket!=-1)){ |
|
740 |
+ FD_SET(si->socket, &master_set); |
|
741 |
+ if (si->socket>maxfd) maxfd=si->socket; |
|
742 |
+ }else{ |
|
743 |
+ LOG(L_CRIT, "BUG: tcp_main_loop: non tcp address in tcp_listen\n"); |
|
740 | 744 |
} |
745 |
+ } |
|
741 | 746 |
#ifdef USE_TLS |
742 |
- if ((!tls_disable)&&(tls_info[r].proto==PROTO_TLS) && |
|
743 |
- (tls_info[r].socket!=-1)){ |
|
744 |
- FD_SET(tls_info[r].socket, &master_set); |
|
745 |
- if (tls_info[r].socket>maxfd) maxfd=tls_info[r].socket; |
|
747 |
+ if (!tls_disable){ |
|
748 |
+ for (si=tls_listen; si; si=si->next){ |
|
749 |
+ if ((si->proto==PROTO_TLS) && (si->socket!=-1)){ |
|
750 |
+ FD_SET(si->socket, &master_set); |
|
751 |
+ if (si->socket>maxfd) maxfd=si->socket; |
|
752 |
+ }else{ |
|
753 |
+ LOG(L_CRIT, "BUG: tcp_main_loop: non tls address in tls_listen\n"); |
|
746 | 754 |
} |
747 |
-#endif |
|
748 | 755 |
} |
756 |
+#endif |
|
749 | 757 |
/* set all the unix sockets used for child comm */ |
750 | 758 |
for (r=1; r<process_no; r++){ |
751 | 759 |
if (pt[r].unix_sock>0){ /* we can't have 0, we never close it!*/ |
... | ... |
@@ -770,13 +778,13 @@ void tcp_main_loop() |
770 | 778 |
n=0; |
771 | 779 |
} |
772 | 780 |
|
773 |
- for (r=0; r<sock_no && n; r++){ |
|
774 |
- handle_new_connect(&tcp_info[r], &sel_set, &n); |
|
781 |
+ for (si=tcp_listen; si && n; si=si->next) |
|
782 |
+ handle_new_connect(si, &sel_set, &n); |
|
775 | 783 |
#ifdef USE_TLS |
776 | 784 |
if (!tls_disable) |
777 |
- handle_new_connect(&tls_info[r], &sel_set, &n); |
|
785 |
+ for (si=tls_listen; si && n; si=si->next) |
|
786 |
+ handle_new_connect(si, &sel_set, &n); |
|
778 | 787 |
#endif |
779 |
- } |
|
780 | 788 |
|
781 | 789 |
/* check all the read fds (from the tcpconn_addr_hash ) */ |
782 | 790 |
for (h=0; h<TCP_ADDR_HASH_SIZE; h++){ |
... | ... |
@@ -1063,7 +1071,6 @@ int tcp_init_children() |
1063 | 1071 |
unix_tcp_sock=sockfd[1]; |
1064 | 1072 |
bind_address=0; /* force a SEGFAULT if someone uses a non-init. |
1065 | 1073 |
bind address on tcp */ |
1066 |
- bind_idx=0; |
|
1067 | 1074 |
if (init_child(r+children_no+1) < 0) { |
1068 | 1075 |
LOG(L_ERR, "init_children failed\n"); |
1069 | 1076 |
goto error; |
... | ... |
@@ -1,29 +1,41 @@ |
1 |
-debug=9 # debug level (cmd line: -dddddddddd) |
|
2 |
-check_via=1 # (cmd. line: -v) |
|
3 |
-dns=on # (cmd. line: -r) |
|
4 |
-rev_dns=yes # (cmd. line: -R) |
|
5 |
-fork=no # (cmd. line: -D) |
|
6 |
-log_stderror=yes # (cmd line: -E) |
|
7 |
-# for more info: sip_router -h |
|
1 |
+# |
|
2 |
+# configuration for stress testing |
|
3 |
+# |
|
4 |
+# $ID: $ |
|
5 |
+# |
|
8 | 6 |
|
9 |
-route{ |
|
10 | 7 |
|
11 |
- (src_ip=~'(dorian)|(ekina)|(terix)' & method=~'^inv') \ |
|
12 |
- forward(centauri.fokus.gmd.de); |
|
13 |
- src_ip=~"^192\.168\.[0-9]{1,3}\.[0-9]{1,3}$" \ |
|
14 |
- log(1,"msg. from a private network\n"); route(1); |
|
15 |
- src_ip==0.0.0.0/0 setuserpass("andrei:test"); log(1, " test msg\n"); forward(192.168.46.55);setuser("foo");sethostport("bar.com:6000");forward(192.168.46.69);drop; |
|
16 |
-} |
|
8 |
+#debug=9 # debug level (cmd line: -dddddddddd) |
|
9 |
+#fork=yes # (cmd. line: -D) |
|
10 |
+#log_stderror=yes # (cmd line: -E) |
|
11 |
+#log_stderror=no # (cmd line: -E) |
|
17 | 12 |
|
18 |
-route[1]{ |
|
19 |
- src_ip==192.168.46.61 log("possible loop, dropping\n"); drop; |
|
20 |
- (src_ip==192.168.46.0/24) log("routing with rt2\n");route(2); log("we're back\n"); |
|
21 |
- src_ip==0.0.0.0/0 log(1, "we'll drop this one too\n"); drop; |
|
22 |
-} |
|
23 | 13 |
|
24 |
-route[2]{ |
|
25 |
- (method=~'^ACK' and uri=~'.*fokus') forward("fox.iptel.org"); |
|
26 |
- ! method=~'^INV' forward(193.175.135.179); /* dorian */ |
|
27 |
- method=~'.' log("spying...\n"); send(dorian,8000); \ |
|
28 |
- forward("fox.iptel.org"); |
|
14 |
+#children=2 |
|
15 |
+check_via=no # (cmd. line: -v) |
|
16 |
+dns=off # (cmd. line: -r) |
|
17 |
+rev_dns=off # (cmd. line: -R) |
|
18 |
+#port=5070 |
|
19 |
+#listen=10.0.0.179 lo dorian |
|
20 |
+#listen=eth0 |
|
21 |
+#listen=127.0.0.1 |
|
22 |
+#listen=192.168.57.33 |
|
23 |
+#listen=192.168.57.72 |
|
24 |
+#loop_checks=0 |
|
25 |
+# for more info: sip_router -h |
|
26 |
+alias=iptel.org |
|
27 |
+alias="foo.bar" |
|
28 |
+fifo="/tmp/ser_fifo" |
|
29 |
+listen= tcp:10.0.0.179:5065 |
|
30 |
+alias= tcp:all:5065 |
|
31 |
+ |
|
32 |
+#modules |
|
33 |
+ |
|
34 |
+ |
|
35 |
+route{ |
|
36 |
+ if (myself==uri){ |
|
37 |
+ log("\n\nfrom myself\n\n"); |
|
38 |
+ }; |
|
39 |
+ log(" continue \n\n"); |
|
40 |
+ forward(uri:host, uri:port); |
|
29 | 41 |
} |