From 102e356db79e993614e9b3f47c874fb6d1e67494 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Wed, 15 Oct 2008 22:50:25 +0200 Subject: [PATCH] prepared code for generic xiocheckrange --- xio-socket.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xio-socket.c b/xio-socket.c index b924f66..a28710f 100644 --- a/xio-socket.c +++ b/xio-socket.c @@ -1671,6 +1671,8 @@ int xiodopacketinfo(struct msghdr *msgh, bool withlog, bool withenv) { } +/* check if peer address is within permitted range. + return >= 0 if so. */ int xiocheckrange(union sockaddr_union *sa, struct xiorange *range) { switch (sa->soa.sa_family) { #if WITH_IP4 @@ -1683,6 +1685,18 @@ int xiocheckrange(union sockaddr_union *sa, struct xiorange *range) { return xiocheckrange_ip6(&sa->ip6, range); #endif /* WITH_IP6 */ +#if 0 + case PF_UNSPEC: + { + socklen_t i; + for (i = 0; i < sizeof(sa->soa.sa_data); ++i) { + if ((range->netmask.soa.sa_data[i] & sa->soa.sa_data[i]) != range->netaddr.soa.sa_data[i]) { + return -1; + } + } + return 0; + } +#endif } return -1; }