This should work much better.
[tinc] / src / netutl.c
index 1e08a9e..4d91bf4 100644 (file)
@@ -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.35 2002/04/19 14:06:40 guus Exp $
+    $Id: netutl.c,v 1.12.4.37 2002/06/07 11:14:05 wsl Exp $
 */
 
 #include "config.h"
 */
 
 #include "config.h"
@@ -27,7 +27,9 @@
 #include <netinet/in.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <netinet/in.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdint.h>
+#ifndef HAVE_NETBSD
+ #include <stdint.h>
+#endif
 #include <string.h>
 #include <signal.h>
 #include <sys/socket.h>
 #include <string.h>
 #include <signal.h>
 #include <sys/socket.h>
@@ -234,14 +236,13 @@ int maskcheck(char *a, int masklen, int len)
 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;
 }