aboutgitcodebugslistschat
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/util.c b/util.c
index e8ee57f..44357b7 100644
--- a/util.c
+++ b/util.c
@@ -160,7 +160,8 @@ int sock_l4_add(struct ctx *c, int v, uint16_t proto, uint16_t port)
const struct sockaddr *sa;
int fd, sl, one = 1;
- if (proto != IPPROTO_TCP && proto != IPPROTO_UDP)
+ if (proto != IPPROTO_TCP && proto != IPPROTO_UDP &&
+ proto != IPPROTO_ICMP && proto != IPPROTO_ICMPV6)
return -1; /* Not implemented. */
fd = socket(v == 4 ? AF_INET : AF_INET6,
@@ -170,6 +171,9 @@ int sock_l4_add(struct ctx *c, int v, uint16_t proto, uint16_t port)
return -1;
}
+ if (proto == IPPROTO_ICMP || proto == IPPROTO_ICMPV6)
+ goto epoll_add;
+
if (v == 4) {
sa = (const struct sockaddr *)&addr4;
sl = sizeof(addr4);
@@ -195,6 +199,7 @@ int sock_l4_add(struct ctx *c, int v, uint16_t proto, uint16_t port)
return -1;
}
+epoll_add:
ev.events = EPOLLIN;
ev.data.fd = fd;
if (epoll_ctl(c->epollfd, EPOLL_CTL_ADD, fd, &ev) == -1) {