libnet: API Documentation: libnet API Documentation

libnet API Documentation

1998 - 2017 The libnet Developer Community

Content(s)

  • Main Page
  • Files
    • File List
    • Globals
  • Stuff
    • Rawsocket Non Sequitur
      • Some Sub-sub-page
    • Design Notes
    • Hacking
    • TODO
  • Bindings
    • Lua
    • Python
  • Page
  • More Page!
    • Me Another Sub-page, yay!
  • TODO

Introduction

Attention: Most on the stuff on this page is either placeholder text and/or work in progress. At best, you should take the content on this page half-serious. I invite you to help expand/improve it.

This manual documents the low-level libnet API. If you're planning to this API directly, you're signing up for some pain. Just kidding. (I'm not kidding)

Although there aren't many up-to-date places to look for libnet information these days (yet), you still might not want to get started learning about libnet by reading this document. These pages provide an overview of (some) the internals of libnet with links to the relevant parts of the code. If you "just want it to work" or if this is all very new to you, then you should first refer to these (more or less) separate set of pages. Be sure to check out the man pages as well.

The libnet API deliberately lacks most convenient functions. As further explained in Design Notes, those happen behind the scenes, are left to complementary libraries, higher-level libraries or to "bindings" such as pcap, Python, Lua, etc. and have features such as ~~object systems and main loops~~ that allow a much more convenient API.

The low-level API also contains plenty of clutter to support integration with arbitrary ~~object systems, languages, main loops~~, and so forth. These features add a lot of noise to the API that you probably don't care about unless you're coding a binding.

For now, and probably never will there be similar docs for libnet's internals. So if you want to get oriented with the libnet source code (because you're interested in patching the code for example), you should dive straight into each source file, read the source and the comments surrounding it, and... just... figure the rest out! Or ask about it here. If that's something you think you're you can see yourself doing then Welcome Aboard! By the way, it's also a good idea to go through some of the commits to understand the purpose or aim of whoever had their hands on the source before you. There will be a "[Hacking](Hacking.html)" section soon that is intended to guide and assist developers through this adventures journey.

That is, if I don't lose interest, any hope or my sanity before that. Just kidding. (I'm not kidding)

Stay tuned.

Last Modified: Wed, 26 Apr 2017 02:58:54 +0300

TODO

  • try to make it sound smart
  • replace stuff inside ~~ with stuff that is actually true
  • call mom and dad
  • try to get Inbal back :-(
  • re-install Windows
  • create a separate "doc" branch and never ever (ever) commit anything relate to it directly to master (lesson learnt)
Documentation for libnet (version 1.2-rc3).
Generated on Sun Jun 10 2018 by Doxygen 1.8.14.


libnet: API Documentation: File List

File List
Here is a list of all documented files with brief descriptions:
libnet-functions.h | Libnet exported function prototypes
libnet-macros.h | Libnet macros and symbolic constants
libnet.h | Top-level libnet header file


libnet: API Documentation: libnet-functions.h File Reference

  • libnet
Functions
libnet-functions.h File Reference

libnet exported function prototypes More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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, 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_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_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)

Detailed Description

libnet exported function prototypes

Function Documentation

◆ libnet_addr2name4()

LIBNET_API char* libnet_addr2name4 | ( | uint32_t | in,
 |  | uint8_t | use_name
 | ) |  |

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
in | network byte ordered IPv4 address
use_name | LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
Returns
a pointer to presentation format string

◆ libnet_addr2name6_r()

LIBNET_API void libnet_addr2name6_r | ( | struct libnet_in6_addr | addr,
 |  | uint8_t | use_name,
 |  | char * | host_name,
 |  | int | host_name_len
 | ) |  |

Should document this baby right here.

◆ libnet_adv_cull_header()

LIBNET_API int libnet_adv_cull_header | ( | libnet_t * | l,
 |  | libnet_ptag_t | ptag,
 |  | uint8_t ** | header,
 |  | uint32_t * | header_s
 | ) |  |

[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
l | pointer to a libnet context
ptag | the ptag referencing the header to pull
header | will contain the header
header_s | will contain the header size
Return values
1 | on success
-1 | on failure

◆ libnet_adv_cull_packet()

LIBNET_API int libnet_adv_cull_packet | ( | libnet_t * | l,
 |  | uint8_t ** | packet,
 |  | uint32_t * | packet_s
 | ) |  |

[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
l | pointer to a libnet context
packet | will contain the wire-ready packet
packet_s | will contain the packet size
Return values
1 | on success
-1 | on failure

◆ libnet_adv_free_packet()

LIBNET_API void libnet_adv_free_packet | ( | libnet_t * | l,
 |  | uint8_t * | packet
 | ) |  |

[Advanced Interface] Frees the memory allocated when libnet_adv_cull_packet() is called.

Parameters
l | pointer to a libnet context
packet | a pointer to the packet to free

◆ libnet_adv_write_link()

LIBNET_API int libnet_adv_write_link | ( | libnet_t * | l,
 |  | const uint8_t * | packet,
 |  | uint32_t | packet_s
 | ) |  |

[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
l | pointer to a libnet context
packet | a pointer to the packet to inject
packet_s | the size of the packet
Returns
the number of bytes written
Return values
-1 on failure

◆ libnet_adv_write_raw_ipv4()

LIBNET_API int libnet_adv_write_raw_ipv4 | ( | libnet_t * | l,
 |  | const uint8_t * | packet,
 |  | uint32_t | packet_s
 | ) |  |

[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
l | pointer to a libnet context
packet | a pointer to the packet to inject
packet_s | the size of the packet
Returns
the number of bytes written
Return values
-1 on failure

◆ libnet_autobuild_arp()

LIBNET_API libnet_ptag_t libnet_autobuild_arp | ( | uint16_t | op,
 |  | const uint8_t * | sha,
 |  | const uint8_t * | spa,
 |  | const uint8_t * | tha,
 |  | uint8_t * | tpa,
 |  | libnet_t * | l
 | ) |  |

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
op | ARP operation type
sha | sender's hardware address
spa | sender's protocol address
tha | target hardware address
tpa | targer protocol address
l | pointer to a libnet context
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_autobuild_ethernet()

LIBNET_API libnet_ptag_t libnet_autobuild_ethernet | ( | const uint8_t * | dst,
 |  | uint16_t | type,
 |  | libnet_t * | l
 | ) |  |

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
dst | destination ethernet address
type | upper layer protocol type
l | pointer to a libnet context
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_autobuild_fddi()

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
 | ) |  |

Autobuilds a Fiber Distributed Data Interface (FDDI) header.

Parameters
fc | class format and priority
dst | destination fddi address
dsap | destination service access point
ssap | source service access point
cf | cf
oui | IEEE organizational code
type | upper layer protocol
l | pointer to a libnet context
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_autobuild_ipv4()

LIBNET_API libnet_ptag_t libnet_autobuild_ipv4 | ( | uint16_t | len,
 |  | uint8_t | prot,
 |  | uint32_t | dst,
 |  | libnet_t * | l
 | ) |  |

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
len | total length of the IP packet including all subsequent data
prot | upper layer protocol
dst | destination IPv4 address (little endian)
l | pointer to a libnet context
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_autobuild_ipv6()

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
 | ) |  |

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
len | length
nh | next header
dst | destination IPv6 address
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_autobuild_link()

LIBNET_API libnet_ptag_t libnet_autobuild_link | ( | const uint8_t * | dst,
 |  | const uint8_t * | oui,
 |  | uint16_t | type,
 |  | libnet_t * | l
 | ) |  |

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
dst | the destination MAC address
oui | Organizationally Unique Identifier (unused for Ethernet)
type | the upper layer protocol type
l | pointer to a libnet context
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_autobuild_token_ring()

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
 | ) |  |

Auto-builds a token ring header.

Parameters
ac | access control
fc | frame control
dst | destination address
dsap | destination service access point
ssap | source service access point
cf | control field
oui | Organizationally Unique Identifier
type | upper layer protocol type
l | pointer to a libnet context
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_802_1q()

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
 | ) |  |

Packet Builder Functions

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:

  1. libnet_build_ntp()
  2. libnet_build_udp()
  3. libnet_build_ipv4()
  4. libnet_build_ethernet() This ordering is essential for libnet 1.1.x to properly link together the packet internally (previous libnet versions did not have the requirement).

The Payload Interface

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:

  • Including additional or arbitrary protocol header information that is not available from a libnet interface
  • Including a packet payload (data segment)
  • Building another protocol header that is not available from a libnet interface To employ the interface, the application programmer should construct the i payload data and pass a const uint8_t * to this data and its size to the desired libnet_build() function. Libnet handles the rest.

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.

Protocol Tags and Packet Builder Return Values

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
dst | pointer to a six byte source ethernet address
src | pointer to a six byte destination ethernet address
tpi | tag protocol identifier
priority | priority
cfi | canonical format indicator
vlan_id | vlan identifier
len_proto | length (802.3) protocol (Ethernet II)
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_802_1x()

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
 | ) |  |

Builds an IEEE 802.1x extended authentication protocol header.

Parameters
eap_ver | the EAP version
eap_type | the EAP type
length | frame length
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_802_2()

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
 | ) |  |

Builds an IEEE 802.2 LLC header.

Parameters
dsap | destination service access point
ssap | source service access point
control | control field
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_802_2snap()

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
 | ) |  |

Builds an IEEE 802.2 LLC SNAP header.

Parameters
dsap | destination service access point
ssap | source service access point
control | control field
oui | Organizationally Unique Identifier
type | upper layer protocol
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_802_3()

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
 | ) |  |

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
dst | destination ethernet address
src | source ethernet address
len | frame length sans header
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_arp()

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
 | ) |  |

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
hrd | hardware address format
pro | protocol address format
hln | hardware address length
pln | protocol address length
op | ARP operation type
sha | sender's hardware address
spa | sender's protocol address
tha | target hardware address
tpa | targer protocol address
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_bgp4_header()

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
 | ) |  |

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
marker | a value the receiver can predict (if the message type is not BGP OPEN, or no authentication is used, these 16 bytes are normally set as all ones)
len | total length of the BGP message, including the header
type | type code of the message (OPEN, UPDATE, NOTIFICATION or KEEPALIVE)
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_bgp4_notification()

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
 | ) |  |

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
err_code | type of notification
err_subcode | more specific information about the reported error.
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_bgp4_open()

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
 | ) |  |

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
version | protocol version (should be set to 4)
src_as | Autonomous System of the sender
hold_time | used to compute the maximum allowed time between the receipt of KEEPALIVE, and/or UPDATE messages by the sender
bgp_id | BGP identifier of the sender
opt_len | total length of the optional parameters field in bytes
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_bgp4_update()

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
 | ) |  |

Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) update header. Update messages are used to transfer routing information between BGP peers.

Parameters
unfeasible_rt_len | indicates the length of the (next) "withdrawn routes" field in bytes
withdrawn_rt | list of IP addresses prefixes for the routes that are being withdrawn; each IP address prefix is built as a 2-tuple <length (1 byte), prefix (variable)>
total_path_attr_len | indicates the length of the (next) "path attributes" field in bytes
path_attributes | each attribute is a 3-tuple <type (2 bytes), length, value>
info_len | indicates the length of the (next) "network layer reachability information" field in bytes (needed for internal memory size calculation)
reachability_info | 2-tuples <length (1 byte), prefix (variable)>.
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_bootpv4()

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
 | ) |  |
Parameters
opcode
htype
hlen
hopcount
xid
secs
flags
cip
yip
sip
gip
chaddr | client hardware address, length is hlen
sname | server host name, a null terminated string
file | boot file name, a null terminated string
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_cdp()

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
 | ) |  |

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
version | CDP version
ttl | time to live (time information should be cached by recipient)
sum | checksum (0 for libnet to auto-fill)
type | type of data contained in value
value_s | length of value argument
value | the CDP information string
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_data()

LIBNET_API libnet_ptag_t libnet_build_data | ( | const uint8_t * | payload,
 |  | uint32_t | payload_s,
 |  | libnet_t * | l,
 |  | libnet_ptag_t | ptag
 | ) |  |

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
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_dhcpv4()

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
 | ) |  |
Parameters
opcode
htype
hlen
hopcount
xid
secs
flags
cip
yip
sip
gip
chaddr | client hardware address, length is hlen
sname | server host name, a null terminated string
file | boot file name, a null terminated string
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_dnsv4()

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
 | ) |  |

Builds an RFC 1035 version 4 DNS header. Additional DNS payload information should be specified using the payload interface.

Parameters
h_len
id | DNS packet id
flags | control flags
num_q | number of questions
num_anws_rr | number of answer resource records
num_auth_rr | number of authority resource records
num_addi_rr | number of additional resource records
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_egre()

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
 | ) |  |

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
fv | the 16 0 to 7: which fields are included in the header (checksum, seq. number, key, ...), bits 8 to 12: flag, bits 13 to 15: version.
type | which protocol is encapsulated (PPP, IP, ...)
sum | checksum (0 for libnet to auto-fill).
offset | byte offset from the start of the routing field to the first byte of the SRE
key | inserted by the encapsulator to authenticate the source
seq | sequence number used by the receiver to sort the packets
len | size of the GRE packet
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ethernet()

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
 | ) |  |

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
dst | destination ethernet address
src | source ethernet address
type | upper layer protocol type
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_fddi()

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
 | ) |  |

Builds a Fiber Distributed Data Interface (FDDI) header.

Parameters
fc | class format and priority
dst | destination fddi address
src | source fddi address
dsap | destination service access point
ssap | source service access point
cf | cf
oui | 3 byte IEEE organizational code
type | upper layer protocol
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_gre()

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
 | ) |  |

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
fv | the 16 0 to 7: which fields are included in the header (checksum, seq. number, key, ...), bits 8 to 12: flag, bits 13 to 15: version.
type | which protocol is encapsulated (PPP, IP, ...)
sum | checksum (0 for libnet to auto-fill).
offset | byte offset from the start of the routing field to the first byte of the SRE
key | inserted by the encapsulator to authenticate the source
seq | sequence number used by the receiver to sort the packets
len | size of the GRE packet
payload
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_gre_last_sre()

