ippool update to allow for gateway address
diff --git a/ggsn/ippool.c b/ggsn/ippool.c
index 99842c5..331306f 100644
--- a/ggsn/ippool.c
+++ b/ggsn/ippool.c
@@ -185,16 +185,7 @@
&m1, &m2, &m3, &m4);
switch (c) {
case 4:
- if (a1 == 0 && a2 == 0 && a3 == 0 && a4 == 0) /* Full Internet */
- mask->s_addr = 0x00000000;
- else if (a2 == 0 && a3 == 0 && a4 == 0) /* class A */
- mask->s_addr = htonl(0xff000000);
- else if (a3 == 0 && a4 == 0) /* class B */
- mask->s_addr = htonl(0xffff0000);
- else if (a4 == 0) /* class C */
- mask->s_addr = htonl(0xffffff00);
- else
- mask->s_addr = 0xffffffff;
+ mask->s_addr = 0xffffffff;
break;
case 5:
if (m1 < 0 || m1 > 32) {
@@ -245,11 +236,18 @@
else {
if (ippool_aton(&addr, &mask, dyn, 0))
return -1; /* Failed to parse dynamic pool */
+
+ /* Set IPPOOL_NONETWORK if IPPOOL_NOGATEWAY is set */
+ if (flags & IPPOOL_NOGATEWAY) {
+ flags |= IPPOOL_NONETWORK;
+ }
m = ntohl(mask.s_addr);
dynsize = ((~m)+1);
if (flags & IPPOOL_NONETWORK) /* Exclude network address from pool */
dynsize--;
+ if (flags & IPPOOL_NOGATEWAY) /* Exclude gateway address from pool */
+ dynsize--;
if (flags & IPPOOL_NOBROADCAST) /* Exclude broadcast address from pool */
dynsize--;
}
@@ -306,11 +304,13 @@
(*this)->lastdyn = NULL;
for (i = 0; i<dynsize; i++) {
- if (flags & IPPOOL_NONETWORK)
+ if (flags & IPPOOL_NOGATEWAY)
+ (*this)->member[i].addr.s_addr = htonl(ntohl(addr.s_addr) + i + 2);
+ else if (flags & IPPOOL_NONETWORK)
(*this)->member[i].addr.s_addr = htonl(ntohl(addr.s_addr) + i + 1);
else
(*this)->member[i].addr.s_addr = htonl(ntohl(addr.s_addr) + i);
-
+
(*this)->member[i].inuse = 0;
/* Insert into list of unused */
diff --git a/ggsn/ippool.h b/ggsn/ippool.h
index 1630a63..67a6f3e 100644
--- a/ggsn/ippool.h
+++ b/ggsn/ippool.h
@@ -35,6 +35,7 @@
#define IPPOOL_NONETWORK 0x01
#define IPPOOL_NOBROADCAST 0x02
+#define IPPOOL_NOGATEWAY 0x04
#define IPPOOL_STATSIZE 0x10000