libnet-functions.h(3)
๐ libnet-functions.h(3) ๐
okay bestie, sit down, hydrate, and let me tell you about this page ๐ it lives in the libnet manual, section 3 โ you know, the section where all the library calls hang out. It's giving "the master list of everything libnet lets you call." iconic behavior, honestly โจ
โจ NAME โจ
libnet-functions.hโ libnet exported function prototypes ๐ซถ
that's it, that's the whole vibe check for this section โ it's the header that holds all the prototypes libnet hands out to the world ๐
no cap, we're just getting started โ the rest of this page has so much more to unpack ๐ฆ
okay bestie, buckle in ๐ this is the entire guest list โ every single function this header hands you. not me listing all of them, but you asked for the full roster, so here's the full roster. signatures are exactly as they live in libnet-functions.h, so copy them character for character, no improvising โจ
๐ซถ Functions ๐ซถ
libnet_t * libnet_init (int injection_type, const char *device, char *err_buf)โ the opening scene of every libnet story ๐ธ you hand it an injection_type, a device, and an err_buf, and it hands you back your very ownlibnet_t *. main character energy fr.void libnet_destroy (libnet_t *l)โ the goodbye kiss ๐ it doesn't return anything, it just cleans up after yourl.void libnet_clear_packet (libnet_t *l)โ wipe the packet, keep the context. fresh start, no drama, no return value.void libnet_stats (libnet_t *l, struct libnet_stats *ls)โ stats go into yourstruct libnet_stats *ls, and nothing comes back out. it's giving "here's the tea, you hold it" ๐int libnet_getfd (libnet_t *l)โ gimme the file descriptor, int-flavored.const char * libnet_getdevice (libnet_t *l)โ the device name, as aconst char *. it's literally telling you where you're at ๐uint8_t * libnet_getpbuf (libnet_t *l, libnet_ptag_t ptag)โ hand over the packet buffer for thatptag, pointer style.uint32_t libnet_getpbuf_size (libnet_t *l, libnet_ptag_t ptag)โ and here's how big that packet buffer is, inuint32_t.char * libnet_geterror (libnet_t *l)โ when things go sideways, this is your emotional support error string ๐ญuint32_t libnet_getpacket_size (libnet_t *l)โ the size of the whole packet,uint32_t, no notes.int libnet_seed_prand (libnet_t *l)โ seed the pseudo-random number generator. an int comes back, obviously.uint32_t libnet_get_prand (int mod)โ random number,mod-modulated,uint32_tout. chaotic in the best way ๐ฆint libnet_toggle_checksum (libnet_t *l, libnet_ptag_t ptag, int mode)โ flip the checksum for aptag,modein charge. returns an int.char * libnet_addr2name4 (uint32_t in, uint8_t use_name)โ IPv4 address in, name out, withuse_namecalling the shots ๐uint32_t libnet_name2addr4 (libnet_t *l, char *host_name, uint8_t use_name)โ the reverse glow-up:host_namein, IPv4 address out,use_namedeciding how.int libnet_in6_is_error (struct libnet_in6_addr addr)โ is thisstruct libnet_in6_addrgiving error? int says yes or no.struct libnet_in6_addr libnet_name2addr6 (libnet_t *l, const char *host_name, uint8_t use_name)โ name to IPv6 address, returning a wholestruct libnet_in6_addrlike it's nothing.void libnet_addr2name6_r (struct libnet_in6_addr addr, uint8_t use_name, char *host_name, int host_name_len)โ the reentrant one โจ you bring your ownhost_nameandhost_name_len, it fills them in, returns nothing.int libnet_plist_chain_new (libnet_t *l, libnet_plist_t **plist, char *token_list)โ build a fresh port-list chain from atoken_list, hand back thelibnet_plist_t **plist. int out.int libnet_plist_chain_next_pair (libnet_plist_t *plist, uint16_t *bport, uint16_t *eport)โ next port pair, delivered throughbportandeport, int returned.int libnet_plist_chain_dump (libnet_plist_t *plist)โ dump that chain, get an int.char * libnet_plist_chain_dump_string (libnet_plist_t *plist)โ same dump, but as achar *string. obsessed ๐int libnet_plist_chain_free (libnet_plist_t *plist)โ free the chain, int back. closure, we love to see it.
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)โ 802.1Q build,libnet_ptag_tout.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)โ 802.1X build, same deal.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)โ 802.2, coming through ๐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)โ 802.2 SNAP edition.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)โ 802.3, yes ma'am.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)โ the ethernet builder, the classic, the icon ๐ฅlibnet_ptag_t libnet_autobuild_ethernet (const uint8_t *dst, uint16_t type, libnet_t *l)โ ethernet but auto, and notice there's noptagargument here, she does her own thing โจ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)โ FDDI, deep cuts only ๐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)โ auto-FDDI, also noptag, also a vibe.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)โ ARP, the wholehrd/pro/hln/pln/opmoment ๐ซถ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)โ auto-ARP. careful,tpahere is a plainuint8_t *, not const, ikyk ๐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)โ TCP header, the queen herself ๐libnet_ptag_t libnet_build_tcp_options (const uint8_t *options, uint32_t options_s, libnet_t *l, libnet_ptag_t ptag)โ TCP options, because the header alone wasn't extra enough.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)โ UDP. short, sweet, unbothered ๐ธ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)โ CDP, withvalue_sandvalueriding along.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)โ ICMPv4 echo, ping-coded ๐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)โ ICMPv4 mask, it has amask, naturally.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)โ ICMPv4 unreachable.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)โ ICMPv4 redirect, gateway included.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)โ ICMPv4 time exceeded.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)โ ICMPv4 timestamp, withotime,rtime, andttimeall present and accounted for โฐ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)โ ICMPv6 echo. yes bestie,payloadis a bareuint8_t *here, not const, noted ๐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)โ ICMPv6 unreachable, same non-constpayloadsituation.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)โ NDP neighbor solicitation, with atargetof thestruct libnet_in6_addrvariety.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)โ NDP neighbor advertisement, plusflags.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)โ NDP option,optionandoption_s, no payload args at all, she's minimal ๐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)โ IGMP, with areservedslot because tradition.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)โ IPv4 header, the blueprint, the whole tos/id/frag/ttl/prot/sum situation ๐ฅlibnet_ptag_t libnet_build_ipv4_options (const uint8_t *options, uint32_t options_s, libnet_t *l, libnet_ptag_t ptag)โ IPv4 options, extra credit.libnet_ptag_t libnet_autobuild_ipv4 (uint16_t len, uint8_t prot, uint32_t dst, libnet_t *l)โ auto-IPv4, onlylen,prot,dst, andl. noptagfor you ๐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)โ IPv6 header, withsrcanddstas wholestruct libnet_in6_addrvalues, not pointers โจ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)โ IPv6 fragmentation header.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)โ IPv6 routing header,rtypeandsegmentsincluded.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)โ IPv6 destination options.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)โ IPv6 hop-by-hop options.libnet_ptag_t libnet_autobuild_ipv6 (uint16_t len, uint8_t nh, struct libnet_in6_addr dst, libnet_t *l, libnet_ptag_t ptag)โ auto-IPv6, and yes, this one does take aptag. inconsistent? a little. iconic? absolutely ๐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)โ ISL,dhostandshostare non-const pointers, mind you.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)โ IPsec ESP header,spi/seq/ivtrio ๐ง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)โ IPsec ESP footer, and look atauth: it's anint8_t *. signed. spicy ๐ถ๏ธ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)โ IPsec AH.authis auint32_there, totally different energy from the ESP footer one, don't mix them up bestie ๐ญ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)โ DNSv4, with all four record counts:num_q,num_anws_rr,num_auth_rr,num_addi_rr.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)โ RIP,cmdtometric, the full journey.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)โ RPC call, and this one's got two data blobs:cdata(a bareuint8_t *) andvdata(const). equal parts chaos and balance โ๏ธ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)โ STP configuration BPDU, the long one, she's thorough ๐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)โ STP topology change notification, much shorter, much calmer.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)โ Token Ring, vintage but still serving ๐ฆ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 Token Ring, noptag, same as the other autobuilds.- `libnet_ptag_t libnet_build_vrrp (uint8_t version, uint8_t type, uint8_t
โฆand here's the rest of the prototype parade, bestie, picking up mid-signature exactly where we left off, no shame:
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_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_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_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_ptag_t libnet_build_ospfv2_hello (uint32_t netmask, uint16_t
interval, uint8_t opts, uint8_t priority, uint dead_int, uint32_t
des_rtr, uint32_t bkup_rtr, const uint8_t *payload, uint32_t
payload_s, libnet_t *l, libnet_ptag_t ptag)
libnet_ptag_t libnet_build_ospfv2_dbd (uint16_t dgram_len, uint8_t opts,
uint8_t type, uint seqnum, const uint8_t *payload, uint32_t
payload_s, libnet_t *l, libnet_ptag_t ptag)
libnet_ptag_t libnet_build_ospfv2_lsr (uint type, uint lsid, uint32_t
advrtr, const uint8_t *payload, uint32_t payload_s, libnet_t *l,
libnet_ptag_t ptag)
libnet_ptag_t libnet_build_ospfv2_lsu (uint num, const uint8_t *payload,
uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
libnet_ptag_t libnet_build_ospfv2_lsa (uint16_t age, uint8_t opts,
uint8_t type, uint lsid, uint32_t advrtr, uint seqnum, uint16_t sum,
uint16_t len, const uint8_t *payload, uint32_t payload_s, libnet_t
*l, libnet_ptag_t ptag)
libnet_ptag_t libnet_build_ospfv2_lsa_rtr (uint16_t flags, uint16_t num,
uint id, uint 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_ptag_t libnet_build_ospfv2_lsa_net (uint32_t nmask, uint rtrid,
const uint8_t *payload, uint32_t payload_s, libnet_t *l,
libnet_ptag_t ptag)
libnet_ptag_t libnet_build_ospfv2_lsa_sum (uint32_t nmask, uint metric,
uint tos, const uint8_t *payload, uint32_t payload_s, libnet_t *l,
libnet_ptag_t ptag)
libnet_ptag_t libnet_build_ospfv2_lsa_as (uint32_t nmask, uint metric,
uint32_t fwdaddr, uint tag, const uint8_t *payload, uint32_t
payload_s, libnet_t *l, libnet_ptag_t ptag)
libnet_ptag_t libnet_build_data (const uint8_t *payload, uint32_t
payload_s, libnet_t *l, libnet_ptag_t ptag)
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_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)
uint32_t libnet_getgre_length (uint16_t fv)
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_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_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_ptag_t libnet_build_gre_last_sre (libnet_t *l, libnet_ptag_t
ptag)
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_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_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_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_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_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_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_ptag_t libnet_autobuild_link (const uint8_t *dst, const uint8_t
*oui, uint16_t type, libnet_t *l)
int libnet_write (libnet_t *l)
uint32_t libnet_get_ipaddr4 (libnet_t *l)
struct libnet_in6_addr libnet_get_ipaddr6 (libnet_t *l)
struct libnet_ether_addr * libnet_get_hwaddr (libnet_t *l)
uint8_t * libnet_hex_aton (const char *s, int *len)
const char * libnet_version (void)
int libnet_adv_cull_packet (libnet_t *l, uint8_t **packet, uint32_t
*packet_s)
int libnet_adv_cull_header (libnet_t *l, libnet_ptag_t ptag, uint8_t
**header, uint32_t *header_s)
int libnet_adv_write_link (libnet_t *l, const uint8_t *packet, uint32_t
packet_s)
int libnet_adv_write_raw_ipv4 (libnet_t *l, const uint8_t *packet,
uint32_t packet_s)
void libnet_adv_free_packet (libnet_t *l, uint8_t *packet)
int libnet_cq_add (libnet_t *l, char *label)
libnet_t * libnet_cq_remove (libnet_t *l)
libnet_t * libnet_cq_remove_by_label (char *label)
const char * libnet_cq_getlabel (libnet_t *l)
libnet_t * libnet_cq_find_by_label (char *label)
void libnet_cq_destroy (void)
libnet_t * libnet_cq_head (void)
int libnet_cq_last (void)
libnet_t * libnet_cq_next (void)
uint32_t libnet_cq_size (void)
uint32_t libnet_cq_end_loop (void)
void libnet_diag_dump_context (libnet_t *l)
void libnet_diag_dump_pblock (libnet_t *l)
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)
int libnet_write_raw_ipv4 (libnet_t *l, const uint8_t *packet, uint32_t
size)
int libnet_write_raw_ipv6 (libnet_t *l, const uint8_t *packet, uint32_t
size)
int libnet_write_link (libnet_t *l, const uint8_t *packet, uint32_t
size)
int libnet_open_raw4 (libnet_t *l)
int libnet_close_raw4 (libnet_t *l)
int libnet_open_raw6 (libnet_t *l)
int libnet_close_raw6 (libnet_t *l)
int libnet_select_device (libnet_t *l)
int libnet_open_link (libnet_t *l)
int libnet_close_link (libnet_t *l)
int libnet_do_checksum (libnet_t *l, uint8_t *iphdr, int protocol, int
h_len)
int libnet_inet_checksum (libnet_t *l, uint8_t *iphdr, int protocol, int
h_len, const uint8_t *beg, const uint8_t *end)
uint32_t libnet_compute_crc (uint8_t *buf, uint32_t len)
uint16_t libnet_ip_check (uint16_t *addr, int len)
int libnet_in_cksum (uint16_t *addr, int len)
libnet_pblock_t * libnet_pblock_probe (libnet_t *l, libnet_ptag_t ptag,
uint32_t b_len, uint8_t type)
libnet_pblock_t * libnet_pblock_new (libnet_t *l, uint32_t b_len)
int libnet_pblock_swap (libnet_t *l, libnet_ptag_t ptag1, libnet_ptag_t
ptag2)
int libnet_pblock_insert_before (libnet_t *l, libnet_ptag_t ptag1,
libnet_ptag_t ptag2)
void libnet_pblock_delete (libnet_t *l, libnet_pblock_t *p)
libnet_ptag_t libnet_pblock_update (libnet_t *l, libnet_pblock_t *p,
uint32_t h, uint8_t type)
libnet_pblock_t * libnet_pblock_find (libnet_t *l, libnet_ptag_t ptag)
int libnet_pblock_append (libnet_t *l, libnet_pblock_t *p, const void
*buf, uint32_t len)
void libnet_pblock_setflags (libnet_pblock_t *p, uint8_t flags)
int libnet_pblock_p2p (uint8_t type)
int libnet_pblock_coalesce (libnet_t *l, uint8_t **packet, uint32_t
*size)
int libnet_check_iface (libnet_t *l)
โจ Variables โจ
Okay so there is exactly one lil global variable in this whole vibe, and here she is, living her best life at file scope:
struct libnet_in6_addr in6addr_error
That's it. That's the entire variables section. Iconic minimalism, honestly. ๐
๐ Detailed Description ๐
The original says, and I quote, libnet exported function prototypes. That's the whole detailed description bestie. It's giving "we put the details in the details" energy but honestly? Respect. The functions are the story. ๐ฆ
๐ Function Documentation ๐
char* libnet_addr2name4 (uint32_tin, uint8_tuse_name)
So this one takes a network byte ordered IPv4 address and hands you back a pointer to either a canonical DNS name (if the address has one, which, slay) or a string of dotted decimals (the classic 1.2.3.4 situation we all know and love).
Heads up tho: this may incur a DNS lookup if the hostname and mode is set to LIBNET_RESOLVE. ๐
But if mode is set to LIBNET_DONT_RESOLVE? Then no DNS lookup happens at all, and the function just returns a pointer to a dotted decimal string. No network calls, no waiting, no drama. ๐ซถ
The function cannot fail โ which is a flex โ because if no canonical name exists, it falls back on returning a dotted decimal string. Bestie always has a backup plan. ๐
โ ๏ธ Also important: this function is non-reentrant. So don't be calling it from two places at once and expecting two separate answers, okay? That's not the vibe. ๐ญ
Parameters:
inโ network byte ordered IPv4 addressuse_nameโLIBNET_RESOLVEorLIBNET_DONT_RESOLVE
Returns:
- a pointer to presentation format string
And that's function one of the docs, bestie โ there are so many more coming, so stay tuned ๐
libnet_addr2name6_r ๐ซ
void libnet_addr2name6_r (struct libnet_in6_addr addr, uint8_t use_name, char *host_name, int host_name_len)
okay so the literal documentation for this one is just "Should document this baby right here." ๐ and honestly? iconic. that's it, that's the whole entry. no parameters listed, no return value, no nothing. we move.
libnet_adv_cull_header ๐ฅ
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 ptag you specify out of the libnet context you handed it. bestie listen โ this one is part of the advanced interface, so it's only available when libnet is initialized in advanced mode. no advanced mode, no header, periodt. if it fails, libnet_geterror() will tell you why. ๐ซถ
Parameters:
lโ pointer to a libnet contextptagโ the ptag referencing the header to pullheaderโ will contain the headerheader_sโ will contain the header size
Returns:
1on success,-1on failure
libnet_adv_cull_packet ๐
int libnet_adv_cull_packet (libnet_t *l, uint8_t **packet, uint32_t *packet_s)
[Advanced Interface] Yanks a prebuilt, wire-ready packet straight out of the given libnet context. if libnet was configured to do so (and it is, by default, no cap) the packet will have all checksums written in. โจ again: advanced interface, only available when libnet is initialized in advanced mode.
โ ๏ธ important bestie: this function performs an implicitmalloc(), and you must make a corresponding call tolibnet_adv_free_packet()to free the memory that packet occupies. don't leave it hanging, that's a leak and leaks are not the vibe. ๐ญ
if it fails, libnet_geterror() can tell you why.
Parameters:
lโ pointer to a libnet contextpacketโ will contain the wire-ready packetpacket_sโ will contain the packet size
Returns:
1on success,-1on failure
libnet_adv_free_packet ๐งน
void libnet_adv_free_packet (libnet_t *l, uint8_t *packet)
[Advanced Interface] Frees the memory that was allocated when libnet_adv_cull_packet() was called. the cleanup queen we love to see. ๐
Parameters:
lโ pointer to a libnet contextpacketโ a pointer to the packet to free
libnet_adv_write_link ๐ฎ
int libnet_adv_write_link (libnet_t *l, const uint8_t *packet, uint32_t packet_s)
[Advanced Interface] Writes a packet to the network at the link layer. this is your go-to when you wanna write a packet that the application programmer constructed by hand, or โ more commonly โ to write a packet that came back from a call to libnet_adv_cull_packet(). it's part of the advanced interface, so it's only available when libnet is initialized in advanced mode. if it fails, libnet_geterror() will spill the tea on why. ๐
Parameters:
lโ pointer to a libnet contextpacketโ a pointer to the packet to injectpacket_sโ the size of the packet
Returns:
- the number of bytes written, or
-1on failure
libnet_adv_write_raw_ipv4 ๐
int libnet_adv_write_raw_ipv4 (libnet_t *l, const uint8_t *packet, uint32_t packet_s)
[Advanced Interface] Writes a packet to the network at the raw socket layer. same deal as above: perfect for writing a packet the application programmer built by hand, or โ more commonly โ a packet returned by libnet_adv_cull_packet(). advanced interface energy only, so libnet must be initialized in advanced mode. if it fails, libnet_geterror() tells you why. ๐ฆ
Parameters:
lโ pointer to a libnet contextpacketโ a pointer to the packet to injectpacket_sโ the size of the packet
Returns:
- the number of bytes written, or
-1on failure
libnet_autobuild_arp ๐
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)
Autobuilds an Address Resolution Protocol (ARP) header. depending on the op value, this function builds one of several different types of RFC 826 or RFC 903 RARP packets. โจ
Parameters:
opโ ARP operation typeshaโ sender's hardware addressspaโ sender's protocol addressthaโ target hardware addresstpaโ target protocol addresslโ pointer to a libnet context
Returns:
- protocol tag value on success,
-1on error
libnet_autobuild_ethernet ๐ง
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, except the field right after the source address holds the layer 3 protocol (instead of the frame's length). iykyk. ๐ธ
๐ก bestie, only use this function when libnet is initialized with the LIBNET_LINK interface. fr fr.
Parameters:
dstโ destination ethernet addresstypeโ upper layer protocol typelโ pointer to a libnet context
Returns:
- protocol tag value on success,
-1on error
libnet_autobuild_fddi ๐
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. very niche, very slay. โจ
Parameters:
fcโ class format and prioritydstโ destination fddi addressdsapโ destination service access pointssapโ source service access pointcfโ cfouiโ IEEE organizational codetypeโ upper layer protocollโ pointer to a libnet context
Returns:
- protocol tag value on success,
-1on error
libnet_autobuild_ipv4 ๐ฅ
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. this one is chef's kiss when you just need to build an IP header fast and don't need granular control over every little thing. it takes the same len, prot, and dst arguments as libnet_build_ipv4(). it does not accept a ptag argument, but it does return a ptag. so basically: you can use it to build a new IP header but not to modify an existing one. periodt. ๐
Parameters:
lenโ total length of the IP packet including all subsequent dataprotโ upper layer protocoldstโ destination IPv4 address (little endian)lโ pointer to a libnet context
Returns:
- protocol tag value on success,
-1on error
libnet_autobuild_ipv6 ๐ฆ
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. same energy as the v4 one: perfect for building an IP header quickly when you don't need a granular level of control. it takes the same len, nh, and dst arguments as libnet_build_ipv4(). it doesn't accept a ptag argument, but it does return a ptag โ so you can build a new IP header, not modify an existing one.
โ ๏ธ heads up bestie: this function requires libnet_get_ipaddr6(), which is not yet implemented for Win32 platforms. ๐
Parameters:
lenโ lengthnhโ next headerdstโ destination IPv6 addresslโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns:
- protocol tag value on success,
-1on error
libnet_autobuild_link ๐
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. it figures out the proper link layer header format from how l was initialized โ main character energy, honestly. currently supports Ethernet and Token Ring link layers. ๐
Parameters:
dstโ the destination MAC addressouiโ Organizationally Unique Identifier (unused for Ethernet)typeโ the upper layer protocol typelโ pointer to a libnet context
Returns:
- protocol tag value on success,
-1on error
libnet_autobuild_token_ring โญ
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. we love a retro protocol moment. ๐
Parameters:
acโ access controlfcโ frame controldstโ destination addressdsapโ destination service access pointssapโ source service access pointcfโ control fieldouiโ Organizationally Unique Identifiertypeโ upper layer protocol typelโ pointer to a libnet context
Returns:
- protocol tag value on success,
-1on error
libnet_build_802_1q ๐
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)
and that's genuinely all this page gives us for this one โ just the signature, no blurb, no parameter list, nothing. ๐ not me wanting lore that isn't there. moving on.
๐งฑ Packet Builder Functions ๐งฑ
The core of libnet is the platform-independent packet-building functionality. these functions let an application programmer 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 it often makes for functions with huge prototypes and large stack frames. ๐ญ
๐ฅ one important thing to note: 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:
libnet_build_ntp()libnet_build_udp()libnet_build_ipv4()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). no cap. ๐
๐ 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 payload data and pass a const uint8_t * to this data and its size to the desired libnet_build() function. libnet handles the rest. ๐
๐ก important to note: 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 โจ
okay bestie, this is THE core glow-up concept of libnet, so pay attention ๐
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.
๐ธ libnet_build_802_1q โ the VLAN tagging era
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 addresssrcโ pointer to a six byte destination ethernet addresstpiโ tag protocol identifierpriorityโ prioritycfiโ canonical format indicatorvlan_idโ vlan identifierlen_protoโ length (802.3) protocol (Ethernet II)payloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns:
protocol tag value on success, -1 on error
๐ฆ libnet_build_802_1x
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. yes, the auth bestie ๐ซถ
Parameters:
eap_verโ the EAP versioneap_typeโ the EAP typelengthโ frame lengthpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns:
protocol tag value on success, -1 on error
๐ libnet_build_802_2
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. little LLC moment, iconic ๐
Parameters:
dsapโ destination service access pointssapโ source service access pointcontrolโ control fieldpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns:
protocol tag value on success, -1 on error
๐ libnet_build_802_2snap
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. the SNAP variant, she's serving โจ
Parameters:
dsapโ destination service access pointssapโ source service access pointcontrolโ control fieldouiโ Organizationally Unique Identifiertypeโ upper layer protocolpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns:
protocol tag value on success, -1 on error
๐ libnet_build_802_3
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 addresssrcโ source ethernet addresslenโ frame length sans headerpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns:
protocol tag value on success, -1 on error
๐ libnet_build_arp
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. classic "who has" energy fr fr ๐ญ
Parameters:
hrdโ hardware address formatproโ protocol address formathlnโ hardware address lengthplnโ protocol address lengthopโ ARP operation typeshaโ sender's hardware addressspaโ sender's protocol addressthaโ target hardware addresstpaโ targer protocol addresspayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns:
protocol tag value on success, -1 on error
๐ libnet_build_bgp4_header
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 BGPOPEN, or no authentication is used, these 16 bytes are normally set as all ones)lenโ total length of the BGP message, including the headertypeโ type code of the message (OPEN,UPDATE,NOTIFICATIONorKEEPALIVE)payloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns:
protocol tag value on success, -1 on error
๐ libnet_build_bgp4_notification
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. it's giving "we need to talk" ๐ญ
Parameters:
err_codeโ type of notificationerr_subcodeโ more specific information about the reported error.payloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns:
protocol tag value on success, -1 on error
๐ง libnet_build_bgp4_open
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). first message sent = main character energy, obviously ๐
Parameters:
versionโ protocol version (should be set to4)src_asโ Autonomous System of the senderhold_timeโ used to compute the maximum allowed time between the receipt ofKEEPALIVE, and/orUPDATEmessages by the senderbgp_idโ BGP identifier of the senderopt_lenโ total length of the optional parameters field in bytespayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns:
protocol tag value on success, -1 on error
๐ฅ libnet_build_bgp4_update
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. gossip but make it routing ๐ซถ
Parameters:
unfeasible_rt_lenโ indicates the length of the (next) 'withdrawn routes' field in byteswithdrawn_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 bytespath_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 orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns:
protocol tag value on success, -1 on error
๐ฅพ libnet_build_bootpv4
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)
okay bestie, this one builds you a BOOTPv4 header, and the whole parameter list is right here:
opcodeโ the opcode, literally just hand it overhtypeโ hardware typehlenโ hardware lengthhopcountโ hop countxidโ transaction idsecsโ secondsflagsโ flagscipโ client ipyipโ your ipsipโ server ipgipโ gateway ipchaddrโ client hardware address, length ishlensnameโ server host name, a null terminated stringfileโ boot file name, a null terminated stringpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error ๐
๐ก libnet_build_cdp
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, which is very much giving "we made our own protocol, you're welcome." The CDP protocol specifies data by using a type/length/value (TLV) setup, and the first TLV can be specified by using the function's type, length, and value arguments. To specify additional TLVs, the programmer could either use the payload interface or libnet_build_data() to construct them. slay, options abound โจ
Parameters:
versionโ CDP versionttlโ time to live (time information should be cached by recipient)sumโ checksum (0for libnet to autofill)typeโ type of data contained invaluevalue_sโ length ofvalueargumentvalueโ the CDP information stringpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error ๐
๐งฉ libnet_build_data
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 โ like, imagine re-sending the same packet shape over and over with a fresh little payload each time. So handy ๐ซถ
โ ๏ธ Heads up bestie: this won't work for TCP or IP payload, they have special types. And yeah, the original says this is probably a bug. Not me exposing the source like that ๐
Parameters:
payloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error ๐ธ
๐ libnet_build_dhcpv4
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)
Same shape as the BOOTP one, because DHCP is BOOTP's glow-up obviously. Parameters:
opcodehtypehlenhopcountxidsecsflagscipyipsipgipchaddrโ client hardware address, length ishlensnameโ server host name, a null terminated stringfileโ boot file name, a null terminated stringpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error ๐
๐ libnet_build_dnsv4
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 โ so the header goes here, the rest goes in payload, got it? ๐
Parameters:
h_lenโ the header lengthidโ DNS packet idflagsโ control flagsnum_qโ number of questionsnum_anws_rrโ number of answer resource recordsnum_auth_rrโ number of authority resource recordsnum_addi_rrโ number of additional resource recordspayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error ๐
๐ libnet_build_egre
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 the '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. it's giving nesting dolls, fr fr ๐ช
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 (0for libnet to autofill).offsetโ byte offset from the start of the routing field to the first byte of the SREkeyโ inserted by the encapsulator to authenticate the sourceseqโ sequence number used by the receiver to sort the packetslenโ size of the GRE packetpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error โจ
๐ libnet_build_ethernet
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). Sneaky little difference, lowkey iconic.
๐จ You should only use this function when libnet is initialized with the LIBNET_LINK interface. Do not come crying to me otherwise bestie.
Parameters:
dstโ destination ethernet addresssrcโ source ethernet addresstypeโ upper layer protocol typepayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error ๐ฆ
๐ซ libnet_build_fddi
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. Retro networking, we love to see it ๐
Parameters:
fcโ class format and prioritydstโ destination fddi addresssrcโ source fddi addressdsapโ destination service access pointssapโ source service access pointcfโ cfouiโ 3 byte IEEE organizational codetypeโ upper layer protocolpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error ๐
๐ฐ๏ธ libnet_build_gre
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 the '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. yes this is the same speech as libnet_build_egre, no I did not forget, it's literally in the original twice ๐
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 (0for libnet to autofill).offsetโ byte offset from the start of the routing field to the first byte of the SREkeyโ inserted by the encapsulator to authenticate the sourceseqโ sequence number used by the receiver to sort the packetslenโ size of the GRE packetpayloadโ the payloadpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error ๐ฅ
๐ libnet_build_gre_last_sre
libnet_ptag_t libnet_build_gre_last_sre (libnet_t *l, libnet_ptag_t ptag)
No extra description in the original, just vibes and two args. Parameters:
lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error ๐
๐งต libnet_build_gre_sre
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โ address familyoffsetโ the offsetlengthโ the lengthroutingโ the routing infopayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error ๐ธ
๐ libnet_build_hsrp
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 propietary protocol defined in RFC 2281 โ yes, propietary and in an RFC, make it make sense ๐ญ
Parameters:
versionโ version of the HSRP messagesopcodeโ type of messagestateโ current state of the routerhello_timeโ period in seconds between hello messageshold_timeโ seconds that the current hello message is validpriorityโ priority for the election proccessgroupโ standby groupreservedโ reserved fieldauthdataโ passwordvirtual_ipโ virtual ip addresspayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error ๐
libnet_build_icmpv4_echo()
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);
okay so this one builds you an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) echo request/reply header โ yes bestie, it's the ping. the original ping. the blueprint. ๐
typeโ type of ICMP packet, and it should beICMP_ECHOREPLYorICMP_ECHOcodeโ code of ICMP packet (should be0)sumโ checksum (0for libnet to autofill)idโ identification numberseqโ packet sequence numberpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_icmpv4_mask()
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);
this one's the netmask sibling ๐ it builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) IP netmask request/reply header.
typeโ type of ICMP packet (should beICMP_MASKREQorICMP_MASKREPLY)codeโ code of ICMP packet (should be0)sumโ checksum (0for libnet to autofill)idโ identification numberseqโ packet sequence numbermaskโ subnet maskpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_icmpv4_redirect()
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 โจ
real talk: the IP header that caused the error message should be built by a previous call to libnet_build_ipv4(). don't skip that step, she needs her context ๐ซถ
typeโ type of ICMP packet (should beICMP_REDIRECT)codeโ code of ICMP packet (should be one of the four redirect codes)sumโ checksum (0for libnet to autofill)gatewayโ gatewaypayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_icmpv4_timeexceed()
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 "girl you've been looping too long" notification ๐ญ
same deal as redirect: the IP header that caused the error message should be built by a previous call to libnet_build_ipv4().
typeโ type of ICMP packet (should beICMP_TIMXCEED)codeโ code of ICMP packet (ICMP_TIMXCEED_INTRANS/ICMP_TIMXCEED_REASS)sumโ checksum (0for libnet to autofill)payloadโ optional payload orNULLpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
not me noticing the docs list payload twice here ๐ iconic of them, no notes, it's still just the one optional payload and one length. i'm keeping it because i keep everything, that's the rule bestie.
Returns: protocol tag value on success, -1 on error
libnet_build_icmpv4_timestamp()
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 โฐ the clock-in girlie of ICMP.
typeโ type of ICMP packet (should beICMP_TSTAMPorICMP_TSTAMPREPLY)codeโ code of ICMP packet (should be0)sumโ checksum (0for libnet to autofill)idโ identification numberseqโ sequence numberotimeโ originate timestamprtimeโ receive timestampttimeโ transmit timestamppayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_icmpv4_unreach()
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 ๐ซ๐
and yes, again: the IP header that caused the error message should be built by a previous call to libnet_build_ipv4().
typeโ type of ICMP packet (should beICMP_UNREACH)codeโ code of ICMP packet (should be one of the 16 unreachable codes)sumโ checksum (0for libnet to autofill)payloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_icmpv6_echo()
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);
v6 besties rise ๐ฆ this builds an IP version 6 RFC 4443 Internet Control Message Protocol (ICMP) echo or echo reply header.
typeโ type of ICMP packet (should beICMP6_ECHO_REQUESTorICMP6_ECHO_REPLY)codeโ code of ICMP packet (should be zero)sumโ checksum (0for libnet to autofill)idโ echo id numberseqโ echo sequence numberpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_icmpv6_ndp_nadv()
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</border> header. yes i typo'd that tag and no i will not be elaborating ๐ anyway โ
could be used with libnet_build_icmpv6_ndp_opt() and ND_OPT_TARGET_LINKADDR ๐
typeโ type of ICMP packet (should beND_NEIGHBOR_ADVERT)codeโ code of ICMP packet (should be zero)sumโ checksum (0for libnet to autofill)flagsโ should be a bitwise or of any applicableND_NA_FLAG_*flagstargetโ target ipv6 addresspayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_icmpv6_ndp_nsol()
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);
and here's her sister โ 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.
typeโ type of ICMP packet (should beND_NEIGHBOR_SOLICIT)codeโ code of ICMP packet (should be zero)sumโ checksum (0for libnet to autofill)targetโ target ipv6 addresspayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_icmpv6_ndp_opt()
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 ๐ the little accessory that goes with the NDP fits above.
typeโ one ofND_OPT_*typesoptionโ option dataoption_sโ size of option data (will be padded out to an 8-byte boundary)lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_icmpv6_unreach()
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 ๐ญ
heads up bestie: the IP header that caused the error message should be built by a previous call to libnet_build_ipv6(). note the v6 this time, don't mix them up ๐
typeโ type of ICMP packet (should beICMP6_DST_UNREACH)codeโ code of ICMP packet (should be one of the 5ICMP6_DST_UNREACH_*codes)sumโ checksum (0for libnet to autofill)payloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_igmp()
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 Memebership Protocol (IGMP) header ๐ group chat, but make it multicast.
typeโ packet typereservedโ (should be0for IGMPv1)sumโ checksum (0for libnet to autofill)ipโ IPv4 address (in standard/network byte order)payloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
Note:reservedwas previously calledcode, which it is not, in any IGMP version. the glow-up was real and also necessary ๐
libnet_build_ipsec_ah()
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 ๐ security girlie behaviour, we love to see it.
nhโ next headerlenโ payload lengthresโ reservedspiโ security parameter indexseqโ sequence numberauthโ authentication datapayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_ipsec_esp_ftr()
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);
last one in this batch โ builds an Internet Protocol Security Encapsulating Security Payload footer โจ the trailer, the outro, the mic drop at the end of the packet ๐ค
lenโ padding lengthnhโ next headerauthโ authentication datapayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ฆ libnet_build_ipsec_esp_hdr
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. yes bestie we're doing IPsec now, we're so back ๐
Parameters:
spiโ security parameter indexseqโ ESP sequence numberivโ initialization vectorpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ libnet_build_ipv4
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. the classic. the blueprint. the moment. ๐
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 bitsidโ IP identification numberfragโ fragmentation bits and offsetttlโ time to live in the networkprotโ upper layer protocolsumโ checksum (0for libnet to autofill) โจsrcโ source IPv4 address (little endian)dstโ destination IPv4 address (little endian)payloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ libnet_build_ipv4_options
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. This 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). like, that's the ceiling, bestie, do not test it ๐
When building a chain, the options must be built, then the IPv4 header. order matters, it's giving choreography ๐ฉฐ
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 stringlโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ง libnet_build_ipv6
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. glow up complete ๐
Parameters:
tcโ traffic classflโ flow labellenโ total length of the IP packetnhโ next headerhlโ hop limitsrcโ source IPv6 addressdstโ destination IPv6 addresspayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ธ libnet_build_ipv6_destopts
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. so like, the payload is the options here, that's the whole vibe ๐ซถ
Parameters:
nhโ next headerlenโ length of the header in 8-byte octets not including the first 8 octetspayloadโ options payloadpayload_sโ payload lengthlโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ libnet_build_ipv6_frag
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 headerreservedโ unused value... OR IS IT! ๐ (we're keeping this exactly as written, it's iconic)fragโ fragmentation bits (ala ipv4)idโ packet identificationpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ libnet_build_ipv6_hbhopts
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. same energy as libnet_build_ipv6_destopts, different header, no cap ๐ง
Parameters:
nhโ next headerlenโ length of the header in 8-byte octets not including the first 8 octetspayloadโ options payloadpayload_sโ payload lengthlโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
โญ libnet_build_ipv6_routing
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. it's giving "here's my itinerary" ๐บ๏ธ
Parameters:
nhโ next headerlenโ length of the header in 8-byte octets not including the first 8 octetsrtypeโ routing header typesegmentsโ number of routing segments that followpayloadโ optional payload of routing informationpayload_sโ payload lengthlโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ฅ libnet_build_isl
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 be01:00:0c:00:00)typeโ type of frameuserโ user defined datashostโ source mac addresslenโ total length of the encapuslated packet less 18 bytessnapโ SNAP information (0xaaaa03+ vendor code)vidโ 15 bit VLAN ID, 1 bit BPDU or CDP indicatorportindexโ port indexreservedโ used for FDDI and token ringpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ libnet_build_link
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. it reads the room and picks the fit, we love an adaptive queen โจ
Parameters:
dstโ the destination MAC addresssrcโ the source MAC addressouiโ Organizationally Unique Identifier (unused for Ethernet)typeโ the upper layer protocol typepayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ฆ libnet_build_mpls
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 valueexperimentalโ 3-bit reserved fieldbosโ 1-bit bottom of stack identifierttlโ time to livepayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ libnet_build_ntp
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. so many timestamps, she's thorough ๐
Parameters:
leap_indicatorโ the leap indicatorversionโ NTP protocol versionmodeโ NTP modestratumโ stratumpollโ polling intervalprecisionโ precisiondelay_intโ delay intervaldelay_fracโ delay fractiondispersion_intโ dispersion intervaldispersion_fracโ dispersion fractionreference_idโ reference idref_ts_intโ reference timestamp integerref_ts_fracโ reference timestamp fractionorig_ts_intโ original timestamp integerorig_ts_fracโ original timestamp fractionrec_ts_intโ receiver timestamp integerrec_ts_fracโ receiver timestamp fractionxmt_ts_intโ transmit timestamp integerxmt_ts_fracโ transmit timestamp integer (yes, that's what it says, we are reporting faithfully ๐ซก)payloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ฐ๏ธ libnet_build_ospfv2
libnet_ptag_t libnet_build_ospfv2 (uint16_tlen, uint8_ttype, uint32_trtr_id,
uint32_tarea_id, uint16_tsum, uint16_tautype, const uint8_t *payload,
uint32_tpayload_s, libnet_t *l, libnet_ptag_tptag)
okay so this is THE base OSPFv2 header builder, the main character of the OSPF crew ๐ hand it the numbers, it hands you a header.
Parameters:
lenโ thelenvalue, that's it, that's the whole description, you got this bestie ๐typeโ thetypevaluertr_idโ the router idarea_idโ the area idsumโ the checksumautypeโ the authentication typepayloadโ optional payload, orNULLif you're not bringing snackspayload_sโ payload length, or0lโ pointer to a libnet context ๐ซถptagโ protocol tag, for when you wanna modify an existing header; pass0to build a fresh new one
Returns: the protocol tag value on success, or -1 if it said no ๐ญ
๐จ libnet_build_ospfv2_dbd
libnet_ptag_t libnet_build_ospfv2_dbd (uint16_tdgram_len, uint8_topts,
uint8_ttype, uintseqnum, const uint8_t *payload, uint32_tpayload_s,
libnet_t *l, libnet_ptag_tptag)
the Database Description packet builder, for when the routers are like "hey here's my whole database, no cap" ๐
Parameters:
dgram_lenโ the datagram lengthoptsโ the optionstypeโ the typeseqnumโ the sequence numberpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ libnet_build_ospfv2_hello
libnet_ptag_t libnet_build_ospfv2_hello (uint32_tnetmask, uint16_tinterval,
uint8_topts, uint8_tpriority, uintdead_int, uint32_tdes_rtr,
uint32_tbkup_rtr, const uint8_t *payload, uint32_tpayload_s, libnet_t
*l, libnet_ptag_tptag)
the HELLO packet!! it's giving "hi bestie, are we neighbors or not" ๐ธ this is literally how OSPF friendships start.
Parameters:
netmaskโ the network maskintervalโ the intervaloptsโ the optionspriorityโ the prioritydead_intโ the dead intervaldes_rtrโ the designated routerbkup_rtrโ the backup designated routerpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐งพ libnet_build_ospfv2_lsa
libnet_ptag_t libnet_build_ospfv2_lsa (uint16_tage, uint8_topts,
uint8_ttype, uintlsid, uint32_tadvrtr, uintseqnum, uint16_tsum,
uint16_tlen, const uint8_t *payload, uint32_tpayload_s, libnet_t *l,
libnet_ptag_tptag)
the Link State Advertisement header โ the receipts of the OSPF world ๐ง
Parameters:
ageโ the ageoptsโ the optionstypeโ the typelsidโ the link state idadvrtrโ the advertising routerseqnumโ the sequence numbersumโ the checksumlenโ the lengthpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ libnet_build_ospfv2_lsa_as
libnet_ptag_t libnet_build_ospfv2_lsa_as (uint32_tnmask, uintmetric,
uint32_tfwdaddr, uinttag, const uint8_t *payload, uint32_tpayload_s,
libnet_t *l, libnet_ptag_tptag)
the AS (Autonomous System) external LSA builder โ this is how routes sneak in from outside the area ๐
Parameters:
nmaskโ the network maskmetricโ the metricfwdaddrโ the forwarding addresstagโ the tagpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ธ๏ธ libnet_build_ospfv2_lsa_net
libnet_ptag_t libnet_build_ospfv2_lsa_net (uint32_tnmask, uintrtrid, const
uint8_t *payload, uint32_tpayload_s, libnet_t *l, libnet_ptag_tptag)
network LSA time!! ๐ this one's all about the broadcast segment and which routers are chillin' on it.
Parameters:
nmaskโ the network maskrtridโ the router idpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ ๏ธ libnet_build_ospfv2_lsa_rtr
libnet_ptag_t libnet_build_ospfv2_lsa_rtr (uint16_tflags, uint16_tnum,
uintid, uintdata, uint8_ttype, uint8_ttos, uint16_tmetric, const uint8_t
*payload, uint32_tpayload_s, libnet_t *l, libnet_ptag_tptag)
router LSA โ the "here's what I'm connected to" flex of every OSPF router ๐ช
Parameters:
flagsโ the flagsnumโ the numberidโ the iddataโ the datatypeโ the typetosโ the TOSmetricโ the metricpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐บ๏ธ libnet_build_ospfv2_lsa_sum
libnet_ptag_t libnet_build_ospfv2_lsa_sum (uint32_tnmask, uintmetric,
uinttos, const uint8_t *payload, uint32_tpayload_s, libnet_t *l,
libnet_ptag_tptag)
summary LSA builder โ it's giving "let me condense all this for you" โจ
Parameters:
nmaskโ the network maskmetricโ the metrictosโ the TOSpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ libnet_build_ospfv2_lsr
libnet_ptag_t libnet_build_ospfv2_lsr (uinttype, uintlsid, uint32_tadvrtr,
const uint8_t *payload, uint32_tpayload_s, libnet_t *l,
libnet_ptag_tptag)
Link State Request โ the polite "may I please see that LSA, bestie?" of OSPF ๐
Parameters:
typeโ the typelsidโ the link state idadvrtrโ the advertising routerpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ฆ libnet_build_ospfv2_lsu
libnet_ptag_t libnet_build_ospfv2_lsu (uintnum, const uint8_t *payload,
uint32_tpayload_s, libnet_t *l, libnet_ptag_tptag)
Link State Update โ and HERE is the actual delivery, the LSAs arriving like your packages on a good day ๐๐จ
Parameters:
numโ the numberpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ฆ libnet_build_rip
libnet_ptag_t libnet_build_rip (uint8_tcmd, uint8_tversion, uint16_trd,
uint16_taf, uint16_trt, uint32_taddr, uint32_tmask, uint32_tnext_hop,
uint32_tmetric, const uint8_t *payload, uint32_tpayload_s, libnet_t *l,
libnet_ptag_tptag)
Builds a Routing Information Protocol header (RFCs 1058 and 2453). old school routing but still iconic, ngl ๐
Parameters:
cmdโ commandversionโ protocol versionrdโ version one:0, version two: routing domainafโ address familyrtโ version one:0, version two: route tagaddrโ IPv4 addressmaskโ version one:0, version two: subnet masknext_hopโ version one:0, version two: next hop addressmetricโ routing metricpayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
โ๏ธ libnet_build_rpc_call
libnet_ptag_t libnet_build_rpc_call (uint32_trm, uint32_txid,
uint32_tprog_num, uint32_tprog_vers, uint32_tprocedure, uint32_tcflavor,
uint32_tclength, uint8_t *cdata, uint32_tvflavor, uint32_tvlength, const
uint8_t *vdata, const uint8_t *payload, uint32_tpayload_s, libnet_t *l,
libnet_ptag_tptag)
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,0otherwisexidโ transaction identifier used to link calls and repliesprog_numโ remote program specification typically between0-1fffffffprog_versโ remote program version specificationprocedureโ procedure to be performed by remote programcflavorโ authentication credential typeclengthโ credential length (should be0)cdataโ opaque credential data (currently unused)vflavorโ authentication verifier typevlengthโ verifier length (should be0)vdataโ opaque verifier data (currently unused)payloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ต๏ธ libnet_build_sebek
libnet_ptag_t libnet_build_sebek (uint32_tmagic, uint16_tversion,
uint16_ttype, uint32_tcounter, uint32_ttime_sec, uint32_ttime_usec,
uint32_tpid, uint32_tuid, uint32_tfd, uint8_tcmd[SEBEK_CMD_LENGTH],
uint32_tlength, const uint8_t *payload, uint32_tpayload_s, libnet_t *l,
libnet_ptag_tptag)
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. ๐ yes this is the honeypot one, it's giving detective energy.
Parameters:
magicโ identify packets that should be hiddenversionโ protocol version, currently1typeโ type of record (read data is type0, write data is type1)counterโ PDU counter used to identify when packet are losttime_secโ seconds since EPOCH according to the honeypottime_usecโ residual microsecondspidโ PIDuidโ UIDfdโ FDcmdโ 12 first characters of the commandlengthโ length in bytes of the PDU's bodypayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ณ libnet_build_stp_conf
libnet_ptag_t libnet_build_stp_conf (uint16_tid, uint8_tversion,
uint8_tbpdu_type, uint8_tflags, const uint8_t *root_id, uint32_troot_pc,
const uint8_t *bridge_id, uint16_tport_id, uint16_tmessage_age,
uint16_tmax_age, uint16_thello_time, uint16_tf_delay, const uint8_t
*payload, uint32_tpayload_s, libnet_t *l, libnet_ptag_tptag)
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 idversionโ protocol versionbpdu_typeโ bridge protocol data unit typeflagsโ flagsroot_idโ root idroot_pcโ root path costbridge_idโ bridge idport_idโ port idmessage_ageโ message agemax_ageโ max agehello_timeโ hello timef_delayโ forward delaypayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
๐ libnet_build_stp_tcn
libnet_ptag_t libnet_build_stp_tcn (uint16_tid, uint8_tversion,
uint8_tbpdu_type, const uint8_t *payload, uint32_tpayload_s, libnet_t
*l, libnet_ptag_tptag)
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. ๐ฆ the "the tree changed, everyone update" announcement, fr fr.
Parameters:
idโ protocol idversionโ protocol versionbpdu_typeโ bridge protocol data unit typepayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_tcp ๐
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. Yes bestie, the actual TCP. The one that carries basically everything you love. ๐ซถ
Parameters:
spโ source portdpโ destination portseqโ sequence numberackโ acknowledgement numbercontrolโ control flagswinโ window sizesumโ checksum (0for libnet to autofill)urgโ urgent pointerlenโ total length of the TCP packet (for checksum calculation)payloadpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_tcp_options โจ
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). It's giving "there's a hard cap and we are respecting it." ๐
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. Doing the math so you don't have to, periodt. ๐
Parameters:
optionsโ byte string of TCP optionsoptions_sโ length of options stringlโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_token_ring ๐ฆ
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. Retro networking, we stan a vintage moment. ๐ธ
Parameters:
acโ access controlfcโ frame controldstโ destination addresssrcโ source addressdsapโ destination service access pointssapโ source service access pointcfโ control fieldouiโ Organizationally Unique Identifiertypeโ upper layer protocol typepayloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
ok yes,fcandcfare both in this signature. Not a typo on my part bestie, they're two different things.fcis frame control up top,cfis the control field later. Read it slow. ๐ซ
libnet_build_udp ๐
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. No handshakes, no drama, just vibes and datagrams. ๐
Parameters:
spโ source portdpโ destination portlenโ total length of the UDP packetsumโ checksum (0for libnet to autofill)payloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_build_vrrp ๐
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 autthentication 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. Do all three or the packet is lowkey not doing what you think it's doing. โญ
Parameters:
versionโ VRRP version (should be2)typeโ VRRP packet type (should be1-- ADVERTISEMENT)vrouter_idโ virtual router identificationpriorityโ priority (higher numbers indicate higher priority)ip_countโ number of IPv4 addresses contained in this advertisementauth_typeโ type of authentication (0,1,2-- see RFC)advert_intโ interval between advertisementssumโ checksum (0for libnet to autofill)payloadโ optional payload orNULLpayload_sโ payload length or0lโ pointer to a libnet contextptagโ protocol tag to modify an existing header,0to build a new one
Returns: protocol tag value on success, -1 on error
libnet_clear_packet ๐งน
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. Basically the "new packet, who dis" button. ๐
Parameters:
lโ pointer to a libnet context
libnet_cq_add [Context Queue] ๐
int libnet_cq_add(libnet_t *l, char *label)
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 contextlabelโ a canonical name given to recognize the new context, no longer thanLIBNET_LABEL_SIZE
Returns: 1 on success, -1 on failure
libnet_cq_destroy [Context Queue] ๐
void libnet_cq_destroy(void)
Destroys the entire context queue, calling libnet_destroy() on each member context. Everyone gets cleaned up. No leftovers. ๐ซถ
libnet_cq_end_loop [Context Queue] ๐ธ
uint32_t libnet_cq_end_loop(void)
libnet_cq_find_by_label [Context Queue] ๐
libnet_t* libnet_cq_find_by_label(char *label)
Locates a libnet context from the queue, indexed by a canonical label. Like find-my-friend but for contexts. ๐
Parameters:
labelโ canonical label of the libnet context to retrieve
Returns: the expected libnet context, NULL on failure
libnet_cq_getlabel [Context Queue] ๐ท๏ธ
const char* libnet_cq_getlabel(libnet_t *l)
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 [Context Queue] ๐
libnet_t* libnet_cq_head(void)
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. Seriously bestie, once. One iterator, one loop, no chaos. ๐ญ
Returns: the head of the context queue
libnet_cq_last [Context Queue] ๐
int libnet_cq_last(void)
Check whether the iterator is at the last context in the queue.
Returns: 1 if at the end of the context queue, 0 otherwise
libnet_cq_next [Context Queue] โก๏ธ
libnet_t* libnet_cq_next(void)
Get next context from the context queue.
Returns: the next context from the context queue
libnet_cq_remove [Context Queue] ๐ซง
libnet_t* libnet_cq_remove(libnet_t *l)
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, NULL on failure
libnet_cq_remove_by_label [Context Queue] ๐
libnet_t* libnet_cq_remove_by_label(char *label)
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, NULL on failure
libnet_cq_size [Context Queue] ๐ข
uint32_t libnet_cq_size(void)
Function returns the number of libnet contexts that are in the queue.
Returns: the number of libnet contexts currently in the queue
libnet_destroy ๐ซถ
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. Saying goodbye, but responsibly. ๐ญ
Parameters:
lโ pointer to a libnet context
libnet_diag_dump_context [Diagnostic] ๐
void libnet_diag_dump_context(libnet_t *l)
Prints the contents of the given context. Peek inside, it's fine, it's a diagnostic bestie. ๐
Parameters:
lโ pointer to a libnet context
libnet_diag_dump_hex [Diagnostic] ๐ง
void libnet_diag_dump_hex(const uint8_t *packet, uint32_t len, int swap, FILE *stream)
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 printlenโ length of the packet in bytesswapโ1to swap byte order,0to 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
๐ซ yes the swap thing is genuinely counter-intuitive, that's not me being dramatic, that's literally what the docs say โ and it may be a bug.
libnet_diag_dump_pblock [Diagnostic] ๐
void libnet_diag_dump_pblock(libnet_t *l)
Prints the contents of every pblock. Every single one. No skips. โจ
Parameters:
lโ pointer to a libnet context
libnet_diag_dump_pblock_type [Diagnostic] ๐ท๏ธ
char* libnet_diag_dump_pblock_type(uint8_t type)
Returns the canonical name of the pblock type.
Parameters:
typeโ pblock type
Returns: a string representing the pblock type type or 'unknown' for an unknown value
libnet_get_hwaddr [read] ๐
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. Main character energy, it'll figure it out or it'll tell you the tea. ๐
Parameters:
lโ pointer to a libnet context
Returns: a pointer to the MAC address or NULL
libnet_get_ipaddr4</p> ๐
uint32_t libnet_get_ipaddr4 (libnet_t *l)
okay so bestie, this one gives you the IP address for the device libnet was initialized with. โจ and if libnet got initialized without a device (aka raw socket mode, we love her) the function will attempt to find one for you. 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 or -1
libnet_get_ipaddr6 ๐
struct libnet_in6_addr libnet_get_ipaddr6 (libnet_t *l)
[read] โ the IPv6 twin of the above, living her best life. Returns the IPv6 address for the device libnet was initialized with. if libnet was initialized without a device (raw socket mode again, she's back) 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
Returns: well, nothing yet ๐
libnet_get_prand ๐ฒ
uint32_t libnet_get_prand (int mod)
Generates an unsigned psuedo-random value within the range specified by mod. the ranges are giving:
LIBNET_PR2โ0-1LIBNET_PR8โ0-255LIBNET_PR16โ0-32767LIBNET_PRu16โ0-65535LIBNET_PR32โ0-2147483647LIBNET_PRu32โ0-4294967295
Parameters:
modโ one the ofLIBNET_PR*constants
Returns: 1 on success, -1 on failure
libnet_getdevice ๐
const char* libnet_getdevice (libnet_t *l)
Returns the canonical name of the device used for packet injection. that's it, that's the function. iconic. ๐
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 โ ๏ธ
char* libnet_geterror (libnet_t *l)
Returns the last error set inside of the referenced libnet context. bestie, this function should be called anytime a function fails or an error condition is detected inside of libnet. fr fr, don't sleep on her. ๐จ
Parameters:
lโ pointer to a libnet context
Returns: an error string or NULL if no error has occured
libnet_getfd ๐ฆ
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 ๐
uint32_t libnet_getgre_length (uint16_t fv)
Parameters:
fvโ seelibnet_build_gre().
Returns: size, see libnet_build_gre().
libnet_getpacket_size ๐
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 resuling packet size). math queen behaviour honestly. โ
Parameters:
lโ pointer to a libnet context
Returns: the size of the packet in l
libnet_getpbuf ๐งบ
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. they're a matching set, you can't split them up. ๐
Parameters:
lโ pointer to a libnet contextptagโ the ptag reference number
Returns: a pointer to the pblock buffer or NULL on error
libnet_getpbuf_size ๐
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. see? told you they were a set. ๐ซถ
Parameters:
lโ pointer to a libnet contextptagโ the ptag reference number
Returns: the size of the pblock buffer
libnet_hex_aton ๐ข
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. ๐งน don't forget to clean up after her!!
Parameters:
sโ the string to be parsedlenโ the resulting size of the returned byte string
Returns: a byte string or NULL on failure
libnet_in6_is_error ๐ต๏ธโโ๏ธ
int libnet_in6_is_error (struct libnet_in6_addr addr)
Check a libnet_in6_addr structure for identity with in6addr_error. vibe check but for structs.
Parameters:
addrโ address to check
Returns: 1 if addr is in6addr_error, 0 if it is not
libnet_init ๐ โจ
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. this is the main character function, ngl.
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. no root, no vibes, no packet injection. ๐จ
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 (NULLand 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 ๐
uint32_t libnet_name2addr4 (libnet_t *l, 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. so like, choose wisely bestie. ๐
Parameters:
lโ pointer to a libnet contexthost_nameโ pointer to a string containing a presentation format host nameuse_nameโLIBNET_RESOLVEorLIBNET_DONT_RESOLVE
Returns: network byte ordered IPv4 address or -1 (2^32 - 1) on error
libnet_name2addr6 ๐ช
struct libnet_in6_addr libnet_name2addr6 (libnet_t *l, const char *host_name, uint8_t use_name)
[read] โ 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. same energy as her IPv4 sister, just more future-proof. โจ
Parameters:
lโ pointer to a libnet contexthost_nameโ pointer to a string containing a presentation format host nameuse_nameโLIBNET_RESOLVEorLIBNET_DONT_RESOLVE
Returns: network byte ordered IPv6 address structure
libnet_plist_chain_dump ๐๏ธ
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
Returns: 1 on success, -1 on failure
libnet_plist_chain_dump_string ๐ฉ
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. ๐ yeah bestie, she's problematic. the original doc is literally telling you to leave her alone.
Parameters:
plistโ previously created portlist
Returns: a printable string containing the port list contents on success NULL on error
libnet_plist_chain_free ๐งผ
int libnet_plist_chain_free (libnet_plist_t *plist)
Frees all memory associated with port list chain. the clean-up queen we stan.
Parameters:
plistโ previously created portlist
Returns: 1 on success, -1 on failure
libnet_plist_chain_new ๐ฑ
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 contextplistโ if successful, will refer to the portlist, if not,NULLtoken_listโ string containing the port list primitive
Returns: 1 on success, -1 on failure
libnet_plist_chain_next_pair ๐
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. three possible outcomes, she's versatile like that. ๐
Parameters:
plistโ previously created portlistbportโ will contain the beginning port number or0eportโ will contain the ending port number or0
Returns: 1 on success, 0 if empty, -1 on failure
libnet_seed_prand ๐พ
int libnet_seed_prand (libnet_t *l)
Seeds the psuedo-random number generator. give her something to grow from. ๐ฑ
Parameters:
lโ pointer to a libnet context
Returns: 1 on success, -1 on failure
libnet_stats ๐
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). the receipts function honestly. ๐
Parameters:
lโ pointer to a libnet contextlsโ pointer to a libnet statistics structure
int libnet_toggle_checksum (libnet_t *l, libnet_ptag_tptag, intmode)
okay so checksum drama โ here's the tea โ๐. 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(). It 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. iykyk ๐
โ ๏ธ 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. no cap, the kernel said โI got thisโ ๐
Parameters:
lโ pointer to a libnet contextptagโ the ptag reference numbermodeโLIBNET_ONorLIBNET_OFF
Returns:
1on success,-1on failure
const char* libnet_version (void)
Returns the version of libnet. literally just the vibe check for which libnet you're running ๐ฆ
Returns:
- the libnet version
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(). main character energy fr fr ๐
Parameters:
lโ pointer to a libnet context
Returns:
- the number of bytes written,
-1on error
๐ Author ๐
Generated automatically by Doxygen for libnet from the source code.
and that's the whole page, bestie ๐ซถ this iconic manual is from libnet version 1.1, dated Thu Mar 29 2012, and it lives at libnet-functions.h(3). stay slaying, keep those packets cute, and remember: checksums are a love language ๐โจ๐
๐ฆ where this page comes from
- debian bookworm: libnet1-dev 1.1.6+dfsg-3.2 ยท BSD-2
- ubuntu jammy: libnet1-dev 1.1.6+dfsg-3.1build3 ยท BSD-2
- ubuntu noble: libnet1-dev 1.1.6+dfsg-3.2build1 ยท BSD-2
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms