aboutgitcodebugslistschat
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/util.c b/util.c
index 7a75e02..cc96a1a 100644
--- a/util.c
+++ b/util.c
@@ -189,6 +189,21 @@ int sock_l4_add(struct ctx *c, int v, uint16_t proto, uint16_t port)
return -1;
}
+#define CHECK_SET_MIN_MAX(ipproto, proto_ctx, fd) \
+ if (proto == (ipproto)) { \
+ if (fd < c->proto_ctx.fd_min) \
+ c->proto_ctx.fd_min = (fd); \
+ if (fd > c->proto_ctx.fd_max) \
+ c->proto_ctx.fd_max = (fd); \
+ }
+
+ CHECK_SET_MIN_MAX(IPPROTO_ICMP, icmp, fd);
+ CHECK_SET_MIN_MAX(IPPROTO_ICMPV6, icmp, fd);
+ CHECK_SET_MIN_MAX(IPPROTO_TCP, tcp, fd);
+ CHECK_SET_MIN_MAX(IPPROTO_UDP, udp, fd);
+
+#undef CHECK_SET_MIN_MAX
+
if (proto == IPPROTO_ICMP || proto == IPPROTO_ICMPV6)
goto epoll_add;