libnet-asn1.h   libnet-asn1.h 
skipping to change at line 60 skipping to change at line 60
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRI CT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRI CT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WA Y * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WA Y
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#ifndef __LIBNET_ASN1_H #ifndef __LIBNET_ASN1_H
#define __LIBNET_ASN1_H #define __LIBNET_ASN1_H
#ifndef EIGHTBIT_SUBIDS #ifndef EIGHTBIT_SUBIDS
typedef u_int32_t oid; typedef uint32_t oid;
#define MAX_SUBID 0xFFFFFFFF #define MAX_SUBID 0xFFFFFFFF
#else #else
typedef u_int8_t oid; typedef uint8_t oid;
#define MAX_SUBID 0xFF #define MAX_SUBID 0xFF
#endif #endif
#define MAX_OID_LEN 64 /* max subid's in an oid */ #define MAX_OID_LEN 64 /* max subid's in an oid */
#define ASN_BOOLEAN (0x01) #define ASN_BOOLEAN (0x01)
#define ASN_INTEGER (0x02) #define ASN_INTEGER (0x02)
#define ASN_BIT_STR (0x03) #define ASN_BIT_STR (0x03)
#define ASN_OCTET_STR (0x04) #define ASN_OCTET_STR (0x04)
#define ASN_NULL (0x05) #define ASN_NULL (0x05)
skipping to change at line 97 skipping to change at line 97
#define ASN_EXTENSION_ID (0x1F) #define ASN_EXTENSION_ID (0x1F)
#define ASN_BIT8 (0x80) #define ASN_BIT8 (0x80)
#define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR) #define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR)
#define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) = ASN_EXTENSION_ ID) #define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) = ASN_EXTENSION_ ID)
/* /*
* All of the build_asn1_* (build_asn1_length being an exception) function s * All of the build_asn1_* (build_asn1_length being an exception) function s
* take the same first 3 arguments: * take the same first 3 arguments:
* *
* u_int8_t *data: This is a pointer to the start of the data object to be * uint8_t *data: This is a pointer to the start of the data object to b e
* manipulated. * manipulated.
* int *datalen: This is a pointer to the number of valid bytes followin g * int *datalen: This is a pointer to the number of valid bytes followin g
* "data". This should be not be exceeded in any function . * "data". This should be not be exceeded in any function .
* Upon exiting a function, this value will reflect the * Upon exiting a function, this value will reflect the
* changed "data" and then refer to the new number of vali d * changed "data" and then refer to the new number of vali d
* bytes until the end of "data". * bytes until the end of "data".
* u_int8_t type: The ASN.1 object type. * uint8_t type: The ASN.1 object type.
*/ */
/* /*
* Builds an ASN object containing an integer. * Builds an ASN object containing an integer.
* *
* Returns NULL upon error or a pointer to the first byte past the end of * Returns NULL upon error or a pointer to the first byte past the end of
* this object (the start of the next object). * this object (the start of the next object).
*/ */
u_int8_t * uint8_t *
libnet_build_asn1_int( libnet_build_asn1_int(
u_int8_t *, /* Pointer to the output buffer */ uint8_t *, /* Pointer to the output buffer */
int *, /* Number of valid bytes left in the buffer */ int *, /* Number of valid bytes left in the buffer */
u_int8_t, /* ASN object type */ uint8_t, /* ASN object type */
int32_t *, /* Pointer to a int32_t integer */ int32_t *, /* Pointer to a int32_t integer */
int /* Size of a int32_t integer */ int /* Size of a int32_t integer */
); );
/* /*
* Builds an ASN object containing an unsigned integer. * Builds an ASN object containing an unsigned integer.
* *
* Returns NULL upon error or a pointer to the first byte past the end of * Returns NULL upon error or a pointer to the first byte past the end of
* this object (the start of the next object). * this object (the start of the next object).
*/ */
u_int8_t * uint8_t *
libnet_build_asn1_uint( libnet_build_asn1_uint(
u_int8_t *, /* Pointer to the output buffer */ uint8_t *, /* Pointer to the output buffer */
int *, /* Number of valid bytes left in the buffer */ int *, /* Number of valid bytes left in the buffer */
u_int8_t, /* ASN object type */ uint8_t, /* ASN object type */
u_int32_t *, /* Pointer to an unsigned int32_t integer */ uint32_t *, /* Pointer to an unsigned int32_t integer */
int /* Size of a int32_t integer */ int /* Size of a int32_t integer */
); );
/* /*
* Builds an ASN object containing an octect string. * Builds an ASN object containing an octect string.
* *
* Returns NULL upon error or a pointer to the first byte past the end of * Returns NULL upon error or a pointer to the first byte past the end of
* this object (the start of the next object). * this object (the start of the next object).
*/ */
u_int8_t * uint8_t *
libnet_build_asn1_string( libnet_build_asn1_string(
u_int8_t *, /* Pointer to the output buffer */ uint8_t *, /* Pointer to the output buffer */
int *, /* Number of valid bytes left in the buffer */ int *, /* Number of valid bytes left in the buffer */
u_int8_t, /* ASN object type */ uint8_t, /* ASN object type */
u_int8_t *, /* Pointer to a string to be built into an object uint8_t *, /* Pointer to a string to be built into an object
*/ */
int /* Size of the string */ int /* Size of the string */
); );
/* /*
* Builds an ASN header for an object with the ID and length specified. T his * Builds an ASN header for an object with the ID and length specified. T his
* only works on data types < 30, i.e. no extension octets. The maximum * only works on data types < 30, i.e. no extension octets. The maximum
* length is 0xFFFF; * length is 0xFFFF;
* *
* Returns a pointer to the first byte of the contents of this object or * Returns a pointer to the first byte of the contents of this object or
* NULL upon error * NULL upon error
*/ */
u_int8_t * uint8_t *
libnet_build_asn1_header( libnet_build_asn1_header(
u_int8_t *, /* Pointer to the start of the object */ uint8_t *, /* Pointer to the start of the object */
int *, /* Number of valid bytes left in buffer */ int *, /* Number of valid bytes left in buffer */
u_int8_t, /* ASN object type */ uint8_t, /* ASN object type */
int /* ASN object length */ int /* ASN object length */
); );
u_int8_t * uint8_t *
libnet_build_asn1_length( libnet_build_asn1_length(
u_int8_t *, /* Pointer to start of object */ uint8_t *, /* Pointer to start of object */
int *, /* Number of valid bytes in buffer */ int *, /* Number of valid bytes in buffer */
int /* Length of object */ int /* Length of object */
); );
/* /*
* Builds an ASN header for a sequence with the ID and length specified. * Builds an ASN header for a sequence with the ID and length specified.
* *
* This only works on data types < 30, i.e. no extension octets. * This only works on data types < 30, i.e. no extension octets.
* The maximum length is 0xFFFF; * The maximum length is 0xFFFF;
* *
* Returns a pointer to the first byte of the contents of this object. * Returns a pointer to the first byte of the contents of this object.
* Returns NULL on any error. * Returns NULL on any error.
*/ */
u_int8_t * uint8_t *
libnet_build_asn1_sequence( libnet_build_asn1_sequence(
u_int8_t *, uint8_t *,
int *, int *,
u_int8_t, uint8_t,
int int
); );
/* /*
* Builds an ASN object identifier object containing the input string. * Builds an ASN object identifier object containing the input string.
* *
* Returns NULL upon error or a pointer to the first byte past the end of * Returns NULL upon error or a pointer to the first byte past the end of
* this object (the start of the next object). * this object (the start of the next object).
*/ */
u_int8_t * uint8_t *
libnet_build_asn1_objid( libnet_build_asn1_objid(
u_int8_t *, uint8_t *,
int *, int *,
u_int8_t, uint8_t,
oid *, oid *,
int int
); );
/* /*
* Builds an ASN null object. * Builds an ASN null object.
* *
* Returns NULL upon error or a pointer to the first byte past the end of * Returns NULL upon error or a pointer to the first byte past the end of
* this object (the start of the next object). * this object (the start of the next object).
*/ */
u_int8_t * uint8_t *
libnet_build_asn1_null( libnet_build_asn1_null(
u_int8_t *, uint8_t *,
int *, int *,
u_int8_t uint8_t
); );
/* /*
* Builds an ASN bitstring. * Builds an ASN bitstring.
* *
* Returns NULL upon error or a pointer to the first byte past the end of * Returns NULL upon error or a pointer to the first byte past the end of
* this object (the start of the next object). * this object (the start of the next object).
*/ */
u_int8_t * uint8_t *
libnet_build_asn1_bitstring( libnet_build_asn1_bitstring(
u_int8_t *, uint8_t *,
int *, int *,
u_int8_t, uint8_t,
u_int8_t *, /* Pointer to the input buffer */ uint8_t *, /* Pointer to the input buffer */
int /* Length of the input buffer */ int /* Length of the input buffer */
); );
#endif /* __LIBNET_ASN1_H */ #endif /* __LIBNET_ASN1_H */
/* EOF */ /* EOF */
 End of changes. 30 change blocks. 
34 lines changed or deleted 34 lines changed or added


 libnet-functions.h   libnet-functions.h 
