Infrasctucture ipSrt Function Reference

ipSrt
A fast method of storing and retrieving custom structures using an IP as key.    All inputs are IPs in Dotted Quad notation "1.2.3.4".    Please checkout ul2dq() and dq2ul() dotted quad to unsigned long and back conversion functions in the "str" module.

ipsAdd ipsClose ipsDel ipsFnd ipsGetCnt ipsInit
ipsOpen ipsTrav


int ipsAdd( int hndl, char* dqIn, void* aarg )
Add an IP to the data set associated with "hndl".    The IP, is supplied in dotted quad "dqIn".    The argument "aarg" may be apointer to anything, but will usually be a structure pointer and will be returned by ipsFnd().    Returns a pointer the arg (new or old).


int ipsClose( int hndl )
Close and free up space for the data set associated with "hndl&qut;.   


int ipsDel( int hndl, char* dqIn )
Delete an IP from the data set associated with "hndl".    The IP is in dotted quad "dqIn" notation.   


void* ipsFnd( int hndl, void* dqIn )
Find an IP in the data set associated with "hndl" and return the address of the original arg stored with it.    Returning the address of "arg" allows us to store counts and other integer data in the arg.    If the IP is not found, NULL is returned.    The IP is in dotted quad "dqIn" notation.    The returned void pointer, is the address of the argument stored with the IP when it was added to the data set.


int ipsGetCnt( int hndl )
Gets the current IP count in the data set associated with "hndl".   


int ipsInit( int argc, char* argv )
Initialize the ipSrt layer.   


int ipsOpen( )
Initialize a data set and return the access handle.   


int ipsTrav( int hndl, pfi_t func, void* targ )
Traverse the data set associated with "hndl" in IP order.    The entire data set will be traversed and at each node the supplied function "func" will be called and passed the argument supplied to ipsTrav "targ", a pointer to the IP in ascii dotted quad "1.2.3.4", and the argument supplied to ipsAdd() "aarg".
The callback prototype is:
func( void *targ, char *dq, void *aarg )

Where "arg" is the argument supplied to the ipsTrav() call and "dq" is the IP in ascii dotted quad.