⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libnet-functions.h

📁 Libnet is a generic networking API that provides access to several protocols. It is not designed as
💻 H
📖 第 1 页 / 共 4 页
字号:
libnet_write(
    libnet_t *          /* libnet context pointer */
    );


/*
 *  libnet_write_ipv4
 *
 *  Function writes an ipv4 packet through the raw socket interface.  Used
 *  internally by libnet.
 */
int                     /* number of bytes written if successful, -1 on error */
libnet_write_raw_ipv4(
    libnet_t *,         /* libnet context pointer */
    u_char *,           /* pointer to the assembled packet */
    u_long              /* size of the assembled packet */
    );


/*
 *  libnet_write_ipv6
 *
 *  Function writes an ipv6 packet through the raw socket interface.  Used
 *  internally by libnet.
 */
int                     /* number of bytes written if successful, -1 on error */
libnet_write_raw_ipv6(
    libnet_t *,         /* libnet context pointer */
    u_char *,           /* pointer to the assembled packet */
    u_long              /* size of the assembled packet */
    );


/*
 *  libnet_write_link
 *
 *  Function writes a packet through the link-layer interface.  Used
 *  internally by libnet.
 */
int                     /* number of bytes written if successful, -1 on error */
libnet_write_link(
    libnet_t *,         /* libnet context pointer */
    u_char *,           /* pointer to the assembled packet */
    u_long              /* size of the assembled packet */
    );


/*
 *  libnet_open_raw4
 *
 *  Function opens a IPv4 raw socket and sets IP_HDRINCL socket option.
 *  Under linux it also sets SO_BROADCAST in order to write broadcast packets.
 */
int                     /* opened file desciptor, or -1 on error */
libnet_open_raw4(
    libnet_t *          /* libnet context pointer */
    );


/*
 *  libnet_close_raw4
 *
 *  Function closes the IPv4 raw socket.
 */
int                     /* 1 upon success, or -1 on error */
libnet_close_raw4(
    libnet_t *          /* libnet context pointer */
    );


/*  
 *  libnet_open_raw6
 * 
 *  Function opens a IPv6 raw socket and sets IP_HDRINCL socket option.
 *  Under linux it also sets SO_BROADCAST in order to write broadcast packets.
 */
int                     /* opened file desciptor, or -1 on error */
libnet_open_raw6(
    libnet_t *          /* libnet context pointer */
    );   
       
       
/*
 *  libnet_close_raw6
 *
 *  Function closes the IPv6 raw socket.
 */
int                     /* 1 upon success, or -1 on error */
libnet_close_raw6(
    libnet_t *          /* libnet context pointer */
    );


/*
 *  libnet_select_device
 *
 *  Function finds a device for use with libnet's link-layer interface.
 */
int
libnet_select_device(
    libnet_t *          /* libnet context pointer */
    );


/*
 *  libnet_open_link
 *
 *  Function opens a link-layer interface for eventual packet injection.  Used
 *  internally by libnet.
 */
int
libnet_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_long                  /* 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_addr
libnet_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_char *,           /* 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_long                  /* 32-bit CRC */
libnet_compute_crc(
    u_char *,           /* pointer to the packet buffer */
    u_long              /* packet size */
    );


/*
 *  libnet_ip_check
 *
 *  Function is a quick down and dirty IP checksum wrapper.
 */
u_short                 /* standard IP checksum */
libnet_ip_check(
    u_short *,          /* 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_short *,          /* 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_long,             /* size of protocol unit to create (or resize to) */
    u_char              /* 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_long              /* size of object (amount of memory to malloc) */
    );


/*
 *  libnet_pblock_swap
 *
 *  Function swaps two pblocks in memory.
 */
int
libnet_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.
 */
int
libnet_pblock_insert_before(
    libnet_t *,         /* libnet context pointer */
    libnet_ptag_t,      /* ptag 1 */
    libnet_ptag_t       /* ptag 2 */
    );

/*
 *  libnet_pblock_free
 *  
 *  Function frees the memory associated with p.
 */
void
libnet_pblock_free(
    libnet_pblock_t *    /* the pblock to destroy */
    );


/*
 *  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_short,            /* header length */
    u_char              /* 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_char *,           /* data to copy */
    u_long              /* size of data to copy */
    );


/*
 *  libnet_pblock_setflags
 *
 *  Function sets pblock flags.
 */
void
libnet_pblock_setflags(
    libnet_pblock_t *,  /* pointer of the pblock to set flags on */
    u_char              /* 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_char              /* 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_char **,          /* resulting packet will be here */
    u_long *            /* size of packet will be here */
    );


/*
 *  __libnet_context_dump
 *
 *  Function returns the contents of the libnet file context.  Not meant for
 *  the applications programer.
 */
void
__libnet_context_dump(
    libnet_t *          /* libnet context pointer */
    );


/*
 *  __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_hex_dump(
    u_char *,           /* buffer to dump */
    u_long,             /* 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 uchar.
 *
 */
u_char *
libnet_hex_aton(
    char *,
    int *
    );

/*
 *  libnet_adv_cull_packet
 *
 *  advanced interface, culls the packet from inside libnet, wraps
 *  libnet_pblock_coalesce().
 *
 */
int
libnet_adv_cull_packet(
    libnet_t *,         /* libnet context pointer */
    u_char **,          /* resulting packet will be here */
    u_long *            /* size of packet will be here */
    );

/*
 *  libnet_adv_write_link
 *
 *  advanced interface, writes a prebuilt frame to the wire
 *
 */
int
libnet_adv_write_link(
    libnet_t *,         /* libnet context pointer */
    u_char *,           /* packet goes here */
    u_long              /* size of packet goes here */
    );

#endif  /* __LIBNET_FUNCTIONS_H */

/* EOF */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -