📄 libnet-functions.h
字号:
intlibnet_select_device( libnet_t * /* libnet context pointer */ );/* * libnet_open_link * * Function opens a link-layer interface for eventual packet injection. Used * internally by libnet. */intlibnet_open_link( libnet_t * /* libnet context pointer */ );/* * libnet_close_link * * Function closes a link interface. Used internally by libnet. */int /* 1 on success, -1 on failure */libnet_close_link( libnet_t * /* libnet context pointer */ );/* * libnet_get_ipaddr4 * * Function returns host-byte order IPv4 address. */u_int32_t /* 0 upon error, address upon success */libnet_get_ipaddr4( libnet_t * /* libnet context pointer */ );/* * libnet_get_ipaddr6 * * Function returns host-byte order IPv6 address. */struct libnet_in6_addrlibnet_get_ipaddr6( libnet_t * );/* * libnet_get_hwaddr * * Function returns a 6-byte ethernet address of the interface libnet is * currently using. */struct libnet_ether_addr * /* 0 upon error, address upon success */libnet_get_hwaddr( libnet_t * /* libnet context pointer */ );/* * libnet_do_checksum * * Function calculates the one's compliment checksum for a given protocol * over the given packet buffer. */int /* 1 on success, -1 on failure */libnet_do_checksum( libnet_t *, /* libnet context pointer */ u_int8_t *, /* pointer to the packet buffer */ int, /* protocol */ int /* packet size */ );/* * libnet_compute_crc * * Function computes the 32-bit CRC as per RFC 2083 over the given packet * buffer. */u_int32_t /* 32-bit CRC */libnet_compute_crc( u_int8_t *, /* pointer to the packet buffer */ u_int32_t /* packet size */ );/* * libnet_ip_check * * Function is a quick down and dirty IP checksum wrapper. */u_int16_t /* standard IP checksum */libnet_ip_check( u_int16_t *, /* pointer to the buffer to be summed */ int /* packet length */ );/* * libnet_in_cksum * * Function is the standard workhorse IP checksum routine. */int /* standard IP checksum */libnet_in_cksum( u_int16_t *, /* pointer to the buffer to be summed */ int /* packet length */ );/* * libnet_pblock_probe * * 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, * function will search the pblock list for the specified protocol block * and return a pointer to it. */libnet_pblock_t * /* the pblock or NULL on error */libnet_pblock_probe( libnet_t *, /* libnet context pointer */ libnet_ptag_t, /* ptag to look for, or 0 to create a new one */ u_int32_t, /* size of protocol unit to create (or resize to) */ u_int8_t /* type of protocol unit */ );/* * libnet_pblock_new * * Function creates the pblock list if l->protocol_blocks == NULL or appends * an entry to the doubly linked list. */libnet_pblock_t * /* the pblock or NULL on error */libnet_pblock_new( libnet_t *, /* libnet context pointer */ u_int32_t /* size of object (amount of memory to malloc) */ );/* * libnet_pblock_swap * * Function swaps two pblocks in memory. */intlibnet_pblock_swap( libnet_t *, /* libnet context pointer */ libnet_ptag_t, /* ptag 1 */ libnet_ptag_t /* ptag 2 */ ); /* * libnet_pblock_insert_before * * Function inserts a pblock into the doubly linked list. */intlibnet_pblock_insert_before( libnet_t *, /* libnet context pointer */ libnet_ptag_t, /* ptag 1 */ libnet_ptag_t /* ptag 2 */ );/* * libnet_pblock_delete * * Function removes a pblock from context */voidlibnet_pblock_delete( libnet_t *, /* libnet context pointer */ libnet_pblock_t * /* the pblock to remove */ );/* * libnet_pblock_update * * Function updates the pblock meta-inforation. Internally it updates the * ptag with a monotonically increasing variable kept in l. This way each * pblock has a succesively increasing ptag identifier. */libnet_ptag_t /* the pblock's updated ptag */libnet_pblock_update( libnet_t *, /* libnet context pointer */ libnet_pblock_t *, /* pointer of the pblock to update */ u_int32_t, /* header length */ u_int8_t /* type of pblock */ ); /* * libnet_pblock_find * * Function locates a given block by it's ptag. */libnet_pblock_t * /* the pblock or NULL on error */libnet_pblock_find( libnet_t *, /* libnet context pointer */ libnet_ptag_t /* ptag to locate */ );/* * libnet_pblock_append * * Function copies protocol block data over. */int /* 1 on success, -1 on failure */libnet_pblock_append( libnet_t *, /* libnet context pointer */ libnet_pblock_t *, /* pointer of the pblock to copy data to */ u_int8_t *, /* data to copy */ u_int32_t /* size of data to copy */ );/* * libnet_pblock_setflags * * Function sets pblock flags. */voidlibnet_pblock_setflags( libnet_pblock_t *, /* pointer of the pblock to set flags on */ u_int8_t /* flags byte */ );/* * libnet_pblock_p2p * * Function returns the protocol number for the protocol block type. If * the type is unknown, the function defaults to returning IPPROTO_IP. */int /* IP proto number */libnet_pblock_p2p( u_int8_t /* pblock type */ );/* * libnet_pblock_coalesce * * Function assembles the packet for subsequent writing. Function makes two * passes through the pblock list: * 1st & 2nd) determine total size of the packet for contiguous malloc * and copy over packet chunks * 3rd run) run through the original list and see which protocol blocks had * the checksum flag set (checksums usually need to be done over * an assembled packet so it's easier to do it here) */int /* 1 on success, -1 on failure */libnet_pblock_coalesce( libnet_t *, /* libnet context pointer */ u_int8_t **, /* resulting packet will be here */ u_int32_t * /* size of packet will be here */ );/* * __libnet_dump_context * * Function returns the contents of the libnet file context. Not meant for * the applications programer. */void__libnet_dump_context( libnet_t * /* libnet context pointer */ );/* * __libnet_dump_pblock * * Function returns the contents of each pblock in a given context. Not meant * for the applications programer. */void__libnet_dump_pblock( libnet_t * /* libnet context pointer */ );/* * __libnet_dump_pblock_type * * Function returns a canonical string referring to the pblock type. */int8_t *__libnet_dump_pblock_type( u_int8_t /* type */ );/* * __libnet_hex_dump * * Function dumps the contents of the supplied buffer to the supplied * stream pointer. Very useful for debugging. Will swap endianness based * disposition of mode variable. Use requires unwrapping the libnet file * context structure so it's hidden down here. If you find it, consider * yourself a trepid adventurer. */void__libnet_dump_hex( u_int8_t *, /* buffer to dump */ u_int32_t, /* length of buffer */ int, /* mode; to swap (1) or not to swap (0) */ FILE * /* stream pointer to dump to */ );/* * libnet_hex_aton * * hexidecimal strings of the format "##:##:##:## ... :##:##" to a uint8_t. * */u_int8_t *libnet_hex_aton( int8_t *, int * );/* * libnet_adv_cull_packet * * advanced interface, culls the packet from inside libnet, wraps * libnet_pblock_coalesce(). * */intlibnet_adv_cull_packet( libnet_t *, /* libnet context pointer */ u_int8_t **, /* resulting packet will be here */ u_int32_t * /* size of packet will be here */ );/* * libnet_adv_cull_header * * advanced interface, culls the header from referenced ptag from inside * libnet. * */intlibnet_adv_cull_header( libnet_t *, /* libnet context pointer */ libnet_ptag_t, /* ptag to yank */ u_int8_t **, /* resulting header will be here */ u_int32_t * /* size of header will be here */ );/* * libnet_adv_write_link * * advanced interface, writes a prebuilt frame to the wire * */intlibnet_adv_write_link( libnet_t *, /* libnet context pointer */ u_int8_t *, /* packet goes here */ u_int32_t /* size of packet goes here */ );/* * libnet_cq_add * * Function adds a context to the libnet context queue. */int libnet_cq_add( libnet_t *, /* libnet context pointer to add */ int8_t * /* label for the context */ );/* * libnet_cq_remove * * Function removes a context from the libnet context queue. * */intlibnet_cq_remove( libnet_t * /* libnet context pointer to remove */ );/* * libnet_cq_remove_by_label * * Function removes a libnet context from the queue, indexed by it's * canonical label. */ intlibnet_cq_remove_by_label( int8_t * /* label of context to remove */ ); /* * libnet_cq_getlabel * * Function returns the label (if any) associated with the conte
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -