Building.Open.Source.Network.Security.Tools.Components.And.Techniques [Electronic resources]

Mike D. Schiffman

نسخه متنی -صفحه : 135/ 34
نمايش فراداده

Port List Functions

The following functions initialize and manipulate libnet port list chains. The port list interface is a memory-efficient way to implement ranges of TCP and UDP ports.


int libnet_plist_chain_new(libnet_t *1, libnet_plist_t
**head, char *tok_list);

libnet_plist_chain_new() initializes a libnet port list chain that is useful for TCP and UDP-based application. The port list chain, which tok_list points to, should contain a series of characters from the following list: "0123456789,-" of the general format "x - y, z" where "xyz" are port numbers between 0 and 65,535. head points to the front of the port list chain list for use in further libnet_plist_chain() functions. Upon success, the function returns 1. Upon failure, the function returns -1 and libnet_geterror() tells you why. A legal port list chain string can consist of the following items:

1-1024,6000-6010 (ports 1 through 1024 and 6000 through 6010)

23 (only port 23)

1 - — all ports inclusive to 65,535


int libnet_plist_chain_next_pair(libnet_plist_t *p, u_short
*bport, u_short *eport);

libnet_plist_chain_next_pair() returns the next port list chain pair from the port list chain p.bport and eport contain the starting port number and ending port number, respectively. Upon success, the function returns 1 and fills in the port variables; however, if the list is empty, the function returns 0 and sets both port variables to 0. Upon failure, the function returns -1.


int libnet_plist_chain_dump(libnet_plist_t *p);

libnet_plist_chain_dump() dumps the port chain list to which p refers to stdout.


u_char *libnet_plist_chain_dump_string(libnet_plist_t *p);

libnet_plist_chain_dump_string() returns the port chain list to which p refers.


int libnet_plist_chain_free(libnet_plist_t *p);

libnet_plist_chain_free() frees the memory associated with the port list chain to which p refers.