mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 23:42:34 +00:00
prepared code for generic xiocheckrange
This commit is contained in:
parent
4821c5b638
commit
102e356db7
1 changed files with 14 additions and 0 deletions
14
xio-socket.c
14
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) {
|
int xiocheckrange(union sockaddr_union *sa, struct xiorange *range) {
|
||||||
switch (sa->soa.sa_family) {
|
switch (sa->soa.sa_family) {
|
||||||
#if WITH_IP4
|
#if WITH_IP4
|
||||||
|
@ -1683,6 +1685,18 @@ int xiocheckrange(union sockaddr_union *sa, struct xiorange *range) {
|
||||||
return
|
return
|
||||||
xiocheckrange_ip6(&sa->ip6, range);
|
xiocheckrange_ip6(&sa->ip6, range);
|
||||||
#endif /* WITH_IP6 */
|
#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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue