projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Include netbsd's device.c in make dist
[tinc]
/
src
/
netutl.c
diff --git
a/src/netutl.c
b/src/netutl.c
index
29bcfc1
..
cfaf6b4
100644
(file)
--- a/
src/netutl.c
+++ b/
src/netutl.c
@@
-17,7
+17,7
@@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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.3
6 2002/06/05 00:25:54
guus Exp $
+ $Id: netutl.c,v 1.12.4.3
9 2002/06/08 13:46:43
guus Exp $
*/
#include "config.h"
*/
#include "config.h"
@@
-27,8
+27,8
@@
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
-#if
ndef HAVE_NETBSD
- #include <
stdint
.h>
+#if
def HAVE_INTTYPES_H
+ #include <
inttypes
.h>
#endif
#include <string.h>
#include <signal.h>
#endif
#include <string.h>
#include <signal.h>
@@
-115,10
+115,8
@@
cp
exit(0);
}
exit(0);
}
-#ifdef HAVE_LINUX
if((scopeid = strchr(address, '%')))
*scopeid = '\0'; /* Descope. */
if((scopeid = strchr(address, '%')))
*scopeid = '\0'; /* Descope. */
-#endif
*addrstr = xstrdup(address);
*portstr = xstrdup(port);
*addrstr = xstrdup(address);
*portstr = xstrdup(port);
@@
-185,9
+183,11
@@
void sockaddrunmap(sockaddr_t *sa)
/* Subnet mask handling */
/* Subnet mask handling */
-int maskcmp(
char *a, char *
b, int masklen, int len)
+int maskcmp(
void *va, void *v
b, int masklen, int len)
{
int i, m, result;
{
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]))
cp
for(m = masklen, i = 0; m >= 8; m -= 8, i++)
if((result = a[i] - b[i]))
@@
-199,9
+199,10
@@
cp
return 0;
}
return 0;
}
-void mask(
char *
a, int masklen, int len)
+void mask(
void *v
a, int masklen, int len)
{
int i;
{
int i;
+ char *a = va;
cp
i = masklen / 8;
masklen %= 8;
cp
i = masklen / 8;
masklen %= 8;
@@
-213,9
+214,11
@@
cp
a[i] = 0;
}
a[i] = 0;
}
-void maskcpy(
char *a, char *
b, int masklen, int len)
+void maskcpy(
void *va, void *v
b, int masklen, int len)
{
int i, m;
{
int i, m;
+ char *a = va;
+ char *b = vb;
cp
for(m = masklen, i = 0; m >= 8; m -= 8, i++)
a[i] = b[i];
cp
for(m = masklen, i = 0; m >= 8; m -= 8, i++)
a[i] = b[i];
@@
-230,20
+233,20
@@
cp
a[i] = 0;
}
a[i] = 0;
}
-int maskcheck(
char *
a, int masklen, int len)
+int maskcheck(
void *v
a, int masklen, int len)
{
int i;
{
int i;
+ char *a = va;
cp
i = masklen / 8;
masklen %= 8;
cp
i = masklen / 8;
masklen %= 8;
-
- if(masklen)
- if(a[i++] & (char)~(0x100 - (1 << masklen)))
- return -1;
-
+
+ if(a[i++] & (0xff >> masklen))
+ return -1;
+
for(; i < len; i++)
if(a[i] != 0)
for(; i < len; i++)
if(a[i] != 0)
- return -
1
;
+ return -
2
;
return 0;
}
return 0;
}