diff options
-rw-r--r-- | libndp/libndp.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libndp/libndp.c b/libndp/libndp.c index 66db796..baacb76 100644 --- a/libndp/libndp.c +++ b/libndp/libndp.c @@ -1737,10 +1737,11 @@ free_msg: static int ndp_sock_open(struct ndp *ndp) { int sock; - //struct icmp6_filter flt; + struct icmp6_filter flt; int ret; int err; int val; + int i; sock = socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6); if (sock == -1) { @@ -1775,6 +1776,17 @@ static int ndp_sock_open(struct ndp *ndp) goto close_sock; } + ICMP6_FILTER_SETBLOCKALL(&flt); + for (i = 0; i < NDP_MSG_TYPE_LIST_SIZE; i++) + ICMP6_FILTER_SETPASS(ndp_msg_type_info(i)->raw_type, &flt); + ret = setsockopt(sock, IPPROTO_ICMPV6, ICMP6_FILTER, &flt, + sizeof(flt)); + if (ret == -1) { + err(ndp, "Failed to setsockopt ICMP6_FILTER."); + err = -errno; + goto close_sock; + } + ndp->sock = sock; return 0; close_sock: |