X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnetutl.c;h=1cf03c3daebf6a35c877891c88702098ed623f7f;hp=4d91bf4460cb1e40662e0c47c915cf4f804b27ed;hb=b5bb06200eda170c9836e1b4474d6f5b920c2151;hpb=d333fca4d611b85dd922ddf35bd9eddcb8095c85 diff --git a/src/netutl.c b/src/netutl.c index 4d91bf44..1cf03c3d 100644 --- a/src/netutl.c +++ b/src/netutl.c @@ -1,7 +1,7 @@ /* netutl.c -- some supporting network utility code - Copyright (C) 1998-2002 Ivo Timmermans - 2000-2002 Guus Sliepen + Copyright (C) 1998-2002 Ivo Timmermans + 2000-2002 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: netutl.c,v 1.12.4.37 2002/06/07 11:14:05 wsl Exp $ + $Id: netutl.c,v 1.12.4.41 2002/06/21 17:49:48 guus Exp $ */ #include "config.h" @@ -27,8 +27,8 @@ #include #include #include -#ifndef HAVE_NETBSD - #include +#ifdef HAVE_INTTYPES_H + #include #endif #include #include @@ -115,10 +115,8 @@ cp exit(0); } -#ifdef HAVE_LINUX if((scopeid = strchr(address, '%'))) *scopeid = '\0'; /* Descope. */ -#endif *addrstr = xstrdup(address); *portstr = xstrdup(port); @@ -185,9 +183,11 @@ void sockaddrunmap(sockaddr_t *sa) /* Subnet mask handling */ -int maskcmp(char *a, char *b, int masklen, int len) +int maskcmp(void *va, void *vb, int masklen, int len) { int i, m, result; + char *a = va; + char *b = vb; cp for(m = masklen, i = 0; m >= 8; m -= 8, i++) if((result = a[i] - b[i])) @@ -199,9 +199,10 @@ cp return 0; } -void mask(char *a, int masklen, int len) +void mask(void *va, int masklen, int len) { int i; + char *a = va; cp i = masklen / 8; masklen %= 8; @@ -213,9 +214,11 @@ cp a[i] = 0; } -void maskcpy(char *a, char *b, int masklen, int len) +void maskcpy(void *va, void *vb, int masklen, int len) { int i, m; + char *a = va; + char *b = vb; cp for(m = masklen, i = 0; m >= 8; m -= 8, i++) a[i] = b[i]; @@ -230,14 +233,15 @@ cp a[i] = 0; } -int maskcheck(char *a, int masklen, int len) +int maskcheck(void *va, int masklen, int len) { int i; + char *a = va; cp i = masklen / 8; masklen %= 8; - if(a[i++] & (0xff >> masklen)) + if(masklen && a[i++] & (0xff >> masklen)) return -1; for(; i < len; i++)