- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,597 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
3 |
- * |
|
4 |
- * This file is part of Kamailio, a free SIP server. |
|
5 |
- * |
|
6 |
- * Kamailio is free software; you can redistribute it and/or modify |
|
7 |
- * it under the terms of the GNU General Public License as published by |
|
8 |
- * the Free Software Foundation; either version 2 of the License, or |
|
9 |
- * (at your option) any later version |
|
10 |
- * |
|
11 |
- * Kamailio is distributed in the hope that it will be useful, |
|
12 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
- * GNU General Public License for more details. |
|
15 |
- * |
|
16 |
- * You should have received a copy of the GNU General Public License |
|
17 |
- * along with this program; if not, write to the Free Software |
|
18 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
- * |
|
20 |
- */ |
|
21 |
- |
|
22 |
- |
|
23 |
-/** Kamailio core :: udp send and loop-receive functions. |
|
24 |
- * @file udp_server.c |
|
25 |
- * @ingroup core |
|
26 |
- * Module: @ref core |
|
27 |
- */ |
|
28 |
- |
|
29 |
-#include <stdlib.h> |
|
30 |
-#include <string.h> |
|
31 |
-#include <sys/types.h> |
|
32 |
-#include <sys/socket.h> |
|
33 |
-#include <netinet/in.h> |
|
34 |
-#include <netinet/in_systm.h> |
|
35 |
-#include <netinet/ip.h> |
|
36 |
-#include <errno.h> |
|
37 |
-#include <arpa/inet.h> |
|
38 |
-#ifdef __linux__ |
|
39 |
- #include <linux/types.h> |
|
40 |
- #include <linux/errqueue.h> |
|
41 |
-#endif |
|
42 |
- |
|
43 |
- |
|
44 |
-#include "udp_server.h" |
|
45 |
-#include "compiler_opt.h" |
|
46 |
-#include "globals.h" |
|
47 |
-#include "config.h" |
|
48 |
-#include "dprint.h" |
|
49 |
-#include "receive.h" |
|
50 |
-#include "mem/mem.h" |
|
51 |
-#include "ip_addr.h" |
|
52 |
-#include "cfg/cfg_struct.h" |
|
53 |
-#include "events.h" |
|
54 |
-#include "stun.h" |
|
55 |
-#ifdef USE_RAW_SOCKS |
|
56 |
-#include "raw_sock.h" |
|
57 |
-#endif /* USE_RAW_SOCKS */ |
|
58 |
-#ifdef USE_MCAST |
|
59 |
-#include <net/if.h> |
|
60 |
-#endif /* USE_MCAST */ |
|
61 |
- |
|
62 |
- |
|
63 |
-#ifdef DBG_MSG_QA |
|
64 |
-/* message quality assurance -- frequently, bugs in ser have |
|
65 |
- been indicated by zero characters or long whitespaces |
|
66 |
- in generated messages; this debugging option aborts if |
|
67 |
- any such message is sighted |
|
68 |
-*/ |
|
69 |
-static int dbg_msg_qa(char *buf, int len) |
|
70 |
-{ |
|
71 |
-#define _DBG_WS_LEN 3 |
|
72 |
-#define _DBG_WS " " |
|
73 |
- |
|
74 |
- char *scan; |
|
75 |
- int my_len; |
|
76 |
- int space_cnt; |
|
77 |
- enum { QA_ANY, QA_SPACE, QA_EOL1 } state; |
|
78 |
- |
|
79 |
- |
|
80 |
- /* is there a zero character in there ? */ |
|
81 |
- if (memchr(buf, 0, len)) { |
|
82 |
- LM_CRIT("message with 0 in it\n"); |
|
83 |
- return 0; |
|
84 |
- } |
|
85 |
- |
|
86 |
- my_len=len; |
|
87 |
- scan=buf; |
|
88 |
- state=QA_ANY; |
|
89 |
- space_cnt=0; |
|
90 |
- |
|
91 |
- while(my_len) { |
|
92 |
- switch(*scan) { |
|
93 |
- case ' ': if (state==QA_SPACE) { |
|
94 |
- space_cnt++; |
|
95 |
- if (space_cnt==4) { |
|
96 |
- LM_CRIT("too many spaces\n"); |
|
97 |
- return 0; |
|
98 |
- } |
|
99 |
- } else space_cnt=0; |
|
100 |
- state=QA_SPACE; |
|
101 |
- break; |
|
102 |
- |
|
103 |
- case '\r': /* ignore */ |
|
104 |
- space_cnt=0; |
|
105 |
- break; |
|
106 |
- |
|
107 |
- case '\n': /* don't proceed to body on EoH */ |
|
108 |
- if (state==QA_EOL1) goto qa_passed; |
|
109 |
- space_cnt=0; |
|
110 |
- state=QA_EOL1; |
|
111 |
- break; |
|
112 |
- |
|
113 |
- default: space_cnt=0; |
|
114 |
- state=QA_ANY; |
|
115 |
- break; |
|
116 |
- } |
|
117 |
- scan++; |
|
118 |
- my_len--; |
|
119 |
- } |
|
120 |
- |
|
121 |
- |
|
122 |
-qa_passed: |
|
123 |
- return 1; |
|
124 |
-} |
|
125 |
- |
|
126 |
-#endif |
|
127 |
- |
|
128 |
- |
|
129 |
-int probe_max_receive_buffer( int udp_sock ) |
|
130 |
-{ |
|
131 |
- int optval; |
|
132 |
- int ioptval; |
|
133 |
- unsigned int ioptvallen; |
|
134 |
- int foptval; |
|
135 |
- unsigned int foptvallen; |
|
136 |
- int voptval; |
|
137 |
- unsigned int voptvallen; |
|
138 |
- int phase=0; |
|
139 |
- |
|
140 |
- /* jku: try to increase buffer size as much as we can */ |
|
141 |
- ioptvallen=sizeof(ioptval); |
|
142 |
- if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &ioptval, |
|
143 |
- &ioptvallen) == -1 ) |
|
144 |
- { |
|
145 |
- LM_ERR("getsockopt: %s\n", strerror(errno)); |
|
146 |
- return -1; |
|
147 |
- } |
|
148 |
- if ( ioptval==0 ) |
|
149 |
- { |
|
150 |
- LM_DBG("SO_RCVBUF initially set to 0; resetting to %d\n", |
|
151 |
- BUFFER_INCREMENT ); |
|
152 |
- ioptval=BUFFER_INCREMENT; |
|
153 |
- } else LM_INFO("SO_RCVBUF is initially %d\n", ioptval ); |
|
154 |
- for (optval=ioptval; ; ) { |
|
155 |
- /* increase size; double in initial phase, add linearly later */ |
|
156 |
- if (phase==0) optval <<= 1; else optval+=BUFFER_INCREMENT; |
|
157 |
- if (optval > maxbuffer){ |
|
158 |
- if (phase==1) break; |
|
159 |
- else { phase=1; optval >>=1; continue; } |
|
160 |
- } |
|
161 |
- LM_DBG("trying SO_RCVBUF: %d\n", optval ); |
|
162 |
- if (setsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, |
|
163 |
- (void*)&optval, sizeof(optval)) ==-1){ |
|
164 |
- /* Solaris returns -1 if asked size too big; Linux ignores */ |
|
165 |
- LM_DBG("SOL_SOCKET failed for %d, phase %d: %s\n", optval, phase, strerror(errno)); |
|
166 |
- /* if setting buffer size failed and still in the aggressive |
|
167 |
- phase, try less aggressively; otherwise give up |
|
168 |
- */ |
|
169 |
- if (phase==0) { phase=1; optval >>=1 ; continue; } |
|
170 |
- else break; |
|
171 |
- } |
|
172 |
- /* verify if change has taken effect */ |
|
173 |
- /* Linux note -- otherwise I would never know that; funny thing: Linux |
|
174 |
- doubles size for which we asked in setsockopt |
|
175 |
- */ |
|
176 |
- voptvallen=sizeof(voptval); |
|
177 |
- if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &voptval, |
|
178 |
- &voptvallen) == -1 ) |
|
179 |
- { |
|
180 |
- LM_ERR("getsockopt: %s\n", strerror(errno)); |
|
181 |
- return -1; |
|
182 |
- } else { |
|
183 |
- LM_DBG("setting SO_RCVBUF; set=%d,verify=%d\n", |
|
184 |
- optval, voptval); |
|
185 |
- if (voptval<optval) { |
|
186 |
- LM_DBG("setting SO_RCVBUF has no effect\n"); |
|
187 |
- /* if setting buffer size failed and still in the aggressive |
|
188 |
- phase, try less aggressively; otherwise give up |
|
189 |
- */ |
|
190 |
- if (phase==0) { phase=1; optval >>=1 ; continue; } |
|
191 |
- else break; |
|
192 |
- } |
|
193 |
- } |
|
194 |
- |
|
195 |
- } /* for ... */ |
|
196 |
- foptvallen=sizeof(foptval); |
|
197 |
- if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &foptval, |
|
198 |
- &foptvallen) == -1 ) |
|
199 |
- { |
|
200 |
- LM_ERR("getsockopt: %s\n", strerror(errno)); |
|
201 |
- return -1; |
|
202 |
- } |
|
203 |
- LM_INFO("SO_RCVBUF is finally %d\n", foptval ); |
|
204 |
- |
|
205 |
- return 0; |
|
206 |
- |
|
207 |
- /* EoJKU */ |
|
208 |
-} |
|
209 |
- |
|
210 |
- |
|
211 |
-#ifdef USE_MCAST |
|
212 |
- |
|
213 |
-/* |
|
214 |
- * Setup multicast receiver |
|
215 |
- */ |
|
216 |
-static int setup_mcast_rcvr(int sock, union sockaddr_union* addr, char* interface) |
|
217 |
-{ |
|
218 |
-#ifdef HAVE_IP_MREQN |
|
219 |
- struct ip_mreqn mreq; |
|
220 |
-#else |
|
221 |
- struct ip_mreq mreq; |
|
222 |
-#endif |
|
223 |
- struct ipv6_mreq mreq6; |
|
224 |
- |
|
225 |
- if (addr->s.sa_family==AF_INET){ |
|
226 |
- memcpy(&mreq.imr_multiaddr, &addr->sin.sin_addr, |
|
227 |
- sizeof(struct in_addr)); |
|
228 |
-#ifdef HAVE_IP_MREQN |
|
229 |
- if (interface!=0) { |
|
230 |
- mreq.imr_ifindex = if_nametoindex(interface); |
|
231 |
- } else { |
|
232 |
- mreq.imr_ifindex = 0; |
|
233 |
- } |
|
234 |
- mreq.imr_address.s_addr = htonl(INADDR_ANY); |
|
235 |
-#else |
|
236 |
- mreq.imr_interface.s_addr = htonl(INADDR_ANY); |
|
237 |
-#endif |
|
238 |
- |
|
239 |
- if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,&mreq, |
|
240 |
- sizeof(mreq))==-1){ |
|
241 |
- LM_ERR("setsockopt: %s\n", strerror(errno)); |
|
242 |
- return -1; |
|
243 |
- } |
|
244 |
- |
|
245 |
- } else if (addr->s.sa_family==AF_INET6){ |
|
246 |
- memcpy(&mreq6.ipv6mr_multiaddr, &addr->sin6.sin6_addr, |
|
247 |
- sizeof(struct in6_addr)); |
|
248 |
- if (interface!=0) { |
|
249 |
- mreq6.ipv6mr_interface = if_nametoindex(interface); |
|
250 |
- } else { |
|
251 |
- mreq6.ipv6mr_interface = 0; |
|
252 |
- } |
|
253 |
-#ifdef __OS_linux |
|
254 |
- if (setsockopt(sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, |
|
255 |
-#else |
|
256 |
- if (setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq6, |
|
257 |
-#endif |
|
258 |
- sizeof(mreq6))==-1){ |
|
259 |
- LM_ERR("setsockopt:%s\n", strerror(errno)); |
|
260 |
- return -1; |
|
261 |
- } |
|
262 |
- |
|
263 |
- } else { |
|
264 |
- LM_ERR("setup_mcast_rcvr: Unsupported protocol family\n"); |
|
265 |
- return -1; |
|
266 |
- } |
|
267 |
- return 0; |
|
268 |
-} |
|
269 |
- |
|
270 |
-#endif /* USE_MCAST */ |
|
271 |
- |
|
272 |
- |
|
273 |
-int udp_init(struct socket_info* sock_info) |
|
274 |
-{ |
|
275 |
- union sockaddr_union* addr; |
|
276 |
- int optval; |
|
277 |
-#ifdef USE_MCAST |
|
278 |
- unsigned char m_ttl, m_loop; |
|
279 |
-#endif |
|
280 |
- addr=&sock_info->su; |
|
281 |
-/* |
|
282 |
- addr=(union sockaddr_union*)pkg_malloc(sizeof(union sockaddr_union)); |
|
283 |
- if (addr==0){ |
|
284 |
- LM_ERR("out of memory\n"); |
|
285 |
- goto error; |
|
286 |
- } |
|
287 |
-*/ |
|
288 |
- sock_info->proto=PROTO_UDP; |
|
289 |
- if (init_su(addr, &sock_info->address, sock_info->port_no)<0){ |
|
290 |
- LM_ERR("could not init sockaddr_union\n"); |
|
291 |
- goto error; |
|
292 |
- } |
|
293 |
- |
|
294 |
- sock_info->socket = socket(AF2PF(addr->s.sa_family), SOCK_DGRAM, 0); |
|
295 |
- if (sock_info->socket==-1){ |
|
296 |
- LM_ERR("socket: %s\n", strerror(errno)); |
|
297 |
- goto error; |
|
298 |
- } |
|
299 |
- /* set sock opts? */ |
|
300 |
- optval=1; |
|
301 |
- if (setsockopt(sock_info->socket, SOL_SOCKET, SO_REUSEADDR , |
|
302 |
- (void*)&optval, sizeof(optval)) ==-1){ |
|
303 |
- LM_ERR("setsockopt: %s\n", strerror(errno)); |
|
304 |
- goto error; |
|
305 |
- } |
|
306 |
- /* tos */ |
|
307 |
- optval = tos; |
|
308 |
- if (addr->s.sa_family==AF_INET){ |
|
309 |
- if (setsockopt(sock_info->socket, IPPROTO_IP, IP_TOS, (void*)&optval, |
|
310 |
- sizeof(optval)) ==-1){ |
|
311 |
- LM_WARN("setsockopt tos: %s\n", strerror(errno)); |
|
312 |
- /* continue since this is not critical */ |
|
313 |
- } |
|
314 |
- } else if (addr->s.sa_family==AF_INET6){ |
|
315 |
- if (setsockopt(sock_info->socket, IPPROTO_IPV6, IPV6_TCLASS, |
|
316 |
- (void*)&optval, sizeof(optval)) ==-1) { |
|
317 |
- LM_WARN("setsockopt v6 tos: %s\n", strerror(errno)); |
|
318 |
- /* continue since this is not critical */ |
|
319 |
- } |
|
320 |
- } |
|
321 |
- |
|
322 |
-#if defined (__OS_linux) && defined(UDP_ERRORS) |
|
323 |
- optval=1; |
|
324 |
- /* enable error receiving on unconnected sockets */ |
|
325 |
- if(setsockopt(sock_info->socket, SOL_IP, IP_RECVERR, |
|
326 |
- (void*)&optval, sizeof(optval)) ==-1){ |
|
327 |
- LM_ERR("setsockopt: %s\n", strerror(errno)); |
|
328 |
- goto error; |
|
329 |
- } |
|
330 |
-#endif |
|
331 |
-#if defined (__OS_linux) |
|
332 |
- /* if pmtu_discovery=1 then set DF bit and do Path MTU discovery |
|
333 |
- * disabled by default */ |
|
334 |
- optval= (pmtu_discovery) ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT; |
|
335 |
- if(setsockopt(sock_info->socket, IPPROTO_IP, IP_MTU_DISCOVER, |
|
336 |
- (void*)&optval, sizeof(optval)) ==-1){ |
|
337 |
- LM_ERR("setsockopt: %s\n", strerror(errno)); |
|
338 |
- goto error; |
|
339 |
- } |
|
340 |
-#endif |
|
341 |
- |
|
342 |
-#ifdef USE_MCAST |
|
343 |
- if ((sock_info->flags & SI_IS_MCAST) |
|
344 |
- && (setup_mcast_rcvr(sock_info->socket, addr, sock_info->mcast.s)<0)){ |
|
345 |
- goto error; |
|
346 |
- } |
|
347 |
- /* set the multicast options */ |
|
348 |
- if (addr->s.sa_family==AF_INET){ |
|
349 |
- m_loop=mcast_loopback; |
|
350 |
- if (setsockopt(sock_info->socket, IPPROTO_IP, IP_MULTICAST_LOOP, |
|
351 |
- &m_loop, sizeof(m_loop))==-1){ |
|
352 |
- LM_WARN("setsockopt(IP_MULTICAST_LOOP): %s\n", strerror(errno)); |
|
353 |
- /* it's only a warning because we might get this error if the |
|
354 |
- network interface doesn't support multicasting -- andrei */ |
|
355 |
- } |
|
356 |
- if (mcast_ttl>=0){ |
|
357 |
- m_ttl=mcast_ttl; |
|
358 |
- if (setsockopt(sock_info->socket, IPPROTO_IP, IP_MULTICAST_TTL, |
|
359 |
- &m_ttl, sizeof(m_ttl))==-1){ |
|
360 |
- LM_WARN("setsockopt (IP_MULTICAST_TTL): %s\n", strerror(errno)); |
|
361 |
- } |
|
362 |
- } |
|
363 |
- } else if (addr->s.sa_family==AF_INET6){ |
|
364 |
- if (setsockopt(sock_info->socket, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, |
|
365 |
- &mcast_loopback, sizeof(mcast_loopback))==-1){ |
|
366 |
- LM_WARN("setsockopt (IPV6_MULTICAST_LOOP): %s\n", strerror(errno)); |
|
367 |
- } |
|
368 |
- if (mcast_ttl>=0){ |
|
369 |
- if (setsockopt(sock_info->socket, IPPROTO_IP, IPV6_MULTICAST_HOPS, |
|
370 |
- &mcast_ttl, sizeof(mcast_ttl))==-1){ |
|
371 |
- LM_WARN("setssckopt (IPV6_MULTICAST_HOPS): %s\n", strerror(errno)); |
|
372 |
- } |
|
373 |
- } |
|
374 |
- } else { |
|
375 |
- LM_ERR("Unsupported protocol family %d\n", addr->s.sa_family); |
|
376 |
- goto error; |
|
377 |
- } |
|
378 |
-#endif /* USE_MCAST */ |
|
379 |
- |
|
380 |
- if ( probe_max_receive_buffer(sock_info->socket)==-1) goto error; |
|
381 |
- |
|
382 |
- if (bind(sock_info->socket, &addr->s, sockaddru_len(*addr))==-1){ |
|
383 |
- LM_ERR("bind(%x, %p, %d) on %s: %s\n", |
|
384 |
- sock_info->socket, &addr->s, |
|
385 |
- (unsigned)sockaddru_len(*addr), |
|
386 |
- sock_info->address_str.s, |
|
387 |
- strerror(errno)); |
|
388 |
- if (addr->s.sa_family==AF_INET6) |
|
389 |
- LM_ERR("might be caused by using a link local address, try site local or global\n"); |
|
390 |
- goto error; |
|
391 |
- } |
|
392 |
- |
|
393 |
-/* pkg_free(addr);*/ |
|
394 |
- return 0; |
|
395 |
- |
|
396 |
-error: |
|
397 |
-/* if (addr) pkg_free(addr);*/ |
|
398 |
- return -1; |
|
399 |
-} |
|
400 |
- |
|
401 |
- |
|
402 |
- |
|
403 |
-int udp_rcv_loop() |
|
404 |
-{ |
|
405 |
- unsigned len; |
|
406 |
-#ifdef DYN_BUF |
|
407 |
- char* buf; |
|
408 |
-#else |
|
409 |
- static char buf [BUF_SIZE+1]; |
|
410 |
-#endif |
|
411 |
- char *tmp; |
|
412 |
- union sockaddr_union* from; |
|
413 |
- unsigned int fromlen; |
|
414 |
- struct receive_info ri; |
|
415 |
- |
|
416 |
- |
|
417 |
- from=(union sockaddr_union*) pkg_malloc(sizeof(union sockaddr_union)); |
|
418 |
- if (from==0){ |
|
419 |
- LM_ERR("out of memory\n"); |
|
420 |
- goto error; |
|
421 |
- } |
|
422 |
- memset(from, 0 , sizeof(union sockaddr_union)); |
|
423 |
- ri.bind_address=bind_address; /* this will not change, we do it only once*/ |
|
424 |
- ri.dst_port=bind_address->port_no; |
|
425 |
- ri.dst_ip=bind_address->address; |
|
426 |
- ri.proto=PROTO_UDP; |
|
427 |
- ri.proto_reserved1=ri.proto_reserved2=0; |
|
428 |
- |
|
429 |
- /* initialize the config framework */ |
|
430 |
- if (cfg_child_init()) goto error; |
|
431 |
- |
|
432 |
- for(;;){ |
|
433 |
-#ifdef DYN_BUF |
|
434 |
- buf=pkg_malloc(BUF_SIZE+1); |
|
435 |
- if (buf==0){ |
|
436 |
- LM_ERR("could not allocate receive buffer\n"); |
|
437 |
- goto error; |
|
438 |
- } |
|
439 |
-#endif |
|
440 |
- fromlen=sockaddru_len(bind_address->su); |
|
441 |
- len=recvfrom(bind_address->socket, buf, BUF_SIZE, 0, &from->s, |
|
442 |
- &fromlen); |
|
443 |
- if (len==-1){ |
|
444 |
- if (errno==EAGAIN){ |
|
445 |
- LM_DBG("packet with bad checksum received\n"); |
|
446 |
- continue; |
|
447 |
- } |
|
448 |
- LM_ERR("recvfrom:[%d] %s\n", errno, strerror(errno)); |
|
449 |
- if ((errno==EINTR)||(errno==EWOULDBLOCK)|| (errno==ECONNREFUSED)) |
|
450 |
- continue; /* goto skip;*/ |
|
451 |
- else goto error; |
|
452 |
- } |
|
453 |
- /* we must 0-term the messages, receive_msg expects it */ |
|
454 |
- buf[len]=0; /* no need to save the previous char */ |
|
455 |
- |
|
456 |
- ri.src_su=*from; |
|
457 |
- su2ip_addr(&ri.src_ip, from); |
|
458 |
- ri.src_port=su_getport(from); |
|
459 |
- |
|
460 |
- if(unlikely(sr_event_enabled(SREV_NET_DGRAM_IN))) |
|
461 |
- { |
|
462 |
- void *sredp[3]; |
|
463 |
- sredp[0] = (void*)buf; |
|
464 |
- sredp[1] = (void*)(&len); |
|
465 |
- sredp[2] = (void*)(&ri); |
|
466 |
- if(sr_event_exec(SREV_NET_DGRAM_IN, (void*)sredp)<0) { |
|
467 |
- /* data handled by callback - continue to next packet */ |
|
468 |
- continue; |
|
469 |
- } |
|
470 |
- } |
|
471 |
-#ifndef NO_ZERO_CHECKS |
|
472 |
- if (!unlikely(sr_event_enabled(SREV_STUN_IN)) || (unsigned char)*buf != 0x00) { |
|
473 |
- if (len<MIN_UDP_PACKET) { |
|
474 |
- tmp=ip_addr2a(&ri.src_ip); |
|
475 |
- LM_DBG("probing packet received from %s %d\n", tmp, htons(ri.src_port)); |
|
476 |
- continue; |
|
477 |
- } |
|
478 |
- } |
|
479 |
-/* historically, zero-terminated packets indicated a bug in clients |
|
480 |
- * that calculated wrongly packet length and included string-terminating |
|
481 |
- * zero; today clients exist with legitimate binary payloads and we |
|
482 |
- * shall not check for zero-terminated payloads |
|
483 |
- */ |
|
484 |
-#ifdef TRASH_ZEROTERMINATED_PACKETS |
|
485 |
- if (buf[len-1]==0) { |
|
486 |
- tmp=ip_addr2a(&ri.src_ip); |
|
487 |
- LM_WARN("upstream bug - 0-terminated packet from %s %d\n", |
|
488 |
- tmp, htons(ri.src_port)); |
|
489 |
- len--; |
|
490 |
- } |
|
491 |
-#endif |
|
492 |
-#endif |
|
493 |
-#ifdef DBG_MSG_QA |
|
494 |
- if (!dbg_msg_qa(buf, len)) { |
|
495 |
- LM_WARN("an incoming message didn't pass test," |
|
496 |
- " drop it: %.*s\n", len, buf ); |
|
497 |
- continue; |
|
498 |
- } |
|
499 |
-#endif |
|
500 |
- if (ri.src_port==0){ |
|
501 |
- tmp=ip_addr2a(&ri.src_ip); |
|
502 |
- LM_INFO("dropping 0 port packet from %s\n", tmp); |
|
503 |
- continue; |
|
504 |
- } |
|
505 |
- |
|
506 |
- /* update the local config */ |
|
507 |
- cfg_update(); |
|
508 |
- if (unlikely(sr_event_enabled(SREV_STUN_IN)) && (unsigned char)*buf == 0x00) { |
|
509 |
- /* stun_process_msg releases buf memory if necessary */ |
|
510 |
- if ((stun_process_msg(buf, len, &ri)) != 0) { |
|
511 |
- continue; /* some error occurred */ |
|
512 |
- } |
|
513 |
- } else { |
|
514 |
- /* receive_msg must free buf too!*/ |
|
515 |
- receive_msg(buf, len, &ri); |
|
516 |
- } |
|
517 |
- |
|
518 |
- /* skip: do other stuff */ |
|
519 |
- |
|
520 |
- } |
|
521 |
- /* |
|
522 |
- if (from) pkg_free(from); |
|
523 |
- return 0; |
|
524 |
- */ |
|
525 |
- |
|
526 |
-error: |
|
527 |
- if (from) pkg_free(from); |
|
528 |
- return -1; |
|
529 |
-} |
|
530 |
- |
|
531 |
- |
|
532 |
- |
|
533 |
- |
|
534 |
-/* send buf:len over udp to dst (uses only the to and send_sock dst members) |
|
535 |
- * returns the numbers of bytes sent on success (>=0) and -1 on error |
|
536 |
- */ |
|
537 |
-int udp_send(struct dest_info* dst, char *buf, unsigned len) |
|
538 |
-{ |
|
539 |
- |
|
540 |
- int n; |
|
541 |
- int tolen; |
|
542 |
- struct ip_addr ip; /* used only on error, for debugging */ |
|
543 |
-#ifdef USE_RAW_SOCKS |
|
544 |
- int mtu; |
|
545 |
-#endif /* USE_RAW_SOCKS */ |
|
546 |
- |
|
547 |
-#ifdef DBG_MSG_QA |
|
548 |
- /* aborts on error, does nothing otherwise */ |
|
549 |
- if (!dbg_msg_qa( buf, len )) { |
|
550 |
- LM_ERR("dbg_msg_qa failed\n"); |
|
551 |
- abort(); |
|
552 |
- } |
|
553 |
-#endif |
|
554 |
-#ifdef USE_RAW_SOCKS |
|
555 |
- if (likely( ! (raw_udp4_send_sock >= 0 && |
|
556 |
- cfg_get(core, core_cfg, udp4_raw) && |
|
557 |
- dst->send_sock->address.af == AF_INET) )) { |
|
558 |
-#endif /* USE_RAW_SOCKS */ |
|
559 |
- /* normal send over udp socket */ |
|
560 |
- tolen=sockaddru_len(dst->to); |
|
561 |
-again: |
|
562 |
- n=sendto(dst->send_sock->socket, buf, len, 0, &dst->to.s, tolen); |
|
563 |
-#ifdef XL_DEBUG |
|
564 |
- LM_INFO("send status: %d\n", n); |
|
565 |
-#endif |
|
566 |
- if (unlikely(n==-1)){ |
|
567 |
- su2ip_addr(&ip, &dst->to); |
|
568 |
- LM_ERR("sendto(sock,%p,%u,0,%s:%d,%d): %s(%d)\n", |
|
569 |
- buf,len, ip_addr2a(&ip), |
|
570 |
- su_getport(&dst->to), tolen, strerror(errno), errno); |
|
571 |
- if (errno==EINTR) goto again; |
|
572 |
- if (errno==EINVAL) { |
|
573 |
- LM_CRIT("invalid sendtoparameters\n" |
|
574 |
- "one possible reason is the server is bound to localhost and\n" |
|
575 |
- "attempts to send to the net\n"); |
|
576 |
- } |
|
577 |
- } |
|
578 |
-#ifdef USE_RAW_SOCKS |
|
579 |
- } else { |
|
580 |
- /* send over a raw socket */ |
|
581 |
- mtu = cfg_get(core, core_cfg, udp4_raw_mtu); |
|
582 |
-raw_again: |
|
583 |
- n=raw_iphdr_udp4_send(raw_udp4_send_sock, buf, len, |
|
584 |
- &dst->send_sock->su, |
|
585 |
- &dst->to, |
|
586 |
- mtu); |
|
587 |
- if (unlikely(n==-1)){ |
|
588 |
- su2ip_addr(&ip, &dst->to); |
|
589 |
- LM_ERR("raw_iphdr_udp4_send(%d,%p,%u,...,%s:%d,%d): %s(%d)\n", |
|
590 |
- raw_udp4_send_sock, buf,len, ip_addr2a(&ip), |
|
591 |
- su_getport(&dst->to), mtu, strerror(errno), errno); |
|
592 |
- if (errno==EINTR) goto raw_again; |
|
593 |
- } |
|
594 |
- } |
|
595 |
-#endif /* USE_RAW_SOCKS */ |
|
596 |
- return n; |
|
597 |
-} |
- collateral by new mcast feature (commit 8b39cb6a3aa37d26da1ccf8f55f25aaba8fc4613)
... | ... |
@@ -215,18 +215,26 @@ int probe_max_receive_buffer( int udp_sock ) |
215 | 215 |
*/ |
216 | 216 |
static int setup_mcast_rcvr(int sock, union sockaddr_union* addr, char* interface) |
217 | 217 |
{ |
218 |
+#ifdef HAVE_IP_MREQN |
|
218 | 219 |
struct ip_mreqn mreq; |
220 |
+#else |
|
221 |
+ struct ip_mreq mreq; |
|
222 |
+#endif |
|
219 | 223 |
struct ipv6_mreq mreq6; |
220 | 224 |
|
221 | 225 |
if (addr->s.sa_family==AF_INET){ |
222 | 226 |
memcpy(&mreq.imr_multiaddr, &addr->sin.sin_addr, |
223 | 227 |
sizeof(struct in_addr)); |
228 |
+#ifdef HAVE_IP_MREQN |
|
224 | 229 |
if (interface!=0) { |
225 | 230 |
mreq.imr_ifindex = if_nametoindex(interface); |
226 | 231 |
} else { |
227 | 232 |
mreq.imr_ifindex = 0; |
228 | 233 |
} |
229 | 234 |
mreq.imr_address.s_addr = htonl(INADDR_ANY); |
235 |
+#else |
|
236 |
+ mreq.imr_interface.s_addr = htonl(INADDR_ANY); |
|
237 |
+#endif |
|
230 | 238 |
|
231 | 239 |
if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,&mreq, |
232 | 240 |
sizeof(mreq))==-1){ |
- You can now define a mcast parameter before a listen parameter that
contains a multicast address. After each listen parameter mcast gets
reset. mcast must contain the name of an interface, eg `eth1`.
Issue GH#813
... | ... |
@@ -55,6 +55,9 @@ |
55 | 55 |
#ifdef USE_RAW_SOCKS |
56 | 56 |
#include "raw_sock.h" |
57 | 57 |
#endif /* USE_RAW_SOCKS */ |
58 |
+#ifdef USE_MCAST |
|
59 |
+#include <net/if.h> |
|
60 |
+#endif /* USE_MCAST */ |
|
58 | 61 |
|
59 | 62 |
|
60 | 63 |
#ifdef DBG_MSG_QA |
... | ... |
@@ -210,15 +213,20 @@ int probe_max_receive_buffer( int udp_sock ) |
210 | 213 |
/* |
211 | 214 |
* Setup multicast receiver |
212 | 215 |
*/ |
213 |
-static int setup_mcast_rcvr(int sock, union sockaddr_union* addr) |
|
216 |
+static int setup_mcast_rcvr(int sock, union sockaddr_union* addr, char* interface) |
|
214 | 217 |
{ |
215 |
- struct ip_mreq mreq; |
|
218 |
+ struct ip_mreqn mreq; |
|
216 | 219 |
struct ipv6_mreq mreq6; |
217 |
- |
|
220 |
+ |
|
218 | 221 |
if (addr->s.sa_family==AF_INET){ |
219 | 222 |
memcpy(&mreq.imr_multiaddr, &addr->sin.sin_addr, |
220 | 223 |
sizeof(struct in_addr)); |
221 |
- mreq.imr_interface.s_addr = htonl(INADDR_ANY); |
|
224 |
+ if (interface!=0) { |
|
225 |
+ mreq.imr_ifindex = if_nametoindex(interface); |
|
226 |
+ } else { |
|
227 |
+ mreq.imr_ifindex = 0; |
|
228 |
+ } |
|
229 |
+ mreq.imr_address.s_addr = htonl(INADDR_ANY); |
|
222 | 230 |
|
223 | 231 |
if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,&mreq, |
224 | 232 |
sizeof(mreq))==-1){ |
... | ... |
@@ -229,7 +237,11 @@ static int setup_mcast_rcvr(int sock, union sockaddr_union* addr) |
229 | 237 |
} else if (addr->s.sa_family==AF_INET6){ |
230 | 238 |
memcpy(&mreq6.ipv6mr_multiaddr, &addr->sin6.sin6_addr, |
231 | 239 |
sizeof(struct in6_addr)); |
232 |
- mreq6.ipv6mr_interface = 0; |
|
240 |
+ if (interface!=0) { |
|
241 |
+ mreq6.ipv6mr_interface = if_nametoindex(interface); |
|
242 |
+ } else { |
|
243 |
+ mreq6.ipv6mr_interface = 0; |
|
244 |
+ } |
|
233 | 245 |
#ifdef __OS_linux |
234 | 246 |
if (setsockopt(sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, |
235 | 247 |
#else |
... | ... |
@@ -321,7 +333,7 @@ int udp_init(struct socket_info* sock_info) |
321 | 333 |
|
322 | 334 |
#ifdef USE_MCAST |
323 | 335 |
if ((sock_info->flags & SI_IS_MCAST) |
324 |
- && (setup_mcast_rcvr(sock_info->socket, addr)<0)){ |
|
336 |
+ && (setup_mcast_rcvr(sock_info->socket, addr, sock_info->mcast.s)<0)){ |
|
325 | 337 |
goto error; |
326 | 338 |
} |
327 | 339 |
/* set the multicast options */ |
... | ... |
@@ -90,7 +90,7 @@ static int dbg_msg_qa(char *buf, int len) |
90 | 90 |
case ' ': if (state==QA_SPACE) { |
91 | 91 |
space_cnt++; |
92 | 92 |
if (space_cnt==4) { |
93 |
- LM_CRIT("DBG_MSG_QA: too many spaces\n"); |
|
93 |
+ LM_CRIT("too many spaces\n"); |
|
94 | 94 |
return 0; |
95 | 95 |
} |
96 | 96 |
} else space_cnt=0; |
... | ... |
@@ -422,7 +422,7 @@ int udp_rcv_loop() |
422 | 422 |
&fromlen); |
423 | 423 |
if (len==-1){ |
424 | 424 |
if (errno==EAGAIN){ |
425 |
- DBG("udp_rcv_loop: packet with bad checksum received\n"); |
|
425 |
+ LM_DBG("packet with bad checksum received\n"); |
|
426 | 426 |
continue; |
427 | 427 |
} |
428 | 428 |
LM_ERR("recvfrom:[%d] %s\n", errno, strerror(errno)); |
... | ... |
@@ -452,8 +452,7 @@ int udp_rcv_loop() |
452 | 452 |
if (!unlikely(sr_event_enabled(SREV_STUN_IN)) || (unsigned char)*buf != 0x00) { |
453 | 453 |
if (len<MIN_UDP_PACKET) { |
454 | 454 |
tmp=ip_addr2a(&ri.src_ip); |
455 |
- DBG("udp_rcv_loop: probing packet received from %s %d\n", |
|
456 |
- tmp, htons(ri.src_port)); |
|
455 |
+ LM_DBG("probing packet received from %s %d\n", tmp, htons(ri.src_port)); |
|
457 | 456 |
continue; |
458 | 457 |
} |
459 | 458 |
} |
... | ... |
@@ -8,11 +8,6 @@ |
8 | 8 |
* the Free Software Foundation; either version 2 of the License, or |
9 | 9 |
* (at your option) any later version |
10 | 10 |
* |
11 |
- * For a license to use the ser software under conditions |
|
12 |
- * other than those described here, or to purchase support for this |
|
13 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
14 |
- * info@iptel.org |
|
15 |
- * |
|
16 | 11 |
* Kamailio is distributed in the hope that it will be useful, |
17 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
... | ... |
@@ -1,11 +1,9 @@ |
1 | 1 |
/* |
2 |
- * $Id$ |
|
3 |
- * |
|
4 | 2 |
* Copyright (C) 2001-2003 FhG Fokus |
5 | 3 |
* |
6 |
- * This file is part of ser, a free SIP server. |
|
4 |
+ * This file is part of Kamailio, a free SIP server. |
|
7 | 5 |
* |
8 |
- * ser is free software; you can redistribute it and/or modify |
|
6 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
9 | 7 |
* it under the terms of the GNU General Public License as published by |
10 | 8 |
* the Free Software Foundation; either version 2 of the License, or |
11 | 9 |
* (at your option) any later version |
... | ... |
@@ -15,7 +13,7 @@ |
15 | 13 |
* software, please contact iptel.org by e-mail at the following addresses: |
16 | 14 |
* info@iptel.org |
17 | 15 |
* |
18 |
- * ser is distributed in the hope that it will be useful, |
|
16 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
19 | 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | 19 |
* GNU General Public License for more details. |
... | ... |
@@ -24,28 +22,10 @@ |
24 | 22 |
* along with this program; if not, write to the Free Software |
25 | 23 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
26 | 24 |
* |
27 |
- * History |
|
28 |
- * -------- |
|
29 |
- * 2003-01-28 packet zero-termination moved to receive_msg (jiri) |
|
30 |
- * 2003-02-10 undoed the above changes (andrei) |
|
31 |
- * 2003-03-19 replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei) |
|
32 |
- * 2003-04-14 set sockopts to TOS low delay (andrei) |
|
33 |
- * 2004-05-03 applied multicast support patch from janakj |
|
34 |
- * added set multicast ttl support (andrei) |
|
35 |
- * 2004-07-05 udp_rcv_loop: drop packets with 0 src port + error msg. |
|
36 |
- * cleanups (andrei) |
|
37 |
- * 2005-03-10 multicast options are now set for all the udp sockets (andrei) |
|
38 |
- * 2005-06-26 failure to set mcast options is not an error anymore (andrei) |
|
39 |
- * 2006-04-12 udp_send() switched to struct dest_info (andrei) |
|
40 |
- * 2006-10-13 added STUN support (vlada) |
|
41 |
- * 2007-08-28 disable/set MTU discover option for the udp sockets |
|
42 |
- * (in linux it's enabled by default which produces udp packets |
|
43 |
- * with the DF flag ser) (patch from hscholz) |
|
44 |
- * 2010-06-15 support for using raw sockets for sending (andrei) |
|
45 | 25 |
*/ |
46 | 26 |
|
47 | 27 |
|
48 |
-/** udp send and loop-receive functions. |
|
28 |
+/** Kamailio core :: udp send and loop-receive functions. |
|
49 | 29 |
* @file udp_server.c |
50 | 30 |
* @ingroup core |
51 | 31 |
* Module: @ref core |
... | ... |
@@ -101,7 +101,7 @@ static int dbg_msg_qa(char *buf, int len) |
101 | 101 |
|
102 | 102 |
/* is there a zero character in there ? */ |
103 | 103 |
if (memchr(buf, 0, len)) { |
104 |
- LOG(L_CRIT, "BUG: message with 0 in it\n"); |
|
104 |
+ LM_CRIT("message with 0 in it\n"); |
|
105 | 105 |
return 0; |
106 | 106 |
} |
107 | 107 |
|
... | ... |
@@ -115,8 +115,7 @@ static int dbg_msg_qa(char *buf, int len) |
115 | 115 |
case ' ': if (state==QA_SPACE) { |
116 | 116 |
space_cnt++; |
117 | 117 |
if (space_cnt==4) { |
118 |
- LOG(L_CRIT, "BUG(probably): DBG_MSG_QA: " |
|
119 |
- "too many spaces\n"); |
|
118 |
+ LM_CRIT("DBG_MSG_QA: too many spaces\n"); |
|
120 | 119 |
return 0; |
121 | 120 |
} |
122 | 121 |
} else space_cnt=0; |
... | ... |
@@ -165,15 +164,15 @@ int probe_max_receive_buffer( int udp_sock ) |
165 | 164 |
if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &ioptval, |
166 | 165 |
&ioptvallen) == -1 ) |
167 | 166 |
{ |
168 |
- LOG(L_ERR, "ERROR: udp_init: getsockopt: %s\n", strerror(errno)); |
|
167 |
+ LM_ERR("getsockopt: %s\n", strerror(errno)); |
|
169 | 168 |
return -1; |
170 | 169 |
} |
171 | 170 |
if ( ioptval==0 ) |
172 | 171 |
{ |
173 |
- LOG(L_DBG, "DEBUG: udp_init: SO_RCVBUF initially set to 0; resetting to %d\n", |
|
172 |
+ LM_DBG("SO_RCVBUF initially set to 0; resetting to %d\n", |
|
174 | 173 |
BUFFER_INCREMENT ); |
175 | 174 |
ioptval=BUFFER_INCREMENT; |
176 |
- } else LOG(L_INFO, "INFO: udp_init: SO_RCVBUF is initially %d\n", ioptval ); |
|
175 |
+ } else LM_INFO("SO_RCVBUF is initially %d\n", ioptval ); |
|
177 | 176 |
for (optval=ioptval; ; ) { |
178 | 177 |
/* increase size; double in initial phase, add linearly later */ |
179 | 178 |
if (phase==0) optval <<= 1; else optval+=BUFFER_INCREMENT; |
... | ... |
@@ -181,12 +180,11 @@ int probe_max_receive_buffer( int udp_sock ) |
181 | 180 |
if (phase==1) break; |
182 | 181 |
else { phase=1; optval >>=1; continue; } |
183 | 182 |
} |
184 |
- LOG(L_DBG, "DEBUG: udp_init: trying SO_RCVBUF: %d\n", optval ); |
|
183 |
+ LM_DBG("trying SO_RCVBUF: %d\n", optval ); |
|
185 | 184 |
if (setsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, |
186 | 185 |
(void*)&optval, sizeof(optval)) ==-1){ |
187 | 186 |
/* Solaris returns -1 if asked size too big; Linux ignores */ |
188 |
- LOG(L_DBG, "DEBUG: udp_init: SOL_SOCKET failed" |
|
189 |
- " for %d, phase %d: %s\n", optval, phase, strerror(errno)); |
|
187 |
+ LM_DBG("SOL_SOCKET failed for %d, phase %d: %s\n", optval, phase, strerror(errno)); |
|
190 | 188 |
/* if setting buffer size failed and still in the aggressive |
191 | 189 |
phase, try less aggressively; otherwise give up |
192 | 190 |
*/ |
... | ... |
@@ -201,13 +199,13 @@ int probe_max_receive_buffer( int udp_sock ) |
201 | 199 |
if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &voptval, |
202 | 200 |
&voptvallen) == -1 ) |
203 | 201 |
{ |
204 |
- LOG(L_ERR, "ERROR: udp_init: getsockopt: %s\n", strerror(errno)); |
|
202 |
+ LM_ERR("getsockopt: %s\n", strerror(errno)); |
|
205 | 203 |
return -1; |
206 | 204 |
} else { |
207 |
- LOG(L_DBG, "DEBUG: setting SO_RCVBUF; set=%d,verify=%d\n", |
|
205 |
+ LM_DBG("setting SO_RCVBUF; set=%d,verify=%d\n", |
|
208 | 206 |
optval, voptval); |
209 | 207 |
if (voptval<optval) { |
210 |
- LOG(L_DBG, "DEBUG: setting SO_RCVBUF has no effect\n"); |
|
208 |
+ LM_DBG("setting SO_RCVBUF has no effect\n"); |
|
211 | 209 |
/* if setting buffer size failed and still in the aggressive |
212 | 210 |
phase, try less aggressively; otherwise give up |
213 | 211 |
*/ |
... | ... |
@@ -221,10 +219,10 @@ int probe_max_receive_buffer( int udp_sock ) |
221 | 219 |
if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &foptval, |
222 | 220 |
&foptvallen) == -1 ) |
223 | 221 |
{ |
224 |
- LOG(L_ERR, "ERROR: udp_init: getsockopt: %s\n", strerror(errno)); |
|
222 |
+ LM_ERR("getsockopt: %s\n", strerror(errno)); |
|
225 | 223 |
return -1; |
226 | 224 |
} |
227 |
- LOG(L_INFO, "INFO: udp_init: SO_RCVBUF is finally %d\n", foptval ); |
|
225 |
+ LM_INFO("SO_RCVBUF is finally %d\n", foptval ); |
|
228 | 226 |
|
229 | 227 |
return 0; |
230 | 228 |
|
... | ... |
@@ -249,8 +247,7 @@ static int setup_mcast_rcvr(int sock, union sockaddr_union* addr) |
249 | 247 |
|
250 | 248 |
if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,&mreq, |
251 | 249 |
sizeof(mreq))==-1){ |
252 |
- LOG(L_ERR, "ERROR: setup_mcast_rcvr: setsockopt: %s\n", |
|
253 |
- strerror(errno)); |
|
250 |
+ LM_ERR("setsockopt: %s\n", strerror(errno)); |
|
254 | 251 |
return -1; |
255 | 252 |
} |
256 | 253 |
|
... | ... |
@@ -264,13 +261,12 @@ static int setup_mcast_rcvr(int sock, union sockaddr_union* addr) |
264 | 261 |
if (setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq6, |
265 | 262 |
#endif |
266 | 263 |
sizeof(mreq6))==-1){ |
267 |
- LOG(L_ERR, "ERROR: setup_mcast_rcvr: setsockopt:%s\n", |
|
268 |
- strerror(errno)); |
|
264 |
+ LM_ERR("setsockopt:%s\n", strerror(errno)); |
|
269 | 265 |
return -1; |
270 | 266 |
} |
271 | 267 |
|
272 | 268 |
} else { |
273 |
- LOG(L_ERR, "ERROR: setup_mcast_rcvr: Unsupported protocol family\n"); |
|
269 |
+ LM_ERR("setup_mcast_rcvr: Unsupported protocol family\n"); |
|
274 | 270 |
return -1; |
275 | 271 |
} |
276 | 272 |
return 0; |
... | ... |
@@ -290,26 +286,26 @@ int udp_init(struct socket_info* sock_info) |
290 | 286 |
/* |
291 | 287 |
addr=(union sockaddr_union*)pkg_malloc(sizeof(union sockaddr_union)); |
292 | 288 |
if (addr==0){ |
293 |
- LOG(L_ERR, "ERROR: udp_init: out of memory\n"); |
|
289 |
+ LM_ERR("out of memory\n"); |
|
294 | 290 |
goto error; |
295 | 291 |
} |
296 | 292 |
*/ |
297 | 293 |
sock_info->proto=PROTO_UDP; |
298 | 294 |
if (init_su(addr, &sock_info->address, sock_info->port_no)<0){ |
299 |
- LOG(L_ERR, "ERROR: udp_init: could not init sockaddr_union\n"); |
|
295 |
+ LM_ERR("could not init sockaddr_union\n"); |
|
300 | 296 |
goto error; |
301 | 297 |
} |
302 | 298 |
|
303 | 299 |
sock_info->socket = socket(AF2PF(addr->s.sa_family), SOCK_DGRAM, 0); |
304 | 300 |
if (sock_info->socket==-1){ |
305 |
- LOG(L_ERR, "ERROR: udp_init: socket: %s\n", strerror(errno)); |
|
301 |