242d098cf9bef3d37255962cf8aa0e9af9c7cecd
[strongswan.git] / src / libcharon / plugins / socket_raw / socket_raw_socket.c
1 /*
2 * Copyright (C) 2006-2010 Tobias Brunner
3 * Copyright (C) 2005-2010 Martin Willi
4 * Copyright (C) 2006 Daniel Roethlisberger
5 * Copyright (C) 2005 Jan Hutter
6 * Hochschule fuer Technik Rapperswil
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 */
18
19 /* for struct in6_pktinfo */
20 #define _GNU_SOURCE
21
22 #include "socket_raw_socket.h"
23
24 #include <sys/types.h>
25 #include <sys/socket.h>
26 #include <string.h>
27 #include <errno.h>
28 #include <unistd.h>
29 #include <stdlib.h>
30 #include <fcntl.h>
31 #include <sys/ioctl.h>
32 #include <netinet/in.h>
33 #include <netinet/ip.h>
34 #include <netinet/ip6.h>
35 #include <netinet/udp.h>
36 #include <linux/types.h>
37 #include <linux/filter.h>
38 #include <net/if.h>
39
40 #include <hydra.h>
41 #include <daemon.h>
42 #include <threading/thread.h>
43
44 /* Maximum size of a packet */
45 #define MAX_PACKET 10000
46
47 /* constants for packet handling */
48 #define IP_LEN sizeof(struct iphdr)
49 #define IP6_LEN sizeof(struct ip6_hdr)
50 #define UDP_LEN sizeof(struct udphdr)
51 #define MARKER_LEN sizeof(u_int32_t)
52
53 /* offsets for packet handling */
54 #define IP_PROTO_OFFSET 9
55 #define IP6_PROTO_OFFSET 6
56 #define IKE_VERSION_OFFSET 17
57 #define IKE_LENGTH_OFFSET 24
58
59 /* from linux/udp.h */
60 #ifndef UDP_ENCAP
61 #define UDP_ENCAP 100
62 #endif /*UDP_ENCAP*/
63
64 #ifndef UDP_ENCAP_ESPINUDP
65 #define UDP_ENCAP_ESPINUDP 2
66 #endif /*UDP_ENCAP_ESPINUDP*/
67
68 /* needed for older kernel headers */
69 #ifndef IPV6_2292PKTINFO
70 #define IPV6_2292PKTINFO 2
71 #endif /*IPV6_2292PKTINFO*/
72
73 typedef struct private_socket_raw_socket_t private_socket_raw_socket_t;
74
75 /**
76 * Private data of an socket_t object
77 */
78 struct private_socket_raw_socket_t {
79
80 /**
81 * public functions
82 */
83 socket_raw_socket_t public;
84
85 /**
86 * regular port
87 */
88 int port;
89
90 /**
91 * port used for nat-t
92 */
93 int natt_port;
94
95 /**
96 * raw receiver socket for IPv4
97 */
98 int recv4;
99
100 /**
101 * raw receiver socket for IPv6
102 */
103 int recv6;
104
105 /**
106 * send socket on regular port for IPv4
107 */
108 int send4;
109
110 /**
111 * send socket on regular port for IPv6
112 */
113 int send6;
114
115 /**
116 * send socket on nat-t port for IPv4
117 */
118 int send4_natt;
119
120 /**
121 * send socket on nat-t port for IPv6
122 */
123 int send6_natt;
124
125 /**
126 * Maximum packet size to receive
127 */
128 int max_packet;
129 };
130
131 METHOD(socket_t, receiver, status_t,
132 private_socket_raw_socket_t *this, packet_t **packet)
133 {
134 char buffer[this->max_packet];
135 chunk_t data;
136 packet_t *pkt;
137 struct udphdr *udp;
138 host_t *source = NULL, *dest = NULL;
139 int bytes_read = 0, data_offset;
140 bool oldstate;
141 fd_set rfds;
142
143 FD_ZERO(&rfds);
144
145 if (this->recv4)
146 {
147 FD_SET(this->recv4, &rfds);
148 }
149 if (this->recv6)
150 {
151 FD_SET(this->recv6, &rfds);
152 }
153
154 DBG2(DBG_NET, "waiting for data on raw sockets");
155
156 oldstate = thread_cancelability(TRUE);
157 if (select(max(this->recv4, this->recv6) + 1, &rfds, NULL, NULL, NULL) <= 0)
158 {
159 thread_cancelability(oldstate);
160 return FAILED;
161 }
162 thread_cancelability(oldstate);
163
164 if (this->recv4 && FD_ISSET(this->recv4, &rfds))
165 {
166 /* IPv4 raw sockets return the IP header. We read src/dest
167 * information directly from the raw header */
168 struct iphdr *ip;
169 struct sockaddr_in src, dst;
170
171 bytes_read = recv(this->recv4, buffer, this->max_packet, 0);
172 if (bytes_read < 0)
173 {
174 DBG1(DBG_NET, "error reading from IPv4 socket: %s", strerror(errno));
175 return FAILED;
176 }
177 if (bytes_read == this->max_packet)
178 {
179 DBG1(DBG_NET, "receive buffer too small, packet discarded");
180 return FAILED;
181 }
182 DBG3(DBG_NET, "received IPv4 packet %b", buffer, bytes_read);
183
184 /* read source/dest from raw IP/UDP header */
185 if (bytes_read < IP_LEN + UDP_LEN + MARKER_LEN)
186 {
187 DBG1(DBG_NET, "received IPv4 packet too short (%d bytes)",
188 bytes_read);
189 return FAILED;
190 }
191 ip = (struct iphdr*) buffer;
192 udp = (struct udphdr*) (buffer + IP_LEN);
193 src.sin_family = AF_INET;
194 src.sin_addr.s_addr = ip->saddr;
195 src.sin_port = udp->source;
196 dst.sin_family = AF_INET;
197 dst.sin_addr.s_addr = ip->daddr;
198 dst.sin_port = udp->dest;
199 source = host_create_from_sockaddr((sockaddr_t*)&src);
200 dest = host_create_from_sockaddr((sockaddr_t*)&dst);
201
202 pkt = packet_create();
203 pkt->set_source(pkt, source);
204 pkt->set_destination(pkt, dest);
205 DBG2(DBG_NET, "received packet: from %#H to %#H", source, dest);
206 data_offset = IP_LEN + UDP_LEN;
207 /* remove non esp marker */
208 if (dest->get_port(dest) == IKEV2_NATT_PORT)
209 {
210 data_offset += MARKER_LEN;
211 }
212 /* fill in packet */
213 data.len = bytes_read - data_offset;
214 data.ptr = malloc(data.len);
215 memcpy(data.ptr, buffer + data_offset, data.len);
216 pkt->set_data(pkt, data);
217 }
218 else if (this->recv6 && FD_ISSET(this->recv6, &rfds))
219 {
220 /* IPv6 raw sockets return no IP header. We must query
221 * src/dest via socket options/ancillary data */
222 struct msghdr msg;
223 struct cmsghdr *cmsgptr;
224 struct sockaddr_in6 src, dst;
225 struct iovec iov;
226 char ancillary[64];
227
228 msg.msg_name = &src;
229 msg.msg_namelen = sizeof(src);
230 iov.iov_base = buffer;
231 iov.iov_len = this->max_packet;
232 msg.msg_iov = &iov;
233 msg.msg_iovlen = 1;
234 msg.msg_control = ancillary;
235 msg.msg_controllen = sizeof(ancillary);
236 msg.msg_flags = 0;
237
238 bytes_read = recvmsg(this->recv6, &msg, 0);
239 if (bytes_read < 0)
240 {
241 DBG1(DBG_NET, "error reading from IPv6 socket: %s", strerror(errno));
242 return FAILED;
243 }
244 DBG3(DBG_NET, "received IPv6 packet %b", buffer, bytes_read);
245
246 if (bytes_read < IP_LEN + UDP_LEN + MARKER_LEN)
247 {
248 DBG3(DBG_NET, "received IPv6 packet too short (%d bytes)",
249 bytes_read);
250 return FAILED;
251 }
252
253 /* read ancillary data to get destination address */
254 for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL;
255 cmsgptr = CMSG_NXTHDR(&msg, cmsgptr))
256 {
257 if (cmsgptr->cmsg_len == 0)
258 {
259 DBG1(DBG_NET, "error reading IPv6 ancillary data");
260 return FAILED;
261 }
262 if (cmsgptr->cmsg_level == SOL_IPV6 &&
263 cmsgptr->cmsg_type == IPV6_2292PKTINFO)
264 {
265 struct in6_pktinfo *pktinfo;
266 pktinfo = (struct in6_pktinfo*)CMSG_DATA(cmsgptr);
267
268 memset(&dst, 0, sizeof(dst));
269 memcpy(&dst.sin6_addr, &pktinfo->ipi6_addr, sizeof(dst.sin6_addr));
270 dst.sin6_family = AF_INET6;
271 udp = (struct udphdr*) (buffer);
272 dst.sin6_port = udp->dest;
273 src.sin6_port = udp->source;
274 dest = host_create_from_sockaddr((sockaddr_t*)&dst);
275 }
276 }
277 /* ancillary data missing? */
278 if (dest == NULL)
279 {
280 DBG1(DBG_NET, "error reading IPv6 packet header");
281 return FAILED;
282 }
283
284 source = host_create_from_sockaddr((sockaddr_t*)&src);
285
286 pkt = packet_create();
287 pkt->set_source(pkt, source);
288 pkt->set_destination(pkt, dest);
289 DBG2(DBG_NET, "received packet: from %#H to %#H", source, dest);
290 data_offset = UDP_LEN;
291 /* remove non esp marker */
292 if (dest->get_port(dest) == IKEV2_NATT_PORT)
293 {
294 data_offset += MARKER_LEN;
295 }
296 /* fill in packet */
297 data.len = bytes_read - data_offset;
298 data.ptr = malloc(data.len);
299 memcpy(data.ptr, buffer + data_offset, data.len);
300 pkt->set_data(pkt, data);
301 }
302 else
303 {
304 /* oops, shouldn't happen */
305 return FAILED;
306 }
307
308 /* return packet */
309 *packet = pkt;
310 return SUCCESS;
311 }
312
313 METHOD(socket_t, sender, status_t,
314 private_socket_raw_socket_t *this, packet_t *packet)
315 {
316 int sport, skt, family;
317 ssize_t bytes_sent;
318 chunk_t data, marked;
319 host_t *src, *dst;
320 struct msghdr msg;
321 struct cmsghdr *cmsg;
322 struct iovec iov;
323
324 src = packet->get_source(packet);
325 dst = packet->get_destination(packet);
326 data = packet->get_data(packet);
327
328 DBG2(DBG_NET, "sending packet: from %#H to %#H", src, dst);
329
330 /* send data */
331 sport = src->get_port(src);
332 family = dst->get_family(dst);
333 if (sport == IKEV2_UDP_PORT)
334 {
335 if (family == AF_INET)
336 {
337 skt = this->send4;
338 }
339 else
340 {
341 skt = this->send6;
342 }
343 }
344 else if (sport == IKEV2_NATT_PORT)
345 {
346 if (family == AF_INET)
347 {
348 skt = this->send4_natt;
349 }
350 else
351 {
352 skt = this->send6_natt;
353 }
354 /* NAT keepalives without marker */
355 if (data.len != 1 || data.ptr[0] != 0xFF)
356 {
357 /* add non esp marker to packet */
358 marked = chunk_alloc(data.len + MARKER_LEN);
359 memset(marked.ptr, 0, MARKER_LEN);
360 memcpy(marked.ptr + MARKER_LEN, data.ptr, data.len);
361 /* let the packet do the clean up for us */
362 packet->set_data(packet, marked);
363 data = marked;
364 }
365 }
366 else
367 {
368 DBG1(DBG_NET, "unable to locate a send socket for port %d", sport);
369 return FAILED;
370 }
371
372 memset(&msg, 0, sizeof(struct msghdr));
373 msg.msg_name = dst->get_sockaddr(dst);;
374 msg.msg_namelen = *dst->get_sockaddr_len(dst);
375 iov.iov_base = data.ptr;
376 iov.iov_len = data.len;
377 msg.msg_iov = &iov;
378 msg.msg_iovlen = 1;
379 msg.msg_flags = 0;
380
381 if (!src->is_anyaddr(src))
382 {
383 if (family == AF_INET)
384 {
385 char buf[CMSG_SPACE(sizeof(struct in_pktinfo))];
386 struct in_pktinfo *pktinfo;
387 struct sockaddr_in *sin;
388
389 msg.msg_control = buf;
390 msg.msg_controllen = sizeof(buf);
391 cmsg = CMSG_FIRSTHDR(&msg);
392 cmsg->cmsg_level = SOL_IP;
393 cmsg->cmsg_type = IP_PKTINFO;
394 cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
395 pktinfo = (struct in_pktinfo*)CMSG_DATA(cmsg);
396 memset(pktinfo, 0, sizeof(struct in_pktinfo));
397 sin = (struct sockaddr_in*)src->get_sockaddr(src);
398 memcpy(&pktinfo->ipi_spec_dst, &sin->sin_addr, sizeof(struct in_addr));
399 }
400 else
401 {
402 char buf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
403 struct in6_pktinfo *pktinfo;
404 struct sockaddr_in6 *sin;
405
406 msg.msg_control = buf;
407 msg.msg_controllen = sizeof(buf);
408 cmsg = CMSG_FIRSTHDR(&msg);
409 cmsg->cmsg_level = SOL_IPV6;
410 cmsg->cmsg_type = IPV6_2292PKTINFO;
411 cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
412 pktinfo = (struct in6_pktinfo*)CMSG_DATA(cmsg);
413 memset(pktinfo, 0, sizeof(struct in6_pktinfo));
414 sin = (struct sockaddr_in6*)src->get_sockaddr(src);
415 memcpy(&pktinfo->ipi6_addr, &sin->sin6_addr, sizeof(struct in6_addr));
416 }
417 }
418
419 bytes_sent = sendmsg(skt, &msg, 0);
420
421 if (bytes_sent != data.len)
422 {
423 DBG1(DBG_NET, "error writing to socket: %s", strerror(errno));
424 return FAILED;
425 }
426 return SUCCESS;
427 }
428
429 /**
430 * open a socket to send packets
431 */
432 static int open_send_socket(private_socket_raw_socket_t *this,
433 int family, u_int16_t port)
434 {
435 int on = TRUE;
436 int type = UDP_ENCAP_ESPINUDP;
437 struct sockaddr_storage addr;
438 int skt;
439
440 memset(&addr, 0, sizeof(addr));
441 /* precalculate constants depending on address family */
442 switch (family)
443 {
444 case AF_INET:
445 {
446 struct sockaddr_in *sin = (struct sockaddr_in *)&addr;
447 sin->sin_family = AF_INET;
448 sin->sin_addr.s_addr = INADDR_ANY;
449 sin->sin_port = htons(port);
450 break;
451 }
452 case AF_INET6:
453 {
454 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&addr;
455 sin6->sin6_family = AF_INET6;
456 memcpy(&sin6->sin6_addr, &in6addr_any, sizeof(in6addr_any));
457 sin6->sin6_port = htons(port);
458 break;
459 }
460 default:
461 return 0;
462 }
463
464 skt = socket(family, SOCK_DGRAM, IPPROTO_UDP);
465 if (skt < 0)
466 {
467 DBG1(DBG_NET, "could not open send socket: %s", strerror(errno));
468 return 0;
469 }
470
471 if (setsockopt(skt, SOL_SOCKET, SO_REUSEADDR, (void*)&on, sizeof(on)) < 0)
472 {
473 DBG1(DBG_NET, "unable to set SO_REUSEADDR on send socket: %s",
474 strerror(errno));
475 close(skt);
476 return 0;
477 }
478
479 /* bind the send socket */
480 if (bind(skt, (struct sockaddr *)&addr, sizeof(addr)) < 0)
481 {
482 DBG1(DBG_NET, "unable to bind send socket: %s",
483 strerror(errno));
484 close(skt);
485 return 0;
486 }
487
488 if (family == AF_INET)
489 {
490 /* enable UDP decapsulation globally, only for one socket needed */
491 if (setsockopt(skt, SOL_UDP, UDP_ENCAP, &type, sizeof(type)) < 0)
492 {
493 DBG1(DBG_NET, "unable to set UDP_ENCAP: %s; NAT-T may fail",
494 strerror(errno));
495 }
496 }
497
498 if (!hydra->kernel_interface->bypass_socket(hydra->kernel_interface,
499 skt, family))
500 {
501 DBG1(DBG_NET, "installing bypass policy on send socket failed");
502 }
503
504 return skt;
505 }
506
507 /**
508 * open a socket to receive packets
509 */
510 static int open_recv_socket(private_socket_raw_socket_t *this, int family)
511 {
512 int skt;
513 int on = TRUE;
514 u_int ip_len, sol, udp_header, ike_header;
515
516 /* precalculate constants depending on address family */
517 switch (family)
518 {
519 case AF_INET:
520 ip_len = IP_LEN;
521 sol = SOL_IP;
522 break;
523 case AF_INET6:
524 ip_len = 0; /* IPv6 raw sockets contain no IP header */
525 sol = SOL_IPV6;
526 break;
527 default:
528 return 0;
529 }
530 udp_header = ip_len;
531 ike_header = ip_len + UDP_LEN;
532
533 /* This filter code filters out all non-IKEv2 traffic on
534 * a SOCK_RAW IP_PROTP_UDP socket. Handling of other
535 * IKE versions is done in pluto.
536 */
537 struct sock_filter ikev2_filter_code[] =
538 {
539 /* Destination Port must be either port or natt_port */
540 BPF_STMT(BPF_LD+BPF_H+BPF_ABS, udp_header + 2),
541 BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, IKEV2_UDP_PORT, 1, 0),
542 BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, IKEV2_NATT_PORT, 6, 14),
543 /* port */
544 /* IKE version must be 2.x */
545 BPF_STMT(BPF_LD+BPF_B+BPF_ABS, ike_header + IKE_VERSION_OFFSET),
546 BPF_STMT(BPF_ALU+BPF_RSH+BPF_K, 4),
547 BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 2, 0, 11),
548 /* packet length is length in IKEv2 header + ip header + udp header */
549 BPF_STMT(BPF_LD+BPF_W+BPF_ABS, ike_header + IKE_LENGTH_OFFSET),
550 BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, ip_len + UDP_LEN),
551 BPF_STMT(BPF_RET+BPF_A, 0),
552 /* natt_port */
553 /* nat-t: check for marker */
554 BPF_STMT(BPF_LD+BPF_W+BPF_ABS, ike_header),
555 BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 6),
556 /* nat-t: IKE version must be 2.x */
557 BPF_STMT(BPF_LD+BPF_B+BPF_ABS, ike_header + MARKER_LEN + IKE_VERSION_OFFSET),
558 BPF_STMT(BPF_ALU+BPF_RSH+BPF_K, 4),
559 BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 2, 0, 3),
560 /* nat-t: packet length is length in IKEv2 header + ip header + udp header + non esp marker */
561 BPF_STMT(BPF_LD+BPF_W+BPF_ABS, ike_header + MARKER_LEN + IKE_LENGTH_OFFSET),
562 BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, ip_len + UDP_LEN + MARKER_LEN),
563 BPF_STMT(BPF_RET+BPF_A, 0),
564 /* packet doesn't match, ignore */
565 BPF_STMT(BPF_RET+BPF_K, 0),
566 };
567
568 /* Filter struct to use with setsockopt */
569 struct sock_fprog ikev2_filter = {
570 sizeof(ikev2_filter_code) / sizeof(struct sock_filter),
571 ikev2_filter_code
572 };
573
574 /* set up a raw socket */
575 skt = socket(family, SOCK_RAW, IPPROTO_UDP);
576 if (skt < 0)
577 {
578 DBG1(DBG_NET, "unable to create raw socket: %s", strerror(errno));
579 return 0;
580 }
581
582 if (setsockopt(skt, SOL_SOCKET, SO_ATTACH_FILTER,
583 &ikev2_filter, sizeof(ikev2_filter)) < 0)
584 {
585 DBG1(DBG_NET, "unable to attach IKEv2 filter to raw socket: %s",
586 strerror(errno));
587 close(skt);
588 return 0;
589 }
590
591 if (family == AF_INET6 &&
592 /* we use IPV6_2292PKTINFO, as IPV6_PKTINFO is defined as
593 * 2 or 50 depending on kernel header version */
594 setsockopt(skt, sol, IPV6_2292PKTINFO, &on, sizeof(on)) < 0)
595 {
596 DBG1(DBG_NET, "unable to set IPV6_PKTINFO on raw socket: %s",
597 strerror(errno));
598 close(skt);
599 return 0;
600 }
601
602 if (!hydra->kernel_interface->bypass_socket(hydra->kernel_interface,
603 skt, family))
604 {
605 DBG1(DBG_NET, "installing bypass policy on receive socket failed");
606 }
607
608 return skt;
609 }
610
611 METHOD(socket_t, destroy, void,
612 private_socket_raw_socket_t *this)
613 {
614 if (this->recv4)
615 {
616 close(this->recv4);
617 }
618 if (this->recv6)
619 {
620 close(this->recv6);
621 }
622 if (this->send4)
623 {
624 close(this->send4);
625 }
626 if (this->send6)
627 {
628 close(this->send6);
629 }
630 if (this->send4_natt)
631 {
632 close(this->send4_natt);
633 }
634 if (this->send6_natt)
635 {
636 close(this->send6_natt);
637 }
638 free(this);
639 }
640
641 /*
642 * See header for description
643 */
644 socket_raw_socket_t *socket_raw_socket_create()
645 {
646 private_socket_raw_socket_t *this;
647
648 INIT(this,
649 .public = {
650 .socket = {
651 .send = _sender,
652 .receive = _receiver,
653 .destroy = _destroy,
654 },
655 },
656 .max_packet = lib->settings->get_int(lib->settings,
657 "charon.max_packet", MAX_PACKET),
658 );
659
660 this->recv4 = open_recv_socket(this, AF_INET);
661 if (this->recv4 == 0)
662 {
663 DBG1(DBG_NET, "could not open IPv4 receive socket, IPv4 disabled");
664 }
665 else
666 {
667 this->send4 = open_send_socket(this, AF_INET, IKEV2_UDP_PORT);
668 if (this->send4 == 0)
669 {
670 DBG1(DBG_NET, "could not open IPv4 send socket, IPv4 disabled");
671 close(this->recv4);
672 }
673 else
674 {
675 this->send4_natt = open_send_socket(this, AF_INET, IKEV2_NATT_PORT);
676 if (this->send4_natt == 0)
677 {
678 DBG1(DBG_NET, "could not open IPv4 NAT-T send socket");
679 }
680 }
681 }
682
683 this->recv6 = open_recv_socket(this, AF_INET6);
684 if (this->recv6 == 0)
685 {
686 DBG1(DBG_NET, "could not open IPv6 receive socket, IPv6 disabled");
687 }
688 else
689 {
690 this->send6 = open_send_socket(this, AF_INET6, IKEV2_UDP_PORT);
691 if (this->send6 == 0)
692 {
693 DBG1(DBG_NET, "could not open IPv6 send socket, IPv6 disabled");
694 close(this->recv6);
695 }
696 else
697 {
698 this->send6_natt = open_send_socket(this, AF_INET6, IKEV2_NATT_PORT);
699 if (this->send6_natt == 0)
700 {
701 DBG1(DBG_NET, "could not open IPv6 NAT-T send socket");
702 }
703 }
704 }
705
706 if (!(this->send4 || this->send6) || !(this->recv4 || this->recv6))
707 {
708 DBG1(DBG_NET, "could not create any sockets");
709 destroy(this);
710 return NULL;
711 }
712
713 return &this->public;
714 }