LIBNET_API libnet_ptag_t libnet_build_gre_last_sre | ( | libnet_t * | l,
 |  | libnet_ptag_t | ptag
 | ) |  |
Parameters
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_gre_sre()

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
 | ) |  |
Parameters
af
offset
length
routing
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_hsrp()

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
 | ) |  |

Builds a HSRP header. HSRP is a Cisco proprietary protocol defined in RFC 2281

Parameters
version | version of the HSRP messages
opcode | type of message
state | current state of the router
hello_time | period in seconds between hello messages
hold_time | seconds that the current hello message is valid
priority | priority for the election process
group | standby group
reserved | reserved field
authdata | password
virtual_ip | virtual ip address
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_icmpv4_echo()

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
 | ) |  |

Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) echo request/reply header

Parameters
type | type of ICMP packet (should be ICMP_ECHOREPLY or ICMP_ECHO)
code | code of ICMP packet (should be 0)
sum | checksum (0 for libnet to auto-fill)
id | identification number
seq | packet sequence number
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_icmpv4_mask()

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
 | ) |  |

Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) IP netmask request/reply header.

Parameters
type | type of ICMP packet (should be ICMP_MASKREQ or ICMP_MASKREPLY)
code | code of ICMP packet (should be 0)
sum | checksum (0 for libnet to auto-fill)
id | identification number
seq | packet sequence number
mask | subnet mask
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_icmpv4_redirect()

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
 | ) |  |

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
type | type of ICMP packet (should be ICMP_REDIRECT)
code | code of ICMP packet (should be one of the four redirect codes)
sum | checksum (0 for libnet to auto-fill)
gateway
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_icmpv4_timeexceed()

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
 | ) |  |

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
type | type of ICMP packet (should be ICMP_TIMXCEED)
code | code of ICMP packet (ICMP_TIMXCEED_INTRANS / ICMP_TIMXCEED_REASS)
sum | checksum (0 for libnet to auto-fill)
payload | optional payload or NULL
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_icmpv4_timestamp()

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
 | ) |  |

Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) timestamp request/reply header.

Parameters
type | type of ICMP packet (should be ICMP_TSTAMP or ICMP_TSTAMPREPLY)
code | code of ICMP packet (should be 0)
sum | checksum (0 for libnet to auto-fill)
id | identification number
seq | sequence number
otime | originate timestamp
rtime | receive timestamp
ttime | transmit timestamp
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_icmpv4_unreach()

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
 | ) |  |

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
type | type of ICMP packet (should be ICMP_UNREACH)
code | code of ICMP packet (should be one of the 16 unreachable codes)
sum | checksum (0 for libnet to auto-fill)
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_icmpv6_echo()

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
 | ) |  |

Builds an IP version 6 RFC 4443 Internet Control Message Protocol (ICMP) echo or echo reply header.

Parameters
type | type of ICMP packet (should be ICMP6_ECHO_REQUEST or ICMP6_ECHO_REPLY)
code | code of ICMP packet (should be zero)
sum | checksum (0 for libnet to auto-fill)
id | echo id number
seq | echo sequence number
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_icmpv6_ndp_nadv()

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
 | ) |  |

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
type | type of ICMP packet (should be ND_NEIGHBOR_ADVERT)
code | code of ICMP packet (should be zero)
sum | checksum (0 for libnet to auto-fill)
flags | should be a bitwise or of any applicable ND_NA_FLAG_* flags
target | target ipv6 address
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_icmpv6_ndp_nsol()

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
 | ) |  |

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
type | type of ICMP packet (should be ND_NEIGHBOR_SOLICIT)
code | code of ICMP packet (should be zero)
sum | checksum (0 for libnet to auto-fill)
target | target ipv6 address
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_icmpv6_ndp_opt()

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
 | ) |  |

Builds ICMPv6 NDP options.

Parameters
type | one of ND_OPT_* types
option | option data
option_s | size of option data (will be padded out to an 8-byte boundary)
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_icmpv6_unreach()

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
 | ) |  |

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
type | type of ICMP packet (should be ICMP6_DST_UNREACH)
code | code of ICMP packet (should be one of the 5 ICMP6_DST_UNREACH_* codes)
sum | checksum (0 for libnet to auto-fill)
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_igmp()

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
 | ) |  |

Builds an RFC 1112 Internet Group Membership Protocol (IGMP) header.

Parameters
type | packet type
reserved | (should be 0 for IGMPv1)
sum | checksum (0 for libnet to auto-fill)
ip | IPv4 address (in standard/network byte order)
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error
Note
'reserved' was previously called 'code', which it is not, in any IGMP version.

◆ libnet_build_ipsec_ah()

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
 | ) |  |

Builds an Internet Protocol Security Authentication header.

Parameters
nh | next header
len | payload length
res | reserved
spi | security parameter index
seq | sequence number
auth | authentication data
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ipsec_esp_ftr()

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
 | ) |  |

Builds an Internet Protocol Security Encapsulating Security Payload footer.

Parameters
len | padding length
nh | next header
auth | authentication data
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ipsec_esp_hdr()

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
 | ) |  |

Builds an Internet Protocol Security Encapsulating Security Payload header.

Parameters
spi | security parameter index
seq | ESP sequence number
iv | initialization vector
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ipv4()

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
 | ) |  |

Builds a version 4 RFC 791 Internet Protocol (IP) header.

Parameters
ip_len | total length of the IP packet including all subsequent data (subsequent data includes any IP options and IP options padding)
tos | type of service bits
id | IP identification number
frag | fragmentation bits and offset
ttl | time to live in the network
prot | upper layer protocol
sum | checksum (0 for libnet to auto-fill)
src | source IPv4 address (little endian)
dst | destination IPv4 address (little endian)
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ipv4_options()

LIBNET_API libnet_ptag_t libnet_build_ipv4_options | ( | const uint8_t * | options,
 |  | uint32_t | options_s,
 |  | libnet_t * | l,
 |  | libnet_ptag_t | ptag
 | ) |  |

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
options | byte string of IP options (it will be padded up to be an integral multiple of 32-bit words).
options_s | length of options string
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ipv6()

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
 | ) |  |

Builds a version 6 RFC 2460 Internet Protocol (IP) header.

Parameters
tc | traffic class
fl | flow label
len | total length of the IP packet
nh | next header
hl | hop limit
src | source IPv6 address
dst | destination IPv6 address
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ipv6_destopts()

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
 | ) |  |

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
nh | next header
len | length of the header in 8-byte octets not including the first 8 octets
payload | options payload
payload_s | payload length
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ipv6_frag()

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
 | ) |  |

Builds a version 6 RFC 2460 Internet Protocol (IP) fragmentation header.

Parameters
nh | next header
reserved | unused value... OR IS IT!
frag | fragmentation bits (ala ipv4)
id | packet identification
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ipv6_hbhopts()

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
 | ) |  |

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
nh | next header
len | length of the header in 8-byte octets not including the first 8 octets
payload | options payload
payload_s | payload length
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ipv6_routing()

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
 | ) |  |

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
nh | next header
len | length of the header in 8-byte octets not including the first 8 octets
rtype | routing header type
segments | number of routing segments that follow
payload | optional payload of routing information
payload_s | payload length
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_isl()

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
 | ) |  |

Builds a Cisco Inter-Switch Link (ISL) header.

Parameters
dhost | destination address (should be 01:00:0c:00:00)
type | type of frame
user | user defined data
shost | source mac address
len | total length of the encapsulated packet less 18 bytes
snap | SNAP information (0xaaaa03 + vendor code)
vid | 15 bit VLAN ID, 1 bit BPDU or CDP indicator
portindex | port index
reserved | used for FDDI and token ring
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_link()

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
 | ) |  |

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
dst | the destination MAC address
src | the source MAC address
oui | Organizationally Unique Identifier (unused for Ethernet)
type | the upper layer protocol type
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_mpls()

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
 | ) |  |

Builds an RFC 3032 Multi-Protocol Label Switching (MPLS) header.

Parameters
label | 20-bit label value
experimental | 3-bit reserved field
bos | 1-bit bottom of stack identifier
ttl | time to live
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ntp()

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
 | ) |  |

Builds an RFC 958 Network Time Protocol (NTP) header.

Parameters
leap_indicator | the leap indicator
version | NTP protocol version
mode | NTP mode
stratum | stratum
poll | polling interval
precision | precision
delay_int | delay interval
delay_frac | delay fraction
dispersion_int | dispersion interval
dispersion_frac | dispersion fraction
reference_id | reference id
ref_ts_int | reference timestamp integer
ref_ts_frac | reference timestamp fraction
orig_ts_int | original timestamp integer
orig_ts_frac | original timestamp fraction
rec_ts_int | receiver timestamp integer
rec_ts_frac | receiver timestamp fraction
xmt_ts_int | transmit timestamp integer
xmt_ts_frac | transmit timestamp integer
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ospfv2()

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
 | ) |  |
Parameters
len
type
rtr_id
area_id
sum
autype
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ospfv2_dbd()

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
 | ) |  |
Parameters
dgram_len
opts
type
seqnum
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ospfv2_hello()

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
 | ) |  |
Parameters
netmask
interval
opts
priority
dead_int
des_rtr
bkup_rtr
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ospfv2_hello_neighbor()

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
 | ) |  |
Parameters
netmask
interval
opts
priority
dead_int
des_rtr
bkup_rtr
neighbor
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ospfv2_lsa()

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
 | ) |  |
Parameters
age
opts
type
lsid
advrtr
seqnum
sum
len
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ospfv2_lsa_as()

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
 | ) |  |
Parameters
nmask
metric
fwdaddr
tag
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ospfv2_lsa_net()

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
 | ) |  |
Parameters
nmask
rtrid
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ospfv2_lsa_rtr()

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
 | ) |  |
Parameters
flags
num
id
data
type
tos
metric
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ospfv2_lsa_sum()

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
 | ) |  |
Parameters
nmask
metric
tos
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ospfv2_lsr()

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
 | ) |  |
Parameters
type
lsid
advrtr
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_ospfv2_lsu()

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
 | ) |  |
Parameters
num
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_rip()

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
 | ) |  |

Builds a Routing Information Protocol header (RFCs 1058 and 2453).

Parameters
cmd | command
version | protocol version
rd | version one: 0, version two: routing domain
af | address family
rt | version one: 0, version two: route tag
addr | IPv4 address
mask | version one: 0, version two: subnet mask
next_hop | version one: 0, version two: next hop address
metric | routing metric
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_rpc_call()

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
 | ) |  |

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
rm | record marking indicating the position in a stream, 0 otherwise
xid | transaction identifier used to link calls and replies
prog_num | remote program specification typically between 0 - 1fffffff
prog_vers | remote program version specification
procedure | procedure to be performed by remote program
cflavor | authentication credential type
clength | credential length (should be 0)
cdata | opaque credential data (currently unused)
vflavor | authentication verifier type
vlength | verifier length (should be 0)
vdata | opaque verifier data (currently unused)
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_sebek()

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
 | ) |  |

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
magic | identify packets that should be hidden
version | protocol version, currently 1
type | type of record (read data is type 0, write data is type 1)
counter | PDU counter used to identify when packet are lost
time_sec | seconds since EPOCH according to the honeypot
time_usec | residual microseconds
pid | PID
uid | UID
fd | FD
cmd | 12 first characters of the command
length | length in bytes of the PDU's body
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_stp_conf()

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
 | ) |  |

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
id | protocol id
version | protocol version
bpdu_type | bridge protocol data unit type
flags | flags
root_id | root id
root_pc | root path cost
bridge_id | bridge id
port_id | port id
message_age | message age
max_age | max age
hello_time | hello time
f_delay | forward delay
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_stp_tcn()

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
 | ) |  |

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
id | protocol id
version | protocol version
bpdu_type | bridge protocol data unit type
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_tcp()

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
 | ) |  |

Builds an RFC 793 Transmission Control Protocol (TCP) header.

Parameters
sp | source port
dp | destination port
seq | sequence number
ack | acknowledgement number
control | control flags
win | window size
sum | checksum (0 for libnet to auto-fill)
urg | urgent pointer
len | total length of the TCP packet (for checksum calculation)
payload
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_tcp_options()

LIBNET_API libnet_ptag_t libnet_build_tcp_options | ( | const uint8_t * | options,
 |  | uint32_t | options_s,
 |  | libnet_t * | l,
 |  | libnet_ptag_t | ptag
 | ) |  |

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
options | byte string of TCP options
options_s | length of options string
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_token_ring()

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
 | ) |  |

Builds a token ring header.

Parameters
ac | access control
fc | frame control
dst | destination address
src | source address
dsap | destination service access point
ssap | source service access point
cf | control field
oui | Organizationally Unique Identifier
type | upper layer protocol type
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_udp()

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
 | ) |  |

Builds an RFC 768 User Datagram Protocol (UDP) header.

Parameters
sp | source port
dp | destination port
len | total length of the UDP packet
sum | checksum (0 for libnet to auto-fill)
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_build_vrrp()

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
 | ) |  |

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
version | VRRP version (should be 2)
type | VRRP packet type (should be 1 – ADVERTISEMENT)
vrouter_id | virtual router identification
priority | priority (higher numbers indicate higher priority)
ip_count | number of IPv4 addresses contained in this advertisement
auth_type | type of authentication (0, 1, 2 – see RFC)
advert_int | interval between advertisements
sum | checksum (0 for libnet to autofill)
payload | optional payload or NULL
payload_s | payload length or 0
l | pointer to a libnet context
ptag | protocol tag to modify an existing header, 0 to build a new one
Returns
protocol tag value on success
Return values
-1 on error

