1libnet-functions.h(3)      libnet Programmers Guide      libnet-functions.h(3)
2
3
4

NAME

6       libnet-functions.h - libnet exported function prototypes
7
8

SYNOPSIS

10   Functions
11       LIBNET_API libnet_t * libnet_init (int injection_type, const char
12           *device, char *err_buf)
13       LIBNET_API void libnet_destroy (libnet_t *l)
14       LIBNET_API void libnet_clear_packet (libnet_t *l)
15       LIBNET_API void libnet_stats (libnet_t *l, struct libnet_stats *ls)
16       LIBNET_API int libnet_getfd (libnet_t *l)
17       LIBNET_API const char * libnet_getdevice (libnet_t *l)
18       LIBNET_API uint8_t * libnet_getpbuf (libnet_t *l, libnet_ptag_t ptag)
19       LIBNET_API uint32_t libnet_getpbuf_size (libnet_t *l, libnet_ptag_t
20           ptag)
21       LIBNET_API char * libnet_geterror (libnet_t *l)
22       LIBNET_API uint32_t libnet_getpacket_size (libnet_t *l)
23       LIBNET_API int libnet_seed_prand (libnet_t *l)
24       LIBNET_API uint32_t libnet_get_prand (int mod)
25       LIBNET_API int libnet_toggle_checksum (libnet_t *l, libnet_ptag_t ptag,
26           int mode)
27       LIBNET_API char * libnet_addr2name4 (uint32_t in, uint8_t use_name)
28       LIBNET_API uint32_t libnet_name2addr4 (libnet_t *l, const char
29           *host_name, uint8_t use_name)
30       LIBNET_API int libnet_in6_is_error (struct libnet_in6_addr addr)
31       LIBNET_API struct libnet_in6_addr libnet_name2addr6 (libnet_t *l, const
32           char *host_name, uint8_t use_name)
33       LIBNET_API void libnet_addr2name6_r (struct libnet_in6_addr addr,
34           uint8_t use_name, char *host_name, int host_name_len)
35       LIBNET_API int libnet_plist_chain_new (libnet_t *l, libnet_plist_t
36           **plist, char *token_list)
37       LIBNET_API int libnet_plist_chain_next_pair (libnet_plist_t *plist,
38           uint16_t *bport, uint16_t *eport)
39       LIBNET_API int libnet_plist_chain_dump (libnet_plist_t *plist)
40       LIBNET_API char * libnet_plist_chain_dump_string (libnet_plist_t
41           *plist)
42       LIBNET_API int libnet_plist_chain_free (libnet_plist_t *plist)
43       LIBNET_API libnet_ptag_t libnet_build_802_1q (const uint8_t *dst, const
44           uint8_t *src, uint16_t tpi, uint8_t priority, uint8_t cfi, uint16_t
45           vlan_id, uint16_t len_proto, const uint8_t *payload, uint32_t
46           payload_s, libnet_t *l, libnet_ptag_t ptag)
47       LIBNET_API libnet_ptag_t libnet_build_802_1x (uint8_t eap_ver, uint8_t
48           eap_type, uint16_t length, const uint8_t *payload, uint32_t
49           payload_s, libnet_t *l, libnet_ptag_t ptag)
50       LIBNET_API libnet_ptag_t libnet_build_802_2 (uint8_t dsap, uint8_t
51           ssap, uint8_t control, const uint8_t *payload, uint32_t payload_s,
52           libnet_t *l, libnet_ptag_t ptag)
53       LIBNET_API libnet_ptag_t libnet_build_802_2snap (uint8_t dsap, uint8_t
54           ssap, uint8_t control, uint8_t *oui, uint16_t type, const uint8_t
55           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
56       LIBNET_API libnet_ptag_t libnet_build_802_3 (const uint8_t *dst, const
57           uint8_t *src, uint16_t len, const uint8_t *payload, uint32_t
58           payload_s, libnet_t *l, libnet_ptag_t ptag)
59       LIBNET_API libnet_ptag_t libnet_build_ethernet (const uint8_t *dst,
60           const uint8_t *src, uint16_t type, const uint8_t *payload, uint32_t
61           payload_s, libnet_t *l, libnet_ptag_t ptag)
62       LIBNET_API libnet_ptag_t libnet_autobuild_ethernet (const uint8_t *dst,
63           uint16_t type, libnet_t *l)
64       LIBNET_API libnet_ptag_t libnet_build_fddi (uint8_t fc, const uint8_t
65           *dst, const uint8_t *src, uint8_t dsap, uint8_t ssap, uint8_t cf,
66           const uint8_t *oui, uint16_t type, const uint8_t *payload, uint32_t
67           payload_s, libnet_t *l, libnet_ptag_t ptag)
68       LIBNET_API libnet_ptag_t libnet_autobuild_fddi (uint8_t fc, const
69           uint8_t *dst, uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t
70           *oui, uint16_t type, libnet_t *l)
71       LIBNET_API libnet_ptag_t libnet_build_arp (uint16_t hrd, uint16_t pro,
72           uint8_t hln, uint8_t pln, uint16_t op, const uint8_t *sha, const
73           uint8_t *spa, const uint8_t *tha, const uint8_t *tpa, const uint8_t
74           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
75       LIBNET_API libnet_ptag_t libnet_autobuild_arp (uint16_t op, const
76           uint8_t *sha, const uint8_t *spa, const uint8_t *tha, const uint8_t
77           *tpa, libnet_t *l)
78       LIBNET_API libnet_ptag_t libnet_build_tcp (uint16_t sp, uint16_t dp,
79           uint32_t seq, uint32_t ack, uint8_t control, uint16_t win, uint16_t
80           sum, uint16_t urg, uint16_t len, const uint8_t *payload, uint32_t
81           payload_s, libnet_t *l, libnet_ptag_t ptag)
82       LIBNET_API libnet_ptag_t libnet_build_tcp_options (const uint8_t
83           *options, uint32_t options_s, libnet_t *l, libnet_ptag_t ptag)
84       LIBNET_API libnet_ptag_t libnet_build_udp (uint16_t sp, uint16_t dp,
85           uint16_t len, uint16_t sum, const uint8_t *payload, uint32_t
86           payload_s, libnet_t *l, libnet_ptag_t ptag)
87       LIBNET_API libnet_ptag_t libnet_build_cdp (uint8_t version, uint8_t
88           ttl, uint16_t sum, uint16_t type, uint16_t value_s, const uint8_t
89           *value, const uint8_t *payload, uint32_t payload_s, libnet_t *l,
90           libnet_ptag_t ptag)
91       LIBNET_API libnet_ptag_t libnet_build_icmpv4_echo (uint8_t type,
92           uint8_t code, uint16_t sum, uint16_t id, uint16_t seq, const
93           uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t
94           ptag)
95       LIBNET_API libnet_ptag_t libnet_build_icmpv4_mask (uint8_t type,
96           uint8_t code, uint16_t sum, uint16_t id, uint16_t seq, uint32_t
97           mask, const uint8_t *payload, uint32_t payload_s, libnet_t *l,
98           libnet_ptag_t ptag)
99       LIBNET_API libnet_ptag_t libnet_build_icmpv4_unreach (uint8_t type,
100           uint8_t code, uint16_t sum, const uint8_t *payload, uint32_t
101           payload_s, libnet_t *l, libnet_ptag_t ptag)
102       LIBNET_API libnet_ptag_t libnet_build_icmpv4_redirect (uint8_t type,
103           uint8_t code, uint16_t sum, uint32_t gateway, const uint8_t
104           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
105       LIBNET_API libnet_ptag_t libnet_build_icmpv4_timeexceed (uint8_t type,
106           uint8_t code, uint16_t sum, const uint8_t *payload, uint32_t
107           payload_s, libnet_t *l, libnet_ptag_t ptag)
108       LIBNET_API libnet_ptag_t libnet_build_icmpv4_timestamp (uint8_t type,
109           uint8_t code, uint16_t sum, uint16_t id, uint16_t seq, uint32_t
110           otime, uint32_t rtime, uint32_t ttime, const uint8_t *payload,
111           uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
112       LIBNET_API libnet_ptag_t libnet_build_icmpv6_echo (uint8_t type,
113           uint8_t code, uint16_t sum, uint16_t id, uint16_t seq, uint8_t
114           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
115       LIBNET_API libnet_ptag_t libnet_build_icmpv6_unreach (uint8_t type,
116           uint8_t code, uint16_t sum, uint8_t *payload, uint32_t payload_s,
117           libnet_t *l, libnet_ptag_t ptag)
118       LIBNET_API libnet_ptag_t libnet_build_icmpv6_ndp_nsol (uint8_t type,
119           uint8_t code, uint16_t sum, struct libnet_in6_addr target, uint8_t
120           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
121       LIBNET_API libnet_ptag_t libnet_build_icmpv6_ndp_nadv (uint8_t type,
122           uint8_t code, uint16_t sum, uint32_t flags, struct libnet_in6_addr
123           target, uint8_t *payload, uint32_t payload_s, libnet_t *l,
124           libnet_ptag_t ptag)
125       LIBNET_API libnet_ptag_t libnet_build_icmpv6_ndp_opt (uint8_t type,
126           uint8_t *option, uint32_t option_s, libnet_t *l, libnet_ptag_t
127           ptag)
128       LIBNET_API libnet_ptag_t libnet_build_igmp (uint8_t type, uint8_t
129           reserved, uint16_t sum, uint32_t ip, const uint8_t *payload,
130           uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
131       LIBNET_API libnet_ptag_t libnet_build_ipv4 (uint16_t ip_len, uint8_t
132           tos, uint16_t id, uint16_t frag, uint8_t ttl, uint8_t prot,
133           uint16_t sum, uint32_t src, uint32_t dst, const uint8_t *payload,
134           uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
135       LIBNET_API libnet_ptag_t libnet_build_ipv4_options (const uint8_t
136           *options, uint32_t options_s, libnet_t *l, libnet_ptag_t ptag)
137       LIBNET_API libnet_ptag_t libnet_autobuild_ipv4 (uint16_t len, uint8_t
138           prot, uint32_t dst, libnet_t *l)
139       LIBNET_API libnet_ptag_t libnet_build_ipv6 (uint8_t tc, uint32_t fl,
140           uint16_t len, uint8_t nh, uint8_t hl, struct libnet_in6_addr src,
141           struct libnet_in6_addr dst, const uint8_t *payload, uint32_t
142           payload_s, libnet_t *l, libnet_ptag_t ptag)
143       LIBNET_API libnet_ptag_t libnet_build_ipv6_frag (uint8_t nh, uint8_t
144           reserved, uint16_t frag, uint32_t id, const uint8_t *payload,
145           uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
146       LIBNET_API libnet_ptag_t libnet_build_ipv6_routing (uint8_t nh, uint8_t
147           len, uint8_t rtype, uint8_t segments, const uint8_t *payload,
148           uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
149       LIBNET_API libnet_ptag_t libnet_build_ipv6_destopts (uint8_t nh,
150           uint8_t len, const uint8_t *payload, uint32_t payload_s, libnet_t
151           *l, libnet_ptag_t ptag)
152       LIBNET_API libnet_ptag_t libnet_build_ipv6_hbhopts (uint8_t nh, uint8_t
153           len, const uint8_t *payload, uint32_t payload_s, libnet_t *l,
154           libnet_ptag_t ptag)
155       LIBNET_API libnet_ptag_t libnet_autobuild_ipv6 (uint16_t len, uint8_t
156           nh, struct libnet_in6_addr dst, libnet_t *l, libnet_ptag_t ptag)
157       LIBNET_API libnet_ptag_t libnet_build_isl (uint8_t *dhost, uint8_t
158           type, uint8_t user, uint8_t *shost, uint16_t len, const uint8_t
159           *snap, uint16_t vid, uint16_t portindex, uint16_t reserved, const
160           uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t
161           ptag)
162       LIBNET_API libnet_ptag_t libnet_build_ipsec_esp_hdr (uint32_t spi,
163           uint32_t seq, uint32_t iv, const uint8_t *payload, uint32_t
164           payload_s, libnet_t *l, libnet_ptag_t ptag)
165       LIBNET_API libnet_ptag_t libnet_build_ipsec_esp_ftr (uint8_t len,
166           uint8_t nh, int8_t *auth, const uint8_t *payload, uint32_t
167           payload_s, libnet_t *l, libnet_ptag_t ptag)
168       LIBNET_API libnet_ptag_t libnet_build_ipsec_ah (uint8_t nh, uint8_t
169           len, uint16_t res, uint32_t spi, uint32_t seq, uint32_t auth, const
170           uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t
171           ptag)
172       LIBNET_API libnet_ptag_t libnet_build_dnsv4 (uint16_t h_len, uint16_t
173           id, uint16_t flags, uint16_t num_q, uint16_t num_anws_rr, uint16_t
174           num_auth_rr, uint16_t num_addi_rr, const uint8_t *payload, uint32_t
175           payload_s, libnet_t *l, libnet_ptag_t ptag)
176       LIBNET_API libnet_ptag_t libnet_build_rip (uint8_t cmd, uint8_t
177           version, uint16_t rd, uint16_t af, uint16_t rt, uint32_t addr,
178           uint32_t mask, uint32_t next_hop, uint32_t metric, const uint8_t
179           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
180       LIBNET_API libnet_ptag_t libnet_build_rpc_call (uint32_t rm, uint32_t
181           xid, uint32_t prog_num, uint32_t prog_vers, uint32_t procedure,
182           uint32_t cflavor, uint32_t clength, uint8_t *cdata, uint32_t
183           vflavor, uint32_t vlength, const uint8_t *vdata, const uint8_t
184           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
185       LIBNET_API libnet_ptag_t libnet_build_stp_conf (uint16_t id, uint8_t
186           version, uint8_t bpdu_type, uint8_t flags, const uint8_t *root_id,
187           uint32_t root_pc, const uint8_t *bridge_id, uint16_t port_id,
188           uint16_t message_age, uint16_t max_age, uint16_t hello_time,
189           uint16_t f_delay, const uint8_t *payload, uint32_t payload_s,
190           libnet_t *l, libnet_ptag_t ptag)
191       LIBNET_API libnet_ptag_t libnet_build_stp_tcn (uint16_t id, uint8_t
192           version, uint8_t bpdu_type, const uint8_t *payload, uint32_t
193           payload_s, libnet_t *l, libnet_ptag_t ptag)
194       LIBNET_API libnet_ptag_t libnet_build_token_ring (uint8_t ac, uint8_t
195           fc, const uint8_t *dst, const uint8_t *src, uint8_t dsap, uint8_t
196           ssap, uint8_t cf, const uint8_t *oui, uint16_t type, const uint8_t
197           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
198       LIBNET_API libnet_ptag_t libnet_autobuild_token_ring (uint8_t ac,
199           uint8_t fc, const uint8_t *dst, uint8_t dsap, uint8_t ssap, uint8_t
200           cf, const uint8_t *oui, uint16_t type, libnet_t *l)
201       LIBNET_API libnet_ptag_t libnet_build_vrrp (uint8_t version, uint8_t
202           type, uint8_t vrouter_id, uint8_t priority, uint8_t ip_count,
203           uint8_t auth_type, uint8_t advert_int, uint16_t sum, const uint8_t
204           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
205       LIBNET_API libnet_ptag_t libnet_build_mpls (uint32_t label, uint8_t
206           experimental, uint8_t bos, uint8_t ttl, const uint8_t *payload,
207           uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
208       LIBNET_API libnet_ptag_t libnet_build_ntp (uint8_t leap_indicator,
209           uint8_t version, uint8_t mode, uint8_t stratum, uint8_t poll,
210           uint8_t precision, uint16_t delay_int, uint16_t delay_frac,
211           uint16_t dispersion_int, uint16_t dispersion_frac, uint32_t
212           reference_id, uint32_t ref_ts_int, uint32_t ref_ts_frac, uint32_t
213           orig_ts_int, uint32_t orig_ts_frac, uint32_t rec_ts_int, uint32_t
214           rec_ts_frac, uint32_t xmt_ts_int, uint32_t xmt_ts_frac, const
215           uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t
216           ptag)
217       LIBNET_API libnet_ptag_t libnet_build_ospfv2 (uint16_t len, uint8_t
218           type, uint32_t rtr_id, uint32_t area_id, uint16_t sum, uint16_t
219           autype, const uint8_t *payload, uint32_t payload_s, libnet_t *l,
220           libnet_ptag_t ptag)
221       LIBNET_API libnet_ptag_t libnet_build_ospfv2_hello (uint32_t netmask,
222           uint16_t interval, uint8_t opts, uint8_t priority, uint32_t
223           dead_int, uint32_t des_rtr, uint32_t bkup_rtr, const uint8_t
224           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
225       libnet_ptag_t libnet_build_ospfv2_hello_neighbor (uint32_t netmask,
226           uint16_t interval, uint8_t opts, uint8_t priority, uint32_t
227           dead_int, uint32_t des_rtr, uint32_t bkup_rtr, uint32_t neighbor,
228           const uint8_t *payload, uint32_t payload_s, libnet_t *l,
229           libnet_ptag_t ptag)
230       LIBNET_API libnet_ptag_t libnet_build_ospfv2_dbd (uint16_t dgram_len,
231           uint8_t opts, uint8_t type, uint32_t seqnum, const uint8_t
232           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
233       LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsr (uint32_t type,
234           uint32_t lsid, uint32_t advrtr, const uint8_t *payload, uint32_t
235           payload_s, libnet_t *l, libnet_ptag_t ptag)
236       LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsu (uint32_t num, const
237           uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t
238           ptag)
239       LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa (uint16_t age, uint8_t
240           opts, uint8_t type, uint32_t lsid, uint32_t advrtr, uint32_t
241           seqnum, uint16_t sum, uint16_t len, const uint8_t *payload,
242           uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
243       LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa_rtr (uint16_t flags,
244           uint16_t num, uint32_t id, uint32_t data, uint8_t type, uint8_t
245           tos, uint16_t metric, const uint8_t *payload, uint32_t payload_s,
246           libnet_t *l, libnet_ptag_t ptag)
247       LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa_net (uint32_t nmask,
248           uint32_t rtrid, const uint8_t *payload, uint32_t payload_s,
249           libnet_t *l, libnet_ptag_t ptag)
250       LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa_sum (uint32_t nmask,
251           uint32_t metric, uint32_t tos, const uint8_t *payload, uint32_t
252           payload_s, libnet_t *l, libnet_ptag_t ptag)
253       LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa_as (uint32_t nmask,
254           uint32_t metric, uint32_t fwdaddr, uint32_t tag, const uint8_t
255           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
256       LIBNET_API libnet_ptag_t libnet_build_data (const uint8_t *payload,
257           uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
258       LIBNET_API libnet_ptag_t libnet_build_dhcpv4 (uint8_t opcode, uint8_t
259           htype, uint8_t hlen, uint8_t hopcount, uint32_t xid, uint16_t secs,
260           uint16_t flags, uint32_t cip, uint32_t yip, uint32_t sip, uint32_t
261           gip, const uint8_t *chaddr, const char *sname, const char *file,
262           const uint8_t *payload, uint32_t payload_s, libnet_t *l,
263           libnet_ptag_t ptag)
264       LIBNET_API libnet_ptag_t libnet_build_bootpv4 (uint8_t opcode, uint8_t
265           htype, uint8_t hlen, uint8_t hopcount, uint32_t xid, uint16_t secs,
266           uint16_t flags, uint32_t cip, uint32_t yip, uint32_t sip, uint32_t
267           gip, const uint8_t *chaddr, const char *sname, const char *file,
268           const uint8_t *payload, uint32_t payload_s, libnet_t *l,
269           libnet_ptag_t ptag)
270       LIBNET_API uint32_t libnet_getgre_length (uint16_t fv)
271       LIBNET_API libnet_ptag_t libnet_build_gre (uint16_t fv, uint16_t type,
272           uint16_t sum, uint16_t offset, uint32_t key, uint32_t seq, uint16_t
273           len, const uint8_t *payload, uint32_t payload_s, libnet_t *l,
274           libnet_ptag_t ptag)
275       LIBNET_API libnet_ptag_t libnet_build_egre (uint16_t fv, uint16_t type,
276           uint16_t sum, uint16_t offset, uint32_t key, uint32_t seq, uint16_t
277           len, const uint8_t *payload, uint32_t payload_s, libnet_t *l,
278           libnet_ptag_t ptag)
279       LIBNET_API libnet_ptag_t libnet_build_gre_sre (uint16_t af, uint8_t
280           offset, uint8_t length, uint8_t *routing, const uint8_t *payload,
281           uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
282       LIBNET_API libnet_ptag_t libnet_build_gre_last_sre (libnet_t *l,
283           libnet_ptag_t ptag)
284       LIBNET_API libnet_ptag_t libnet_build_bgp4_header (uint8_t
285           marker[LIBNET_BGP4_MARKER_SIZE], uint16_t len, uint8_t type, const
286           uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t
287           ptag)
288       LIBNET_API libnet_ptag_t libnet_build_bgp4_open (uint8_t version,
289           uint16_t src_as, uint16_t hold_time, uint32_t bgp_id, uint8_t
290           opt_len, const uint8_t *payload, uint32_t payload_s, libnet_t *l,
291           libnet_ptag_t ptag)
292       LIBNET_API libnet_ptag_t libnet_build_bgp4_update (uint16_t
293           unfeasible_rt_len, const uint8_t *withdrawn_rt, uint16_t
294           total_path_attr_len, const uint8_t *path_attributes, uint16_t
295           info_len, uint8_t *reachability_info, const uint8_t *payload,
296           uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
297       LIBNET_API libnet_ptag_t libnet_build_bgp4_notification (uint8_t
298           err_code, uint8_t err_subcode, const uint8_t *payload, uint32_t
299           payload_s, libnet_t *l, libnet_ptag_t ptag)
300       LIBNET_API libnet_ptag_t libnet_build_sebek (uint32_t magic, uint16_t
301           version, uint16_t type, uint32_t counter, uint32_t time_sec,
302           uint32_t time_usec, uint32_t pid, uint32_t uid, uint32_t fd,
303           uint8_t cmd[SEBEK_CMD_LENGTH], uint32_t length, const uint8_t
304           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
305       LIBNET_API libnet_ptag_t libnet_build_hsrp (uint8_t version, uint8_t
306           opcode, uint8_t state, uint8_t hello_time, uint8_t hold_time,
307           uint8_t priority, uint8_t group, uint8_t reserved, uint8_t
308           authdata[HSRP_AUTHDATA_LENGTH], uint32_t virtual_ip, const uint8_t
309           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
310       LIBNET_API libnet_ptag_t libnet_build_link (const uint8_t *dst, const
311           uint8_t *src, const uint8_t *oui, uint16_t type, const uint8_t
312           *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
313       LIBNET_API libnet_ptag_t libnet_autobuild_link (const uint8_t *dst,
314           const uint8_t *oui, uint16_t type, libnet_t *l)
315       LIBNET_API int libnet_write (libnet_t *l)
316       LIBNET_API uint32_t libnet_get_ipaddr4 (libnet_t *l)
317       LIBNET_API struct libnet_in6_addr libnet_get_ipaddr6 (libnet_t *l)
318       LIBNET_API struct libnet_ether_addr * libnet_get_hwaddr (libnet_t *l)
319       LIBNET_API uint8_t * libnet_hex_aton (const char *s, int *len)
320       LIBNET_API const char * libnet_version (void)
321       LIBNET_API int libnet_adv_cull_packet (libnet_t *l, uint8_t **packet,
322           uint32_t *packet_s)
323       LIBNET_API int libnet_adv_cull_header (libnet_t *l, libnet_ptag_t ptag,
324           uint8_t **header, uint32_t *header_s)
325       LIBNET_API int libnet_adv_write_link (libnet_t *l, const uint8_t
326           *packet, uint32_t packet_s)
327       LIBNET_API int libnet_adv_write_raw_ipv4 (libnet_t *l, const uint8_t
328           *packet, uint32_t packet_s)
329       LIBNET_API void libnet_adv_free_packet (libnet_t *l, uint8_t *packet)
330       int libnet_cq_add (libnet_t *l, char *label)
331       LIBNET_API libnet_t * libnet_cq_remove (libnet_t *l)
332       LIBNET_API libnet_t * libnet_cq_remove_by_label (char *label)
333       LIBNET_API const char * libnet_cq_getlabel (libnet_t *l)
334       LIBNET_API libnet_t * libnet_cq_find_by_label (char *label)
335       LIBNET_API void libnet_cq_destroy (void)
336       LIBNET_API libnet_t * libnet_cq_head (void)
337       LIBNET_API int libnet_cq_last (void)
338       LIBNET_API libnet_t * libnet_cq_next (void)
339       LIBNET_API uint32_t libnet_cq_size (void)
340       LIBNET_API uint32_t libnet_cq_end_loop (void)
341       LIBNET_API void libnet_diag_dump_context (libnet_t *l)
342       LIBNET_API void libnet_diag_dump_pblock (libnet_t *l)
343       LIBNET_API char * libnet_diag_dump_pblock_type (uint8_t type)
344       void libnet_diag_dump_hex (const uint8_t *packet, uint32_t len, int
345           swap, FILE *stream)
346

Detailed Description

348       libnet exported function prototypes
349
350
351

Function Documentation

353   LIBNET_API char* libnet_addr2name4 (uint32_t in, uint8_t use_name)
354       Takes a network byte ordered IPv4 address and returns a pointer to
355       either a canonical DNS name (if it has one) or a string of dotted
356       decimals. This may incur a DNS lookup if the hostname and mode is set
357       to LIBNET_RESOLVE. If mode is set to LIBNET_DONT_RESOLVE, no DNS lookup
358       will be performed and the function will return a pointer to a dotted
359       decimal string. The function cannot fail -- if no canonical name
360       exists, it will fall back on returning a dotted decimal string. This
361       function is non-reentrant.
362
363       Parameters
364           in network byte ordered IPv4 address
365           use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
366
367       Returns
368           a pointer to presentation format string
369
370   LIBNET_API void libnet_addr2name6_r (struct libnet_in6_addr addr, uint8_t
371       use_name, char * host_name, int host_name_len)
372       Should document this baby right here.
373
374   LIBNET_API int libnet_adv_cull_header (libnet_t * l, libnet_ptag_t ptag,
375       uint8_t ** header, uint32_t * header_s)
376       [Advanced Interface] Pulls the header from the specified ptag from the
377       given libnet context. This function is part of the advanced interface
378       and is only available when libnet is initialized in advanced mode. If
379       the function fails libnet_geterror() can tell you why.
380
381       Parameters
382           l pointer to a libnet context
383           ptag the ptag referencing the header to pull
384           header will contain the header
385           header_s will contain the header size
386
387       Return values
388           1 on success
389           -1 on failure
390
391
392   LIBNET_API int libnet_adv_cull_packet (libnet_t * l, uint8_t ** packet,
393       uint32_t * packet_s)
394       [Advanced Interface] Yanks a prebuilt, wire-ready packet from the given
395       libnet context. If libnet was configured to do so (which it is by
396       default) the packet will have all checksums written in. This function
397       is part of the advanced interface and is only available when libnet is
398       initialized in advanced mode. It is important to note that the function
399       performs an implicit malloc() and a corresponding call to
400       libnet_adv_free_packet() should be made to free the memory packet
401       occupies. If the function fails libnet_geterror() can tell you why.
402
403       Parameters
404           l pointer to a libnet context
405           packet will contain the wire-ready packet
406           packet_s will contain the packet size
407
408       Return values
409           1 on success
410           -1 on failure
411
412
413   LIBNET_API void libnet_adv_free_packet (libnet_t * l, uint8_t * packet)
414       [Advanced Interface] Frees the memory allocated when
415       libnet_adv_cull_packet() is called.
416
417       Parameters
418           l pointer to a libnet context
419           packet a pointer to the packet to free
420
421   LIBNET_API int libnet_adv_write_link (libnet_t * l, const uint8_t * packet,
422       uint32_t packet_s)
423       [Advanced Interface] Writes a packet the network at the link layer.
424       This function is useful to write a packet that has been constructed by
425       hand by the application programmer or, more commonly, to write a packet
426       that has been returned by a call to libnet_adv_cull_packet(). This
427       function is part of the advanced interface and is only available when
428       libnet is initialized in advanced mode. If the function fails
429       libnet_geterror() can tell you why.
430
431       Parameters
432           l pointer to a libnet context
433           packet a pointer to the packet to inject
434           packet_s the size of the packet
435
436       Returns
437           the number of bytes written
438
439       Return values
440           -1 on failure
441
442   LIBNET_API int libnet_adv_write_raw_ipv4 (libnet_t * l, const uint8_t *
443       packet, uint32_t packet_s)
444       [Advanced Interface] Writes a packet the network at the raw socket
445       layer. This function is useful to write a packet that has been
446       constructed by hand by the application programmer or, more commonly, to
447       write a packet that has been returned by a call to
448       libnet_adv_cull_packet(). This function is part of the advanced
449       interface and is only available when libnet is initialized in advanced
450       mode. If the function fails libnet_geterror() can tell you why.
451
452       Parameters
453           l pointer to a libnet context
454           packet a pointer to the packet to inject
455           packet_s the size of the packet
456
457       Returns
458           the number of bytes written
459
460       Return values
461           -1 on failure
462
463   LIBNET_API libnet_ptag_t libnet_autobuild_arp (uint16_t op, const uint8_t *
464       sha, const uint8_t * spa, const uint8_t * tha, const uint8_t * tpa,
465       libnet_t * l)
466       Autouilds an Address Resolution Protocol (ARP) header. Depending on the
467       op value, the function builds one of several different types of RFC 826
468       or RFC 903 RARP packets.
469
470       Parameters
471           op ARP operation type
472           sha sender's hardware address
473           spa sender's protocol address
474           tha target hardware address
475           tpa target protocol address
476           l pointer to a libnet context
477
478       Returns
479           protocol tag value on success
480
481       Return values
482           -1 on error
483
484   LIBNET_API libnet_ptag_t libnet_autobuild_ethernet (const uint8_t * dst,
485       uint16_t type, libnet_t * l)
486       Autobuilds an Ethernet header. The RFC 894 Ethernet II header is almost
487       identical to the IEEE 802.3 header, with the exception that the field
488       immediately following the source address holds the layer 3 protocol (as
489       opposed to frame's length). You should only use this function when
490       libnet is initialized with the LIBNET_LINK interface.
491
492       Parameters
493           dst destination ethernet address
494           type upper layer protocol type
495           l pointer to a libnet context
496
497       Returns
498           protocol tag value on success
499
500       Return values
501           -1 on error
502
503   LIBNET_API libnet_ptag_t libnet_autobuild_fddi (uint8_t fc, const uint8_t *
504       dst, uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t * oui,
505       uint16_t type, libnet_t * l)
506       Autobuilds a Fiber Distributed Data Interface (FDDI) header.
507
508       Parameters
509           fc class format and priority
510           dst destination fddi address
511           dsap destination service access point
512           ssap source service access point
513           cf cf
514           oui IEEE organizational code
515           type upper layer protocol
516           l pointer to a libnet context
517
518       Returns
519           protocol tag value on success
520
521       Return values
522           -1 on error
523
524   LIBNET_API libnet_ptag_t libnet_autobuild_ipv4 (uint16_t len, uint8_t prot,
525       uint32_t dst, libnet_t * l)
526       Autobuilds a version 4 Internet Protocol (IP) header. The function is
527       useful to build an IP header quickly when you do not need a granular
528       level of control. The function takes the same len, prot, and dst
529       arguments as libnet_build_ipv4(). The function does not accept a ptag
530       argument, but it does return a ptag. In other words, you can use it to
531       build a new IP header but not to modify an existing one.
532
533       Parameters
534           len total length of the IP packet including all subsequent data
535           prot upper layer protocol
536           dst destination IPv4 address (little endian)
537           l pointer to a libnet context
538
539       Returns
540           protocol tag value on success
541
542       Return values
543           -1 on error
544
545   LIBNET_API libnet_ptag_t libnet_autobuild_ipv6 (uint16_t len, uint8_t nh,
546       struct libnet_in6_addr dst, libnet_t * l, libnet_ptag_t ptag)
547       Autobuilds a version 6 RFC 2460 Internet Protocol (IP) header. The
548       function is useful to build an IP header quickly when you do not need a
549       granular level of control. The function takes the same len, nh, and dst
550       arguments as libnet_build_ipv4(). The function does not accept a ptag
551       argument, but it does return a ptag. In other words, you can use it to
552       build a new IP header but not to modify an existing one. This function
553       requires libnet_get_ipaddr6(), which is not yet implemented for Win32
554       platforms.
555
556       Parameters
557           len length
558           nh next header
559           dst destination IPv6 address
560           l pointer to a libnet context
561           ptag protocol tag to modify an existing header, 0 to build a new
562           one
563
564       Returns
565           protocol tag value on success
566
567       Return values
568           -1 on error
569
570   LIBNET_API libnet_ptag_t libnet_autobuild_link (const uint8_t * dst, const
571       uint8_t * oui, uint16_t type, libnet_t * l)
572       Automatically builds a link layer header for an initialized l. The
573       function determines the proper link layer header format from how l was
574       initialized. The function current supports Ethernet and Token Ring link
575       layers.
576
577       Parameters
578           dst the destination MAC address
579           oui Organizationally Unique Identifier (unused for Ethernet)
580           type the upper layer protocol type
581           l pointer to a libnet context
582
583       Returns
584           protocol tag value on success
585
586       Return values
587           -1 on error
588
589   LIBNET_API libnet_ptag_t libnet_autobuild_token_ring (uint8_t ac, uint8_t
590       fc, const uint8_t * dst, uint8_t dsap, uint8_t ssap, uint8_t cf, const
591       uint8_t * oui, uint16_t type, libnet_t * l)
592       Auto-builds a token ring header.
593
594       Parameters
595           ac access control
596           fc frame control
597           dst destination address
598           dsap destination service access point
599           ssap source service access point
600           cf control field
601           oui Organizationally Unique Identifier
602           type upper layer protocol type
603           l pointer to a libnet context
604
605       Returns
606           protocol tag value on success
607
608       Return values
609           -1 on error
610
611   LIBNET_API libnet_ptag_t libnet_build_802_1q (const uint8_t * dst, const
612       uint8_t * src, uint16_t tpi, uint8_t priority, uint8_t cfi, uint16_t
613       vlan_id, uint16_t len_proto, const uint8_t * payload, uint32_t
614       payload_s, libnet_t * l, libnet_ptag_t ptag)

Packet Builder Functions

616       The core of libnet is the platform-independent packet-building
617       functionality. These functions enable an application programmer to
618       build protocol headers (and data) in a simple and consistent manner
619       without having to worry (too much) about low-level network odds and
620       ends. Each libnet_build() function builds a piece of a packet
621       (generally a protocol header). While it is perfectly possible to build
622       an entire, ready-to-transmit packet with a single call to a
623       libnet_build() function, generally more than one builder-class function
624       call is required to construct a full packet. A complete wire-ready
625       packet generally consists of more than one piece. Every function that
626       builds a protocol header takes a series of arguments roughly
627       corresponding to the header values as they appear on the wire. This
628       process is intuitive but often makes for functions with huge prototypes
629       and large stack frames. One important thing to note is that you must
630       call these functions in order, corresponding to how they should appear
631       on the wire (from the highest protocol layer on down). This building
632       process is intuitive; it approximates what happens in an operating
633       system kernel. In other words, to build a Network Time Protocol (NTP)
634       packet by using the link-layer interface, the application programmer
635       would call the libnet_build() functions in the following order:
636
637       1.  libnet_build_ntp()
638
639       2.  libnet_build_udp()
640
641       3.  libnet_build_ipv4()
642
643       4.  libnet_build_ethernet() This ordering is essential for libnet 1.1.x
644           to properly link together the packet internally (previous libnet
645           versions did not have the requirement).
646
647   The Payload Interface
648       The payload interface specifies an optional way to include data
649       directly after the protocol header in question. You can use this
650       function for a variety of purposes, including the following:
651
652       • Including additional or arbitrary protocol header information that is
653         not available from a libnet interface
654
655       • Including a packet payload (data segment)
656
657       • Building another protocol header that is not available from a libnet
658         interface To employ the interface, the application programmer should
659         construct the i payload data and pass a const uint8_t * to this data
660         and its size to the desired libnet_build() function. Libnet handles
661         the rest.
662
663       It is important to note that some functions (notably the IPv6 builders)
664       do use the payload interface to specify variable length but ostensibly
665       non-optional data. See the individual libnet_build_ipv6*() functions
666       for more information.
667
668   Protocol Tags and Packet Builder Return Values
669       Libnet uses the protocol tag (ptag) to identify individual pieces of a
670       packet after being created. A new ptag results every time a
671       libnet_build() function with an empty (0) ptag argument completes
672       successfully. This new ptag now refers to the packet piece just
673       created. The application programmer's responsibility is to save this
674       value if he or she plans to modify this particular portion later on in
675       the program. If the application programmer needs to modify some portion
676       of that particular packet piece again, he or she calls the same
677       libnet_build() function specifying the saved ptag argument. Libnet then
678       searches for that packet piece and modifies it rather than creating a
679       new one. Upon failure for any reason, libnet_build() functions return
680       -1; libnet_geterror() tells you why. Builds an IEEE 802.1q VLAN tagging
681       header. Depending on the value of len_proto, the function wraps the
682       802.1q header inside either an IEEE 802.3 header or an RFC 894 Ethernet
683       II (DIX) header (both resulting in an 18-byte frame). If len is 1500 or
684       less, most receiving protocol stacks parse the frame as an IEEE 802.3
685       encapsulated frame. If len is one of the Ethernet type values, most
686       protocol stacks parse the frame as an RFC 894 Ethernet II encapsulated
687       frame. Note the length value is calculated without the 802.1q header of
688       18 bytes.
689
690       Parameters
691           dst pointer to a six byte source ethernet address
692           src pointer to a six byte destination ethernet address
693           tpi tag protocol identifier
694           priority priority
695           cfi canonical format indicator
696           vlan_id vlan identifier
697           len_proto length (802.3) protocol (Ethernet II)
698           payload optional payload or NULL
699           payload_s payload length or 0
700           l pointer to a libnet context
701           ptag protocol tag to modify an existing header, 0 to build a new
702           one
703
704       Returns
705           protocol tag value on success
706
707       Return values
708           -1 on error
709
710   LIBNET_API libnet_ptag_t libnet_build_802_1x (uint8_t eap_ver, uint8_t
711       eap_type, uint16_t length, const uint8_t * payload, uint32_t payload_s,
712       libnet_t * l, libnet_ptag_t ptag)
713       Builds an IEEE 802.1x extended authentication protocol header.
714
715       Parameters
716           eap_ver the EAP version
717           eap_type the EAP type
718           length frame length
719           payload optional payload or NULL
720           payload_s payload length or 0
721           l pointer to a libnet context
722           ptag protocol tag to modify an existing header, 0 to build a new
723           one
724
725       Returns
726           protocol tag value on success
727
728       Return values
729           -1 on error
730
731   LIBNET_API libnet_ptag_t libnet_build_802_2 (uint8_t dsap, uint8_t ssap,
732       uint8_t control, const uint8_t * payload, uint32_t payload_s, libnet_t
733       * l, libnet_ptag_t ptag)
734       Builds an IEEE 802.2 LLC header.
735
736       Parameters
737           dsap destination service access point
738           ssap source service access point
739           control control field
740           payload optional payload or NULL
741           payload_s payload length or 0
742           l pointer to a libnet context
743           ptag protocol tag to modify an existing header, 0 to build a new
744           one
745
746       Returns
747           protocol tag value on success
748
749       Return values
750           -1 on error
751
752   LIBNET_API libnet_ptag_t libnet_build_802_2snap (uint8_t dsap, uint8_t
753       ssap, uint8_t control, uint8_t * oui, uint16_t type, const uint8_t *
754       payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
755       Builds an IEEE 802.2 LLC SNAP header.
756
757       Parameters
758           dsap destination service access point
759           ssap source service access point
760           control control field
761           oui Organizationally Unique Identifier
762           type upper layer protocol
763           payload optional payload or NULL
764           payload_s payload length or 0
765           l pointer to a libnet context
766           ptag protocol tag to modify an existing header, 0 to build a new
767           one
768
769       Returns
770           protocol tag value on success
771
772       Return values
773           -1 on error
774
775   LIBNET_API libnet_ptag_t libnet_build_802_3 (const uint8_t * dst, const
776       uint8_t * src, uint16_t len, const uint8_t * payload, uint32_t
777       payload_s, libnet_t * l, libnet_ptag_t ptag)
778       Builds an IEEE 802.3 header. The 802.3 header is almost identical to
779       the RFC 894 Ethernet II header, the exception being that the field
780       immediately following the source address holds the frame's length (as
781       opposed to the layer 3 protocol). You should only use this function
782       when libnet is initialized with the LIBNET_LINK interface.
783
784       Parameters
785           dst destination ethernet address
786           src source ethernet address
787           len frame length sans header
788           payload optional payload or NULL
789           payload_s payload length or 0
790           l pointer to a libnet context
791           ptag protocol tag to modify an existing header, 0 to build a new
792           one
793
794       Returns
795           protocol tag value on success
796
797       Return values
798           -1 on error
799
800   LIBNET_API libnet_ptag_t libnet_build_arp (uint16_t hrd, uint16_t pro,
801       uint8_t hln, uint8_t pln, uint16_t op, const uint8_t * sha, const
802       uint8_t * spa, const uint8_t * tha, const uint8_t * tpa, const uint8_t
803       * payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
804       Builds an Address Resolution Protocol (ARP) header. Depending on the op
805       value, the function builds one of several different types of RFC 826 or
806       RFC 903 RARP packets.
807
808       Parameters
809           hrd hardware address format
810           pro protocol address format
811           hln hardware address length
812           pln protocol address length
813           op ARP operation type
814           sha sender's hardware address
815           spa sender's protocol address
816           tha target hardware address
817           tpa target protocol address
818           payload optional payload or NULL
819           payload_s payload length or 0
820           l pointer to a libnet context
821           ptag protocol tag to modify an existing header, 0 to build a new
822           one
823
824       Returns
825           protocol tag value on success
826
827       Return values
828           -1 on error
829
830   LIBNET_API libnet_ptag_t libnet_build_bgp4_header (uint8_t
831       marker[LIBNET_BGP4_MARKER_SIZE], uint16_t len, uint8_t type, const
832       uint8_t * payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t
833       ptag)
834       Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) header. The
835       primary function of a BGP speaking system is to exchange network
836       reachability information with other BGP systems. This network
837       reachability information includes information on the list of Autonomous
838       Systems (ASs) that reachability information traverses. This information
839       is sufficient to construct a graph of AS connectivity from which
840       routing loops may be pruned and some policy decisions at the AS level
841       may be enforced. This function builds the base BGP header which is used
842       as a preamble before any other BGP header. For example, a BGP KEEPALIVE
843       message may be built with only this function, while an error
844       notification requires a subsequent call to
845       libnet_build_bgp4_notification.
846
847       Parameters
848           marker a value the receiver can predict (if the message type is not
849           BGP OPEN, or no authentication is used, these 16 bytes are normally
850           set as all ones)
851           len total length of the BGP message, including the header
852           type type code of the message (OPEN, UPDATE, NOTIFICATION or
853           KEEPALIVE)
854           payload optional payload or NULL
855           payload_s payload length or 0
856           l pointer to a libnet context
857           ptag protocol tag to modify an existing header, 0 to build a new
858           one
859
860       Returns
861           protocol tag value on success
862
863       Return values
864           -1 on error
865
866   LIBNET_API libnet_ptag_t libnet_build_bgp4_notification (uint8_t err_code,
867       uint8_t err_subcode, const uint8_t * payload, uint32_t payload_s,
868       libnet_t * l, libnet_ptag_t ptag)
869       Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) notification
870       header. A NOTIFICATION message is sent when an error condition is
871       detected. Specific error information may be passed through the payload
872       interface.
873
874       Parameters
875           err_code type of notification
876           err_subcode more specific information about the reported error.
877           payload optional payload or NULL
878           payload_s payload length or 0
879           l pointer to a libnet context
880           ptag protocol tag to modify an existing header, 0 to build a new
881           one
882
883       Returns
884           protocol tag value on success
885
886       Return values
887           -1 on error
888
889   LIBNET_API libnet_ptag_t libnet_build_bgp4_open (uint8_t version, uint16_t
890       src_as, uint16_t hold_time, uint32_t bgp_id, uint8_t opt_len, const
891       uint8_t * payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t
892       ptag)
893       Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) OPEN header. This
894       is the first message sent by each side of a BGP connection. The
895       optional parameters options should be constructed using the payload
896       interface (see RFC 1771 for the options structures).
897
898       Parameters
899           version protocol version (should be set to 4)
900           src_as Autonomous System of the sender
901           hold_time used to compute the maximum allowed time between the
902           receipt of KEEPALIVE, and/or UPDATE messages by the sender
903           bgp_id BGP identifier of the sender
904           opt_len total length of the optional parameters field in bytes
905           payload optional payload or NULL
906           payload_s payload length or 0
907           l pointer to a libnet context
908           ptag protocol tag to modify an existing header, 0 to build a new
909           one
910
911       Returns
912           protocol tag value on success
913
914       Return values
915           -1 on error
916
917   LIBNET_API libnet_ptag_t libnet_build_bgp4_update (uint16_t
918       unfeasible_rt_len, const uint8_t * withdrawn_rt, uint16_t
919       total_path_attr_len, const uint8_t * path_attributes, uint16_t
920       info_len, uint8_t * reachability_info, const uint8_t * payload,
921       uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
922       Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) update header.
923       Update messages are used to transfer routing information between BGP
924       peers.
925
926       Parameters
927           unfeasible_rt_len indicates the length of the (next) 'withdrawn
928           routes' field in bytes
929           withdrawn_rt list of IP addresses prefixes for the routes that are
930           being withdrawn; each IP address prefix is built as a 2-tuple
931           <length (1 byte), prefix (variable)>
932           total_path_attr_len indicates the length of the (next) 'path
933           attributes' field in bytes
934           path_attributes each attribute is a 3-tuple <type (2 bytes),
935           length, value>
936           info_len indicates the length of the (next) 'network layer
937           reachability information' field in bytes (needed for internal
938           memory size calculation)
939           reachability_info 2-tuples <length (1 byte), prefix (variable)>.
940           payload optional payload or NULL
941           payload_s payload length or 0
942           l pointer to a libnet context
943           ptag protocol tag to modify an existing header, 0 to build a new
944           one
945
946       Returns
947           protocol tag value on success
948
949       Return values
950           -1 on error
951
952   LIBNET_API libnet_ptag_t libnet_build_bootpv4 (uint8_t opcode, uint8_t
953       htype, uint8_t hlen, uint8_t hopcount, uint32_t xid, uint16_t secs,
954       uint16_t flags, uint32_t cip, uint32_t yip, uint32_t sip, uint32_t gip,
955       const uint8_t * chaddr, const char * sname, const char * file, const
956       uint8_t * payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t
957       ptag)
958       Parameters
959           opcode
960           htype
961           hlen
962           hopcount
963           xid
964           secs
965           flags
966           cip
967           yip
968           sip
969           gip
970           chaddr client hardware address, length is hlen
971           sname server host name, a null terminated string
972           file boot file name, a null terminated string
973           payload optional payload or NULL
974           payload_s payload length or 0
975           l pointer to a libnet context
976           ptag protocol tag to modify an existing header, 0 to build a new
977           one
978
979       Returns
980           protocol tag value on success
981
982       Return values
983           -1 on error
984
985   LIBNET_API libnet_ptag_t libnet_build_cdp (uint8_t version, uint8_t ttl,
986       uint16_t sum, uint16_t type, uint16_t value_s, const uint8_t * value,
987       const uint8_t * payload, uint32_t payload_s, libnet_t * l,
988       libnet_ptag_t ptag)
989       Builds a Cisco Discovery Protocol (CDP) header. Cisco Systems designed
990       CDP to aid in the network management of adjacent Cisco devices. The CDP
991       protocol specifies data by using a type/length/value (TLV) setup. The
992       first TLV can specified by using the functions type, length, and value
993       arguments. To specify additional TLVs, the programmer could either use
994       the payload interface or libnet_build_data() to construct them.
995
996       Parameters
997           version CDP version
998           ttl time to live (time information should be cached by recipient)
999           sum checksum (0 for libnet to auto-fill)
1000           type type of data contained in value
1001           value_s length of value argument
1002           value the CDP information string
1003           payload optional payload or NULL
1004           payload_s payload length or 0
1005           l pointer to a libnet context
1006           ptag protocol tag to modify an existing header, 0 to build a new
1007           one
1008
1009       Returns
1010           protocol tag value on success
1011
1012       Return values
1013           -1 on error
1014
1015   LIBNET_API libnet_ptag_t libnet_build_data (const uint8_t * payload,
1016       uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
1017       Builds a generic libnet protocol header. This is useful for including
1018       an optional payload to a packet that might need to change repeatedly
1019       inside of a loop. This won't work for TCP or IP payload, they have
1020       special types (this is probably a bug).
1021
1022       Parameters
1023           payload optional payload or NULL
1024           payload_s payload length or 0
1025           l pointer to a libnet context
1026           ptag protocol tag to modify an existing header, 0 to build a new
1027           one
1028
1029       Returns
1030           protocol tag value on success
1031
1032       Return values
1033           -1 on error
1034
1035   LIBNET_API libnet_ptag_t libnet_build_dhcpv4 (uint8_t opcode, uint8_t
1036       htype, uint8_t hlen, uint8_t hopcount, uint32_t xid, uint16_t secs,
1037       uint16_t flags, uint32_t cip, uint32_t yip, uint32_t sip, uint32_t gip,
1038       const uint8_t * chaddr, const char * sname, const char * file, const
1039       uint8_t * payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t
1040       ptag)
1041       Parameters
1042           opcode
1043           htype
1044           hlen
1045           hopcount
1046           xid
1047           secs
1048           flags
1049           cip
1050           yip
1051           sip
1052           gip
1053           chaddr client hardware address, length is hlen
1054           sname server host name, a null terminated string
1055           file boot file name, a null terminated string
1056           payload optional payload or NULL
1057           payload_s payload length or 0
1058           l pointer to a libnet context
1059           ptag protocol tag to modify an existing header, 0 to build a new
1060           one
1061
1062       Returns
1063           protocol tag value on success
1064
1065       Return values
1066           -1 on error
1067
1068   LIBNET_API libnet_ptag_t libnet_build_dnsv4 (uint16_t h_len, uint16_t id,
1069       uint16_t flags, uint16_t num_q, uint16_t num_anws_rr, uint16_t
1070       num_auth_rr, uint16_t num_addi_rr, const uint8_t * payload, uint32_t
1071       payload_s, libnet_t * l, libnet_ptag_t ptag)
1072       Builds an RFC 1035 version 4 DNS header. Additional DNS payload
1073       information should be specified using the payload interface.
1074
1075       Parameters
1076           h_len
1077           id DNS packet id
1078           flags control flags
1079           num_q number of questions
1080           num_anws_rr number of answer resource records
1081           num_auth_rr number of authority resource records
1082           num_addi_rr number of additional resource records
1083           payload optional payload or NULL
1084           payload_s payload length or 0
1085           l pointer to a libnet context
1086           ptag protocol tag to modify an existing header, 0 to build a new
1087           one
1088
1089       Returns
1090           protocol tag value on success
1091
1092       Return values
1093           -1 on error
1094
1095   LIBNET_API libnet_ptag_t libnet_build_egre (uint16_t fv, uint16_t type,
1096       uint16_t sum, uint16_t offset, uint32_t key, uint32_t seq, uint16_t
1097       len, const uint8_t * payload, uint32_t payload_s, libnet_t * l,
1098       libnet_ptag_t ptag)
1099       Generic Routing Encapsulation (GRE - RFC 1701) is used to encapsulate
1100       any protocol. Hence, the IP part of the packet is usually referred as
1101       'delivery header'. It is then followed by the GRE header and finally
1102       the encapsulated packet (IP or whatever). As GRE is very modular, the
1103       first GRE header describes the structure of the header, using bits and
1104       flag to specify which fields will be present in the header.
1105
1106       Parameters
1107           fv the 16 0 to 7: which fields are included in the header
1108           (checksum, seq. number, key, ...), bits 8 to 12: flag, bits 13 to
1109           15: version.
1110           type which protocol is encapsulated (PPP, IP, ...)
1111           sum checksum (0 for libnet to auto-fill).
1112           offset byte offset from the start of the routing field to the first
1113           byte of the SRE
1114           key inserted by the encapsulator to authenticate the source
1115           seq sequence number used by the receiver to sort the packets
1116           len size of the GRE packet
1117           payload optional payload or NULL
1118           payload_s payload length or 0
1119           l pointer to a libnet context
1120           ptag protocol tag to modify an existing header, 0 to build a new
1121           one
1122
1123       Returns
1124           protocol tag value on success
1125
1126       Return values
1127           -1 on error
1128
1129   LIBNET_API libnet_ptag_t libnet_build_ethernet (const uint8_t * dst, const
1130       uint8_t * src, uint16_t type, const uint8_t * payload, uint32_t
1131       payload_s, libnet_t * l, libnet_ptag_t ptag)
1132       Builds an Ethernet header. The RFC 894 Ethernet II header is almost
1133       identical to the IEEE 802.3 header, with the exception that the field
1134       immediately following the source address holds the layer 3 protocol (as
1135       opposed to frame's length). You should only use this function when
1136       libnet is initialized with the LIBNET_LINK interface.
1137
1138       Parameters
1139           dst destination ethernet address
1140           src source ethernet address
1141           type upper layer protocol type
1142           payload optional payload or NULL
1143           payload_s payload length or 0
1144           l pointer to a libnet context
1145           ptag protocol tag to modify an existing header, 0 to build a new
1146           one
1147
1148       Returns
1149           protocol tag value on success
1150
1151       Return values
1152           -1 on error
1153
1154   LIBNET_API libnet_ptag_t libnet_build_fddi (uint8_t fc, const uint8_t *
1155       dst, const uint8_t * src, uint8_t dsap, uint8_t ssap, uint8_t cf, const
1156       uint8_t * oui, uint16_t type, const uint8_t * payload, uint32_t
1157       payload_s, libnet_t * l, libnet_ptag_t ptag)
1158       Builds a Fiber Distributed Data Interface (FDDI) header.
1159
1160       Parameters
1161           fc class format and priority
1162           dst destination fddi address
1163           src source fddi address
1164           dsap destination service access point
1165           ssap source service access point
1166           cf cf
1167           oui 3 byte IEEE organizational code
1168           type upper layer protocol
1169           payload optional payload or NULL
1170           payload_s payload length or 0
1171           l pointer to a libnet context
1172           ptag protocol tag to modify an existing header, 0 to build a new
1173           one
1174
1175       Returns
1176           protocol tag value on success
1177
1178       Return values
1179           -1 on error
1180
1181   LIBNET_API libnet_ptag_t libnet_build_gre (uint16_t fv, uint16_t type,
1182       uint16_t sum, uint16_t offset, uint32_t key, uint32_t seq, uint16_t
1183       len, const uint8_t * payload, uint32_t payload_s, libnet_t * l,
1184       libnet_ptag_t ptag)
1185       Generic Routing Encapsulation (GRE - RFC 1701) is used to encapsulate
1186       any protocol. Hence, the IP part of the packet is usually referred as
1187       'delivery header'. It is then followed by the GRE header and finally
1188       the encapsulated packet (IP or whatever). As GRE is very modular, the
1189       first GRE header describes the structure of the header, using bits and
1190       flag to specify which fields will be present in the header.
1191
1192       Parameters
1193           fv the 16 0 to 7: which fields are included in the header
1194           (checksum, seq. number, key, ...), bits 8 to 12: flag, bits 13 to
1195           15: version.
1196           type which protocol is encapsulated (PPP, IP, ...)
1197           sum checksum (0 for libnet to auto-fill).
1198           offset byte offset from the start of the routing field to the first
1199           byte of the SRE
1200           key inserted by the encapsulator to authenticate the source
1201           seq sequence number used by the receiver to sort the packets
1202           len size of the GRE packet
1203           payload
1204           payload_s payload length or 0
1205           l pointer to a libnet context
1206           ptag protocol tag to modify an existing header, 0 to build a new
1207           one
1208
1209       Returns
1210           protocol tag value on success
1211
1212       Return values
1213           -1 on error
1214
1215   LIBNET_API libnet_ptag_t libnet_build_gre_last_sre (libnet_t * l,
1216       libnet_ptag_t ptag)
1217       Parameters
1218           l pointer to a libnet context
1219           ptag protocol tag to modify an existing header, 0 to build a new
1220           one
1221
1222       Returns
1223           protocol tag value on success
1224
1225       Return values
1226           -1 on error
1227
1228   LIBNET_API libnet_ptag_t libnet_build_gre_sre (uint16_t af, uint8_t offset,
1229       uint8_t length, uint8_t * routing, const uint8_t * payload, uint32_t
1230       payload_s, libnet_t * l, libnet_ptag_t ptag)
1231       Parameters
1232           af
1233           offset
1234           length
1235           routing
1236           payload optional payload or NULL
1237           payload_s payload length or 0
1238           l pointer to a libnet context
1239           ptag protocol tag to modify an existing header, 0 to build a new
1240           one
1241
1242       Returns
1243           protocol tag value on success
1244
1245       Return values
1246           -1 on error
1247
1248   LIBNET_API libnet_ptag_t libnet_build_hsrp (uint8_t version, uint8_t
1249       opcode, uint8_t state, uint8_t hello_time, uint8_t hold_time, uint8_t
1250       priority, uint8_t group, uint8_t reserved, uint8_t
1251       authdata[HSRP_AUTHDATA_LENGTH], uint32_t virtual_ip, const uint8_t *
1252       payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
1253       Builds a HSRP header. HSRP is a Cisco proprietary protocol defined in
1254       RFC 2281
1255
1256       Parameters
1257           version version of the HSRP messages
1258           opcode type of message
1259           state current state of the router
1260           hello_time period in seconds between hello messages
1261           hold_time seconds that the current hello message is valid
1262           priority priority for the election process
1263           group standby group
1264           reserved reserved field
1265           authdata password
1266           virtual_ip virtual ip address
1267           payload optional payload or NULL
1268           payload_s payload length or 0
1269           l pointer to a libnet context
1270           ptag protocol tag to modify an existing header, 0 to build a new
1271           one
1272
1273       Returns
1274           protocol tag value on success
1275
1276       Return values
1277           -1 on error
1278
1279   LIBNET_API libnet_ptag_t libnet_build_icmpv4_echo (uint8_t type, uint8_t
1280       code, uint16_t sum, uint16_t id, uint16_t seq, const uint8_t * payload,
1281       uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
1282       Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
1283       echo request/reply header
1284
1285       Parameters
1286           type type of ICMP packet (should be ICMP_ECHOREPLY or ICMP_ECHO)
1287           code code of ICMP packet (should be 0)
1288           sum checksum (0 for libnet to auto-fill)
1289           id identification number
1290           seq packet sequence number
1291           payload optional payload or NULL
1292           payload_s payload length or 0
1293           l pointer to a libnet context
1294           ptag protocol tag to modify an existing header, 0 to build a new
1295           one
1296
1297       Returns
1298           protocol tag value on success
1299
1300       Return values
1301           -1 on error
1302
1303   LIBNET_API libnet_ptag_t libnet_build_icmpv4_mask (uint8_t type, uint8_t
1304       code, uint16_t sum, uint16_t id, uint16_t seq, uint32_t mask, const
1305       uint8_t * payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t
1306       ptag)
1307       Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
1308       IP netmask request/reply header.
1309
1310       Parameters
1311           type type of ICMP packet (should be ICMP_MASKREQ or ICMP_MASKREPLY)
1312           code code of ICMP packet (should be 0)
1313           sum checksum (0 for libnet to auto-fill)
1314           id identification number
1315           seq packet sequence number
1316           mask subnet mask
1317           payload optional payload or NULL
1318           payload_s payload length or 0
1319           l pointer to a libnet context
1320           ptag protocol tag to modify an existing header, 0 to build a new
1321           one
1322
1323       Returns
1324           protocol tag value on success
1325
1326       Return values
1327           -1 on error
1328
1329   LIBNET_API libnet_ptag_t libnet_build_icmpv4_redirect (uint8_t type,
1330       uint8_t code, uint16_t sum, uint32_t gateway, const uint8_t * payload,
1331       uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
1332       Builds an IP version 4 RFC 792 Internet Message Control Protocol (ICMP)
1333       redirect header. The IP header that caused the error message should be
1334       built by a previous call to libnet_build_ipv4().
1335
1336       Parameters
1337           type type of ICMP packet (should be ICMP_REDIRECT)
1338           code code of ICMP packet (should be one of the four redirect codes)
1339           sum checksum (0 for libnet to auto-fill)
1340           gateway
1341           payload optional payload or NULL
1342           payload_s payload length or 0
1343           l pointer to a libnet context
1344           ptag protocol tag to modify an existing header, 0 to build a new
1345           one
1346
1347       Returns
1348           protocol tag value on success
1349
1350       Return values
1351           -1 on error
1352
1353   LIBNET_API libnet_ptag_t libnet_build_icmpv4_timeexceed (uint8_t type,
1354       uint8_t code, uint16_t sum, const uint8_t * payload, uint32_t
1355       payload_s, libnet_t * l, libnet_ptag_t ptag)
1356       Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
1357       time exceeded header. The IP header that caused the error message
1358       should be built by a previous call to libnet_build_ipv4().
1359
1360       Parameters
1361           type type of ICMP packet (should be ICMP_TIMXCEED)
1362           code code of ICMP packet (ICMP_TIMXCEED_INTRANS /
1363           ICMP_TIMXCEED_REASS)
1364           sum checksum (0 for libnet to auto-fill)
1365           payload optional payload or NULL
1366           payload optional payload or NULL
1367           payload_s payload length or 0
1368           l pointer to a libnet context
1369           ptag protocol tag to modify an existing header, 0 to build a new
1370           one
1371
1372       Returns
1373           protocol tag value on success
1374
1375       Return values
1376           -1 on error
1377
1378   LIBNET_API libnet_ptag_t libnet_build_icmpv4_timestamp (uint8_t type,
1379       uint8_t code, uint16_t sum, uint16_t id, uint16_t seq, uint32_t otime,
1380       uint32_t rtime, uint32_t ttime, const uint8_t * payload, uint32_t
1381       payload_s, libnet_t * l, libnet_ptag_t ptag)
1382       Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
1383       timestamp request/reply header.
1384
1385       Parameters
1386           type type of ICMP packet (should be ICMP_TSTAMP or
1387           ICMP_TSTAMPREPLY)
1388           code code of ICMP packet (should be 0)
1389           sum checksum (0 for libnet to auto-fill)
1390           id identification number
1391           seq sequence number
1392           otime originate timestamp
1393           rtime receive timestamp
1394           ttime transmit timestamp
1395           payload optional payload or NULL
1396           payload_s payload length or 0
1397           l pointer to a libnet context
1398           ptag protocol tag to modify an existing header, 0 to build a new
1399           one
1400
1401       Returns
1402           protocol tag value on success
1403
1404       Return values
1405           -1 on error
1406
1407   LIBNET_API libnet_ptag_t libnet_build_icmpv4_unreach (uint8_t type, uint8_t
1408       code, uint16_t sum, const uint8_t * payload, uint32_t payload_s,
1409       libnet_t * l, libnet_ptag_t ptag)
1410       Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
1411       unreachable header. The IP header that caused the error message should
1412       be built by a previous call to libnet_build_ipv4().
1413
1414       Parameters
1415           type type of ICMP packet (should be ICMP_UNREACH)
1416           code code of ICMP packet (should be one of the 16 unreachable
1417           codes)
1418           sum checksum (0 for libnet to auto-fill)
1419           payload optional payload or NULL
1420           payload_s payload length or 0
1421           l pointer to a libnet context
1422           ptag protocol tag to modify an existing header, 0 to build a new
1423           one
1424
1425       Returns
1426           protocol tag value on success
1427
1428       Return values
1429           -1 on error
1430
1431   LIBNET_API libnet_ptag_t libnet_build_icmpv6_echo (uint8_t type, uint8_t
1432       code, uint16_t sum, uint16_t id, uint16_t seq, uint8_t * payload,
1433       uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
1434       Builds an IP version 6 RFC 4443 Internet Control Message Protocol
1435       (ICMP) echo or echo reply header.
1436
1437       Parameters
1438           type type of ICMP packet (should be ICMP6_ECHO_REQUEST or
1439           ICMP6_ECHO_REPLY)
1440           code code of ICMP packet (should be zero)
1441           sum checksum (0 for libnet to auto-fill)
1442           id echo id number
1443           seq echo sequence number
1444           payload optional payload or NULL
1445           payload_s payload length or 0
1446           l pointer to a libnet context
1447           ptag protocol tag to modify an existing header, 0 to build a new
1448           one
1449
1450       Returns
1451           protocol tag value on success
1452
1453       Return values
1454           -1 on error
1455
1456   LIBNET_API libnet_ptag_t libnet_build_icmpv6_ndp_nadv (uint8_t type,
1457       uint8_t code, uint16_t sum, uint32_t flags, struct libnet_in6_addr
1458       target, uint8_t * payload, uint32_t payload_s, libnet_t * l,
1459       libnet_ptag_t ptag)
1460       Builds an IP version 6 RFC 2461 Internet Control Message Protocol
1461       (ICMP) NDP neighbour advertisement header. Could be used with
1462       libnet_build_icmpv6_ndp_opt() and ND_OPT_TARGET_LINKADDR.
1463
1464       Parameters
1465           type type of ICMP packet (should be ND_NEIGHBOR_ADVERT)
1466           code code of ICMP packet (should be zero)
1467           sum checksum (0 for libnet to auto-fill)
1468           flags should be a bitwise or of any applicable ND_NA_FLAG_* flags
1469           target target ipv6 address
1470           payload optional payload or NULL
1471           payload_s payload length or 0
1472           l pointer to a libnet context
1473           ptag protocol tag to modify an existing header, 0 to build a new
1474           one
1475
1476       Returns
1477           protocol tag value on success
1478
1479       Return values
1480           -1 on error
1481
1482   LIBNET_API libnet_ptag_t libnet_build_icmpv6_ndp_nsol (uint8_t type,
1483       uint8_t code, uint16_t sum, struct libnet_in6_addr target, uint8_t *
1484       payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
1485       Builds an IP version 6 RFC 2461 Internet Control Message Protocol
1486       (ICMP) NDP neighbour solicitation header. Could be used with
1487       libnet_build_icmpv6_ndp_opt() and ICMPV6_NDP_OPT_SLLA.
1488
1489       Parameters
1490           type type of ICMP packet (should be ND_NEIGHBOR_SOLICIT)
1491           code code of ICMP packet (should be zero)
1492           sum checksum (0 for libnet to auto-fill)
1493           target target ipv6 address
1494           payload optional payload or NULL
1495           payload_s payload length or 0
1496           l pointer to a libnet context
1497           ptag protocol tag to modify an existing header, 0 to build a new
1498           one
1499
1500       Returns
1501           protocol tag value on success
1502
1503       Return values
1504           -1 on error
1505
1506   LIBNET_API libnet_ptag_t libnet_build_icmpv6_ndp_opt (uint8_t type, uint8_t
1507       * option, uint32_t option_s, libnet_t * l, libnet_ptag_t ptag)
1508       Builds ICMPv6 NDP options.
1509
1510       Parameters
1511           type one of ND_OPT_* types
1512           option option data
1513           option_s size of option data (will be padded out to an 8-byte
1514           boundary)
1515           l pointer to a libnet context
1516           ptag protocol tag to modify an existing header, 0 to build a new
1517           one
1518
1519       Returns
1520           protocol tag value on success
1521
1522       Return values
1523           -1 on error
1524
1525   LIBNET_API libnet_ptag_t libnet_build_icmpv6_unreach (uint8_t type, uint8_t
1526       code, uint16_t sum, uint8_t * payload, uint32_t payload_s, libnet_t *
1527       l, libnet_ptag_t ptag)
1528       Builds an IP version 6 RFC 4443 Internet Control Message Protocol
1529       (ICMP) unreachable header. The IP header that caused the error message
1530       should be built by a previous call to libnet_build_ipv6().
1531
1532       Parameters
1533           type type of ICMP packet (should be ICMP6_DST_UNREACH)
1534           code code of ICMP packet (should be one of the 5
1535           ICMP6_DST_UNREACH_* codes)
1536           sum checksum (0 for libnet to auto-fill)
1537           payload optional payload or NULL
1538           payload_s payload length or 0
1539           l pointer to a libnet context
1540           ptag protocol tag to modify an existing header, 0 to build a new
1541           one
1542
1543       Returns
1544           protocol tag value on success
1545
1546       Return values
1547           -1 on error
1548
1549   LIBNET_API libnet_ptag_t libnet_build_igmp (uint8_t type, uint8_t reserved,
1550       uint16_t sum, uint32_t ip, const uint8_t * payload, uint32_t payload_s,
1551       libnet_t * l, libnet_ptag_t ptag)
1552       Builds an RFC 1112 Internet Group Membership Protocol (IGMP) header.
1553
1554       Parameters
1555           type packet type
1556           reserved (should be 0 for IGMPv1)
1557           sum checksum (0 for libnet to auto-fill)
1558           ip IPv4 address (in standard/network byte order)
1559           payload optional payload or NULL
1560           payload_s payload length or 0
1561           l pointer to a libnet context
1562           ptag protocol tag to modify an existing header, 0 to build a new
1563           one
1564
1565       Returns
1566           protocol tag value on success
1567
1568       Return values
1569           -1 on error
1570
1571       Note
1572
1573   LIBNET_API libnet_ptag_t libnet_build_ipsec_ah (uint8_t nh, uint8_t len,
1574       uint16_t res, uint32_t spi, uint32_t seq, uint32_t auth, const uint8_t
1575       * payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
1576       Builds an Internet Protocol Security Authentication header.
1577
1578       Parameters
1579           nh next header
1580           len payload length
1581           res reserved
1582           spi security parameter index
1583           seq sequence number
1584           auth authentication data
1585           payload optional payload or NULL
1586           payload_s payload length or 0
1587           l pointer to a libnet context
1588           ptag protocol tag to modify an existing header, 0 to build a new
1589           one
1590
1591       Returns
1592           protocol tag value on success
1593
1594       Return values
1595           -1 on error
1596
1597   LIBNET_API libnet_ptag_t libnet_build_ipsec_esp_ftr (uint8_t len, uint8_t
1598       nh, int8_t * auth, const uint8_t * payload, uint32_t payload_s,
1599       libnet_t * l, libnet_ptag_t ptag)
1600       Builds an Internet Protocol Security Encapsulating Security Payload
1601       footer.
1602
1603       Parameters
1604           len padding length
1605           nh next header
1606           auth authentication data
1607           payload optional payload or NULL
1608           payload_s payload length or 0
1609           l pointer to a libnet context
1610           ptag protocol tag to modify an existing header, 0 to build a new
1611           one
1612
1613       Returns
1614           protocol tag value on success
1615
1616       Return values
1617           -1 on error
1618
1619   LIBNET_API libnet_ptag_t libnet_build_ipsec_esp_hdr (uint32_t spi, uint32_t
1620       seq, uint32_t iv, const uint8_t * payload, uint32_t payload_s, libnet_t
1621       * l, libnet_ptag_t ptag)
1622       Builds an Internet Protocol Security Encapsulating Security Payload
1623       header.
1624
1625       Parameters
1626           spi security parameter index
1627           seq ESP sequence number
1628           iv initialization vector
1629           payload optional payload or NULL
1630           payload_s payload length or 0
1631           l pointer to a libnet context
1632           ptag protocol tag to modify an existing header, 0 to build a new
1633           one
1634
1635       Returns
1636           protocol tag value on success
1637
1638       Return values
1639           -1 on error
1640
1641   LIBNET_API libnet_ptag_t libnet_build_ipv4 (uint16_t ip_len, uint8_t tos,
1642       uint16_t id, uint16_t frag, uint8_t ttl, uint8_t prot, uint16_t sum,
1643       uint32_t src, uint32_t dst, const uint8_t * payload, uint32_t
1644       payload_s, libnet_t * l, libnet_ptag_t ptag)
1645       Builds a version 4 RFC 791 Internet Protocol (IP) header.
1646
1647       Parameters
1648           ip_len total length of the IP packet including all subsequent data
1649           (subsequent data includes any IP options and IP options padding)
1650           tos type of service bits
1651           id IP identification number
1652           frag fragmentation bits and offset
1653           ttl time to live in the network
1654           prot upper layer protocol
1655           sum checksum (0 for libnet to auto-fill)
1656           src source IPv4 address (little endian)
1657           dst destination IPv4 address (little endian)
1658           payload optional payload or NULL
1659           payload_s payload length or 0
1660           l pointer to a libnet context
1661           ptag protocol tag to modify an existing header, 0 to build a new
1662           one
1663
1664       Returns
1665           protocol tag value on success
1666
1667       Return values
1668           -1 on error
1669
1670   LIBNET_API libnet_ptag_t libnet_build_ipv4_options (const uint8_t *
1671       options, uint32_t options_s, libnet_t * l, libnet_ptag_t ptag)
1672       Builds an version 4 Internet Protocol (IP) options header. The function
1673       expects options to be a valid IP options string of size options_s, no
1674       larger than 40 bytes (the maximum size of an options string).
1675
1676       When building a chain, the options must be built, then the IPv4 header.
1677
1678       When updating a chain, if the block following the options is an IPv4
1679       header, it's total length and header length will be updated if the
1680       options block size changes.
1681
1682       Parameters
1683           options byte string of IP options (it will be padded up to be an
1684           integral multiple of 32-bit words).
1685           options_s length of options string
1686           l pointer to a libnet context
1687           ptag protocol tag to modify an existing header, 0 to build a new
1688           one
1689
1690       Returns
1691           protocol tag value on success
1692
1693       Return values
1694           -1 on error
1695
1696   LIBNET_API libnet_ptag_t libnet_build_ipv6 (uint8_t tc, uint32_t fl,
1697       uint16_t len, uint8_t nh, uint8_t hl, struct libnet_in6_addr src,
1698       struct libnet_in6_addr dst, const uint8_t * payload, uint32_t
1699       payload_s, libnet_t * l, libnet_ptag_t ptag)
1700       Builds a version 6 RFC 2460 Internet Protocol (IP) header.
1701
1702       Parameters
1703           tc traffic class
1704           fl flow label
1705           len total length of the IP packet
1706           nh next header
1707           hl hop limit
1708           src source IPv6 address
1709           dst destination IPv6 address
1710           payload optional payload or NULL
1711           payload_s payload length or 0
1712           l pointer to a libnet context
1713           ptag protocol tag to modify an existing header, 0 to build a new
1714           one
1715
1716       Returns
1717           protocol tag value on success
1718
1719       Return values
1720           -1 on error
1721
1722   LIBNET_API libnet_ptag_t libnet_build_ipv6_destopts (uint8_t nh, uint8_t
1723       len, const uint8_t * payload, uint32_t payload_s, libnet_t * l,
1724       libnet_ptag_t ptag)
1725       Builds a version 6 RFC 2460 Internet Protocol (IP) destination options
1726       header. This function is special in that it uses the payload interface
1727       to include the options data. The application programmer will build an
1728       IPv6 options byte string and pass it to the function using the payload
1729       interface.
1730
1731       Parameters
1732           nh next header
1733           len length of the header in 8-byte octets not including the first 8
1734           octets
1735           payload options payload
1736           payload_s payload length
1737           l pointer to a libnet context
1738           ptag protocol tag to modify an existing header, 0 to build a new
1739           one
1740
1741       Returns
1742           protocol tag value on success
1743
1744       Return values
1745           -1 on error
1746
1747   LIBNET_API libnet_ptag_t libnet_build_ipv6_frag (uint8_t nh, uint8_t
1748       reserved, uint16_t frag, uint32_t id, const uint8_t * payload, uint32_t
1749       payload_s, libnet_t * l, libnet_ptag_t ptag)
1750       Builds a version 6 RFC 2460 Internet Protocol (IP) fragmentation
1751       header.
1752
1753       Parameters
1754           nh next header
1755           reserved unused value... OR IS IT!
1756           frag fragmentation bits (ala ipv4)
1757           id packet identification
1758           payload optional payload or NULL
1759           payload_s payload length or 0
1760           l pointer to a libnet context
1761           ptag protocol tag to modify an existing header, 0 to build a new
1762           one
1763
1764       Returns
1765           protocol tag value on success
1766
1767       Return values
1768           -1 on error
1769
1770   LIBNET_API libnet_ptag_t libnet_build_ipv6_hbhopts (uint8_t nh, uint8_t
1771       len, const uint8_t * payload, uint32_t payload_s, libnet_t * l,
1772       libnet_ptag_t ptag)
1773       Builds a version 6 RFC 2460 Internet Protocol (IP) hop by hop options
1774       header. This function is special in that it uses the payload interface
1775       to include the options data. The application programmer will build an
1776       IPv6 hop by hop options byte string and pass it to the function using
1777       the payload interface.
1778
1779       Parameters
1780           nh next header
1781           len length of the header in 8-byte octets not including the first 8
1782           octets
1783           payload options payload
1784           payload_s payload length
1785           l pointer to a libnet context
1786           ptag protocol tag to modify an existing header, 0 to build a new
1787           one
1788
1789       Returns
1790           protocol tag value on success
1791
1792       Return values
1793           -1 on error
1794
1795   LIBNET_API libnet_ptag_t libnet_build_ipv6_routing (uint8_t nh, uint8_t
1796       len, uint8_t rtype, uint8_t segments, const uint8_t * payload, uint32_t
1797       payload_s, libnet_t * l, libnet_ptag_t ptag)
1798       Builds a version 6 RFC 2460 Internet Protocol (IP) routing header. This
1799       function is special in that it uses the payload interface to include
1800       the 'type-specific data'; that is the routing information. Most often
1801       this will be a number of 128-bit IPv6 addresses. The application
1802       programmer will build a byte string of IPv6 address and pass them to
1803       the function using the payload interface.
1804
1805       Parameters
1806           nh next header
1807           len length of the header in 8-byte octets not including the first 8
1808           octets
1809           rtype routing header type
1810           segments number of routing segments that follow
1811           payload optional payload of routing information
1812           payload_s payload length
1813           l pointer to a libnet context
1814           ptag protocol tag to modify an existing header, 0 to build a new
1815           one
1816
1817       Returns
1818           protocol tag value on success
1819
1820       Return values
1821           -1 on error
1822
1823   LIBNET_API libnet_ptag_t libnet_build_isl (uint8_t * dhost, uint8_t type,
1824       uint8_t user, uint8_t * shost, uint16_t len, const uint8_t * snap,
1825       uint16_t vid, uint16_t portindex, uint16_t reserved, const uint8_t *
1826       payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
1827       Builds a Cisco Inter-Switch Link (ISL) header.
1828
1829       Parameters
1830           dhost destination address (should be 01:00:0c:00:00)
1831           type type of frame
1832           user user defined data
1833           shost source mac address
1834           len total length of the encapsulated packet less 18 bytes
1835           snap SNAP information (0xaaaa03 + vendor code)
1836           vid 15 bit VLAN ID, 1 bit BPDU or CDP indicator
1837           portindex port index
1838           reserved used for FDDI and token ring
1839           payload optional payload or NULL
1840           payload_s payload length or 0
1841           l pointer to a libnet context
1842           ptag protocol tag to modify an existing header, 0 to build a new
1843           one
1844
1845       Returns
1846           protocol tag value on success
1847
1848       Return values
1849           -1 on error
1850
1851   LIBNET_API libnet_ptag_t libnet_build_link (const uint8_t * dst, const
1852       uint8_t * src, const uint8_t * oui, uint16_t type, const uint8_t *
1853       payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
1854       Builds a link layer header for an initialized l. The function
1855       determines the proper link layer header format from how l was
1856       initialized. The function current supports Ethernet and Token Ring link
1857       layers.
1858
1859       Parameters
1860           dst the destination MAC address
1861           src the source MAC address
1862           oui Organizationally Unique Identifier (unused for Ethernet)
1863           type the upper layer protocol type
1864           payload optional payload or NULL
1865           payload_s payload length or 0
1866           l pointer to a libnet context
1867           ptag protocol tag to modify an existing header, 0 to build a new
1868           one
1869
1870       Returns
1871           protocol tag value on success
1872
1873       Return values
1874           -1 on error
1875
1876   LIBNET_API libnet_ptag_t libnet_build_mpls (uint32_t label, uint8_t
1877       experimental, uint8_t bos, uint8_t ttl, const uint8_t * payload,
1878       uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
1879       Builds an RFC 3032 Multi-Protocol Label Switching (MPLS) header.
1880
1881       Parameters
1882           label 20-bit label value
1883           experimental 3-bit reserved field
1884           bos 1-bit bottom of stack identifier
1885           ttl time to live
1886           payload optional payload or NULL
1887           payload_s payload length or 0
1888           l pointer to a libnet context
1889           ptag protocol tag to modify an existing header, 0 to build a new
1890           one
1891
1892       Returns
1893           protocol tag value on success
1894
1895       Return values
1896           -1 on error
1897
1898   LIBNET_API libnet_ptag_t libnet_build_ntp (uint8_t leap_indicator, uint8_t
1899       version, uint8_t mode, uint8_t stratum, uint8_t poll, uint8_t
1900       precision, uint16_t delay_int, uint16_t delay_frac, uint16_t
1901       dispersion_int, uint16_t dispersion_frac, uint32_t reference_id,
1902       uint32_t ref_ts_int, uint32_t ref_ts_frac, uint32_t orig_ts_int,
1903       uint32_t orig_ts_frac, uint32_t rec_ts_int, uint32_t rec_ts_frac,
1904       uint32_t xmt_ts_int, uint32_t xmt_ts_frac, const uint8_t * payload,
1905       uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
1906       Builds an RFC 958 Network Time Protocol (NTP) header.
1907
1908       Parameters
1909           leap_indicator the leap indicator
1910           version NTP protocol version
1911           mode NTP mode
1912           stratum stratum
1913           poll polling interval
1914           precision precision
1915           delay_int delay interval
1916           delay_frac delay fraction
1917           dispersion_int dispersion interval
1918           dispersion_frac dispersion fraction
1919           reference_id reference id
1920           ref_ts_int reference timestamp integer
1921           ref_ts_frac reference timestamp fraction
1922           orig_ts_int original timestamp integer
1923           orig_ts_frac original timestamp fraction
1924           rec_ts_int receiver timestamp integer
1925           rec_ts_frac receiver timestamp fraction
1926           xmt_ts_int transmit timestamp integer
1927           xmt_ts_frac transmit timestamp integer
1928           payload optional payload or NULL
1929           payload_s payload length or 0
1930           l pointer to a libnet context
1931           ptag protocol tag to modify an existing header, 0 to build a new
1932           one
1933
1934       Returns
1935           protocol tag value on success
1936
1937       Return values
1938           -1 on error
1939
1940   LIBNET_API libnet_ptag_t libnet_build_ospfv2 (uint16_t len, uint8_t type,
1941       uint32_t rtr_id, uint32_t area_id, uint16_t sum, uint16_t autype, const
1942       uint8_t * payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t
1943       ptag)
1944       Parameters
1945           len
1946           type
1947           rtr_id
1948           area_id
1949           sum
1950           autype
1951           payload optional payload or NULL
1952           payload_s payload length or 0
1953           l pointer to a libnet context
1954           ptag protocol tag to modify an existing header, 0 to build a new
1955           one
1956
1957       Returns
1958           protocol tag value on success
1959
1960       Return values
1961           -1 on error
1962
1963   LIBNET_API libnet_ptag_t libnet_build_ospfv2_dbd (uint16_t dgram_len,
1964       uint8_t opts, uint8_t type, uint32_t seqnum, const uint8_t * payload,
1965       uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
1966       Parameters
1967           dgram_len
1968           opts
1969           type
1970           seqnum
1971           payload optional payload or NULL
1972           payload_s payload length or 0
1973           l pointer to a libnet context
1974           ptag protocol tag to modify an existing header, 0 to build a new
1975           one
1976
1977       Returns
1978           protocol tag value on success
1979
1980       Return values
1981           -1 on error
1982
1983   LIBNET_API libnet_ptag_t libnet_build_ospfv2_hello (uint32_t netmask,
1984       uint16_t interval, uint8_t opts, uint8_t priority, uint32_t dead_int,
1985       uint32_t des_rtr, uint32_t bkup_rtr, const uint8_t * payload, uint32_t
1986       payload_s, libnet_t * l, libnet_ptag_t ptag)
1987       Parameters
1988           netmask
1989           interval
1990           opts
1991           priority
1992           dead_int
1993           des_rtr
1994           bkup_rtr
1995           payload optional payload or NULL
1996           payload_s payload length or 0
1997           l pointer to a libnet context
1998           ptag protocol tag to modify an existing header, 0 to build a new
1999           one
2000
2001       Returns
2002           protocol tag value on success
2003
2004       Return values
2005           -1 on error
2006
2007   libnet_ptag_t libnet_build_ospfv2_hello_neighbor (uint32_t netmask,
2008       uint16_t interval, uint8_t opts, uint8_t priority, uint32_t dead_int,
2009       uint32_t des_rtr, uint32_t bkup_rtr, uint32_t neighbor, const uint8_t *
2010       payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
2011       Parameters
2012           netmask
2013           interval
2014           opts
2015           priority
2016           dead_int
2017           des_rtr
2018           bkup_rtr
2019           neighbor
2020           payload optional payload or NULL
2021           payload_s payload length or 0
2022           l pointer to a libnet context
2023           ptag protocol tag to modify an existing header, 0 to build a new
2024           one
2025
2026       Returns
2027           protocol tag value on success
2028
2029       Return values
2030           -1 on error
2031
2032   LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa (uint16_t age, uint8_t
2033       opts, uint8_t type, uint32_t lsid, uint32_t advrtr, uint32_t seqnum,
2034       uint16_t sum, uint16_t len, const uint8_t * payload, uint32_t
2035       payload_s, libnet_t * l, libnet_ptag_t ptag)
2036       Parameters
2037           age
2038           opts
2039           type
2040           lsid
2041           advrtr
2042           seqnum
2043           sum
2044           len
2045           payload optional payload or NULL
2046           payload_s payload length or 0
2047           l pointer to a libnet context
2048           ptag protocol tag to modify an existing header, 0 to build a new
2049           one
2050
2051       Returns
2052           protocol tag value on success
2053
2054       Return values
2055           -1 on error
2056
2057   LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa_as (uint32_t nmask,
2058       uint32_t metric, uint32_t fwdaddr, uint32_t tag, const uint8_t *
2059       payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
2060       Parameters
2061           nmask
2062           metric
2063           fwdaddr
2064           tag
2065           payload optional payload or NULL
2066           payload_s payload length or 0
2067           l pointer to a libnet context
2068           ptag protocol tag to modify an existing header, 0 to build a new
2069           one
2070
2071       Returns
2072           protocol tag value on success
2073
2074       Return values
2075           -1 on error
2076
2077   LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa_net (uint32_t nmask,
2078       uint32_t rtrid, const uint8_t * payload, uint32_t payload_s, libnet_t *
2079       l, libnet_ptag_t ptag)
2080       Parameters
2081           nmask
2082           rtrid
2083           payload optional payload or NULL
2084           payload_s payload length or 0
2085           l pointer to a libnet context
2086           ptag protocol tag to modify an existing header, 0 to build a new
2087           one
2088
2089       Returns
2090           protocol tag value on success
2091
2092       Return values
2093           -1 on error
2094
2095   LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa_rtr (uint16_t flags,
2096       uint16_t num, uint32_t id, uint32_t data, uint8_t type, uint8_t tos,
2097       uint16_t metric, const uint8_t * payload, uint32_t payload_s, libnet_t
2098       * l, libnet_ptag_t ptag)
2099       Parameters
2100           flags
2101           num
2102           id
2103           data
2104           type
2105           tos
2106           metric
2107           payload optional payload or NULL
2108           payload_s payload length or 0
2109           l pointer to a libnet context
2110           ptag protocol tag to modify an existing header, 0 to build a new
2111           one
2112
2113       Returns
2114           protocol tag value on success
2115
2116       Return values
2117           -1 on error
2118
2119   LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsa_sum (uint32_t nmask,
2120       uint32_t metric, uint32_t tos, const uint8_t * payload, uint32_t
2121       payload_s, libnet_t * l, libnet_ptag_t ptag)
2122       Parameters
2123           nmask
2124           metric
2125           tos
2126           payload optional payload or NULL
2127           payload_s payload length or 0
2128           l pointer to a libnet context
2129           ptag protocol tag to modify an existing header, 0 to build a new
2130           one
2131
2132       Returns
2133           protocol tag value on success
2134
2135       Return values
2136           -1 on error
2137
2138   LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsr (uint32_t type, uint32_t
2139       lsid, uint32_t advrtr, const uint8_t * payload, uint32_t payload_s,
2140       libnet_t * l, libnet_ptag_t ptag)
2141       Parameters
2142           type
2143           lsid
2144           advrtr
2145           payload optional payload or NULL
2146           payload_s payload length or 0
2147           l pointer to a libnet context
2148           ptag protocol tag to modify an existing header, 0 to build a new
2149           one
2150
2151       Returns
2152           protocol tag value on success
2153
2154       Return values
2155           -1 on error
2156
2157   LIBNET_API libnet_ptag_t libnet_build_ospfv2_lsu (uint32_t num, const
2158       uint8_t * payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t
2159       ptag)
2160       Parameters
2161           num
2162           payload optional payload or NULL
2163           payload_s payload length or 0
2164           l pointer to a libnet context
2165           ptag protocol tag to modify an existing header, 0 to build a new
2166           one
2167
2168       Returns
2169           protocol tag value on success
2170
2171       Return values
2172           -1 on error
2173
2174   LIBNET_API libnet_ptag_t libnet_build_rip (uint8_t cmd, uint8_t version,
2175       uint16_t rd, uint16_t af, uint16_t rt, uint32_t addr, uint32_t mask,
2176       uint32_t next_hop, uint32_t metric, const uint8_t * payload, uint32_t
2177       payload_s, libnet_t * l, libnet_ptag_t ptag)
2178       Builds a Routing Information Protocol header (RFCs 1058 and 2453).
2179
2180       Parameters
2181           cmd command
2182           version protocol version
2183           rd version one: 0, version two: routing domain
2184           af address family
2185           rt version one: 0, version two: route tag
2186           addr IPv4 address
2187           mask version one: 0, version two: subnet mask
2188           next_hop version one: 0, version two: next hop address
2189           metric routing metric
2190           payload optional payload or NULL
2191           payload_s payload length or 0
2192           l pointer to a libnet context
2193           ptag protocol tag to modify an existing header, 0 to build a new
2194           one
2195
2196       Returns
2197           protocol tag value on success
2198
2199       Return values
2200           -1 on error
2201
2202   LIBNET_API libnet_ptag_t libnet_build_rpc_call (uint32_t rm, uint32_t xid,
2203       uint32_t prog_num, uint32_t prog_vers, uint32_t procedure, uint32_t
2204       cflavor, uint32_t clength, uint8_t * cdata, uint32_t vflavor, uint32_t
2205       vlength, const uint8_t * vdata, const uint8_t * payload, uint32_t
2206       payload_s, libnet_t * l, libnet_ptag_t ptag)
2207       Builds an Remote Procedure Call (Version 2) Call message header as
2208       specified in RFC 1831. This builder provides the option for specifying
2209       the record marking which is required when used with streaming protocols
2210       (TCP).
2211
2212       Parameters
2213           rm record marking indicating the position in a stream, 0 otherwise
2214           xid transaction identifier used to link calls and replies
2215           prog_num remote program specification typically between 0 -
2216           1fffffff
2217           prog_vers remote program version specification
2218           procedure procedure to be performed by remote program
2219           cflavor authentication credential type
2220           clength credential length (should be 0)
2221           cdata opaque credential data (currently unused)
2222           vflavor authentication verifier type
2223           vlength verifier length (should be 0)
2224           vdata opaque verifier data (currently unused)
2225           payload optional payload or NULL
2226           payload_s payload length or 0
2227           l pointer to a libnet context
2228           ptag protocol tag to modify an existing header, 0 to build a new
2229           one
2230
2231       Returns
2232           protocol tag value on success
2233
2234       Return values
2235           -1 on error
2236
2237   LIBNET_API libnet_ptag_t libnet_build_sebek (uint32_t magic, uint16_t
2238       version, uint16_t type, uint32_t counter, uint32_t time_sec, uint32_t
2239       time_usec, uint32_t pid, uint32_t uid, uint32_t fd, uint8_t
2240       cmd[SEBEK_CMD_LENGTH], uint32_t length, const uint8_t * payload,
2241       uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
2242       Builds a Sebek header. The Sebek protocol was designed by the Honeynet
2243       Project as a transport mechanism for post-intrusion forensic data. More
2244       information may be found here:
2245       http://www.honeynet.org/papers/sebek.pdf.
2246
2247       Parameters
2248           magic identify packets that should be hidden
2249           version protocol version, currently 1
2250           type type of record (read data is type 0, write data is type 1)
2251           counter PDU counter used to identify when packet are lost
2252           time_sec seconds since EPOCH according to the honeypot
2253           time_usec residual microseconds
2254           pid PID
2255           uid UID
2256           fd FD
2257           cmd 12 first characters of the command
2258           length length in bytes of the PDU's body
2259           payload optional payload or NULL
2260           payload_s payload length or 0
2261           l pointer to a libnet context
2262           ptag protocol tag to modify an existing header, 0 to build a new
2263           one
2264
2265       Returns
2266           protocol tag value on success
2267
2268       Return values
2269           -1 on error
2270
2271   LIBNET_API libnet_ptag_t libnet_build_stp_conf (uint16_t id, uint8_t
2272       version, uint8_t bpdu_type, uint8_t flags, const uint8_t * root_id,
2273       uint32_t root_pc, const uint8_t * bridge_id, uint16_t port_id, uint16_t
2274       message_age, uint16_t max_age, uint16_t hello_time, uint16_t f_delay,
2275       const uint8_t * payload, uint32_t payload_s, libnet_t * l,
2276       libnet_ptag_t ptag)
2277       Builds an IEEE 802.1d Spanning Tree Protocol (STP) configuration
2278       header. STP frames are usually encapsulated inside of an 802.2 + 802.3
2279       frame combination.
2280
2281       Parameters
2282           id protocol id
2283           version protocol version
2284           bpdu_type bridge protocol data unit type
2285           flags flags
2286           root_id root id
2287           root_pc root path cost
2288           bridge_id bridge id
2289           port_id port id
2290           message_age message age
2291           max_age max age
2292           hello_time hello time
2293           f_delay forward delay
2294           payload optional payload or NULL
2295           payload_s payload length or 0
2296           l pointer to a libnet context
2297           ptag protocol tag to modify an existing header, 0 to build a new
2298           one
2299
2300       Returns
2301           protocol tag value on success
2302
2303       Return values
2304           -1 on error
2305
2306   LIBNET_API libnet_ptag_t libnet_build_stp_tcn (uint16_t id, uint8_t
2307       version, uint8_t bpdu_type, const uint8_t * payload, uint32_t
2308       payload_s, libnet_t * l, libnet_ptag_t ptag)
2309       Builds an IEEE 802.1d Spanning Tree Protocol (STP) topology change
2310       notification header. STP frames are usually encapsulated inside of an
2311       802.2 + 802.3 frame combination.
2312
2313       Parameters
2314           id protocol id
2315           version protocol version
2316           bpdu_type bridge protocol data unit type
2317           payload optional payload or NULL
2318           payload_s payload length or 0
2319           l pointer to a libnet context
2320           ptag protocol tag to modify an existing header, 0 to build a new
2321           one
2322
2323       Returns
2324           protocol tag value on success
2325
2326       Return values
2327           -1 on error
2328
2329   LIBNET_API libnet_ptag_t libnet_build_tcp (uint16_t sp, uint16_t dp,
2330       uint32_t seq, uint32_t ack, uint8_t control, uint16_t win, uint16_t
2331       sum, uint16_t urg, uint16_t len, const uint8_t * payload, uint32_t
2332       payload_s, libnet_t * l, libnet_ptag_t ptag)
2333       Builds an RFC 793 Transmission Control Protocol (TCP) header.
2334
2335       Parameters
2336           sp source port
2337           dp destination port
2338           seq sequence number
2339           ack acknowledgement number
2340           control control flags
2341           win window size
2342           sum checksum (0 for libnet to auto-fill)
2343           urg urgent pointer
2344           len total length of the TCP packet (for checksum calculation)
2345           payload
2346           payload_s payload length or 0
2347           l pointer to a libnet context
2348           ptag protocol tag to modify an existing header, 0 to build a new
2349           one
2350
2351       Returns
2352           protocol tag value on success
2353
2354       Return values
2355           -1 on error
2356
2357   LIBNET_API libnet_ptag_t libnet_build_tcp_options (const uint8_t * options,
2358       uint32_t options_s, libnet_t * l, libnet_ptag_t ptag)
2359       Builds an RFC 793 Transmission Control Protocol (TCP) options header.
2360       The function expects options to be a valid TCP options string of size
2361       options_s, which is no larger than 40 bytes (the maximum size of an
2362       options string). The function checks to ensure that the packet consists
2363       of a TCP header preceded by an IPv4 header, and that the addition of
2364       the options string would not result in a packet larger than 65,535
2365       bytes (IPMAXPACKET). The function counts up the number of 32-bit words
2366       in the options string and adjusts the TCP header length value as
2367       necessary.
2368
2369       Parameters
2370           options byte string of TCP options
2371           options_s length of options string
2372           l pointer to a libnet context
2373           ptag protocol tag to modify an existing header, 0 to build a new
2374           one
2375
2376       Returns
2377           protocol tag value on success
2378
2379       Return values
2380           -1 on error
2381
2382   LIBNET_API libnet_ptag_t libnet_build_token_ring (uint8_t ac, uint8_t fc,
2383       const uint8_t * dst, const uint8_t * src, uint8_t dsap, uint8_t ssap,
2384       uint8_t cf, const uint8_t * oui, uint16_t type, const uint8_t *
2385       payload, uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
2386       Builds a token ring header.
2387
2388       Parameters
2389           ac access control
2390           fc frame control
2391           dst destination address
2392           src source address
2393           dsap destination service access point
2394           ssap source service access point
2395           cf control field
2396           oui Organizationally Unique Identifier
2397           type upper layer protocol type
2398           payload optional payload or NULL
2399           payload_s payload length or 0
2400           l pointer to a libnet context
2401           ptag protocol tag to modify an existing header, 0 to build a new
2402           one
2403
2404       Returns
2405           protocol tag value on success
2406
2407       Return values
2408           -1 on error
2409
2410   LIBNET_API libnet_ptag_t libnet_build_udp (uint16_t sp, uint16_t dp,
2411       uint16_t len, uint16_t sum, const uint8_t * payload, uint32_t
2412       payload_s, libnet_t * l, libnet_ptag_t ptag)
2413       Builds an RFC 768 User Datagram Protocol (UDP) header.
2414
2415       Parameters
2416           sp source port
2417           dp destination port
2418           len total length of the UDP packet
2419           sum checksum (0 for libnet to auto-fill)
2420           payload optional payload or NULL
2421           payload_s payload length or 0
2422           l pointer to a libnet context
2423           ptag protocol tag to modify an existing header, 0 to build a new
2424           one
2425
2426       Returns
2427           protocol tag value on success
2428
2429       Return values
2430           -1 on error
2431
2432   LIBNET_API libnet_ptag_t libnet_build_vrrp (uint8_t version, uint8_t type,
2433       uint8_t vrouter_id, uint8_t priority, uint8_t ip_count, uint8_t
2434       auth_type, uint8_t advert_int, uint16_t sum, const uint8_t * payload,
2435       uint32_t payload_s, libnet_t * l, libnet_ptag_t ptag)
2436       Builds an RFC 2338 Virtual Router Redundacy Protool (VRRP) header. Use
2437       the payload interface to specify address and authentication
2438       information. To build a 'legal' packet, the destination IPv4 address
2439       should be the multicast * address 224.0.0.18, the IP TTL should be set
2440       to 255, and the IP protocol should be set to 112.
2441
2442       Parameters
2443           version VRRP version (should be 2)
2444           type VRRP packet type (should be 1 -- ADVERTISEMENT)
2445           vrouter_id virtual router identification
2446           priority priority (higher numbers indicate higher priority)
2447           ip_count number of IPv4 addresses contained in this advertisement
2448           auth_type type of authentication (0, 1, 2 -- see RFC)
2449           advert_int interval between advertisements
2450           sum checksum (0 for libnet to autofill)
2451           payload optional payload or NULL
2452           payload_s payload length or 0
2453           l pointer to a libnet context
2454           ptag protocol tag to modify an existing header, 0 to build a new
2455           one
2456
2457       Returns
2458           protocol tag value on success
2459
2460       Return values
2461           -1 on error
2462
2463   LIBNET_API void libnet_clear_packet (libnet_t * l)
2464       Clears the current packet referenced and frees all pblocks. Should be
2465       called when the programmer want to send a completely new packet of a
2466       different type using the same context.
2467
2468       Parameters
2469           l pointer to a libnet context
2470
2471   int libnet_cq_add (libnet_t * l, char * label)
2472       [Context Queue] Adds a new context to the libnet context queue. If no
2473       queue exists, this function will create the queue and add the specified
2474       libnet context as the first entry on the list. The functions checks to
2475       ensure niether l nor label are NULL, and that label doesn't refer to an
2476       existing context already in the queue. Additionally, l should refer to
2477       a libnet context previously initialized with a call to libnet_init().
2478       If the context queue in write locked, this function will fail.
2479
2480       Parameters
2481           l pointer to a libnet context
2482           label a canonical name given to recognize the new context, no
2483           longer than LIBNET_LABEL_SIZE
2484
2485       Return values
2486           1 on success
2487           -1 on failure
2488
2489   LIBNET_API void libnet_cq_destroy (void)
2490       [Context Queue] Destroys the entire context queue, calling
2491       libnet_destroy() on each member context.
2492
2493   LIBNET_API uint32_t libnet_cq_end_loop (void)
2494       [Context Queue]
2495
2496   LIBNET_API libnet_t* libnet_cq_find_by_label (char * label)
2497       [Context Queue] Locates a libnet context from the queue, indexed by a
2498       canonical label.
2499
2500       Parameters
2501           label canonical label of the libnet context to retrieve
2502
2503       Returns
2504           the expected libnet context
2505
2506       Return values
2507           NULL on failure
2508
2509   LIBNET_API const char* libnet_cq_getlabel (libnet_t * l)
2510       [Context Queue] Returns the canonical label associated with the
2511       context.
2512
2513       Parameters
2514           l pointer to a libnet context
2515
2516       Returns
2517           pointer to the libnet context's label
2518
2519   LIBNET_API libnet_t* libnet_cq_head (void)
2520       [Context Queue] Intiailizes the interator interface and set a write
2521       lock on the entire queue. This function is intended to be called just
2522       prior to interating through the entire list of contexts (with the
2523       probable intent of inject a series of packets in rapid succession).
2524       This function is often used as per the following:
2525
2526       for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next()) {
2527       ... }
2528
2529       Much of the time, the application programmer will use the iterator as
2530       it is written above; as such, libnet provides a macro to do exactly
2531       that, for_each_context_in_cq(l). Warning: do not call the iterator more
2532       than once in a single loop.
2533
2534       Returns
2535           the head of the context queue
2536
2537   LIBNET_API int libnet_cq_last (void)
2538       [Context Queue] Check whether the iterator is at the last context in
2539       the queue.
2540
2541       Return values
2542           1 if at the end of the context queue
2543           0 otherwise
2544
2545   LIBNET_API libnet_t* libnet_cq_next (void)
2546       [Context Queue] Get next context from the context queue.
2547
2548       Returns
2549           the next context from the context queue
2550
2551   LIBNET_API libnet_t* libnet_cq_remove (libnet_t * l)
2552       [Context Queue] Removes a specified context from the libnet context
2553       queue by specifying the libnet context pointer. Note the function will
2554       remove the specified context from the context queue and cleanup
2555       internal memory from the queue, it is up to the application programmer
2556       to free the returned libnet context with a call to libnet_destroy().
2557       Also, as it is not necessary to keep the libnet context pointer when
2558       initially adding it to the context queue, most application programmers
2559       will prefer to refer to entries on the context queue by canonical name
2560       and would use libnet_cq_remove_by_label(). If the context queue is
2561       write locked, this function will fail.
2562
2563       Parameters
2564           l pointer to a libnet context
2565
2566       Returns
2567           the pointer to the removed libnet context
2568
2569       Return values
2570           NULL on failure
2571
2572   LIBNET_API libnet_t* libnet_cq_remove_by_label (char * label)
2573       [Context Queue] Removes a specified context from the libnet context
2574       queue by specifying the canonical name. Note the function will remove
2575       the specified context from the context queue and cleanup internal
2576       memory from the queue, it is up to the application programmer to free
2577       the returned libnet context with a call to libnet_destroy(). If the
2578       context queue is write locked, this function will fail.
2579
2580       Parameters
2581           label canonical name of the context to remove
2582
2583       Returns
2584           the pointer to the removed libnet context
2585
2586       Return values
2587           NULL on failure
2588
2589   LIBNET_API uint32_t libnet_cq_size (void)
2590       [Context Queue] Function returns the number of libnet contexts that are
2591       in the queue.
2592
2593       Returns
2594           the number of libnet contexts currently in the queue
2595
2596   LIBNET_API void libnet_destroy (libnet_t * l)
2597       Shuts down the libnet session referenced by l. It closes the network
2598       interface and frees all internal memory structures associated with l.
2599
2600
2601       Parameters
2602           l pointer to a libnet context
2603
2604   LIBNET_API void libnet_diag_dump_context (libnet_t * l)
2605       [Diagnostic] Prints the contents of the given context.
2606
2607       Parameters
2608           l pointer to a libnet context
2609
2610   void libnet_diag_dump_hex (const uint8_t * packet, uint32_t len, int swap,
2611       FILE * stream)
2612       [Diagnostic] Function prints the contents of the supplied buffer to the
2613       supplied stream pointer. Will swap endianness based disposition of mode
2614       variable. Useful to be used in conjunction with the advanced interface
2615       and a culled packet.
2616
2617       Parameters
2618           packet the packet to print
2619           len length of the packet in bytes
2620           swap 1 to swap byte order, 0 to not. Counter-intuitively, it is
2621           necessary to swap in order to see the byte order as it is on the
2622           wire (this may be a bug).
2623           stream a stream pointer to print to
2624
2625   LIBNET_API void libnet_diag_dump_pblock (libnet_t * l)
2626       [Diagnostic] Prints the contents of every pblock.
2627
2628       Parameters
2629           l pointer to a libnet context
2630
2631   LIBNET_API char* libnet_diag_dump_pblock_type (uint8_t type)
2632       [Diagnostic] Returns the canonical name of the pblock type.
2633
2634       Parameters
2635           type pblock type
2636
2637       Returns
2638           a string representing the pblock type type
2639
2640       Return values
2641           unknown for an unknown value
2642
2643   LIBNET_API struct libnet_ether_addr* libnet_get_hwaddr (libnet_t * l)
2644       Returns the MAC address for the device libnet was initialized with. If
2645       libnet was initialized without a device the function will attempt to
2646       find one. If the function fails and returns NULL a call to
2647       libnet_geterror() will tell you why.
2648
2649       Parameters
2650           l pointer to a libnet context
2651
2652       Returns
2653           a pointer to the MAC address or NULL
2654
2655   LIBNET_API uint32_t libnet_get_ipaddr4 (libnet_t * l)
2656       Returns the IP address for the device libnet was initialized with. If
2657       libnet was initialized without a device (in raw socket mode) the
2658       function will attempt to find one. If the function fails and returns -1
2659       a call to libnet_geterrror() will tell you why.
2660
2661       Parameters
2662           l pointer to a libnet context
2663
2664       Returns
2665           a big endian IP address suitable for use in a libnet_build function
2666
2667       Return values
2668           -1
2669
2670   LIBNET_API struct libnet_in6_addr libnet_get_ipaddr6 (libnet_t * l)
2671       Returns the IPv6 address for the device libnet was initialized with. If
2672       libnet was initialized without a device (in raw socket mode) the
2673       function will attempt to find one. If the function fails and returns
2674       in6addr_error, a call to libnet_geterrror() will tell you why. This
2675       function is not yet implemented for Win32 platforms.
2676
2677       Parameters
2678           l pointer to a libnet context
2679
2680       Return values
2681           in6addr_error on failure
2682
2683   LIBNET_API uint32_t libnet_get_prand (int mod)
2684       Generates an unsigned pseudo-random value within the range specified by
2685       mod. LIBNET_PR2 0 - 1 LIBNET_PR8 0 - 255 LIBNET_PR16 0 - 32767
2686       LIBNET_PRu16 0 - 65535 LIBNET_PR32 0 - 2147483647 LIBNET_PRu32 0 -
2687       4294967295
2688
2689       Parameters
2690           mod one the of LIBNET_PR* constants
2691
2692       Return values
2693           1 on success
2694           -1 on failure
2695
2696   LIBNET_API const char* libnet_getdevice (libnet_t * l)
2697       Returns the canonical name of the device used for packet injection.
2698
2699       Parameters
2700           l pointer to a libnet context
2701
2702       Returns
2703           the canonical name of the device used for packet injection. Note it
2704           can be NULL without being an error.
2705
2706   LIBNET_API char* libnet_geterror (libnet_t * l)
2707       Returns the last error set inside of the referenced libnet context.
2708       This function should be called anytime a function fails or an error
2709       condition is detected inside of libnet.
2710
2711       Parameters
2712           l pointer to a libnet context
2713
2714       Returns
2715           an error string or NULL if no error has occurred
2716
2717   LIBNET_API int libnet_getfd (libnet_t * l)
2718       Returns the FILENO of the file descriptor used for packet injection.
2719
2720       Parameters
2721           l pointer to a libnet context
2722
2723       Returns
2724           the file number of the file descriptor used for packet injection
2725
2726   LIBNET_API uint32_t libnet_getgre_length (uint16_t fv)
2727       Parameters
2728           fv see libnet_build_gre().
2729
2730       Returns
2731           size
2732
2733       See also
2734           libnet_build_gre().
2735
2736   LIBNET_API uint32_t libnet_getpacket_size (libnet_t * l)
2737       Returns the sum of the size of all of the pblocks inside of l (this
2738       should be the resulting packet size).
2739
2740       Parameters
2741           l pointer to a libnet context
2742
2743       Returns
2744           the size of the packet in l
2745
2746   LIBNET_API uint8_t* libnet_getpbuf (libnet_t * l, libnet_ptag_t ptag)
2747       Returns the pblock buffer contents for the specified ptag; a subsequent
2748       call to libnet_getpbuf_size() should be made to determine the size of
2749       the buffer.
2750
2751       Parameters
2752           l pointer to a libnet context
2753           ptag the ptag reference number
2754
2755       Returns
2756           a pointer to the pblock buffer or NULL on error
2757
2758   LIBNET_API uint32_t libnet_getpbuf_size (libnet_t * l, libnet_ptag_t ptag)
2759       Returns the pblock buffer size for the specified ptag; a previous call
2760       to libnet_getpbuf() should be made to pull the actual buffer contents.
2761
2762       Parameters
2763           l pointer to a libnet context
2764           ptag the ptag reference number
2765
2766       Returns
2767           the size of the pblock buffer
2768
2769   LIBNET_API uint8_t* libnet_hex_aton (const char * s, int * len)
2770       Takes a colon separated hexidecimal address (from the command line) and
2771       returns a bytestring suitable for use in a libnet_build function. Note
2772       this function performs an implicit malloc and the return value should
2773       be freed after its use.
2774
2775       Parameters
2776           s the string to be parsed
2777           len the resulting size of the returned byte string
2778
2779       Returns
2780           a byte string or NULL on failure
2781
2782   LIBNET_API int libnet_in6_is_error (struct libnet_in6_addr addr)
2783       Check a libnet_in6_addr structure for identity with in6addr_error.
2784
2785       Parameters
2786           addr address to check
2787
2788       Return values
2789           1 if addr is in6addr_error
2790           0 if it is not
2791
2792   LIBNET_API libnet_t* libnet_init (int injection_type, const char * device,
2793       char * err_buf)
2794       Creates the libnet environment. It initializes the library and returns
2795       a libnet context. If the injection_type is LIBNET_LINK or
2796       LIBNET_LINK_ADV, the function initializes the injection primitives for
2797       the link-layer interface enabling the application programmer to build
2798       packets starting at the data-link layer (which also provides more
2799       granular control over the IP layer). If libnet uses the link-layer and
2800       the device argument is non-NULL, the function attempts to use the
2801       specified network device for packet injection. This is either a
2802       canonical string that references the device (such as 'eth0' for a 100MB
2803       Ethernet card on Linux or 'fxp0' for a 100MB Ethernet card on OpenBSD)
2804       or the dots and decimals representation of the device's IP address
2805       (192.168.0.1). If device is NULL, libnet attempts to find a suitable
2806       device to use. If the injection_type is LIBNET_RAW4 or LIBNET_RAW4_ADV,
2807       the function initializes the injection primitives for the IPv4 raw
2808       socket interface. The final argument, err_buf, should be a buffer of
2809       size LIBNET_ERRBUF_SIZE and holds an error message if the function
2810       fails. This function requires root privileges to execute successfully.
2811       Upon success, the function returns a valid libnet context for use in
2812       later function calls; upon failure, the function returns NULL.
2813
2814       Parameters
2815           injection_type packet injection type (LIBNET_LINK, LIBNET_LINK_ADV,
2816           LIBNET_RAW4, LIBNET_RAW4_ADV, LIBNET_RAW6, LIBNET_RAW6_ADV)
2817           device the interface to use (NULL and libnet will choose one)
2818           err_buf will contain an error message on failure
2819
2820       Returns
2821           libnet context ready for use or NULL on error.
2822
2823   LIBNET_API uint32_t libnet_name2addr4 (libnet_t * l, const char *
2824       host_name, uint8_t use_name)
2825       Takes a dotted decimal string or a canonical DNS name and returns a
2826       network byte ordered IPv4 address. This may incur a DNS lookup if mode
2827       is set to LIBNET_RESOLVE and host_name refers to a canonical DNS name.
2828       If mode is set to LIBNET_DONT_RESOLVE no DNS lookup will occur. The
2829       function can fail if DNS lookup fails or if mode is set to
2830       LIBNET_DONT_RESOLVE and host_name refers to a canonical DNS name.
2831
2832       Parameters
2833           l pointer to a libnet context
2834           host_name pointer to a string containing a presentation format host
2835           name
2836           use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
2837
2838       Returns
2839           address in network byte order
2840
2841       Return values
2842           -1 (2^32 - 1) on error
2843
2844   LIBNET_API struct libnet_in6_addr libnet_name2addr6 (libnet_t * l, const
2845       char * host_name, uint8_t use_name)
2846       Takes a dotted decimal string or a canonical DNS name and returns a
2847       network byte ordered IPv6 address. This may incur a DNS lookup if mode
2848       is set to LIBNET_RESOLVE and host_name refers to a canonical DNS name.
2849       If mode is set to LIBNET_DONT_RESOLVE no DNS lookup will occur. The
2850       function can fail if DNS lookup fails or if mode is set to
2851       LIBNET_DONT_RESOLVE and host_name refers to a canonical DNS name.
2852
2853       Parameters
2854           l pointer to a libnet context
2855           host_name pointer to a string containing a presentation format host
2856           name
2857           use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
2858
2859       Returns
2860           network byte ordered IPv6 address structure
2861
2862   LIBNET_API int libnet_plist_chain_dump (libnet_plist_t * plist)
2863       Runs through the port list and prints the contents of the port list
2864       chain list to stdout.
2865
2866       Parameters
2867           plist previously created portlist
2868
2869       Return values
2870           1 on success
2871           -1 on failure
2872
2873   LIBNET_API char* libnet_plist_chain_dump_string (libnet_plist_t * plist)
2874       Runs through the port list and prints the contents of the port list
2875       chain list to string. This function uses strdup and is not re-entrant.
2876       It also has a memory leak and should not really be used.
2877
2878       Parameters
2879           plist previously created portlist
2880
2881       Returns
2882           a printable string containing the port list contents on success or
2883           NULL on error
2884
2885   LIBNET_API int libnet_plist_chain_free (libnet_plist_t * plist)
2886       Frees all memory associated with port list chain.
2887
2888       Parameters
2889           plist previously created portlist
2890
2891       Return values
2892           1 on success
2893           -1 on failure
2894
2895   LIBNET_API int libnet_plist_chain_new (libnet_t * l, libnet_plist_t **
2896       plist, char * token_list)
2897       Creates a new port list. Port list chains are useful for TCP and UDP-
2898       based applications that need to send packets to a range of ports
2899       (contiguous or otherwise). The port list chain, which token_list points
2900       to, should contain a series of int8_tacters from the following list:
2901       '0123456789,-' of the general format 'x - y, z', where 'xyz' are port
2902       numbers between 0 and 65,535. plist points to the front of the port
2903       list chain list for use in further libnet_plist_chain() functions. Upon
2904       success, the function returns
2905
2906       1.  Upon failure, the function returns -1 and libnet_geterror() can
2907           tell you why.
2908
2909       Parameters
2910           l pointer to a libnet context
2911           plist if successful, will refer to the portlist, if not, NULL
2912           token_list string containing the port list primitive
2913
2914       Return values
2915           1 on success
2916           -1 on failure
2917
2918   LIBNET_API int libnet_plist_chain_next_pair (libnet_plist_t * plist,
2919       uint16_t * bport, uint16_t * eport)
2920       Returns the next port list chain pair from the port list chain plist.
2921       bport and eport contain the starting port number and ending port
2922       number, respectively. Upon success, the function returns 1 and fills in
2923       the port variables; however, if the list is empty, the function returns
2924       0 and sets both port variables to 0. Upon failure, the function returns
2925       -1.
2926
2927       Parameters
2928           plist previously created portlist
2929           bport will contain the beginning port number or 0
2930           eport will contain the ending port number or 0
2931
2932       Return values
2933           1 on success
2934           0 if empty
2935           -1 on failure
2936
2937   LIBNET_API int libnet_seed_prand (libnet_t * l)
2938       Seeds the pseudo-random number generator.
2939
2940       Parameters
2941           l pointer to a libnet context
2942
2943       Return values
2944           1 on success
2945           -1 on failure
2946
2947   LIBNET_API void libnet_stats (libnet_t * l, struct libnet_stats * ls)
2948       Fills in a libnet_stats structure with packet injection statistics
2949       (packets written, bytes written, packet sending errors).
2950
2951       Parameters
2952           l pointer to a libnet context
2953           ls pointer to a libnet statistics structure
2954
2955   LIBNET_API int libnet_toggle_checksum (libnet_t * l, libnet_ptag_t ptag,
2956       int mode)
2957       If a given protocol header is built with the checksum field set to '0',
2958       by default libnet will calculate the header checksum prior to
2959       injection. If the header is set to any other value, by default libnet
2960       will not calculate the header checksum. To over-ride this behavior, use
2961       libnet_toggle_checksum(). Switches auto-checksumming on or off for the
2962       specified ptag. If mode is set to LIBNET_ON, libnet will mark the
2963       specified ptag to calculate a checksum for the ptag prior to injection.
2964       This assumes that the ptag refers to a protocol that has a checksum
2965       field. If mode is set to LIBNET_OFF, libnet will clear the checksum
2966       flag and no checksum will be computed prior to injection. This assumes
2967       that the programmer will assign a value (zero or otherwise) to the
2968       checksum field. Often times this is useful if a precomputed checksum or
2969       some other predefined value is going to be used. Note that when libnet
2970       is initialized with LIBNET_RAW4, the IPv4 header checksum will always
2971       be computed by the kernel prior to injection, regardless of what the
2972       programmer sets.
2973
2974       Parameters
2975           l pointer to a libnet context
2976           ptag the ptag reference number
2977           mode LIBNET_ON or LIBNET_OFF
2978
2979       Return values
2980           1 on success
2981           -1 on failure
2982
2983   LIBNET_API const char* libnet_version (void)
2984       Returns the version of libnet.
2985
2986       Returns
2987           the libnet version
2988
2989   LIBNET_API int libnet_write (libnet_t * l)
2990       Writes a prebuilt packet to the network. The function assumes that l
2991       was previously initialized (via a call to libnet_init()) and that a
2992       previously constructed packet has been built inside this context (via
2993       one or more calls to the libnet_build* family of functions) and is
2994       ready to go. Depending on how libnet was initialized, the function will
2995       write the packet to the wire either via the raw or link layer
2996       interface. The function will also bump up the internal libnet stat
2997       counters which are retrievable via libnet_stats().
2998
2999       Parameters
3000           l pointer to a libnet context
3001
3002       Returns
3003           the number of bytes written
3004
3005       Return values
3006           -1 on error
3007

SEE ALSO

3009       libnet(3)
3010

AUTHORS

3012       The original author of libnet is Mike D. Schiffman.
3013
3014       libnet has been maintained and extensively enhanced since 2009 by Sam
3015       Roberts.
3016
3017       It is maintained by the Libnet Developer Community at GitHub.
3018
3019        <https://github.com/libnet/libnet>
3020

BUGS

3022       Suggestions, bug reports/fixes, and pull requests, see:
3023
3024        <https://github.com/libnet/libnet/issues>
3025
3027       libnet is licensed under the 3-Clause BSD License.
3028

SEE ALSO

3030       libnet(3)
3031

AUTHORS

3033       The original author of libnet is Mike D. Schiffman.
3034
3035       libnet has been maintained and extensively enhanced since 2009 by Sam
3036       Roberts.
3037
3038       It is maintained by the Libnet Developer Community at GitHub.
3039
3040        <https://github.com/libnet/libnet>
3041

BUGS

3043       Suggestions, bug reports/fixes, and pull requests, see:
3044
3045        <https://github.com/libnet/libnet/issues>
3046
3048       libnet is licensed under the 3-Clause BSD License.
3049

SEE ALSO

3051       libnet(3)
3052

AUTHORS

3054       The original author of libnet is Mike D. Schiffman.
3055
3056       libnet has been maintained and extensively enhanced since 2009 by Sam
3057       Roberts.
3058
3059       It is maintained by the Libnet Developer Community at GitHub.
3060
3061        <https://github.com/libnet/libnet>
3062

BUGS

3064       Suggestions, bug reports/fixes, and pull requests, see:
3065
3066        <https://github.com/libnet/libnet/issues>
3067
3069       libnet is licensed under the 3-Clause BSD License.
3070

SEE ALSO

3072       libnet(3)
3073

AUTHORS

3075       The original author of libnet is Mike D. Schiffman.
3076
3077       libnet has been maintained and extensively enhanced since 2009 by Sam
3078       Roberts.
3079
3080       It is maintained by the Libnet Developer Community at GitHub.
3081
3082        <https://github.com/libnet/libnet>
3083

BUGS

3085       Suggestions, bug reports/fixes, and pull requests, see:
3086
3087        <https://github.com/libnet/libnet/issues>
3088
3090       libnet is licensed under the 3-Clause BSD License.
3091
3092
3093
3094libnet-1.2                      Tue Jan 26 2021          libnet-functions.h(3)
Impressum