[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7605 - GNUnet/src/util/network
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7605 - GNUnet/src/util/network |
Date: |
Sun, 24 Aug 2008 15:46:02 -0600 (MDT) |
Author: grothoff
Date: 2008-08-24 15:46:02 -0600 (Sun, 24 Aug 2008)
New Revision: 7605
Modified:
GNUnet/src/util/network/ipcheck.c
Log:
allowing /16
Modified: GNUnet/src/util/network/ipcheck.c
===================================================================
--- GNUnet/src/util/network/ipcheck.c 2008-08-24 21:29:31 UTC (rev 7604)
+++ GNUnet/src/util/network/ipcheck.c 2008-08-24 21:46:02 UTC (rev 7605)
@@ -248,6 +248,8 @@
int ret;
char *routeList;
CIDR6Network *result;
+ unsigned int bits;
+ unsigned int off;
if (routeListX == NULL)
return NULL;
@@ -293,22 +295,41 @@
ret = inet_pton (AF_INET6,
&routeList[slash + 1], &result[i].netmask);
if (ret <= 0)
- {
- if (ret == 0)
- GNUNET_GE_LOG (ectx,
- GNUNET_GE_ERROR | GNUNET_GE_USER |
- GNUNET_GE_IMMEDIATE,
- _("Wrong format `%s' for netmask\n"),
- &routeList[slash + 1]);
- else
- GNUNET_GE_LOG_STRERROR (ectx,
- GNUNET_GE_ERROR | GNUNET_GE_USER |
- GNUNET_GE_IMMEDIATE,
- "inet_pton");
- GNUNET_free (result);
- GNUNET_free (routeList);
- return NULL;
- }
+ {
+ if ( (1 != SSCANF(&routeList[slash + 1],
+ "%u",
+ &bits)) &&
+ (bits >= 0) &&
+ (bits <= 128) )
+ {
+ if (ret == 0)
+ GNUNET_GE_LOG (ectx,
+ GNUNET_GE_ERROR | GNUNET_GE_USER |
+ GNUNET_GE_IMMEDIATE,
+ _("Wrong format `%s' for netmask\n"),
+ &routeList[slash + 1]);
+ else
+ GNUNET_GE_LOG_STRERROR (ectx,
+ GNUNET_GE_ERROR | GNUNET_GE_USER |
+ GNUNET_GE_IMMEDIATE,
+ "inet_pton");
+ GNUNET_free (result);
+ GNUNET_free (routeList);
+ return NULL;
+ }
+ off = 0;
+ while (bits > 8)
+ {
+ result[i].netmask.s6_addr[off++] = 0xFF;
+ bits -= 8;
+ }
+ while (bits > 0)
+ {
+ result[i].netmask.s6_addr[off]
+ = (result[i].netmask.s6_addr[off] >> 1) + 0x80;
+ bits--;
+ }
+ }
}
routeList[slash] = '\0';
ret = inet_pton (AF_INET6, &routeList[start], &result[i].network);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7605 - GNUnet/src/util/network,
gnunet <=