diff options
Diffstat (limited to 'sgsnemu/ippool.h')
-rw-r--r-- | sgsnemu/ippool.h | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/sgsnemu/ippool.h b/sgsnemu/ippool.h index 2d3f575..1630a63 100644 --- a/sgsnemu/ippool.h +++ b/sgsnemu/ippool.h @@ -31,25 +31,30 @@ in RFC2373. */ -typedef unsigned long int ub4; /* unsigned 4-byte quantities */ -typedef unsigned char ub1; - #define IPPOOL_NOIP6 #define IPPOOL_NONETWORK 0x01 #define IPPOOL_NOBROADCAST 0x02 +#define IPPOOL_STATSIZE 0x10000 + struct ippoolm_t; /* Forward declaration */ struct ippool_t { int listsize; /* Total number of addresses */ + int allowdyn; /* Allow dynamic IP address allocation */ + int allowstat; /* Allow static IP address allocation */ + struct in_addr stataddr; /* Static address range network address */ + struct in_addr statmask; /* Static address range network mask */ struct ippoolm_t *member; /* Listsize array of members */ int hashsize; /* Size of hash table */ int hashlog; /* Log2 size of hash table */ int hashmask; /* Bitmask for calculating hash */ struct ippoolm_t **hash; /* Hashsize array of pointer to member */ - struct ippoolm_t *first; /* Pointer to first available member */ - struct ippoolm_t *last; /* Pointer to last available member */ + struct ippoolm_t *firstdyn; /* Pointer to first free dynamic member */ + struct ippoolm_t *lastdyn; /* Pointer to last free dyanmic member */ + struct ippoolm_t *firststat; /* Pointer to first free static member */ + struct ippoolm_t *laststat; /* Pointer to last free static member */ }; struct ippoolm_t { @@ -58,15 +63,13 @@ struct ippoolm_t { #else struct in_addr addr; /* IP address of this member */ #endif - int inuse; /* 0=available; 1= inuse */ + int inuse; /* 0=available; 1= dynamic; 2 = static */ struct ippoolm_t *nexthash; /* Linked list part of hash table */ - struct ippoolm_t *prev, *next; /* Double linked list of available members */ - struct ippool_t *parent; /* Pointer to parent */ + struct ippoolm_t *prev, *next; /* Linked list of free dynamic or static */ void *peer; /* Pointer to peer protocol handler */ }; - -/* The above structures requires approximately 20+4 = 24 bytes for +/* The above structures require approximately 20+4 = 24 bytes for each address (IPv4). For IPv6 the corresponding value is 32+4 = 36 bytes for each address. */ @@ -74,7 +77,8 @@ struct ippoolm_t { extern unsigned long int ippool_hash4(struct in_addr *addr); /* Create new address pool */ -extern int ippool_new(struct ippool_t **this, char *pool, int flags); +extern int ippool_new(struct ippool_t **this, char *dyn, char *stat, + int allowdyn, int allowstat, int flags); /* Delete existing address pool */ extern int ippool_free(struct ippool_t *this); @@ -89,7 +93,7 @@ extern int ippool_newip(struct ippool_t *this, struct ippoolm_t **member, struct in_addr *addr); /* Return a previously allocated IP address */ -extern int ippool_freeip(struct ippoolm_t *member); +extern int ippool_freeip(struct ippool_t *this, struct ippoolm_t *member); /* Get net and mask based on ascii string */ extern int ippool_aton(struct in_addr *addr, struct in_addr *mask, |