libnet-functions.h   libnet-functions.h 
skipping to change at line 63 skipping to change at line 63
* IPv4 raw socket interface. The final argument, err_buf, should be a buff er * IPv4 raw socket interface. The final argument, err_buf, should be a buff er
* 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_API
libnet_t * libnet_t *
libnet_init(int injection_type, const 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
*/ */
LIBNET_API
void void
libnet_destroy(libnet_t *l); libnet_destroy(libnet_t *l);
/** /**
* Clears the current packet referenced and frees all pblocks. Should be * Clears the current packet referenced and frees all pblocks. Should be
* called when the programmer want to send a completely new packet of * called when the programmer want to send a completely new packet of
* a different type using the same context. * a different type using the same context.
* @param l pointer to a libnet context * @param l pointer to a libnet context
*/ */
LIBNET_API
void void
libnet_clear_packet(libnet_t *l); libnet_clear_packet(libnet_t *l);
/** /**
* Fills in a libnet_stats structure with packet injection statistics * Fills in a libnet_stats structure with packet injection statistics
* (packets written, bytes written, packet sending errors). * (packets written, bytes written, packet sending errors).
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param ls pointer to a libnet statistics structure * @param ls pointer to a libnet statistics structure
*/ */
LIBNET_API
void void
libnet_stats(libnet_t *l, struct libnet_stats *ls); libnet_stats(libnet_t *l, struct libnet_stats *ls);
/** /**
* Returns the FILENO of the file descriptor used for packet injection. * Returns the FILENO of the file descriptor used for packet injection.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return the file number of the file descriptor used for packet injection * @return the file number of the file descriptor used for packet injection
*/ */
LIBNET_API
int int
libnet_getfd(libnet_t *l); libnet_getfd(libnet_t *l);
/** /**
* Returns the canonical name of the device used for packet injection. * Returns the canonical name of the device used for packet injection.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return the canonical name of the device used for packet injection. Note * @return the canonical name of the device used for packet injection. Note
* it can be NULL without being an error. * it can be NULL without being an error.
*/ */
LIBNET_API
const char * const char *
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
*/ */
LIBNET_API
uint8_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
*/ */
LIBNET_API
uint32_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
*/ */
LIBNET_API
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
*/ */
LIBNET_API
uint32_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 * @retval 1 on success
* @retval -1 on failure
*/ */
LIBNET_API
int int
libnet_seed_prand(libnet_t *l); libnet_seed_prand(libnet_t *l);
/** /**
* Generates an unsigned psuedo-random value within the range specified by * Generates an unsigned psuedo-random value within the range specified by
* mod. * mod.
* 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 * @retval 1 on success
* @retval -1 on failure
*/ */
LIBNET_API
uint32_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
skipping to change at line 193 skipping to change at line 207
* will clear the checksum flag and no checksum will be computed prior to * will clear the checksum flag and no checksum will be computed prior to
* injection. This assumes that the programmer will assign a value (zero or * injection. This assumes that the programmer will assign a value (zero or
* otherwise) to the checksum field. Often times this is useful if a * otherwise) to the checksum field. Often times this is useful if a
* precomputed checksum or some other predefined value is going to be used. * precomputed checksum or some other predefined value is going to be used.
* Note that when libnet is initialized with LIBNET_RAW4, the IPv4 header * Note that when libnet is initialized with LIBNET_RAW4, the IPv4 header
* checksum will always be computed by the kernel prior to injection, * checksum will always be computed by the kernel prior to injection,
* regardless of what the programmer sets. * regardless of what the programmer sets.
* @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
* @param mode LIBNET_ON or LIBNET_OFF * @param mode LIBNET_ON or LIBNET_OFF
* @return 1 on success, -1 on failure * @retval 1 on success
* @retval -1 on failure
*/ */
LIBNET_API
int int
libnet_toggle_checksum(libnet_t *l, libnet_ptag_t ptag, int mode); libnet_toggle_checksum(libnet_t *l, libnet_ptag_t ptag, int mode);
/** /**
* Takes a network byte ordered IPv4 address and returns a pointer to eithe r a * Takes a network byte ordered IPv4 address and returns a pointer to eithe r a
* canonical DNS name (if it has one) or a string of dotted decimals. This may * canonical DNS name (if it has one) or a string of dotted decimals. This may
* 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
*/ */
LIBNET_API
char * char *
libnet_addr2name4(uint32_t in, uint8_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 address in network byte order
* @retval -1 (2^32 - 1) on error
*/ */
LIBNET_API
uint32_t uint32_t
libnet_name2addr4(libnet_t *l, char *host_name, uint8_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;
/** /**
* Check a libnet_in6_addr structure for identity with in6addr_error. * Check a libnet_in6_addr structure for identity with in6addr_error.
* @param addr address to check * @param addr address to check
* @return 1 if addr is in6addr_error, 0 if it is not * @retval 1 if addr is in6addr_error
* @retval 0 if it is not
*/ */
LIBNET_API
int int
libnet_in6_is_error(struct libnet_in6_addr addr); libnet_in6_is_error(struct libnet_in6_addr addr);
/** /**
* 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
*/ */
LIBNET_API
struct libnet_in6_addr struct libnet_in6_addr
libnet_name2addr6(libnet_t *l, const char *host_name, uint8_t use_name); libnet_name2addr6(libnet_t *l, const char *host_name, uint8_t use_name);
/** /**
* Should document this baby right here. * Should document this baby right here.
*/ */
LIBNET_API
void void
libnet_addr2name6_r(struct libnet_in6_addr addr, uint8_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
* 1. Upon failure, the function returns -1 and libnet_geterror() can tell you * 1. Upon failure, the function returns -1 and libnet_geterror() can tell you
* why. * why.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param plist if successful, will refer to the portlist, if not, NULL * @param plist if successful, will refer to the portlist, if not, NULL
* @param token_list string containing the port list primitive * @param token_list string containing the port list primitive
* @return 1 on success, -1 on failure * @retval 1 on success
* @retval -1 on failure
*/ */
LIBNET_API
int int
libnet_plist_chain_new(libnet_t *l, libnet_plist_t **plist, char *token_lis t); libnet_plist_chain_new(libnet_t *l, libnet_plist_t **plist, char *token_lis t);
/** /**
* Returns the next port list chain pair from the port list chain plist. bp ort * Returns the next port list chain pair from the port list chain plist. bp ort
* 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 * @retval 1 on success
* @retval 0 if empty
* @retval -1 on failure
*/ */
LIBNET_API
int int
libnet_plist_chain_next_pair(libnet_plist_t *plist, uint16_t *bport, libnet_plist_chain_next_pair(libnet_plist_t *plist, uint16_t *bport,
uint16_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 * @retval 1 on success
* @retval -1 on failure
*/ */
LIBNET_API
int int
libnet_plist_chain_dump(libnet_plist_t *plist); libnet_plist_chain_dump(libnet_plist_t *plist);
/** /**
* 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 string. This function uses strdup and is not re-entrant. It als o * list to string. This function uses strdup and is not re-entrant. It als o
* has a memory leak and should not really be used. * has a memory leak and should not really be used.
* @param plist previously created portlist * @param plist previously created portlist
* @return a printable string containing the port list contents on success * @return a printable string containing the port list contents on success
* NULL on error or NULL on error
*/ */
LIBNET_API
char * char *
libnet_plist_chain_dump_string(libnet_plist_t *plist); libnet_plist_chain_dump_string(libnet_plist_t *plist);
/** /**
* Frees all memory associated with port list chain. * Frees all memory associated with port list chain.
* @param plist previously created portlist * @param plist previously created portlist
* @return 1 on success, -1 on failure * @retval 1 on success
* @retval -1 on failure
*/ */
LIBNET_API
int int
libnet_plist_chain_free(libnet_plist_t *plist); libnet_plist_chain_free(libnet_plist_t *plist);
/** /**
* @section PBF Packet Builder Functions * @section PBF Packet Builder Functions
* *
* The core of libnet is the platform-independent packet-building * The core of libnet is the platform-independent packet-building
* functionality. These functions enable an application programmer to build * functionality. These functions enable an application programmer to build
* protocol headers (and data) in a simple and consistent manner without ha ving * protocol headers (and data) in a simple and consistent manner without ha ving
* to worry (too much) about low-level network odds and ends. Each * to worry (too much) about low-level network odds and ends. Each
skipping to change at line 408 skipping to change at line 440
* @param src pointer to a six byte destination ethernet address * @param src pointer to a six byte destination ethernet address
* @param tpi tag protocol identifier * @param tpi tag protocol identifier
* @param priority priority * @param priority priority
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_802_1q(const uint8_t *dst, const uint8_t *src, uint16_t tpi, libnet_build_802_1q(const uint8_t *dst, const uint8_t *src, uint16_t tpi,
uint8_t priority, uint8_t cfi, uint16_t vlan_id, uint16_t len_proto, uint8_t priority, uint8_t cfi, uint16_t vlan_id, uint16_t len_proto,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_802_1x(uint8_t eap_ver, uint8_t eap_type, uint16_t length, libnet_build_802_1x(uint8_t eap_ver, uint8_t eap_type, uint16_t length,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_802_2(uint8_t dsap, uint8_t ssap, uint8_t control, libnet_build_802_2(uint8_t dsap, uint8_t ssap, uint8_t control,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_802_2snap(uint8_t dsap, uint8_t ssap, uint8_t control, libnet_build_802_2snap(uint8_t dsap, uint8_t ssap, uint8_t control,
uint8_t *oui, uint16_t type, const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_802_3(const uint8_t *dst, const uint8_t *src, uint16_t len, libnet_build_802_3(const uint8_t *dst, const uint8_t *src, uint16_t len,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ethernet(const uint8_t *dst, const uint8_t *src, uint16_t type , libnet_build_ethernet(const uint8_t *dst, const uint8_t *src, uint16_t type ,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_autobuild_ethernet(const uint8_t *dst, uint16_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_fddi(uint8_t fc, const uint8_t *dst, const uint8_t *src, uint8 _t dsap, libnet_build_fddi(uint8_t fc, const uint8_t *dst, const uint8_t *src, uint8 _t dsap,
uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type, const uint8_t* payload, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type, const uint8_t* payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag); 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_autobuild_fddi(uint8_t fc, const uint8_t *dst, uint8_t dsap, uint8_t ssap, libnet_autobuild_fddi(uint8_t fc, const uint8_t *dst, uint8_t dsap, uint8_t ssap,
uint8_t cf, const uint8_t *oui, uint16_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
skipping to change at line 569 skipping to change at line 619
* @param pln protocol address length * @param pln protocol address length
* @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 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_arp(uint16_t hrd, uint16_t pro, uint8_t hln, uint8_t pln, libnet_build_arp(uint16_t hrd, uint16_t pro, uint8_t hln, uint8_t pln,
uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha, co nst uint8_t *tpa, uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha, co nst uint8_t *tpa,
const uint8_t* payload, uint32_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 );
/** /**
* 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_autobuild_arp(uint16_t op, const uint8_t *sha, const uint8_t *spa, c onst uint8_t *tha, libnet_autobuild_arp(uint16_t op, const uint8_t *sha, const uint8_t *spa, c onst uint8_t *tha,
uint8_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_tcp(uint16_t sp, uint16_t dp, uint32_t seq, uint32_t ack, libnet_build_tcp(uint16_t sp, uint16_t dp, uint32_t seq, uint32_t ack,
uint8_t control, uint16_t win, uint16_t sum, uint16_t urg, uint16_t len, uint8_t control, uint16_t win, uint16_t sum, uint16_t urg, uint16_t len,
const uint8_t* payload, uint32_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 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_tcp_options(const uint8_t *options, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_udp(uint16_t sp, uint16_t dp, uint16_t len, uint16_t sum, libnet_build_udp(uint16_t sp, uint16_t dp, uint16_t len, uint16_t sum,
const uint8_t* payload, uint32_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
skipping to change at line 666 skipping to change at line 726
* @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 value_s length of value argument * @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_cdp(uint8_t version, uint8_t ttl, uint16_t sum, uint16_t type, libnet_build_cdp(uint8_t version, uint8_t ttl, uint16_t sum, uint16_t type,
uint16_t value_s, const uint8_t *value, const uint8_t* payload, uint32_t pa yload_s, uint16_t value_s, const uint8_t *value, const uint8_t* payload, uint32_t pa 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv4_echo(uint8_t type, uint8_t code, uint16_t sum, libnet_build_icmpv4_echo(uint8_t type, uint8_t code, uint16_t sum,
uint16_t id, uint16_t seq, const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv4_mask(uint8_t type, uint8_t code, uint16_t sum, libnet_build_icmpv4_mask(uint8_t type, uint8_t code, uint16_t sum,
uint16_t id, uint16_t seq, uint32_t mask, const uint8_t* payload, uint16_t id, uint16_t seq, uint32_t mask, const uint8_t* payload,
uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv4_unreach(uint8_t type, uint8_t code, uint16_t sum, libnet_build_icmpv4_unreach(uint8_t type, uint8_t code, uint16_t sum,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv4_redirect(uint8_t type, uint8_t code, uint16_t sum, libnet_build_icmpv4_redirect(uint8_t type, uint8_t code, uint16_t sum,
uint32_t gateway, const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv4_timeexceed(uint8_t type, uint8_t code, uint16_t sum, libnet_build_icmpv4_timeexceed(uint8_t type, uint8_t code, uint16_t sum,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv4_timestamp(uint8_t type, uint8_t code, uint16_t sum, libnet_build_icmpv4_timestamp(uint8_t type, uint8_t code, uint16_t sum,
uint16_t id, uint16_t seq, uint32_t otime, uint32_t rtime, uint32_t 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 ); 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) * Builds an IP version 6 RFC 4443 Internet Control Message Protocol (ICMP)
* echo or echo reply header. * echo or echo reply header.
* @param type type of ICMP packet (should be ICMP6_ECHO_REQUEST or ICMP6_E CHO_REPLY) * @param type type of ICMP packet (should be ICMP6_ECHO_REQUEST or ICMP6_E CHO_REPLY)
* @param code code of ICMP packet (should be zero) * @param code code of ICMP packet (should be zero)
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param id echo id number * @param id echo id number
* @param seq echo sequence number * @param seq echo 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_build_icmpv6_echo(uint8_t type, uint8_t code, uint16_t libnet_ptag_t libnet_build_icmpv6_echo(uint8_t type, uint8_t code, uint16_t
sum, uint16_t id, uint16_t seq, uint8_t *payload, uint32_t payload_ s, sum, uint16_t id, uint16_t seq, 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 6 RFC 4443 Internet Control Message Protocol (ICMP) * 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 * unreachable header. The IP header that caused the error message should b e
* built by a previous call to libnet_build_ipv6(). * built by a previous call to libnet_build_ipv6().
* @param type type of ICMP packet (should be ICMP6_DST_UNREACH) * @param type type of ICMP packet (should be ICMP6_DST_UNREACH)
* @param code code of ICMP packet (should be one of the 5 ICMP6_DST_UNREAC H_* codes) * @param code code of ICMP packet (should be one of the 5 ICMP6_DST_UNREAC H_* codes)
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_icmpv6_unreach(uint8_t type, uint8_t code, uint16_t sum, libnet_build_icmpv6_unreach(uint8_t type, uint8_t code, uint16_t sum,
uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag); uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* Builds an IP version 6 RFC 2461 Internet Control Message Protocol (ICMP) * Builds an IP version 6 RFC 2461 Internet Control Message Protocol (ICMP)
* NDP neighbour solicitation header. Could be used with * NDP neighbour solicitation header. Could be used with
* libnet_build_icmpv6_ndp_opt() and ICMPV6_NDP_OPT_SLLA. * libnet_build_icmpv6_ndp_opt() and ICMPV6_NDP_OPT_SLLA.
* @param type type of ICMP packet (should be ND_NEIGHBOR_SOLICIT) * @param type type of ICMP packet (should be ND_NEIGHBOR_SOLICIT)
* @param code code of ICMP packet (should be zero) * @param code code of ICMP packet (should be zero)
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param target target ipv6 address * @param target target 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_build_icmpv6_ndp_nsol(uint8_t type, uint8_t code, libnet_ptag_t libnet_build_icmpv6_ndp_nsol(uint8_t type, uint8_t code,
uint16_t sum, struct libnet_in6_addr target, uint8_t *payload, uint 32_t uint16_t sum, struct libnet_in6_addr target, uint8_t *payload, uint 32_t
payload_s, libnet_t* l, libnet_ptag_t ptag); payload_s, libnet_t* l, libnet_ptag_t ptag);
/** /**
* Builds an IP version 6 RFC 2461 Internet Control Message Protocol (ICMP) * Builds an IP version 6 RFC 2461 Internet Control Message Protocol (ICMP)
* NDP neighbour advertisement header. Could be used with * NDP neighbour advertisement header. Could be used with
* libnet_build_icmpv6_ndp_opt() and ND_OPT_TARGET_LINKADDR. * libnet_build_icmpv6_ndp_opt() and ND_OPT_TARGET_LINKADDR.
* @param type type of ICMP packet (should be ND_NEIGHBOR_ADVERT) * @param type type of ICMP packet (should be ND_NEIGHBOR_ADVERT)
* @param code code of ICMP packet (should be zero) * @param code code of ICMP packet (should be zero)
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param flags should be a bitwise or of any applicable ND_NA_FLAG_* flags * @param flags should be a bitwise or of any applicable ND_NA_FLAG_* flags
* @param target target ipv6 address * @param target target 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_build_icmpv6_ndp_nadv(uint8_t type, uint8_t code, libnet_ptag_t libnet_build_icmpv6_ndp_nadv(uint8_t type, uint8_t code,
uint16_t sum, uint32_t flags, struct libnet_in6_addr target, uint8_ t uint16_t sum, uint32_t flags, struct libnet_in6_addr target, uint8_ t
*payload, uint32_t payload_s, libnet_t* l, libnet_ptag_t ptag); *payload, uint32_t payload_s, libnet_t* l, libnet_ptag_t ptag);
/** /**
* Builds ICMPv6 NDP options. * Builds ICMPv6 NDP options.
* @param type one of ND_OPT_* types * @param type one of ND_OPT_* types
* @param option option data * @param option option data
* @param option_s size of option data (will be padded out to an 8-byte bou ndary) * @param option_s size of option data (will be padded out to an 8-byte bou ndary)
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_build_icmpv6_ndp_opt(uint8_t type, uint8_t* option, libnet_ptag_t libnet_build_icmpv6_ndp_opt(uint8_t type, uint8_t* option,
uint32_t option_s, libnet_t* l, libnet_ptag_t ptag); uint32_t option_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 reserved (should be 0 for IGMPv1) * @param reserved (should be 0 for IGMPv1)
* @param sum checksum (0 for libnet to autofill) * @param sum checksum (0 for libnet to autofill)
* @param ip IPv4 address (in standard/network byte order) * @param ip IPv4 address (in standard/network byte order)
* @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
* @retval -1 on error
* *
* @note 'reserved' was previously called 'code', which it is not, in any I GMP version. * @note 'reserved' was previously called 'code', which it is not, in any I GMP version.
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_igmp(uint8_t type, uint8_t reserved, uint16_t sum, uint32_t ip , libnet_build_igmp(uint8_t type, uint8_t reserved, uint16_t sum, uint32_t ip ,
const uint8_t* payload, uint32_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 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
skipping to change at line 907 skipping to change at line 993
* @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
* @param prot upper layer protocol * @param prot upper layer protocol
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ipv4(uint16_t ip_len, uint8_t tos, uint16_t id, uint16_t frag, libnet_build_ipv4(uint16_t ip_len, uint8_t tos, uint16_t id, uint16_t frag,
uint8_t ttl, uint8_t prot, uint16_t sum, uint32_t src, uint32_t dst, uint8_t ttl, uint8_t prot, uint16_t sum, uint32_t src, uint32_t dst,
const uint8_t* payload, uint32_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 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).
* *
skipping to change at line 930 skipping to change at line 1018
* *
* 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ipv4_options(const uint8_t *options, uint32_t options_s, libne t_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_autobuild_ipv4(uint16_t len, uint8_t prot, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ipv6(uint8_t tc, uint32_t fl, uint16_t len, uint8_t nh, libnet_build_ipv6(uint8_t tc, uint32_t fl, uint16_t len, uint8_t nh,
uint8_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,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ipv6_frag(uint8_t nh, uint8_t reserved, uint16_t frag, libnet_build_ipv6_frag(uint8_t nh, uint8_t reserved, uint16_t frag,
uint32_t id, const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ipv6_routing(uint8_t nh, uint8_t len, uint8_t rtype, libnet_build_ipv6_routing(uint8_t nh, uint8_t len, uint8_t rtype,
uint8_t segments, const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ipv6_destopts(uint8_t nh, uint8_t len, const uint8_t* payload, libnet_build_ipv6_destopts(uint8_t nh, uint8_t len, const uint8_t* payload,
uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ipv6_hbhopts(uint8_t nh, uint8_t len, const uint8_t* payload, libnet_build_ipv6_hbhopts(uint8_t nh, uint8_t len, const uint8_t* payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag); uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
/** /**
* Autobuilds a version 6 RFC 2460 Internet Protocol (IP) header. The funct ion * Autobuilds a version 6 RFC 2460 Internet Protocol (IP) header. The funct ion
* is useful to build an IP header quickly when you do not need a granular * is useful to build an IP header quickly when you do not need a granular
* level of control. The function takes the same len, nh, and dst arguments * level of control. The function takes the same len, nh, and dst arguments
* as libnet_build_ipv4(). The function does not accept a ptag argument, bu t it * as libnet_build_ipv4(). The function does not accept a ptag argument, bu t it
* 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.
* This function requires libnet_get_ipaddr6(), which is not yet implemente d * This function requires libnet_get_ipaddr6(), which is not yet implemente d
* for Win32 platforms. * for Win32 platforms.
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_autobuild_ipv6(uint16_t len, uint8_t nh, struct libnet_in6_addr dst, 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_isl(uint8_t *dhost, uint8_t type, uint8_t user, libnet_build_isl(uint8_t *dhost, uint8_t type, uint8_t user,
uint8_t *shost, uint16_t len, const uint8_t *snap, uint16_t vid, uint8_t *shost, uint16_t len, const uint8_t *snap, uint16_t vid,
uint16_t portindex, uint16_t reserved, const uint8_t* payload, uint16_t portindex, uint16_t reserved, const uint8_t* payload,
uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ipsec_esp_hdr(uint32_t spi, uint32_t seq, uint32_t iv, libnet_build_ipsec_esp_hdr(uint32_t spi, uint32_t seq, uint32_t iv,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ipsec_esp_ftr(uint8_t len, uint8_t nh, int8_t *auth, libnet_build_ipsec_esp_ftr(uint8_t len, uint8_t nh, int8_t *auth,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ipsec_ah(uint8_t nh, uint8_t len, uint16_t res, libnet_build_ipsec_ah(uint8_t nh, uint8_t len, uint16_t res,
uint32_t spi, uint32_t seq, uint32_t auth, const uint8_t* payload, uint32_t spi, uint32_t seq, uint32_t auth, const uint8_t* payload,
uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_dnsv4(uint16_t h_len, uint16_t id, uint16_t flags, libnet_build_dnsv4(uint16_t h_len, uint16_t id, uint16_t flags,
uint16_t num_q, uint16_t num_anws_rr, uint16_t num_auth_rr, uint16_t num_q, uint16_t num_anws_rr, uint16_t num_auth_rr,
uint16_t num_addi_rr, const uint8_t* payload, uint32_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
skipping to change at line 1175 skipping to change at line 1289
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_rip(uint8_t cmd, uint8_t version, uint16_t rd, uint16_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, uint16_t rt, uint32_t addr, uint32_t mask, uint32_t next_hop,
uint32_t metric, const uint8_t* payload, uint32_t payload_s, libnet_t *l, uint32_t metric, const uint8_t* payload, uint32_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
skipping to change at line 1203 skipping to change at line 1319
* @param cflavor authentication credential type * @param cflavor authentication credential type
* @param clength credential length (should be 0) * @param clength credential length (should be 0)
* @param cdata opaque credential data (currently unused) * @param cdata opaque credential data (currently unused)
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_rpc_call(uint32_t rm, uint32_t xid, uint32_t prog_num, libnet_build_rpc_call(uint32_t rm, uint32_t xid, uint32_t prog_num,
uint32_t prog_vers, uint32_t procedure, uint32_t cflavor, uint32_t clength, uint32_t prog_vers, uint32_t procedure, uint32_t cflavor, uint32_t clength,
uint8_t *cdata, uint32_t vflavor, uint32_t vlength, const uint8_t *vdata, uint8_t *cdata, uint32_t vflavor, uint32_t vlength, const uint8_t *vdata,
const uint8_t* payload, uint32_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.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.
skipping to change at line 1231 skipping to change at line 1349
* @param bridge_id bridge id * @param bridge_id bridge id
* @param port_id port id * @param port_id port id
* @param message_age message age * @param message_age message age
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_stp_conf(uint16_t id, uint8_t version, uint8_t bpdu_type, libnet_build_stp_conf(uint16_t id, uint8_t version, uint8_t bpdu_type,
uint8_t flags, const uint8_t *root_id, uint32_t root_pc, const uint8_t *bri dge_id, uint8_t flags, const uint8_t *root_id, uint32_t root_pc, const uint8_t *bri dge_id,
uint16_t port_id, uint16_t message_age, uint16_t max_age, uint16_t port_id, uint16_t message_age, uint16_t max_age,
uint16_t hello_time, uint16_t f_delay, const uint8_t* payload, uint16_t hello_time, uint16_t f_delay, const uint8_t* payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag); 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_stp_tcn(uint16_t id, uint8_t version, uint8_t bpdu_type, libnet_build_stp_tcn(uint16_t id, uint8_t version, uint8_t bpdu_type,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst, const u int8_t *src, libnet_build_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst, const u int8_t *src,
uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type, uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_autobuild_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst, libnet_autobuild_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst,
uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_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.
skipping to change at line 1314 skipping to change at line 1440
* @param vrouter_id virtual router identification * @param vrouter_id virtual router identification
* @param priority priority (higher numbers indicate higher priority) * @param priority priority (higher numbers indicate higher priority)
* @param ip_count number of IPv4 addresses contained in this advertisement * @param ip_count number of IPv4 addresses contained in this advertisement
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_vrrp(uint8_t version, uint8_t type, uint8_t vrouter_id, libnet_build_vrrp(uint8_t version, uint8_t type, uint8_t vrouter_id,
uint8_t priority, uint8_t ip_count, uint8_t auth_type, uint8_t advert_int, uint8_t priority, uint8_t ip_count, uint8_t auth_type, uint8_t advert_int,
uint16_t sum, const uint8_t* payload, uint32_t payload_s, libnet_t *l, uint16_t sum, const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_mpls(uint32_t label, uint8_t experimental, uint8_t bos, libnet_build_mpls(uint32_t label, uint8_t experimental, uint8_t bos,
uint8_t ttl, const uint8_t* payload, uint32_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
skipping to change at line 1364 skipping to change at line 1494
* @param orig_ts_int original timestamp integer * @param orig_ts_int original timestamp integer
* @param orig_ts_frac original timestamp fraction * @param orig_ts_frac original timestamp fraction
* @param rec_ts_int receiver timestamp integer * @param rec_ts_int receiver timestamp integer
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ntp(uint8_t leap_indicator, uint8_t version, uint8_t mode, libnet_build_ntp(uint8_t leap_indicator, uint8_t version, uint8_t mode,
uint8_t stratum, uint8_t poll, uint8_t precision, uint16_t delay_int, uint8_t stratum, uint8_t poll, uint8_t precision, uint16_t delay_int,
uint16_t delay_frac, uint16_t dispersion_int, uint16_t dispersion_frac, uint16_t delay_frac, uint16_t dispersion_int, uint16_t dispersion_frac,
uint32_t reference_id, uint32_t ref_ts_int, uint32_t ref_ts_frac, uint32_t reference_id, uint32_t ref_ts_int, uint32_t ref_ts_frac,
uint32_t orig_ts_int, uint32_t orig_ts_frac, uint32_t rec_ts_int, uint32_t orig_ts_int, uint32_t orig_ts_frac, uint32_t rec_ts_int,
uint32_t rec_ts_frac, uint32_t xmt_ts_int, uint32_t xmt_ts_frac, uint32_t rec_ts_frac, uint32_t xmt_ts_int, uint32_t xmt_ts_frac,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2(uint16_t len, uint8_t type, uint32_t rtr_id, libnet_build_ospfv2(uint16_t len, uint8_t type, uint32_t rtr_id,
uint32_t area_id, uint16_t sum, uint16_t autype, const uint8_t* payload, uint32_t area_id, uint16_t sum, uint16_t autype, const uint8_t* payload,
uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_hello(uint32_t netmask, uint16_t interval, uint8_t opts , libnet_build_ospfv2_hello(uint32_t netmask, uint16_t interval, uint8_t opts ,
uint8_t priority, uint dead_int, uint32_t des_rtr, uint32_t bkup_rtr, uint8_t priority, uint32_t dead_int, uint32_t des_rtr, uint32_t bkup_rtr,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_dbd(uint16_t dgram_len, uint8_t opts, uint8_t type, libnet_build_ospfv2_dbd(uint16_t dgram_len, uint8_t opts, uint8_t type,
uint seqnum, const uint8_t* payload, uint32_t payload_s, libnet_t *l, uint32_t 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsr(uint type, uint lsid, uint32_t advrtr, libnet_build_ospfv2_lsr(uint32_t type, uint32_t lsid, uint32_t advrtr,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsu(uint num, const uint8_t* payload, uint32_t payload_ s, libnet_build_ospfv2_lsu(uint32_t num, const uint8_t* payload, uint32_t payl oad_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsa(uint16_t age, uint8_t opts, uint8_t type, libnet_build_ospfv2_lsa(uint16_t age, uint8_t opts, uint8_t type,
uint lsid, uint32_t advrtr, uint seqnum, uint16_t sum, uint16_t len, uint32_t lsid, uint32_t advrtr, uint32_t seqnum, uint16_t sum, uint16_t len ,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsa_rtr(uint16_t flags, uint16_t num, uint id, libnet_build_ospfv2_lsa_rtr(uint16_t flags, uint16_t num, uint32_t id,
uint data, uint8_t type, uint8_t tos, uint16_t metric, const uint8_t* paylo uint32_t data, uint8_t type, uint8_t tos, uint16_t metric, const uint8_t* p
ad, ayload,
uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsa_net(uint32_t nmask, uint rtrid, const uint8_t* payl oad, libnet_build_ospfv2_lsa_net(uint32_t nmask, uint32_t rtrid, const uint8_t* payload,
uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsa_sum(uint32_t nmask, uint metric, uint tos, libnet_build_ospfv2_lsa_sum(uint32_t nmask, uint32_t metric, uint32_t tos,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_ospfv2_lsa_as(uint32_t nmask, uint metric, uint32_t fwdaddr, libnet_build_ospfv2_lsa_as(uint32_t nmask, uint32_t metric, uint32_t fwdadd
uint tag, const uint8_t* payload, uint32_t payload_s, libnet_t *l, r,
uint32_t tag, const uint8_t* payload, uint32_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. This won't work for TCP or IP payload, they have special type s * of a loop. This won't work for TCP or IP payload, they have special type s
* (this is probably a bug). * (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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_data(const uint8_t* payload, uint32_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
skipping to change at line 1570 skipping to change at line 1724
* @param yip * @param yip
* @param sip * @param sip
* @param gip * @param gip
* @param chaddr client hardware address, length is hlen * @param chaddr client hardware address, length is hlen
* @param sname server host name, a null terminated string * @param sname server host name, a null terminated string
* @param file boot file name, a null terminated string * @param file boot file name, a null terminated 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_dhcpv4(uint8_t opcode, uint8_t htype, uint8_t hlen, libnet_build_dhcpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags, uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
uint32_t cip, uint32_t yip, uint32_t sip, uint32_t gip, const uint8_t *cha ddr, uint32_t cip, uint32_t yip, uint32_t sip, uint32_t gip, const uint8_t *cha ddr,
const char *sname, const char *file, const uint8_t* payload, uint32_t paylo ad_s, const char *sname, const char *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
skipping to change at line 1598 skipping to change at line 1754
* @param yip * @param yip
* @param sip * @param sip
* @param gip * @param gip
* @param chaddr client hardware address, length is hlen * @param chaddr client hardware address, length is hlen
* @param sname server host name, a null terminated string * @param sname server host name, a null terminated string
* @param file boot file name, a null terminated string * @param file boot file name, a null terminated 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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_bootpv4(uint8_t opcode, uint8_t htype, uint8_t hlen, libnet_build_bootpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags, uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
uint32_t cip, uint32_t yip, uint32_t sip, uint32_t gip, const uint8_t *cha ddr, uint32_t cip, uint32_t yip, uint32_t sip, uint32_t gip, const uint8_t *cha ddr,
const char *sname, const char *file, const uint8_t* payload, uint32_t paylo ad_s, const char *sname, const char *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().
*/ */
LIBNET_API
uint32_t uint32_t
libnet_getgre_length(uint16_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
skipping to change at line 1634 skipping to change at line 1794
* @param type which protocol is encapsulated (PPP, IP, ...) * @param type which protocol is encapsulated (PPP, IP, ...)
* @param sum checksum (0 for libnet to autofill). * @param sum checksum (0 for libnet to autofill).
* @param offset byte offset from the start of the routing field to the fir st byte of the SRE * @param offset byte offset from the start of the routing field to the fir st byte of the SRE
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_gre(uint16_t fv, uint16_t type, uint16_t sum, libnet_build_gre(uint16_t fv, uint16_t type, uint16_t sum,
uint16_t offset, uint32_t key, uint32_t seq, uint16_t len, uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
const uint8_t* payload, uint32_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).
skipping to change at line 1660 skipping to change at line 1822
* @param type which protocol is encapsulated (PPP, IP, ...) * @param type which protocol is encapsulated (PPP, IP, ...)
* @param sum checksum (0 for libnet to autofill). * @param sum checksum (0 for libnet to autofill).
* @param offset byte offset from the start of the routing field to the fir st byte of the SRE * @param offset byte offset from the start of the routing field to the fir st byte of the SRE
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_egre(uint16_t fv, uint16_t type, uint16_t sum, libnet_build_egre(uint16_t fv, uint16_t type, uint16_t sum,
uint16_t offset, uint32_t key, uint32_t seq, uint16_t len, uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_gre_sre(uint16_t af, uint8_t offset, uint8_t length, libnet_build_gre_sre(uint16_t af, uint8_t offset, uint8_t length,
uint8_t *routing, const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
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);
/** /**
* Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) header. The primary * Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) header. The primary
* function of a BGP speaking system is to exchange network reachability * function of a BGP speaking system is to exchange network reachability
* information with other BGP systems. This network reachability informatio n * information with other BGP systems. This network reachability informatio n
* includes information on the list of Autonomous Systems (ASs) that * includes information on the list of Autonomous Systems (ASs) that
* reachability information traverses. This information is sufficient to * reachability information traverses. This information is sufficient to
* construct a graph of AS connectivity from which routing loops may be pru ned * construct a graph of AS connectivity from which routing loops may be pru ned
skipping to change at line 1710 skipping to change at line 1878
* any other BGP header. For example, a BGP KEEPALIVE message may be built with * any other BGP header. For example, a BGP KEEPALIVE message may be built with
* only this function, while an error notification requires a subsequent ca ll * only this function, while an error notification requires a subsequent ca ll
* to libnet_build_bgp4_notification. * to libnet_build_bgp4_notification.
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_bgp4_header(uint8_t marker[LIBNET_BGP4_MARKER_SIZE], libnet_build_bgp4_header(uint8_t marker[LIBNET_BGP4_MARKER_SIZE],
uint16_t len, uint8_t type, const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_bgp4_open(uint8_t version, uint16_t src_as, uint16_t hold_time , libnet_build_bgp4_open(uint8_t version, uint16_t src_as, uint16_t hold_time ,
uint32_t bgp_id, uint8_t opt_len, const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_bgp4_update(uint16_t unfeasible_rt_len, const uint8_t *withdra wn_rt, libnet_build_bgp4_update(uint16_t unfeasible_rt_len, const uint8_t *withdra wn_rt,
uint16_t total_path_attr_len, const uint8_t *path_attributes, uint16_t info _len, uint16_t total_path_attr_len, const uint8_t *path_attributes, uint16_t info _len,
uint8_t *reachability_info, const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_bgp4_notification(uint8_t err_code, uint8_t err_subcode, libnet_build_bgp4_notification(uint8_t err_code, uint8_t err_subcode,
const uint8_t* payload, uint32_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
skipping to change at line 1794 skipping to change at line 1970
* @param time_usec residual microseconds * @param time_usec residual microseconds
* @param pid PID * @param pid PID
* @param uid UID * @param uid UID
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_sebek(uint32_t magic, uint16_t version, uint16_t type, libnet_build_sebek(uint32_t magic, uint16_t version, uint16_t type,
uint32_t counter, uint32_t time_sec, uint32_t time_usec, uint32_t pid, uint32_t counter, uint32_t time_sec, uint32_t time_usec, uint32_t pid,
uint32_t uid, uint32_t fd, uint8_t cmd[SEBEK_CMD_LENGTH], uint32_t length, uint32_t uid, uint32_t fd, uint8_t cmd[SEBEK_CMD_LENGTH], uint32_t length,
const uint8_t* payload, uint32_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 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
skipping to change at line 1819 skipping to change at line 1997
* @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
* @param group standby group * @param group standby group
* @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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_hsrp(uint8_t version, uint8_t opcode, uint8_t state, libnet_build_hsrp(uint8_t version, uint8_t opcode, uint8_t state,
uint8_t hello_time, uint8_t hold_time, uint8_t priority, uint8_t group, uint8_t hello_time, uint8_t hold_time, uint8_t priority, uint8_t group,
uint8_t reserved, uint8_t authdata[HSRP_AUTHDATA_LENGTH], uint32_t virtual_ ip, uint8_t reserved, uint8_t authdata[HSRP_AUTHDATA_LENGTH], uint32_t virtual_ ip,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_build_link(const uint8_t *dst, const uint8_t *src, const uint8_t *ou i, uint16_t type, libnet_build_link(const uint8_t *dst, const uint8_t *src, const uint8_t *ou i, uint16_t type,
const uint8_t* payload, uint32_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
* @retval -1 on error
*/ */
LIBNET_API
libnet_ptag_t libnet_ptag_t
libnet_autobuild_link(const uint8_t *dst, const uint8_t *oui, uint16_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
* libnet_stats(). * libnet_stats().
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return the number of bytes written, -1 on error * @return the number of bytes written
* @retval -1 on error
*/ */
LIBNET_API
int int
libnet_write(libnet_t *l); libnet_write(libnet_t *l);
/** /**
* 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 * @return a big endian IP address suitable for use in a libnet_build funct
ion or -1 ion
* @retval -1
*/ */
LIBNET_API
uint32_t uint32_t
libnet_get_ipaddr4(libnet_t *l); libnet_get_ipaddr4(libnet_t *l);
/** /**
* Returns the IPv6 address for the device libnet was initialized with. If * Returns the IPv6 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 in6addr_erro r, a * will attempt to find one. If the function fails and returns in6addr_erro r, a
* call to libnet_geterrror() will tell you why. * call to libnet_geterrror() will tell you why.
* This function is not yet implemented for Win32 platforms. * This function is not yet implemented for Win32 platforms.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return well, nothing yet * @retval in6addr_error on failure
*/ */
LIBNET_API
struct libnet_in6_addr struct libnet_in6_addr
libnet_get_ipaddr6(libnet_t *l); libnet_get_ipaddr6(libnet_t *l);
/** /**
* Returns the MAC address for the device libnet was initialized with. If * Returns the MAC address for the device libnet was initialized with. If
* libnet was initialized without a device the function will attempt to fin d * libnet was initialized without a device the function will attempt to fin d
* one. If the function fails and returns NULL a call to libnet_geterror() will * one. If the function fails and returns NULL a call to libnet_geterror() will
* tell you why. * tell you why.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return a pointer to the MAC address or NULL * @return a pointer to the MAC address or NULL
*/ */
LIBNET_API
struct libnet_ether_addr * struct libnet_ether_addr *
libnet_get_hwaddr(libnet_t *l); libnet_get_hwaddr(libnet_t *l);
/** /**
* 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
*/ */
LIBNET_API
uint8_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
*/ */
LIBNET_API
const char * const char *
libnet_version(void); libnet_version(void);
/** /**
* [Advanced Interface] * [Advanced Interface]
* Yanks a prebuilt, wire-ready packet from the given libnet context. If * Yanks a prebuilt, wire-ready packet from the given libnet context. If
* libnet was configured to do so (which it is by default) the packet will have * libnet was configured to do so (which it is by default) the packet will have
* all checksums written in. This function is part of the advanced interfac e * all checksums written in. This function is part of the advanced interfac e
* and is only available when libnet is initialized in advanced mode. It is * and is only available when libnet is initialized in advanced mode. It is
* 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 * @retval 1 on success
* @retval -1 on failure
*/ */
LIBNET_API
int int
libnet_adv_cull_packet(libnet_t *l, uint8_t **packet, uint32_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 * @retval 1 on success
* @retval -1 on failure
*/ */
LIBNET_API
int int
libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, uint8_t **header, libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, uint8_t **header,
uint32_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
* @retval -1 on failure
*/ */
LIBNET_API
int int
libnet_adv_write_link(libnet_t *l, const uint8_t *packet, uint32_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
* @retval -1 on failure
*/ */
LIBNET_API
int int
libnet_adv_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t pack et_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
*/ */
LIBNET_API
void void
libnet_adv_free_packet(libnet_t *l, uint8_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.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @param label a canonical name given to recognize the new context, no lon ger than LIBNET_LABEL_SIZE * @param label a canonical name given to recognize the new context, no lon ger than LIBNET_LABEL_SIZE
* @return 1 on success, -1 on failure * @retval 1 on success
* @retval -1 on failure
*/ */
int int
libnet_cq_add(libnet_t *l, char *label); libnet_cq_add(libnet_t *l, char *label);
/** /**
* [Context Queue] * [Context Queue]
* Removes a specified context from the libnet context queue by specifying the * Removes a specified context from the libnet context queue by specifying the
* libnet context pointer. Note the function will remove the specified cont ext * libnet context pointer. Note the function will remove the specified cont ext
* from the context queue and cleanup internal memory from the queue, it is up * from the context queue and cleanup internal memory from the queue, it is up
* to the application programmer to free the returned libnet context with a * to the application programmer to free the returned libnet context with a
* call to libnet_destroy(). Also, as it is not necessary to keep the libne t * call to libnet_destroy(). Also, as it is not necessary to keep the libne t
* context pointer when initially adding it to the context queue, most * context pointer when initially adding it to the context queue, most
* application programmers will prefer to refer to entries on the context * application programmers will prefer to refer to entries on the context
* queue by canonical name and would use libnet_cq_remove_by_label(). If th e * queue by canonical name and would use libnet_cq_remove_by_label(). If th e
* context queue is write locked, this function will fail. * context queue is write locked, this function will fail.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return the pointer to the removed libnet context, NULL on failure * @return the pointer to the removed libnet context
* @retval NULL on failure
*/ */
LIBNET_API
libnet_t * libnet_t *
libnet_cq_remove(libnet_t *l); libnet_cq_remove(libnet_t *l);
/** /**
* [Context Queue] * [Context Queue]
* Removes a specified context from the libnet context queue by specifying the * Removes a specified context from the libnet context queue by specifying the
* canonical name. Note the function will remove the specified context from * canonical name. Note the function will remove the specified context from
* the context queue and cleanup internal memory from the queue, it is up t o * the context queue and cleanup internal memory from the queue, it is up t o
* the application programmer to free the returned libnet context with a ca ll * the application programmer to free the returned libnet context with a ca ll
* to libnet_destroy(). If the context queue is write locked, this function * to libnet_destroy(). If the context queue is write locked, this function
* will fail. * will fail.
* @param label canonical name of the context to remove * @param label canonical name of the context to remove
* @return the pointer to the removed libnet context, NULL on failure * @return the pointer to the removed libnet context
* @retval NULL on failure
*/ */
LIBNET_API
libnet_t * libnet_t *
libnet_cq_remove_by_label(char *label); libnet_cq_remove_by_label(char *label);
/** /**
* [Context Queue] * [Context Queue]
* Returns the canonical label associated with the context. * Returns the canonical label associated with the context.
* @param l pointer to a libnet context * @param l pointer to a libnet context
* @return pointer to the libnet context's label * @return pointer to the libnet context's label
*/ */
LIBNET_API
const char * const char *
libnet_cq_getlabel(libnet_t *l); libnet_cq_getlabel(libnet_t *l);
/** /**
* [Context Queue] * [Context Queue]
* Locates a libnet context from the queue, indexed by a canonical label. * Locates a libnet context from the queue, indexed by a canonical label.
* @param label canonical label of the libnet context to retrieve * @param label canonical label of the libnet context to retrieve
* @return the expected libnet context, NULL on failure * @return the expected libnet context
* @retval NULL on failure
*/ */
LIBNET_API
libnet_t * libnet_t *
libnet_cq_find_by_label(char *label); libnet_cq_find_by_label(char *label);
/** /**
* [Context Queue] * [Context Queue]
* Destroys the entire context queue, calling libnet_destroy() on each * Destroys the entire context queue, calling libnet_destroy() on each
* member context. * member context.
*/ */
LIBNET_API
void void
libnet_cq_destroy(void); libnet_cq_destroy(void);
/** /**
* [Context Queue] * [Context Queue]
* Intiailizes the interator interface and set a write lock on the entire * Intiailizes the interator interface and set a write lock on the entire
* queue. This function is intended to be called just prior to interating * queue. This function is intended to be called just prior to interating
* through the entire list of contexts (with the probable intent of inject a * through the entire list of contexts (with the probable intent of inject a
* series of packets in rapid succession). This function is often used as * series of packets in rapid succession). This function is often used as
* per the following: * per the following:
skipping to change at line 2095 skipping to change at line 2304
* { * {
* ... * ...
* } * }
* *
* Much of the time, the application programmer will use the iterator as it is * Much of the time, the application programmer will use the iterator as it is
* written above; as such, libnet provides a macro to do exactly that, * written above; as such, libnet provides a macro to do exactly that,
* for_each_context_in_cq(l). Warning: do not call the iterator more than o nce * for_each_context_in_cq(l). Warning: do not call the iterator more than o nce
* in a single loop. * in a single loop.
* @return the head of the context queue * @return the head of the context queue
*/ */
LIBNET_API
libnet_t * libnet_t *
libnet_cq_head(void); libnet_cq_head(void);
/** /**
* [Context Queue] * [Context Queue]
* Check whether the iterator is at the last context in the queue. * Check whether the iterator is at the last context in the queue.
* @return 1 if at the end of the context queue, 0 otherwise * @retval 1 if at the end of the context queue
* @retval 0 otherwise
*/ */
LIBNET_API
int int
libnet_cq_last(void); libnet_cq_last(void);
/** /**
* [Context Queue] * [Context Queue]
* Get next context from the context queue. * Get next context from the context queue.
* @return the next context from the context queue * @return the next context from the context queue
*/ */
LIBNET_API
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
*/ */
LIBNET_API
uint32_t uint32_t
libnet_cq_size(void); libnet_cq_size(void);
/** /**
* [Context Queue] * [Context Queue]
*/ */
LIBNET_API
uint32_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
*/ */
LIBNET_API
void void
libnet_diag_dump_context(libnet_t *l); libnet_diag_dump_context(libnet_t *l);
/** /**
* [Diagnostic] * [Diagnostic]
* Prints the contents of every pblock. * Prints the contents of every pblock.
* @param l pointer to a libnet context * @param l pointer to a libnet context
*/ */
LIBNET_API
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 * @return a string representing the pblock type type
nknown value * @retval "unknown" for an unknown value
*/ */
LIBNET_API
char * char *
libnet_diag_dump_pblock_type(uint8_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
skipping to change at line 2172 skipping to change at line 2391
* 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(const uint8_t *packet, uint32_t len, int swap, FILE *s tream); libnet_diag_dump_hex(const uint8_t *packet, uint32_t len, int swap, FILE *s tream);
/* /*
* [Internal] * [Internal]
*/ */
LIBNET_API
int int
libnet_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t size); libnet_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t size);
/* /*
* [Internal] * [Internal]
*/ */
LIBNET_API
int int
libnet_write_raw_ipv6(libnet_t *l, const uint8_t *packet, uint32_t size); libnet_write_raw_ipv6(libnet_t *l, const uint8_t *packet, uint32_t size);
/* /*
* [Internal] * [Internal]
*/ */
LIBNET_API
int int
libnet_write_link(libnet_t *l, const uint8_t *packet, uint32_t size); libnet_write_link(libnet_t *l, const uint8_t *packet, uint32_t size);
#if ((__WIN32__) && !(__CYGWIN__))
/*
* [Internal]
*/
SOCKET
libnet_open_raw4(libnet_t *l);
#else
/* /*
* [Internal] * [Internal]
*/ */
int int
libnet_open_raw4(libnet_t *l); libnet_open_raw4(libnet_t *l);
#endif
/* /*
* [Internal] * [Internal]
*/ */
LIBNET_API
int int
libnet_close_raw4(libnet_t *l); libnet_close_raw4(libnet_t *l);
/* /*
* [Internal] * [Internal]
*/ */
int int
libnet_open_raw6(libnet_t *l); libnet_open_raw6(libnet_t *l);
/* /*
skipping to change at line 2257 skipping to change at line 2472
* *
* IP (TCP, UDP, IGMP, ICMP, etc...) checksums usually need information fro m * IP (TCP, UDP, IGMP, ICMP, etc...) checksums usually need information fro m
* the IP header to construct the "pseudo header", this function takes a * 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 * 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 * 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 * altogether), and the protocol number for the protocol that is to be
* checksummed. * checksummed.
* *
* Finding that protocol requires that the IP header be well-formed... so t his * 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 * won't work well for invalid packets. But then, what is the valid checksu m
* for a valid packet, anyhow? * for a invalid packet, anyhow?
* *
* This doesn't work well for non-inet checksums, sorry, that's an original design * 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 * flaw. pblock_t needs a pointer in it, to a packet assembly function that can be
* called at runtime to do assembly and checksumming. * called at runtime to do assembly and checksumming.
*/ */
LIBNET_API
int int
libnet_inet_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len, const uint8_t *beg, const uint8_t * end); libnet_inet_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len, const uint8_t *beg, const uint8_t * end);
/* /*
* [Internal] * [Internal]
*/ */
LIBNET_API
uint32_t uint32_t
libnet_compute_crc(uint8_t *buf, uint32_t len); libnet_compute_crc(uint8_t *buf, uint32_t len);
/* /*
* [Internal] * [Internal]
*/ */
LIBNET_API
uint16_t uint16_t
libnet_ip_check(uint16_t *addr, int len); libnet_ip_check(uint16_t *addr, int len);
/* /*
* [Internal] * [Internal]
*/ */
LIBNET_API
int int
libnet_in_cksum(uint16_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_API
libnet_pblock_t * libnet_pblock_t *
libnet_pblock_probe(libnet_t *l, libnet_ptag_t ptag, uint32_t b_len, libnet_pblock_probe(libnet_t *l, libnet_ptag_t ptag, uint32_t b_len,
uint8_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_API
libnet_pblock_t * libnet_pblock_t *
libnet_pblock_new(libnet_t *l, uint32_t b_len); libnet_pblock_new(libnet_t *l, uint32_t b_len);
/* /*
* [Internal] * [Internal]
* Function swaps two pblocks in memory. * Function swaps two pblocks in memory.
*/ */
LIBNET_API
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 ptag2 before ptag1 in the doubly linked list. * Function inserts ptag2 before ptag1 in the doubly linked list.
*/ */
LIBNET_API
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
*/ */
LIBNET_API
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_API
libnet_ptag_t libnet_ptag_t
libnet_pblock_update(libnet_t *l, libnet_pblock_t *p, uint32_t h, uint8_t t ype); libnet_pblock_update(libnet_t *l, libnet_pblock_t *p, uint32_t h, uint8_t t ype);
/* /*
* [Internal] * [Internal]
* Function locates a given block by it's ptag. * Function locates a given block by it's ptag.
*/ */
LIBNET_API
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.
*/ */
LIBNET_API
int int
libnet_pblock_append(libnet_t *l, libnet_pblock_t *p, const void *buf, uint 32_t len); libnet_pblock_append(libnet_t *l, libnet_pblock_t *p, const void *buf, uint 32_t len);
/* /*
* [Internal] * [Internal]
* Function sets pblock flags. * Function sets pblock flags.
*/ */
LIBNET_API
void void
libnet_pblock_setflags(libnet_pblock_t *p, uint8_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.
*/ */
LIBNET_API
int int
libnet_pblock_p2p(uint8_t type); libnet_pblock_p2p(uint8_t type);
/* /*
* [Internal] * [Internal]
* Function assembles the protocol blocks into a packet, checksums are * Function assembles the protocol blocks into a packet, checksums are
* calculated if that was requested. * calculated if that was requested.
*/ */
LIBNET_API
int int
libnet_pblock_coalesce(libnet_t *l, uint8_t **packet, uint32_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
 End of changes. 253 change blocks. 
124 lines changed or deleted 355 lines changed or added


 libnet-headers.h   libnet-headers.h 
skipping to change at line 1357 skipping to change at line 1357
/* /*
* 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
{ {
uint16_t ospf_auth_null; /* NULL */ uint16_t ospf_auth_null; /* NULL */
uint8_t ospf_auth_keyid; /* authentication key ID */ uint8_t ospf_auth_keyid; /* authentication key ID */
uint8_t ospf_auth_len; /* auth data length */ uint8_t ospf_auth_len; /* auth data length */
uint ospf_auth_seq; /* cryptographic sequence number */ uint32_t 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 */
uint16_t hello_intrvl; /* num of seconds between routers last pac ket */ uint16_t hello_intrvl; /* num of seconds between routers last pac ket */
uint8_t hello_opts; /* Options for HELLO packets (look above) */ uint8_t hello_opts; /* Options for HELLO packets (look above) */
uint8_t hello_rtr_pri; /* router's priority (if 0, can't be backu p) */ uint8_t hello_rtr_pri; /* router's priority (if 0, can't be backu p) */
uint hello_dead_intvl; /* # of secs a router is silent till deemed down */ uint32_t hello_dead_intvl; /* # of secs a router is silent till dee med 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
{ {
uint16_t dbd_mtu_len; /* max length of IP dgram that this 'if' can u se */ uint16_t dbd_mtu_len; /* max length of IP dgram that this 'if' can u se */
uint8_t dbd_opts; /* DBD packet options (from above) */ uint8_t dbd_opts; /* DBD packet options (from above) */
uint8_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 */
uint dbd_seq; /* DBD sequence number */ uint32_t 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
{ {
uint lsr_type; /* type of LS being requested */ uint32_t lsr_type; /* type of LS being requested */
uint lsr_lsid; /* link state ID */ uint32_t 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
{ {
uint lsu_num; /* number of LSAs that will be broadcasted * / uint32_t lsu_num; /* number of LSAs that will be broadcast ed */
}; };
/* /*
* Link State Acknowledgement header. * Link State Acknowledgement header.
*/ */
struct libnet_lsa_hdr struct libnet_lsa_hdr
{ {
uint16_t lsa_age; /* time in seconds since the LSA was originate d */ uint16_t lsa_age; /* time in seconds since the LSA was originate d */
uint8_t lsa_opts; /* look above for OPTS_* */ uint8_t lsa_opts; /* look above for OPTS_* */
uint8_t lsa_type; /* look below for LS_TYPE_* */ uint8_t lsa_type; /* look below for LS_TYPE_* */
uint lsa_id; /* link State ID */ uint32_t 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 */
uint lsa_seq; /* LSA sequence number to detect old/bad ones */ uint32_t lsa_seq; /* LSA sequence number to detect old/bad one s */
uint16_t lsa_sum; /* "Fletcher Checksum" of all fields minus age * / uint16_t lsa_sum; /* "Fletcher Checksum" of all fields minus age * /
uint16_t lsa_len; /* length in bytes including the 20 byte heade r */ uint16_t lsa_len; /* length in bytes including the 20 byte heade r */
}; };
/* /*
* 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
{ {
uint16_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 */
uint16_t rtr_num; /* number of links within that packet */ uint16_t rtr_num; /* number of links within that packet */
uint rtr_link_id; /* describes link_data (look below) */ uint32_t 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 */
uint rtr_link_data; /* Depending on link_id, info is here */ uint32_t rtr_link_data; /* Depending on link_id, info is here */
uint8_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" */
uint8_t rtr_tos_num; /* number of different TOS metrics for this li nk */ uint8_t rtr_tos_num; /* number of different TOS metrics for this li nk */
uint16_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 */
uint net_rtr_id; /* ID of router attached to that network */ uint32_t 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 */
uint sum_metric; /* Same as in rtr_lsa (&0xfff to use last 24 uint32_t sum_metric; /* Same as in rtr_lsa (&0xfff to use las
bit */ t 24bit */
uint sum_tos_metric; /* first 8bits are TOS, 24bits are TOS Metri uint32_t sum_tos_metric; /* first 8bits are TOS, 24bits are TOS M
c */ etric */
}; };
/* /*
* 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 */
uint as_metric; /* May have to set E bit in first 8bits */ uint32_t 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 */
uint as_rte_tag; /* External route tag */ uint32_t 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
{ {
uint8_t rip_cmd; /* RIP command */ uint8_t rip_cmd; /* RIP command */
 End of changes. 13 change blocks. 
17 lines changed or deleted 17 lines changed or added


 libnet.h   libnet.h 
skipping to change at line 91 skipping to change at line 91
#if !defined(__WIN32__) #if !defined(__WIN32__)
# include <sys/socket.h> # include <sys/socket.h>
# include <net/if.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>
#endif /* __WIN32__ */ #endif /* __WIN32__ */
#if !(__linux__) && !(__WIN32__) && !(__APPLE__) && !(__CYGWIN__) && !(__GN U__) #if !(__linux__) && !(__WIN32__) && !(__APPLE__) && !(__CYGWIN__) && !(__GN U__)
#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 <arpa/inet.h> # include <arpa/inet.h>
# include <sys/time.h> # include <sys/time.h>
# include <netdb.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.6" #define LIBNET_VERSION "1.2-rc3"
#define LIBNET_LIL_ENDIAN 1 #define LIBNET_LIL_ENDIAN 1
#ifndef LIBNET_API
#define LIBNET_API
#endif
#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"
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
 End of changes. 3 change blocks. 
2 lines changed or deleted 5 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/