◆ libnet_clear_packet()

LIBNET_API void libnet_clear_packet ( libnet_t * l )

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
l pointer to a libnet context

◆ libnet_cq_add()

int libnet_cq_add | ( | libnet_t * | l,
 |  | char * | label
 | ) |  |

[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
l | pointer to a libnet context
label | a canonical name given to recognize the new context, no longer than LIBNET_LABEL_SIZE
Return values
1 | on success
-1 | on failure

◆ libnet_cq_destroy()

LIBNET_API void libnet_cq_destroy ( void )

[Context Queue] Destroys the entire context queue, calling libnet_destroy() on each member context.

◆ libnet_cq_end_loop()

LIBNET_API uint32_t libnet_cq_end_loop ( void )

[Context Queue]

◆ libnet_cq_find_by_label()

LIBNET_API libnet_t* libnet_cq_find_by_label ( char * label )

[Context Queue] Locates a libnet context from the queue, indexed by a canonical label.

Parameters
label canonical label of the libnet context to retrieve
Returns
the expected libnet context
Return values
NULL on failure

◆ libnet_cq_getlabel()

LIBNET_API const char* libnet_cq_getlabel ( libnet_t * l )

[Context Queue] Returns the canonical label associated with the context.

Parameters
l pointer to a libnet context
Returns
pointer to the libnet context's label

◆ libnet_cq_head()

LIBNET_API libnet_t* libnet_cq_head ( void )

[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
the head of the context queue

◆ libnet_cq_last()

LIBNET_API int libnet_cq_last ( void )

[Context Queue] Check whether the iterator is at the last context in the queue.

Return values
1 | if at the end of the context queue
0 | otherwise

◆ libnet_cq_next()

LIBNET_API libnet_t* libnet_cq_next ( void )

[Context Queue] Get next context from the context queue.

Returns
the next context from the context queue

◆ libnet_cq_remove()

LIBNET_API libnet_t* libnet_cq_remove ( libnet_t * l )

[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
l pointer to a libnet context
Returns
the pointer to the removed libnet context
Return values
NULL on failure

◆ libnet_cq_remove_by_label()

LIBNET_API libnet_t* libnet_cq_remove_by_label ( char * label )

[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
label canonical name of the context to remove
Returns
the pointer to the removed libnet context
Return values
NULL on failure

◆ libnet_cq_size()

LIBNET_API uint32_t libnet_cq_size ( void )

[Context Queue] Function returns the number of libnet contexts that are in the queue.

Returns
the number of libnet contexts currently in the queue

◆ libnet_destroy()

LIBNET_API void libnet_destroy ( libnet_t * l )

Shuts down the libnet session referenced by l. It closes the network interface and frees all internal memory structures associated with l.

Parameters
l pointer to a libnet context

◆ libnet_diag_dump_context()

LIBNET_API void libnet_diag_dump_context ( libnet_t * l )

[Diagnostic] Prints the contents of the given context.

Parameters
l pointer to a libnet context

◆ libnet_diag_dump_hex()

void libnet_diag_dump_hex | ( | const uint8_t * | packet,
 |  | uint32_t | len,
 |  | int | swap,
 |  | FILE * | stream
 | ) |  |

[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
packet | the packet to print
len | length of the packet in bytes
swap | 1 to swap byte order, 0 to not. 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).
stream | a stream pointer to print to

◆ libnet_diag_dump_pblock()

LIBNET_API void libnet_diag_dump_pblock ( libnet_t * l )

[Diagnostic] Prints the contents of every pblock.

Parameters
l pointer to a libnet context

◆ libnet_diag_dump_pblock_type()

LIBNET_API char* libnet_diag_dump_pblock_type ( uint8_t type )

[Diagnostic] Returns the canonical name of the pblock type.

Parameters
type pblock type
Returns
a string representing the pblock type type
Return values
unknown for an unknown value

◆ libnet_get_hwaddr()

LIBNET_API struct libnet_ether_addr* libnet_get_hwaddr ( libnet_t * l )

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
l pointer to a libnet context
Returns
a pointer to the MAC address or NULL

◆ libnet_get_ipaddr4()

LIBNET_API uint32_t libnet_get_ipaddr4 ( libnet_t * l )

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
l pointer to a libnet context
Returns
a big endian IP address suitable for use in a libnet_build function
Return values
-1

◆ libnet_get_ipaddr6()

LIBNET_API struct libnet_in6_addr libnet_get_ipaddr6 ( libnet_t * l )

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
l pointer to a libnet context
Return values
in6addr_error on failure

◆ libnet_get_prand()

LIBNET_API uint32_t libnet_get_prand ( int mod )

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
mod one the of LIBNET_PR* constants
Return values
1 | on success
-1 | on failure

◆ libnet_getdevice()

LIBNET_API const char* libnet_getdevice ( libnet_t * l )

Returns the canonical name of the device used for packet injection.

Parameters
l pointer to a libnet context
Returns
the canonical name of the device used for packet injection. Note it can be NULL without being an error.

◆ libnet_geterror()

LIBNET_API char* libnet_geterror ( libnet_t * l )

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
l pointer to a libnet context
Returns
an error string or NULL if no error has occurred

◆ libnet_getfd()

LIBNET_API int libnet_getfd ( libnet_t * l )

Returns the FILENO of the file descriptor used for packet injection.

Parameters
l pointer to a libnet context
Returns
the file number of the file descriptor used for packet injection

◆ libnet_getgre_length()

LIBNET_API uint32_t libnet_getgre_length ( uint16_t fv )
Parameters
fv see libnet_build_gre().
Returns
size
See also
libnet_build_gre().

◆ libnet_getpacket_size()

LIBNET_API uint32_t libnet_getpacket_size ( libnet_t * l )

Returns the sum of the size of all of the pblocks inside of l (this should be the resulting packet size).

Parameters
l pointer to a libnet context
Returns
the size of the packet in l

◆ libnet_getpbuf()

LIBNET_API uint8_t* libnet_getpbuf | ( | libnet_t * | l,
 |  | libnet_ptag_t | ptag
 | ) |  |

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
l | pointer to a libnet context
ptag | the ptag reference number
Returns
a pointer to the pblock buffer or NULL on error

◆ libnet_getpbuf_size()

LIBNET_API uint32_t libnet_getpbuf_size | ( | libnet_t * | l,
 |  | libnet_ptag_t | ptag
 | ) |  |

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
l | pointer to a libnet context
ptag | the ptag reference number
Returns
the size of the pblock buffer

◆ libnet_hex_aton()

LIBNET_API uint8_t* libnet_hex_aton | ( | const char * | s,
 |  | int * | len
 | ) |  |

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
s | the string to be parsed
len | the resulting size of the returned byte string
Returns
a byte string or NULL on failure

◆ libnet_in6_is_error()

LIBNET_API int libnet_in6_is_error ( struct libnet_in6_addr addr )

Check a libnet_in6_addr structure for identity with in6addr_error.

Parameters
addr address to check
Return values
1 | if addr is in6addr_error
0 | if it is not

◆ libnet_init()

LIBNET_API libnet_t* libnet_init | ( | int | injection_type,
 |  | const char * | device,
 |  | char * | err_buf
 | ) |  |

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
injection_type | packet injection type (LIBNET_LINK, LIBNET_LINK_ADV, LIBNET_RAW4, LIBNET_RAW4_ADV, LIBNET_RAW6, LIBNET_RAW6_ADV)
device | the interface to use (NULL and libnet will choose one)
err_buf | will contain an error message on failure
Returns
libnet context ready for use or NULL on error.

◆ libnet_name2addr4()

LIBNET_API uint32_t libnet_name2addr4 | ( | libnet_t * | l,
 |  | const char * | host_name,
 |  | uint8_t | use_name
 | ) |  |

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
l | pointer to a libnet context
host_name | pointer to a string containing a presentation format host name
use_name | LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
Returns
address in network byte order
Return values
-1 (2^32 - 1) on error

◆ libnet_name2addr6()

LIBNET_API struct libnet_in6_addr libnet_name2addr6 | ( | libnet_t * | l,
 |  | const char * | host_name,
 |  | uint8_t | use_name
 | ) |  |

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
l | pointer to a libnet context
host_name | pointer to a string containing a presentation format host name
use_name | LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
Returns
network byte ordered IPv6 address structure

◆ libnet_plist_chain_dump()

LIBNET_API int libnet_plist_chain_dump ( libnet_plist_t * plist )

Runs through the port list and prints the contents of the port list chain list to stdout.

Parameters
plist previously created portlist
Return values
1 | on success
-1 | on failure

◆ libnet_plist_chain_dump_string()

LIBNET_API char* libnet_plist_chain_dump_string ( libnet_plist_t * plist )

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
plist previously created portlist
Returns
a printable string containing the port list contents on success or NULL on error

◆ libnet_plist_chain_free()

LIBNET_API int libnet_plist_chain_free ( libnet_plist_t * plist )

Frees all memory associated with port list chain.

Parameters
plist previously created portlist
Return values
1 | on success
-1 | on failure

◆ libnet_plist_chain_new()

LIBNET_API int libnet_plist_chain_new | ( | libnet_t * | l,
 |  | libnet_plist_t ** | plist,
 |  | char * | token_list
 | ) |  |

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

  1. Upon failure, the function returns -1 and libnet_geterror() can tell you why.
    Parameters
    l | pointer to a libnet context
    plist | if successful, will refer to the portlist, if not, NULL
    token_list | string containing the port list primitive
    Return values
    1 | on success
    -1 | on failure

◆ libnet_plist_chain_next_pair()

LIBNET_API int libnet_plist_chain_next_pair | ( | libnet_plist_t * | plist,
 |  | uint16_t * | bport,
 |  | uint16_t * | eport
 | ) |  |

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
plist | previously created portlist
bport | will contain the beginning port number or 0
eport | will contain the ending port number or 0
Return values
1 | on success
0 | if empty
-1 | on failure

◆ libnet_seed_prand()

LIBNET_API int libnet_seed_prand ( libnet_t * l )

Seeds the pseudo-random number generator.

Parameters
l pointer to a libnet context
Return values
1 | on success
-1 | on failure

◆ libnet_stats()

LIBNET_API void libnet_stats | ( | libnet_t * | l,
 |  | struct libnet_stats * | ls
 | ) |  |

Fills in a libnet_stats structure with packet injection statistics (packets written, bytes written, packet sending errors).

Parameters
l | pointer to a libnet context
ls | pointer to a libnet statistics structure

◆ libnet_toggle_checksum()

LIBNET_API int libnet_toggle_checksum | ( | libnet_t * | l,
 |  | libnet_ptag_t | ptag,
 |  | int | mode
 | ) |  |

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
l | pointer to a libnet context
ptag | the ptag reference number
mode | LIBNET_ON or LIBNET_OFF
Return values
1 | on success
-1 | on failure

◆ libnet_version()

LIBNET_API const char* libnet_version ( void )

Returns the version of libnet.

Returns
the libnet version

◆ libnet_write()

LIBNET_API int libnet_write ( libnet_t * l )

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
l pointer to a libnet context
Returns
the number of bytes written
Return values
-1 on error


libnet: API Documentation: libnet-macros.h File Reference

  • libnet
Macros
libnet-macros.h File Reference

libnet macros and symbolic constants More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define | LIBNET_DONT_RESOLVE 0
#define | LIBNET_RESOLVE 1
#define | LIBNET_ON 0
#define | LIBNET_OFF 1
#define | IN6ADDR_ERROR_INIT
#define | LIBNET_PR2 0
#define | LIBNET_MAX_PACKET 0xffff
#define | LIBNET_ERRBUF_SIZE 0x100
#define | LIBNET_MAXOPTION_SIZE 0x28
#define | for_each_context_in_cq(l) for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next())

Detailed Description

libnet macros and symbolic constants

Macro Definition Documentation

◆ for_each_context_in_cq

#define for_each_context_in_cq ( l ) for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next())

Provides an interface to iterate through the context queue of libnet contexts. Before calling this macro, be sure to set the queue using libnet_cq_head().

◆ IN6ADDR_ERROR_INIT

#define IN6ADDR_ERROR_INIT
Value:
{ { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff } } }

IPv6 error code

◆ LIBNET_DONT_RESOLVE

#define LIBNET_DONT_RESOLVE 0

Used for libnet's name resolution functions, specifies that no DNS lookups should be performed and the IP address should be kept in numeric form.

◆ LIBNET_ERRBUF_SIZE

#define LIBNET_ERRBUF_SIZE 0x100

The libnet error buffer is 256 bytes long.

◆ LIBNET_MAX_PACKET

#define LIBNET_MAX_PACKET 0xffff

The biggest an IP packet can be – 65,535 bytes.

◆ LIBNET_MAXOPTION_SIZE

#define LIBNET_MAXOPTION_SIZE 0x28

IP and TCP options can be up to 40 bytes long.

◆ LIBNET_OFF

#define LIBNET_OFF 1

Used several places, to specify "on" or "one"

◆ LIBNET_ON

#define LIBNET_ON 0

Used several places, to specify "on" or "one"

◆ LIBNET_PR2

#define LIBNET_PR2 0

Used for libnet_get_prand() to specify function disposition

◆ LIBNET_RESOLVE

#define LIBNET_RESOLVE 1

Used for libnet's name resolution functions, specifies that a DNS lookup can be performed if needed to resolve the IP address to a canonical form.


libnet: API Documentation: libnet.h File Reference

libnet.h File Reference

Top-level libnet header file. More...

#include "./libnet/libnet-types.h"
#include "./libnet/libnet-macros.h"
#include "./libnet/libnet-headers.h"
#include "./libnet/libnet-structures.h"
#include "./libnet/libnet-asn1.h"
#include "./libnet/libnet-functions.h"
Include dependency graph for libnet.h:

Go to the source code of this file.

Detailed Description

Top-level libnet header file.

This section doesn't contain any details about libnet.h.

If you're wondering why, then that's mostly because libnet.h isn't where the action takes place. In fact, no action at all. Okay, maybe a little. But definitely not enough worth a separate man page or a detailed description. The real action goes down in some of the other files this file includes.

Which probably makes you wonder why, of all libnet*.h headers this file includes, only libnet-functions.h and libnet-macros.h are documented. My friend, you're not alone in your marveling.

You see, the guy who wrote them (Mike D. Schiffman) is gone, and the guy after him (Sam Roberts) didn't had much time left at the end of the day after bug fixing the living hell out of the source.

And if you're wondering why the rest of libnet's documentation is either full of holes or nonexistent, then (a) good question; and (b) see the previous paragraph.

Is this a sinking ship? Well, I can't answer that right now. What I can say is that it's just us now. So, "Lets (try to) make libnet great again"!

Sincerely,

Ali Abdulkadir


libnet: API Documentation: Globals

Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation:

- f -

  • for_each_context_in_cq : libnet-macros.h

- i -

  • IN6ADDR_ERROR_INIT : libnet-macros.h

- l -

  • libnet_addr2name4() : libnet-functions.h
  • libnet_addr2name6_r() : libnet-functions.h
  • libnet_adv_cull_header() : libnet-functions.h
  • libnet_adv_cull_packet() : libnet-functions.h
  • libnet_adv_free_packet() : libnet-functions.h
  • libnet_adv_write_link() : libnet-functions.h
  • libnet_adv_write_raw_ipv4() : libnet-functions.h
  • libnet_autobuild_arp() : libnet-functions.h
  • libnet_autobuild_ethernet() : libnet-functions.h
  • libnet_autobuild_fddi() : libnet-functions.h
  • libnet_autobuild_ipv4() : libnet-functions.h
  • libnet_autobuild_ipv6() : libnet-functions.h
  • libnet_autobuild_link() : libnet-functions.h
  • libnet_autobuild_token_ring() : libnet-functions.h
  • libnet_build_802_1q() : libnet-functions.h
  • libnet_build_802_1x() : libnet-functions.h
  • libnet_build_802_2() : libnet-functions.h
  • libnet_build_802_2snap() : libnet-functions.h
  • libnet_build_802_3() : libnet-functions.h
  • libnet_build_arp() : libnet-functions.h
  • libnet_build_bgp4_header() : libnet-functions.h
  • libnet_build_bgp4_notification() : libnet-functions.h
  • libnet_build_bgp4_open() : libnet-functions.h
  • libnet_build_bgp4_update() : libnet-functions.h
  • libnet_build_bootpv4() : libnet-functions.h
  • libnet_build_cdp() : libnet-functions.h
  • libnet_build_data() : libnet-functions.h
  • libnet_build_dhcpv4() : libnet-functions.h
  • libnet_build_dnsv4() : libnet-functions.h
  • libnet_build_egre() : libnet-functions.h
  • libnet_build_ethernet() : libnet-functions.h
  • libnet_build_fddi() : libnet-functions.h
  • libnet_build_gre() : libnet-functions.h
  • libnet_build_gre_last_sre() : libnet-functions.h
  • libnet_build_gre_sre() : libnet-functions.h
  • libnet_build_hsrp() : libnet-functions.h
  • libnet_build_icmpv4_echo() : libnet-functions.h
  • libnet_build_icmpv4_mask() : libnet-functions.h
  • libnet_build_icmpv4_redirect() : libnet-functions.h
  • libnet_build_icmpv4_timeexceed() : libnet-functions.h
  • libnet_build_icmpv4_timestamp() : libnet-functions.h
  • libnet_build_icmpv4_unreach() : libnet-functions.h
  • libnet_build_icmpv6_echo() : libnet-functions.h
  • libnet_build_icmpv6_ndp_nadv() : libnet-functions.h
  • libnet_build_icmpv6_ndp_nsol() : libnet-functions.h
  • libnet_build_icmpv6_ndp_opt() : libnet-functions.h
  • libnet_build_icmpv6_unreach() : libnet-functions.h
  • libnet_build_igmp() : libnet-functions.h
  • libnet_build_ipsec_ah() : libnet-functions.h
  • libnet_build_ipsec_esp_ftr() : libnet-functions.h
  • libnet_build_ipsec_esp_hdr() : libnet-functions.h
  • libnet_build_ipv4() : libnet-functions.h
  • libnet_build_ipv4_options() : libnet-functions.h
  • libnet_build_ipv6() : libnet-functions.h
  • libnet_build_ipv6_destopts() : libnet-functions.h
  • libnet_build_ipv6_frag() : libnet-functions.h
  • libnet_build_ipv6_hbhopts() : libnet-functions.h
  • libnet_build_ipv6_routing() : libnet-functions.h
  • libnet_build_isl() : libnet-functions.h
  • libnet_build_link() : libnet-functions.h
  • libnet_build_mpls() : libnet-functions.h
  • libnet_build_ntp() : libnet-functions.h
  • libnet_build_ospfv2() : libnet-functions.h
  • libnet_build_ospfv2_dbd() : libnet-functions.h
  • libnet_build_ospfv2_hello() : libnet-functions.h
  • libnet_build_ospfv2_hello_neighbor() : libnet-functions.h
  • libnet_build_ospfv2_lsa() : libnet-functions.h
  • libnet_build_ospfv2_lsa_as() : libnet-functions.h
  • libnet_build_ospfv2_lsa_net() : libnet-functions.h
  • libnet_build_ospfv2_lsa_rtr() : libnet-functions.h
  • libnet_build_ospfv2_lsa_sum() : libnet-functions.h
  • libnet_build_ospfv2_lsr() : libnet-functions.h
  • libnet_build_ospfv2_lsu() : libnet-functions.h
  • libnet_build_rip() : libnet-functions.h
  • libnet_build_rpc_call() : libnet-functions.h
  • libnet_build_sebek() : libnet-functions.h
  • libnet_build_stp_conf() : libnet-functions.h
  • libnet_build_stp_tcn() : libnet-functions.h
  • libnet_build_tcp() : libnet-functions.h
  • libnet_build_tcp_options() : libnet-functions.h
  • libnet_build_token_ring() : libnet-functions.h
  • libnet_build_udp() : libnet-functions.h
  • libnet_build_vrrp() : libnet-functions.h
  • libnet_clear_packet() : libnet-functions.h
  • libnet_cq_add() : libnet-functions.h
  • libnet_cq_destroy() : libnet-functions.h
  • libnet_cq_end_loop() : libnet-functions.h
  • libnet_cq_find_by_label() : libnet-functions.h
  • libnet_cq_getlabel() : libnet-functions.h
  • libnet_cq_head() : libnet-functions.h
  • libnet_cq_last() : libnet-functions.h
  • libnet_cq_next() : libnet-functions.h
  • libnet_cq_remove() : libnet-functions.h
  • libnet_cq_remove_by_label() : libnet-functions.h
  • libnet_cq_size() : libnet-functions.h
  • libnet_destroy() : libnet-functions.h
  • libnet_diag_dump_context() : libnet-functions.h
  • libnet_diag_dump_hex() : libnet-functions.h
  • libnet_diag_dump_pblock() : libnet-functions.h
  • libnet_diag_dump_pblock_type() : libnet-functions.h
  • LIBNET_DONT_RESOLVE : libnet-macros.h
  • LIBNET_ERRBUF_SIZE : libnet-macros.h
  • libnet_get_hwaddr() : libnet-functions.h
  • libnet_get_ipaddr4() : libnet-functions.h
  • libnet_get_ipaddr6() : libnet-functions.h
  • libnet_get_prand() : libnet-functions.h
  • libnet_getdevice() : libnet-functions.h
  • libnet_geterror() : libnet-functions.h
  • libnet_getfd() : libnet-functions.h
  • libnet_getgre_length() : libnet-functions.h
  • libnet_getpacket_size() : libnet-functions.h
  • libnet_getpbuf() : libnet-functions.h
  • libnet_getpbuf_size() : libnet-functions.h
  • libnet_hex_aton() : libnet-functions.h
  • libnet_in6_is_error() : libnet-functions.h
  • libnet_init() : libnet-functions.h
  • LIBNET_MAX_PACKET : libnet-macros.h
  • LIBNET_MAXOPTION_SIZE : libnet-macros.h
  • libnet_name2addr4() : libnet-functions.h
  • libnet_name2addr6() : libnet-functions.h
  • LIBNET_OFF : libnet-macros.h
  • LIBNET_ON : libnet-macros.h
  • libnet_plist_chain_dump() : libnet-functions.h
  • libnet_plist_chain_dump_string() : libnet-functions.h
  • libnet_plist_chain_free() : libnet-functions.h
  • libnet_plist_chain_new() : libnet-functions.h
  • libnet_plist_chain_next_pair() : libnet-functions.h
  • LIBNET_PR2 : libnet-macros.h
  • LIBNET_RESOLVE : libnet-macros.h
  • libnet_seed_prand() : libnet-functions.h
  • libnet_stats() : libnet-functions.h
  • libnet_toggle_checksum() : libnet-functions.h
  • libnet_version() : libnet-functions.h
  • libnet_write() : libnet-functions.h


libnet: API Documentation: Globals

- l -

  • libnet_addr2name4() : libnet-functions.h
  • libnet_addr2name6_r() : libnet-functions.h
  • libnet_adv_cull_header() : libnet-functions.h
  • libnet_adv_cull_packet() : libnet-functions.h
  • libnet_adv_free_packet() : libnet-functions.h
  • libnet_adv_write_link() : libnet-functions.h
  • libnet_adv_write_raw_ipv4() : libnet-functions.h
  • libnet_autobuild_arp() : libnet-functions.h
  • libnet_autobuild_ethernet() : libnet-functions.h
  • libnet_autobuild_fddi() : libnet-functions.h
  • libnet_autobuild_ipv4() : libnet-functions.h
  • libnet_autobuild_ipv6() : libnet-functions.h
  • libnet_autobuild_link() : libnet-functions.h
  • libnet_autobuild_token_ring() : libnet-functions.h
  • libnet_build_802_1q() : libnet-functions.h
  • libnet_build_802_1x() : libnet-functions.h
  • libnet_build_802_2() : libnet-functions.h
  • libnet_build_802_2snap() : libnet-functions.h
  • libnet_build_802_3() : libnet-functions.h
  • libnet_build_arp() : libnet-functions.h
  • libnet_build_bgp4_header() : libnet-functions.h
  • libnet_build_bgp4_notification() : libnet-functions.h
  • libnet_build_bgp4_open() : libnet-functions.h
  • libnet_build_bgp4_update() : libnet-functions.h
  • libnet_build_bootpv4() : libnet-functions.h
  • libnet_build_cdp() : libnet-functions.h
  • libnet_build_data() : libnet-functions.h
  • libnet_build_dhcpv4() : libnet-functions.h
  • libnet_build_dnsv4() : libnet-functions.h
  • libnet_build_egre() : libnet-functions.h
  • libnet_build_ethernet() : libnet-functions.h
  • libnet_build_fddi() : libnet-functions.h
  • libnet_build_gre() : libnet-functions.h
  • libnet_build_gre_last_sre() : libnet-functions.h
  • libnet_build_gre_sre() : libnet-functions.h
  • libnet_build_hsrp() : libnet-functions.h
  • libnet_build_icmpv4_echo() : libnet-functions.h
  • libnet_build_icmpv4_mask() : libnet-functions.h
  • libnet_build_icmpv4_redirect() : libnet-functions.h
  • libnet_build_icmpv4_timeexceed() : libnet-functions.h
  • libnet_build_icmpv4_timestamp() : libnet-functions.h
  • libnet_build_icmpv4_unreach() : libnet-functions.h
  • libnet_build_icmpv6_echo() : libnet-functions.h
  • libnet_build_icmpv6_ndp_nadv() : libnet-functions.h
  • libnet_build_icmpv6_ndp_nsol() : libnet-functions.h
  • libnet_build_icmpv6_ndp_opt() : libnet-functions.h
  • libnet_build_icmpv6_unreach() : libnet-functions.h
  • libnet_build_igmp() : libnet-functions.h
  • libnet_build_ipsec_ah() : libnet-functions.h
  • libnet_build_ipsec_esp_ftr() : libnet-functions.h
  • libnet_build_ipsec_esp_hdr() : libnet-functions.h
  • libnet_build_ipv4() : libnet-functions.h
  • libnet_build_ipv4_options() : libnet-functions.h
  • libnet_build_ipv6() : libnet-functions.h
  • libnet_build_ipv6_destopts() : libnet-functions.h
  • libnet_build_ipv6_frag() : libnet-functions.h
  • libnet_build_ipv6_hbhopts() : libnet-functions.h
  • libnet_build_ipv6_routing() : libnet-functions.h
  • libnet_build_isl() : libnet-functions.h
  • libnet_build_link() : libnet-functions.h
  • libnet_build_mpls() : libnet-functions.h
  • libnet_build_ntp() : libnet-functions.h
  • libnet_build_ospfv2() : libnet-functions.h
  • libnet_build_ospfv2_dbd() : libnet-functions.h
  • libnet_build_ospfv2_hello() : libnet-functions.h
  • libnet_build_ospfv2_hello_neighbor() : libnet-functions.h
  • libnet_build_ospfv2_lsa() : libnet-functions.h
  • libnet_build_ospfv2_lsa_as() : libnet-functions.h
  • libnet_build_ospfv2_lsa_net() : libnet-functions.h
  • libnet_build_ospfv2_lsa_rtr() : libnet-functions.h
  • libnet_build_ospfv2_lsa_sum() : libnet-functions.h
  • libnet_build_ospfv2_lsr() : libnet-functions.h
  • libnet_build_ospfv2_lsu() : libnet-functions.h
  • libnet_build_rip() : libnet-functions.h
  • libnet_build_rpc_call() : libnet-functions.h
  • libnet_build_sebek() : libnet-functions.h
  • libnet_build_stp_conf() : libnet-functions.h
  • libnet_build_stp_tcn() : libnet-functions.h
  • libnet_build_tcp() : libnet-functions.h
  • libnet_build_tcp_options() : libnet-functions.h
  • libnet_build_token_ring() : libnet-functions.h
  • libnet_build_udp() : libnet-functions.h
  • libnet_build_vrrp() : libnet-functions.h
  • libnet_clear_packet() : libnet-functions.h
  • libnet_cq_add() : libnet-functions.h
  • libnet_cq_destroy() : libnet-functions.h
  • libnet_cq_end_loop() : libnet-functions.h
  • libnet_cq_find_by_label() : libnet-functions.h
  • libnet_cq_getlabel() : libnet-functions.h
  • libnet_cq_head() : libnet-functions.h
  • libnet_cq_last() : libnet-functions.h
  • libnet_cq_next() : libnet-functions.h
  • libnet_cq_remove() : libnet-functions.h
  • libnet_cq_remove_by_label() : libnet-functions.h
  • libnet_cq_size() : libnet-functions.h
  • libnet_destroy() : libnet-functions.h
  • libnet_diag_dump_context() : libnet-functions.h
  • libnet_diag_dump_hex() : libnet-functions.h
  • libnet_diag_dump_pblock() : libnet-functions.h
  • libnet_diag_dump_pblock_type() : libnet-functions.h
  • libnet_get_hwaddr() : libnet-functions.h
  • libnet_get_ipaddr4() : libnet-functions.h
  • libnet_get_ipaddr6() : libnet-functions.h
  • libnet_get_prand() : libnet-functions.h
  • libnet_getdevice() : libnet-functions.h
  • libnet_geterror() : libnet-functions.h
  • libnet_getfd() : libnet-functions.h
  • libnet_getgre_length() : libnet-functions.h
  • libnet_getpacket_size() : libnet-functions.h
  • libnet_getpbuf() : libnet-functions.h
  • libnet_getpbuf_size() : libnet-functions.h
  • libnet_hex_aton() : libnet-functions.h
  • libnet_in6_is_error() : libnet-functions.h
  • libnet_init() : libnet-functions.h
  • libnet_name2addr4() : libnet-functions.h
  • libnet_name2addr6() : libnet-functions.h
  • libnet_plist_chain_dump() : libnet-functions.h
  • libnet_plist_chain_dump_string() : libnet-functions.h
  • libnet_plist_chain_free() : libnet-functions.h
  • libnet_plist_chain_new() : libnet-functions.h
  • libnet_plist_chain_next_pair() : libnet-functions.h
  • libnet_seed_prand() : libnet-functions.h
  • libnet_stats() : libnet-functions.h
  • libnet_toggle_checksum() : libnet-functions.h
  • libnet_version() : libnet-functions.h
  • libnet_write() : libnet-functions.h


libnet: API Documentation: Globals

  • for_each_context_in_cq : libnet-macros.h
  • IN6ADDR_ERROR_INIT : libnet-macros.h
  • LIBNET_DONT_RESOLVE : libnet-macros.h
  • LIBNET_ERRBUF_SIZE : libnet-macros.h
  • LIBNET_MAX_PACKET : libnet-macros.h
  • LIBNET_MAXOPTION_SIZE : libnet-macros.h
  • LIBNET_OFF : libnet-macros.h
  • LIBNET_ON : libnet-macros.h
  • LIBNET_PR2 : libnet-macros.h
  • LIBNET_RESOLVE : libnet-macros.h


libnet: API Documentation: libnet Directory Reference

  • libnet
libnet Directory Reference

Files

file | libnet-functions.h [code]
libnet exported function prototypes
file | libnet-macros.h [code]
libnet macros and symbolic constants


libnet: API Documentation: Graph Legend

Graph Legend

This page explains how to interpret the graphs that are generated by doxygen.

Consider the following example:

/*! Invisible class because of truncation */
class Invisible { };
/*! Truncated class, inheritance relation is hidden */
class Truncated : public Invisible { };
/* Class not documented with doxygen comments */
class Undocumented { };
/*! Class that is inherited using public inheritance */
class PublicBase : public Truncated { };
/*! A template class */
template<class T> class Templ { };
/*! Class that is inherited using protected inheritance */
class ProtectedBase { };
/*! Class that is inherited using private inheritance */
class PrivateBase { };
/*! Class that is used by the Inherited class */
class Used { };
/*! Super class that inherits a number of other classes */
class Inherited : public PublicBase,
protected ProtectedBase,
private PrivateBase,
public Undocumented,
public Templ<int>
{
private:
Used *m_usedClass;
};

This will result in the following graph:

The boxes in the above graph have the following meaning:

  • A filled gray box represents the struct or class for which the graph is generated.
  • A box with a black border denotes a documented struct or class.
  • A box with a gray border denotes an undocumented struct or class.
  • A box with a red border denotes a documented struct or class forwhich not all inheritance/containment relations are shown. A graph is truncated if it does not fit within the specified boundaries.

The arrows have the following meaning:

  • A dark blue arrow is used to visualize a public inheritance relation between two classes.
  • A dark green arrow is used for protected inheritance.
  • A dark red arrow is used for private inheritance.
  • A purple dashed arrow is used if a class is contained or used by another class. The arrow is labelled with the variable(s) through which the pointed class or struct is accessible.
  • A yellow dashed arrow denotes a relation between a template instance and the template class it was instantiated from. The arrow is labelled with the template parameters of the instance.


libnet: API Documentation: libnet-functions.h Source File

  • libnet
libnet-functions.h
Go to the documentation of this file.
1 /*
2 * libnet
3 * libnet-functions.h - function prototypes
4 *
5 * Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 */
30
31 #ifndef __LIBNET_FUNCTIONS_H
32 #define __LIBNET_FUNCTIONS_H
33
62 LIBNET_API
63 libnet_t *
64 libnet_init(int injection_type, const char *device, char *err_buf);
65
71 LIBNET_API
72 void
73 libnet_destroy(libnet_t *l);
74
81 LIBNET_API
82 void
83 libnet_clear_packet(libnet_t *l);
84
91 LIBNET_API
92 void
93 libnet_stats(libnet_t *l, struct libnet_stats *ls);
94
100 LIBNET_API
101 int
102 libnet_getfd(libnet_t *l);
103
110 LIBNET_API
111 const char *
112 libnet_getdevice(libnet_t *l);
113
122 LIBNET_API
123 uint8_t *
124 libnet_getpbuf(libnet_t *l, libnet_ptag_t ptag);
125
134 LIBNET_API
135 uint32_t
136 libnet_getpbuf_size(libnet_t *l, libnet_ptag_t ptag);
137
145 LIBNET_API
146 char *
147 libnet_geterror(libnet_t *l);
148
155 LIBNET_API
156 uint32_t
157 libnet_getpacket_size(libnet_t *l);
158
165 LIBNET_API
166 int
167 libnet_seed_prand(libnet_t *l);
168
183 LIBNET_API
184 uint32_t
185 libnet_get_prand(int mod);
186
209 LIBNET_API
210 int
211 libnet_toggle_checksum(libnet_t *l, libnet_ptag_t ptag, int mode);
212
225 LIBNET_API
226 char *
227 libnet_addr2name4(uint32_t in, uint8_t use_name);
228
243 LIBNET_API
244 uint32_t
245 libnet_name2addr4(libnet_t *l, const char *host_name, uint8_t use_name);
246
247 extern const struct libnet_in6_addr in6addr_error;
248
255 LIBNET_API
256 int
257 libnet_in6_is_error(struct libnet_in6_addr addr);
258
272 LIBNET_API
273 struct libnet_in6_addr
274 libnet_name2addr6(libnet_t *l, const char *host_name, uint8_t use_name);
275
279 LIBNET_API
280 void
281 libnet_addr2name6_r(struct libnet_in6_addr addr, uint8_t use_name,
282 char *host_name, int host_name_len);
283
300 LIBNET_API
301 int
302 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **plist, char *token_list);
303
317 LIBNET_API
318 int
319 libnet_plist_chain_next_pair(libnet_plist_t *plist, uint16_t *bport,
320 uint16_t *eport);
321
329 LIBNET_API
330 int
331 libnet_plist_chain_dump(libnet_plist_t *plist);
332
340 LIBNET_API
341 char *
342 libnet_plist_chain_dump_string(libnet_plist_t *plist);
343
350 LIBNET_API
351 int
352 libnet_plist_chain_free(libnet_plist_t *plist);
353
442 LIBNET_API
443 libnet_ptag_t
444 libnet_build_802_1q(const uint8_t *dst, const uint8_t *src, uint16_t tpi,
445 uint8_t priority, uint8_t cfi, uint16_t vlan_id, uint16_t len_proto,
446 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
447
460 LIBNET_API
461 libnet_ptag_t
462 libnet_build_802_1x(uint8_t eap_ver, uint8_t eap_type, uint16_t length,
463 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
464
477 LIBNET_API
478 libnet_ptag_t
479 libnet_build_802_2(uint8_t dsap, uint8_t ssap, uint8_t control,
480 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
481
496 LIBNET_API
497 libnet_ptag_t
498 libnet_build_802_2snap(uint8_t dsap, uint8_t ssap, uint8_t control,
499 uint8_t *oui, uint16_t type, const uint8_t* payload, uint32_t payload_s,
500 libnet_t *l, libnet_ptag_t ptag);
501
518 LIBNET_API
519 libnet_ptag_t
520 libnet_build_802_3(const uint8_t *dst, const uint8_t *src, uint16_t len,
521 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
522
539 LIBNET_API
540 libnet_ptag_t
541 libnet_build_ethernet(const uint8_t *dst, const uint8_t *src, uint16_t type,
542 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
543
556 LIBNET_API
557 libnet_ptag_t
558 libnet_autobuild_ethernet(const uint8_t *dst, uint16_t type, libnet_t *l);
559
577 LIBNET_API
578 libnet_ptag_t
579 libnet_build_fddi(uint8_t fc, const uint8_t *dst, const uint8_t *src, uint8_t dsap,
580 uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type, const uint8_t* payload,
581 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
582
596 LIBNET_API
597 libnet_ptag_t
598 libnet_autobuild_fddi(uint8_t fc, const uint8_t *dst, uint8_t dsap, uint8_t ssap,
599 uint8_t cf, const uint8_t *oui, uint16_t type, libnet_t *l);
600
621 LIBNET_API
622 libnet_ptag_t
623 libnet_build_arp(uint16_t hrd, uint16_t pro, uint8_t hln, uint8_t pln,
624 uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha, const uint8_t *tpa,
625 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
626
640 LIBNET_API
641 libnet_ptag_t
642 libnet_autobuild_arp(uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha,
643 uint8_t *tpa, libnet_t *l);
644
663 LIBNET_API
664 libnet_ptag_t
665 libnet_build_tcp(uint16_t sp, uint16_t dp, uint32_t seq, uint32_t ack,
666 uint8_t control, uint16_t win, uint16_t sum, uint16_t urg, uint16_t len,
667 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
668
685 LIBNET_API
686 libnet_ptag_t
687 libnet_build_tcp_options(const uint8_t *options, uint32_t options_s, libnet_t *l,
688 libnet_ptag_t ptag);
689
703 LIBNET_API
704 libnet_ptag_t
705 libnet_build_udp(uint16_t sp, uint16_t dp, uint16_t len, uint16_t sum,
706 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
707
728 LIBNET_API
729 libnet_ptag_t
730 libnet_build_cdp(uint8_t version, uint8_t ttl, uint16_t sum, uint16_t type,
731 uint16_t value_s, const uint8_t *value, const uint8_t* payload, uint32_t payload_s,
732 libnet_t *l, libnet_ptag_t ptag);
733
749 LIBNET_API
750 libnet_ptag_t
751 libnet_build_icmpv4_echo(uint8_t type, uint8_t code, uint16_t sum,
752 uint16_t id, uint16_t seq, const uint8_t* payload, uint32_t payload_s,
753 libnet_t *l, libnet_ptag_t ptag);
754
771 LIBNET_API
772 libnet_ptag_t
773 libnet_build_icmpv4_mask(uint8_t type, uint8_t code, uint16_t sum,
774 uint16_t id, uint16_t seq, uint32_t mask, const uint8_t* payload,
775 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
776
791 LIBNET_API
792 libnet_ptag_t
793 libnet_build_icmpv4_unreach(uint8_t type, uint8_t code, uint16_t sum,
794 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
795
811 LIBNET_API
812 libnet_ptag_t
813 libnet_build_icmpv4_redirect(uint8_t type, uint8_t code, uint16_t sum,
814 uint32_t gateway, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
815 libnet_ptag_t ptag);
816
832 LIBNET_API
833 libnet_ptag_t
834 libnet_build_icmpv4_timeexceed(uint8_t type, uint8_t code, uint16_t sum,
835 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
836
855 LIBNET_API
856 libnet_ptag_t
857 libnet_build_icmpv4_timestamp(uint8_t type, uint8_t code, uint16_t sum,
858 uint16_t id, uint16_t seq, uint32_t otime, uint32_t rtime, uint32_t ttime,
859 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
860
876 LIBNET_API
877 libnet_ptag_t libnet_build_icmpv6_echo(uint8_t type, uint8_t code, uint16_t
878 sum, uint16_t id, uint16_t seq, uint8_t *payload, uint32_t payload_s,
879 libnet_t *l, libnet_ptag_t ptag);
880
895 LIBNET_API
896 libnet_ptag_t
897 libnet_build_icmpv6_unreach(uint8_t type, uint8_t code, uint16_t sum,
898 uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
899
915 LIBNET_API
916 libnet_ptag_t libnet_build_icmpv6_ndp_nsol(uint8_t type, uint8_t code,
917 uint16_t sum, struct libnet_in6_addr target, uint8_t *payload, uint32_t
918 payload_s, libnet_t* l, libnet_ptag_t ptag);
919
936 LIBNET_API
937 libnet_ptag_t libnet_build_icmpv6_ndp_nadv(uint8_t type, uint8_t code,
938 uint16_t sum, uint32_t flags, struct libnet_in6_addr target, uint8_t
939 *payload, uint32_t payload_s, libnet_t* l, libnet_ptag_t ptag);
940
951 LIBNET_API
952 libnet_ptag_t libnet_build_icmpv6_ndp_opt(uint8_t type, uint8_t* option,
953 uint32_t option_s, libnet_t* l, libnet_ptag_t ptag);
954
970 LIBNET_API
971 libnet_ptag_t
972 libnet_build_igmp(uint8_t type, uint8_t reserved, uint16_t sum, uint32_t ip,
973 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
974
995 LIBNET_API
996 libnet_ptag_t
997 libnet_build_ipv4(uint16_t ip_len, uint8_t tos, uint16_t id, uint16_t frag,
998 uint8_t ttl, uint8_t prot, uint16_t sum, uint32_t src, uint32_t dst,
999 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1000
1020 LIBNET_API
1021 libnet_ptag_t
1022 libnet_build_ipv4_options(const uint8_t *options, uint32_t options_s, libnet_t *l,
1023 libnet_ptag_t ptag);
1024
1039 LIBNET_API
1040 libnet_ptag_t
1041 libnet_autobuild_ipv4(uint16_t len, uint8_t prot, uint32_t dst, libnet_t *l);
1042
1059 LIBNET_API
1060 libnet_ptag_t
1061 libnet_build_ipv6(uint8_t tc, uint32_t fl, uint16_t len, uint8_t nh,
1062 uint8_t hl, struct libnet_in6_addr src, struct libnet_in6_addr dst,
1063 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1064
1078 LIBNET_API
1079 libnet_ptag_t
1080 libnet_build_ipv6_frag(uint8_t nh, uint8_t reserved, uint16_t frag,
1081 uint32_t id, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1082 libnet_ptag_t ptag);
1083
1102 LIBNET_API
1103 libnet_ptag_t
1104 libnet_build_ipv6_routing(uint8_t nh, uint8_t len, uint8_t rtype,
1105 uint8_t segments, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1106 libnet_ptag_t ptag);
1107
1122 LIBNET_API
1123 libnet_ptag_t
1124 libnet_build_ipv6_destopts(uint8_t nh, uint8_t len, const uint8_t* payload,
1125 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1126
1142 LIBNET_API
1143 libnet_ptag_t
1144 libnet_build_ipv6_hbhopts(uint8_t nh, uint8_t len, const uint8_t* payload,
1145 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1146
1164 LIBNET_API
1165 libnet_ptag_t
1166 libnet_autobuild_ipv6(uint16_t len, uint8_t nh, struct libnet_in6_addr dst,
1167 libnet_t *l, libnet_ptag_t ptag);
1168
1187 LIBNET_API
1188 libnet_ptag_t
1189 libnet_build_isl(uint8_t *dhost, uint8_t type, uint8_t user,
1190 uint8_t *shost, uint16_t len, const uint8_t *snap, uint16_t vid,
1191 uint16_t portindex, uint16_t reserved, const uint8_t* payload,
1192 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1193
1206 LIBNET_API
1207 libnet_ptag_t
1208 libnet_build_ipsec_esp_hdr(uint32_t spi, uint32_t seq, uint32_t iv,
1209 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1210
1223 LIBNET_API
1224 libnet_ptag_t
1225 libnet_build_ipsec_esp_ftr(uint8_t len, uint8_t nh, int8_t *auth,
1226 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1227
1243 LIBNET_API
1244 libnet_ptag_t
1245 libnet_build_ipsec_ah(uint8_t nh, uint8_t len, uint16_t res,
1246 uint32_t spi, uint32_t seq, uint32_t auth, const uint8_t* payload,
1247 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1248
1266 LIBNET_API
1267 libnet_ptag_t
1268 libnet_build_dnsv4(uint16_t h_len, uint16_t id, uint16_t flags,
1269 uint16_t num_q, uint16_t num_anws_rr, uint16_t num_auth_rr,
1270 uint16_t num_addi_rr, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1271 libnet_ptag_t ptag);
1272
1291 LIBNET_API
1292 libnet_ptag_t
1293 libnet_build_rip(uint8_t cmd, uint8_t version, uint16_t rd, uint16_t af,
1294 uint16_t rt, uint32_t addr, uint32_t mask, uint32_t next_hop,
1295 uint32_t metric, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1296 libnet_ptag_t ptag);
1297
1321 LIBNET_API
1322 libnet_ptag_t
1323 libnet_build_rpc_call(uint32_t rm, uint32_t xid, uint32_t prog_num,
1324 uint32_t prog_vers, uint32_t procedure, uint32_t cflavor, uint32_t clength,
1325 uint8_t *cdata, uint32_t vflavor, uint32_t vlength, const uint8_t *vdata,
1326 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1327
1351 LIBNET_API
1352 libnet_ptag_t
1353 libnet_build_stp_conf(uint16_t id, uint8_t version, uint8_t bpdu_type,
1354 uint8_t flags, const uint8_t *root_id, uint32_t root_pc, const uint8_t *bridge_id,
1355 uint16_t port_id, uint16_t message_age, uint16_t max_age,
1356 uint16_t hello_time, uint16_t f_delay, const uint8_t* payload,
1357 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1358
1373 LIBNET_API
1374 libnet_ptag_t
1375 libnet_build_stp_tcn(uint16_t id, uint8_t version, uint8_t bpdu_type,
1376 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1377
1396 LIBNET_API
1397 libnet_ptag_t
1398 libnet_build_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst, const uint8_t *src,
1399 uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
1400 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1401
1416 LIBNET_API
1417 libnet_ptag_t
1418 libnet_autobuild_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst,
1419 uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
1420 libnet_t *l);
1421
1442 LIBNET_API
1443 libnet_ptag_t
1444 libnet_build_vrrp(uint8_t version, uint8_t type, uint8_t vrouter_id,
1445 uint8_t priority, uint8_t ip_count, uint8_t auth_type, uint8_t advert_int,
1446 uint16_t sum, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1447 libnet_ptag_t ptag);
1448
1462 LIBNET_API
1463 libnet_ptag_t
1464 libnet_build_mpls(uint32_t label, uint8_t experimental, uint8_t bos,
1465 uint8_t ttl, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1466 libnet_ptag_t ptag);
1467
1496 LIBNET_API
1497 libnet_ptag_t
1498 libnet_build_ntp(uint8_t leap_indicator, uint8_t version, uint8_t mode,
1499 uint8_t stratum, uint8_t poll, uint8_t precision, uint16_t delay_int,
1500 uint16_t delay_frac, uint16_t dispersion_int, uint16_t dispersion_frac,
1501 uint32_t reference_id, uint32_t ref_ts_int, uint32_t ref_ts_frac,
1502 uint32_t orig_ts_int, uint32_t orig_ts_frac, uint32_t rec_ts_int,
1503 uint32_t rec_ts_frac, uint32_t xmt_ts_int, uint32_t xmt_ts_frac,
1504 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1505
1520 LIBNET_API
1521 libnet_ptag_t
1522 libnet_build_ospfv2(uint16_t len, uint8_t type, uint32_t rtr_id,
1523 uint32_t area_id, uint16_t sum, uint16_t autype, const uint8_t* payload,
1524 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1525
1541 LIBNET_API
1542 libnet_ptag_t
1543 libnet_build_ospfv2_hello(uint32_t netmask, uint16_t interval, uint8_t opts,
1544 uint8_t priority, uint32_t dead_int, uint32_t des_rtr, uint32_t bkup_rtr,
1545 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1546
1563 libnet_ptag_t
1564 libnet_build_ospfv2_hello_neighbor(uint32_t netmask, uint16_t interval, uint8_t opts,
1565 uint8_t priority, uint32_t dead_int, uint32_t des_rtr, uint32_t bkup_rtr, uint32_t neighbor,
1566 const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1567
1580 LIBNET_API
1581 libnet_ptag_t
1582 libnet_build_ospfv2_dbd(uint16_t dgram_len, uint8_t opts, uint8_t type,
1583 uint32_t seqnum, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1584 libnet_ptag_t ptag);
1585
1597 LIBNET_API
1598 libnet_ptag_t
1599 libnet_build_ospfv2_lsr(uint32_t type, uint32_t lsid, uint32_t advrtr,
1600 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1601
1611 LIBNET_API
1612 libnet_ptag_t
1613 libnet_build_ospfv2_lsu(uint32_t num, const uint8_t* payload, uint32_t payload_s,
1614 libnet_t *l, libnet_ptag_t ptag);
1615
1632 LIBNET_API
1633 libnet_ptag_t
1634 libnet_build_ospfv2_lsa(uint16_t age, uint8_t opts, uint8_t type,
1635 uint32_t lsid, uint32_t advrtr, uint32_t seqnum, uint16_t sum, uint16_t len,
1636 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1637
1653 LIBNET_API
1654 libnet_ptag_t
1655 libnet_build_ospfv2_lsa_rtr(uint16_t flags, uint16_t num, uint32_t id,
1656 uint32_t data, uint8_t type, uint8_t tos, uint16_t metric, const uint8_t* payload,
1657 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1658
1669 LIBNET_API
1670 libnet_ptag_t
1671 libnet_build_ospfv2_lsa_net(uint32_t nmask, uint32_t rtrid, const uint8_t* payload,
1672 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1673
1685 LIBNET_API
1686 libnet_ptag_t
1687 libnet_build_ospfv2_lsa_sum(uint32_t nmask, uint32_t metric, uint32_t tos,
1688 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1689
1702 LIBNET_API
1703 libnet_ptag_t
1704 libnet_build_ospfv2_lsa_as(uint32_t nmask, uint32_t metric, uint32_t fwdaddr,
1705 uint32_t tag, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1706 libnet_ptag_t ptag);
1707
1720 LIBNET_API
1721 libnet_ptag_t
1722 libnet_build_data(const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1723 libnet_ptag_t ptag);
1724
1747 LIBNET_API
1748 libnet_ptag_t
1749 libnet_build_dhcpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
1750 uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
1751 uint32_t cip, uint32_t yip, uint32_t sip, uint32_t gip, const uint8_t *chaddr,
1752 const char *sname, const char *file, const uint8_t* payload, uint32_t payload_s,
1753 libnet_t *l, libnet_ptag_t ptag);
1754
1777 LIBNET_API
1778 libnet_ptag_t
1779 libnet_build_bootpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
1780 uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
1781 uint32_t cip, uint32_t yip, uint32_t sip, uint32_t gip, const uint8_t *chaddr,
1782 const char *sname, const char *file, const uint8_t* payload, uint32_t payload_s,
1783 libnet_t *l, libnet_ptag_t ptag);
1784
1790 LIBNET_API
1791 uint32_t
1792 libnet_getgre_length(uint16_t fv);
1793
1817 LIBNET_API
1818 libnet_ptag_t
1819 libnet_build_gre(uint16_t fv, uint16_t type, uint16_t sum,
1820 uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
1821 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1822
1845 LIBNET_API
1846 libnet_ptag_t
1847 libnet_build_egre(uint16_t fv, uint16_t type, uint16_t sum,
1848 uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
1849 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1850
1863 LIBNET_API
1864 libnet_ptag_t
1865 libnet_build_gre_sre(uint16_t af, uint8_t offset, uint8_t length,
1866 uint8_t *routing, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1867 libnet_ptag_t ptag);
1868
1875 LIBNET_API
1876 libnet_ptag_t
1877 libnet_build_gre_last_sre(libnet_t *l, libnet_ptag_t ptag);
1878
1901 LIBNET_API
1902 libnet_ptag_t
1903 libnet_build_bgp4_header(uint8_t marker[LIBNET_BGP4_MARKER_SIZE],
1904 uint16_t len, uint8_t type, const uint8_t* payload, uint32_t payload_s,
1905 libnet_t *l, libnet_ptag_t ptag);
1906
1924 LIBNET_API
1925 libnet_ptag_t
1926 libnet_build_bgp4_open(uint8_t version, uint16_t src_as, uint16_t hold_time,
1927 uint32_t bgp_id, uint8_t opt_len, const uint8_t* payload, uint32_t payload_s,
1928 libnet_t *l, libnet_ptag_t ptag);
1929
1946 LIBNET_API
1947 libnet_ptag_t
1948 libnet_build_bgp4_update(uint16_t unfeasible_rt_len, const uint8_t *withdrawn_rt,
1949 uint16_t total_path_attr_len, const uint8_t *path_attributes, uint16_t info_len,
1950 uint8_t *reachability_info, const uint8_t* payload, uint32_t payload_s,
1951 libnet_t *l, libnet_ptag_t ptag);
1952
1966 LIBNET_API
1967 libnet_ptag_t
1968 libnet_build_bgp4_notification(uint8_t err_code, uint8_t err_subcode,
1969 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1970
1993 LIBNET_API
1994 libnet_ptag_t
1995 libnet_build_sebek(uint32_t magic, uint16_t version, uint16_t type,
1996 uint32_t counter, uint32_t time_sec, uint32_t time_usec, uint32_t pid,
1997 uint32_t uid, uint32_t fd, uint8_t cmd[SEBEK_CMD_LENGTH], uint32_t length,
1998 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1999
2020 LIBNET_API
2021 libnet_ptag_t
2022 libnet_build_hsrp(uint8_t version, uint8_t opcode, uint8_t state,
2023 uint8_t hello_time, uint8_t hold_time, uint8_t priority, uint8_t group,
2024 uint8_t reserved, uint8_t authdata[HSRP_AUTHDATA_LENGTH], uint32_t virtual_ip,
2025 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
2026
2042 LIBNET_API
2043 libnet_ptag_t
2044 libnet_build_link(const uint8_t *dst, const uint8_t *src, const uint8_t *oui, uint16_t type,
2045 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
2046
2058 LIBNET_API
2059 libnet_ptag_t
2060 libnet_autobuild_link(const uint8_t *dst, const uint8_t *oui, uint16_t type,
2061 libnet_t *l);
2062
2076 LIBNET_API
2077 int
2078 libnet_write(libnet_t *l);
2079
2089 LIBNET_API
2090 uint32_t
2091 libnet_get_ipaddr4(libnet_t *l);
2092
2102 LIBNET_API
2103 struct libnet_in6_addr
2104 libnet_get_ipaddr6(libnet_t *l);
2105
2114 LIBNET_API
2115 struct libnet_ether_addr *
2116 libnet_get_hwaddr(libnet_t *l);
2117
2127 LIBNET_API
2128 uint8_t *
2129 libnet_hex_aton(const char *s, int *len);
2130
2135 LIBNET_API
2136 const char *
2137 libnet_version(void);
2138
2155 LIBNET_API
2156 int
2157 libnet_adv_cull_packet(libnet_t *l, uint8_t **packet, uint32_t *packet_s);
2158
2172 LIBNET_API
2173 int
2174 libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, uint8_t **header,
2175 uint32_t *header_s);
2176
2191 LIBNET_API
2192 int
2193 libnet_adv_write_link(libnet_t *l, const uint8_t *packet, uint32_t packet_s);
2194
2209 LIBNET_API
2210 int
2211 libnet_adv_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t packet_s);
2212
2219 LIBNET_API
2220 void
2221 libnet_adv_free_packet(libnet_t *l, uint8_t *packet);
2222
2237 int
2238 libnet_cq_add(libnet_t *l, char *label);
2239
2255 LIBNET_API
2256 libnet_t *
2257 libnet_cq_remove(libnet_t *l);
2258
2271 LIBNET_API
2272 libnet_t *
2273 libnet_cq_remove_by_label(char *label);
2274
2281 LIBNET_API
2282 const char *
2283 libnet_cq_getlabel(libnet_t *l);
2284
2292 LIBNET_API
2293 libnet_t *
2294 libnet_cq_find_by_label(char *label);
2295
2301 LIBNET_API
2302 void
2303 libnet_cq_destroy(void);
2304
2324 LIBNET_API
2325 libnet_t *
2326 libnet_cq_head(void);
2327
2334 LIBNET_API
2335 int
2336 libnet_cq_last(void);
2337
2343 LIBNET_API
2344 libnet_t *
2345 libnet_cq_next(void);
2346
2352 LIBNET_API
2353 uint32_t
2354 libnet_cq_size(void);
2355
2359 LIBNET_API
2360 uint32_t
2361 libnet_cq_end_loop(void);
2362
2368 LIBNET_API
2369 void
2370 libnet_diag_dump_context(libnet_t *l);
2371
2377 LIBNET_API
2378 void
2379 libnet_diag_dump_pblock(libnet_t *l);
2380
2388 LIBNET_API
2389 char *
2390 libnet_diag_dump_pblock_type(uint8_t type);
2391
2405 void
2406 libnet_diag_dump_hex(const uint8_t *packet, uint32_t len, int swap, FILE *stream);
2407
2408 /*
2409 * [Internal]
2410 */
2411 LIBNET_API
2412 int
2413 libnet_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t size);
2414
2415 /*
2416 * [Internal]
2417 */
2418 LIBNET_API
2419 int
2420 libnet_write_raw_ipv6(libnet_t *l, const uint8_t *packet, uint32_t size);
2421
2422 /*
2423 * [Internal]
2424 */
2425 LIBNET_API
2426 int
2427 libnet_write_link(libnet_t *l, const uint8_t *packet, uint32_t size);
2428
2429 /*
2430 * [Internal]
2431 */
2432 int
2433 libnet_open_raw4(libnet_t *l);
2434
2435 /*
2436 * [Internal]
2437 */
2438 LIBNET_API
2439 int
2440 libnet_close_raw4(libnet_t *l);
2441
2442 /*
2443 * [Internal]
2444 */
2445 int
2446 libnet_open_raw6(libnet_t *l);
2447
2448 /*
2449 * [Internal]
2450 */
2451 int
2452 libnet_close_raw6(libnet_t *l);
2453
2454 /*
2455 * [Internal]
2456 */
2457 int
2458 libnet_select_device(libnet_t *l);
2459
2460 /*
2461 * [Internal]
2462 */
2463 int
2464 libnet_open_link(libnet_t *l);
2465
2466 /*
2467 * [Internal]
2468 */
2469 int
2470 libnet_close_link(libnet_t *l);
2471
2472 /*
2473 * [Internal]
2474 * THIS FUNCTION IS BROKEN. IT WILL SEGFAULT OR CORRUPT MEMORY, OR JUST SILENTLY DO THE
2475 * WRONG THING IF NOT CALLED CORRECTLY, AND CALLING IT CORRECTLY IS UNDOCUMENTED, AND
2476 * ALMOST IMPOSSIBLE. YOU HAVE BEEN WARNED.
2477 */
2478 int
2479 libnet_do_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len);
2480
2481 /* Calculate internet checksums.
2482 *
2483 * IP (TCP, UDP, IGMP, ICMP, etc...) checksums usually need information from
2484 * the IP header to construct the "pseudo header", this function takes a
2485 * pointer to that header, the buffer boundaries, the "h_len" (see pblock_t for
2486 * a description, it is increasingly unused, though, and I'm trying to remove it
2487 * altogether), and the protocol number for the protocol that is to be
2488 * checksummed.
2489 *
2490 * Finding that protocol requires that the IP header be well-formed... so this
2491 * won't work well for invalid packets. But then, what is the valid checksum
2492 * for a invalid packet, anyhow?
2493 *
2494 * This doesn't work well for non-inet checksums, sorry, that's an original design
2495 * flaw. pblock_t needs a pointer in it, to a packet assembly function that can be
2496 * called at runtime to do assembly and checksumming.
2497 */
2498 LIBNET_API
2499 int
2500 libnet_inet_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len, const uint8_t *beg, const uint8_t * end);
2501
2502 /*
2503 * [Internal]
2504 */
2505 LIBNET_API
2506 uint32_t
2507 libnet_compute_crc(uint8_t *buf, uint32_t len);
2508
2509 /*
2510 * [Internal]
2511 */
2512 LIBNET_API
2513 uint16_t
2514 libnet_ip_check(uint16_t *addr, int len);
2515
2516 /*
2517 * [Internal]
2518 */
2519 LIBNET_API
2520 int
2521 libnet_in_cksum(uint16_t *addr, int len);
2522
2523 /*
2524 * [Internal]
2525 * If ptag is 0, function will create a pblock for the protocol unit type,
2526 * append it to the list and return a pointer to it. If ptag is not 0,
2527 * function will search the pblock list for the specified protocol block
2528 * and return a pointer to it.
2529 */
2530 LIBNET_API
2531 libnet_pblock_t *
2532 libnet_pblock_probe(libnet_t *l, libnet_ptag_t ptag, uint32_t b_len,
2533 uint8_t type);
2534
2535 /*
2536 * [Internal]
2537 * Function creates the pblock list if l->protocol_blocks == NULL or appends
2538 * an entry to the doubly linked list.
2539 */
2540 LIBNET_API
2541 libnet_pblock_t *
2542 libnet_pblock_new(libnet_t *l, uint32_t b_len);
2543
2544 /*
2545 * [Internal]
2546 * Function swaps two pblocks in memory.
2547 */
2548 LIBNET_API
2549 int
2550 libnet_pblock_swap(libnet_t *l, libnet_ptag_t ptag1, libnet_ptag_t ptag2);
2551
2552 /*
2553 * [Internal]
2554 * Function inserts ptag2 before ptag1 in the doubly linked list.
2555 */
2556 LIBNET_API
2557 int
2558 libnet_pblock_insert_before(libnet_t *l, libnet_ptag_t ptag1,
2559 libnet_ptag_t ptag2);
2560
2561 /*
2562 * [Internal]
2563 * Function removes a pblock from context
2564 */
2565 LIBNET_API
2566 void
2567 libnet_pblock_delete(libnet_t *l, libnet_pblock_t *p);
2568
2569 /*
2570 * [Internal]
2571 * Function updates the pblock meta-information. Internally it updates the
2572 * ptag with a monotonically increasing variable kept in l. This way each
2573 * pblock has a successively increasing ptag identifier.
2574 */
2575 LIBNET_API
2576 libnet_ptag_t
2577 libnet_pblock_update(libnet_t *l, libnet_pblock_t *p, uint32_t h, uint8_t type);
2578
2579
2580 /*
2581 * [Internal]
2582 * Function locates a given block by it's ptag.
2583 */
2584 LIBNET_API
2585 libnet_pblock_t *
2586 libnet_pblock_find(libnet_t *l, libnet_ptag_t ptag);
2587
2588 /*
2589 * [Internal]
2590 * Function copies protocol block data over.
2591 */
2592 LIBNET_API
2593 int
2594 libnet_pblock_append(libnet_t *l, libnet_pblock_t *p, const void *buf, uint32_t len);
2595
2596 /*
2597 * [Internal]
2598 * Function sets pblock flags.
2599 */
2600 LIBNET_API
2601 void
2602 libnet_pblock_setflags(libnet_pblock_t *p, uint8_t flags);
2603
2604 /*
2605 * [Internal]
2606 * Function returns the protocol number for the protocol block type. If
2607 * the type is unknown, the function defaults to returning IPPROTO_IP.
2608 */
2609 LIBNET_API
2610 int
2611 libnet_pblock_p2p(uint8_t type);
2612
2613 /*
2614 * [Internal]
2615 * Function assembles the protocol blocks into a packet, checksums are
2616 * calculated if that was requested.
2617 */
2618 LIBNET_API
2619 int
2620 libnet_pblock_coalesce(libnet_t *l, uint8_t **packet, uint32_t *size);
2621
2622 #if !(__WIN32__)
2623 /*
2624 * [Internal]
2625 * By testing if we can retrieve the FLAGS of an interface
2626 * we can know if it exists or not and if it is up.
2627 */
2628 int
2629 libnet_check_iface(libnet_t *l);
2630 #endif
2631
2632 #if defined(__WIN32__)
2633 /*
2634 * [Internal]
2635 */
2636 BYTE *
2637 libnet_win32_get_remote_mac(libnet_t *l, DWORD IP);
2638
2639 /*
2640 * [Internal]
2641 */
2642 int
2643 libnet_close_link_interface(libnet_t *l);
2644
2645 /*
2646 * [Internal]
2647 */
2648 BYTE *
2649 libnet_win32_read_arp_table(DWORD IP);
2650 #endif
2651 #endif /* __LIBNET_FUNCTIONS_H */
2652
2653 /* EOF */
libnet_write
LIBNET_API int libnet_write(libnet_t *l)
libnet_build_802_1q
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_build_ospfv2_dbd
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_build_igmp
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_build_bgp4_notification
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_build_bgp4_update
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_build_ospfv2_lsu
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_autobuild_ethernet
LIBNET_API libnet_ptag_t libnet_autobuild_ethernet(const uint8_t *dst, uint16_t type, libnet_t *l)
libnet_getgre_length
LIBNET_API uint32_t libnet_getgre_length(uint16_t fv)
libnet_build_ospfv2_hello_neighbor
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_get_hwaddr
LIBNET_API struct libnet_ether_addr * libnet_get_hwaddr(libnet_t *l)
libnet_build_ipv4_options
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_build_stp_tcn
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_getfd
LIBNET_API int libnet_getfd(libnet_t *l)
libnet_stats
LIBNET_API void libnet_stats(libnet_t *l, struct libnet_stats *ls)
libnet_cq_next
LIBNET_API libnet_t * libnet_cq_next(void)
libnet_build_802_1x
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_cq_find_by_label
LIBNET_API libnet_t * libnet_cq_find_by_label(char *label)
libnet_in6_is_error
LIBNET_API int libnet_in6_is_error(struct libnet_in6_addr addr)
libnet_build_ipv6_destopts
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_get_ipaddr6
LIBNET_API struct libnet_in6_addr libnet_get_ipaddr6(libnet_t *l)
libnet_build_ethernet
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_plist_chain_dump
LIBNET_API int libnet_plist_chain_dump(libnet_plist_t *plist)
libnet_autobuild_link
LIBNET_API libnet_ptag_t libnet_autobuild_link(const uint8_t *dst, const uint8_t *oui, uint16_t type, libnet_t *l)
libnet_build_stp_conf
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_diag_dump_pblock
LIBNET_API void libnet_diag_dump_pblock(libnet_t *l)
libnet_build_fddi
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_build_ipv4
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_build_802_2snap
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_plist_chain_new
LIBNET_API int libnet_plist_chain_new(libnet_t *l, libnet_plist_t **plist, char *token_list)
libnet_build_ipv6_routing
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_build_ospfv2
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_build_ipsec_esp_ftr
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_build_tcp_options
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_build_cdp
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_autobuild_ipv6
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_build_ospfv2_hello
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_build_vrrp
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_cq_remove_by_label
LIBNET_API libnet_t * libnet_cq_remove_by_label(char *label)
libnet_build_hsrp
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_seed_prand
LIBNET_API int libnet_seed_prand(libnet_t *l)
libnet_adv_cull_header
LIBNET_API int libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, uint8_t **header, uint32_t *header_s)
libnet_build_egre
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_build_ipv6
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_plist_chain_free
LIBNET_API int libnet_plist_chain_free(libnet_plist_t *plist)
libnet_build_tcp
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_autobuild_fddi
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_build_bgp4_header
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_build_icmpv4_timestamp
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_build_arp
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_name2addr4
LIBNET_API uint32_t libnet_name2addr4(libnet_t *l, const char *host_name, uint8_t use_name)
libnet_build_ospfv2_lsa
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_cq_destroy
LIBNET_API void libnet_cq_destroy(void)
libnet_build_ipsec_ah
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_build_gre
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_cq_size
LIBNET_API uint32_t libnet_cq_size(void)
libnet_build_ospfv2_lsa_sum
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_build_icmpv4_mask
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_toggle_checksum
LIBNET_API int libnet_toggle_checksum(libnet_t *l, libnet_ptag_t ptag, int mode)
libnet_get_ipaddr4
LIBNET_API uint32_t libnet_get_ipaddr4(libnet_t *l)
libnet_build_ospfv2_lsa_as
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_build_ipsec_esp_hdr
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_addr2name6_r
LIBNET_API void libnet_addr2name6_r(struct libnet_in6_addr addr, uint8_t use_name, char *host_name, int host_name_len)
libnet_autobuild_ipv4
LIBNET_API libnet_ptag_t libnet_autobuild_ipv4(uint16_t len, uint8_t prot, uint32_t dst, libnet_t *l)
libnet_getpacket_size
LIBNET_API uint32_t libnet_getpacket_size(libnet_t *l)
libnet_build_udp
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_build_icmpv6_ndp_nsol
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_cq_add
int libnet_cq_add(libnet_t *l, char *label)
libnet_diag_dump_pblock_type
LIBNET_API char * libnet_diag_dump_pblock_type(uint8_t type)
libnet_build_icmpv6_unreach
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_clear_packet
LIBNET_API void libnet_clear_packet(libnet_t *l)
libnet_build_802_3
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_geterror
LIBNET_API char * libnet_geterror(libnet_t *l)
libnet_build_icmpv6_ndp_nadv
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_adv_cull_packet
LIBNET_API int libnet_adv_cull_packet(libnet_t *l, uint8_t **packet, uint32_t *packet_s)
libnet_destroy
LIBNET_API void libnet_destroy(libnet_t *l)
libnet_build_dnsv4
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_cq_remove
LIBNET_API libnet_t * libnet_cq_remove(libnet_t *l)
libnet_cq_getlabel
LIBNET_API const char * libnet_cq_getlabel(libnet_t *l)
libnet_cq_head
LIBNET_API libnet_t * libnet_cq_head(void)
libnet_build_ospfv2_lsa_rtr
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_build_rip
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_adv_free_packet
LIBNET_API void libnet_adv_free_packet(libnet_t *l, uint8_t *packet)
libnet_getpbuf
LIBNET_API uint8_t * libnet_getpbuf(libnet_t *l, libnet_ptag_t ptag)
libnet_build_isl
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_autobuild_token_ring
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_build_data
LIBNET_API libnet_ptag_t libnet_build_data(const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
libnet_build_token_ring
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_build_ipv6_hbhopts
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_build_rpc_call
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_plist_chain_next_pair
LIBNET_API int libnet_plist_chain_next_pair(libnet_plist_t *plist, uint16_t *bport, uint16_t *eport)
libnet_build_icmpv4_echo
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_cq_end_loop
LIBNET_API uint32_t libnet_cq_end_loop(void)
libnet_build_ospfv2_lsr
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_adv_write_raw_ipv4
LIBNET_API int libnet_adv_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t packet_s)
libnet_init
LIBNET_API libnet_t * libnet_init(int injection_type, const char *device, char *err_buf)
libnet_hex_aton
LIBNET_API uint8_t * libnet_hex_aton(const char *s, int *len)
libnet_getpbuf_size
LIBNET_API uint32_t libnet_getpbuf_size(libnet_t *l, libnet_ptag_t ptag)
libnet_build_bootpv4
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_version
LIBNET_API const char * libnet_version(void)
libnet_build_link
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_cq_last
LIBNET_API int libnet_cq_last(void)
libnet_build_bgp4_open
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_build_icmpv6_ndp_opt
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_autobuild_arp
LIBNET_API libnet_ptag_t libnet_autobuild_arp(uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha, uint8_t *tpa, libnet_t *l)
libnet_diag_dump_hex
void libnet_diag_dump_hex(const uint8_t *packet, uint32_t len, int swap, FILE *stream)
libnet_getdevice
LIBNET_API const char * libnet_getdevice(libnet_t *l)
libnet_build_sebek
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_build_ospfv2_lsa_net
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_diag_dump_context
LIBNET_API void libnet_diag_dump_context(libnet_t *l)
libnet_build_icmpv6_echo
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_adv_write_link
LIBNET_API int libnet_adv_write_link(libnet_t *l, const uint8_t *packet, uint32_t packet_s)
libnet_name2addr6
LIBNET_API struct libnet_in6_addr libnet_name2addr6(libnet_t *l, const char *host_name, uint8_t use_name)
libnet_build_icmpv4_redirect
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_build_gre_sre
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_build_icmpv4_unreach
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_build_dhcpv4
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_build_icmpv4_timeexceed
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_build_802_2
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_build_mpls
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_addr2name4
LIBNET_API char * libnet_addr2name4(uint32_t in, uint8_t use_name)
libnet_build_ntp
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_build_gre_last_sre
LIBNET_API libnet_ptag_t libnet_build_gre_last_sre(libnet_t *l, libnet_ptag_t ptag)
libnet_plist_chain_dump_string
LIBNET_API char * libnet_plist_chain_dump_string(libnet_plist_t *plist)
libnet_build_ipv6_frag
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_get_prand
LIBNET_API uint32_t libnet_get_prand(int mod)


libnet: API Documentation: libnet-macros.h Source File

  • libnet
libnet-macros.h
Go to the documentation of this file.
1 /*
2 * $Id: libnet-macros.h,v 1.7 2004/04/13 17:32:28 mike Exp $
3 *
4 * libnet-macros.h - Network routine library macro header file
5 *
6 * Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 */
31
32 #ifndef __LIBNET_MACROS_H
33 #define __LIBNET_MACROS_H
34
39 /* for systems without snprintf */
40 #if defined(NO_SNPRINTF)
41 #define snprintf(buf, len, args...) sprintf(buf, ##args)
42 #endif
43
44
49 #define LIBNET_DONT_RESOLVE 0
50
55 #define LIBNET_RESOLVE 1
56
60 #define LIBNET_ON 0
61
65 #define LIBNET_OFF 1
66
70 #ifndef IN6ADDR_ERROR_INIT
71 #define IN6ADDR_ERROR_INIT { { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
72 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
73 0xff, 0xff } } }
74 #endif
75
79 #define LIBNET_PR2 0
80 #define LIBNET_PR8 1
81 #define LIBNET_PR16 2
82 #define LIBNET_PRu16 3
83 #define LIBNET_PR32 4
84 #define LIBNET_PRu32 5
85 #define LIBNET_PRAND_MAX 0xffffffff
86
90 #define LIBNET_MAX_PACKET 0xffff
91 #ifndef IP_MAXPACKET
92 #define IP_MAXPACKET 0xffff
93 #endif
94
95
96 /* ethernet addresses are 6 octets long */
97 #ifndef ETHER_ADDR_LEN
98 #define ETHER_ADDR_LEN 0x6
99 #endif
100
101 /* FDDI addresses are 6 octets long */
102 #ifndef FDDI_ADDR_LEN
103 #define FDDI_ADDR_LEN 0x6
104 #endif
105
106 /* token ring addresses are 6 octets long */
107 #ifndef TOKEN_RING_ADDR_LEN
108 #define TOKEN_RING_ADDR_LEN 0x6
109 #endif
110
111 /* LLC Organization Code is 3 bytes long */
112 #define LIBNET_ORG_CODE_SIZE 0x3
113
117 #define LIBNET_ERRBUF_SIZE 0x100
118
122 #define LIBNET_MAXOPTION_SIZE 0x28
123
124 /* some BSD variants have this endianess problem */
125 #if (LIBNET_BSD_BYTE_SWAP)
126 #define FIX(n) ntohs(n)
127 #define UNFIX(n) htons(n)
128 #else
129 #define FIX(n) (n)
130 #define UNFIX(n) (n)
131 #endif
132
133 /* used internally for packet builders */
134 #define LIBNET_DO_PAYLOAD(l, p) \
135 if (payload_s && !payload) \
136 { \
137 snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, \
138 "%s(): payload inconsistency\n", __func__); \
139 goto bad; \
140 } \
141 if (payload_s) \
142 { \
143 n = libnet_pblock_append(l, p, payload, payload_s); \
144 if (n == (uint32_t) - 1) \
145 { \
146 goto bad; \
147 } \
148 } \
149
150
151 /* used internally for checksum stuff */
152 #define LIBNET_CKSUM_CARRY(x) \
153 (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff))
154
155 /* used interally for OSPF stuff */
156 #define LIBNET_OSPF_AUTHCPY(x, y) \
157 memcpy((uint8_t *)x, (uint8_t *)y, sizeof(y))
158 #define LIBNET_OSPF_CKSUMBUF(x, y) \
159 memcpy((uint8_t *)x, (uint8_t *)y, sizeof(y))
160
161 /* used internally for NTP leap indicator, version, and mode */
162 #define LIBNET_NTP_DO_LI_VN_MODE(li, vn, md) \
163 ((uint8_t)((((li) << 6) & 0xc0) | (((vn) << 3) & 0x38) | ((md) & 0x7)))
164
165 /* Not all systems have IFF_LOOPBACK */
166 #ifdef IFF_LOOPBACK
167 #define LIBNET_ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK)
168 #else
169 #define LIBNET_ISLOOPBACK(p) (strcmp((p)->ifr_name, "lo") == 0)
170 #endif
171
172 /* advanced mode check */
173 #define LIBNET_ISADVMODE(x) (x & 0x08)
174
175 /* context queue macros and constants */
176 #define LIBNET_LABEL_SIZE 64
177 #define LIBNET_LABEL_DEFAULT "cardshark"
178 #define CQ_LOCK_UNLOCKED (u_int)0x00000000
179 #define CQ_LOCK_READ (u_int)0x00000001
180 #define CQ_LOCK_WRITE (u_int)0x00000002
181
187 #define for_each_context_in_cq(l) \
188 for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next())
189
190 /* return 1 if write lock is set on cq */
191 #define cq_is_wlocked() (l_cqd.cq_lock & CQ_LOCK_WRITE)
192
193 /* return 1 if read lock is set on cq */
194 #define cq_is_rlocked() (l_cqd.cq_lock & CQ_LOCK_READ)
195
196 /* return 1 if any lock is set on cq */
197 #define cq_is_locked() (l_cqd.cq_lock & (CQ_LOCK_READ | CQ_LOCK_WRITE))
198
199 /* check if a context queue is locked */
200 #define check_cq_lock(x) (l_cqd.cq_lock & x)
201
202 #endif /* __LIBNET_MACROS_H */
203
204 /* EOF */


libnet: API Documentation: libnet.h Source File

libnet.h
Go to the documentation of this file.
1 /*
2 * libnet
3 * libnet.h - Network routine library header file
4 * include/libnet.h. Generated from libnet.h.in by configure.
5 *
6 * Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 */
31
32 #ifndef __LIBNET_H
33 #define __LIBNET_H
34
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70
71 /*
72 * TODO move the stuff we ALWAYS need out of the DOXYGEN ifndef block
73 * and minimize their redundancies (see doc/TODO)
74 */
75 #ifndef DOXYGEN_SHOULD_SKIP_THIS // mess
76 #include <stdio.h>
77 #include <string.h>
78 #include <fcntl.h>
79 #include <signal.h>
80 #include <stdlib.h>
81
82 #include <sys/stat.h>
83 #include <sys/types.h>
84 #include <ctype.h>
85
86 #include <errno.h>
87 #include <stdarg.h>
88
89 #if !defined(_MSC_VER)
90 #include <unistd.h>
91 #endif
92
93 #if defined(HAVE_SYS_SOCKIO_H) && !defined(SIOCGIFADDR)
94 #include <sys/sockio.h>
95 #endif
96
97 #if !defined(__WIN32__)
98 #include <sys/ioctl.h>
99 #include <sys/socket.h>
100 #include <net/if.h>
101 #include <arpa/inet.h>
102 #include <sys/time.h>
103 #include <netdb.h>
104 #else /* __WIN32__ */
105 #if (__CYGWIN__)
106 #include <sys/socket.h>
107 #endif
108 #include <stdint.h>
109 #include <ws2tcpip.h>
110 #include <windows.h>
111 #include <winsock2.h>
112 #endif /* __WIN32__ */
113
114 #if (HAVE_NET_ETHERNET_H)
115 #include <net/ethernet.h>
116 #endif /* HAVE_NET_ETHERNET_H */
117
118 #define LIBNET_VERSION "1.2-rc3"
119
120 #define LIBNET_LIL_ENDIAN 1
121
122 #ifndef LIBNET_API
123 #define LIBNET_API
124 #endif
125 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
126
127 #include "./libnet/libnet-types.h"
128 #include "./libnet/libnet-macros.h"
129 #include "./libnet/libnet-headers.h"
130 #include "./libnet/libnet-structures.h"
131 #include "./libnet/libnet-asn1.h"
132 #include "./libnet/libnet-functions.h"
133
134 #ifdef __cplusplus
135 }
136 #endif
137
138 #endif /* __LIBNET_H */
139
140 /* EOF */
libnet-functions.h
libnet exported function prototypes
libnet-macros.h
libnet macros and symbolic constants