| libnet-functions.h(3) | Library Functions Manual | libnet-functions.h(3) |
libnet-functions.h - libnet exported function prototypes
LIBNET_API libnet_t * libnet_init (int injection_type,
const char *device, char *err_buf)
LIBNET_API void libnet_destroy (libnet_t *l)
LIBNET_API void libnet_clear_packet (libnet_t *l)
LIBNET_API void libnet_stats (libnet_t *l, struct libnet_stats *ls)
LIBNET_API int libnet_getfd (libnet_t *l)
LIBNET_API const char * libnet_getdevice (libnet_t *l)
LIBNET_API uint8_t * libnet_getpbuf (libnet_t *l, libnet_ptag_t ptag)
LIBNET_API uint32_t libnet_getpbuf_size (libnet_t *l, libnet_ptag_t
ptag)
LIBNET_API char * libnet_geterror (libnet_t *l)
LIBNET_API uint32_t libnet_getpacket_size (libnet_t *l)
LIBNET_API int libnet_seed_prand (libnet_t *l)
LIBNET_API uint32_t libnet_get_prand (int mod)
LIBNET_API int libnet_toggle_checksum (libnet_t *l, libnet_ptag_t ptag,
int mode)
LIBNET_API char * libnet_addr2name4 (uint32_t in, uint8_t use_name)
LIBNET_API uint32_t libnet_name2addr4 (libnet_t *l, const char
*host_name, uint8_t use_name)
LIBNET_API int libnet_in6_is_error (struct libnet_in6_addr addr)
LIBNET_API struct libnet_in6_addr libnet_name2addr6 (libnet_t *l, const
char *host_name, uint8_t use_name)
LIBNET_API void libnet_addr2name6_r (struct libnet_in6_addr addr,
uint8_t use_name, char *host_name, int host_name_len)
LIBNET_API int libnet_plist_chain_new (libnet_t *l, libnet_plist_t
**plist, char *token_list)
LIBNET_API int libnet_plist_chain_next_pair (libnet_plist_t *plist,
uint16_t *bport, uint16_t *eport)
LIBNET_API int libnet_plist_chain_dump (libnet_plist_t *plist)
LIBNET_API char * libnet_plist_chain_dump_string (libnet_plist_t
*plist)
LIBNET_API int libnet_plist_chain_free (libnet_plist_t *plist)
LIBNET_API libnet_ptag_t 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, const uint8_t *payload, uint32_t payload_s, libnet_t *l,
libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t libnet_autobuild_ethernet (const uint8_t *dst,
uint16_t type, libnet_t *l)
LIBNET_API libnet_ptag_t 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, uint32_t payload_s,
libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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, const uint8_t *tpa, const uint8_t *payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_autobuild_arp (uint16_t op, const
uint8_t *sha, const uint8_t *spa, const uint8_t *tha, const uint8_t *tpa,
libnet_t *l)
LIBNET_API libnet_ptag_t 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, const uint8_t *payload, uint32_t payload_s,
libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_tcp_options (const uint8_t
*options, uint32_t options_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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 payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_lldp_chassis (const uint8_t
subtype, const uint8_t *value, const uint8_t value_s, libnet_t *l,
libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_lldp_port (const uint8_t subtype,
const uint8_t *value, const uint8_t value_s, libnet_t *l, libnet_ptag_t
ptag)
LIBNET_API libnet_ptag_t libnet_build_lldp_ttl (const uint16_t ttl,
libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_lldp_end (libnet_t *l,
libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_lldp_org_spec (const uint8_t
*value, const uint16_t value_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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, const uint8_t *payload, uint32_t payload_s,
libnet_t *l, libnet_ptag_t ptag)
LIBNET_API 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, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API 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,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API 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 *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API 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)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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, const uint8_t *payload, uint32_t payload_s,
libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_ipv4_options (const uint8_t
*options, uint32_t options_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_autobuild_ipv4 (uint16_t len, uint8_t
prot, uint32_t dst, libnet_t *l)
LIBNET_API libnet_ptag_t 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, const uint8_t *payload, uint32_t payload_s, libnet_t
*l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t libnet_autobuild_ipv6 (uint16_t len, uint8_t
nh, struct libnet_in6_addr dst, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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, uint16_t portindex, uint16_t reserved, const uint8_t *payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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 payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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_addi_rr, const uint8_t *payload, uint32_t
payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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, uint32_t metric, const uint8_t *payload, uint32_t
payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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, 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)
LIBNET_API libnet_ptag_t 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 *bridge_id, uint16_t port_id, uint16_t message_age,
uint16_t max_age, uint16_t hello_time, uint16_t f_delay, const uint8_t
*payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t libnet_build_udld_hdr (uint8_t version,
uint8_t opcode, uint8_t flags, uint8_t checksum, const uint8_t *payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_udld_device_id (const uint8_t
*value, const uint8_t value_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_udld_port_id (const uint8_t
*value, const uint8_t value_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_udld_echo (const uint8_t *value,
const uint8_t value_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_udld_message_interval (const
uint8_t *value, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_udld_timeout_interval (const
uint8_t *value, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_udld_device_name (const uint8_t
*value, const uint8_t value_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_udld_sequence_number (const
uint8_t *value, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_token_ring (uint8_t ac, 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,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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, libnet_t *l)
LIBNET_API libnet_ptag_t 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, uint16_t sum, const uint8_t *payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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, 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 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,
const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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 payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_ospfv2_hello (uint32_t netmask,
uint16_t interval, uint8_t opts, 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)
libnet_ptag_t libnet_build_ospfv2_hello_neighbor (uint32_t netmask,
uint16_t interval, uint8_t opts, uint8_t priority, uint32_t dead_int,
uint32_t des_rtr, uint32_t bkup_rtr, uint32_t neighbor, const uint8_t
*payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_ospfv2_dbd (uint16_t dgram_len,
uint8_t opts, uint8_t type, uint32_t seqnum, const uint8_t *payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsu (uint32_t num, const
uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa (uint16_t age, uint8_t
opts, uint8_t type, 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)
LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa_rtr (uint16_t flags,
uint16_t num, uint32_t id, uint32_t data, uint8_t type, uint8_t tos,
uint16_t metric, const uint8_t *payload, uint32_t payload_s, libnet_t *l,
libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa_as (uint32_t nmask,
uint32_t metric, uint32_t fwdaddr, uint32_t tag, const uint8_t *payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_data (const uint8_t *payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_dhcpv4 (uint8_t opcode, uint8_t
htype, uint8_t hlen, 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
*chaddr, const char *sname, const char *file, const uint8_t *payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_bootpv4 (uint8_t opcode, uint8_t
htype, uint8_t hlen, 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
*chaddr, const char *sname, const char *file, const uint8_t *payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API uint32_t libnet_getgre_length (uint16_t fv)
LIBNET_API libnet_ptag_t libnet_build_gre (uint16_t fv, uint16_t type,
uint16_t sum, 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)
LIBNET_API libnet_ptag_t libnet_build_egre (uint16_t fv, uint16_t type,
uint16_t sum, 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)
LIBNET_API libnet_ptag_t 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, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_gre_last_sre (libnet_t *l,
libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_build_bgp4_update (uint16_t
unfeasible_rt_len, const uint8_t *withdrawn_rt, 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,
libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t 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)
LIBNET_API libnet_ptag_t 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 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)
LIBNET_API libnet_ptag_t 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 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)
LIBNET_API libnet_ptag_t libnet_build_link (const uint8_t *dst, const
uint8_t *src, const uint8_t *oui, uint16_t type, const uint8_t *payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
LIBNET_API libnet_ptag_t libnet_autobuild_link (const uint8_t *dst,
const uint8_t *oui, uint16_t type, libnet_t *l)
LIBNET_API int libnet_write (libnet_t *l)
LIBNET_API uint32_t libnet_get_ipaddr4 (libnet_t *l)
LIBNET_API struct libnet_in6_addr libnet_get_ipaddr6 (libnet_t *l)
LIBNET_API struct libnet_ether_addr * libnet_get_hwaddr (libnet_t *l)
LIBNET_API uint8_t * libnet_hex_aton (const char *s, int *len)
LIBNET_API const char * libnet_version (void)
LIBNET_API int libnet_adv_cull_packet (libnet_t *l, uint8_t **packet,
uint32_t *packet_s)
LIBNET_API int libnet_adv_cull_header (libnet_t *l, libnet_ptag_t ptag,
uint8_t **header, uint32_t *header_s)
LIBNET_API int libnet_adv_write_link (libnet_t *l, const uint8_t
*packet, uint32_t packet_s)
LIBNET_API int libnet_adv_write_raw_ipv4 (libnet_t *l, const uint8_t
*packet, uint32_t packet_s)
LIBNET_API void libnet_adv_free_packet (libnet_t *l, uint8_t *packet)
int libnet_cq_add (libnet_t *l, char *label)
LIBNET_API libnet_t * libnet_cq_remove (libnet_t *l)
LIBNET_API libnet_t * libnet_cq_remove_by_label (char *label)
LIBNET_API const char * libnet_cq_getlabel (libnet_t *l)
LIBNET_API libnet_t * libnet_cq_find_by_label (char *label)
LIBNET_API void libnet_cq_destroy (void)
LIBNET_API libnet_t * libnet_cq_head (void)
LIBNET_API int libnet_cq_last (void)
LIBNET_API libnet_t * libnet_cq_next (void)
LIBNET_API uint32_t libnet_cq_size (void)
LIBNET_API uint32_t libnet_cq_end_loop (void)
LIBNET_API void libnet_diag_dump_context (libnet_t *l)
LIBNET_API void libnet_diag_dump_pblock (libnet_t *l)
LIBNET_API char * libnet_diag_dump_pblock_type (uint8_t type)
void libnet_diag_dump_hex (const uint8_t *packet, uint32_t len, int
swap, FILE *stream)
libnet exported function prototypes
Takes a network byte ordered IPv4 address and returns a pointer to either a 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 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 function cannot fail -- if no canonical name exists, it will fall back on returning a dotted decimal string. This function is non-reentrant.
Parameters
Returns
Translate an IPv6 address to a canonical DNS name or hexadecimal string.
This may incur a DNS lookup if the mode is set to LIBNET_RESOLVE. If mode is set to LIBNET_DONT_RESOLVE, no DNS lookup will be performed. The function cannot fail -- if no canonical name exists, it will fall back to the hexadecimal string representation.
This function is reentrant.
Parameters
[Advanced Interface] 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 libnet is initialized in advanced mode. If the function fails libnet_geterror() can tell you why.
Parameters
Return values
[Advanced Interface] 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 all checksums written in. This function is part of the advanced interface 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 corresponding call to libnet_adv_free_packet() should be made to free the memory packet occupies. If the function fails libnet_geterror() can tell you why.
Parameters
Return values
[Advanced Interface] Frees the memory allocated when libnet_adv_cull_packet() is called.
Parameters
[Advanced Interface] Writes a packet the network at the link layer. This function is useful 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 by a call to libnet_adv_cull_packet(). This function is part of the advanced interface and is only available when libnet is initialized in advanced mode. If the function fails libnet_geterror() can tell you why.
Parameters
Returns
Return values
[Advanced Interface] Writes a packet the network at the raw socket layer. This function is useful 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 by a call to libnet_adv_cull_packet(). This function is part of the advanced interface and is only available when libnet is initialized in advanced mode. If the function fails libnet_geterror() can tell you why.
Parameters
Returns
Return values
Autouilds an Address Resolution Protocol (ARP) header. Depending on the op value, the function builds one of several different types of RFC 826 or RFC 903 RARP packets.
Parameters
Returns
Return values
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 immediately following the source address holds the layer 3 protocol (as opposed to frame's length). You should only use this function when libnet is initialized with the LIBNET_LINK interface.
Parameters
Returns
Return values
Autobuilds a Fiber Distributed Data Interface (FDDI) header.
Parameters
Returns
Return values
Autobuilds a version 4 Internet Protocol (IP) header. The function is useful 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 libnet_build_ipv4(). The function does not accept a ptag argument, but it does return a ptag. In other words, you can use it to build a new IP header but not to modify an existing one.
Parameters
Returns
Return values
Autobuilds a version 6 RFC 2460 Internet Protocol (IP) header. The function 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 as libnet_build_ipv4(). The function does not accept a ptag argument, but it does return a ptag. In other words, you can use it to build a new IP header but not to modify an existing one. This function requires libnet_get_ipaddr6(), which is not yet implemented for Win32 platforms.
Parameters
Returns
Return values
Automatically builds a link layer header for an initialized l. The function determines the proper link layer header format from how l was initialized. The function current supports Ethernet and Token Ring link layers.
Parameters
Returns
Return values
Auto-builds a token ring header.
Parameters
Returns
Return values
The core of libnet is the platform-independent packet-building functionality. These functions enable an application programmer to build protocol headers (and data) in a simple and consistent manner without having to worry (too much) about low-level network odds and ends. Each libnet_build() function builds a piece of a packet (generally a protocol header). While it is perfectly possible to build an entire, ready-to-transmit packet with a single call to a libnet_build() function, generally more than one builder-class function call is required to construct a full packet. A complete wire-ready packet generally consists of more than one piece. Every function that builds a protocol header takes a series of arguments roughly corresponding to the header values as they appear on the wire. This process is intuitive but often makes for functions with huge prototypes and large stack frames. One important thing to note is that you must call these functions in order, corresponding to how they should appear on the wire (from the highest protocol layer on down). This building process is intuitive; it approximates what happens in an operating system kernel. In other words, to build a Network Time Protocol (NTP) packet by using the link-layer interface, the application programmer would call the libnet_build() functions in the following order:
The payload interface specifies an optional way to include data directly after the protocol header in question. You can use this function for a variety of purposes, including the following:
It is important to note that some functions (notably the IPv6 builders) do use the payload interface to specify variable length but ostensibly non-optional data. See the individual libnet_build_ipv6*() functions for more information.
Libnet uses the protocol tag (ptag) to identify individual pieces of a packet after being created. A new ptag results every time a libnet_build() function with an empty (0) ptag argument completes successfully. This new ptag now refers to the packet piece just created. The application programmer's responsibility is to save this value if he or she plans to modify this particular portion later on in the program. If the application programmer needs to modify some portion of that particular packet piece again, he or she calls the same libnet_build() function specifying the saved ptag argument. Libnet then searches for that packet piece and modifies it rather than creating a new one. Upon failure for any reason, libnet_build() functions return -1; libnet_geterror() tells you why. Builds an IEEE 802.1q VLAN tagging header. Depending on the value of len_proto, the function wraps the 802.1q header inside either an IEEE 802.3 header or an RFC 894 Ethernet II (DIX) header (both resulting in an 18-byte frame). If len is 1500 or less, most receiving protocol stacks parse the frame as an IEEE 802.3 encapsulated frame. If len is one of the Ethernet type values, most protocol stacks parse the frame as an RFC 894 Ethernet II encapsulated frame. Note the length value is calculated without the 802.1q header of 18 bytes.
Parameters
Returns
Return values
Builds an IEEE 802.1x extended authentication protocol header.
Parameters
Returns
Return values
Builds an IEEE 802.2 LLC header.
Parameters
Returns
Return values
Builds an IEEE 802.2 LLC SNAP header.
Parameters
Returns
Return values
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 immediately 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 initialized with the LIBNET_LINK interface.
Parameters
Returns
Return values
Builds an Address Resolution Protocol (ARP) header. Depending on the op value, the function builds one of several different types of RFC 826 or RFC 903 RARP packets.
Parameters
Returns
Return values
Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) header. The primary function of a BGP speaking system is to exchange network reachability information with other BGP systems. This network reachability information includes information on the list of Autonomous Systems (ASs) that reachability information traverses. This information is sufficient to construct a graph of AS connectivity from which routing loops may be pruned and some policy decisions at the AS level may be enforced. This function builds the base BGP header which is used as a preamble before any other BGP header. For example, a BGP KEEPALIVE message may be built with only this function, while an error notification requires a subsequent call to libnet_build_bgp4_notification.
Parameters
Returns
Return values
Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) notification header. A NOTIFICATION message is sent when an error condition is detected. Specific error information may be passed through the payload interface.
Parameters
Returns
Return values
Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) OPEN header. This is the first message sent by each side of a BGP connection. The optional parameters options should be constructed using the payload interface (see RFC 1771 for the options structures).
Parameters
Returns
Return values
Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) update header. Update messages are used to transfer routing information between BGP peers.
Parameters
Returns
Return values
Parameters
Returns
Return values
Builds a Cisco Discovery Protocol (CDP) header. Cisco Systems designed CDP to aid in the network management of adjacent Cisco devices. The CDP protocol specifies data by using a type/length/value (TLV) setup. The first TLV can specified by using the functions type, length, and value arguments. To specify additional TLVs, the programmer could either use the payload interface or libnet_build_data() to construct them.
Parameters
Returns
Return values
Builds a generic libnet protocol header. This is useful for including an 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 types (this is probably a bug).
Parameters
Returns
Return values
Parameters
Returns
Return values
Builds an RFC 1035 version 4 DNS header. Additional DNS payload information should be specified using the payload interface.
Parameters
Returns
Return values
Generic Routing Encapsulation (GRE - RFC 1701) is used to encapsulate any protocol. Hence, the IP part of the packet is usually referred as 'delivery header'. It is then followed by the GRE header and finally the encapsulated packet (IP or whatever). 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 the header.
Parameters
Returns
Return values
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 immediately following the source address holds the layer 3 protocol (as opposed to frame's length). You should only use this function when libnet is initialized with the LIBNET_LINK interface.
Parameters
Returns
Return values
Builds a Fiber Distributed Data Interface (FDDI) header.
Parameters
Returns
Return values
Generic Routing Encapsulation (GRE - RFC 1701) is used to encapsulate any protocol. Hence, the IP part of the packet is usually referred as 'delivery header'. It is then followed by the GRE header and finally the encapsulated packet (IP or whatever). 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 the header.
Parameters
Returns
Return values
Parameters
Returns
Return values
Parameters
Returns
Return values
Builds a HSRP header. HSRP is a Cisco proprietary protocol defined in RFC 2281
Parameters
Returns
Return values
At the moment, this function is not implemented.
This stub may be useful in feature to let to the user build the LLDPDU in one function by passing corresponding arguments. Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) echo request/reply header
Parameters
Returns
Return values
Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) IP netmask request/reply header.
Parameters
Returns
Return values
Builds an IP version 4 RFC 792 Internet Message Control Protocol (ICMP) redirect header. The IP header that caused the error message should be built by a previous call to libnet_build_ipv4().
Parameters
Returns
Return values
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 built by a previous call to libnet_build_ipv4().
Parameters
Returns
Return values
Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) timestamp request/reply header.
Parameters
Returns
Return values
Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) unreachable header. The IP header that caused the error message should be built by a previous call to libnet_build_ipv4().
Parameters
Returns
Return values
Builds an IP version 6 RFC 4443 Internet Control Message Protocol (ICMP) echo or echo reply header.
Parameters
Returns
Return values
Builds an IP version 6 RFC 2461 Internet Control Message Protocol (ICMP) NDP neighbour advertisement header. Could be used with libnet_build_icmpv6_ndp_opt() and ND_OPT_TARGET_LINKADDR.
Parameters
Returns
Return values
Builds an IP version 6 RFC 2461 Internet Control Message Protocol (ICMP) NDP neighbour solicitation header. Could be used with libnet_build_icmpv6_ndp_opt() and ICMPV6_NDP_OPT_SLLA.
Parameters
Returns
Return values
Builds ICMPv6 NDP options.
Parameters
Returns
Return values
Builds an IP version 6 RFC 4443 Internet Control Message Protocol (ICMP) unreachable header. The IP header that caused the error message should be built by a previous call to libnet_build_ipv6().
Parameters
Returns
Return values
Builds an RFC 1112 Internet Group Membership Protocol (IGMP) header.
Parameters
Returns
Return values
Note
Builds an Internet Protocol Security Authentication header.
Parameters
Returns
Return values
Builds an Internet Protocol Security Encapsulating Security Payload footer.
Parameters
Returns
Return values
Builds an Internet Protocol Security Encapsulating Security Payload header.
Parameters
Returns
Return values
Builds a version 4 RFC 791 Internet Protocol (IP) header.
Parameters
Returns
Return values
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 larger than 40 bytes (the maximum size of an options string).
When building a chain, the options must be built, then the IPv4 header.
When updating a chain, if the block following the options is an IPv4 header, it's total length and header length will be updated if the options block size changes.
Parameters
Returns
Return values
Builds a version 6 RFC 2460 Internet Protocol (IP) header.
Parameters
Returns
Return values
Builds a version 6 RFC 2460 Internet Protocol (IP) destination options header. This function is special in that it uses the payload interface to include the options data. The application programmer will build an IPv6 options byte string and pass it to the function using the payload interface.
Parameters
Returns
Return values
Builds a version 6 RFC 2460 Internet Protocol (IP) fragmentation header.
Parameters
Returns
Return values
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 to 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 payload interface.
Parameters
Returns
Return values
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 'type-specific data'; that is the routing information. Most often this will be a number of 128-bit IPv6 addresses. The application programmer will build a byte string of IPv6 address and pass them to the function using the payload interface.
Parameters
Returns
Return values
Builds a Cisco Inter-Switch Link (ISL) header.
Parameters
Returns
Return values
Builds a link layer header for an initialized l. The function determines the proper link layer header format from how l was initialized. The function current supports Ethernet and Token Ring link layers.
Parameters
Returns
Return values
Builds a LLDP Chassis ID TLV. The Chassis ID TLV is the first mandatory TLV in the LLDPDU.
Parameters
Returns
Return values
Builds a LLDP End of LLDPDU TLV. The End of LLDPDU TLV used to mark the end of the TLV sequence in LLDPDU. Is a 2 octet all-zero TLV
Parameters
Returns
Return values
Builds a LLDP Organization Specific TLV.
Parameters
Returns
Return values
Builds a LLDP Port ID TLV. The Port ID TLV is the second mandatory TLV in the LLDPDU.
Parameters
Returns
Return values
Builds a LLDP TTL TLV. The TTL TLV is the third mandatory TLV in the LLDPDU.
Parameters
Returns
Return values
Builds an RFC 3032 Multi-Protocol Label Switching (MPLS) header.
Parameters
Returns
Return values
Builds an RFC 958 Network Time Protocol (NTP) header.
Parameters
Returns
Return values
Parameters
Returns
Return values
Parameters
Returns
Return values
Parameters
Returns
Return values
Parameters
Returns
Return values
Parameters
Returns
Return values
Parameters
Returns
Return values
Parameters
Returns
Return values
Parameters
Returns
Return values
Parameters
Returns
Return values
Parameters
Returns
Return values
Parameters
Returns
Return values
Builds a Routing Information Protocol header (RFCs 1058 and 2453).
Parameters
Returns
Return values
Builds an Remote Procedure Call (Version 2) Call message header as specified in RFC 1831. This builder provides the option for specifying the record marking which is required when used with streaming protocols (TCP).
Parameters
Returns
Return values
Builds a Sebek header. The Sebek protocol was designed by the Honeynet Project as a transport mechanism for post-intrusion forensic data. More information may be found here: http://www.honeynet.org/papers/sebek.pdf.
Parameters
Returns
Return values
Builds an IEEE 802.1d Spanning Tree Protocol (STP) configuration header. STP frames are usually encapsulated inside of an 802.2 + 802.3 frame combination.
Parameters
Returns
Return values
Builds an IEEE 802.1d Spanning Tree Protocol (STP) topology change notification header. STP frames are usually encapsulated inside of an 802.2 + 802.3 frame combination.
Parameters
Returns
Return values
Builds an RFC 793 Transmission Control Protocol (TCP) header.
Parameters
Returns
Return values
Builds an RFC 793 Transmission Control Protocol (TCP) options header. 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 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 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 options string and adjusts the TCP header length value as necessary.
Parameters
Returns
Return values
Builds a token ring header.
Parameters
Returns
Return values
Builds an UniDirectional Link Detection(UDLD) Device ID TLV.
Parameters
Returns
Return values
Builds an UniDirectional Link Detection(UDLD) Device Name TLV.
Parameters
Returns
Return values
Builds an UniDirectional Link Detection(UDLD) Echo TLV.
Parameters
Returns
Return values
Builds an UniDirectional Link Detection(UDLD) header. UDLD frames are usually encapsulated inside of an 802.2 + 802.3 frame combination.
Parameters
Returns
Return values
Builds an UniDirectional Link Detection(UDLD) Message Interval TLV.
Parameters
Returns
Return values
Builds an UniDirectional Link Detection(UDLD) Port ID TLV.
Parameters
Returns
Return values
Builds an UniDirectional Link Detection(UDLD) Sequence Number TLV.
Parameters
Returns
Return values
Builds an UniDirectional Link Detection(UDLD) Timeout Interval TLV.
Parameters
Returns
Return values
Builds an RFC 768 User Datagram Protocol (UDP) header.
Parameters
Returns
Return values
Builds an RFC 2338 Virtual Router Redundacy Protool (VRRP) header. Use the payload interface to specify address and authentication information. To build a 'legal' packet, the destination IPv4 address should be the multicast * address 224.0.0.18, the IP TTL should be set to 255, and the IP protocol should be set to 112.
Parameters
Returns
Return values
Clears the current packet referenced and frees all pblocks. Should be called when the programmer want to send a completely new packet of a different type using the same context.
Parameters
[Context Queue] 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 the first entry on the list. The functions checks to ensure niether l nor label 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 initialized with a call to libnet_init(). If the context queue in write locked, this function will fail.
Parameters
Return values
[Context Queue] Destroys the entire context queue, calling libnet_destroy() on each member context.
[Context Queue] Cleanup from iterating through the context queue.
Return values
[Context Queue] Locates a libnet context from the queue, indexed by a canonical label.
Parameters
Returns
Return values
[Context Queue] Returns the canonical label associated with the context.
Parameters
Returns
[Context Queue] Intiailizes the interator interface and set a write lock on the entire 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 series of packets in rapid succession). This function is often used as per the following:
for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next()) { ... }
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, for_each_context_in_cq(l). Warning: do not call the iterator more than once in a single loop.
Returns
[Context Queue] Check whether the iterator is at the last context in the queue.
Return values
[Context Queue] Get next context from the context queue.
Returns
[Context Queue] Removes a specified context from the libnet context queue by specifying the libnet context pointer. Note the function will remove the specified context 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 call to libnet_destroy(). Also, as it is not necessary to keep the libnet context pointer when initially adding it to the context queue, most application programmers will prefer to refer to entries on the context queue by canonical name and would use libnet_cq_remove_by_label(). If the context queue is write locked, this function will fail.
Parameters
Returns
Return values
[Context Queue] Removes a specified context from the libnet context queue by specifying the canonical name. Note the function will remove the specified context 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 call to libnet_destroy(). If the context queue is write locked, this function will fail.
Parameters
Returns
Return values
[Context Queue] Function returns the number of libnet contexts that are in the queue.
Returns
Shuts down the libnet session referenced by l. It closes the network interface and frees all internal memory structures associated with l.
Parameters
[Diagnostic] Prints the contents of the given context.
Parameters
[Diagnostic] Function prints the contents of the supplied buffer to the supplied stream pointer. Will swap endianness based disposition of mode variable. Useful to be used in conjunction with the advanced interface and a culled packet.
Parameters
[Diagnostic] Prints the contents of every pblock.
Parameters
[Diagnostic] Returns the canonical name of the pblock type.
Parameters
Returns
Return values
Returns the MAC address for the device libnet was initialized with. If libnet was initialized without a device the function will attempt to find one. If the function fails and returns NULL a call to libnet_geterror() will tell you why.
Parameters
Returns
Returns the IP address for the device libnet was initialized with. If libnet was initialized without a device (in raw socket mode) the function will attempt to find one. If the function fails and returns -1 a call to libnet_geterrror() will tell you why.
Parameters
Returns
Return values
Returns the IPv6 address for the device libnet was initialized with. If libnet was initialized without a device (in raw socket mode) the function will attempt to find one. If the function fails and returns in6addr_error, a call to libnet_geterrror() will tell you why. This function is not yet implemented for Win32 platforms.
Parameters
Return values
Generates an unsigned pseudo-random value within the range specified by mod. LIBNET_PR2 0 - 1 LIBNET_PR8 0 - 255 LIBNET_PR16 0 - 32767 LIBNET_PRu16 0 - 65535 LIBNET_PR32 0 - 2147483647 LIBNET_PRu32 0 - 4294967295
Parameters
Return values
Returns the canonical name of the device used for packet injection.
Parameters
Returns
Returns the last error set inside of the referenced libnet context. This function should be called anytime a function fails or an error condition is detected inside of libnet.
Parameters
Returns
Returns the FILENO of the file descriptor used for packet injection.
Parameters
Returns
Parameters
Returns
See also
Returns the sum of the size of all of the pblocks inside of l (this should be the resulting packet size).
Parameters
Returns
Returns the pblock buffer contents for the specified ptag; a subsequent call to libnet_getpbuf_size() should be made to determine the size of the buffer.
Parameters
Returns
Returns the pblock buffer size for the specified ptag; a previous call to libnet_getpbuf() should be made to pull the actual buffer contents.
Parameters
Returns
Takes a colon separated hexidecimal address (from the command line) and returns a bytestring suitable for use in a libnet_build function. Note this function performs an implicit malloc and the return value should be freed after its use.
Parameters
Returns
Check a libnet_in6_addr structure for identity with in6addr_error.
Parameters
Return values
Creates the libnet environment. It initializes the library and returns a libnet context. If the injection_type is LIBNET_LINK or LIBNET_LINK_ADV, the function initializes the injection primitives for the link-layer interface enabling the application programmer to build packets starting at the data-link layer (which also provides more granular control over the IP layer). If libnet uses the link-layer and the device argument is non-NULL, the function attempts to use the specified network device for packet injection. This is either a canonical string that references the device (such as 'eth0' for a 100MB Ethernet card on Linux or 'fxp0' for a 100MB Ethernet card on OpenBSD) or the dots and decimals representation of the device's IP address (192.168.0.1). If device is NULL, libnet attempts to find a suitable device to use. If the injection_type is LIBNET_RAW4 or LIBNET_RAW4_ADV, the function initializes the injection primitives for the IPv4 raw socket interface. The final argument, err_buf, should be a buffer of size LIBNET_ERRBUF_SIZE and holds an error message if the function fails. This function requires root privileges to execute successfully. Upon success, the function returns a valid libnet context for use in later function calls; upon failure, the function returns NULL.
Parameters
Returns
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 is set to LIBNET_RESOLVE and host_name refers to a canonical DNS name. If mode 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 host_name refers to a canonical DNS name.
Parameters
Returns
Return values
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 is set to LIBNET_RESOLVE and host_name refers to a canonical DNS name. If mode 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 host_name refers to a canonical DNS name.
Parameters
Returns
Runs through the port list and prints the contents of the port list chain list to stdout.
Parameters
Return values
Runs through the port list and prints the contents of the port list chain list to string. This function uses strdup and is not re-entrant. It also has a memory leak and should not really be used.
Parameters
Returns
Frees all memory associated with port list chain.
Parameters
Return values
Creates a new port list. Port list chains are useful for TCP and UDP-based applications that need to send packets to a range of ports (contiguous or otherwise). The port list chain, which token_list points to, should contain 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 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 returns
Parameters
Return values
Returns the next port list chain pair from the port list chain plist. bport and eport contain the starting port number and ending port number, respectively. Upon success, the function returns 1 and fills in the port variables; however, if the list is empty, the function returns 0 and sets both port variables to 0. Upon failure, the function returns -1.
Parameters
Return values
Seeds the pseudo-random number generator.
Parameters
Return values
Fills in a libnet_stats structure with packet injection statistics (packets written, bytes written, packet sending errors).
Parameters
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 header is set to any other value, by default libnet will not calculate the 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 to LIBNET_ON, libnet will mark the specified ptag to calculate a checksum for the ptag prior to injection. This assumes that the ptag refers to a protocol that has a checksum field. If mode is set to LIBNET_OFF, libnet 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 otherwise) to the checksum field. Often times this is useful if a precomputed checksum or some other predefined value is going to be used. Note that when libnet is initialized with LIBNET_RAW4, the IPv4 header checksum will always be computed by the kernel prior to injection, regardless of what the programmer sets.
Parameters
Return values
Returns the version of libnet.
Returns
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 constructed packet has been built inside this context (via one or 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 packet to the wire either via the raw or link layer interface. The function will also bump up the internal libnet stat counters which are retrievable via libnet_stats().
Parameters
Returns
Return values
libnet(3)
The original author of libnet is Mike D. Schiffman.
libnet has been maintained and extensively enhanced since 2009 by Sam Roberts.
It is maintained by the Libnet Developer Community at GitHub.
<https://github.com/libnet/libnet>
Suggestions, bug reports/fixes, and pull requests, see:
<https://github.com/libnet/libnet/issues>
libnet is licensed under the 2-Clause BSD License.
libnet(3)
The original author of libnet is Mike D. Schiffman.
libnet has been maintained and extensively enhanced since 2009 by Sam Roberts.
It is maintained by the Libnet Developer Community at GitHub.
<https://github.com/libnet/libnet>
Suggestions, bug reports/fixes, and pull requests, see:
<https://github.com/libnet/libnet/issues>
libnet is licensed under the 2-Clause BSD License.
| libnet-1.3 | libnet Programmers Guide |