2 * $Id: socket.c,v 1.8 2010/12/14 11:58:21 psavola Exp $
5 * Pedro Roque <roque@di.fc.ul.pt>
6 * Lars Fenneberg <lf@elemental.net>
8 * This software is Copyright 1996,1997 by the above mentioned author(s),
11 * The license which is distributed with this software in the file COPYRIGHT
12 * applies to this software. If your distribution is missing this file, you
13 * may request it from <pekkas@netcore.fi>.
21 /* Note: these are applicable to receiving sockopts only */
22 #if defined IPV6_HOPLIMIT && !defined IPV6_RECVHOPLIMIT
23 # define IPV6_RECVHOPLIMIT IPV6_HOPLIMIT
26 #if defined IPV6_PKTINFO && !defined IPV6_RECVPKTINFO
27 # define IPV6_RECVPKTINFO IPV6_PKTINFO
31 open_icmpv6_socket(void)
34 struct icmp6_filter filter
;
37 sock
= socket(AF_INET6
, SOCK_RAW
, IPPROTO_ICMPV6
);
40 flog(LOG_ERR
, "can't create socket(AF_INET6): %s", strerror(errno
));
45 err
= setsockopt(sock
, IPPROTO_IPV6
, IPV6_RECVPKTINFO
, &val
, sizeof(val
));
48 flog(LOG_ERR
, "setsockopt(IPV6_RECVPKTINFO): %s", strerror(errno
));
54 err
= setsockopt(sock
, IPPROTO_RAW
, IPV6_CHECKSUM
, &val
, sizeof(val
));
56 err
= setsockopt(sock
, IPPROTO_IPV6
, IPV6_CHECKSUM
, &val
, sizeof(val
));
60 flog(LOG_ERR
, "setsockopt(IPV6_CHECKSUM): %s", strerror(errno
));
65 err
= setsockopt(sock
, IPPROTO_IPV6
, IPV6_UNICAST_HOPS
, &val
, sizeof(val
));
68 flog(LOG_ERR
, "setsockopt(IPV6_UNICAST_HOPS): %s", strerror(errno
));
73 err
= setsockopt(sock
, IPPROTO_IPV6
, IPV6_MULTICAST_HOPS
, &val
, sizeof(val
));
76 flog(LOG_ERR
, "setsockopt(IPV6_MULTICAST_HOPS): %s", strerror(errno
));
80 #ifdef IPV6_RECVHOPLIMIT
82 err
= setsockopt(sock
, IPPROTO_IPV6
, IPV6_RECVHOPLIMIT
, &val
, sizeof(val
));
85 flog(LOG_ERR
, "setsockopt(IPV6_RECVHOPLIMIT): %s", strerror(errno
));
94 ICMP6_FILTER_SETBLOCKALL(&filter
);
95 ICMP6_FILTER_SETPASS(ND_ROUTER_SOLICIT
, &filter
);
96 ICMP6_FILTER_SETPASS(ND_ROUTER_ADVERT
, &filter
);
98 err
= setsockopt(sock
, IPPROTO_ICMPV6
, ICMP6_FILTER
, &filter
,
102 flog(LOG_ERR
, "setsockopt(ICMPV6_FILTER): %s", strerror(errno
));