skipping to change at line 64 skipping to change at line 64
* of size LIBNET_ERRBUF_SIZE and holds an error message if the function fa ils. * of size LIBNET_ERRBUF_SIZE and holds an error message if the function fa ils.
* This function requires root privileges to execute successfully. Upon * This function requires root privileges to execute successfully. Upon
* success, the function returns a valid libnet context for use in later * success, the function returns a valid libnet context for use in later
* function calls; upon failure, the function returns NULL. * function calls; upon failure, the function returns NULL.
* @param injection_type packet injection type (LIBNET_LINK, LIBNET_LINK_AD V, LIBNET_RAW4, LIBNET_RAW4_ADV, LIBNET_RAW6, LIBNET_RAW6_ADV) * @param injection_type packet injection type (LIBNET_LINK, LIBNET_LINK_AD V, LIBNET_RAW4, LIBNET_RAW4_ADV, LIBNET_RAW6, LIBNET_RAW6_ADV)
* @param device the interface to use (NULL and libnet will choose one) * @param device the interface to use (NULL and libnet will choose one)
* @param err_buf will contain an error message on failure * @param err_buf will contain an error message on failure
* @return libnet context ready for use or NULL on error. * @return libnet context ready for use or NULL on error.
*/ */
libnet_t * libnet_t *
libnet_init(int injection_type, char *device, char *err_buf); libnet_init(int injection_type, const char *device, char *err_buf);
/** /**
* Shuts down the libnet session referenced by l. It closes the network * Shuts down the libnet session referenced by l. It closes the network
* interface and frees all internal memory structures associated with l. * interface and frees all internal memory structures associated with l.
* @param l pointer to a libnet context * @param l pointer to a libnet context
*/ */
void void
libnet_destroy(libnet_t *l); libnet_destroy(libnet_t *l);
/** /**
skipping to change at line 117 skipping to change at line 117
libnet_getdevice(libnet_t *l); libnet_getdevice(libnet_t *l);
/** /**
* Returns the pblock buffer contents for the specified ptag; a * Returns the pblock buffer contents for the specified ptag; a
* subsequent call to libnet_getpbuf_size() should be made to determine the * subsequent call to libnet_getpbuf_size() should be made to determine the
* size of the buffer. * size of the buffer.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag the ptag reference number * @param ptag the ptag reference number
* @return a pointer to the pblock buffer or NULL on error * @return a pointer to the pblock buffer or NULL on error
*/ */
u_int8_t * uint8_t *
libnet_getpbuf(libnet_t *l, libnet_ptag_t ptag); libnet_getpbuf(libnet_t *l, libnet_ptag_t ptag);
/** /**
* Returns the pblock buffer size for the specified ptag; a * Returns the pblock buffer size for the specified ptag; a
* previous call to libnet_getpbuf() should be made to pull the actual buff er * previous call to libnet_getpbuf() should be made to pull the actual buff er
* contents. * contents.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag the ptag reference number * @param ptag the ptag reference number
* @return the size of the pblock buffer * @return the size of the pblock buffer
*/ */
u_int32_t uint32_t
libnet_getpbuf_size(libnet_t *l, libnet_ptag_t ptag); libnet_getpbuf_size(libnet_t *l, libnet_ptag_t ptag);
/** /**
* Returns the last error set inside of the referenced libnet context. This * Returns the last error set inside of the referenced libnet context. This
* function should be called anytime a function fails or an error condition * function should be called anytime a function fails or an error condition
* is detected inside of libnet. * is detected inside of libnet.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return an error string or NULL if no error has occured * @return an error string or NULL if no error has occured
*/ */
char * char *
libnet_geterror(libnet_t *l); libnet_geterror(libnet_t *l);
/** /**
* Returns the sum of the size of all of the pblocks inside of l (this shou ld * Returns the sum of the size of all of the pblocks inside of l (this shou ld
* be the resuling packet size). * be the resuling packet size).
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return the size of the packet in l * @return the size of the packet in l
*/ */
u_int32_t uint32_t
libnet_getpacket_size(libnet_t *l); libnet_getpacket_size(libnet_t *l);
/** /**
* Seeds the psuedo-random number generator. * Seeds the psuedo-random number generator.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return 1 on success, -1 on failure * @return 1 on success, -1 on failure
*/ */
int int
libnet_seed_prand(libnet_t *l); libnet_seed_prand(libnet_t *l);
skipping to change at line 171 skipping to change at line 171
* LIBNET_PR2 0 - 1 * LIBNET_PR2 0 - 1
* LIBNET_PR8 0 - 255 * LIBNET_PR8 0 - 255
* LIBNET_PR16 0 - 32767 * LIBNET_PR16 0 - 32767
* LIBNET_PRu16 0 - 65535 * LIBNET_PRu16 0 - 65535
* LIBNET_PR32 0 - 2147483647 * LIBNET_PR32 0 - 2147483647
* LIBNET_PRu32 0 - 4294967295 * LIBNET_PRu32 0 - 4294967295
* *
* @param mod one the of LIBNET_PR* constants * @param mod one the of LIBNET_PR* constants
* @return 1 on success, -1 on failure * @return 1 on success, -1 on failure
*/ */
u_int32_t uint32_t
libnet_get_prand(int mod); libnet_get_prand(int mod);
/** /**
* If a given protocol header is built with the checksum field set to "0", by * If a given protocol header is built with the checksum field set to "0", by
* default libnet will calculate the header checksum prior to injection. If the * default libnet will calculate the header checksum prior to injection. If the
* header is set to any other value, by default libnet will not calculate t he * header is set to any other value, by default libnet will not calculate t he
* header checksum. To over-ride this behavior, use libnet_toggle_checksum( ). * header checksum. To over-ride this behavior, use libnet_toggle_checksum( ).
* Switches auto-checksumming on or off for the specified ptag. If mode is set * Switches auto-checksumming on or off for the specified ptag. If mode is set
* to LIBNET_ON, libnet will mark the specificed ptag to calculate a checks um * to LIBNET_ON, libnet will mark the specificed ptag to calculate a checks um
* for the ptag prior to injection. This assumes that the ptag refers to a * for the ptag prior to injection. This assumes that the ptag refers to a
skipping to change at line 211 skipping to change at line 211
* incur a DNS lookup if the hostname and mode is set to LIBNET_RESOLVE. If * incur a DNS lookup if the hostname and mode is set to LIBNET_RESOLVE. If
* mode is set to LIBNET_DONT_RESOLVE, no DNS lookup will be performed and * mode is set to LIBNET_DONT_RESOLVE, no DNS lookup will be performed and
* the function will return a pointer to a dotted decimal string. The funct ion * the function will return a pointer to a dotted decimal string. The funct ion
* cannot fail -- if no canonical name exists, it will fall back on returni ng * cannot fail -- if no canonical name exists, it will fall back on returni ng
* a dotted decimal string. This function is non-reentrant. * a dotted decimal string. This function is non-reentrant.
* @param in network byte ordered IPv4 address * @param in network byte ordered IPv4 address
* @param use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE * @param use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
* @return a pointer to presentation format string * @return a pointer to presentation format string
*/ */
char * char *
libnet_addr2name4(u_int32_t in, u_int8_t use_name); libnet_addr2name4(uint32_t in, uint8_t use_name);
/** /**
* Takes a dotted decimal string or a canonical DNS name and returns a * Takes a dotted decimal string or a canonical DNS name and returns a
* network byte ordered IPv4 address. This may incur a DNS lookup if mode i s * network byte ordered IPv4 address. This may incur a DNS lookup if mode i s
* set to LIBNET_RESOLVE and host_name refers to a canonical DNS name. If m ode * set to LIBNET_RESOLVE and host_name refers to a canonical DNS name. If m ode
* is set to LIBNET_DONT_RESOLVE no DNS lookup will occur. The function can * is set to LIBNET_DONT_RESOLVE no DNS lookup will occur. The function can
* fail if DNS lookup fails or if mode is set to LIBNET_DONT_RESOLVE and * fail if DNS lookup fails or if mode is set to LIBNET_DONT_RESOLVE and
* host_name refers to a canonical DNS name. * host_name refers to a canonical DNS name.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param host_name pointer to a string containing a presentation format ho st * @param host_name pointer to a string containing a presentation format ho st
* name * name
* @param use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE * @param use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
* @return network byte ordered IPv4 address or -1 (2^32 - 1) on error * @return network byte ordered IPv4 address or -1 (2^32 - 1) on error
*/ */
u_int32_t uint32_t
libnet_name2addr4(libnet_t *l, char *host_name, u_int8_t use_name); libnet_name2addr4(libnet_t *l, char *host_name, uint8_t use_name);
extern const struct libnet_in6_addr in6addr_error; extern const struct libnet_in6_addr in6addr_error;
/** /**
* Takes a dotted decimal string or a canonical DNS name and returns a * Takes a dotted decimal string or a canonical DNS name and returns a
* network byte ordered IPv6 address. This may incur a DNS lookup if mode i s * network byte ordered IPv6 address. This may incur a DNS lookup if mode i s
* set to LIBNET_RESOLVE and host_name refers to a canonical DNS name. If m ode * set to LIBNET_RESOLVE and host_name refers to a canonical DNS name. If m ode
* is set to LIBNET_DONT_RESOLVE no DNS lookup will occur. The function can * is set to LIBNET_DONT_RESOLVE no DNS lookup will occur. The function can
* fail if DNS lookup fails or if mode is set to LIBNET_DONT_RESOLVE and * fail if DNS lookup fails or if mode is set to LIBNET_DONT_RESOLVE and
* host_name refers to a canonical DNS name. * host_name refers to a canonical DNS name.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param host_name pointer to a string containing a presentation format ho st * @param host_name pointer to a string containing a presentation format ho st
* name * name
* @param use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE * @param use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
* @return network byte ordered IPv6 address structure * @return network byte ordered IPv6 address structure
*/ */
struct libnet_in6_addr struct libnet_in6_addr
libnet_name2addr6(libnet_t *l, char *host_name, u_int8_t use_name); libnet_name2addr6(libnet_t *l, char *host_name, uint8_t use_name);
/** /**
* Should document this baby right here. * Should document this baby right here.
*/ */
void void
libnet_addr2name6_r(struct libnet_in6_addr addr, u_int8_t use_name, libnet_addr2name6_r(struct libnet_in6_addr addr, uint8_t use_name,
char *host_name, int host_name_len); char *host_name, int host_name_len);
/** /**
* Creates a new port list. Port list chains are useful for TCP and UDP-bas ed * Creates a new port list. Port list chains are useful for TCP and UDP-bas ed
* applications that need to send packets to a range of ports (contiguous o r * applications that need to send packets to a range of ports (contiguous o r
* otherwise). The port list chain, which token_list points to, should cont ain * otherwise). The port list chain, which token_list points to, should cont ain
* a series of int8_tacters from the following list: "0123456789,-" of the * a series of int8_tacters from the following list: "0123456789,-" of the
* general format "x - y, z", where "xyz" are port numbers between 0 and * general format "x - y, z", where "xyz" are port numbers between 0 and
* 65,535. plist points to the front of the port list chain list for use in * 65,535. plist points to the front of the port list chain list for use in
* further libnet_plist_chain() functions. Upon success, the function retur ns * further libnet_plist_chain() functions. Upon success, the function retur ns
skipping to change at line 284 skipping to change at line 284
* and eport contain the starting port number and ending port number, * and eport contain the starting port number and ending port number,
* respectively. Upon success, the function returns 1 and fills in the port * respectively. Upon success, the function returns 1 and fills in the port
* variables; however, if the list is empty, the function returns 0 and set s * variables; however, if the list is empty, the function returns 0 and set s
* both port variables to 0. Upon failure, the function returns -1. * both port variables to 0. Upon failure, the function returns -1.
* @param plist previously created portlist * @param plist previously created portlist
* @param bport will contain the beginning port number or 0 * @param bport will contain the beginning port number or 0
* @param eport will contain the ending port number or 0 * @param eport will contain the ending port number or 0
* @return 1 on success, 0 if empty, -1 on failure * @return 1 on success, 0 if empty, -1 on failure
*/ */
int int
libnet_plist_chain_next_pair(libnet_plist_t *plist, u_int16_t *bport, libnet_plist_chain_next_pair(libnet_plist_t *plist, uint16_t *bport,
u_int16_t *eport); uint16_t *eport);
/** /**
* Runs through the port list and prints the contents of the port list chai n * Runs through the port list and prints the contents of the port list chai n
* list to stdout. * list to stdout.
* @param plist previously created portlist * @param plist previously created portlist
* @return 1 on success, -1 on failure * @return 1 on success, -1 on failure
*/ */
int int
libnet_plist_chain_dump(libnet_plist_t *plist); libnet_plist_chain_dump(libnet_plist_t *plist);
skipping to change at line 357 skipping to change at line 357
* *
* The payload interface specifies an optional way to include data directly * The payload interface specifies an optional way to include data directly
* after the protocol header in question. You can use this function for a * after the protocol header in question. You can use this function for a
* variety of purposes, including the following: * variety of purposes, including the following:
* - Including additional or arbitrary protocol header information that is not * - Including additional or arbitrary protocol header information that is not
* available from a libnet interface * available from a libnet interface
* - Including a packet payload (data segment) * - Including a packet payload (data segment)
* - Building another protocol header that is not available from a libnet * - Building another protocol header that is not available from a libnet
* interface * interface
* To employ the interface, the application programmer should construct the i * To employ the interface, the application programmer should construct the i
* payload data and pass a u_int8_t * to this data and its size to the desi red * payload data and pass a const uint8_t * to this data and its size to the desired
* libnet_build() function. Libnet handles the rest. * libnet_build() function. Libnet handles the rest.
* *
* It is important to note that some functions (notably the IPv6 builders) do * It is important to note that some functions (notably the IPv6 builders) do
* use the payload interface to specify variable length but ostensibly * use the payload interface to specify variable length but ostensibly
* non-optional data. See the individual libnet_build_ipv6*() functions for * non-optional data. See the individual libnet_build_ipv6*() functions for
* more information. * more information.
* *
* @subsection PT Protocol Tags and Packet Builder Return Values * @subsection PT Protocol Tags and Packet Builder Return Values
* *
* Libnet uses the protocol tag (ptag) to identify individual pieces of a * Libnet uses the protocol tag (ptag) to identify individual pieces of a
skipping to change at line 403 skipping to change at line 403
* @param cfi canonical format indicator * @param cfi canonical format indicator
* @param vlan_id vlan identifier * @param vlan_id vlan identifier
* @param len_proto length (802.3) protocol (Ethernet II) * @param len_proto length (802.3) protocol (Ethernet II)
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_802_1q(u_int8_t *dst, u_int8_t *src, u_int16_t tpi, libnet_build_802_1q(const uint8_t *dst, const uint8_t *src, uint16_t tpi,
u_int8_t priority, u_int8_t cfi, u_int16_t vlan_id, u_int16_t len_proto, uint8_t priority, uint8_t cfi, uint16_t vlan_id, uint16_t len_proto,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds an IEEE 802.1x extended authentication protocol header. * Builds an IEEE 802.1x extended authentication protocol header.
* @param eap_ver the EAP version * @param eap_ver the EAP version
* @param eap_type the EAP type * @param eap_type the EAP type
* @param length frame length * @param length frame length
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_802_1x(u_int8_t eap_ver, u_int8_t eap_type, u_int16_t length, libnet_build_802_1x(uint8_t eap_ver, uint8_t eap_type, uint16_t length,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds an IEEE 802.2 LLC header. * Builds an IEEE 802.2 LLC header.
* @param dsap destination service access point * @param dsap destination service access point
* @param ssap source service access point * @param ssap source service access point
* @param control control field * @param control control field
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_802_2(u_int8_t dsap, u_int8_t ssap, u_int8_t control, libnet_build_802_2(uint8_t dsap, uint8_t ssap, uint8_t control,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds an IEEE 802.2 LLC SNAP header. * Builds an IEEE 802.2 LLC SNAP header.
* @param dsap destination service access point * @param dsap destination service access point
* @param ssap source service access point * @param ssap source service access point
* @param control control field * @param control control field
* @param oui Organizationally Unique Identifier * @param oui Organizationally Unique Identifier
* @param type upper layer protocol * @param type upper layer protocol
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_802_2snap(u_int8_t dsap, u_int8_t ssap, u_int8_t control, libnet_build_802_2snap(uint8_t dsap, uint8_t ssap, uint8_t control,
u_int8_t *oui, u_int16_t type, u_int8_t *payload, u_int32_t payload_s, uint8_t *oui, uint16_t type, const uint8_t* payload, uint32_t payload_s,
libnet_t *l, libnet_ptag_t ptag); libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds an IEEE 802.3 header. The 802.3 header is almost identical to the * Builds an IEEE 802.3 header. The 802.3 header is almost identical to the
* RFC 894 Ethernet II header, the exception being that the field immediate ly * RFC 894 Ethernet II header, the exception being that the field immediate ly
* following the source address holds the frame's length (as opposed to the * following the source address holds the frame's length (as opposed to the
* layer 3 protocol). You should only use this function when libnet is * layer 3 protocol). You should only use this function when libnet is
* initialized with the LIBNET_LINK interface. * initialized with the LIBNET_LINK interface.
* @param dst destination ethernet address * @param dst destination ethernet address
* @param src source ethernet address * @param src source ethernet address
* @param len frame length sans header * @param len frame length sans header
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_802_3(u_int8_t *dst, u_int8_t *src, u_int16_t len, libnet_build_802_3(const uint8_t *dst, const uint8_t *src, uint16_t len,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds an Ethernet header. The RFC 894 Ethernet II header is almost * Builds an Ethernet header. The RFC 894 Ethernet II header is almost
* identical to the IEEE 802.3 header, with the exception that the field * identical to the IEEE 802.3 header, with the exception that the field
* immediately following the source address holds the layer 3 protocol (as * immediately following the source address holds the layer 3 protocol (as
* opposed to frame's length). You should only use this function when * opposed to frame's length). You should only use this function when
* libnet is initialized with the LIBNET_LINK interface. * libnet is initialized with the LIBNET_LINK interface.
* @param dst destination ethernet address * @param dst destination ethernet address
* @param src source ethernet address * @param src source ethernet address
* @param type upper layer protocol type * @param type upper layer protocol type
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ethernet(u_int8_t *dst, u_int8_t *src, u_int16_t type, libnet_build_ethernet(const uint8_t *dst, const uint8_t *src, uint16_t type
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); ,
const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Autobuilds an Ethernet header. The RFC 894 Ethernet II header is almost * Autobuilds an Ethernet header. The RFC 894 Ethernet II header is almost
* identical to the IEEE 802.3 header, with the exception that the field * identical to the IEEE 802.3 header, with the exception that the field
* immediately following the source address holds the layer 3 protocol (as * immediately following the source address holds the layer 3 protocol (as
* opposed to frame's length). You should only use this function when * opposed to frame's length). You should only use this function when
* libnet is initialized with the LIBNET_LINK interface. * libnet is initialized with the LIBNET_LINK interface.
* @param dst destination ethernet address * @param dst destination ethernet address
* @param type upper layer protocol type * @param type upper layer protocol type
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_autobuild_ethernet(u_int8_t *dst, u_int16_t type, libnet_t *l); libnet_autobuild_ethernet(const uint8_t *dst, uint16_t type, libnet_t *l);
/** /**
* Builds a Fiber Distributed Data Interface (FDDI) header. * Builds a Fiber Distributed Data Interface (FDDI) header.
* @param fc class format and priority * @param fc class format and priority
* @param dst destination fddi address * @param dst destination fddi address
* @param src source fddi address * @param src source fddi address
* @param dsap destination service access point * @param dsap destination service access point
* @param ssap source service access point * @param ssap source service access point
* @param cf cf * @param cf cf
* @param oui 3 byte IEEE organizational code * @param oui 3 byte IEEE organizational code
* @param type upper layer protocol * @param type upper layer protocol
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_fddi(u_int8_t fc, u_int8_t *dst, u_int8_t *src, u_int8_t dsap, libnet_build_fddi(uint8_t fc, const uint8_t *dst, const uint8_t *src, uint8
u_int8_t ssap, u_int8_t cf, u_int8_t *oui, u_int16_t type, u_int8_t *payloa _t dsap,
d, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type, const uint8_t*
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* Autobuilds a Fiber Distributed Data Interface (FDDI) header. * Autobuilds a Fiber Distributed Data Interface (FDDI) header.
* @param fc class format and priority * @param fc class format and priority
* @param dst destination fddi address * @param dst destination fddi address
* @param dsap destination service access point * @param dsap destination service access point
* @param ssap source service access point * @param ssap source service access point
* @param cf cf * @param cf cf
* @param oui IEEE organizational code * @param oui IEEE organizational code
* @param type upper layer protocol * @param type upper layer protocol
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_autobuild_fddi(u_int8_t fc, u_int8_t *dst, u_int8_t dsap, u_int8_t s libnet_autobuild_fddi(uint8_t fc, const uint8_t *dst, uint8_t dsap, uint8_t
sap, ssap,
u_int8_t cf, u_int8_t *oui, u_int16_t type, libnet_t *l); uint8_t cf, const uint8_t *oui, uint16_t type, libnet_t *l);
/** /**
* Builds an Address Resolution Protocol (ARP) header. Depending on the op * Builds an Address Resolution Protocol (ARP) header. Depending on the op
* value, the function builds one of several different types of RFC 826 or * value, the function builds one of several different types of RFC 826 or
* RFC 903 RARP packets. * RFC 903 RARP packets.
* @param hrd hardware address format * @param hrd hardware address format
* @param pro protocol address format * @param pro protocol address format
* @param hln hardware address length * @param hln hardware address length
* @param pln protocol address length * @param pln protocol address length
* @param op ARP operation type * @param op ARP operation type
skipping to change at line 564 skipping to change at line 564
* @param spa sender's protocol address * @param spa sender's protocol address
* @param tha target hardware address * @param tha target hardware address
* @param tpa targer protocol address * @param tpa targer protocol address
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_arp(u_int16_t hrd, u_int16_t pro, u_int8_t hln, u_int8_t pln, libnet_build_arp(uint16_t hrd, uint16_t pro, uint8_t hln, uint8_t pln,
u_int16_t op, u_int8_t *sha, u_int8_t *spa, u_int8_t *tha, u_int8_t *tpa, uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha, co
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); nst uint8_t *tpa,
const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Autouilds an Address Resolution Protocol (ARP) header. Depending on the op * Autouilds an Address Resolution Protocol (ARP) header. Depending on the op
* value, the function builds one of several different types of RFC 826 or * value, the function builds one of several different types of RFC 826 or
* RFC 903 RARP packets. * RFC 903 RARP packets.
* @param op ARP operation type * @param op ARP operation type
* @param sha sender's hardware address * @param sha sender's hardware address
* @param spa sender's protocol address * @param spa sender's protocol address
* @param tha target hardware address * @param tha target hardware address
* @param tpa targer protocol address * @param tpa targer protocol address
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_autobuild_arp(u_int16_t op, u_int8_t *sha, u_int8_t *spa, u_int8_t * libnet_autobuild_arp(uint16_t op, const uint8_t *sha, const uint8_t *spa, c
tha, onst uint8_t *tha,
u_int8_t *tpa, libnet_t *l); uint8_t *tpa, libnet_t *l);
/** /**
* Builds an RFC 793 Transmission Control Protocol (TCP) header. * Builds an RFC 793 Transmission Control Protocol (TCP) header.
* @param sp source port * @param sp source port
* @param dp destination port * @param dp destination port
* @param seq sequence number * @param seq sequence number
* @param ack acknowledgement number * @param ack acknowledgement number
* @param control control flags * @param control control flags
* @param win window size * @param win window size
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param urg urgent pointer * @param urg urgent pointer
* @param len total length of the TCP packet (for checksum calculation) * @param len total length of the TCP packet (for checksum calculation)
* @param payload * @param payload
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_tcp(u_int16_t sp, u_int16_t dp, u_int32_t seq, u_int32_t ack, libnet_build_tcp(uint16_t sp, uint16_t dp, uint32_t seq, uint32_t ack,
u_int8_t control, u_int16_t win, u_int16_t sum, u_int16_t urg, u_int16_t le uint8_t control, uint16_t win, uint16_t sum, uint16_t urg, uint16_t len,
n, const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); );
/** /**
* Builds an RFC 793 Transmission Control Protocol (TCP) options header. * Builds an RFC 793 Transmission Control Protocol (TCP) options header.
* The function expects options to be a valid TCP options string of size * The function expects options to be a valid TCP options string of size
* options_s, which is no larger than 40 bytes (the maximum size of an * options_s, which is no larger than 40 bytes (the maximum size of an
* options string). The function checks to ensure that the packet consists of * options string). The function checks to ensure that the packet consists of
* a TCP header preceded by an IPv4 header, and that the addition of the * a TCP header preceded by an IPv4 header, and that the addition of the
* options string would not result in a packet larger than 65,535 bytes * options string would not result in a packet larger than 65,535 bytes
* (IPMAXPACKET). The function counts up the number of 32-bit words in the * (IPMAXPACKET). The function counts up the number of 32-bit words in the
* options string and adjusts the TCP header length value as necessary. * options string and adjusts the TCP header length value as necessary.
* @param options byte string of TCP options * @param options byte string of TCP options
* @param options_s length of options string * @param options_s length of options string
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_tcp_options(u_int8_t *options, u_int32_t options_s, libnet_t * l, libnet_build_tcp_options(const uint8_t *options, uint32_t options_s, libnet _t *l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* Builds an RFC 768 User Datagram Protocol (UDP) header. * Builds an RFC 768 User Datagram Protocol (UDP) header.
* @param sp source port * @param sp source port
* @param dp destination port * @param dp destination port
* @param len total length of the UDP packet * @param len total length of the UDP packet
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_udp(u_int16_t sp, u_int16_t dp, u_int16_t len, u_int16_t sum, libnet_build_udp(uint16_t sp, uint16_t dp, uint16_t len, uint16_t sum,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds a Cisco Discovery Protocol (CDP) header. Cisco Systems designed C DP * Builds a Cisco Discovery Protocol (CDP) header. Cisco Systems designed C DP
* to aid in the network management of adjacent Cisco devices. The CDP prot ocol * to aid in the network management of adjacent Cisco devices. The CDP prot ocol
* specifies data by using a type/length/value (TLV) setup. The first TLV c an * specifies data by using a type/length/value (TLV) setup. The first TLV c an
* specified by using the functions type, length, and value arguments. To * specified by using the functions type, length, and value arguments. To
* specify additional TLVs, the programmer could either use the payload * specify additional TLVs, the programmer could either use the payload
* interface or libnet_build_data() to construct them. * interface or libnet_build_data() to construct them.
* @param version CDP version * @param version CDP version
* @param ttl time to live (time information should be cached by recipient) * @param ttl time to live (time information should be cached by recipient)
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param type type of data contained in value * @param type type of data contained in value
* @param len length of value arugment * @param value_s length of value argument
* @param value the CDP information string * @param value the CDP information string
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_cdp(u_int8_t version, u_int8_t ttl, u_int16_t sum, u_int16_t t libnet_build_cdp(uint8_t version, uint8_t ttl, uint16_t sum, uint16_t type,
ype, uint16_t value_s, const uint8_t *value, const uint8_t* payload, uint32_t pa
u_int16_t len, u_int8_t *value, u_int8_t *payload, u_int32_t payload_s, yload_s,
libnet_t *l, libnet_ptag_t ptag); libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) * Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
* echo request/reply header * echo request/reply header
* @param type type of ICMP packet (should be ICMP_ECHOREPLY or ICMP_ECHO) * @param type type of ICMP packet (should be ICMP_ECHOREPLY or ICMP_ECHO)
* @param code code of ICMP packet (should be 0) * @param code code of ICMP packet (should be 0)
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param id identification number * @param id identification number
* @param seq packet sequence number * @param seq packet sequence number
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv4_echo(u_int8_t type, u_int8_t code, u_int16_t sum, libnet_build_icmpv4_echo(uint8_t type, uint8_t code, uint16_t sum,
u_int16_t id, u_int16_t seq, u_int8_t *payload, u_int32_t payload_s, uint16_t id, uint16_t seq, const uint8_t* payload, uint32_t payload_s,
libnet_t *l, libnet_ptag_t ptag); libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) * Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
* IP netmask request/reply header. * IP netmask request/reply header.
* @param type type of ICMP packet (should be ICMP_MASKREQ or ICMP_MASKREPL Y) * @param type type of ICMP packet (should be ICMP_MASKREQ or ICMP_MASKREPL Y)
* @param code code of ICMP packet (should be 0) * @param code code of ICMP packet (should be 0)
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param id identification number * @param id identification number
* @param seq packet sequence number * @param seq packet sequence number
* @param mask subnet mask * @param mask subnet mask
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv4_mask(u_int8_t type, u_int8_t code, u_int16_t sum, libnet_build_icmpv4_mask(uint8_t type, uint8_t code, uint16_t sum,
u_int16_t id, u_int16_t seq, u_int32_t mask, u_int8_t *payload, uint16_t id, uint16_t seq, uint32_t mask, const uint8_t* payload,
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) * Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
* unreachable header. The IP header that caused the error message should b e * unreachable header. The IP header that caused the error message should b e
* built by a previous call to libnet_build_ipv4(). * built by a previous call to libnet_build_ipv4().
* @param type type of ICMP packet (should be ICMP_UNREACH) * @param type type of ICMP packet (should be ICMP_UNREACH)
* @param code code of ICMP packet (should be one of the 16 unreachable cod es) * @param code code of ICMP packet (should be one of the 16 unreachable cod es)
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv4_unreach(u_int8_t type, u_int8_t code, u_int16_t sum, libnet_build_icmpv4_unreach(uint8_t type, uint8_t code, uint16_t sum,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds an IP version 4 RFC 792 Internet Message Control Protocol (ICMP) * Builds an IP version 4 RFC 792 Internet Message Control Protocol (ICMP)
* redirect header. The IP header that caused the error message should be * redirect header. The IP header that caused the error message should be
* built by a previous call to libnet_build_ipv4(). * built by a previous call to libnet_build_ipv4().
* @param type type of ICMP packet (should be ICMP_REDIRECT) * @param type type of ICMP packet (should be ICMP_REDIRECT)
* @param code code of ICMP packet (should be one of the four redirect code s) * @param code code of ICMP packet (should be one of the four redirect code s)
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param gateway * @param gateway
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv4_redirect(u_int8_t type, u_int8_t code, u_int16_t sum, libnet_build_icmpv4_redirect(uint8_t type, uint8_t code, uint16_t sum,
u_int32_t gateway, u_int8_t *payload, u_int32_t payload_s, libnet_t *l, uint32_t gateway, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) time * Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) time
* exceeded header. The IP header that caused the error message should be * exceeded header. The IP header that caused the error message should be
* built by a previous call to libnet_build_ipv4(). * built by a previous call to libnet_build_ipv4().
* @param type type of ICMP packet (should be ICMP_TIMXCEED) * @param type type of ICMP packet (should be ICMP_TIMXCEED)
* @param code code of ICMP packet (ICMP_TIMXCEED_INTRANS / ICMP_TIMXCEED_R EASS) * @param code code of ICMP packet (ICMP_TIMXCEED_INTRANS / ICMP_TIMXCEED_R EASS)
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv4_timeexceed(u_int8_t type, u_int8_t code, u_int16_t sum, libnet_build_icmpv4_timeexceed(uint8_t type, uint8_t code, uint16_t sum,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) * Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
* timestamp request/reply header. * timestamp request/reply header.
* @param type type of ICMP packet (should be ICMP_TSTAMP or ICMP_TSTAMPREP LY) * @param type type of ICMP packet (should be ICMP_TSTAMP or ICMP_TSTAMPREP LY)
* @param code code of ICMP packet (should be 0) * @param code code of ICMP packet (should be 0)
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param id identification number * @param id identification number
* @param seq sequence number * @param seq sequence number
* @param otime originate timestamp * @param otime originate timestamp
* @param rtime receive timestamp * @param rtime receive timestamp
* @param ttime transmit timestamp * @param ttime transmit timestamp
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv4_timestamp(u_int8_t type, u_int8_t code, u_int16_t sum, libnet_build_icmpv4_timestamp(uint8_t type, uint8_t code, uint16_t sum,
u_int16_t id, u_int16_t seq, n_time otime, n_time rtime, n_time ttime, uint16_t id, uint16_t seq, uint32_t otime, uint32_t rtime, uint32_t ttime,
const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/**
* Builds an IP version 6 RFC 4443 Internet Control Message Protocol (ICMP)
* unreachable header. The IP header that caused the error message should b
e
* built by a previous call to libnet_build_ipv6().
* @param type type of ICMP packet (should be ICMP6_UNREACH)
* @param code code of ICMP packet (should be one of the 5 unreachable code
s)
* @param sum checksum (0 for libnet to autofill)
* @param payload optional payload or NULL
* @param payload_s payload length or 0
* @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new
one
* @return protocol tag value on success, -1 on error
*/
libnet_ptag_t
libnet_build_icmpv6_unreach(u_int8_t type, u_int8_t code, u_int16_t sum,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds an RFC 1112 Internet Group Memebership Protocol (IGMP) header. * Builds an RFC 1112 Internet Group Memebership Protocol (IGMP) header.
* @param type packet type * @param type packet type
* @param code packet code (should be 0) * @param code packet code (should be 0)
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param ip IPv4 address * @param ip IPv4 address
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_igmp(u_int8_t type, u_int8_t code, u_int16_t sum, u_int32_t ip libnet_build_igmp(uint8_t type, uint8_t code, uint16_t sum, uint32_t ip,
, const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); );
/** /**
* Builds a version 4 RFC 791 Internet Protocol (IP) header. * Builds a version 4 RFC 791 Internet Protocol (IP) header.
* *
* @param ip_len total length of the IP packet including all subsequent dat a (subsequent * @param ip_len total length of the IP packet including all subsequent dat a (subsequent
* data includes any IP options and IP options padding) * data includes any IP options and IP options padding)
* @param tos type of service bits * @param tos type of service bits
* @param id IP identification number * @param id IP identification number
* @param frag fragmentation bits and offset * @param frag fragmentation bits and offset
* @param ttl time to live in the network * @param ttl time to live in the network
skipping to change at line 816 skipping to change at line 833
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param src source IPv4 address (little endian) * @param src source IPv4 address (little endian)
* @param dst destination IPv4 address (little endian) * @param dst destination IPv4 address (little endian)
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ipv4(u_int16_t ip_len, u_int8_t tos, u_int16_t id, u_int16_t f libnet_build_ipv4(uint16_t ip_len, uint8_t tos, uint16_t id, uint16_t frag,
rag, uint8_t ttl, uint8_t prot, uint16_t sum, uint32_t src, uint32_t dst,
u_int8_t ttl, u_int8_t prot, u_int16_t sum, u_int32_t src, u_int32_t dst, const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); );
/** /**
* Builds an version 4 Internet Protocol (IP) options header. The function * Builds an version 4 Internet Protocol (IP) options header. The function
* expects options to be a valid IP options string of size options_s, no la rger * expects options to be a valid IP options string of size options_s, no la rger
* than 40 bytes (the maximum size of an options string). * than 40 bytes (the maximum size of an options string).
* *
* When building a chain, the options must be built, then the IPv4 header. * When building a chain, the options must be built, then the IPv4 header.
* *
* When updating a chain, if the block following the options is an IPv4 hea der, * When updating a chain, if the block following the options is an IPv4 hea der,
* it's total length and header length will be updated if the options block * it's total length and header length will be updated if the options block
* size changes. * size changes.
* *
* @param options byte string of IP options (it will be padded up to be an integral * @param options byte string of IP options (it will be padded up to be an integral
* multiple of 32-bit words). * multiple of 32-bit words).
* @param options_s length of options string * @param options_s length of options string
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ipv4_options(u_int8_t *options, u_int32_t options_s, libnet_t *l, libnet_build_ipv4_options(const uint8_t *options, uint32_t options_s, libne t_t *l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* Autobuilds a version 4 Internet Protocol (IP) header. The function is us eful * Autobuilds a version 4 Internet Protocol (IP) header. The function is us eful
* to build an IP header quickly when you do not need a granular level of * to build an IP header quickly when you do not need a granular level of
* control. The function takes the same len, prot, and dst arguments as * control. The function takes the same len, prot, and dst arguments as
* libnet_build_ipv4(). The function does not accept a ptag argument, but i t * libnet_build_ipv4(). The function does not accept a ptag argument, but i t
* does return a ptag. In other words, you can use it to build a new IP hea der * does return a ptag. In other words, you can use it to build a new IP hea der
* but not to modify an existing one. * but not to modify an existing one.
* @param len total length of the IP packet including all subsequent data * @param len total length of the IP packet including all subsequent data
* @param prot upper layer protocol * @param prot upper layer protocol
* @param dst destination IPv4 address (little endian) * @param dst destination IPv4 address (little endian)
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_autobuild_ipv4(u_int16_t len, u_int8_t prot, u_int32_t dst, libnet_t *l); libnet_autobuild_ipv4(uint16_t len, uint8_t prot, uint32_t dst, libnet_t *l );
/** /**
* Builds a version 6 RFC 2460 Internet Protocol (IP) header. * Builds a version 6 RFC 2460 Internet Protocol (IP) header.
* @param tc traffic class * @param tc traffic class
* @param fl flow label * @param fl flow label
* @param len total length of the IP packet * @param len total length of the IP packet
* @param nh next header * @param nh next header
* @param hl hop limit * @param hl hop limit
* @param src source IPv6 address * @param src source IPv6 address
* @param dst destination IPv6 address * @param dst destination IPv6 address
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ipv6(u_int8_t tc, u_int32_t fl, u_int16_t len, u_int8_t nh, libnet_build_ipv6(uint8_t tc, uint32_t fl, uint16_t len, uint8_t nh,
u_int8_t hl, struct libnet_in6_addr src, struct libnet_in6_addr dst, uint8_t hl, struct libnet_in6_addr src, struct libnet_in6_addr dst,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds a version 6 RFC 2460 Internet Protocol (IP) fragmentation header. * Builds a version 6 RFC 2460 Internet Protocol (IP) fragmentation header.
* @param nh next header * @param nh next header
* @param reserved unused value... OR IS IT! * @param reserved unused value... OR IS IT!
* @param frag fragmentation bits (ala ipv4) * @param frag fragmentation bits (ala ipv4)
* @param id packet identification * @param id packet identification
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ipv6_frag(u_int8_t nh, u_int8_t reserved, u_int16_t frag, libnet_build_ipv6_frag(uint8_t nh, uint8_t reserved, uint16_t frag,
u_int32_t id, u_int8_t *payload, u_int32_t payload_s, libnet_t *l, uint32_t id, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* Builds a version 6 RFC 2460 Internet Protocol (IP) routing header. This * Builds a version 6 RFC 2460 Internet Protocol (IP) routing header. This
* function is special in that it uses the payload interface to include the * function is special in that it uses the payload interface to include the
* "type-specific data"; that is the routing information. Most often this w ill * "type-specific data"; that is the routing information. Most often this w ill
* be a number of 128-bit IPv6 addresses. The application programmer will b uild * be a number of 128-bit IPv6 addresses. The application programmer will b uild
* a byte string of IPv6 address and pass them to the function using the * a byte string of IPv6 address and pass them to the function using the
* payload interface. * payload interface.
* @param nh next header * @param nh next header
* @param len length of the header in 8-byte octets not including the first 8 octets * @param len length of the header in 8-byte octets not including the first 8 octets
* @param rtype routing header type * @param rtype routing header type
* @param segments number of routing segments that follow * @param segments number of routing segments that follow
* @param payload optional payload of routing information * @param payload optional payload of routing information
* @param payload_s payload length * @param payload_s payload length
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ipv6_routing(u_int8_t nh, u_int8_t len, u_int8_t rtype, libnet_build_ipv6_routing(uint8_t nh, uint8_t len, uint8_t rtype,
u_int8_t segments, u_int8_t *payload, u_int32_t payload_s, libnet_t *l, uint8_t segments, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* Builds a version 6 RFC 2460 Internet Protocol (IP) destination options * Builds a version 6 RFC 2460 Internet Protocol (IP) destination options
* header. This function is special in that it uses the payload interface t o * header. This function is special in that it uses the payload interface t o
* include the options data. The application programmer will build an IPv6 * include the options data. The application programmer will build an IPv6
* options byte string and pass it to the function using the payload interf ace. * options byte string and pass it to the function using the payload interf ace.
* @param nh next header * @param nh next header
* @param len length of the header in 8-byte octets not including the first 8 octets * @param len length of the header in 8-byte octets not including the first 8 octets
* @param payload options payload * @param payload options payload
* @param payload_s payload length * @param payload_s payload length
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ipv6_destopts(u_int8_t nh, u_int8_t len, u_int8_t *payload, libnet_build_ipv6_destopts(uint8_t nh, uint8_t len, const uint8_t* payload,
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds a version 6 RFC 2460 Internet Protocol (IP) hop by hop options * Builds a version 6 RFC 2460 Internet Protocol (IP) hop by hop options
* header. This function is special in that it uses the payload interface t o * header. This function is special in that it uses the payload interface t o
* include the options data. The application programmer will build an IPv6 * include the options data. The application programmer will build an IPv6
* hop by hop options byte string and pass it to the function using the pay load * hop by hop options byte string and pass it to the function using the pay load
* interface. * interface.
* @param nh next header * @param nh next header
* @param len length of the header in 8-byte octets not including the first 8 octets * @param len length of the header in 8-byte octets not including the first 8 octets
* @param payload options payload * @param payload options payload
* @param payload_s payload length * @param payload_s payload length
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ipv6_hbhopts(u_int8_t nh, u_int8_t len, u_int8_t *payload, libnet_build_ipv6_hbhopts(uint8_t nh, uint8_t len, const uint8_t* payload,
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* This function is not yet implement and is a NOOP. * This function is not yet implement and is a NOOP.
* @param len length * @param len length
* @param nh next header * @param nh next header
* @param dst destination IPv6 address * @param dst destination IPv6 address
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_autobuild_ipv6(u_int16_t len, u_int8_t nh, struct libnet_in6_addr ds t, libnet_autobuild_ipv6(uint16_t len, uint8_t nh, struct libnet_in6_addr dst,
libnet_t *l, libnet_ptag_t ptag); libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds a Cisco Inter-Switch Link (ISL) header. * Builds a Cisco Inter-Switch Link (ISL) header.
* @param dhost destination address (should be 01:00:0c:00:00) * @param dhost destination address (should be 01:00:0c:00:00)
* @param type type of frame * @param type type of frame
* @param user user defined data * @param user user defined data
* @param shost source mac address * @param shost source mac address
* @param len total length of the encapuslated packet less 18 bytes * @param len total length of the encapuslated packet less 18 bytes
* @param snap SNAP information (0xaaaa03 + vendor code) * @param snap SNAP information (0xaaaa03 + vendor code)
* @param vid 15 bit VLAN ID, 1 bit BPDU or CDP indicator * @param vid 15 bit VLAN ID, 1 bit BPDU or CDP indicator
* @param portindex port index * @param portindex port index
* @param reserved used for FDDI and token ring * @param reserved used for FDDI and token ring
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_isl(u_int8_t *dhost, u_int8_t type, u_int8_t user, libnet_build_isl(uint8_t *dhost, uint8_t type, uint8_t user,
u_int8_t *shost, u_int16_t len, u_int8_t *snap, u_int16_t vid, uint8_t *shost, uint16_t len, const uint8_t *snap, uint16_t vid,
u_int16_t portindex, u_int16_t reserved, u_int8_t *payload, uint16_t portindex, uint16_t reserved, const uint8_t* payload,
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds an Internet Protocol Security Encapsulating Security Payload head er. * Builds an Internet Protocol Security Encapsulating Security Payload head er.
* @param spi security parameter index * @param spi security parameter index
* @param seq ESP sequence number * @param seq ESP sequence number
* @param iv initialization vector * @param iv initialization vector
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ipsec_esp_hdr(u_int32_t spi, u_int32_t seq, u_int32_t iv, libnet_build_ipsec_esp_hdr(uint32_t spi, uint32_t seq, uint32_t iv,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds an Internet Protocol Security Encapsulating Security Payload foot er. * Builds an Internet Protocol Security Encapsulating Security Payload foot er.
* @param len padding length * @param len padding length
* @param nh next header * @param nh next header
* @param auth authentication data * @param auth authentication data
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ipsec_esp_ftr(u_int8_t len, u_int8_t nh, int8_t *auth, libnet_build_ipsec_esp_ftr(uint8_t len, uint8_t nh, int8_t *auth,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds an Internet Protocol Security Authentication header. * Builds an Internet Protocol Security Authentication header.
* @param nh next header * @param nh next header
* @param len payload length * @param len payload length
* @param res reserved * @param res reserved
* @param spi security parameter index * @param spi security parameter index
* @param seq sequence number * @param seq sequence number
* @param auth authentication data * @param auth authentication data
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ipsec_ah(u_int8_t nh, u_int8_t len, u_int16_t res, libnet_build_ipsec_ah(uint8_t nh, uint8_t len, uint16_t res,
u_int32_t spi, u_int32_t seq, u_int32_t auth, u_int8_t *payload, uint32_t spi, uint32_t seq, uint32_t auth, const uint8_t* payload,
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds an RFC 1035 version 4 DNS header. Additional DNS payload informat ion * Builds an RFC 1035 version 4 DNS header. Additional DNS payload informat ion
* should be specified using the payload interface. * should be specified using the payload interface.
* @param h_len * @param h_len
* @param id DNS packet id * @param id DNS packet id
* @param flags control flags * @param flags control flags
* @param num_q number of questions * @param num_q number of questions
* @param num_anws_rr number of answer resource records * @param num_anws_rr number of answer resource records
* @param num_auth_rr number of authority resource records * @param num_auth_rr number of authority resource records
* @param num_addi_rr number of additional resource records * @param num_addi_rr number of additional resource records
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_dnsv4(u_int16_t h_len, u_int16_t id, u_int16_t flags, libnet_build_dnsv4(uint16_t h_len, uint16_t id, uint16_t flags,
u_int16_t num_q, u_int16_t num_anws_rr, u_int16_t num_auth_rr, uint16_t num_q, uint16_t num_anws_rr, uint16_t num_auth_rr,
u_int16_t num_addi_rr, u_int8_t *payload, u_int32_t payload_s, libnet_t *l, uint16_t num_addi_rr, const uint8_t* payload, uint32_t payload_s, libnet_t
*l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* Builds a Routing Information Protocol header (RFCs 1058 and 2453). * Builds a Routing Information Protocol header (RFCs 1058 and 2453).
* @param cmd command * @param cmd command
* @param version protocol version * @param version protocol version
* @param rd version one: 0, version two: routing domain * @param rd version one: 0, version two: routing domain
* @param af address family * @param af address family
* @param rt version one: 0, version two: route tag * @param rt version one: 0, version two: route tag
* @param addr IPv4 address * @param addr IPv4 address
* @param mask version one: 0, version two: subnet mask * @param mask version one: 0, version two: subnet mask
* @param next_hop version one: 0, version two: next hop address * @param next_hop version one: 0, version two: next hop address
* @param metric routing metric * @param metric routing metric
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_rip(u_int8_t cmd, u_int8_t version, u_int16_t rd, u_int16_t af libnet_build_rip(uint8_t cmd, uint8_t version, uint16_t rd, uint16_t af,
, uint16_t rt, uint32_t addr, uint32_t mask, uint32_t next_hop,
u_int16_t rt, u_int32_t addr, u_int32_t mask, u_int32_t next_hop, uint32_t metric, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
u_int32_t metric, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* Builds an Remote Procedure Call (Version 2) Call message header as * Builds an Remote Procedure Call (Version 2) Call message header as
* specified in RFC 1831. This builder provides the option for * specified in RFC 1831. This builder provides the option for
* specifying the record marking which is required when used with * specifying the record marking which is required when used with
* streaming protocols (TCP). * streaming protocols (TCP).
* @param rm record marking indicating the position in a stream, 0 otherwis e * @param rm record marking indicating the position in a stream, 0 otherwis e
* @param xid transaction identifier used to link calls and replies * @param xid transaction identifier used to link calls and replies
* @param prog_num remote program specification typically between 0 - 1ffff fff * @param prog_num remote program specification typically between 0 - 1ffff fff
skipping to change at line 1105 skipping to change at line 1122
* @param vflavor authentication verifier type * @param vflavor authentication verifier type
* @param vlength verifier length (should be 0) * @param vlength verifier length (should be 0)
* @param vdata opaque verifier data (currently unused) * @param vdata opaque verifier data (currently unused)
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_rpc_call(u_int32_t rm, u_int32_t xid, u_int32_t prog_num, libnet_build_rpc_call(uint32_t rm, uint32_t xid, uint32_t prog_num,
u_int32_t prog_vers, u_int32_t procedure, u_int32_t cflavor, u_int32_t clen uint32_t prog_vers, uint32_t procedure, uint32_t cflavor, uint32_t clength,
gth, uint8_t *cdata, uint32_t vflavor, uint32_t vlength, const uint8_t *vdata,
u_int8_t *cdata, u_int32_t vflavor, u_int32_t vlength, u_int8_t *vdata, const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); );
/** /**
* Builds an IEEE 802.1d Spanning Tree Protocol (STP) configuration header. * Builds an IEEE 802.1d Spanning Tree Protocol (STP) configuration header.
* STP frames are usually encapsulated inside of an 802.2 + 802.3 frame * STP frames are usually encapsulated inside of an 802.2 + 802.3 frame
* combination. * combination.
* @param id protocol id * @param id protocol id
* @param version protocol version * @param version protocol version
* @param bpdu_type bridge protocol data unit type * @param bpdu_type bridge protocol data unit type
* @param flags flags * @param flags flags
* @param root_id root id * @param root_id root id
skipping to change at line 1133 skipping to change at line 1150
* @param max_age max age * @param max_age max age
* @param hello_time hello time * @param hello_time hello time
* @param f_delay forward delay * @param f_delay forward delay
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_stp_conf(u_int16_t id, u_int8_t version, u_int8_t bpdu_type, libnet_build_stp_conf(uint16_t id, uint8_t version, uint8_t bpdu_type,
u_int8_t flags, u_int8_t *root_id, u_int32_t root_pc, u_int8_t *bridge_id, uint8_t flags, const uint8_t *root_id, uint32_t root_pc, const uint8_t *bri
u_int16_t port_id, u_int16_t message_age, u_int16_t max_age, dge_id,
u_int16_t hello_time, u_int16_t f_delay, u_int8_t *payload, uint16_t port_id, uint16_t message_age, uint16_t max_age,
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); uint16_t hello_time, uint16_t f_delay, const uint8_t* payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds an IEEE 802.1d Spanning Tree Protocol (STP) topology change * Builds an IEEE 802.1d Spanning Tree Protocol (STP) topology change
* notification header. STP frames are usually encapsulated inside of an * notification header. STP frames are usually encapsulated inside of an
* 802.2 + 802.3 frame combination. * 802.2 + 802.3 frame combination.
* @param id protocol id * @param id protocol id
* @param version protocol version * @param version protocol version
* @param bpdu_type bridge protocol data unit type * @param bpdu_type bridge protocol data unit type
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_stp_tcn(u_int16_t id, u_int8_t version, u_int8_t bpdu_type, libnet_build_stp_tcn(uint16_t id, uint8_t version, uint8_t bpdu_type,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds a token ring header. * Builds a token ring header.
* @param ac access control * @param ac access control
* @param fc frame control * @param fc frame control
* @param dst destination address * @param dst destination address
* @param src source address * @param src source address
* @param dsap destination service access point * @param dsap destination service access point
* @param ssap source service access point * @param ssap source service access point
* @param cf control field * @param cf control field
* @param oui Organizationally Unique Identifier * @param oui Organizationally Unique Identifier
* @param type upper layer protocol type * @param type upper layer protocol type
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_token_ring(u_int8_t ac, u_int8_t fc, u_int8_t *dst, u_int8_t * libnet_build_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst, const u
src, int8_t *src,
u_int8_t dsap, u_int8_t ssap, u_int8_t cf, u_int8_t *oui, u_int16_t type, uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Auto-builds a token ring header. * Auto-builds a token ring header.
* @param ac access control * @param ac access control
* @param fc frame control * @param fc frame control
* @param dst destination address * @param dst destination address
* @param dsap destination service access point * @param dsap destination service access point
* @param ssap source service access point * @param ssap source service access point
* @param cf control field * @param cf control field
* @param oui Organizationally Unique Identifier * @param oui Organizationally Unique Identifier
* @param type upper layer protocol type * @param type upper layer protocol type
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_autobuild_token_ring(u_int8_t ac, u_int8_t fc, u_int8_t *dst, libnet_autobuild_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst,
u_int8_t dsap, u_int8_t ssap, u_int8_t cf, u_int8_t *oui, u_int16_t type, uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
libnet_t *l); libnet_t *l);
/** /**
* Builds an RFC 2338 Virtual Router Redundacy Protool (VRRP) header. Use t he * Builds an RFC 2338 Virtual Router Redundacy Protool (VRRP) header. Use t he
* payload interface to specify address and autthentication information. To * payload interface to specify address and autthentication information. To
* build a "legal" packet, the destination IPv4 address should be the multi cast * address 224.0.0.18, the IP TTL should be set to 255, and the IP pro tocol * build a "legal" packet, the destination IPv4 address should be the multi cast * address 224.0.0.18, the IP TTL should be set to 255, and the IP pro tocol
* should be set to 112. * should be set to 112.
* @param version VRRP version (should be 2) * @param version VRRP version (should be 2)
* @param type VRRP packet type (should be 1 -- ADVERTISEMENT) * @param type VRRP packet type (should be 1 -- ADVERTISEMENT)
* @param vrouter_id virtual router identification * @param vrouter_id virtual router identification
skipping to change at line 1216 skipping to change at line 1233
* @param auth_type type of authentication (0, 1, 2 -- see RFC) * @param auth_type type of authentication (0, 1, 2 -- see RFC)
* @param advert_int interval between advertisements * @param advert_int interval between advertisements
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_vrrp(u_int8_t version, u_int8_t type, u_int8_t vrouter_id, libnet_build_vrrp(uint8_t version, uint8_t type, uint8_t vrouter_id,
u_int8_t priority, u_int8_t ip_count, u_int8_t auth_type, u_int8_t advert_i uint8_t priority, uint8_t ip_count, uint8_t auth_type, uint8_t advert_int,
nt, uint16_t sum, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
u_int16_t sum, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* Builds an RFC 3032 Multi-Protocol Label Switching (MPLS) header. * Builds an RFC 3032 Multi-Protocol Label Switching (MPLS) header.
* @param label 20-bit label value * @param label 20-bit label value
* @param experimental 3-bit reserved field * @param experimental 3-bit reserved field
* @param bos 1-bit bottom of stack identifier * @param bos 1-bit bottom of stack identifier
* @param ttl time to live * @param ttl time to live
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_mpls(u_int32_t label, u_int8_t experimental, u_int8_t bos, libnet_build_mpls(uint32_t label, uint8_t experimental, uint8_t bos,
u_int8_t ttl, u_int8_t *payload, u_int32_t payload_s, libnet_t *l, uint8_t ttl, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* Builds an RFC 958 Network Time Protocol (NTP) header. * Builds an RFC 958 Network Time Protocol (NTP) header.
* @param leap_indicator the leap indicator * @param leap_indicator the leap indicator
* @param version NTP protocol version * @param version NTP protocol version
* @param mode NTP mode * @param mode NTP mode
* @param stratum stratum * @param stratum stratum
* @param poll polling interval * @param poll polling interval
* @param precision precision * @param precision precision
skipping to change at line 1266 skipping to change at line 1283
* @param rec_ts_frac reciever timestamp fraction * @param rec_ts_frac reciever timestamp fraction
* @param xmt_ts_int transmit timestamp integer * @param xmt_ts_int transmit timestamp integer
* @param xmt_ts_frac transmit timestamp integer * @param xmt_ts_frac transmit timestamp integer
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ntp(u_int8_t leap_indicator, u_int8_t version, u_int8_t mode, libnet_build_ntp(uint8_t leap_indicator, uint8_t version, uint8_t mode,
u_int8_t stratum, u_int8_t poll, u_int8_t precision, u_int16_t delay_int, uint8_t stratum, uint8_t poll, uint8_t precision, uint16_t delay_int,
u_int16_t delay_frac, u_int16_t dispersion_int, u_int16_t dispersion_frac, uint16_t delay_frac, uint16_t dispersion_int, uint16_t dispersion_frac,
u_int32_t reference_id, u_int32_t ref_ts_int, u_int32_t ref_ts_frac, uint32_t reference_id, uint32_t ref_ts_int, uint32_t ref_ts_frac,
u_int32_t orig_ts_int, u_int32_t orig_ts_frac, u_int32_t rec_ts_int, uint32_t orig_ts_int, uint32_t orig_ts_frac, uint32_t rec_ts_int,
u_int32_t rec_ts_frac, u_int32_t xmt_ts_int, u_int32_t xmt_ts_frac, uint32_t rec_ts_frac, uint32_t xmt_ts_int, uint32_t xmt_ts_frac,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* @param len * @param len
* @param type * @param type
* @param rtr_id * @param rtr_id
* @param area_id * @param area_id
* @param sum * @param sum
* @param autype * @param autype
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2(u_int16_t len, u_int8_t type, u_int32_t rtr_id, libnet_build_ospfv2(uint16_t len, uint8_t type, uint32_t rtr_id,
u_int32_t area_id, u_int16_t sum, u_int16_t autype, u_int8_t *payload, uint32_t area_id, uint16_t sum, uint16_t autype, const uint8_t* payload,
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* @param netmask * @param netmask
* @param interval * @param interval
* @param opts * @param opts
* @param priority * @param priority
* @param dead_int * @param dead_int
* @param des_rtr * @param des_rtr
* @param bkup_rtr * @param bkup_rtr
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_hello(u_int32_t netmask, u_int16_t interval, u_int8_t o libnet_build_ospfv2_hello(uint32_t netmask, uint16_t interval, uint8_t opts
pts, ,
u_int8_t priority, u_int dead_int, u_int32_t des_rtr, u_int32_t bkup_rtr, uint8_t priority, uint dead_int, uint32_t des_rtr, uint32_t bkup_rtr,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* @param dgram_len * @param dgram_len
* @param opts * @param opts
* @param type * @param type
* @param seqnum * @param seqnum
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_dbd(u_int16_t dgram_len, u_int8_t opts, u_int8_t type, libnet_build_ospfv2_dbd(uint16_t dgram_len, uint8_t opts, uint8_t type,
u_int seqnum, u_int8_t *payload, u_int32_t payload_s, libnet_t *l, uint seqnum, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* @param type * @param type
* @param lsid * @param lsid
* @param advrtr * @param advrtr
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsr(u_int type, u_int lsid, u_int32_t advrtr, libnet_build_ospfv2_lsr(uint type, uint lsid, uint32_t advrtr,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* @param num * @param num
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsu(u_int num, u_int8_t *payload, u_int32_t payload_s, libnet_build_ospfv2_lsu(uint num, const uint8_t* payload, uint32_t payload_ s,
libnet_t *l, libnet_ptag_t ptag); libnet_t *l, libnet_ptag_t ptag);
/** /**
* @param age * @param age
* @param opts * @param opts
* @param type * @param type
* @param lsid * @param lsid
* @param advrtr * @param advrtr
* @param seqnum * @param seqnum
* @param sum * @param sum
* @param len * @param len
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsa(u_int16_t age, u_int8_t opts, u_int8_t type, libnet_build_ospfv2_lsa(uint16_t age, uint8_t opts, uint8_t type,
u_int lsid, u_int32_t advrtr, u_int seqnum, u_int16_t sum, u_int16_t len, uint lsid, uint32_t advrtr, uint seqnum, uint16_t sum, uint16_t len,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* @param flags * @param flags
* @param num * @param num
* @param id * @param id
* @param data * @param data
* @param type * @param type
* @param tos * @param tos
* @param metric * @param metric
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsa_rtr(u_int16_t flags, u_int16_t num, u_int id, libnet_build_ospfv2_lsa_rtr(uint16_t flags, uint16_t num, uint id,
u_int data, u_int8_t type, u_int8_t tos, u_int16_t metric, u_int8_t *payloa uint data, uint8_t type, uint8_t tos, uint16_t metric, const uint8_t* paylo
d, ad,
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* @param nmask * @param nmask
* @param rtrid * @param rtrid
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsa_net(u_int32_t nmask, u_int rtrid, u_int8_t *payload libnet_build_ospfv2_lsa_net(uint32_t nmask, uint rtrid, const uint8_t* payl
, oad,
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* @param nmask * @param nmask
* @param metric * @param metric
* @param tos * @param tos
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsa_sum(u_int32_t nmask, u_int metric, u_int tos, libnet_build_ospfv2_lsa_sum(uint32_t nmask, uint metric, uint tos,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* @param nmask * @param nmask
* @param metric * @param metric
* @param fwdaddr * @param fwdaddr
* @param tag * @param tag
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsa_as(u_int32_t nmask, u_int metric, u_int32_t fwdaddr libnet_build_ospfv2_lsa_as(uint32_t nmask, uint metric, uint32_t fwdaddr,
, uint tag, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
u_int tag, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* Builds a generic libnet protocol header. This is useful for including an * Builds a generic libnet protocol header. This is useful for including an
* optional payload to a packet that might need to change repeatedly inside * optional payload to a packet that might need to change repeatedly inside
* of a loop. * of a loop. This won't work for TCP or IP payload, they have special type
s
* (this is probably a bug).
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_data(u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_build_data(const uint8_t* payload, uint32_t payload_s, libnet_t *l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* @param opcode * @param opcode
* @param htype * @param htype
* @param hlen * @param hlen
* @param hopcount * @param hopcount
* @param xid * @param xid
* @param secs * @param secs
* @param flags * @param flags
skipping to change at line 1471 skipping to change at line 1489
* @param chaddr * @param chaddr
* @param sname * @param sname
* @param file * @param file
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_dhcpv4(u_int8_t opcode, u_int8_t htype, u_int8_t hlen, libnet_build_dhcpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
u_int8_t hopcount, u_int32_t xid, u_int16_t secs, u_int16_t flags, uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
u_int32_t cip, u_int32_t yip, u_int32_t sip, u_int32_t gip, u_int8_t *chad uint32_t cip, uint32_t yip, uint32_t sip, uint32_t gip, const uint8_t *cha
dr, ddr,
u_int8_t *sname, u_int8_t *file, u_int8_t *payload, u_int32_t payload_s, uint8_t *sname, const uint8_t *file, const uint8_t* payload, uint32_t paylo
ad_s,
libnet_t *l, libnet_ptag_t ptag); libnet_t *l, libnet_ptag_t ptag);
/** /**
* @param opcode * @param opcode
* @param htype * @param htype
* @param hlen * @param hlen
* @param hopcount * @param hopcount
* @param xid * @param xid
* @param secs * @param secs
* @param flags * @param flags
skipping to change at line 1499 skipping to change at line 1517
* @param chaddr * @param chaddr
* @param sname * @param sname
* @param file * @param file
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_bootpv4(u_int8_t opcode, u_int8_t htype, u_int8_t hlen, libnet_build_bootpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
u_int8_t hopcount, u_int32_t xid, u_int16_t secs, u_int16_t flags, uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
u_int32_t cip, u_int32_t yip, u_int32_t sip, u_int32_t gip, u_int8_t *chad uint32_t cip, uint32_t yip, uint32_t sip, uint32_t gip, const uint8_t *cha
dr, ddr,
u_int8_t *sname, u_int8_t *file, u_int8_t *payload, u_int32_t payload_s, uint8_t *sname, const uint8_t *file, const uint8_t* payload, uint32_t paylo
ad_s,
libnet_t *l, libnet_ptag_t ptag); libnet_t *l, libnet_ptag_t ptag);
/** /**
* @param fv see libnet_build_gre(). * @param fv see libnet_build_gre().
* @return size, see libnet_build_gre(). * @return size, see libnet_build_gre().
*/ */
u_int32_t uint32_t
libnet_getgre_length(u_int16_t fv); libnet_getgre_length(uint16_t fv);
/** /**
* Generic Routing Encapsulation (GRE - RFC 1701) is used to encapsulate an y * Generic Routing Encapsulation (GRE - RFC 1701) is used to encapsulate an y
* protocol. Hence, the IP part of the packet is usually referred as "deliv ery * protocol. Hence, the IP part of the packet is usually referred as "deliv ery
* header". It is then followed by the GRE header and finally the encapsula ted * header". It is then followed by the GRE header and finally the encapsula ted
* packet (IP or whatever). * packet (IP or whatever).
* As GRE is very modular, the first GRE header describes the structure of the * As GRE is very modular, the first GRE header describes the structure of the
* header, using bits and flag to specify which fields will be present in t he * header, using bits and flag to specify which fields will be present in t he
* header. * header.
* @param fv the 16 0 to 7: which fields are included in the header (checks um, * @param fv the 16 0 to 7: which fields are included in the header (checks um,
skipping to change at line 1535 skipping to change at line 1553
* @param key inserted by the encapsulator to authenticate the source * @param key inserted by the encapsulator to authenticate the source
* @param seq sequence number used by the receiver to sort the packets * @param seq sequence number used by the receiver to sort the packets
* @param len size of the GRE packet * @param len size of the GRE packet
* @param payload * @param payload
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_gre(u_int16_t fv, u_int16_t type, u_int16_t sum, libnet_build_gre(uint16_t fv, uint16_t type, uint16_t sum,
u_int16_t offset, u_int32_t key, u_int32_t seq, u_int16_t len, uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Generic Routing Encapsulation (GRE - RFC 1701) is used to encapsulate an y * Generic Routing Encapsulation (GRE - RFC 1701) is used to encapsulate an y
* protocol. Hence, the IP part of the packet is usually referred as "deliv ery * protocol. Hence, the IP part of the packet is usually referred as "deliv ery
* header". It is then followed by the GRE header and finally the encapsula ted * header". It is then followed by the GRE header and finally the encapsula ted
* packet (IP or whatever). * packet (IP or whatever).
* As GRE is very modular, the first GRE header describes the structure of the * As GRE is very modular, the first GRE header describes the structure of the
* header, using bits and flag to specify which fields will be present in t he * header, using bits and flag to specify which fields will be present in t he
* header. * header.
* @param fv the 16 0 to 7: which fields are included in the header (checks um, seq. number, key, ...), bits 8 to 12: flag, bits 13 to 15: version. * @param fv the 16 0 to 7: which fields are included in the header (checks um, seq. number, key, ...), bits 8 to 12: flag, bits 13 to 15: version.
skipping to change at line 1561 skipping to change at line 1579
* @param key inserted by the encapsulator to authenticate the source * @param key inserted by the encapsulator to authenticate the source
* @param seq sequence number used by the receiver to sort the packets * @param seq sequence number used by the receiver to sort the packets
* @param len size of the GRE packet * @param len size of the GRE packet
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_egre(u_int16_t fv, u_int16_t type, u_int16_t sum, libnet_build_egre(uint16_t fv, uint16_t type, uint16_t sum,
u_int16_t offset, u_int32_t key, u_int32_t seq, u_int16_t len, uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* @param af * @param af
* @param offset * @param offset
* @param length * @param length
* @param routing * @param routing
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_gre_sre(u_int16_t af, u_int8_t offset, u_int8_t length, libnet_build_gre_sre(uint16_t af, uint8_t offset, uint8_t length,
u_int8_t *routing, u_int8_t *payload, u_int32_t payload_s, libnet_t *l, uint8_t *routing, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
libnet_ptag_t ptag); libnet_ptag_t ptag);
/** /**
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_gre_last_sre(libnet_t *l, libnet_ptag_t ptag); libnet_build_gre_last_sre(libnet_t *l, libnet_ptag_t ptag);
skipping to change at line 1611 skipping to change at line 1629
* @param marker a value the receiver can predict (if the message type is n ot BGP OPEN, or no authentication is used, these 16 bytes are normally set as all ones) * @param marker a value the receiver can predict (if the message type is n ot BGP OPEN, or no authentication is used, these 16 bytes are normally set as all ones)
* @param len total length of the BGP message, including the header * @param len total length of the BGP message, including the header
* @param type type code of the message (OPEN, UPDATE, NOTIFICATION or KEEP ALIVE) * @param type type code of the message (OPEN, UPDATE, NOTIFICATION or KEEP ALIVE)
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_bgp4_header(u_int8_t marker[LIBNET_BGP4_MARKER_SIZE], libnet_build_bgp4_header(uint8_t marker[LIBNET_BGP4_MARKER_SIZE],
u_int16_t len, u_int8_t type, u_int8_t *payload, u_int32_t payload_s, uint16_t len, uint8_t type, const uint8_t* payload, uint32_t payload_s,
libnet_t *l, libnet_ptag_t ptag); libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) OPEN header. This i s * Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) OPEN header. This i s
* the first message sent by each side of a BGP connection. The optional * the first message sent by each side of a BGP connection. The optional
* parameters options should be constructed using the payload interface (se e * parameters options should be constructed using the payload interface (se e
* RFC 1771 for the options structures). * RFC 1771 for the options structures).
* @param version protocol version (should be set to 4) * @param version protocol version (should be set to 4)
* @param src_as Autonomous System of the sender * @param src_as Autonomous System of the sender
* @param hold_time used to compute the maximum allowed time between the re ceipt of KEEPALIVE, and/or UPDATE messages by the sender * @param hold_time used to compute the maximum allowed time between the re ceipt of KEEPALIVE, and/or UPDATE messages by the sender
* @param bgp_id BGP identifier of the sender * @param bgp_id BGP identifier of the sender
* @param opt_len total length of the optional parameters field in bytes * @param opt_len total length of the optional parameters field in bytes
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_bgp4_open(u_int8_t version, u_int16_t src_as, u_int16_t hold_t libnet_build_bgp4_open(uint8_t version, uint16_t src_as, uint16_t hold_time
ime, ,
u_int32_t bgp_id, u_int8_t opt_len, u_int8_t *payload, u_int32_t payload_s, uint32_t bgp_id, uint8_t opt_len, const uint8_t* payload, uint32_t payload_
s,
libnet_t *l, libnet_ptag_t ptag); libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) update header. Upda te * Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) update header. Upda te
* messages are used to transfer routing information between BGP peers. * messages are used to transfer routing information between BGP peers.
* @param unfeasible_rt_len indicates the length of the (next) "withdrawn r outes" field in bytes * @param unfeasible_rt_len indicates the length of the (next) "withdrawn r outes" field in bytes
* @param withdrawn_rt list of IP addresses prefixes for the routes that ar e being withdrawn; each IP address prefix is built as a 2-tuple <length (1 byte), prefix (variable)> * @param withdrawn_rt list of IP addresses prefixes for the routes that ar e being withdrawn; each IP address prefix is built as a 2-tuple <length (1 byte), prefix (variable)>
* @param total_path_attr_len indicates the length of the (next) "path attr ibutes" field in bytes * @param total_path_attr_len indicates the length of the (next) "path attr ibutes" field in bytes
* @param path_attributes each attribute is a 3-tuple <type (2 bytes), leng th, value> * @param path_attributes each attribute is a 3-tuple <type (2 bytes), leng th, value>
* @param info_len indicates the length of the (next) "network layer reacha bility information" field in bytes (needed for internal memory size calcula tion) * @param info_len indicates the length of the (next) "network layer reacha bility information" field in bytes (needed for internal memory size calcula tion)
* @param reachability_info 2-tuples <length (1 byte), prefix (variable)>. * @param reachability_info 2-tuples <length (1 byte), prefix (variable)>.
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_bgp4_update(u_int16_t unfeasible_rt_len, u_int8_t *withdrawn_r libnet_build_bgp4_update(uint16_t unfeasible_rt_len, const uint8_t *withdra
t, wn_rt,
u_int16_t total_path_attr_len, u_int8_t *path_attributes, u_int16_t info_le uint16_t total_path_attr_len, const uint8_t *path_attributes, uint16_t info
n, _len,
u_int8_t *reachability_info, u_int8_t *payload, u_int32_t payload_s, uint8_t *reachability_info, const uint8_t* payload, uint32_t payload_s,
libnet_t *l, libnet_ptag_t ptag); libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) notification header . * Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) notification header .
* A NOTIFICATION message is sent when an error condition is detected. Spec ific * A NOTIFICATION message is sent when an error condition is detected. Spec ific
* error information may be passed through the payload interface. * error information may be passed through the payload interface.
* @param err_code type of notification * @param err_code type of notification
* @param err_subcode more specific information about the reported error. * @param err_subcode more specific information about the reported error.
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_bgp4_notification(u_int8_t err_code, u_int8_t err_subcode, libnet_build_bgp4_notification(uint8_t err_code, uint8_t err_subcode,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds a Sebek header. The Sebek protocol was designed by the Honeynet * Builds a Sebek header. The Sebek protocol was designed by the Honeynet
* Project as a transport mechanism for post-intrusion forensic data. More * Project as a transport mechanism for post-intrusion forensic data. More
* information may be found here: http://www.honeynet.org/papers/sebek.pdf. * information may be found here: http://www.honeynet.org/papers/sebek.pdf.
* @param magic identify packets that should be hidden * @param magic identify packets that should be hidden
* @param version protocol version, currently 1 * @param version protocol version, currently 1
* @param type type of record (read data is type 0, write data is type 1) * @param type type of record (read data is type 0, write data is type 1)
* @param counter PDU counter used to identify when packet are lost * @param counter PDU counter used to identify when packet are lost
* @param time_sec seconds since EPOCH according to the honeypot * @param time_sec seconds since EPOCH according to the honeypot
skipping to change at line 1695 skipping to change at line 1713
* @param fd FD * @param fd FD
* @param cmd 12 first characters of the command * @param cmd 12 first characters of the command
* @param length length in bytes of the PDU's body * @param length length in bytes of the PDU's body
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_sebek(u_int32_t magic, u_int16_t version, u_int16_t type, libnet_build_sebek(uint32_t magic, uint16_t version, uint16_t type,
u_int32_t counter, u_int32_t time_sec, u_int32_t time_usec, u_int32_t pid, uint32_t counter, uint32_t time_sec, uint32_t time_usec, uint32_t pid,
u_int32_t uid, u_int32_t fd, u_int8_t cmd[SEBEK_CMD_LENGTH], u_int32_t leng uint32_t uid, uint32_t fd, uint8_t cmd[SEBEK_CMD_LENGTH], uint32_t length,
th, const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); );
/** /**
* Builds a HSRP header. HSRP is a Cisco propietary protocol defined in * Builds a HSRP header. HSRP is a Cisco propietary protocol defined in
* RFC 2281 * RFC 2281
* @param version version of the HSRP messages * @param version version of the HSRP messages
* @param opcode type of message * @param opcode type of message
* @param state current state of the router * @param state current state of the router
* @param hello_time period in seconds between hello messages * @param hello_time period in seconds between hello messages
* @param hold_time seconds that the current hello message is valid * @param hold_time seconds that the current hello message is valid
* @param priority priority for the election proccess * @param priority priority for the election proccess
skipping to change at line 1720 skipping to change at line 1738
* @param reserved reserved field * @param reserved reserved field
* @param authdata password * @param authdata password
* @param virtual_ip virtual ip address * @param virtual_ip virtual ip address
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_hsrp(u_int8_t version, u_int8_t opcode, u_int8_t state, libnet_build_hsrp(uint8_t version, uint8_t opcode, uint8_t state,
u_int8_t hello_time, u_int8_t hold_time, u_int8_t priority, u_int8_t group, uint8_t hello_time, uint8_t hold_time, uint8_t priority, uint8_t group,
u_int8_t reserved, u_int8_t authdata[HSRP_AUTHDATA_LENGTH], u_int32_t virtu uint8_t reserved, uint8_t authdata[HSRP_AUTHDATA_LENGTH], uint32_t virtual_
al_ip, ip,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Builds a link layer header for an initialized l. The function * Builds a link layer header for an initialized l. The function
* determines the proper link layer header format from how l was initialize d. * determines the proper link layer header format from how l was initialize d.
* The function current supports Ethernet and Token Ring link layers. * The function current supports Ethernet and Token Ring link layers.
* @param dst the destination MAC address * @param dst the destination MAC address
* @param src the source MAC address * @param src the source MAC address
* @param oui Organizationally Unique Identifier (unused for Ethernet) * @param oui Organizationally Unique Identifier (unused for Ethernet)
* @param type the upper layer protocol type * @param type the upper layer protocol type
* @param payload optional payload or NULL * @param payload optional payload or NULL
* @param payload_s payload length or 0 * @param payload_s payload length or 0
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag protocol tag to modify an existing header, 0 to build a new one * @param ptag protocol tag to modify an existing header, 0 to build a new one
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_build_link(u_int8_t *dst, u_int8_t *src, u_int8_t *oui, u_int16_t ty libnet_build_link(const uint8_t *dst, const uint8_t *src, const uint8_t *ou
pe, i, uint16_t type,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag); const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag
);
/** /**
* Automatically builds a link layer header for an initialized l. The funct ion * Automatically builds a link layer header for an initialized l. The funct ion
* determines the proper link layer header format from how l was initialize d. * determines the proper link layer header format from how l was initialize d.
* The function current supports Ethernet and Token Ring link layers. * The function current supports Ethernet and Token Ring link layers.
* @param dst the destination MAC address * @param dst the destination MAC address
* @param oui Organizationally Unique Identifier (unused for Ethernet) * @param oui Organizationally Unique Identifier (unused for Ethernet)
* @param type the upper layer protocol type * @param type the upper layer protocol type
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return protocol tag value on success, -1 on error * @return protocol tag value on success, -1 on error
*/ */
libnet_ptag_t libnet_ptag_t
libnet_autobuild_link(u_int8_t *dst, u_int8_t *oui, u_int16_t type, libnet_autobuild_link(const uint8_t *dst, const uint8_t *oui, uint16_t type ,
libnet_t *l); libnet_t *l);
/** /**
* Writes a prebuilt packet to the network. The function assumes that l was * Writes a prebuilt packet to the network. The function assumes that l was
* previously initialized (via a call to libnet_init()) and that a * previously initialized (via a call to libnet_init()) and that a
* previously constructed packet has been built inside this context (via on e or * previously constructed packet has been built inside this context (via on e or
* more calls to the libnet_build* family of functions) and is ready to go. * more calls to the libnet_build* family of functions) and is ready to go.
* Depending on how libnet was initialized, the function will write the pac ket * Depending on how libnet was initialized, the function will write the pac ket
* to the wire either via the raw or link layer interface. The function wil l * to the wire either via the raw or link layer interface. The function wil l
* also bump up the internal libnet stat counters which are retrievable via * also bump up the internal libnet stat counters which are retrievable via
skipping to change at line 1781 skipping to change at line 1799
/** /**
* Returns the IP address for the device libnet was initialized with. If * Returns the IP address for the device libnet was initialized with. If
* libnet was initialized without a device (in raw socket mode) the functio n * libnet was initialized without a device (in raw socket mode) the functio n
* will attempt to find one. If the function fails and returns -1 a call to * will attempt to find one. If the function fails and returns -1 a call to
* libnet_geterrror() will tell you why. * libnet_geterrror() will tell you why.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return a big endian IP address suitable for use in a libnet_build funct ion or -1 * @return a big endian IP address suitable for use in a libnet_build funct ion or -1
*/ */
u_int32_t uint32_t
libnet_get_ipaddr4(libnet_t *l); libnet_get_ipaddr4(libnet_t *l);
/** /**
* This function is not yet implemented under IPv6. * This function is not yet implemented under IPv6.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return well, nothing yet * @return well, nothing yet
*/ */
struct libnet_in6_addr struct libnet_in6_addr
libnet_get_ipaddr6(libnet_t *l); libnet_get_ipaddr6(libnet_t *l);
skipping to change at line 1812 skipping to change at line 1830
/** /**
* Takes a colon separated hexidecimal address (from the command line) and * Takes a colon separated hexidecimal address (from the command line) and
* returns a bytestring suitable for use in a libnet_build function. Note t his * returns a bytestring suitable for use in a libnet_build function. Note t his
* function performs an implicit malloc and the return value should be free d * function performs an implicit malloc and the return value should be free d
* after its use. * after its use.
* @param s the string to be parsed * @param s the string to be parsed
* @param len the resulting size of the returned byte string * @param len the resulting size of the returned byte string
* @return a byte string or NULL on failure * @return a byte string or NULL on failure
*/ */
u_int8_t * uint8_t *
libnet_hex_aton(const char *s, int *len); libnet_hex_aton(const char *s, int *len);
/** /**
* Returns the version of libnet. * Returns the version of libnet.
* @return the libnet version * @return the libnet version
*/ */
const char * const char *
libnet_version(void); libnet_version(void);
/** /**
skipping to change at line 1838 skipping to change at line 1856
* important to note that the function performs an implicit malloc() and a * important to note that the function performs an implicit malloc() and a
* corresponding call to libnet_adv_free_packet() should be made to free th e * corresponding call to libnet_adv_free_packet() should be made to free th e
* memory packet occupies. If the function fails libnet_geterror() can tell you * memory packet occupies. If the function fails libnet_geterror() can tell you
* why. * why.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param packet will contain the wire-ready packet * @param packet will contain the wire-ready packet
* @param packet_s will contain the packet size * @param packet_s will contain the packet size
* @return 1 on success, -1 on failure * @return 1 on success, -1 on failure
*/ */
int int
libnet_adv_cull_packet(libnet_t *l, u_int8_t **packet, u_int32_t *packet_s) ; libnet_adv_cull_packet(libnet_t *l, uint8_t **packet, uint32_t *packet_s);
/** /**
* [Advanced Interface] * [Advanced Interface]
* Pulls the header from the specified ptag from the given libnet context. This * Pulls the header from the specified ptag from the given libnet context. This
* function is part of the advanced interface and is only available when li bnet * function is part of the advanced interface and is only available when li bnet
* is initialized in advanced mode. If the function fails libnet_geterror() can * is initialized in advanced mode. If the function fails libnet_geterror() can
* tell you why. * tell you why.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ptag the ptag referencing the header to pull * @param ptag the ptag referencing the header to pull
* @param header will contain the header * @param header will contain the header
* @param header_s will contain the header size * @param header_s will contain the header size
* @return 1 on success, -1 on failure * @return 1 on success, -1 on failure
*/ */
int int
libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, u_int8_t **header, libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, uint8_t **header,
u_int32_t *header_s); uint32_t *header_s);
/** /**
* [Advanced Interface] * [Advanced Interface]
* Writes a packet the network at the link layer. This function is useful t o * Writes a packet the network at the link layer. This function is useful t o
* write a packet that has been constructed by hand by the application * write a packet that has been constructed by hand by the application
* programmer or, more commonly, to write a packet that has been returned b y * programmer or, more commonly, to write a packet that has been returned b y
* a call to libnet_adv_cull_packet(). This function is part of the advance d * a call to libnet_adv_cull_packet(). This function is part of the advance d
* interface and is only available when libnet is initialized in advanced m ode. * interface and is only available when libnet is initialized in advanced m ode.
* If the function fails libnet_geterror() can tell you why. * If the function fails libnet_geterror() can tell you why.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param packet a pointer to the packet to inject * @param packet a pointer to the packet to inject
* @param packet_s the size of the packet * @param packet_s the size of the packet
* @return the number of bytes written, or -1 on failure * @return the number of bytes written, or -1 on failure
*/ */
int int
libnet_adv_write_link(libnet_t *l, u_int8_t *packet, u_int32_t packet_s); libnet_adv_write_link(libnet_t *l, const uint8_t *packet, uint32_t packet_s );
/** /**
* [Advanced Interface] * [Advanced Interface]
* Writes a packet the network at the raw socket layer. This function is us eful * Writes a packet the network at the raw socket layer. This function is us eful
* to write a packet that has been constructed by hand by the application * to write a packet that has been constructed by hand by the application
* programmer or, more commonly, to write a packet that has been returned b y * programmer or, more commonly, to write a packet that has been returned b y
* a call to libnet_adv_cull_packet(). This function is part of the advance d * a call to libnet_adv_cull_packet(). This function is part of the advance d
* interface and is only available when libnet is initialized in advanced m ode. * interface and is only available when libnet is initialized in advanced m ode.
* If the function fails libnet_geterror() can tell you why. * If the function fails libnet_geterror() can tell you why.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param packet a pointer to the packet to inject * @param packet a pointer to the packet to inject
* @param packet_s the size of the packet * @param packet_s the size of the packet
* @return the number of bytes written, or -1 on failure * @return the number of bytes written, or -1 on failure
*/ */
int int
libnet_adv_write_raw_ipv4(libnet_t *l, u_int8_t *packet, u_int32_t packet_s ); libnet_adv_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t pack et_s);
/** /**
* [Advanced Interface] * [Advanced Interface]
* Frees the memory allocated when libnet_adv_cull_packet() is called. * Frees the memory allocated when libnet_adv_cull_packet() is called.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param packet a pointer to the packet to free * @param packet a pointer to the packet to free
*/ */
void void
libnet_adv_free_packet(libnet_t *l, u_int8_t *packet); libnet_adv_free_packet(libnet_t *l, uint8_t *packet);
/** /**
* [Context Queue] * [Context Queue]
* Adds a new context to the libnet context queue. If no queue exists, this * Adds a new context to the libnet context queue. If no queue exists, this
* function will create the queue and add the specified libnet context as t he * function will create the queue and add the specified libnet context as t he
* first entry on the list. The functions checks to ensure niether l nor la bel * first entry on the list. The functions checks to ensure niether l nor la bel
* are NULL, and that label doesn't refer to an existing context already in the * are NULL, and that label doesn't refer to an existing context already in the
* queue. Additionally, l should refer to a libnet context previously * queue. Additionally, l should refer to a libnet context previously
* initialized with a call to libnet_init(). If the context queue in write * initialized with a call to libnet_init(). If the context queue in write
* locked, this function will fail. * locked, this function will fail.
skipping to change at line 2013 skipping to change at line 2031
* @return the next context from the context queue * @return the next context from the context queue
*/ */
libnet_t * libnet_t *
libnet_cq_next(void); libnet_cq_next(void);
/** /**
* [Context Queue] * [Context Queue]
* Function returns the number of libnet contexts that are in the queue. * Function returns the number of libnet contexts that are in the queue.
* @return the number of libnet contexts currently in the queue * @return the number of libnet contexts currently in the queue
*/ */
u_int32_t uint32_t
libnet_cq_size(void); libnet_cq_size(void);
/** /**
* [Context Queue] * [Context Queue]
*/ */
u_int32_t uint32_t
libnet_cq_end_loop(void); libnet_cq_end_loop(void);
/** /**
* [Diagnostic] * [Diagnostic]
* Prints the contents of the given context. * Prints the contents of the given context.
* @param l pointer to a libnet context * @param l pointer to a libnet context
*/ */
void void
libnet_diag_dump_context(libnet_t *l); libnet_diag_dump_context(libnet_t *l);
skipping to change at line 2045 skipping to change at line 2063
void void
libnet_diag_dump_pblock(libnet_t *l); libnet_diag_dump_pblock(libnet_t *l);
/** /**
* [Diagnostic] * [Diagnostic]
* Returns the canonical name of the pblock type. * Returns the canonical name of the pblock type.
* @param type pblock type * @param type pblock type
* @return a string representing the pblock type type or "unknown" for an u nknown value * @return a string representing the pblock type type or "unknown" for an u nknown value
*/ */
char * char *
libnet_diag_dump_pblock_type(u_int8_t type); libnet_diag_dump_pblock_type(uint8_t type);
/** /**
* [Diagnostic] * [Diagnostic]
* Function prints the contents of the supplied buffer to the supplied * Function prints the contents of the supplied buffer to the supplied
* stream pointer. Will swap endianness based disposition of mode variable. * stream pointer. Will swap endianness based disposition of mode variable.
* Useful to be used in conjunction with the advanced interface and a culle d * Useful to be used in conjunction with the advanced interface and a culle d
* packet. * packet.
* @param packet the packet to print * @param packet the packet to print
* @param len length of the packet in bytes * @param len length of the packet in bytes
* @param swap 1 to swap byte order, 0 to not. * @param swap 1 to swap byte order, 0 to not.
* Counter-intuitively, it is necessary to swap in order to see the byte * Counter-intuitively, it is necessary to swap in order to see the byte
* order as it is on the wire (this may be a bug). * order as it is on the wire (this may be a bug).
* @param stream a stream pointer to print to * @param stream a stream pointer to print to
*/ */
void void
libnet_diag_dump_hex(u_int8_t *packet, u_int32_t len, int swap, FILE *strea m); libnet_diag_dump_hex(const uint8_t *packet, uint32_t len, int swap, FILE *s tream);
/* /*
* [Internal] * [Internal]
*/ */
int int
libnet_write_raw_ipv4(libnet_t *l, u_int8_t *packet, u_int32_t size); libnet_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t size);
/* /*
* [Internal] * [Internal]
*/ */
int int
libnet_write_raw_ipv6(libnet_t *l, u_int8_t *packet, u_int32_t size); libnet_write_raw_ipv6(libnet_t *l, const uint8_t *packet, uint32_t size);
/* /*
* [Internal] * [Internal]
*/ */
int int
libnet_write_link(libnet_t *l, u_int8_t *packet, u_int32_t size); libnet_write_link(libnet_t *l, const uint8_t *packet, uint32_t size);
#if ((__WIN32__) && !(__CYGWIN__)) #if ((__WIN32__) && !(__CYGWIN__))
/* /*
* [Internal] * [Internal]
*/ */
SOCKET SOCKET
libnet_open_raw4(libnet_t *l); libnet_open_raw4(libnet_t *l);
#else #else
/* /*
* [Internal] * [Internal]
skipping to change at line 2133 skipping to change at line 2151
libnet_open_link(libnet_t *l); libnet_open_link(libnet_t *l);
/* /*
* [Internal] * [Internal]
*/ */
int int
libnet_close_link(libnet_t *l); libnet_close_link(libnet_t *l);
/* /*
* [Internal] * [Internal]
* THIS FUNCTION IS BROKEN. IT WILL SEGFAULT OR CORRUPT MEMORY, OR JUST S
ILENTLY DO THE
* WRONG THING IF NOT CALLED CORRECTLY, AND CALLING IT CORRECTLY IS UNDOC
UMENTED, AND
* ALMOST IMPOSSIBLE. YOU HAVE BEEN WARNED.
*/ */
int int
libnet_do_checksum(libnet_t *l, u_int8_t *packet, int protocol, int len); libnet_do_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len);
/* Calculate internet checksums.
*
* IP (TCP, UDP, IGMP, ICMP, etc...) checksums usually need information fro
m
* the IP header to construct the "pseudo header", this function takes a
* pointer to that header, the buffer boundaries, the "h_len" (see pblock_t
for
* a description, it is increasinly unused, though, and I'm trying to remov
e it
* altogether), and the protocol number for the protocol that is to be
* checksummed.
*
* Finding that protocol requires that the IP header be well-formed... so t
his
* won't work well for invalid packets. But then, what is the valid checksu
m
* for a valid packet, anyhow?
*
* This doesn't work well for non-inet checksums, sorry, that's an original
design
* flaw. pblock_t needs a pointer in it, to a packet assembly function that
can be
* called at runtime to do assembly and checksumming.
*/
int
libnet_inet_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len,
const uint8_t *beg, const uint8_t * end);
/* /*
* [Internal] * [Internal]
*/ */
u_int32_t uint32_t
libnet_compute_crc(u_int8_t *buf, u_int32_t len); libnet_compute_crc(uint8_t *buf, uint32_t len);
/* /*
* [Internal] * [Internal]
*/ */
u_int16_t uint16_t
libnet_ip_check(u_int16_t *addr, int len); libnet_ip_check(uint16_t *addr, int len);
/* /*
* [Internal] * [Internal]
*/ */
int int
libnet_in_cksum(u_int16_t *addr, int len); libnet_in_cksum(uint16_t *addr, int len);
/* /*
* [Internal] * [Internal]
* If ptag is 0, function will create a pblock for the protocol unit type, * If ptag is 0, function will create a pblock for the protocol unit type,
* append it to the list and return a pointer to it. If ptag is not 0, * append it to the list and return a pointer to it. If ptag is not 0,
* function will search the pblock list for the specified protocol block * function will search the pblock list for the specified protocol block
* and return a pointer to it. * and return a pointer to it.
*/ */
libnet_pblock_t * libnet_pblock_t *
libnet_pblock_probe(libnet_t *l, libnet_ptag_t ptag, u_int32_t n, libnet_pblock_probe(libnet_t *l, libnet_ptag_t ptag, uint32_t b_len,
u_int8_t type); uint8_t type);
/* /*
* [Internal] * [Internal]
* Function creates the pblock list if l->protocol_blocks == NULL or append s * Function creates the pblock list if l->protocol_blocks == NULL or append s
* an entry to the doubly linked list. * an entry to the doubly linked list.
*/ */
libnet_pblock_t * libnet_pblock_t *
libnet_pblock_new(libnet_t *l, u_int32_t size); libnet_pblock_new(libnet_t *l, uint32_t b_len);
/* /*
* [Internal] * [Internal]
* Function swaps two pblocks in memory. * Function swaps two pblocks in memory.
*/ */
int int
libnet_pblock_swap(libnet_t *l, libnet_ptag_t ptag1, libnet_ptag_t ptag2); libnet_pblock_swap(libnet_t *l, libnet_ptag_t ptag1, libnet_ptag_t ptag2);
/* /*
* [Internal] * [Internal]
* Function inserts a pblock into the doubly linked list. * Function inserts ptag2 before ptag1 in the doubly linked list.
*/ */
int int
libnet_pblock_insert_before(libnet_t *l, libnet_ptag_t ptag1, libnet_pblock_insert_before(libnet_t *l, libnet_ptag_t ptag1,
libnet_ptag_t ptag2); libnet_ptag_t ptag2);
/* /*
* [Internal] * [Internal]
* Function removes a pblock from context * Function removes a pblock from context
*/ */
void void
libnet_pblock_delete(libnet_t *l, libnet_pblock_t *p); libnet_pblock_delete(libnet_t *l, libnet_pblock_t *p);
/* /*
* [Internal] * [Internal]
* Function updates the pblock meta-inforation. Internally it updates the * Function updates the pblock meta-inforation. Internally it updates the
* ptag with a monotonically increasing variable kept in l. This way each * ptag with a monotonically increasing variable kept in l. This way each
* pblock has a succesively increasing ptag identifier. * pblock has a succesively increasing ptag identifier.
*/ */
libnet_ptag_t libnet_ptag_t
libnet_pblock_update(libnet_t *l, libnet_pblock_t *p, u_int32_t h, libnet_pblock_update(libnet_t *l, libnet_pblock_t *p, uint32_t h, uint8_t t
u_int8_t type); ype);
/*
* [Internal]
* Checksums are a real pain in the <beep>!!!
* Function updates referer used to compute the checksum. All
* pblock need to know where is their referer (ie IP header).
* So, this function is called each time a new IP header is inserted.
* It updates the ip_offset field (referer) of each previous pblock.
*/
void
libnet_pblock_record_ip_offset(libnet_t *l, libnet_pblock_t *p);
/* /*
* [Internal] * [Internal]
* Function locates a given block by it's ptag. * Function locates a given block by it's ptag.
*/ */
libnet_pblock_t * libnet_pblock_t *
libnet_pblock_find(libnet_t *l, libnet_ptag_t ptag); libnet_pblock_find(libnet_t *l, libnet_ptag_t ptag);
/* /*
* [Internal] * [Internal]
* Function copies protocol block data over. * Function copies protocol block data over.
*/ */
int int
libnet_pblock_append(libnet_t *l, libnet_pblock_t *p, u_int8_t *buf, libnet_pblock_append(libnet_t *l, libnet_pblock_t *p, const uint8_t *buf,
u_int32_t len); uint32_t len);
/* /*
* [Internal] * [Internal]
* Function sets pblock flags. * Function sets pblock flags.
*/ */
void void
libnet_pblock_setflags(libnet_pblock_t *p, u_int8_t flags); libnet_pblock_setflags(libnet_pblock_t *p, uint8_t flags);
/* /*
* [Internal] * [Internal]
* Function returns the protocol number for the protocol block type. If * Function returns the protocol number for the protocol block type. If
* the type is unknown, the function defaults to returning IPPROTO_IP. * the type is unknown, the function defaults to returning IPPROTO_IP.
*/ */
int int
libnet_pblock_p2p(u_int8_t type); libnet_pblock_p2p(uint8_t type);
/* /*
* [Internal] * [Internal]
* Function assembles the packet for subsequent writing. Function makes tw * Function assembles the protocol blocks into a packet, checksums are
o * calculated if that was requested.
* passes through the pblock list:
*/ */
int int
libnet_pblock_coalesce(libnet_t *l, u_int8_t **packet, u_int32_t *size); libnet_pblock_coalesce(libnet_t *l, uint8_t **packet, uint32_t *size);
#if !(__WIN32__) #if !(__WIN32__)
/* /*
* [Internal] * [Internal]
* By testing if we can retrieve the FLAGS of an iface * By testing if we can retrieve the FLAGS of an iface
* we can know if it exists or not and if it is up. * we can know if it exists or not and if it is up.
*/ */
int int
libnet_check_iface(libnet_t *l); libnet_check_iface(libnet_t *l);
#endif #endif
 End of changes. 111 change blocks. 
255 lines changed or deleted 328 lines changed or added


 libnet-headers.h   libnet-headers.h 
skipping to change at line 67 skipping to change at line 67
#define LIBNET_ETH_H 0x0e /**< Ethernet header: 14 bytes */ #define LIBNET_ETH_H 0x0e /**< Ethernet header: 14 bytes */
#define LIBNET_FDDI_H 0x15 /**< FDDI header: 21 bytes */ #define LIBNET_FDDI_H 0x15 /**< FDDI header: 21 bytes */
#define LIBNET_ICMPV4_H 0x04 /**< ICMP header base: 4 bytes */ #define LIBNET_ICMPV4_H 0x04 /**< ICMP header base: 4 bytes */
#define LIBNET_ICMPV4_ECHO_H 0x08 /**< ICMP_ECHO header: 8 bytes */ #define LIBNET_ICMPV4_ECHO_H 0x08 /**< ICMP_ECHO header: 8 bytes */
#define LIBNET_ICMPV4_MASK_H 0x0c /**< ICMP_MASK header: 12 bytes */ #define LIBNET_ICMPV4_MASK_H 0x0c /**< ICMP_MASK header: 12 bytes */
#define LIBNET_ICMPV4_UNREACH_H 0x08 /**< ICMP_UNREACH header: 8 bytes */ #define LIBNET_ICMPV4_UNREACH_H 0x08 /**< ICMP_UNREACH header: 8 bytes */
#define LIBNET_ICMPV4_TIMXCEED_H 0x08 /**< ICMP_TIMXCEED header: 8 bytes */ #define LIBNET_ICMPV4_TIMXCEED_H 0x08 /**< ICMP_TIMXCEED header: 8 bytes */
#define LIBNET_ICMPV4_REDIRECT_H 0x08 /**< ICMP_REDIRECT header: 8 bytes */ #define LIBNET_ICMPV4_REDIRECT_H 0x08 /**< ICMP_REDIRECT header: 8 bytes */
#define LIBNET_ICMPV4_TS_H 0x14 /**< ICMP_TIMESTAMP headr:20 bytes */ #define LIBNET_ICMPV4_TS_H 0x14 /**< ICMP_TIMESTAMP headr:20 bytes */
#define LIBNET_ICMPV6_H 0x08 /**< ICMP6 header base: 8 bytes */ #define LIBNET_ICMPV6_H 0x08 /**< ICMP6 header base: 8 bytes */
#define LIBNET_ICMPV6_UNREACH_H 0x08 /**< ICMP6 unreach base: 8 bytes */
#define LIBNET_IGMP_H 0x08 /**< IGMP header: 8 bytes */ #define LIBNET_IGMP_H 0x08 /**< IGMP header: 8 bytes */
#define LIBNET_IPV4_H 0x14 /**< IPv4 header: 20 bytes */ #define LIBNET_IPV4_H 0x14 /**< IPv4 header: 20 bytes */
#define LIBNET_IPV6_H 0x28 /**< IPv6 header: 40 bytes */ #define LIBNET_IPV6_H 0x28 /**< IPv6 header: 40 bytes */
#define LIBNET_IPV6_FRAG_H 0x08 /**< IPv6 frag header: 8 bytes */ #define LIBNET_IPV6_FRAG_H 0x08 /**< IPv6 frag header: 8 bytes */
#define LIBNET_IPV6_ROUTING_H 0x04 /**< IPv6 frag header base:4 bytes */ #define LIBNET_IPV6_ROUTING_H 0x04 /**< IPv6 frag header base:4 bytes */
#define LIBNET_IPV6_DESTOPTS_H 0x02 /**< IPv6 dest opts base: 2 bytes */ #define LIBNET_IPV6_DESTOPTS_H 0x02 /**< IPv6 dest opts base: 2 bytes */
#define LIBNET_IPV6_HBHOPTS_H 0x02 /**< IPv6 hop/hop opt base:2 bytes */ #define LIBNET_IPV6_HBHOPTS_H 0x02 /**< IPv6 hop/hop opt base:2 bytes */
#define LIBNET_IPSEC_ESP_HDR_H 0x0c /**< IPSEC ESP header: 12 bytes */ #define LIBNET_IPSEC_ESP_HDR_H 0x0c /**< IPSEC ESP header: 12 bytes */
#define LIBNET_IPSEC_ESP_FTR_H 0x02 /**< IPSEC ESP footer: 2 bytes */ #define LIBNET_IPSEC_ESP_FTR_H 0x02 /**< IPSEC ESP footer: 2 bytes */
#define LIBNET_IPSEC_AH_H 0x10 /**< IPSEC AH header: 16 bytes */ #define LIBNET_IPSEC_AH_H 0x10 /**< IPSEC AH header: 16 bytes */
skipping to change at line 116 skipping to change at line 117
#define LIBNET_UDP_H 0x08 /**< UDP header: 8 bytes */ #define LIBNET_UDP_H 0x08 /**< UDP header: 8 bytes */
#define LIBNET_VRRP_H 0x08 /**< VRRP header: 8 bytes */ #define LIBNET_VRRP_H 0x08 /**< VRRP header: 8 bytes */
#define LIBNET_HSRP_H 0x14 /**< HSRP header: 8 bytes */ #define LIBNET_HSRP_H 0x14 /**< HSRP header: 8 bytes */
/* /*
* IEEE 802.1Q (Virtual Local Area Network) VLAN header, static header * IEEE 802.1Q (Virtual Local Area Network) VLAN header, static header
* size: 18 bytes * size: 18 bytes
*/ */
struct libnet_802_1q_hdr struct libnet_802_1q_hdr
{ {
u_int8_t vlan_dhost[ETHER_ADDR_LEN]; /**< destination ethernet address uint8_t vlan_dhost[ETHER_ADDR_LEN]; /**< destination ethernet address
*/ */
u_int8_t vlan_shost[ETHER_ADDR_LEN]; /**< source ethernet address */ uint8_t vlan_shost[ETHER_ADDR_LEN]; /**< source ethernet address */
u_int16_t vlan_tpi; /**< tag protocol ID */ uint16_t vlan_tpi; /**< tag protocol ID */
u_int16_t vlan_priority_c_vid; /**< priority | VLAN ID */ uint16_t vlan_priority_c_vid; /**< priority | VLAN ID */
#define LIBNET_802_1Q_PRIMASK 0x0007 /**< priority mask */ #define LIBNET_802_1Q_PRIMASK 0x0007 /**< priority mask */
#define LIBNET_802_1Q_CFIMASK 0x0001 /**< CFI mask */ #define LIBNET_802_1Q_CFIMASK 0x0001 /**< CFI mask */
#define LIBNET_802_1Q_VIDMASK 0x0fff /**< vid mask */ #define LIBNET_802_1Q_VIDMASK 0x0fff /**< vid mask */
u_int16_t vlan_len; /**< length or type (802.3 / Eth 2) */ uint16_t vlan_len; /**< length or type (802.3 / Eth 2 ) */
}; };
/* /*
* IEEE 802.1X EAP (Extensible Authentication Protocol) header, static head er * IEEE 802.1X EAP (Extensible Authentication Protocol) header, static head er
* size: 4 bytes * size: 4 bytes
*/ */
struct libnet_802_1x_hdr struct libnet_802_1x_hdr
{ {
u_int8_t dot1x_version; /**< protocol version */ uint8_t dot1x_version; /**< protocol version */
u_int8_t dot1x_type; /**< frame type */ uint8_t dot1x_type; /**< frame type */
#define LIBNET_802_1X_PACKET 0x00 /**< 802.1x packet */ #define LIBNET_802_1X_PACKET 0x00 /**< 802.1x packet */
#define LIBNET_802_1X_START 0x01 /**< 802.1x start */ #define LIBNET_802_1X_START 0x01 /**< 802.1x start */
#define LIBNET_802_1X_LOGOFF 0x02 /**< 802.1x logoff */ #define LIBNET_802_1X_LOGOFF 0x02 /**< 802.1x logoff */
#define LIBNET_802_1X_KEY 0x03 /**< 802.1x key */ #define LIBNET_802_1X_KEY 0x03 /**< 802.1x key */
#define LIBNET_802_1X_ENCASFAL 0x04 /**< 802.1x encasfal */ #define LIBNET_802_1X_ENCASFAL 0x04 /**< 802.1x encasfal */
u_int16_t dot1x_length; /**< total frame length */ uint16_t dot1x_length; /**< total frame length */
}; };
/* /*
* IEEE 802.2 LLC header * IEEE 802.2 LLC header
* Link Layer Control * Link Layer Control
* static header size: 3 bytes * static header size: 3 bytes
*/ */
struct libnet_802_2_hdr struct libnet_802_2_hdr
{ {
u_int8_t llc_dsap; /* destination service access point */ uint8_t llc_dsap; /* destination service access point */
u_int8_t llc_ssap; /* source service access point */ uint8_t llc_ssap; /* source service access point */
#define LIBNET_SAP_STP 0x42 #define LIBNET_SAP_STP 0x42
#define LIBNET_SAP_SNAP 0xaa #define LIBNET_SAP_SNAP 0xaa
u_int8_t llc_control; /* control field */ uint8_t llc_control; /* control field */
}; };
/* /*
* IEEE 802.2 LLC/SNAP header * IEEE 802.2 LLC/SNAP header
* SubNetwork Attachment Point * SubNetwork Attachment Point
* static header size: 8 bytes * static header size: 8 bytes
*/ */
struct libnet_802_2snap_hdr struct libnet_802_2snap_hdr
{ {
u_int8_t snap_dsap; /* destination service access point */ uint8_t snap_dsap; /* destination service access point */
u_int8_t snap_ssap; /* destination service access point */ uint8_t snap_ssap; /* destination service access point */
u_int8_t snap_control; /* control field */ uint8_t snap_control; /* control field */
u_int8_t snap_oui[3]; /* OUI */ uint8_t snap_oui[3]; /* OUI */
u_int16_t snap_type; /* type */ uint16_t snap_type; /* type */
}; };
/* /*
* 802.3 header * 802.3 header
* IEEE Ethernet * IEEE Ethernet
* Static header size: 14 bytes * Static header size: 14 bytes
*/ */
struct libnet_802_3_hdr struct libnet_802_3_hdr
{ {
u_int8_t _802_3_dhost[ETHER_ADDR_LEN];/* destination ethernet address uint8_t _802_3_dhost[ETHER_ADDR_LEN];/* destination ethernet address *
*/ /
u_int8_t _802_3_shost[ETHER_ADDR_LEN];/* source ethernet address */ uint8_t _802_3_shost[ETHER_ADDR_LEN];/* source ethernet address */
u_int16_t _802_3_len; /* packet type ID */ uint16_t _802_3_len; /* packet type ID */
}; };
/* /*
* ARP header * ARP header
* Address Resolution Protocol * Address Resolution Protocol
* Base header size: 8 bytes * Base header size: 8 bytes
*/ */
struct libnet_arp_hdr struct libnet_arp_hdr
{ {
u_int16_t ar_hrd; /* format of hardware address */ uint16_t ar_hrd; /* format of hardware address */
#define ARPHRD_NETROM 0 /* from KA9Q: NET/ROM pseudo */ #define ARPHRD_NETROM 0 /* from KA9Q: NET/ROM pseudo */
#define ARPHRD_ETHER 1 /* Ethernet 10Mbps */ #define ARPHRD_ETHER 1 /* Ethernet 10Mbps */
#define ARPHRD_EETHER 2 /* Experimental Ethernet */ #define ARPHRD_EETHER 2 /* Experimental Ethernet */
#define ARPHRD_AX25 3 /* AX.25 Level 2 */ #define ARPHRD_AX25 3 /* AX.25 Level 2 */
#define ARPHRD_PRONET 4 /* PROnet token ring */ #define ARPHRD_PRONET 4 /* PROnet token ring */
#define ARPHRD_CHAOS 5 /* Chaosnet */ #define ARPHRD_CHAOS 5 /* Chaosnet */
#define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB */ #define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB */
#define ARPHRD_ARCNET 7 /* ARCnet */ #define ARPHRD_ARCNET 7 /* ARCnet */
#define ARPHRD_APPLETLK 8 /* APPLEtalk */ #define ARPHRD_APPLETLK 8 /* APPLEtalk */
#define ARPHRD_LANSTAR 9 /* Lanstar */ #define ARPHRD_LANSTAR 9 /* Lanstar */
#define ARPHRD_DLCI 15 /* Frame Relay DLCI */ #define ARPHRD_DLCI 15 /* Frame Relay DLCI */
#define ARPHRD_ATM 19 /* ATM */ #define ARPHRD_ATM 19 /* ATM */
#define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id) */ #define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id) */
#define ARPHRD_IPSEC 31 /* IPsec tunnel */ #define ARPHRD_IPSEC 31 /* IPsec tunnel */
u_int16_t ar_pro; /* format of protocol address */ uint16_t ar_pro; /* format of protocol address */
u_int8_t ar_hln; /* length of hardware address */ uint8_t ar_hln; /* length of hardware address */
u_int8_t ar_pln; /* length of protocol addres */ uint8_t ar_pln; /* length of protocol addres */
u_int16_t ar_op; /* operation type */ uint16_t ar_op; /* operation type */
#define ARPOP_REQUEST 1 /* req to resolve address */ #define ARPOP_REQUEST 1 /* req to resolve address */
#define ARPOP_REPLY 2 /* resp to previous request */ #define ARPOP_REPLY 2 /* resp to previous request */
#define ARPOP_REVREQUEST 3 /* req protocol address given hardware */ #define ARPOP_REVREQUEST 3 /* req protocol address given hardware */
#define ARPOP_REVREPLY 4 /* resp giving protocol address */ #define ARPOP_REVREPLY 4 /* resp giving protocol address */
#define ARPOP_INVREQUEST 8 /* req to identify peer */ #define ARPOP_INVREQUEST 8 /* req to identify peer */
#define ARPOP_INVREPLY 9 /* resp identifying peer */ #define ARPOP_INVREPLY 9 /* resp identifying peer */
/* address information allocated dynamically */ /* address information allocated dynamically */
}; };
/* /*
* BGP4 header * BGP4 header
* Border Gateway Protocol 4 * Border Gateway Protocol 4
* Base header size : 19 bytes * Base header size : 19 bytes
*/ */
struct libnet_bgp4_header_hdr struct libnet_bgp4_header_hdr
{ {
#define LIBNET_BGP4_MARKER_SIZE 16 #define LIBNET_BGP4_MARKER_SIZE 16
u_int8_t marker[LIBNET_BGP4_MARKER_SIZE]; uint8_t marker[LIBNET_BGP4_MARKER_SIZE];
u_int16_t len; uint16_t len;
u_int8_t type; uint8_t type;
#define LIBNET_BGP4_OPEN 1 #define LIBNET_BGP4_OPEN 1
#define LIBNET_BGP4_UPDATE 2 #define LIBNET_BGP4_UPDATE 2
#define LIBNET_BGP4_NOTIFICATION 3 #define LIBNET_BGP4_NOTIFICATION 3
#define LIBNET_BGP4_KEEPALIVE 4 #define LIBNET_BGP4_KEEPALIVE 4
}; };
/* /*
* BGP4 open header * BGP4 open header
* Border Gateway Protocol 4 * Border Gateway Protocol 4
* Base header size : 10 bytes * Base header size : 10 bytes
*/ */
struct libnet_bgp4_open_hdr struct libnet_bgp4_open_hdr
{ {
u_int8_t version; uint8_t version;
u_int16_t src_as; uint16_t src_as;
u_int16_t hold_time; uint16_t hold_time;
u_int32_t bgp_id; uint32_t bgp_id;
u_int8_t opt_len; uint8_t opt_len;
}; };
/* /*
* BGP4 notification message * BGP4 notification message
* *
* Border Gateway Protocol 4 * Border Gateway Protocol 4
* Base header size : 2 bytes * Base header size : 2 bytes
* *
* Use payload if you need data * Use payload if you need data
*/ */
struct libnet_bgp4_notification_hdr struct libnet_bgp4_notification_hdr
{ {
#define LIBNET_BGP4_MESSAGE_HEADER_ERROR 1 #define LIBNET_BGP4_MESSAGE_HEADER_ERROR 1
#define LIBNET_BGP4_OPEN_MESSAGE_ERROR 2 #define LIBNET_BGP4_OPEN_MESSAGE_ERROR 2
#define LIBNET_BGP4_UPDATE_MESSAGE_ERROR 3 #define LIBNET_BGP4_UPDATE_MESSAGE_ERROR 3
#define LIBNET_BGP4_HOLD_TIMER_EXPIRED 4 #define LIBNET_BGP4_HOLD_TIMER_EXPIRED 4
#define LIBNET_BGP4_FINITE_STATE__ERROR 5 #define LIBNET_BGP4_FINITE_STATE__ERROR 5
#define LIBNET_BGP4_CEASE 6 #define LIBNET_BGP4_CEASE 6
u_int8_t err_code; uint8_t err_code;
/* Message Header Error subcodes */ /* Message Header Error subcodes */
#define LIBNET_BGP4_CONNECTION_NOT_SYNCHRONIZED 1 #define LIBNET_BGP4_CONNECTION_NOT_SYNCHRONIZED 1
#define LIBNET_BGP4_BAD_MESSAGE_LENGTH 2 #define LIBNET_BGP4_BAD_MESSAGE_LENGTH 2
#define LIBNET_BGP4_BAD_MESSAGE_TYPE 3 #define LIBNET_BGP4_BAD_MESSAGE_TYPE 3
/* OPEN Message Error subcodes */ /* OPEN Message Error subcodes */
#define LIBNET_BGP4_UNSUPPORTED_VERSION_NUMBER 1 #define LIBNET_BGP4_UNSUPPORTED_VERSION_NUMBER 1
#define LIBNET_BGP4_BAD_PEER_AS 2 #define LIBNET_BGP4_BAD_PEER_AS 2
#define LIBNET_BGP4_BAD_BGP_IDENTIFIER 3 #define LIBNET_BGP4_BAD_BGP_IDENTIFIER 3
#define LIBNET_BGP4_UNSUPPORTED_OPTIONAL_PARAMETER 4 #define LIBNET_BGP4_UNSUPPORTED_OPTIONAL_PARAMETER 4
skipping to change at line 289 skipping to change at line 290
#define LIBNET_BGP4_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE #define LIBNET_BGP4_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE
#define LIBNET_BGP4_MISSING_WELL_KNOWN_ATTRIBUTE #define LIBNET_BGP4_MISSING_WELL_KNOWN_ATTRIBUTE
#define LIBNET_BGP4_ATTRIBUTE_FLAGS_ERROR #define LIBNET_BGP4_ATTRIBUTE_FLAGS_ERROR
#define LIBNET_BGP4_ATTRIBUTE_LENGTH_ERROR #define LIBNET_BGP4_ATTRIBUTE_LENGTH_ERROR
#define LIBNET_BGP4_INVALID_ORIGIN_ATTRIBUTE #define LIBNET_BGP4_INVALID_ORIGIN_ATTRIBUTE
#define LIBNET_BGP4_AS_ROUTING_LOOP #define LIBNET_BGP4_AS_ROUTING_LOOP
#define LIBNET_BGP4_INVALID_NEXT_HOP_ATTRIBUTE #define LIBNET_BGP4_INVALID_NEXT_HOP_ATTRIBUTE
#define LIBNET_BGP4_OPTIONAL_ATTRIBUTE_ERROR #define LIBNET_BGP4_OPTIONAL_ATTRIBUTE_ERROR
#define LIBNET_BGP4_INVALID_NETWORK_FIELD #define LIBNET_BGP4_INVALID_NETWORK_FIELD
#define LIBNET_BGP4_MALFORMED_AS_PATH #define LIBNET_BGP4_MALFORMED_AS_PATH
u_int8_t err_subcode; uint8_t err_subcode;
}; };
/* /*
* For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001. * For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001.
* Let's hope this one stays that way for a while! * Let's hope this one stays that way for a while!
*/ */
#define LIBNET_PROTO_CDP 200 #define LIBNET_PROTO_CDP 200
/* /*
* CDP header * CDP header
* Cisco Discovery Protocol * Cisco Discovery Protocol
* Base header size: 8 bytes * Base header size: 8 bytes
*/ */
struct libnet_cdp_hdr struct libnet_cdp_hdr
{ {
u_int8_t cdp_version; /* version (should always be 0x01) */ uint8_t cdp_version; /* version (should always be 0x01) */
u_int8_t cdp_ttl; /* time reciever should hold info in this pac uint8_t cdp_ttl; /* time reciever should hold info in this pack
ket */ et */
u_int16_t cdp_sum; /* checksum */ uint16_t cdp_sum; /* checksum */
u_int16_t cdp_type; /* type */ uint16_t cdp_type; /* type */
#define LIBNET_CDP_DEVID 0x1 /* device id */ #define LIBNET_CDP_DEVID 0x1 /* device id */
#define LIBNET_CDP_ADDRESS 0x2 /* address */ #define LIBNET_CDP_ADDRESS 0x2 /* address */
#define LIBNET_CDP_PORTID 0x3 /* port id */ #define LIBNET_CDP_PORTID 0x3 /* port id */
#define LIBNET_CDP_CAPABIL 0x4 /* capabilities */ #define LIBNET_CDP_CAPABIL 0x4 /* capabilities */
#define LIBNET_CDP_VERSION 0x5 /* version */ #define LIBNET_CDP_VERSION 0x5 /* version */
#define LIBNET_CDP_PLATFORM 0x6 /* platform */ #define LIBNET_CDP_PLATFORM 0x6 /* platform */
#define LIBNET_CDP_IPPREFIX 0x7 /* ip prefix */ #define LIBNET_CDP_IPPREFIX 0x7 /* ip prefix */
u_int16_t cdp_len; /* type + length + value */ uint16_t cdp_len; /* type + length + value */
/* value information done dynamically */ /* value information done dynamically */
/* CDP capabilities */ /* CDP capabilities */
#define LIBNET_CDP_CAP_L3R 0x01/* performs level 3 routing */ #define LIBNET_CDP_CAP_L3R 0x01/* performs level 3 routing */
#define LIBNET_CDP_CAP_L2B 0x02/* performs level 2 transparent bridging */ #define LIBNET_CDP_CAP_L2B 0x02/* performs level 2 transparent bridging */
#define LIBNET_CDP_CAP_L2SRB 0x04/* performs level 2 sourceroute bridging * / #define LIBNET_CDP_CAP_L2SRB 0x04/* performs level 2 sourceroute bridging * /
#define LIBNET_CDP_CAP_L2S 0x08/* performs level 2 switching */ #define LIBNET_CDP_CAP_L2S 0x08/* performs level 2 switching */
#define LIBNET_CDP_CAP_SR 0x10/* sends and recieves packets on a network */ #define LIBNET_CDP_CAP_SR 0x10/* sends and recieves packets on a network */
#define LIBNET_CDP_CAP_NOI 0x20/* does not forward IGMP on non-router port s */ #define LIBNET_CDP_CAP_NOI 0x20/* does not forward IGMP on non-router port s */
#define LIBNET_CDP_CAP_L1F 0x40/* provides level 1 functionality */ #define LIBNET_CDP_CAP_L1F 0x40/* provides level 1 functionality */
}; };
/* /*
* Used as an overlay for type/len/values * Used as an overlay for type/len/values
*/ */
struct libnet_cdp_value_hdr struct libnet_cdp_value_hdr
{ {
u_int16_t cdp_type; uint16_t cdp_type;
u_int16_t cdp_len; uint16_t cdp_len;
}; };
/* /*
* DHCP header * DHCP header
* Dynamic Host Configuration Protocol * Dynamic Host Configuration Protocol
* Static header size: f0 bytes * Static header size: f0 bytes
*/ */
struct libnet_dhcpv4_hdr struct libnet_dhcpv4_hdr
{ {
u_int8_t dhcp_opcode; /* opcode */ uint8_t dhcp_opcode; /* opcode */
#define LIBNET_DHCP_REQUEST 0x1 #define LIBNET_DHCP_REQUEST 0x1
#define LIBNET_DHCP_REPLY 0x2 #define LIBNET_DHCP_REPLY 0x2
u_int8_t dhcp_htype; /* hardware address type */ uint8_t dhcp_htype; /* hardware address type */
u_int8_t dhcp_hlen; /* hardware address length */ uint8_t dhcp_hlen; /* hardware address length */
u_int8_t dhcp_hopcount; /* used by proxy servers */ uint8_t dhcp_hopcount; /* used by proxy servers */
u_int32_t dhcp_xid; /* transaction ID */ uint32_t dhcp_xid; /* transaction ID */
u_int16_t dhcp_secs; /* number of seconds since trying to bootstra uint16_t dhcp_secs; /* number of seconds since trying to bootstrap
p */ */
u_int16_t dhcp_flags; /* flags for DHCP, unused for BOOTP */ uint16_t dhcp_flags; /* flags for DHCP, unused for BOOTP */
u_int32_t dhcp_cip; /* client's IP */ uint32_t dhcp_cip; /* client's IP */
u_int32_t dhcp_yip; /* your IP */ uint32_t dhcp_yip; /* your IP */
u_int32_t dhcp_sip; /* server's IP */ uint32_t dhcp_sip; /* server's IP */
u_int32_t dhcp_gip; /* gateway IP */ uint32_t dhcp_gip; /* gateway IP */
u_int8_t dhcp_chaddr[16]; /* client hardware address */ uint8_t dhcp_chaddr[16]; /* client hardware address */
u_int8_t dhcp_sname[64]; /* server host name */ uint8_t dhcp_sname[64]; /* server host name */
u_int8_t dhcp_file[128]; /* boot file name */ uint8_t dhcp_file[128]; /* boot file name */
u_int32_t dhcp_magic; /* BOOTP magic header */ uint32_t dhcp_magic; /* BOOTP magic header */
#define DHCP_MAGIC 0x63825363 #define DHCP_MAGIC 0x63825363
#define LIBNET_BOOTP_MIN_LEN 0x12c #define LIBNET_BOOTP_MIN_LEN 0x12c
#define LIBNET_DHCP_PAD 0x00 #define LIBNET_DHCP_PAD 0x00
#define LIBNET_DHCP_SUBNETMASK 0x01 #define LIBNET_DHCP_SUBNETMASK 0x01
#define LIBNET_DHCP_TIMEOFFSET 0x02 #define LIBNET_DHCP_TIMEOFFSET 0x02
#define LIBNET_DHCP_ROUTER 0x03 #define LIBNET_DHCP_ROUTER 0x03
#define LIBNET_DHCP_TIMESERVER 0x04 #define LIBNET_DHCP_TIMESERVER 0x04
#define LIBNET_DHCP_NAMESERVER 0x05 #define LIBNET_DHCP_NAMESERVER 0x05
#define LIBNET_DHCP_DNS 0x06 #define LIBNET_DHCP_DNS 0x06
#define LIBNET_DHCP_LOGSERV 0x07 #define LIBNET_DHCP_LOGSERV 0x07
skipping to change at line 458 skipping to change at line 459
/* this little guy got left out in the cold */ /* this little guy got left out in the cold */
#define LIBNET_DNS_H LIBNET_UDP_DNSV4_H #define LIBNET_DNS_H LIBNET_UDP_DNSV4_H
/* /*
* Base DNSv4 header * Base DNSv4 header
* Domain Name System * Domain Name System
* Base header size: 12/14 bytes * Base header size: 12/14 bytes
*/ */
struct libnet_dnsv4_hdr struct libnet_dnsv4_hdr
{ {
u_int16_t h_len; /* length of the packet - only used with TCP uint16_t h_len; /* length of the packet - only used with TCP *
*/ /
u_int16_t id; /* DNS packet ID */ uint16_t id; /* DNS packet ID */
u_int16_t flags; /* DNS flags */ uint16_t flags; /* DNS flags */
u_int16_t num_q; /* Number of questions */ uint16_t num_q; /* Number of questions */
u_int16_t num_answ_rr; /* Number of answer resource records */ uint16_t num_answ_rr; /* Number of answer resource records */
u_int16_t num_auth_rr; /* Number of authority resource records */ uint16_t num_auth_rr; /* Number of authority resource records */
u_int16_t num_addi_rr; /* Number of additional resource records */ uint16_t num_addi_rr; /* Number of additional resource records */
}; };
#define LIBNET_DNS_H LIBNET_UDP_DNSV4_H #define LIBNET_DNS_H LIBNET_UDP_DNSV4_H
struct libnet_dnsv4udp_hdr struct libnet_dnsv4udp_hdr
{ {
u_int16_t id; /* DNS packet ID */ uint16_t id; /* DNS packet ID */
u_int16_t flags; /* DNS flags */ uint16_t flags; /* DNS flags */
u_int16_t num_q; /* Number of questions */ uint16_t num_q; /* Number of questions */
u_int16_t num_answ_rr; /* Number of answer resource records */ uint16_t num_answ_rr; /* Number of answer resource records */
u_int16_t num_auth_rr; /* Number of authority resource records */ uint16_t num_auth_rr; /* Number of authority resource records */
u_int16_t num_addi_rr; /* Number of additional resource records */ uint16_t num_addi_rr; /* Number of additional resource records */
}; };
/* /*
* Ethernet II header * Ethernet II header
* Static header size: 14 bytes * Static header size: 14 bytes
*/ */
struct libnet_ethernet_hdr struct libnet_ethernet_hdr
{ {
u_int8_t ether_dhost[ETHER_ADDR_LEN];/* destination ethernet address * uint8_t ether_dhost[ETHER_ADDR_LEN];/* destination ethernet address */
/ uint8_t ether_shost[ETHER_ADDR_LEN];/* source ethernet address */
u_int8_t ether_shost[ETHER_ADDR_LEN];/* source ethernet address */ uint16_t ether_type; /* protocol */
u_int16_t ether_type; /* protocol */
}; };
#ifndef ETHERTYPE_PUP #ifndef ETHERTYPE_PUP
#define ETHERTYPE_PUP 0x0200 /* PUP protocol */ #define ETHERTYPE_PUP 0x0200 /* PUP protocol */
#endif #endif
#ifndef ETHERTYPE_IP #ifndef ETHERTYPE_IP
#define ETHERTYPE_IP 0x0800 /* IP protocol */ #define ETHERTYPE_IP 0x0800 /* IP protocol */
#endif #endif
#ifndef ETHERTYPE_ARP #ifndef ETHERTYPE_ARP
#define ETHERTYPE_ARP 0x0806 /* addr. resolution protocol */ #define ETHERTYPE_ARP 0x0806 /* addr. resolution protocol */
skipping to change at line 516 skipping to change at line 517
#endif #endif
#ifndef ETHERTYPE_MPLS #ifndef ETHERTYPE_MPLS
#define ETHERTYPE_MPLS 0x8847 /* MPLS */ #define ETHERTYPE_MPLS 0x8847 /* MPLS */
#endif #endif
#ifndef ETHERTYPE_LOOPBACK #ifndef ETHERTYPE_LOOPBACK
#define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */ #define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */
#endif #endif
struct libnet_ether_addr struct libnet_ether_addr
{ {
u_int8_t ether_addr_octet[6]; /* Ethernet address */ uint8_t ether_addr_octet[6]; /* Ethernet address */
}; };
/* /*
* Fiber Distributed Data Interface header * Fiber Distributed Data Interface header
* *
* Static header size: 21 bytes (LLC and 48-bit address addr only) * Static header size: 21 bytes (LLC and 48-bit address addr only)
* *
* Note: Organization field is 3 bytes which throws off the * Note: Organization field is 3 bytes which throws off the
* alignment of type. Therefore fddi_type (19 bytes in) * alignment of type. Therefore fddi_type (19 bytes in)
* is specified as two u_int8_ts. * is specified as two uint8_ts.
*/ */
struct libnet_fddi_hdr struct libnet_fddi_hdr
{ {
u_int8_t fddi_frame_control; /* Class/Format/Prio rity */ uint8_t fddi_frame_control; /* Class/Format/Prior ity */
#define LIBNET_FDDI_LLC_FRAME 0x10 #define LIBNET_FDDI_LLC_FRAME 0x10
#define LIBNET_FDDI_48BIT_ADDR 0x40 #define LIBNET_FDDI_48BIT_ADDR 0x40
#define LIBNET_FDDI_FC_REQD LIBNET_FDDI_LLC_FRAME | LIBNET_FDDI_48BIT_AD DR #define LIBNET_FDDI_FC_REQD LIBNET_FDDI_LLC_FRAME | LIBNET_FDDI_48BIT_AD DR
u_int8_t fddi_dhost[FDDI_ADDR_LEN]; /* destination fddi uint8_t fddi_dhost[FDDI_ADDR_LEN]; /* destination fddi a
address */ ddress */
u_int8_t fddi_shost[FDDI_ADDR_LEN]; /* source fddi addre uint8_t fddi_shost[FDDI_ADDR_LEN]; /* source fddi addres
ss */ s */
u_int8_t fddi_llc_dsap; /* DSAP */ uint8_t fddi_llc_dsap; /* DSAP */
u_int8_t fddi_llc_ssap; /* SSAP */ uint8_t fddi_llc_ssap; /* SSAP */
u_int8_t fddi_llc_control_field; /* Class/Format/Prio uint8_t fddi_llc_control_field; /* Class/Format/Prior
rity */ ity */
u_int8_t fddi_llc_org_code[LIBNET_ORG_CODE_SIZE]; /* Organization Code uint8_t fddi_llc_org_code[LIBNET_ORG_CODE_SIZE]; /* Organization Code
3-bytes */ 3-bytes */
u_int8_t fddi_type; /* Protocol Type */ uint8_t fddi_type; /* Protocol Type */
u_int8_t fddi_type1; /* see note above. * uint8_t fddi_type1; /* see note above. */
/
#define FDDI_TYPE_IP 0x0800 /* IP protocol */ #define FDDI_TYPE_IP 0x0800 /* IP protocol */
#define FDDI_TYPE_ARP 0x0806 /* addr. resolution protocol */ #define FDDI_TYPE_ARP 0x0806 /* addr. resolution protocol */
#define FDDI_TYPE_REVARP 0x8035 /* reverse addr. resolution protoco l */ #define FDDI_TYPE_REVARP 0x8035 /* reverse addr. resolution protoco l */
}; };
struct libnet_fddi_addr struct libnet_fddi_addr
{ {
u_int8_t fddi_addr_octet[6]; /* FDDI address */ uint8_t fddi_addr_octet[6]; /* FDDI address */
}; };
/* /*
* GRE header - RFC 1701 & 2637 * GRE header - RFC 1701 & 2637
* Generic Routing Encapsulation (GRE) * Generic Routing Encapsulation (GRE)
* Base header size: 4 bytes * Base header size: 4 bytes
*/ */
struct libnet_gre_hdr struct libnet_gre_hdr
{ {
u_int16_t flags_ver; uint16_t flags_ver;
#define GRE_CSUM 0x8000 #define GRE_CSUM 0x8000
#define GRE_ROUTING 0x4000 #define GRE_ROUTING 0x4000
#define GRE_KEY 0x2000 #define GRE_KEY 0x2000
#define GRE_SEQ 0x1000 #define GRE_SEQ 0x1000
#define GRE_STRICT 0x0800 #define GRE_STRICT 0x0800
#define GRE_REC 0x0700 #define GRE_REC 0x0700
#define GRE_ACK 0x0080 #define GRE_ACK 0x0080
#define GRE_FLAGS_MASK 0x00F8 #define GRE_FLAGS_MASK 0x00F8
#define GRE_VERSION_MASK 0x0007 #define GRE_VERSION_MASK 0x0007
#define GRE_VERSION_0 0x0000 #define GRE_VERSION_0 0x0000
#define GRE_VERSION_1 0x0001 #define GRE_VERSION_1 0x0001
u_int16_t type; uint16_t type;
#define GRE_SNA 0x0004 #define GRE_SNA 0x0004
#define GRE_OSI_NETWORK_LAYER 0x00FE #define GRE_OSI_NETWORK_LAYER 0x00FE
#define GRE_PUP 0x0200 #define GRE_PUP 0x0200
#define GRE_XNS 0x0600 #define GRE_XNS 0x0600
#define GRE_IP 0x0800 #define GRE_IP 0x0800
#define GRE_CHAOS 0x0804 #define GRE_CHAOS 0x0804
#define GRE_RFC_826_ARP 0x0806 #define GRE_RFC_826_ARP 0x0806
#define GRE_FRAME_RELAY_ARP 0x0808 #define GRE_FRAME_RELAY_ARP 0x0808
#define GRE_VINES 0x0BAD #define GRE_VINES 0x0BAD
#define GRE_VINES_ECHO 0x0BAE #define GRE_VINES_ECHO 0x0BAE
skipping to change at line 599 skipping to change at line 600
#define GRE_APOLLO_DOMAIN 0x8019 #define GRE_APOLLO_DOMAIN 0x8019
#define GRE_ETHERTALK 0x809B #define GRE_ETHERTALK 0x809B
#define GRE_NOVELL_IPX 0x8137 #define GRE_NOVELL_IPX 0x8137
#define GRE_RFC_1144_TCP_IP_COMPRESSION 0x876B #define GRE_RFC_1144_TCP_IP_COMPRESSION 0x876B
#define GRE_IP_AUTONOMOUS_SYSTEMS 0x876C #define GRE_IP_AUTONOMOUS_SYSTEMS 0x876C
#define GRE_SECURE_DATA 0x876D #define GRE_SECURE_DATA 0x876D
#define GRE_PPP 0x880b /* taken from RFC 26 37 */ #define GRE_PPP 0x880b /* taken from RFC 26 37 */
union { union {
struct { struct {
u_int16_t sum; /* optional */ uint16_t sum; /* optional */
u_int16_t offset; /* optional */ uint16_t offset; /* optional */
u_int32_t key; /* optional */ uint32_t key; /* optional */
u_int32_t seq; /* optional */ uint32_t seq; /* optional */
} _gre; } _gre;
struct { struct {
u_int16_t payload_s; /* optional */ uint16_t payload_s; /* optional */
u_int16_t callID; /* optional */ uint16_t callID; /* optional */
u_int32_t seq; /* optional */ uint32_t seq; /* optional */
u_int32_t ack; /* optional */ uint32_t ack; /* optional */
} _egre; } _egre;
}_data; }_data;
#define gre_sum _data._gre.sum #define gre_sum _data._gre.sum
#define gre_offset _data._gre.offset #define gre_offset _data._gre.offset
#define gre_key _data._gre.key #define gre_key _data._gre.key
#define gre_seq _data._gre.seq #define gre_seq _data._gre.seq
#define egre_payload_s _data._egre.payload_s #define egre_payload_s _data._egre.payload_s
#define egre_callID _data._egre.callID #define egre_callID _data._egre.callID
skipping to change at line 635 skipping to change at line 636
#define IPPROTO_GRE 47 #define IPPROTO_GRE 47
#endif #endif
/* /*
* Source Route Entries (SRE) * Source Route Entries (SRE)
* This is used for GRE as the Routing field is a list of SREs - RFC 1701 * This is used for GRE as the Routing field is a list of SREs - RFC 1701
* Base header size: 4 bytes * Base header size: 4 bytes
*/ */
struct libnet_gre_sre_hdr struct libnet_gre_sre_hdr
{ {
u_int16_t af; /* address familly */ uint16_t af; /* address familly */
u_int8_t sre_offset; uint8_t sre_offset;
u_int8_t sre_length; uint8_t sre_length;
u_int8_t *routing; uint8_t *routing;
}; };
/* /*
* IPv4 header * IPv4 header
* Internet Protocol, version 4 * Internet Protocol, version 4
* Static header size: 20 bytes * Static header size: 20 bytes
*/ */
struct libnet_ipv4_hdr struct libnet_ipv4_hdr
{ {
#if (LIBNET_LIL_ENDIAN) #if (LIBNET_LIL_ENDIAN)
u_int8_t ip_hl:4, /* header length */ uint8_t ip_hl:4, /* header length */
ip_v:4; /* version */ ip_v:4; /* version */
#endif #endif
#if (LIBNET_BIG_ENDIAN) #if (LIBNET_BIG_ENDIAN)
u_int8_t ip_v:4, /* version */ uint8_t ip_v:4, /* version */
ip_hl:4; /* header length */ ip_hl:4; /* header length */
#endif #endif
u_int8_t ip_tos; /* type of service */ uint8_t ip_tos; /* type of service */
#ifndef IPTOS_LOWDELAY #ifndef IPTOS_LOWDELAY
#define IPTOS_LOWDELAY 0x10 #define IPTOS_LOWDELAY 0x10
#endif #endif
#ifndef IPTOS_THROUGHPUT #ifndef IPTOS_THROUGHPUT
#define IPTOS_THROUGHPUT 0x08 #define IPTOS_THROUGHPUT 0x08
#endif #endif
#ifndef IPTOS_RELIABILITY #ifndef IPTOS_RELIABILITY
#define IPTOS_RELIABILITY 0x04 #define IPTOS_RELIABILITY 0x04
#endif #endif
#ifndef IPTOS_LOWCOST #ifndef IPTOS_LOWCOST
#define IPTOS_LOWCOST 0x02 #define IPTOS_LOWCOST 0x02
#endif #endif
u_int16_t ip_len; /* total length */ uint16_t ip_len; /* total length */
u_int16_t ip_id; /* identification */ uint16_t ip_id; /* identification */
u_int16_t ip_off; uint16_t ip_off;
#ifndef IP_RF #ifndef IP_RF
#define IP_RF 0x8000 /* reserved fragment flag */ #define IP_RF 0x8000 /* reserved fragment flag */
#endif #endif
#ifndef IP_DF #ifndef IP_DF
#define IP_DF 0x4000 /* dont fragment flag */ #define IP_DF 0x4000 /* dont fragment flag */
#endif #endif
#ifndef IP_MF #ifndef IP_MF
#define IP_MF 0x2000 /* more fragments flag */ #define IP_MF 0x2000 /* more fragments flag */
#endif #endif
#ifndef IP_OFFMASK #ifndef IP_OFFMASK
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
#endif #endif
u_int8_t ip_ttl; /* time to live */ uint8_t ip_ttl; /* time to live */
u_int8_t ip_p; /* protocol */ uint8_t ip_p; /* protocol */
u_int16_t ip_sum; /* checksum */ uint16_t ip_sum; /* checksum */
struct in_addr ip_src, ip_dst; /* source and dest address */ struct in_addr ip_src, ip_dst; /* source and dest address */
}; };
/* /*
* IP options * IP options
*/ */
#ifndef IPOPT_EOL #ifndef IPOPT_EOL
#define IPOPT_EOL 0 /* end of option list */ #define IPOPT_EOL 0 /* end of option list */
#endif #endif
#ifndef IPOPT_NOP #ifndef IPOPT_NOP
skipping to change at line 725 skipping to change at line 726
#define IPOPT_SSRR 137 /* strict source route */ #define IPOPT_SSRR 137 /* strict source route */
#endif #endif
/* /*
* IPv6 address * IPv6 address
*/ */
struct libnet_in6_addr struct libnet_in6_addr
{ {
union union
{ {
u_int8_t __u6_addr8[16]; uint8_t __u6_addr8[16];
u_int16_t __u6_addr16[8]; uint16_t __u6_addr16[8];
u_int32_t __u6_addr32[4]; uint32_t __u6_addr32[4];
} __u6_addr; /* 128-bit IP6 address */ } __u6_addr; /* 128-bit IP6 address */
}; };
#define libnet_s6_addr __u6_addr.__u6_addr8 #define libnet_s6_addr __u6_addr.__u6_addr8
/* /*
* IPv6 header * IPv6 header
* Internet Protocol, version 6 * Internet Protocol, version 6
* Static header size: 40 bytes * Static header size: 40 bytes
*/ */
struct libnet_ipv6_hdr struct libnet_ipv6_hdr
{ {
u_int8_t ip_flags[4]; /* version, traffic class, flow label */ uint8_t ip_flags[4]; /* version, traffic class, flow label */
u_int16_t ip_len; /* total length */ uint16_t ip_len; /* total length */
u_int8_t ip_nh; /* next header */ uint8_t ip_nh; /* next header */
u_int8_t ip_hl; /* hop limit */ uint8_t ip_hl; /* hop limit */
struct libnet_in6_addr ip_src, ip_dst; /* source and dest address */ struct libnet_in6_addr ip_src, ip_dst; /* source and dest address */
}; };
/* /*
* IPv6 frag header * IPv6 frag header
* Internet Protocol, version 6 * Internet Protocol, version 6
* Static header size: 8 bytes * Static header size: 8 bytes
*/ */
#define LIBNET_IPV6_NH_FRAGMENT 44 #define LIBNET_IPV6_NH_FRAGMENT 44
struct libnet_ipv6_frag_hdr struct libnet_ipv6_frag_hdr
{ {
u_int8_t ip_nh; /* next header */ uint8_t ip_nh; /* next header */
u_int8_t ip_reserved; /* reserved */ uint8_t ip_reserved; /* reserved */
u_int16_t ip_frag; /* fragmentation stuff */ uint16_t ip_frag; /* fragmentation stuff */
u_int32_t ip_id; /* id */ uint32_t ip_id; /* id */
}; };
/* /*
* IPv6 routing header * IPv6 routing header
* Internet Protocol, version 6 * Internet Protocol, version 6
* Base header size: 4 bytes * Base header size: 4 bytes
*/ */
#define LIBNET_IPV6_NH_ROUTING 43 #define LIBNET_IPV6_NH_ROUTING 43
struct libnet_ipv6_routing_hdr struct libnet_ipv6_routing_hdr
{ {
u_int8_t ip_nh; /* next header */ uint8_t ip_nh; /* next header */
u_int8_t ip_len; /* length of header in 8 octet units (sans 1st uint8_t ip_len; /* length of header in 8 octet units (sans 1st)
) */ */
u_int8_t ip_rtype; /* routing type */ uint8_t ip_rtype; /* routing type */
u_int8_t ip_segments; /* segments left */ uint8_t ip_segments; /* segments left */
/* routing information allocated dynamically */ /* routing information allocated dynamically */
}; };
/* /*
* IPv6 destination options header * IPv6 destination options header
* Internet Protocol, version 6 * Internet Protocol, version 6
* Base header size: 2 bytes * Base header size: 2 bytes
*/ */
#define LIBNET_IPV6_NH_DESTOPTS 60 #define LIBNET_IPV6_NH_DESTOPTS 60
struct libnet_ipv6_destopts_hdr struct libnet_ipv6_destopts_hdr
{ {
u_int8_t ip_nh; /* next header */ uint8_t ip_nh; /* next header */
u_int8_t ip_len; /* length of header in 8 octet units (sans 1st uint8_t ip_len; /* length of header in 8 octet units (sans 1st)
) */ */
/* destination options information allocated dynamically */ /* destination options information allocated dynamically */
}; };
/* /*
* IPv6 hop by hop options header * IPv6 hop by hop options header
* Internet Protocol, version 6 * Internet Protocol, version 6
* Base header size: 2 bytes * Base header size: 2 bytes
*/ */
#define LIBNET_IPV6_NH_HBH 0 #define LIBNET_IPV6_NH_HBH 0
struct libnet_ipv6_hbhopts_hdr struct libnet_ipv6_hbhopts_hdr
{ {
u_int8_t ip_nh; /* next header */ uint8_t ip_nh; /* next header */
u_int8_t ip_len; /* length of header in 8 octet units (sans 1st uint8_t ip_len; /* length of header in 8 octet units (sans 1st)
) */ */
/* destination options information allocated dynamically */ /* destination options information allocated dynamically */
}; };
/* /*
* ICMP6 header * ICMP6 header
* Internet Control Message Protocol v6 * Internet Control Message Protocol v6
* Base header size: 8 bytes * Base header size: 8 bytes
*/ */
#ifndef IPPROTO_ICMP6 #ifndef IPPROTO_ICMP6
#define IPPROTO_ICMP6 0x3a #define IPPROTO_ICMP6 0x3a
#endif #endif
struct libnet_icmpv6_hdr struct libnet_icmpv6_hdr
{ {
u_int8_t icmp_type; /* ICMP type */ uint8_t icmp_type; /* ICMP type */
#ifndef ICMP6_ECHO #ifndef ICMP6_ECHO
#define ICMP6_ECHO 128 #define ICMP6_ECHO 128
#endif #endif
#ifndef ICMP6_ECHOREPLY #ifndef ICMP6_ECHOREPLY
#define ICMP6_ECHOREPLY 129 #define ICMP6_ECHOREPLY 129
#endif #endif
#ifndef ICMP6_UNREACH #ifndef ICMP6_UNREACH
#define ICMP6_UNREACH 1 #define ICMP6_UNREACH 1
#endif #endif
#ifndef ICMP6_PKTTOOBIG #ifndef ICMP6_PKTTOOBIG
#define ICMP6_PKTTOOBIG 2 #define ICMP6_PKTTOOBIG 2
#endif #endif
#ifndef ICMP6_TIMXCEED #ifndef ICMP6_TIMXCEED
#define ICMP6_TIMXCEED 3 #define ICMP6_TIMXCEED 3
#endif #endif
#ifndef ICMP6_PARAMPROB #ifndef ICMP6_PARAMPROB
#define ICMP6_PARAMPROB 4 #define ICMP6_PARAMPROB 4
#endif #endif
u_int8_t icmp_code; /* ICMP code */ uint8_t icmp_code; /* ICMP code */
u_int16_t icmp_sum; /* ICMP Checksum */ #ifndef ICMP6_NOROUTE
u_int16_t id; /* ICMP id */ #define ICMP6_NOROUTE 0
u_int16_t seq; /* ICMP sequence number */ #endif
#ifndef ICMP6_ADM_PROHIBITED
#define ICMP6_ADM_PROHIBITED 1
#endif
#ifndef ICMP6_NOT_NEIGHBOUR
#define ICMP6_NOT_NEIGHBOUR 2
#endif
#ifndef ICMP6_ADDR_UNREACH
#define ICMP6_ADDR_UNREACH 3
#endif
#ifndef ICMP6_PORT_UNREACH
#define ICMP6_PORT_UNREACH 4
#endif
uint16_t icmp_sum; /* ICMP Checksum */
uint16_t id; /* ICMP id */
uint16_t seq; /* ICMP sequence number */
}; };
/* /*
* ICMP header * ICMP header
* Internet Control Message Protocol * Internet Control Message Protocol
* Base header size: 4 bytes * Base header size: 4 bytes
*/ */
struct libnet_icmpv4_hdr struct libnet_icmpv4_hdr
{ {
u_int8_t icmp_type; /* ICMP type */ uint8_t icmp_type; /* ICMP type */
#ifndef ICMP_ECHOREPLY #ifndef ICMP_ECHOREPLY
#define ICMP_ECHOREPLY 0 #define ICMP_ECHOREPLY 0
#endif #endif
#ifndef ICMP_UNREACH #ifndef ICMP_UNREACH
#define ICMP_UNREACH 3 #define ICMP_UNREACH 3
#endif #endif
#ifndef ICMP_SOURCEQUENCH #ifndef ICMP_SOURCEQUENCH
#define ICMP_SOURCEQUENCH 4 #define ICMP_SOURCEQUENCH 4
#endif #endif
#ifndef ICMP_REDIRECT #ifndef ICMP_REDIRECT
skipping to change at line 890 skipping to change at line 906
#endif #endif
#ifndef ICMP_IREQREPLY #ifndef ICMP_IREQREPLY
#define ICMP_IREQREPLY 16 #define ICMP_IREQREPLY 16
#endif #endif
#ifndef ICMP_MASKREQ #ifndef ICMP_MASKREQ
#define ICMP_MASKREQ 17 #define ICMP_MASKREQ 17
#endif #endif
#ifndef ICMP_MASKREPLY #ifndef ICMP_MASKREPLY
#define ICMP_MASKREPLY 18 #define ICMP_MASKREPLY 18
#endif #endif
u_int8_t icmp_code; /* ICMP code */ uint8_t icmp_code; /* ICMP code */
#ifndef ICMP_UNREACH_NET #ifndef ICMP_UNREACH_NET
#define ICMP_UNREACH_NET 0 #define ICMP_UNREACH_NET 0
#endif #endif
#ifndef ICMP_UNREACH_HOST #ifndef ICMP_UNREACH_HOST
#define ICMP_UNREACH_HOST 1 #define ICMP_UNREACH_HOST 1
#endif #endif
#ifndef ICMP_UNREACH_PROTOCOL #ifndef ICMP_UNREACH_PROTOCOL
#define ICMP_UNREACH_PROTOCOL 2 #define ICMP_UNREACH_PROTOCOL 2
#endif #endif
#ifndef ICMP_UNREACH_PORT #ifndef ICMP_UNREACH_PORT
skipping to change at line 961 skipping to change at line 977
#ifndef ICMP_TIMXCEED_INTRANS #ifndef ICMP_TIMXCEED_INTRANS
#define ICMP_TIMXCEED_INTRANS 0 #define ICMP_TIMXCEED_INTRANS 0
#endif #endif
#ifndef ICMP_TIMXCEED_REASS #ifndef ICMP_TIMXCEED_REASS
#define ICMP_TIMXCEED_REASS 1 #define ICMP_TIMXCEED_REASS 1
#endif #endif
#ifndef ICMP_PARAMPROB_OPTABSENT #ifndef ICMP_PARAMPROB_OPTABSENT
#define ICMP_PARAMPROB_OPTABSENT 1 #define ICMP_PARAMPROB_OPTABSENT 1
#endif #endif
u_int16_t icmp_sum; /* ICMP Checksum */ uint16_t icmp_sum; /* ICMP Checksum */
union union
{ {
struct struct
{ {
u_int16_t id; /* ICMP id */ uint16_t id; /* ICMP id */
u_int16_t seq;/* ICMP sequence number */ uint16_t seq;/* ICMP sequence number */
} echo; } echo;
#undef icmp_id #undef icmp_id
#undef icmp_seq #undef icmp_seq
#define icmp_id hun.echo.id #define icmp_id hun.echo.id
#define icmp_seq hun.echo.seq #define icmp_seq hun.echo.seq
u_int32_t gateway; /* gateway host */ uint32_t gateway; /* gateway host */
struct struct
{ {
u_int16_t pad;/* padding */ uint16_t pad;/* padding */
u_int16_t mtu;/* MTU size */ uint16_t mtu;/* MTU size */
} frag; } frag;
} hun; } hun;
union union
{ {
struct struct
{ {
n_time its_otime; uint32_t its_otime;
n_time its_rtime; uint32_t its_rtime;
n_time its_ttime; uint32_t its_ttime;
} ts; } ts;
struct struct
{ {
struct libnet_ipv4_hdr idi_ip; struct libnet_ipv4_hdr idi_ip;
/* options and then 64 bits of data */ /* options and then 64 bits of data */
} ip; } ip;
u_int32_t mask; uint32_t mask;
int8_t data[1]; int8_t data[1];
#undef icmp_mask #undef icmp_mask
#define icmp_mask dun.mask #define icmp_mask dun.mask
#undef icmp_data #undef icmp_data
#define icmp_data dun.data #define icmp_data dun.data
#undef icmp_otime #undef icmp_otime
#define icmp_otime dun.ts.its_otime #define icmp_otime dun.ts.its_otime
#undef icmp_rtime #undef icmp_rtime
skipping to change at line 1020 skipping to change at line 1036
}dun; }dun;
}; };
/* /*
* IGMP header * IGMP header
* Internet Group Message Protocol * Internet Group Message Protocol
* Static header size: 8 bytes * Static header size: 8 bytes
*/ */
struct libnet_igmp_hdr struct libnet_igmp_hdr
{ {
u_int8_t igmp_type; /* IGMP type */ uint8_t igmp_type; /* IGMP type */
#ifndef IGMP_MEMBERSHIP_QUERY #ifndef IGMP_MEMBERSHIP_QUERY
#define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */ #define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */
#endif #endif
#ifndef IGMP_V1_MEMBERSHIP_REPORT #ifndef IGMP_V1_MEMBERSHIP_REPORT
#define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */ #define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */
#endif #endif
#ifndef IGMP_V2_MEMBERSHIP_REPORT #ifndef IGMP_V2_MEMBERSHIP_REPORT
#define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */ #define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */
#endif #endif
#ifndef IGMP_LEAVE_GROUP #ifndef IGMP_LEAVE_GROUP
#define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */ #define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */
#endif #endif
u_int8_t igmp_code; /* IGMP code */ uint8_t igmp_code; /* IGMP code */
u_int16_t igmp_sum; /* IGMP checksum */ uint16_t igmp_sum; /* IGMP checksum */
struct in_addr igmp_group;/* IGMP host IP */ struct in_addr igmp_group;/* IGMP host IP */
}; };
/* /*
* IPSEC header * IPSEC header
* Internet Protocol Security Protocol * Internet Protocol Security Protocol
* Encapsulating Security Payload Header Static header size: 12 bytes * Encapsulating Security Payload Header Static header size: 12 bytes
* Encapsulating Security Payload Footer Base header size: 2 bytes * Encapsulating Security Payload Footer Base header size: 2 bytes
* Authentication Header Static Size: 16 bytes * Authentication Header Static Size: 16 bytes
*/ */
#ifndef IPPROTO_ESP #ifndef IPPROTO_ESP
#define IPPROTO_ESP 50 /* not everyone's got this */ #define IPPROTO_ESP 50 /* not everyone's got this */
#endif #endif
struct libnet_esp_hdr struct libnet_esp_hdr
{ {
u_int32_t esp_spi; /* security parameter index */ uint32_t esp_spi; /* security parameter index */
u_int32_t esp_seq; /* ESP sequence number */ uint32_t esp_seq; /* ESP sequence number */
u_int32_t esp_iv; /* initialization vector */ uint32_t esp_iv; /* initialization vector */
}; };
struct libnet_esp_ftr struct libnet_esp_ftr
{ {
u_int8_t esp_pad_len; /* padding length */ uint8_t esp_pad_len; /* padding length */
u_int8_t esp_nh; /* next header pointer */ uint8_t esp_nh; /* next header pointer */
int8_t *esp_auth; /* authentication data */ int8_t *esp_auth; /* authentication data */
}; };
#ifndef IPPROTO_AH #ifndef IPPROTO_AH
#define IPPROTO_AH 51 /* not everyone's got this */ #define IPPROTO_AH 51 /* not everyone's got this */
#endif #endif
struct libnet_ah_hdr struct libnet_ah_hdr
{ {
u_int8_t ah_nh; /* next header */ uint8_t ah_nh; /* next header */
u_int8_t ah_len; /* payload length */ uint8_t ah_len; /* payload length */
u_int16_t ah_res; /* reserved */ uint16_t ah_res; /* reserved */
u_int32_t ah_spi; /* security parameter index */ uint32_t ah_spi; /* security parameter index */
u_int32_t ah_seq; /* AH sequence number */ uint32_t ah_seq; /* AH sequence number */
u_int32_t ah_auth; /* authentication data */ uint32_t ah_auth; /* authentication data */
}; };
/* /*
* For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001. * For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001.
* Let's hope this one stays that way for a while! * Let's hope this one stays that way for a while!
*/ */
#define LIBNET_PROTO_ISL 201 #define LIBNET_PROTO_ISL 201
/* /*
* ISL header * ISL header
* Cisco Inter-Switch Link * Cisco Inter-Switch Link
* Static header size: 26 bytes * Static header size: 26 bytes
*/ */
struct libnet_isl_hdr struct libnet_isl_hdr
{ {
u_int8_t isl_dhost[5]; /* destination address "01:00:0c:00:00" */ uint8_t isl_dhost[5]; /* destination address "01:00:0c:00:00" */
#if (LIBNET_LIL_ENDIAN) #if (LIBNET_LIL_ENDIAN)
u_int8_t isl_type:4, /* type of frame */ uint8_t isl_type:4, /* type of frame */
isl_user:4; /* user defined bits */ isl_user:4; /* user defined bits */
#endif #endif
#if (LIBNET_BIG_ENDIAN) #if (LIBNET_BIG_ENDIAN)
u_int8_t isl_user:4, /* user defined bits */ uint8_t isl_user:4, /* user defined bits */
isl_type:4; /* type of frame */ isl_type:4; /* type of frame */
#endif #endif
u_int8_t isl_shost[6]; /* source address */ uint8_t isl_shost[6]; /* source address */
u_int16_t isl_len; /* total length of packet - 18 bytes */ uint16_t isl_len; /* total length of packet - 18 bytes */
u_int8_t isl_snap[6]; /* 0xaaaa03 + vendor code */ uint8_t isl_snap[6]; /* 0xaaaa03 + vendor code */
u_int16_t isl_vid; /* 15 bit VLAN ID, 1 bit BPDU / CDP indicator uint16_t isl_vid; /* 15 bit VLAN ID, 1 bit BPDU / CDP indicator
*/ */
u_int16_t isl_index; /* port index */ uint16_t isl_index; /* port index */
u_int16_t isl_reserved; /* used for FDDI and token ring */ uint16_t isl_reserved; /* used for FDDI and token ring */
/* ethernet frame and 4 byte isl crc */ /* ethernet frame and 4 byte isl crc */
}; };
#ifndef IPPROTO_OSPF #ifndef IPPROTO_OSPF
#define IPPROTO_OSPF 89 /* not everyone's got this */ #define IPPROTO_OSPF 89 /* not everyone's got this */
#endif #endif
#define IPPROTO_OSPF_LSA 890 /* made this up. Hope it's unused */ #define IPPROTO_OSPF_LSA 890 /* made this up. Hope it's unused */
#define LIBNET_MODX 4102 /* used in LSA checksum */ #define LIBNET_MODX 4102 /* used in LSA checksum */
/* /*
skipping to change at line 1128 skipping to change at line 1144
#define LIBNET_OPT_EABIT 0x10 /* rtr's willingness to send/recv EA-LSAs */ #define LIBNET_OPT_EABIT 0x10 /* rtr's willingness to send/recv EA-LSAs */
#define LIBNET_OPT_DCBIT 0x20 /* describes handling of demand circuits */ #define LIBNET_OPT_DCBIT 0x20 /* describes handling of demand circuits */
/* /*
* MPLS header * MPLS header
* Multi-Protocol Label Switching * Multi-Protocol Label Switching
* Static header size: 4 bytes * Static header size: 4 bytes
*/ */
struct libnet_mpls_hdr struct libnet_mpls_hdr
{ {
u_int32_t mpls_les; /* 20 bits label, 3 bits exp, 1 bit bos, t tl */ uint32_t mpls_les; /* 20 bits label, 3 bits exp, 1 bit bos, tt l */
#define LIBNET_MPLS_BOS_ON 1 #define LIBNET_MPLS_BOS_ON 1
#define LIBNET_MPLS_BOS_OFF 0 #define LIBNET_MPLS_BOS_OFF 0
}; };
/* /*
* NTP header * NTP header
* Network Time Protocol * Network Time Protocol
* Static header size: 48 bytes * Static header size: 48 bytes
*/ */
struct libnet_ntp_hdr_l_fp /* int32_t floating point (64-bit) */ struct libnet_ntp_hdr_l_fp /* int32_t floating point (64-bit) */
{ {
u_int32_t integer; /* integer */ uint32_t integer; /* integer */
u_int32_t fraction; /* fraction */ uint32_t fraction; /* fraction */
}; };
struct libnet_ntp_hdr_s_fp /* int16_t floating point (32-bit) */ struct libnet_ntp_hdr_s_fp /* int16_t floating point (32-bit) */
{ {
u_int16_t integer; /* integer */ uint16_t integer; /* integer */
u_int16_t fraction; /* fraction */ uint16_t fraction; /* fraction */
}; };
struct libnet_ntp_hdr struct libnet_ntp_hdr
{ {
u_int8_t ntp_li_vn_mode; /* leap indicator, version, mode */ uint8_t ntp_li_vn_mode; /* leap indicator, version, mode * /
#define LIBNET_NTP_LI_NW 0x0 /* no warning */ #define LIBNET_NTP_LI_NW 0x0 /* no warning */
#define LIBNET_NTP_LI_AS 0x1 /* last minute has 61 seconds */ #define LIBNET_NTP_LI_AS 0x1 /* last minute has 61 seconds */
#define LIBNET_NTP_LI_DS 0x2 /* last minute has 59 seconds */ #define LIBNET_NTP_LI_DS 0x2 /* last minute has 59 seconds */
#define LIBNET_NTP_LI_AC 0x3 /* alarm condition */ #define LIBNET_NTP_LI_AC 0x3 /* alarm condition */
#define LIBNET_NTP_VN_2 0x2 /* version 2 */ #define LIBNET_NTP_VN_2 0x2 /* version 2 */
#define LIBNET_NTP_VN_3 0x3 /* version 3 */ #define LIBNET_NTP_VN_3 0x3 /* version 3 */
#define LIBNET_NTP_VN_4 0x4 /* version 4 */ #define LIBNET_NTP_VN_4 0x4 /* version 4 */
#define LIBNET_NTP_MODE_R 0x0 /* reserved */ #define LIBNET_NTP_MODE_R 0x0 /* reserved */
#define LIBNET_NTP_MODE_A 0x1 /* symmetric active */ #define LIBNET_NTP_MODE_A 0x1 /* symmetric active */
#define LIBNET_NTP_MODE_P 0x2 /* symmetric passive */ #define LIBNET_NTP_MODE_P 0x2 /* symmetric passive */
#define LIBNET_NTP_MODE_C 0x3 /* client */ #define LIBNET_NTP_MODE_C 0x3 /* client */
#define LIBNET_NTP_MODE_S 0x4 /* server */ #define LIBNET_NTP_MODE_S 0x4 /* server */
#define LIBNET_NTP_MODE_B 0x5 /* broadcast */ #define LIBNET_NTP_MODE_B 0x5 /* broadcast */
#define LIBNET_NTP_MODE_RC 0x6 /* reserved for NTP control message */ #define LIBNET_NTP_MODE_RC 0x6 /* reserved for NTP control message */
#define LIBNET_NTP_MODE_RP 0x7 /* reserved for private use */ #define LIBNET_NTP_MODE_RP 0x7 /* reserved for private use */
u_int8_t ntp_stratum; /* stratum */ uint8_t ntp_stratum; /* stratum */
#define LIBNET_NTP_STRATUM_UNAVAIL 0x0 /* unspecified or unavailable */ #define LIBNET_NTP_STRATUM_UNAVAIL 0x0 /* unspecified or unavailable */
#define LIBNET_NTP_STRATUM_PRIMARY 0x1 /* primary reference (radio clock) */ #define LIBNET_NTP_STRATUM_PRIMARY 0x1 /* primary reference (radio clock) */
/* 2 - 15 is secondary */ /* 2 - 15 is secondary */
/* 16 - 255 is reserved */ /* 16 - 255 is reserved */
u_int8_t ntp_poll; /* poll interval (should be 4 - 1 uint8_t ntp_poll; /* poll interval (should be 4 - 12
2) */ ) */
u_int8_t ntp_precision; /* local clock precision */ uint8_t ntp_precision; /* local clock precision */
struct libnet_ntp_hdr_s_fp ntp_delay; /* roundtrip delay */ struct libnet_ntp_hdr_s_fp ntp_delay; /* roundtrip delay */
struct libnet_ntp_hdr_s_fp ntp_dispersion; /* nominal error */ struct libnet_ntp_hdr_s_fp ntp_dispersion; /* nominal error */
u_int32_t ntp_reference_id; /* reference source id */ uint32_t ntp_reference_id; /* reference source id */
#define LIBNET_NTP_REF_LOCAL 0x4c4f434c /* uncalibrated local clock */ #define LIBNET_NTP_REF_LOCAL 0x4c4f434c /* uncalibrated local clock */
#define LIBNET_NTP_REF_PPS 0x50505300 /* atomic / pulse-per-second cl ock */ #define LIBNET_NTP_REF_PPS 0x50505300 /* atomic / pulse-per-second cl ock */
#define LIBNET_NTP_REF_ACTS 0x41435453 /* NIST dialup modem */ #define LIBNET_NTP_REF_ACTS 0x41435453 /* NIST dialup modem */
#define LIBNET_NTP_REF_USNO 0x55534e4f /* USNO modem service */ #define LIBNET_NTP_REF_USNO 0x55534e4f /* USNO modem service */
#define LIBNET_NTP_REF_PTB 0x50544200 /* PTB (German) modem service * / #define LIBNET_NTP_REF_PTB 0x50544200 /* PTB (German) modem service * /
#define LIBNET_NTP_REF_TDF 0x54444600 /* Allouis (French) radio */ #define LIBNET_NTP_REF_TDF 0x54444600 /* Allouis (French) radio */
#define LIBNET_NTP_REF_DCF 0x44434600 /* Mainflingen (German) radio * / #define LIBNET_NTP_REF_DCF 0x44434600 /* Mainflingen (German) radio * /
#define LIBNET_NTP_REF_MSF 0x4d534600 /* Rugby (UK) radio */ #define LIBNET_NTP_REF_MSF 0x4d534600 /* Rugby (UK) radio */
#define LIBNET_NTP_REF_WWV 0x57575600 /* Ft Collins (US) radio */ #define LIBNET_NTP_REF_WWV 0x57575600 /* Ft Collins (US) radio */
#define LIBNET_NTP_REF_WWVB 0x57575642 /* Boulder (US) radio */ #define LIBNET_NTP_REF_WWVB 0x57575642 /* Boulder (US) radio */
skipping to change at line 1209 skipping to change at line 1225
struct libnet_ntp_hdr_l_fp ntp_xmt_ts; /* transmit timestamp */ struct libnet_ntp_hdr_l_fp ntp_xmt_ts; /* transmit timestamp */
}; };
/* /*
* OSPFv2 header * OSPFv2 header
* Open Shortest Path First * Open Shortest Path First
* Static header size: 16 bytes * Static header size: 16 bytes
*/ */
struct libnet_ospf_hdr struct libnet_ospf_hdr
{ {
u_int8_t ospf_v; /* version */ uint8_t ospf_v; /* version */
#define OSPFVERSION 2 #define OSPFVERSION 2
u_int8_t ospf_type; /* type */ uint8_t ospf_type; /* type */
#define LIBNET_OSPF_UMD 0 /* UMd monitoring packet */ #define LIBNET_OSPF_UMD 0 /* UMd monitoring packet */
#define LIBNET_OSPF_HELLO 1 /* HELLO packet */ #define LIBNET_OSPF_HELLO 1 /* HELLO packet */
#define LIBNET_OSPF_DBD 2 /* dataBase description packet */ #define LIBNET_OSPF_DBD 2 /* dataBase description packet */
#define LIBNET_OSPF_LSR 3 /* link state request packet */ #define LIBNET_OSPF_LSR 3 /* link state request packet */
#define LIBNET_OSPF_LSU 4 /* link state Update Packet */ #define LIBNET_OSPF_LSU 4 /* link state Update Packet */
#define LIBNET_OSPF_LSA 5 /* link state acknowledgement packet */ #define LIBNET_OSPF_LSA 5 /* link state acknowledgement packet */
u_int16_t ospf_len; /* length */ uint16_t ospf_len; /* length */
struct in_addr ospf_rtr_id; /* source router ID */ struct in_addr ospf_rtr_id; /* source router ID */
struct in_addr ospf_area_id;/* roam ID */ struct in_addr ospf_area_id;/* roam ID */
u_int16_t ospf_sum; /* checksum */ uint16_t ospf_sum; /* checksum */
u_int16_t ospf_auth_type; /* authentication type */ uint16_t ospf_auth_type; /* authentication type */
#define LIBNET_OSPF_AUTH_NULL 0 /* null password */ #define LIBNET_OSPF_AUTH_NULL 0 /* null password */
#define LIBNET_OSPF_AUTH_SIMPLE 1 /* simple, plaintext, 8 int8_t password */ #define LIBNET_OSPF_AUTH_SIMPLE 1 /* simple, plaintext, 8 int8_t password */
#define LIBNET_OSPF_AUTH_MD5 2 /* MD5 */ #define LIBNET_OSPF_AUTH_MD5 2 /* MD5 */
}; };
/* /*
* OSPF authentication header * OSPF authentication header
* Open Shortest Path First * Open Shortest Path First
* Static header size: 8 bytes * Static header size: 8 bytes
*/ */
struct libnet_auth_hdr struct libnet_auth_hdr
{ {
u_int16_t ospf_auth_null; /* NULL */ uint16_t ospf_auth_null; /* NULL */
u_int8_t ospf_auth_keyid; /* authentication key ID */ uint8_t ospf_auth_keyid; /* authentication key ID */
u_int8_t ospf_auth_len; /* auth data length */ uint8_t ospf_auth_len; /* auth data length */
u_int ospf_auth_seq; /* cryptographic sequence number */ uint ospf_auth_seq; /* cryptographic sequence number */
}; };
/* /*
* OSPF hello header * OSPF hello header
* Open Shortest Path First * Open Shortest Path First
* Static header size: 28 bytes * Static header size: 28 bytes
*/ */
struct libnet_ospf_hello_hdr struct libnet_ospf_hello_hdr
{ {
struct in_addr hello_nmask; /* netmask associated with the interface */ struct in_addr hello_nmask; /* netmask associated with the interface */
u_int16_t hello_intrvl; /* num of seconds between routers last pa uint16_t hello_intrvl; /* num of seconds between routers last pac
cket */ ket */
u_int8_t hello_opts; /* Options for HELLO packets (look above) uint8_t hello_opts; /* Options for HELLO packets (look above)
*/ */
u_int8_t hello_rtr_pri; /* router's priority (if 0, can't be back uint8_t hello_rtr_pri; /* router's priority (if 0, can't be backu
up) */ p) */
u_int hello_dead_intvl; /* # of secs a router is silent till deemed uint hello_dead_intvl; /* # of secs a router is silent till deemed
down */ down */
struct in_addr hello_des_rtr; /* Designated router on the network */ struct in_addr hello_des_rtr; /* Designated router on the network */
struct in_addr hello_bkup_rtr; /* Backup router */ struct in_addr hello_bkup_rtr; /* Backup router */
struct in_addr hello_nbr; /* neighbor router, memcpy more as need ed */ struct in_addr hello_nbr; /* neighbor router, memcpy more as need ed */
}; };
/* /*
* Database Description header. * Database Description header.
*/ */
struct libnet_dbd_hdr struct libnet_dbd_hdr
{ {
u_int16_t dbd_mtu_len; /* max length of IP dgram that this 'if' can uint16_t dbd_mtu_len; /* max length of IP dgram that this 'if' can u
use */ se */
u_int8_t dbd_opts; /* DBD packet options (from above) */ uint8_t dbd_opts; /* DBD packet options (from above) */
u_int8_t dbd_type; /* type of exchange occurring */ uint8_t dbd_type; /* type of exchange occurring */
#define LIBNET_DBD_IBI 0x01 /* init */ #define LIBNET_DBD_IBI 0x01 /* init */
#define LIBNET_DBD_MBIT 0x02 /* more DBD packets are to come */ #define LIBNET_DBD_MBIT 0x02 /* more DBD packets are to come */
#define LIBNET_DBD_MSBIT 0x04 /* If 1, sender is the master in the ex change */ #define LIBNET_DBD_MSBIT 0x04 /* If 1, sender is the master in the ex change */
u_int dbd_seq; /* DBD sequence number */ uint dbd_seq; /* DBD sequence number */
}; };
/* /*
* used for the LS type field in all LS* headers * used for the LS type field in all LS* headers
*/ */
#define LIBNET_LS_TYPE_RTR 1 /* router-LSA */ #define LIBNET_LS_TYPE_RTR 1 /* router-LSA */
#define LIBNET_LS_TYPE_NET 2 /* network-LSA */ #define LIBNET_LS_TYPE_NET 2 /* network-LSA */
#define LIBNET_LS_TYPE_IP 3 /* summary-LSA (IP Network) */ #define LIBNET_LS_TYPE_IP 3 /* summary-LSA (IP Network) */
#define LIBNET_LS_TYPE_ASBR 4 /* summary-LSA (ASBR) */ #define LIBNET_LS_TYPE_ASBR 4 /* summary-LSA (ASBR) */
#define LIBNET_LS_TYPE_ASEXT 5 /* AS-external-LSA */ #define LIBNET_LS_TYPE_ASEXT 5 /* AS-external-LSA */
/* /*
* Link State Request header * Link State Request header
*/ */
struct libnet_lsr_hdr struct libnet_lsr_hdr
{ {
u_int lsr_type; /* type of LS being requested */ uint lsr_type; /* type of LS being requested */
u_int lsr_lsid; /* link state ID */ uint lsr_lsid; /* link state ID */
struct in_addr lsr_adrtr; /* advertising router (memcpy more as neede d) */ struct in_addr lsr_adrtr; /* advertising router (memcpy more as neede d) */
}; };
/* /*
* Link State Update header * Link State Update header
*/ */
struct libnet_lsu_hdr struct libnet_lsu_hdr
{ {
u_int lsu_num; /* number of LSAs that will be broadcasted */ uint lsu_num; /* number of LSAs that will be broadcasted * /
}; };
/* /*
* Link State Acknowledgement header. * Link State Acknowledgement header.
*/ */
struct libnet_lsa_hdr struct libnet_lsa_hdr
{ {
u_int16_t lsa_age; /* time in seconds since the LSA was originat uint16_t lsa_age; /* time in seconds since the LSA was originate
ed */ d */
u_int8_t lsa_opts; /* look above for OPTS_* */ uint8_t lsa_opts; /* look above for OPTS_* */
u_int8_t lsa_type; /* look below for LS_TYPE_* */ uint8_t lsa_type; /* look below for LS_TYPE_* */
u_int lsa_id; /* link State ID */ uint lsa_id; /* link State ID */
struct in_addr lsa_adv; /* router ID of Advertising router */ struct in_addr lsa_adv; /* router ID of Advertising router */
u_int lsa_seq; /* LSA sequence number to detect old/bad ones * uint lsa_seq; /* LSA sequence number to detect old/bad ones */
/ uint16_t lsa_sum; /* "Fletcher Checksum" of all fields minus age *
u_int16_t lsa_sum; /* "Fletcher Checksum" of all fields minus age /
*/ uint16_t lsa_len; /* length in bytes including the 20 byte heade
u_int16_t lsa_len; /* length in bytes including the 20 byte head r */
er */
}; };
/* /*
* Router LSA data format * Router LSA data format
* *
* Other stuff for TOS can be added for backward compatability, for this * Other stuff for TOS can be added for backward compatability, for this
* version, only OSPFv2 is being FULLY supported. * version, only OSPFv2 is being FULLY supported.
*/ */
struct libnet_rtr_lsa_hdr struct libnet_rtr_lsa_hdr
{ {
u_int16_t rtr_flags; /* set to help describe packet */ uint16_t rtr_flags; /* set to help describe packet */
#define LIBNET_RTR_FLAGS_W 0x0100 /* W bit */ #define LIBNET_RTR_FLAGS_W 0x0100 /* W bit */
#define LIBNET_RTR_FLAGS_E 0x0200 /* E bit */ #define LIBNET_RTR_FLAGS_E 0x0200 /* E bit */
#define LIBNET_RTR_FLAGS_B 0x0400 /* B bit */ #define LIBNET_RTR_FLAGS_B 0x0400 /* B bit */
u_int16_t rtr_num; /* number of links within that packet */ uint16_t rtr_num; /* number of links within that packet */
u_int rtr_link_id; /* describes link_data (look below) */ uint rtr_link_id; /* describes link_data (look below) */
#define LIBNET_LINK_ID_NBR_ID 1 /* Neighbors router ID, also can be 4 * / #define LIBNET_LINK_ID_NBR_ID 1 /* Neighbors router ID, also can be 4 * /
#define LIBNET_LINK_ID_IP_DES 2 /* IP address of designated router */ #define LIBNET_LINK_ID_IP_DES 2 /* IP address of designated router */
#define LIBNET_LINK_ID_SUB 3 /* IP subnet number */ #define LIBNET_LINK_ID_SUB 3 /* IP subnet number */
u_int rtr_link_data; /* Depending on link_id, info is here */ uint rtr_link_data; /* Depending on link_id, info is here */
u_int8_t rtr_type; /* Description of router link */ uint8_t rtr_type; /* Description of router link */
#define LIBNET_RTR_TYPE_PTP 1 /* Point-To-Point */ #define LIBNET_RTR_TYPE_PTP 1 /* Point-To-Point */
#define LIBNET_RTR_TYPE_TRANS 2 /* Connection to a "transit network" */ #define LIBNET_RTR_TYPE_TRANS 2 /* Connection to a "transit network" */
#define LIBNET_RTR_TYPE_STUB 3 /* Connectin to a "stub network" */ #define LIBNET_RTR_TYPE_STUB 3 /* Connectin to a "stub network" */
#define RTR_TYPE_VRTL 4 /* connects to a "virtual link" */ #define RTR_TYPE_VRTL 4 /* connects to a "virtual link" */
u_int8_t rtr_tos_num; /* number of different TOS metrics for this l uint8_t rtr_tos_num; /* number of different TOS metrics for this li
ink */ nk */
u_int16_t rtr_metric; /* the "cost" of using this link */ uint16_t rtr_metric; /* the "cost" of using this link */
}; };
/* /*
* Network LSA data format. * Network LSA data format.
*/ */
struct libnet_net_lsa_hdr struct libnet_net_lsa_hdr
{ {
struct in_addr net_nmask; /* Netmask for that network */ struct in_addr net_nmask; /* Netmask for that network */
u_int net_rtr_id; /* ID of router attached to that network */ uint net_rtr_id; /* ID of router attached to that network */
}; };
/* /*
* Summary LSA data format. * Summary LSA data format.
*/ */
struct libnet_sum_lsa_hdr struct libnet_sum_lsa_hdr
{ {
struct in_addr sum_nmask; /* Netmask of destination IP address */ struct in_addr sum_nmask; /* Netmask of destination IP address */
u_int sum_metric; /* Same as in rtr_lsa (&0xfff to use last 2 uint sum_metric; /* Same as in rtr_lsa (&0xfff to use last 24
4bit */ bit */
u_int sum_tos_metric; /* first 8bits are TOS, 24bits are TOS Metr uint sum_tos_metric; /* first 8bits are TOS, 24bits are TOS Metri
ic */ c */
}; };
/* /*
* AS External LSA data format. * AS External LSA data format.
* & 0xfff logic operator for as_metric to get last 24bits. * & 0xfff logic operator for as_metric to get last 24bits.
*/ */
struct libnet_as_lsa_hdr struct libnet_as_lsa_hdr
{ {
struct in_addr as_nmask; /* Netmask for advertised destination */ struct in_addr as_nmask; /* Netmask for advertised destination */
u_int as_metric; /* May have to set E bit in first 8bits */ uint as_metric; /* May have to set E bit in first 8bits */
#define LIBNET_AS_E_BIT_ON 0x80000000 /* as_metric */ #define LIBNET_AS_E_BIT_ON 0x80000000 /* as_metric */
struct in_addr as_fwd_addr; /* Forwarding address */ struct in_addr as_fwd_addr; /* Forwarding address */
u_int as_rte_tag; /* External route tag */ uint as_rte_tag; /* External route tag */
}; };
/* /*
* Base RIP header * Base RIP header
* Routing Information Protocol * Routing Information Protocol
* Base header size: 24 bytes * Base header size: 24 bytes
*/ */
struct libnet_rip_hdr struct libnet_rip_hdr
{ {
u_int8_t rip_cmd; /* RIP command */ uint8_t rip_cmd; /* RIP command */
#define RIPCMD_REQUEST 1 /* want info */ #define RIPCMD_REQUEST 1 /* want info */
#define RIPCMD_RESPONSE 2 /* responding to request */ #define RIPCMD_RESPONSE 2 /* responding to request */
#define RIPCMD_TRACEON 3 /* turn tracing on */ #define RIPCMD_TRACEON 3 /* turn tracing on */
#define RIPCMD_TRACEOFF 4 /* turn it off */ #define RIPCMD_TRACEOFF 4 /* turn it off */
#define RIPCMD_POLL 5 /* like request, but anyone answers */ #define RIPCMD_POLL 5 /* like request, but anyone answers */
#define RIPCMD_POLLENTRY 6 /* like poll, but for entire entry */ #define RIPCMD_POLLENTRY 6 /* like poll, but for entire entry */
#define RIPCMD_MAX 7 /* ? command */ #define RIPCMD_MAX 7 /* ? command */
u_int8_t rip_ver; /* RIP version */ uint8_t rip_ver; /* RIP version */
#define RIPVER_0 0 #define RIPVER_0 0
#define RIPVER_1 1 #define RIPVER_1 1
#define RIPVER_2 2 #define RIPVER_2 2
u_int16_t rip_rd; /* Zero (v1) or Routing Domain (v2) */ uint16_t rip_rd; /* Zero (v1) or Routing Domain (v2) */
u_int16_t rip_af; /* Address family */ uint16_t rip_af; /* Address family */
u_int16_t rip_rt; /* Zero (v1) or Route Tag (v2) */ uint16_t rip_rt; /* Zero (v1) or Route Tag (v2) */
u_int32_t rip_addr; /* IP address */ uint32_t rip_addr; /* IP address */
u_int32_t rip_mask; /* Zero (v1) or Subnet Mask (v2) */ uint32_t rip_mask; /* Zero (v1) or Subnet Mask (v2) */
u_int32_t rip_next_hop; /* Zero (v1) or Next hop IP address (v2) */ uint32_t rip_next_hop; /* Zero (v1) or Next hop IP address (v2) */
u_int32_t rip_metric; /* Metric */ uint32_t rip_metric; /* Metric */
}; };
/* /*
* RPC headers * RPC headers
* Remote Procedure Call * Remote Procedure Call
*/ */
#define LIBNET_RPC_CALL 0 #define LIBNET_RPC_CALL 0
#define LIBNET_RPC_REPLY 1 #define LIBNET_RPC_REPLY 1
#define LIBNET_RPC_VERS 2 #define LIBNET_RPC_VERS 2
#define LIBNET_RPC_LAST_FRAG 0x80000000 #define LIBNET_RPC_LAST_FRAG 0x80000000
skipping to change at line 1433 skipping to change at line 1449
#define LIBNET_PMAP_PROC_TADDR2UADDR 8 #define LIBNET_PMAP_PROC_TADDR2UADDR 8
#define LIBNET_PMAP_PROC_GETVERSADDR 9 #define LIBNET_PMAP_PROC_GETVERSADDR 9
#define LIBNET_PMAP_PROC_INDIRECT 10 #define LIBNET_PMAP_PROC_INDIRECT 10
#define LIBNET_PMAP_PROC_GETADDRLIST 11 #define LIBNET_PMAP_PROC_GETADDRLIST 11
#define LIBNET_PMAP_PROC_GETSTAT 12 #define LIBNET_PMAP_PROC_GETSTAT 12
/* There will be more to add... */ /* There will be more to add... */
struct libnet_rpc_opaque_auth struct libnet_rpc_opaque_auth
{ {
u_int32_t rpc_auth_flavor; uint32_t rpc_auth_flavor;
u_int32_t rpc_auth_length; uint32_t rpc_auth_length;
#if 0 #if 0
u_int8_t *rpc_auth_data; uint8_t *rpc_auth_data;
#endif #endif
}; };
struct libnet_rpc_call struct libnet_rpc_call
{ {
u_int32_t rpc_rpcvers; /* RPC version - must be 2 */ uint32_t rpc_rpcvers; /* RPC version - must be 2 */
u_int32_t rpc_prognum; /* Program Number */ uint32_t rpc_prognum; /* Program Number */
u_int32_t rpc_vers; /* Program Version */ uint32_t rpc_vers; /* Program Version */
u_int32_t rpc_procedure; /* RPC procedure */ uint32_t rpc_procedure; /* RPC procedure */
struct libnet_rpc_opaque_auth rpc_credentials; struct libnet_rpc_opaque_auth rpc_credentials;
struct libnet_rpc_opaque_auth rpc_verifier; struct libnet_rpc_opaque_auth rpc_verifier;
}; };
struct libnet_rpc_call_hdr struct libnet_rpc_call_hdr
{ {
u_int32_t rpc_xid; /* xid (transaction identifier) */ uint32_t rpc_xid; /* xid (transaction identifier) */
u_int32_t rpc_type; uint32_t rpc_type;
struct libnet_rpc_call rpc_call; struct libnet_rpc_call rpc_call;
}; };
struct libnet_rpc_call_tcp_hdr struct libnet_rpc_call_tcp_hdr
{ {
u_int32_t rpc_record_marking; /* used with byte stream protocols */ uint32_t rpc_record_marking; /* used with byte stream protocols */
struct libnet_rpc_call_hdr rpc_common; struct libnet_rpc_call_hdr rpc_common;
}; };
/* /*
* STP configuration header * STP configuration header
* Spanning Tree Protocol * Spanning Tree Protocol
* Static header size: 35 bytes * Static header size: 35 bytes
*/ */
struct libnet_stp_conf_hdr struct libnet_stp_conf_hdr
{ {
u_int16_t stp_id; /* protocol id */ uint16_t stp_id; /* protocol id */
u_int8_t stp_version; /* protocol version */ uint8_t stp_version; /* protocol version */
u_int8_t stp_bpdu_type; /* bridge protocol data unit type */ uint8_t stp_bpdu_type; /* bridge protocol data unit type */
u_int8_t stp_flags; /* control flags */ uint8_t stp_flags; /* control flags */
u_int8_t stp_rootid[8]; /* root id */ uint8_t stp_rootid[8]; /* root id */
u_int32_t stp_rootpc; /* root path cost */ uint32_t stp_rootpc; /* root path cost */
u_int8_t stp_bridgeid[8]; /* bridge id */ uint8_t stp_bridgeid[8]; /* bridge id */
u_int16_t stp_portid; /* port id */ uint16_t stp_portid; /* port id */
u_int16_t stp_mage; /* message age */ uint16_t stp_mage; /* message age */
u_int16_t stp_maxage; /* max age */ uint16_t stp_maxage; /* max age */
u_int16_t stp_hellot; /* hello time */ uint16_t stp_hellot; /* hello time */
u_int16_t stp_fdelay; /* forward delay */ uint16_t stp_fdelay; /* forward delay */
}; };
/* /*
* STP topology change notification header * STP topology change notification header
* Spanning Tree Protocol * Spanning Tree Protocol
* Static header size: 4 bytes * Static header size: 4 bytes
*/ */
struct libnet_stp_tcn_hdr struct libnet_stp_tcn_hdr
{ {
u_int16_t stp_id; /* protocol id */ uint16_t stp_id; /* protocol id */
u_int8_t stp_version; /* protocol version */ uint8_t stp_version; /* protocol version */
u_int8_t stp_bpdu_type; /* bridge protocol data unit type */ uint8_t stp_bpdu_type; /* bridge protocol data unit type */
}; };
/* /*
* TCP header * TCP header
* Transmission Control Protocol * Transmission Control Protocol
* Static header size: 20 bytes * Static header size: 20 bytes
*/ */
struct libnet_tcp_hdr struct libnet_tcp_hdr
{ {
u_int16_t th_sport; /* source port */ uint16_t th_sport; /* source port */
u_int16_t th_dport; /* destination port */ uint16_t th_dport; /* destination port */
u_int32_t th_seq; /* sequence number */ uint32_t th_seq; /* sequence number */
u_int32_t th_ack; /* acknowledgement number */ uint32_t th_ack; /* acknowledgement number */
#if (LIBNET_LIL_ENDIAN) #if (LIBNET_LIL_ENDIAN)
u_int8_t th_x2:4, /* (unused) */ uint8_t th_x2:4, /* (unused) */
th_off:4; /* data offset */ th_off:4; /* data offset */
#endif #endif
#if (LIBNET_BIG_ENDIAN) #if (LIBNET_BIG_ENDIAN)
u_int8_t th_off:4, /* data offset */ uint8_t th_off:4, /* data offset */
th_x2:4; /* (unused) */ th_x2:4; /* (unused) */
#endif #endif
u_int8_t th_flags; /* control flags */ uint8_t th_flags; /* control flags */
#ifndef TH_FIN #ifndef TH_FIN
#define TH_FIN 0x01 /* finished send data */ #define TH_FIN 0x01 /* finished send data */
#endif #endif
#ifndef TH_SYN #ifndef TH_SYN
#define TH_SYN 0x02 /* synchronize sequence numbers */ #define TH_SYN 0x02 /* synchronize sequence numbers */
#endif #endif
#ifndef TH_RST #ifndef TH_RST
#define TH_RST 0x04 /* reset the connection */ #define TH_RST 0x04 /* reset the connection */
#endif #endif
#ifndef TH_PUSH #ifndef TH_PUSH
skipping to change at line 1540 skipping to change at line 1556
#endif #endif
#ifndef TH_URG #ifndef TH_URG
#define TH_URG 0x20 /* urgent! */ #define TH_URG 0x20 /* urgent! */
#endif #endif
#ifndef TH_ECE #ifndef TH_ECE
#define TH_ECE 0x40 #define TH_ECE 0x40
#endif #endif
#ifndef TH_CWR #ifndef TH_CWR
#define TH_CWR 0x80 #define TH_CWR 0x80
#endif #endif
u_int16_t th_win; /* window */ uint16_t th_win; /* window */
u_int16_t th_sum; /* checksum */ uint16_t th_sum; /* checksum */
u_int16_t th_urp; /* urgent pointer */ uint16_t th_urp; /* urgent pointer */
}; };
/* /*
* Token Ring Header * Token Ring Header
*/ */
struct libnet_token_ring_hdr struct libnet_token_ring_hdr
{ {
u_int8_t token_ring_access_control; uint8_t token_ring_access_control;
#define LIBNET_TOKEN_RING_FRAME 0x10 #define LIBNET_TOKEN_RING_FRAME 0x10
u_int8_t token_ring_frame_control; uint8_t token_ring_frame_control;
#define LIBNET_TOKEN_RING_LLC_FRAME 0x40 #define LIBNET_TOKEN_RING_LLC_FRAME 0x40
u_int8_t token_ring_dhost[TOKEN_RING_ADDR_LEN]; uint8_t token_ring_dhost[TOKEN_RING_ADDR_LEN];
u_int8_t token_ring_shost[TOKEN_RING_ADDR_LEN]; uint8_t token_ring_shost[TOKEN_RING_ADDR_LEN];
u_int8_t token_ring_llc_dsap; uint8_t token_ring_llc_dsap;
u_int8_t token_ring_llc_ssap; uint8_t token_ring_llc_ssap;
u_int8_t token_ring_llc_control_field; uint8_t token_ring_llc_control_field;
u_int8_t token_ring_llc_org_code[LIBNET_ORG_CODE_SIZE]; uint8_t token_ring_llc_org_code[LIBNET_ORG_CODE_SIZE];
u_int16_t token_ring_type; uint16_t token_ring_type;
#define TOKEN_RING_TYPE_IP 0x0800 /* IP protocol */ #define TOKEN_RING_TYPE_IP 0x0800 /* IP protocol */
#define TOKEN_RING_TYPE_ARP 0x0806 /* addr. resolution protocol */ #define TOKEN_RING_TYPE_ARP 0x0806 /* addr. resolution protocol */
#define TOKEN_RING_TYPE_REVARP 0x8035 /* reverse addr. resolution p rotocol */ #define TOKEN_RING_TYPE_REVARP 0x8035 /* reverse addr. resolution p rotocol */
}; };
struct libnet_token_ring_addr struct libnet_token_ring_addr
{ {
u_int8_t token_ring_addr_octet[6]; /* Token Ring address */ uint8_t token_ring_addr_octet[6]; /* Token Ring address */
}; };
/* /*
* UDP header * UDP header
* User Data Protocol * User Data Protocol
* Static header size: 8 bytes * Static header size: 8 bytes
*/ */
struct libnet_udp_hdr struct libnet_udp_hdr
{ {
u_int16_t uh_sport; /* soure port */ uint16_t uh_sport; /* source port */
u_int16_t uh_dport; /* destination port */ uint16_t uh_dport; /* destination port */
u_int16_t uh_ulen; /* length */ uint16_t uh_ulen; /* length */
u_int16_t uh_sum; /* checksum */ uint16_t uh_sum; /* checksum */
}; };
/* /*
* Sebek header * Sebek header
* Static header size: 48 bytes * Static header size: 48 bytes
*/ */
struct libnet_sebek_hdr struct libnet_sebek_hdr
{ {
u_int32_t magic; /* identify packets that should be hidden */ uint32_t magic; /* identify packets that should be hidden */
u_int16_t version; /* protocol version, currently 1 */ uint16_t version; /* protocol version, currently 1 */
#define SEBEK_PROTO_VERSION 1 #define SEBEK_PROTO_VERSION 1
u_int16_t type; /* type of record (read data is type 0, writ e data is type 1) */ uint16_t type; /* type of record (read data is type 0, write data is type 1) */
#define SEBEK_TYPE_READ 0 /* Currently, only read is supported */ #define SEBEK_TYPE_READ 0 /* Currently, only read is supported */
#define SEBEK_TYPE_WRITE 1 #define SEBEK_TYPE_WRITE 1
u_int32_t counter; /* PDU counter used to identify when packet uint32_t counter; /* PDU counter used to identify when packet
are lost */ are lost */
u_int32_t time_sec; /* seconds since EPOCH according to the hone uint32_t time_sec; /* seconds since EPOCH according to the honey
ypot */ pot */
u_int32_t time_usec; /* residual microseconds */ uint32_t time_usec; /* residual microseconds */
u_int32_t pid; /* PID */ uint32_t pid; /* PID */
u_int32_t uid; /* UID */ uint32_t uid; /* UID */
u_int32_t fd; /* FD */ uint32_t fd; /* FD */
#define SEBEK_CMD_LENGTH 12 #define SEBEK_CMD_LENGTH 12
u_int8_t cmd[SEBEK_CMD_LENGTH]; /* 12 first characters of the command * uint8_t cmd[SEBEK_CMD_LENGTH]; /* 12 first characters of the command */
/ uint32_t length; /* length in bytes of the PDU's body */
u_int32_t length; /* length in bytes of the PDU's body */
}; };
/* /*
* VRRP header * VRRP header
* Virtual Router Redundancy Protocol * Virtual Router Redundancy Protocol
* Static header size: 8 bytes * Static header size: 8 bytes
*/ */
#ifndef IPPROTO_VRRP #ifndef IPPROTO_VRRP
#define IPPROTO_VRRP 112 /* not everyone's got this */ #define IPPROTO_VRRP 112 /* not everyone's got this */
#endif #endif
struct libnet_vrrp_hdr struct libnet_vrrp_hdr
{ {
#if (LIBNET_LIL_ENDIAN) #if (LIBNET_LIL_ENDIAN)
u_int8_t vrrp_v:4, /* protocol version */ uint8_t vrrp_v:4, /* protocol version */
vrrp_t:4; /* packet type */ vrrp_t:4; /* packet type */
#endif #endif
#if (LIBNET_BIG_ENDIAN) #if (LIBNET_BIG_ENDIAN)
u_int8_t vrrp_t:4, /* packet type */ uint8_t vrrp_t:4, /* packet type */
vrrp_v:4; /* protocol version */ vrrp_v:4; /* protocol version */
#endif #endif
#define LIBNET_VRRP_VERSION_01 0x1 #define LIBNET_VRRP_VERSION_01 0x1
#define LIBNET_VRRP_VERSION_02 0x2 #define LIBNET_VRRP_VERSION_02 0x2
#define LIBNET_VRRP_TYPE_ADVERT 0x1 #define LIBNET_VRRP_TYPE_ADVERT 0x1
u_int8_t vrrp_vrouter_id; /* virtual router id */ uint8_t vrrp_vrouter_id; /* virtual router id */
u_int8_t vrrp_priority; /* priority */ uint8_t vrrp_priority; /* priority */
u_int8_t vrrp_ip_count; /* number of IP addresses */ uint8_t vrrp_ip_count; /* number of IP addresses */
u_int8_t vrrp_auth_type; /* authorization type */ uint8_t vrrp_auth_type; /* authorization type */
#define LIBNET_VRRP_AUTH_NONE 0x1 #define LIBNET_VRRP_AUTH_NONE 0x1
#define LIBNET_VRRP_AUTH_PASSWD 0x2 #define LIBNET_VRRP_AUTH_PASSWD 0x2
#define LIBNET_VRRP_AUTH_IPAH 0x3 #define LIBNET_VRRP_AUTH_IPAH 0x3
u_int8_t vrrp_advert_int; /* advertisement interval */ uint8_t vrrp_advert_int; /* advertisement interval */
u_int16_t vrrp_sum; /* checksum */ uint16_t vrrp_sum; /* checksum */
/* additional addresses */ /* additional addresses */
/* authentication info */ /* authentication info */
}; };
/* /*
* HSRP header * HSRP header
* Static header size: 20 bytes * Static header size: 20 bytes
*/ */
struct libnet_hsrp_hdr struct libnet_hsrp_hdr
{ {
#define LIBNET_HSRP_VERSION 0x0 #define LIBNET_HSRP_VERSION 0x0
u_int8_t version; /* Version of the HSRP messages */ uint8_t version; /* Version of the HSRP messages */
#define LIBNET_HSRP_TYPE_HELLO 0x0 #define LIBNET_HSRP_TYPE_HELLO 0x0
#define LIBNET_HSRP_TYPE_COUP 0x1 #define LIBNET_HSRP_TYPE_COUP 0x1
#define LIBNET_HSRP_TYPE_RESIGN 0x2 #define LIBNET_HSRP_TYPE_RESIGN 0x2
u_int8_t opcode; /* Type of message */ uint8_t opcode; /* Type of message */
#define LIBNET_HSRP_STATE_INITIAL 0x0 #define LIBNET_HSRP_STATE_INITIAL 0x0
#define LIBNET_HSRP_STATE_LEARN 0x1 #define LIBNET_HSRP_STATE_LEARN 0x1
#define LIBNET_HSRP_STATE_LISTEN 0x2 #define LIBNET_HSRP_STATE_LISTEN 0x2
#define LIBNET_HSRP_STATE_SPEAK 0x4 #define LIBNET_HSRP_STATE_SPEAK 0x4
#define LIBNET_HSRP_STATE_STANDBY 0x8 #define LIBNET_HSRP_STATE_STANDBY 0x8
#define LIBNET_HSRP_STATE_ACTIVE 0x10 #define LIBNET_HSRP_STATE_ACTIVE 0x10
u_int8_t state; /* Current state of the router */ uint8_t state; /* Current state of the router */
u_int8_t hello_time; /* Period in seconds between hello messages uint8_t hello_time; /* Period in seconds between hello messages *
*/ /
u_int8_t hold_time; /* Seconds that the current hello message is uint8_t hold_time; /* Seconds that the current hello message is
valid */ valid */
u_int8_t priority; /* Priority for the election proccess */ uint8_t priority; /* Priority for the election proccess */
u_int8_t group; /* Standby group */ uint8_t group; /* Standby group */
u_int8_t reserved; /* Reserved field */ uint8_t reserved; /* Reserved field */
#define HSRP_AUTHDATA_LENGTH 8 #define HSRP_AUTHDATA_LENGTH 8
u_int8_t authdata[HSRP_AUTHDATA_LENGTH]; /* Password */ uint8_t authdata[HSRP_AUTHDATA_LENGTH]; /* Password */
u_int32_t virtual_ip; /* Virtual IP address */ uint32_t virtual_ip; /* Virtual IP address */
}; };
#endif /* __LIBNET_HEADERS_H */ #endif /* __LIBNET_HEADERS_H */
/* EOF */ /* EOF */
 End of changes. 122 change blocks. 
339 lines changed or deleted 351 lines changed or added


 libnet-macros.h   libnet-macros.h 
skipping to change at line 133 skipping to change at line 133
#if (LIBNET_BSD_BYTE_SWAP) #if (LIBNET_BSD_BYTE_SWAP)
#define FIX(n) ntohs(n) #define FIX(n) ntohs(n)
#define UNFIX(n) htons(n) #define UNFIX(n) htons(n)
#else #else
#define FIX(n) (n) #define FIX(n) (n)
#define UNFIX(n) (n) #define UNFIX(n) (n)
#endif #endif
/* used internally for packet builders */ /* used internally for packet builders */
#define LIBNET_DO_PAYLOAD(l, p) \ #define LIBNET_DO_PAYLOAD(l, p) \
if ((payload && !payload_s) || (!payload && payload_s)) \ if (payload_s && !payload) \
{ \ { \
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, \ snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, \
"%s(): payload inconsistency\n", __func__); \ "%s(): payload inconsistency\n", __func__); \
goto bad; \ goto bad; \
} \ } \
if (payload && payload_s) \ if (payload_s) \
{ \ { \
n = libnet_pblock_append(l, p, payload, payload_s); \ n = libnet_pblock_append(l, p, payload, payload_s); \
if (n == (u_int32_t) - 1) \ if (n == (uint32_t) - 1) \
{ \ { \
goto bad; \ goto bad; \
} \ } \
} \ } \
/* used internally for checksum stuff */ /* used internally for checksum stuff */
#define LIBNET_CKSUM_CARRY(x) \ #define LIBNET_CKSUM_CARRY(x) \
(x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff)) (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff))
/* used interally for OSPF stuff */ /* used interally for OSPF stuff */
#define LIBNET_OSPF_AUTHCPY(x, y) \ #define LIBNET_OSPF_AUTHCPY(x, y) \
memcpy((u_int8_t *)x, (u_int8_t *)y, sizeof(y)) memcpy((uint8_t *)x, (uint8_t *)y, sizeof(y))
#define LIBNET_OSPF_CKSUMBUF(x, y) \ #define LIBNET_OSPF_CKSUMBUF(x, y) \
memcpy((u_int8_t *)x, (u_int8_t *)y, sizeof(y)) memcpy((uint8_t *)x, (uint8_t *)y, sizeof(y))
/* used internally for NTP leap indicator, version, and mode */ /* used internally for NTP leap indicator, version, and mode */
#define LIBNET_NTP_DO_LI_VN_MODE(li, vn, md) \ #define LIBNET_NTP_DO_LI_VN_MODE(li, vn, md) \
((u_int8_t)((((li) << 6) & 0xc0) | (((vn) << 3) & 0x38) | ((md) & 0x7)) ) ((uint8_t)((((li) << 6) & 0xc0) | (((vn) << 3) & 0x38) | ((md) & 0x7)))
/* Not all systems have IFF_LOOPBACK */ /* Not all systems have IFF_LOOPBACK */
#ifdef IFF_LOOPBACK #ifdef IFF_LOOPBACK
#define LIBNET_ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK) #define LIBNET_ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK)
#else #else
#define LIBNET_ISLOOPBACK(p) (strcmp((p)->ifr_name, "lo0") == 0) #define LIBNET_ISLOOPBACK(p) (strcmp((p)->ifr_name, "lo0") == 0)
#endif #endif
/* advanced mode check */ /* advanced mode check */
#define LIBNET_ISADVMODE(x) (x & 0x08) #define LIBNET_ISADVMODE(x) (x & 0x08)
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added


 libnet-structures.h   libnet-structures.h 
skipping to change at line 43 skipping to change at line 43
#define __LIBNET_STRUCTURES_H #define __LIBNET_STRUCTURES_H
#if ((__WIN32__) && !(__CYGWIN__)) #if ((__WIN32__) && !(__CYGWIN__))
#include "Packet32.h" #include "Packet32.h"
#endif #endif
/* port list chain structure */ /* port list chain structure */
typedef struct libnet_port_list_chain libnet_plist_t; typedef struct libnet_port_list_chain libnet_plist_t;
struct libnet_port_list_chain struct libnet_port_list_chain
{ {
u_int16_t node; /* node number */ uint16_t node; /* node number */
u_int16_t bport; /* beggining port */ uint16_t bport; /* beggining port */
u_int16_t eport; /* terminating port */ uint16_t eport; /* terminating port */
u_int8_t id; /* global array offset */ uint8_t id; /* global array offset */
libnet_plist_t *next; /* next node in the list */ libnet_plist_t *next; /* next node in the list */
}; };
/* libnet statistics structure */ /* libnet statistics structure */
struct libnet_stats struct libnet_stats
{ {
#if (!defined(__WIN32__) || (__CYGWIN__)) #if (!defined(__WIN32__) || (__CYGWIN__))
u_int64_t packets_sent; /* packets sent */ uint64_t packets_sent; /* packets sent */
u_int64_t packet_errors; /* packets errors */ uint64_t packet_errors; /* packets errors */
u_int64_t bytes_written; /* bytes written */ uint64_t bytes_written; /* bytes written */
#else #else
__int64 packets_sent; /* packets sent */ __int64 packets_sent; /* packets sent */
__int64 packet_errors; /* packets errors */ __int64 packet_errors; /* packets errors */
__int64 bytes_written; /* bytes written */ __int64 bytes_written; /* bytes written */
#endif #endif
}; };
/* /*
* Libnet ptags are how we identify specific protocol blocks inside the * Libnet ptags are how we identify specific protocol blocks inside the
* list. * list.
*/ */
typedef int32_t libnet_ptag_t; typedef int32_t libnet_ptag_t;
#define LIBNET_PTAG_INITIALIZER 0 #define LIBNET_PTAG_INITIALIZER 0
/* /*
* Libnet generic protocol block memory object. Sort of a poor man's mbuf . * Libnet generic protocol block memory object. Sort of a poor man's mbuf .
*/ */
struct libnet_protocol_block struct libnet_protocol_block
{ {
u_int8_t *buf; /* protocol buffer */ uint8_t *buf; /* protocol buffer */
u_int32_t b_len; /* length of buf */ uint32_t b_len; /* length of buf */
u_int16_t h_len; /* header length (for checksumming) uint16_t h_len; /* header length */
*/ /* Passed as last argument to libnet_do_checksum(). Not necessarily
/* Unused for IPV4_H block types. used
* by that function, it is essentially a pblock specific number, pas
sed
* from _builder to the _do_checksum
*
* Unused for IPV4_H block types.
*
* For protocols that sit on top of IP, it should be the the amount of * For protocols that sit on top of IP, it should be the the amount of
* buf that is the header, and will be included in the checksum. * buf that will be included in the checksum, starting from the begi
*/ nning
u_int32_t ip_offset; /* offset from end of pkt to beginn * of the header.
ing of IP header for csums */
/* Unused for IPV4_H block types.
* For protocols that sit on top of IP (UDP, ICMP, ...), they often
* include some information from the IP header (in the form of a "ps
eudo
* header") in their own checksum calculation. To build that
* pseudo-header, thet need to find the real header.
*/ */
u_int32_t copied; /* bytes copied - the amount of dat a copied into buf */ uint32_t copied; /* bytes copied - the amount of data copied into buf */
/* Used and updated by libnet_pblock_append(). */ /* Used and updated by libnet_pblock_append(). */
u_int8_t type; /* type of pblock */ uint8_t type; /* type of pblock */
/* this needs to be updated every time a new packet builder is added */ /* this needs to be updated every time a new packet builder is added */
/* libnet_diag_dump_pblock_type() also needs updating for every new pblock tag */
#define LIBNET_PBLOCK_ARP_H 0x01 /* ARP header */ #define LIBNET_PBLOCK_ARP_H 0x01 /* ARP header */
#define LIBNET_PBLOCK_DHCPV4_H 0x02 /* DHCP v4 header */ #define LIBNET_PBLOCK_DHCPV4_H 0x02 /* DHCP v4 header */
#define LIBNET_PBLOCK_DNSV4_H 0x03 /* DNS v4 header */ #define LIBNET_PBLOCK_DNSV4_H 0x03 /* DNS v4 header */
#define LIBNET_PBLOCK_ETH_H 0x04 /* Ethernet header */ #define LIBNET_PBLOCK_ETH_H 0x04 /* Ethernet header */
#define LIBNET_PBLOCK_ICMPV4_H 0x05 /* ICMP v4 base header */ #define LIBNET_PBLOCK_ICMPV4_H 0x05 /* ICMP v4 base header */
#define LIBNET_PBLOCK_ICMPV4_ECHO_H 0x06 /* ICMP v4 echo header */ #define LIBNET_PBLOCK_ICMPV4_ECHO_H 0x06 /* ICMP v4 echo header */
#define LIBNET_PBLOCK_ICMPV4_MASK_H 0x07 /* ICMP v4 mask header */ #define LIBNET_PBLOCK_ICMPV4_MASK_H 0x07 /* ICMP v4 mask header */
#define LIBNET_PBLOCK_ICMPV4_UNREACH_H 0x08 /* ICMP v4 unreach header * / #define LIBNET_PBLOCK_ICMPV4_UNREACH_H 0x08 /* ICMP v4 unreach header * /
#define LIBNET_PBLOCK_ICMPV4_TIMXCEED_H 0x09 /* ICMP v4 exceed header */ #define LIBNET_PBLOCK_ICMPV4_TIMXCEED_H 0x09 /* ICMP v4 exceed header */
#define LIBNET_PBLOCK_ICMPV4_REDIRECT_H 0x0a /* ICMP v4 redirect header */ #define LIBNET_PBLOCK_ICMPV4_REDIRECT_H 0x0a /* ICMP v4 redirect header */
skipping to change at line 158 skipping to change at line 158
#define LIBNET_PBLOCK_BGP4_UPDATE_H 0x37 /* BGP4 update header */ #define LIBNET_PBLOCK_BGP4_UPDATE_H 0x37 /* BGP4 update header */
#define LIBNET_PBLOCK_BGP4_NOTIFICATION_H 0x38 /* BGP4 notification header */ #define LIBNET_PBLOCK_BGP4_NOTIFICATION_H 0x38 /* BGP4 notification header */
#define LIBNET_PBLOCK_GRE_H 0x39 /* GRE header */ #define LIBNET_PBLOCK_GRE_H 0x39 /* GRE header */
#define LIBNET_PBLOCK_GRE_SRE_H 0x3a /* GRE SRE header */ #define LIBNET_PBLOCK_GRE_SRE_H 0x3a /* GRE SRE header */
#define LIBNET_PBLOCK_IPV6_FRAG_H 0x3b /* IPv6 frag header */ #define LIBNET_PBLOCK_IPV6_FRAG_H 0x3b /* IPv6 frag header */
#define LIBNET_PBLOCK_IPV6_ROUTING_H 0x3c /* IPv6 routing header */ #define LIBNET_PBLOCK_IPV6_ROUTING_H 0x3c /* IPv6 routing header */
#define LIBNET_PBLOCK_IPV6_DESTOPTS_H 0x3d /* IPv6 dest opts header */ #define LIBNET_PBLOCK_IPV6_DESTOPTS_H 0x3d /* IPv6 dest opts header */
#define LIBNET_PBLOCK_IPV6_HBHOPTS_H 0x3e /* IPv6 hop/hop opts header */ #define LIBNET_PBLOCK_IPV6_HBHOPTS_H 0x3e /* IPv6 hop/hop opts header */
#define LIBNET_PBLOCK_SEBEK_H 0x3f /* Sebek header */ #define LIBNET_PBLOCK_SEBEK_H 0x3f /* Sebek header */
#define LIBNET_PBLOCK_HSRP_H 0x40 /* HSRP header */ #define LIBNET_PBLOCK_HSRP_H 0x40 /* HSRP header */
u_int8_t flags; /* control flags */ #define LIBNET_PBLOCK_ICMPV6_H 0x41 /* ICMPv6 header */
#define LIBNET_PBLOCK_ICMPV6_UNREACH_H 0x42 /* ICMPv6 unreach header */
uint8_t flags; /* control flags */
#define LIBNET_PBLOCK_DO_CHECKSUM 0x01 /* needs a checksum */ #define LIBNET_PBLOCK_DO_CHECKSUM 0x01 /* needs a checksum */
libnet_ptag_t ptag; /* protocol block tag */ libnet_ptag_t ptag; /* protocol block tag */
/* Chains are built from highest level protocol, towards the link level
, so
* prev traverses away from link level, and next traverses towards the
* link level.
*/
struct libnet_protocol_block *next; /* next pblock */ struct libnet_protocol_block *next; /* next pblock */
struct libnet_protocol_block *prev; /* prev pblock */ struct libnet_protocol_block *prev; /* prev pblock */
}; };
typedef struct libnet_protocol_block libnet_pblock_t; typedef struct libnet_protocol_block libnet_pblock_t;
/* /*
* Libnet context * Libnet context
* Opaque structure. Nothing in here should ever been touched first hand by * Opaque structure. Nothing in here should ever been touched first hand by
* the applications programmer. * the applications programmer.
*/ */
struct libnet_context struct libnet_context
{ {
#if ((__WIN32__) && !(__CYGWIN__)) #if ((__WIN32__) && !(__CYGWIN__))
SOCKET fd; SOCKET fd;
LPADAPTER lpAdapter; LPADAPTER lpAdapter;
#else #else
int fd; /* file descriptor of packet device */ int fd; /* file descriptor of packet device */
#endif #endif
int injection_type; /* raw (ipv4 or ipv6) or link */ int injection_type; /* one of: */
#define LIBNET_NONE 0xf8 /* no injection type, only construc
t packets */
#define LIBNET_LINK 0x00 /* link-layer interface */ #define LIBNET_LINK 0x00 /* link-layer interface */
#define LIBNET_RAW4 0x01 /* raw socket interface (ipv4) */ #define LIBNET_RAW4 0x01 /* raw socket interface (ipv4) */
#define LIBNET_RAW6 0x02 /* raw socket interface (ipv6) */ #define LIBNET_RAW6 0x02 /* raw socket interface (ipv6) */
/* the following should actually set a flag in the flags variable above */ /* the following should actually set a flag in the flags variable above */
#define LIBNET_LINK_ADV 0x08 /* advanced mode link-layer */ #define LIBNET_LINK_ADV 0x08 /* advanced mode link-layer */
#define LIBNET_RAW4_ADV 0x09 /* advanced mode raw socket (ipv4) */ #define LIBNET_RAW4_ADV 0x09 /* advanced mode raw socket (ipv4) */
#define LIBNET_RAW6_ADV 0x0a /* advanced mode raw socket (ipv6) */ #define LIBNET_RAW6_ADV 0x0a /* advanced mode raw socket (ipv6) */
#define LIBNET_ADV_MASK 0x08 /* mask to determine adv mode */ #define LIBNET_ADV_MASK 0x08 /* mask to determine adv mode */
/* _blocks is the highest level, and _end is closest to link-level */
libnet_pblock_t *protocol_blocks; /* protocol headers / data */ libnet_pblock_t *protocol_blocks; /* protocol headers / data */
libnet_pblock_t *pblock_end; /* last node in list */ libnet_pblock_t *pblock_end; /* last node in list */
u_int32_t n_pblocks; /* number of pblocks */ uint32_t n_pblocks; /* number of pblocks */
int link_type; /* link-layer type, a DLT_ value. *
/
/* These are the only values used by libnet (see libnet_build_arp and
* libnet_build_link). Other values are assigned by the various
* libnet_link_*.c OS support functions, but are not yet used or suppor
ted,
* they are effectively dead code. <pcap.h> claims these two are invari
ant
* across operating systems... hopefully it is correct!
*/
#ifndef DLT_EN10MB
# define DLT_EN10MB 1 /* Ethernet (10Mb) */
#endif
#ifndef DLT_IEEE802
# define DLT_IEEE802 6 /* IEEE 802 Networks */
#endif
int link_type; /* link-layer type */
int link_offset; /* link-layer header size */ int link_offset; /* link-layer header size */
int aligner; /* used to align packets */ int aligner; /* used to align packets */
char *device; /* device name */ char *device; /* device name */
struct libnet_stats stats; /* statistics */ struct libnet_stats stats; /* statistics */
libnet_ptag_t ptag_state; /* state holder for pblock tag */ libnet_ptag_t ptag_state; /* state holder for pblock tag */
char label[LIBNET_LABEL_SIZE]; /* textual label for cq interface * / char label[LIBNET_LABEL_SIZE]; /* textual label for cq interface * /
char err_buf[LIBNET_ERRBUF_SIZE]; /* error buffer */ char err_buf[LIBNET_ERRBUF_SIZE]; /* error buffer */
u_int32_t total_size; /* total size */ uint32_t total_size; /* total size */
}; };
typedef struct libnet_context libnet_t; typedef struct libnet_context libnet_t;
/* /*
* Libnet context queue structure * Libnet context queue structure
* Opaque structure. Nothing in here should ever been touched first hand by * Opaque structure. Nothing in here should ever been touched first hand by
* the applications programmer. * the applications programmer.
*/ */
typedef struct _libnet_context_queue libnet_cq_t; typedef struct _libnet_context_queue libnet_cq_t;
struct _libnet_context_queue struct _libnet_context_queue
{ {
libnet_t *context; /* pointer to libnet context */ libnet_t *context; /* pointer to libnet context */
libnet_cq_t *next; /* next node in the list */ libnet_cq_t *next; /* next node in the list */
libnet_cq_t *prev; /* previous node in the list */ libnet_cq_t *prev; /* previous node in the list */
}; };
struct _libnet_context_queue_descriptor struct _libnet_context_queue_descriptor
{ {
u_int32_t node; /* number of nodes in the list */ uint32_t node; /* number of nodes in the list */
u_int32_t cq_lock; /* lock status */ uint32_t cq_lock; /* lock status */
libnet_cq_t *current; /* current context */ libnet_cq_t *current; /* current context */
}; };
typedef struct _libnet_context_queue_descriptor libnet_cqd_t; typedef struct _libnet_context_queue_descriptor libnet_cqd_t;
#endif /* __LIBNET_STRUCTURES_H */ #endif /* __LIBNET_STRUCTURES_H */
/* EOF */ /* EOF */
 End of changes. 15 change blocks. 
31 lines changed or deleted 58 lines changed or added


 libnet-types.h   libnet-types.h 
skipping to change at line 35 skipping to change at line 35
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRI CT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRI CT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WA Y * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WA Y
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
*/ */
#ifndef __LIBNET_TYPES_H #ifndef __LIBNET_TYPES_H
#define __LIBNET_TYPES_H #define __LIBNET_TYPES_H
#if (__sun__ && __svr4__) /* libnet should be using the standard type names, so mapping standard
/* libnet should be using the standard type names, but in the short term * to non-standard should not be necessary. */
* define our non-standard type names in terms of the standard names.
*/
#include <inttypes.h>
typedef uint8_t u_int8_t;
typedef uint16_t u_int16_t;
typedef uint32_t u_int32_t;
typedef uint64_t u_int64_t;
#endif
#endif /* __LIBNET_TYPES_H */ #endif /* __LIBNET_TYPES_H */
/* EOF */ /* EOF */
 End of changes. 1 change blocks. 
10 lines changed or deleted 2 lines changed or added


 libnet.h   libnet.h 
skipping to change at line 62 skipping to change at line 62
* libnet, quick and simple packet assembly applications can be whipped up with * libnet, quick and simple packet assembly applications can be whipped up with
* little effort. With a bit more time, more complex programs can be writte n * little effort. With a bit more time, more complex programs can be writte n
* (Traceroute and ping were easily rewritten using libnet and * (Traceroute and ping were easily rewritten using libnet and
* <a href="www.tcpdump.org">libpcap</a>). * <a href="www.tcpdump.org">libpcap</a>).
*/ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define _GNU_SOURCE
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#if !defined(__WIN32__) #if !defined(__WIN32__)
#include <sys/ioctl.h> # include <sys/ioctl.h>
#endif /* __WIN32__ */ #endif /* __WIN32__ */
#if defined(HAVE_SYS_SOCKIO_H) && !defined(SIOCGIFADDR) #if defined(HAVE_SYS_SOCKIO_H) && !defined(SIOCGIFADDR)
#include <sys/sockio.h> # include <sys/sockio.h>
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <ctype.h> #include <ctype.h>
#if !defined(__WIN32__) #if !defined(__WIN32__)
#include <sys/socket.h> # include <sys/socket.h>
#include <netinet/in.h> # include <netinet/in.h>
#include <netinet/in_systm.h> # include <net/if.h>
#include <netinet/ip.h>
#include <net/if.h>
#else /* __WIN32__ */ #else /* __WIN32__ */
#if (__CYGWIN__) # if (__CYGWIN__)
#include <sys/socket.h> # include <sys/socket.h>
#endif # endif
#include <ws2tcpip.h> # include <ws2tcpip.h>
#include <windows.h> # include <windows.h>
#include <winsock2.h> # include <winsock2.h>
#include <win32/in_systm.h> # include <win32/in_systm.h>
#endif /* __WIN32__ */ #endif /* __WIN32__ */
#if !(__linux__) && !(__WIN32__) && !(__APPLE__) && !(__CYGWIN__) && !(__GN U__) #if !(__linux__) && !(__WIN32__) && !(__APPLE__) && !(__CYGWIN__) && !(__GN U__)
#include <netinet/ip_var.h>
#else /* __linux__ */ #else /* __linux__ */
#if (HAVE_NET_ETHERNET_H) # if (HAVE_NET_ETHERNET_H)
#include <net/ethernet.h> # include <net/ethernet.h>
#endif /* HAVE_NET_ETHERNET_H */ # endif /* HAVE_NET_ETHERNET_H */
#endif /* __linux__ */ #endif /* __linux__ */
#if !defined(__WIN32__) #if !defined(__WIN32__)
#include <netinet/tcp.h> # include <arpa/inet.h>
#include <netinet/udp.h> # include <sys/time.h>
#if (__linux__) && !(__GLIBC__) # include <netdb.h>
/* we get multiple definitions of IGMP_AGE_THRESHOLD if we include netinet
*/
#include <linux/igmp.h>
#else
#include <netinet/igmp.h>
#endif
#include <arpa/inet.h>
#include <sys/time.h>
#include <netdb.h>
#endif /* __WIN32__ */ #endif /* __WIN32__ */
#include <errno.h> #include <errno.h>
#include <stdarg.h> #include <stdarg.h>
#define LIBNET_VERSION "1.1.4" #define LIBNET_VERSION "1.1.5"
#define LIBNET_LIL_ENDIAN 1 #define LIBNET_LIL_ENDIAN 1
#include "./libnet/libnet-types.h" #include "./libnet/libnet-types.h"
#include "./libnet/libnet-macros.h" #include "./libnet/libnet-macros.h"
#include "./libnet/libnet-headers.h" #include "./libnet/libnet-headers.h"
#include "./libnet/libnet-structures.h" #include "./libnet/libnet-structures.h"
#include "./libnet/libnet-asn1.h" #include "./libnet/libnet-asn1.h"
#include "./libnet/libnet-functions.h" #include "./libnet/libnet-functions.h"
 End of changes. 16 change blocks. 
32 lines changed or deleted 26 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/