libnet  1.1
libnet-functions.h
Go to the documentation of this file.
1 /*
2  * $Id: libnet-functions.h,v 1.43 2004/11/09 07:05:07 mike Exp $
3  *
4  * libnet-functions.h - function prototypes
5  *
6  * Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  */
31 
32 #ifndef __LIBNET_FUNCTIONS_H
33 #define __LIBNET_FUNCTIONS_H
34 
63 LIBNET_API
64 libnet_t *
65 libnet_init(int injection_type, const char *device, char *err_buf);
66 
72 LIBNET_API
73 void
74 libnet_destroy(libnet_t *l);
75 
82 LIBNET_API
83 void
84 libnet_clear_packet(libnet_t *l);
85 
92 LIBNET_API
93 void
94 libnet_stats(libnet_t *l, struct libnet_stats *ls);
95 
101 LIBNET_API
102 int
103 libnet_getfd(libnet_t *l);
104 
111 LIBNET_API
112 const char *
113 libnet_getdevice(libnet_t *l);
114 
123 LIBNET_API
124 uint8_t *
125 libnet_getpbuf(libnet_t *l, libnet_ptag_t ptag);
126 
135 LIBNET_API
136 uint32_t
137 libnet_getpbuf_size(libnet_t *l, libnet_ptag_t ptag);
138 
146 LIBNET_API
147 char *
148 libnet_geterror(libnet_t *l);
149 
156 LIBNET_API
157 uint32_t
158 libnet_getpacket_size(libnet_t *l);
159 
166 LIBNET_API
167 int
168 libnet_seed_prand(libnet_t *l);
169 
184 LIBNET_API
185 uint32_t
186 libnet_get_prand(int mod);
187 
210 LIBNET_API
211 int
212 libnet_toggle_checksum(libnet_t *l, libnet_ptag_t ptag, int mode);
213 
226 LIBNET_API
227 char *
228 libnet_addr2name4(uint32_t in, uint8_t use_name);
229 
244 LIBNET_API
245 uint32_t
246 libnet_name2addr4(libnet_t *l, char *host_name, uint8_t use_name);
247 
248 extern const struct libnet_in6_addr in6addr_error;
249 
256 LIBNET_API
257 int
258 libnet_in6_is_error(struct libnet_in6_addr addr);
259 
273 LIBNET_API
274 struct libnet_in6_addr
275 libnet_name2addr6(libnet_t *l, const char *host_name, uint8_t use_name);
276 
280 LIBNET_API
281 void
282 libnet_addr2name6_r(struct libnet_in6_addr addr, uint8_t use_name,
283 char *host_name, int host_name_len);
284 
301 LIBNET_API
302 int
303 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **plist, char *token_list);
304 
318 LIBNET_API
319 int
320 libnet_plist_chain_next_pair(libnet_plist_t *plist, uint16_t *bport,
321 uint16_t *eport);
322 
330 LIBNET_API
331 int
332 libnet_plist_chain_dump(libnet_plist_t *plist);
333 
341 LIBNET_API
342 char *
343 libnet_plist_chain_dump_string(libnet_plist_t *plist);
344 
351 LIBNET_API
352 int
353 libnet_plist_chain_free(libnet_plist_t *plist);
354 
443 LIBNET_API
444 libnet_ptag_t
445 libnet_build_802_1q(const uint8_t *dst, const uint8_t *src, uint16_t tpi,
446 uint8_t priority, uint8_t cfi, uint16_t vlan_id, uint16_t len_proto,
447 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
448 
461 LIBNET_API
462 libnet_ptag_t
463 libnet_build_802_1x(uint8_t eap_ver, uint8_t eap_type, uint16_t length,
464 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
465 
478 LIBNET_API
479 libnet_ptag_t
480 libnet_build_802_2(uint8_t dsap, uint8_t ssap, uint8_t control,
481 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
482 
497 LIBNET_API
498 libnet_ptag_t
499 libnet_build_802_2snap(uint8_t dsap, uint8_t ssap, uint8_t control,
500 uint8_t *oui, uint16_t type, const uint8_t* payload, uint32_t payload_s,
501 libnet_t *l, libnet_ptag_t ptag);
502 
519 LIBNET_API
520 libnet_ptag_t
521 libnet_build_802_3(const uint8_t *dst, const uint8_t *src, uint16_t len,
522 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
523 
540 LIBNET_API
541 libnet_ptag_t
542 libnet_build_ethernet(const uint8_t *dst, const uint8_t *src, uint16_t type,
543 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
544 
557 LIBNET_API
558 libnet_ptag_t
559 libnet_autobuild_ethernet(const uint8_t *dst, uint16_t type, libnet_t *l);
560 
578 LIBNET_API
579 libnet_ptag_t
580 libnet_build_fddi(uint8_t fc, const uint8_t *dst, const uint8_t *src, uint8_t dsap,
581 uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type, const uint8_t* payload,
582 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
583 
597 LIBNET_API
598 libnet_ptag_t
599 libnet_autobuild_fddi(uint8_t fc, const uint8_t *dst, uint8_t dsap, uint8_t ssap,
600 uint8_t cf, const uint8_t *oui, uint16_t type, libnet_t *l);
601 
622 LIBNET_API
623 libnet_ptag_t
624 libnet_build_arp(uint16_t hrd, uint16_t pro, uint8_t hln, uint8_t pln,
625 uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha, const uint8_t *tpa,
626 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
627 
641 LIBNET_API
642 libnet_ptag_t
643 libnet_autobuild_arp(uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha,
644 uint8_t *tpa, libnet_t *l);
645 
664 LIBNET_API
665 libnet_ptag_t
666 libnet_build_tcp(uint16_t sp, uint16_t dp, uint32_t seq, uint32_t ack,
667 uint8_t control, uint16_t win, uint16_t sum, uint16_t urg, uint16_t len,
668 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
669 
686 LIBNET_API
687 libnet_ptag_t
688 libnet_build_tcp_options(const uint8_t *options, uint32_t options_s, libnet_t *l,
689 libnet_ptag_t ptag);
690 
704 LIBNET_API
705 libnet_ptag_t
706 libnet_build_udp(uint16_t sp, uint16_t dp, uint16_t len, uint16_t sum,
707 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
708 
729 LIBNET_API
730 libnet_ptag_t
731 libnet_build_cdp(uint8_t version, uint8_t ttl, uint16_t sum, uint16_t type,
732 uint16_t value_s, const uint8_t *value, const uint8_t* payload, uint32_t payload_s,
733 libnet_t *l, libnet_ptag_t ptag);
734 
750 LIBNET_API
751 libnet_ptag_t
752 libnet_build_icmpv4_echo(uint8_t type, uint8_t code, uint16_t sum,
753 uint16_t id, uint16_t seq, const uint8_t* payload, uint32_t payload_s,
754 libnet_t *l, libnet_ptag_t ptag);
755 
772 LIBNET_API
773 libnet_ptag_t
774 libnet_build_icmpv4_mask(uint8_t type, uint8_t code, uint16_t sum,
775 uint16_t id, uint16_t seq, uint32_t mask, const uint8_t* payload,
776 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
777 
792 LIBNET_API
793 libnet_ptag_t
794 libnet_build_icmpv4_unreach(uint8_t type, uint8_t code, uint16_t sum,
795 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
796 
812 LIBNET_API
813 libnet_ptag_t
814 libnet_build_icmpv4_redirect(uint8_t type, uint8_t code, uint16_t sum,
815 uint32_t gateway, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
816 libnet_ptag_t ptag);
817 
833 LIBNET_API
834 libnet_ptag_t
835 libnet_build_icmpv4_timeexceed(uint8_t type, uint8_t code, uint16_t sum,
836 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
837 
856 LIBNET_API
857 libnet_ptag_t
858 libnet_build_icmpv4_timestamp(uint8_t type, uint8_t code, uint16_t sum,
859 uint16_t id, uint16_t seq, uint32_t otime, uint32_t rtime, uint32_t ttime,
860 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
861 
877 LIBNET_API
878 libnet_ptag_t libnet_build_icmpv6_echo(uint8_t type, uint8_t code, uint16_t
879  sum, uint16_t id, uint16_t seq, uint8_t *payload, uint32_t payload_s,
880  libnet_t *l, libnet_ptag_t ptag);
881 
896 LIBNET_API
897 libnet_ptag_t
898 libnet_build_icmpv6_unreach(uint8_t type, uint8_t code, uint16_t sum,
899 uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
900 
916 LIBNET_API
917 libnet_ptag_t libnet_build_icmpv6_ndp_nsol(uint8_t type, uint8_t code,
918  uint16_t sum, struct libnet_in6_addr target, uint8_t *payload, uint32_t
919  payload_s, libnet_t* l, libnet_ptag_t ptag);
920 
937 LIBNET_API
938 libnet_ptag_t libnet_build_icmpv6_ndp_nadv(uint8_t type, uint8_t code,
939  uint16_t sum, uint32_t flags, struct libnet_in6_addr target, uint8_t
940  *payload, uint32_t payload_s, libnet_t* l, libnet_ptag_t ptag);
941 
952 LIBNET_API
953 libnet_ptag_t libnet_build_icmpv6_ndp_opt(uint8_t type, uint8_t* option,
954  uint32_t option_s, libnet_t* l, libnet_ptag_t ptag);
955 
971 LIBNET_API
972 libnet_ptag_t
973 libnet_build_igmp(uint8_t type, uint8_t reserved, uint16_t sum, uint32_t ip,
974 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
975 
996 LIBNET_API
997 libnet_ptag_t
998 libnet_build_ipv4(uint16_t ip_len, uint8_t tos, uint16_t id, uint16_t frag,
999 uint8_t ttl, uint8_t prot, uint16_t sum, uint32_t src, uint32_t dst,
1000 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1001 
1021 LIBNET_API
1022 libnet_ptag_t
1023 libnet_build_ipv4_options(const uint8_t *options, uint32_t options_s, libnet_t *l,
1024 libnet_ptag_t ptag);
1025 
1040 LIBNET_API
1041 libnet_ptag_t
1042 libnet_autobuild_ipv4(uint16_t len, uint8_t prot, uint32_t dst, libnet_t *l);
1043 
1060 LIBNET_API
1061 libnet_ptag_t
1062 libnet_build_ipv6(uint8_t tc, uint32_t fl, uint16_t len, uint8_t nh,
1063 uint8_t hl, struct libnet_in6_addr src, struct libnet_in6_addr dst,
1064 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1065 
1079 LIBNET_API
1080 libnet_ptag_t
1081 libnet_build_ipv6_frag(uint8_t nh, uint8_t reserved, uint16_t frag,
1082 uint32_t id, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1083 libnet_ptag_t ptag);
1084 
1103 LIBNET_API
1104 libnet_ptag_t
1105 libnet_build_ipv6_routing(uint8_t nh, uint8_t len, uint8_t rtype,
1106 uint8_t segments, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1107 libnet_ptag_t ptag);
1108 
1123 LIBNET_API
1124 libnet_ptag_t
1125 libnet_build_ipv6_destopts(uint8_t nh, uint8_t len, const uint8_t* payload,
1126 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1127 
1143 LIBNET_API
1144 libnet_ptag_t
1145 libnet_build_ipv6_hbhopts(uint8_t nh, uint8_t len, const uint8_t* payload,
1146 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1147 
1165 LIBNET_API
1166 libnet_ptag_t
1167 libnet_autobuild_ipv6(uint16_t len, uint8_t nh, struct libnet_in6_addr dst,
1168 libnet_t *l, libnet_ptag_t ptag);
1169 
1188 LIBNET_API
1189 libnet_ptag_t
1190 libnet_build_isl(uint8_t *dhost, uint8_t type, uint8_t user,
1191 uint8_t *shost, uint16_t len, const uint8_t *snap, uint16_t vid,
1192 uint16_t portindex, uint16_t reserved, const uint8_t* payload,
1193 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1194 
1207 LIBNET_API
1208 libnet_ptag_t
1209 libnet_build_ipsec_esp_hdr(uint32_t spi, uint32_t seq, uint32_t iv,
1210 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1211 
1224 LIBNET_API
1225 libnet_ptag_t
1226 libnet_build_ipsec_esp_ftr(uint8_t len, uint8_t nh, int8_t *auth,
1227 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1228 
1244 LIBNET_API
1245 libnet_ptag_t
1246 libnet_build_ipsec_ah(uint8_t nh, uint8_t len, uint16_t res,
1247 uint32_t spi, uint32_t seq, uint32_t auth, const uint8_t* payload,
1248 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1249 
1267 LIBNET_API
1268 libnet_ptag_t
1269 libnet_build_dnsv4(uint16_t h_len, uint16_t id, uint16_t flags,
1270 uint16_t num_q, uint16_t num_anws_rr, uint16_t num_auth_rr,
1271 uint16_t num_addi_rr, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1272 libnet_ptag_t ptag);
1273 
1292 LIBNET_API
1293 libnet_ptag_t
1294 libnet_build_rip(uint8_t cmd, uint8_t version, uint16_t rd, uint16_t af,
1295 uint16_t rt, uint32_t addr, uint32_t mask, uint32_t next_hop,
1296 uint32_t metric, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1297 libnet_ptag_t ptag);
1298 
1322 LIBNET_API
1323 libnet_ptag_t
1324 libnet_build_rpc_call(uint32_t rm, uint32_t xid, uint32_t prog_num,
1325 uint32_t prog_vers, uint32_t procedure, uint32_t cflavor, uint32_t clength,
1326 uint8_t *cdata, uint32_t vflavor, uint32_t vlength, const uint8_t *vdata,
1327 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1328 
1352 LIBNET_API
1353 libnet_ptag_t
1354 libnet_build_stp_conf(uint16_t id, uint8_t version, uint8_t bpdu_type,
1355 uint8_t flags, const uint8_t *root_id, uint32_t root_pc, const uint8_t *bridge_id,
1356 uint16_t port_id, uint16_t message_age, uint16_t max_age,
1357 uint16_t hello_time, uint16_t f_delay, const uint8_t* payload,
1358 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1359 
1374 LIBNET_API
1375 libnet_ptag_t
1376 libnet_build_stp_tcn(uint16_t id, uint8_t version, uint8_t bpdu_type,
1377 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1378 
1397 LIBNET_API
1398 libnet_ptag_t
1399 libnet_build_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst, const uint8_t *src,
1400 uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
1401 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1402 
1417 LIBNET_API
1418 libnet_ptag_t
1419 libnet_autobuild_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst,
1420 uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
1421 libnet_t *l);
1422 
1443 LIBNET_API
1444 libnet_ptag_t
1445 libnet_build_vrrp(uint8_t version, uint8_t type, uint8_t vrouter_id,
1446 uint8_t priority, uint8_t ip_count, uint8_t auth_type, uint8_t advert_int,
1447 uint16_t sum, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1448 libnet_ptag_t ptag);
1449 
1463 LIBNET_API
1464 libnet_ptag_t
1465 libnet_build_mpls(uint32_t label, uint8_t experimental, uint8_t bos,
1466 uint8_t ttl, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1467 libnet_ptag_t ptag);
1468 
1497 LIBNET_API
1498 libnet_ptag_t
1499 libnet_build_ntp(uint8_t leap_indicator, uint8_t version, uint8_t mode,
1500 uint8_t stratum, uint8_t poll, uint8_t precision, uint16_t delay_int,
1501 uint16_t delay_frac, uint16_t dispersion_int, uint16_t dispersion_frac,
1502 uint32_t reference_id, uint32_t ref_ts_int, uint32_t ref_ts_frac,
1503 uint32_t orig_ts_int, uint32_t orig_ts_frac, uint32_t rec_ts_int,
1504 uint32_t rec_ts_frac, uint32_t xmt_ts_int, uint32_t xmt_ts_frac,
1505 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1506 
1521 LIBNET_API
1522 libnet_ptag_t
1523 libnet_build_ospfv2(uint16_t len, uint8_t type, uint32_t rtr_id,
1524 uint32_t area_id, uint16_t sum, uint16_t autype, const uint8_t* payload,
1525 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1526 
1542 LIBNET_API
1543 libnet_ptag_t
1544 libnet_build_ospfv2_hello(uint32_t netmask, uint16_t interval, uint8_t opts,
1545 uint8_t priority, uint32_t dead_int, uint32_t des_rtr, uint32_t bkup_rtr,
1546 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1547 
1560 LIBNET_API
1561 libnet_ptag_t
1562 libnet_build_ospfv2_dbd(uint16_t dgram_len, uint8_t opts, uint8_t type,
1563 uint32_t seqnum, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1564 libnet_ptag_t ptag);
1565 
1577 LIBNET_API
1578 libnet_ptag_t
1579 libnet_build_ospfv2_lsr(uint32_t type, uint32_t lsid, uint32_t advrtr,
1580 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1581 
1591 LIBNET_API
1592 libnet_ptag_t
1593 libnet_build_ospfv2_lsu(uint32_t num, const uint8_t* payload, uint32_t payload_s,
1594 libnet_t *l, libnet_ptag_t ptag);
1595 
1612 LIBNET_API
1613 libnet_ptag_t
1614 libnet_build_ospfv2_lsa(uint16_t age, uint8_t opts, uint8_t type,
1615 uint32_t lsid, uint32_t advrtr, uint32_t seqnum, uint16_t sum, uint16_t len,
1616 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1617 
1633 LIBNET_API
1634 libnet_ptag_t
1635 libnet_build_ospfv2_lsa_rtr(uint16_t flags, uint16_t num, uint32_t id,
1636 uint32_t data, uint8_t type, uint8_t tos, uint16_t metric, const uint8_t* payload,
1637 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1638 
1649 LIBNET_API
1650 libnet_ptag_t
1651 libnet_build_ospfv2_lsa_net(uint32_t nmask, uint32_t rtrid, const uint8_t* payload,
1652 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1653 
1665 LIBNET_API
1666 libnet_ptag_t
1667 libnet_build_ospfv2_lsa_sum(uint32_t nmask, uint32_t metric, uint32_t tos,
1668 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1669 
1682 LIBNET_API
1683 libnet_ptag_t
1684 libnet_build_ospfv2_lsa_as(uint32_t nmask, uint32_t metric, uint32_t fwdaddr,
1685 uint32_t tag, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1686 libnet_ptag_t ptag);
1687 
1700 LIBNET_API
1701 libnet_ptag_t
1702 libnet_build_data(const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1703 libnet_ptag_t ptag);
1704 
1727 LIBNET_API
1728 libnet_ptag_t
1729 libnet_build_dhcpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
1730 uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
1731 uint32_t cip, uint32_t yip, uint32_t sip, uint32_t gip, const uint8_t *chaddr,
1732 const char *sname, const char *file, const uint8_t* payload, uint32_t payload_s,
1733 libnet_t *l, libnet_ptag_t ptag);
1734 
1757 LIBNET_API
1758 libnet_ptag_t
1759 libnet_build_bootpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
1760 uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
1761 uint32_t cip, uint32_t yip, uint32_t sip, uint32_t gip, const uint8_t *chaddr,
1762 const char *sname, const char *file, const uint8_t* payload, uint32_t payload_s,
1763 libnet_t *l, libnet_ptag_t ptag);
1764 
1770 LIBNET_API
1771 uint32_t
1772 libnet_getgre_length(uint16_t fv);
1773 
1797 LIBNET_API
1798 libnet_ptag_t
1799 libnet_build_gre(uint16_t fv, uint16_t type, uint16_t sum,
1800 uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
1801 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1802 
1825 LIBNET_API
1826 libnet_ptag_t
1827 libnet_build_egre(uint16_t fv, uint16_t type, uint16_t sum,
1828 uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
1829 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1830 
1843 LIBNET_API
1844 libnet_ptag_t
1845 libnet_build_gre_sre(uint16_t af, uint8_t offset, uint8_t length,
1846 uint8_t *routing, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
1847 libnet_ptag_t ptag);
1848 
1855 LIBNET_API
1856 libnet_ptag_t
1857 libnet_build_gre_last_sre(libnet_t *l, libnet_ptag_t ptag);
1858 
1881 LIBNET_API
1882 libnet_ptag_t
1883 libnet_build_bgp4_header(uint8_t marker[LIBNET_BGP4_MARKER_SIZE],
1884 uint16_t len, uint8_t type, const uint8_t* payload, uint32_t payload_s,
1885 libnet_t *l, libnet_ptag_t ptag);
1886 
1904 LIBNET_API
1905 libnet_ptag_t
1906 libnet_build_bgp4_open(uint8_t version, uint16_t src_as, uint16_t hold_time,
1907 uint32_t bgp_id, uint8_t opt_len, const uint8_t* payload, uint32_t payload_s,
1908 libnet_t *l, libnet_ptag_t ptag);
1909 
1926 LIBNET_API
1927 libnet_ptag_t
1928 libnet_build_bgp4_update(uint16_t unfeasible_rt_len, const uint8_t *withdrawn_rt,
1929 uint16_t total_path_attr_len, const uint8_t *path_attributes, uint16_t info_len,
1930 uint8_t *reachability_info, const uint8_t* payload, uint32_t payload_s,
1931 libnet_t *l, libnet_ptag_t ptag);
1932 
1946 LIBNET_API
1947 libnet_ptag_t
1948 libnet_build_bgp4_notification(uint8_t err_code, uint8_t err_subcode,
1949 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1950 
1973 LIBNET_API
1974 libnet_ptag_t
1975 libnet_build_sebek(uint32_t magic, uint16_t version, uint16_t type,
1976 uint32_t counter, uint32_t time_sec, uint32_t time_usec, uint32_t pid,
1977 uint32_t uid, uint32_t fd, uint8_t cmd[SEBEK_CMD_LENGTH], uint32_t length,
1978 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
1979 
2000 LIBNET_API
2001 libnet_ptag_t
2002 libnet_build_hsrp(uint8_t version, uint8_t opcode, uint8_t state,
2003 uint8_t hello_time, uint8_t hold_time, uint8_t priority, uint8_t group,
2004 uint8_t reserved, uint8_t authdata[HSRP_AUTHDATA_LENGTH], uint32_t virtual_ip,
2005 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
2006 
2022 LIBNET_API
2023 libnet_ptag_t
2024 libnet_build_link(const uint8_t *dst, const uint8_t *src, const uint8_t *oui, uint16_t type,
2025 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
2026 
2038 LIBNET_API
2039 libnet_ptag_t
2040 libnet_autobuild_link(const uint8_t *dst, const uint8_t *oui, uint16_t type,
2041 libnet_t *l);
2042 
2056 LIBNET_API
2057 int
2058 libnet_write(libnet_t *l);
2059 
2069 LIBNET_API
2070 uint32_t
2071 libnet_get_ipaddr4(libnet_t *l);
2072 
2082 LIBNET_API
2083 struct libnet_in6_addr
2084 libnet_get_ipaddr6(libnet_t *l);
2085 
2094 LIBNET_API
2095 struct libnet_ether_addr *
2096 libnet_get_hwaddr(libnet_t *l);
2097 
2107 LIBNET_API
2108 uint8_t *
2109 libnet_hex_aton(const char *s, int *len);
2110 
2115 LIBNET_API
2116 const char *
2117 libnet_version(void);
2118 
2135 LIBNET_API
2136 int
2137 libnet_adv_cull_packet(libnet_t *l, uint8_t **packet, uint32_t *packet_s);
2138 
2152 LIBNET_API
2153 int
2154 libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, uint8_t **header,
2155 uint32_t *header_s);
2156 
2171 LIBNET_API
2172 int
2173 libnet_adv_write_link(libnet_t *l, const uint8_t *packet, uint32_t packet_s);
2174 
2189 LIBNET_API
2190 int
2191 libnet_adv_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t packet_s);
2192 
2199 LIBNET_API
2200 void
2201 libnet_adv_free_packet(libnet_t *l, uint8_t *packet);
2202 
2217 int
2218 libnet_cq_add(libnet_t *l, char *label);
2219 
2235 LIBNET_API
2236 libnet_t *
2237 libnet_cq_remove(libnet_t *l);
2238 
2251 LIBNET_API
2252 libnet_t *
2253 libnet_cq_remove_by_label(char *label);
2254 
2261 LIBNET_API
2262 const char *
2263 libnet_cq_getlabel(libnet_t *l);
2264 
2272 LIBNET_API
2273 libnet_t *
2274 libnet_cq_find_by_label(char *label);
2275 
2281 LIBNET_API
2282 void
2283 libnet_cq_destroy(void);
2284 
2304 LIBNET_API
2305 libnet_t *
2306 libnet_cq_head(void);
2307 
2314 LIBNET_API
2315 int
2316 libnet_cq_last(void);
2317 
2323 LIBNET_API
2324 libnet_t *
2325 libnet_cq_next(void);
2326 
2332 LIBNET_API
2333 uint32_t
2334 libnet_cq_size(void);
2335 
2339 LIBNET_API
2340 uint32_t
2341 libnet_cq_end_loop(void);
2342 
2348 LIBNET_API
2349 void
2350 libnet_diag_dump_context(libnet_t *l);
2351 
2357 LIBNET_API
2358 void
2359 libnet_diag_dump_pblock(libnet_t *l);
2360 
2368 LIBNET_API
2369 char *
2370 libnet_diag_dump_pblock_type(uint8_t type);
2371 
2385 void
2386 libnet_diag_dump_hex(const uint8_t *packet, uint32_t len, int swap, FILE *stream);
2387 
2388 /*
2389  * [Internal]
2390  */
2391 LIBNET_API
2392 int
2393 libnet_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t size);
2394 
2395 /*
2396  * [Internal]
2397  */
2398 LIBNET_API
2399 int
2400 libnet_write_raw_ipv6(libnet_t *l, const uint8_t *packet, uint32_t size);
2401 
2402 /*
2403  * [Internal]
2404  */
2405 LIBNET_API
2406 int
2407 libnet_write_link(libnet_t *l, const uint8_t *packet, uint32_t size);
2408 
2409 /*
2410  * [Internal]
2411  */
2412 int
2413 libnet_open_raw4(libnet_t *l);
2414 
2415 /*
2416  * [Internal]
2417  */
2418 LIBNET_API
2419 int
2420 libnet_close_raw4(libnet_t *l);
2421 
2422 /*
2423  * [Internal]
2424  */
2425 int
2426 libnet_open_raw6(libnet_t *l);
2427 
2428 /*
2429  * [Internal]
2430  */
2431 int
2432 libnet_close_raw6(libnet_t *l);
2433 
2434 /*
2435  * [Internal]
2436  */
2437 int
2438 libnet_select_device(libnet_t *l);
2439 
2440 /*
2441  * [Internal]
2442  */
2443 int
2444 libnet_open_link(libnet_t *l);
2445 
2446 /*
2447  * [Internal]
2448  */
2449 int
2450 libnet_close_link(libnet_t *l);
2451 
2452 /*
2453  * [Internal]
2454  * THIS FUNCTION IS BROKEN. IT WILL SEGFAULT OR CORRUPT MEMORY, OR JUST SILENTLY DO THE
2455  * WRONG THING IF NOT CALLED CORRECTLY, AND CALLING IT CORRECTLY IS UNDOCUMENTED, AND
2456  * ALMOST IMPOSSIBLE. YOU HAVE BEEN WARNED.
2457  */
2458 int
2459 libnet_do_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len);
2460 
2461 /* Calculate internet checksums.
2462  *
2463  * IP (TCP, UDP, IGMP, ICMP, etc...) checksums usually need information from
2464  * the IP header to construct the "pseudo header", this function takes a
2465  * pointer to that header, the buffer boundaries, the "h_len" (see pblock_t for
2466  * a description, it is increasinly unused, though, and I'm trying to remove it
2467  * altogether), and the protocol number for the protocol that is to be
2468  * checksummed.
2469  *
2470  * Finding that protocol requires that the IP header be well-formed... so this
2471  * won't work well for invalid packets. But then, what is the valid checksum
2472  * for a invalid packet, anyhow?
2473  *
2474  * This doesn't work well for non-inet checksums, sorry, that's an original design
2475  * flaw. pblock_t needs a pointer in it, to a packet assembly function that can be
2476  * called at runtime to do assembly and checksumming.
2477  */
2478 LIBNET_API
2479 int
2480 libnet_inet_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len, const uint8_t *beg, const uint8_t * end);
2481 
2482 /*
2483  * [Internal]
2484  */
2485 LIBNET_API
2486 uint32_t
2487 libnet_compute_crc(uint8_t *buf, uint32_t len);
2488 
2489 /*
2490  * [Internal]
2491  */
2492 LIBNET_API
2493 uint16_t
2494 libnet_ip_check(uint16_t *addr, int len);
2495 
2496 /*
2497  * [Internal]
2498  */
2499 LIBNET_API
2500 int
2501 libnet_in_cksum(uint16_t *addr, int len);
2502 
2503 /*
2504  * [Internal]
2505  * If ptag is 0, function will create a pblock for the protocol unit type,
2506  * append it to the list and return a pointer to it. If ptag is not 0,
2507  * function will search the pblock list for the specified protocol block
2508  * and return a pointer to it.
2509  */
2510 LIBNET_API
2511 libnet_pblock_t *
2512 libnet_pblock_probe(libnet_t *l, libnet_ptag_t ptag, uint32_t b_len,
2513 uint8_t type);
2514 
2515 /*
2516  * [Internal]
2517  * Function creates the pblock list if l->protocol_blocks == NULL or appends
2518  * an entry to the doubly linked list.
2519  */
2520 LIBNET_API
2521 libnet_pblock_t *
2522 libnet_pblock_new(libnet_t *l, uint32_t b_len);
2523 
2524 /*
2525  * [Internal]
2526  * Function swaps two pblocks in memory.
2527  */
2528 LIBNET_API
2529 int
2530 libnet_pblock_swap(libnet_t *l, libnet_ptag_t ptag1, libnet_ptag_t ptag2);
2531 
2532 /*
2533  * [Internal]
2534  * Function inserts ptag2 before ptag1 in the doubly linked list.
2535  */
2536 LIBNET_API
2537 int
2538 libnet_pblock_insert_before(libnet_t *l, libnet_ptag_t ptag1,
2539 libnet_ptag_t ptag2);
2540 
2541 /*
2542  * [Internal]
2543  * Function removes a pblock from context
2544  */
2545 LIBNET_API
2546 void
2547 libnet_pblock_delete(libnet_t *l, libnet_pblock_t *p);
2548 
2549 /*
2550  * [Internal]
2551  * Function updates the pblock meta-inforation. Internally it updates the
2552  * ptag with a monotonically increasing variable kept in l. This way each
2553  * pblock has a succesively increasing ptag identifier.
2554  */
2555 LIBNET_API
2556 libnet_ptag_t
2557 libnet_pblock_update(libnet_t *l, libnet_pblock_t *p, uint32_t h, uint8_t type);
2558 
2559 
2560 /*
2561  * [Internal]
2562  * Function locates a given block by it's ptag.
2563  */
2564 LIBNET_API
2565 libnet_pblock_t *
2566 libnet_pblock_find(libnet_t *l, libnet_ptag_t ptag);
2567 
2568 /*
2569  * [Internal]
2570  * Function copies protocol block data over.
2571  */
2572 LIBNET_API
2573 int
2574 libnet_pblock_append(libnet_t *l, libnet_pblock_t *p, const void *buf, uint32_t len);
2575 
2576 /*
2577  * [Internal]
2578  * Function sets pblock flags.
2579  */
2580 LIBNET_API
2581 void
2582 libnet_pblock_setflags(libnet_pblock_t *p, uint8_t flags);
2583 
2584 /*
2585  * [Internal]
2586  * Function returns the protocol number for the protocol block type. If
2587  * the type is unknown, the function defaults to returning IPPROTO_IP.
2588  */
2589 LIBNET_API
2590 int
2591 libnet_pblock_p2p(uint8_t type);
2592 
2593 /*
2594  * [Internal]
2595  * Function assembles the protocol blocks into a packet, checksums are
2596  * calculated if that was requested.
2597  */
2598 LIBNET_API
2599 int
2600 libnet_pblock_coalesce(libnet_t *l, uint8_t **packet, uint32_t *size);
2601 
2602 #if !(__WIN32__)
2603 /*
2604  * [Internal]
2605  * By testing if we can retrieve the FLAGS of an iface
2606  * we can know if it exists or not and if it is up.
2607  */
2608 int
2609 libnet_check_iface(libnet_t *l);
2610 #endif
2611 
2612 #if defined(__WIN32__)
2613 /*
2614  * [Internal]
2615  */
2616 BYTE *
2617 libnet_win32_get_remote_mac(libnet_t *l, DWORD IP);
2618 
2619 /*
2620  * [Internal]
2621  */
2622 int
2623 libnet_close_link_interface(libnet_t *l);
2624 
2625 /*
2626  * [Internal]
2627  */
2628 BYTE *
2629 libnet_win32_read_arp_table(DWORD IP);
2630 #endif
2631 #endif /* __LIBNET_FUNCTIONS_H */
2632 
2633 /* EOF */