- Main Page
- Files

# libnet-functions.h

Go to the documentation of this file.

    00001 /*
    00002  *  $Id: libnet-functions.h,v 1.43 2004/11/09 07:05:07 mike Exp $
    00003  *
    00004  *  libnet-functions.h - function prototypes
    00005  *
    00006  *  Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
    00007  *  All rights reserved.
    00008  *
    00009  * Redistribution and use in source and binary forms, with or without
    00010  * modification, are permitted provided that the following conditions
    00011  * are met:
    00012  * 1. Redistributions of source code must retain the above copyright
    00013  *    notice, this list of conditions and the following disclaimer.
    00014  * 2. Redistributions in binary form must reproduce the above copyright
    00015  *    notice, this list of conditions and the following disclaimer in the
    00016  *    documentation and/or other materials provided with the distribution.
    00017  *
    00018  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
    00019  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    00020  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    00021  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
    00022  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    00023  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    00024  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    00025  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    00026  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    00027  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    00028  * SUCH DAMAGE.
    00029  *
    00030  */
    00031
    00032 #ifndef __LIBNET_FUNCTIONS_H
    00033 #define __LIBNET_FUNCTIONS_H
    00034
    00063 libnet_t *
    00064 libnet_init(int injection_type, const char *device, char *err_buf);
    00065
    00071 void
    00072 libnet_destroy(libnet_t *l);
    00073
    00080 void
    00081 libnet_clear_packet(libnet_t *l);
    00082
    00089 void
    00090 libnet_stats(libnet_t *l, struct libnet_stats *ls);
    00091
    00097 int
    00098 libnet_getfd(libnet_t *l);
    00099
    00106 const char *
    00107 libnet_getdevice(libnet_t *l);
    00108
    00117 uint8_t *
    00118 libnet_getpbuf(libnet_t *l, libnet_ptag_t ptag);
    00119
    00128 uint32_t
    00129 libnet_getpbuf_size(libnet_t *l, libnet_ptag_t ptag);
    00130
    00138 char *
    00139 libnet_geterror(libnet_t *l);
    00140
    00147 uint32_t
    00148 libnet_getpacket_size(libnet_t *l);
    00149
    00155 int
    00156 libnet_seed_prand(libnet_t *l);
    00157
    00171 uint32_t
    00172 libnet_get_prand(int mod);
    00173
    00195 int
    00196 libnet_toggle_checksum(libnet_t *l, libnet_ptag_t ptag, int mode);
    00197
    00210 char *
    00211 libnet_addr2name4(uint32_t in, uint8_t use_name);
    00212
    00226 uint32_t
    00227 libnet_name2addr4(libnet_t *l, char *host_name, uint8_t use_name);
    00228
    00229 extern const struct libnet_in6_addr in6addr_error;
    00230
    00244 struct libnet_in6_addr
    00245 libnet_name2addr6(libnet_t *l, char *host_name, uint8_t use_name);
    00246
    00250 void
    00251 libnet_addr2name6_r(struct libnet_in6_addr addr, uint8_t use_name,
    00252 char *host_name, int host_name_len);
    00253
    00269 int
    00270 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **plist, char *token_list);
    00271
    00283 int
    00284 libnet_plist_chain_next_pair(libnet_plist_t *plist, uint16_t *bport,
    00285 uint16_t *eport);
    00286
    00293 int
    00294 libnet_plist_chain_dump(libnet_plist_t *plist);
    00295
    00304 char *
    00305 libnet_plist_chain_dump_string(libnet_plist_t *plist);
    00306
    00312 int
    00313 libnet_plist_chain_free(libnet_plist_t *plist);
    00314
    00402 libnet_ptag_t
    00403 libnet_build_802_1q(const uint8_t *dst, const uint8_t *src, uint16_t tpi,
    00404 uint8_t priority, uint8_t cfi, uint16_t vlan_id, uint16_t len_proto,
    00405 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00406
    00418 libnet_ptag_t
    00419 libnet_build_802_1x(uint8_t eap_ver, uint8_t eap_type, uint16_t length,
    00420 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00421
    00433 libnet_ptag_t
    00434 libnet_build_802_2(uint8_t dsap, uint8_t ssap, uint8_t control,
    00435 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00436
    00450 libnet_ptag_t
    00451 libnet_build_802_2snap(uint8_t dsap, uint8_t ssap, uint8_t control,
    00452 uint8_t *oui, uint16_t type, const uint8_t* payload, uint32_t payload_s,
    00453 libnet_t *l, libnet_ptag_t ptag);
    00454
    00470 libnet_ptag_t
    00471 libnet_build_802_3(const uint8_t *dst, const uint8_t *src, uint16_t len,
    00472 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00473
    00489 libnet_ptag_t
    00490 libnet_build_ethernet(const uint8_t *dst, const uint8_t *src, uint16_t type,
    00491 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00492
    00504 libnet_ptag_t
    00505 libnet_autobuild_ethernet(const uint8_t *dst, uint16_t type, libnet_t *l);
    00506
    00523 libnet_ptag_t
    00524 libnet_build_fddi(uint8_t fc, const uint8_t *dst, const uint8_t *src, uint8_t dsap,
    00525 uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type, const uint8_t* payload,
    00526 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00527
    00540 libnet_ptag_t
    00541 libnet_autobuild_fddi(uint8_t fc, const uint8_t *dst, uint8_t dsap, uint8_t ssap,
    00542 uint8_t cf, const uint8_t *oui, uint16_t type, libnet_t *l);
    00543
    00563 libnet_ptag_t
    00564 libnet_build_arp(uint16_t hrd, uint16_t pro, uint8_t hln, uint8_t pln,
    00565 uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha, const uint8_t *tpa,
    00566 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00567
    00580 libnet_ptag_t
    00581 libnet_autobuild_arp(uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha,
    00582 uint8_t *tpa, libnet_t *l);
    00583
    00601 libnet_ptag_t
    00602 libnet_build_tcp(uint16_t sp, uint16_t dp, uint32_t seq, uint32_t ack,
    00603 uint8_t control, uint16_t win, uint16_t sum, uint16_t urg, uint16_t len,
    00604 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00605
    00621 libnet_ptag_t
    00622 libnet_build_tcp_options(const uint8_t *options, uint32_t options_s, libnet_t *l,
    00623 libnet_ptag_t ptag);
    00624
    00637 libnet_ptag_t
    00638 libnet_build_udp(uint16_t sp, uint16_t dp, uint16_t len, uint16_t sum,
    00639 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00640
    00660 libnet_ptag_t
    00661 libnet_build_cdp(uint8_t version, uint8_t ttl, uint16_t sum, uint16_t type,
    00662 uint16_t value_s, const uint8_t *value, const uint8_t* payload, uint32_t payload_s,
    00663 libnet_t *l, libnet_ptag_t ptag);
    00664
    00679 libnet_ptag_t
    00680 libnet_build_icmpv4_echo(uint8_t type, uint8_t code, uint16_t sum,
    00681 uint16_t id, uint16_t seq, const uint8_t* payload, uint32_t payload_s,
    00682 libnet_t *l, libnet_ptag_t ptag);
    00683
    00699 libnet_ptag_t
    00700 libnet_build_icmpv4_mask(uint8_t type, uint8_t code, uint16_t sum,
    00701 uint16_t id, uint16_t seq, uint32_t mask, const uint8_t* payload,
    00702 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00703
    00717 libnet_ptag_t
    00718 libnet_build_icmpv4_unreach(uint8_t type, uint8_t code, uint16_t sum,
    00719 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00720
    00735 libnet_ptag_t
    00736 libnet_build_icmpv4_redirect(uint8_t type, uint8_t code, uint16_t sum,
    00737 uint32_t gateway, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    00738 libnet_ptag_t ptag);
    00739
    00754 libnet_ptag_t
    00755 libnet_build_icmpv4_timeexceed(uint8_t type, uint8_t code, uint16_t sum,
    00756 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00757
    00775 libnet_ptag_t
    00776 libnet_build_icmpv4_timestamp(uint8_t type, uint8_t code, uint16_t sum,
    00777 uint16_t id, uint16_t seq, uint32_t otime, uint32_t rtime, uint32_t ttime,
    00778 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00779
    00793 libnet_ptag_t
    00794 libnet_build_icmpv6_unreach(u_int8_t type, u_int8_t code, u_int16_t sum,
    00795 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00796
    00809 libnet_ptag_t
    00810 libnet_build_igmp(uint8_t type, uint8_t code, uint16_t sum, uint32_t ip,
    00811 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00812
    00832 libnet_ptag_t
    00833 libnet_build_ipv4(uint16_t ip_len, uint8_t tos, uint16_t id, uint16_t frag,
    00834 uint8_t ttl, uint8_t prot, uint16_t sum, uint32_t src, uint32_t dst,
    00835 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00836
    00855 libnet_ptag_t
    00856 libnet_build_ipv4_options(const uint8_t *options, uint32_t options_s, libnet_t *l,
    00857 libnet_ptag_t ptag);
    00858
    00872 libnet_ptag_t
    00873 libnet_autobuild_ipv4(uint16_t len, uint8_t prot, uint32_t dst, libnet_t *l);
    00874
    00890 libnet_ptag_t
    00891 libnet_build_ipv6(uint8_t tc, uint32_t fl, uint16_t len, uint8_t nh,
    00892 uint8_t hl, struct libnet_in6_addr src, struct libnet_in6_addr dst,
    00893 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00894
    00907 libnet_ptag_t
    00908 libnet_build_ipv6_frag(uint8_t nh, uint8_t reserved, uint16_t frag,
    00909 uint32_t id, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    00910 libnet_ptag_t ptag);
    00911
    00929 libnet_ptag_t
    00930 libnet_build_ipv6_routing(uint8_t nh, uint8_t len, uint8_t rtype,
    00931 uint8_t segments, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    00932 libnet_ptag_t ptag);
    00933
    00947 libnet_ptag_t
    00948 libnet_build_ipv6_destopts(uint8_t nh, uint8_t len, const uint8_t* payload,
    00949 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00950
    00965 libnet_ptag_t
    00966 libnet_build_ipv6_hbhopts(uint8_t nh, uint8_t len, const uint8_t* payload,
    00967 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00968
    00978 libnet_ptag_t
    00979 libnet_autobuild_ipv6(uint16_t len, uint8_t nh, struct libnet_in6_addr dst,
    00980 libnet_t *l, libnet_ptag_t ptag);
    00981
    00999 libnet_ptag_t
    01000 libnet_build_isl(uint8_t *dhost, uint8_t type, uint8_t user,
    01001 uint8_t *shost, uint16_t len, const uint8_t *snap, uint16_t vid,
    01002 uint16_t portindex, uint16_t reserved, const uint8_t* payload,
    01003 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01004
    01016 libnet_ptag_t
    01017 libnet_build_ipsec_esp_hdr(uint32_t spi, uint32_t seq, uint32_t iv,
    01018 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01019
    01031 libnet_ptag_t
    01032 libnet_build_ipsec_esp_ftr(uint8_t len, uint8_t nh, int8_t *auth,
    01033 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01034
    01049 libnet_ptag_t
    01050 libnet_build_ipsec_ah(uint8_t nh, uint8_t len, uint16_t res,
    01051 uint32_t spi, uint32_t seq, uint32_t auth, const uint8_t* payload,
    01052 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01053
    01070 libnet_ptag_t
    01071 libnet_build_dnsv4(uint16_t h_len, uint16_t id, uint16_t flags,
    01072 uint16_t num_q, uint16_t num_anws_rr, uint16_t num_auth_rr,
    01073 uint16_t num_addi_rr, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01074 libnet_ptag_t ptag);
    01075
    01093 libnet_ptag_t
    01094 libnet_build_rip(uint8_t cmd, uint8_t version, uint16_t rd, uint16_t af,
    01095 uint16_t rt, uint32_t addr, uint32_t mask, uint32_t next_hop,
    01096 uint32_t metric, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01097 libnet_ptag_t ptag);
    01098
    01121 libnet_ptag_t
    01122 libnet_build_rpc_call(uint32_t rm, uint32_t xid, uint32_t prog_num,
    01123 uint32_t prog_vers, uint32_t procedure, uint32_t cflavor, uint32_t clength,
    01124 uint8_t *cdata, uint32_t vflavor, uint32_t vlength, const uint8_t *vdata,
    01125 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01126
    01149 libnet_ptag_t
    01150 libnet_build_stp_conf(uint16_t id, uint8_t version, uint8_t bpdu_type,
    01151 uint8_t flags, const uint8_t *root_id, uint32_t root_pc, const uint8_t *bridge_id,
    01152 uint16_t port_id, uint16_t message_age, uint16_t max_age,
    01153 uint16_t hello_time, uint16_t f_delay, const uint8_t* payload,
    01154 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01155
    01169 libnet_ptag_t
    01170 libnet_build_stp_tcn(uint16_t id, uint8_t version, uint8_t bpdu_type,
    01171 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01172
    01190 libnet_ptag_t
    01191 libnet_build_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst, const uint8_t *src,
    01192 uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
    01193 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01194
    01208 libnet_ptag_t
    01209 libnet_autobuild_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst,
    01210 uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
    01211 libnet_t *l);
    01212
    01232 libnet_ptag_t
    01233 libnet_build_vrrp(uint8_t version, uint8_t type, uint8_t vrouter_id,
    01234 uint8_t priority, uint8_t ip_count, uint8_t auth_type, uint8_t advert_int,
    01235 uint16_t sum, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01236 libnet_ptag_t ptag);
    01237
    01250 libnet_ptag_t
    01251 libnet_build_mpls(uint32_t label, uint8_t experimental, uint8_t bos,
    01252 uint8_t ttl, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01253 libnet_ptag_t ptag);
    01254
    01282 libnet_ptag_t
    01283 libnet_build_ntp(uint8_t leap_indicator, uint8_t version, uint8_t mode,
    01284 uint8_t stratum, uint8_t poll, uint8_t precision, uint16_t delay_int,
    01285 uint16_t delay_frac, uint16_t dispersion_int, uint16_t dispersion_frac,
    01286 uint32_t reference_id, uint32_t ref_ts_int, uint32_t ref_ts_frac,
    01287 uint32_t orig_ts_int, uint32_t orig_ts_frac, uint32_t rec_ts_int,
    01288 uint32_t rec_ts_frac, uint32_t xmt_ts_int, uint32_t xmt_ts_frac,
    01289 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01290
    01304 libnet_ptag_t
    01305 libnet_build_ospfv2(uint16_t len, uint8_t type, uint32_t rtr_id,
    01306 uint32_t area_id, uint16_t sum, uint16_t autype, const uint8_t* payload,
    01307 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01308
    01323 libnet_ptag_t
    01324 libnet_build_ospfv2_hello(uint32_t netmask, uint16_t interval, uint8_t opts,
    01325 uint8_t priority, uint dead_int, uint32_t des_rtr, uint32_t bkup_rtr,
    01326 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01327
    01339 libnet_ptag_t
    01340 libnet_build_ospfv2_dbd(uint16_t dgram_len, uint8_t opts, uint8_t type,
    01341 uint seqnum, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01342 libnet_ptag_t ptag);
    01343
    01354 libnet_ptag_t
    01355 libnet_build_ospfv2_lsr(uint type, uint lsid, uint32_t advrtr,
    01356 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01357
    01366 libnet_ptag_t
    01367 libnet_build_ospfv2_lsu(uint num, const uint8_t* payload, uint32_t payload_s,
    01368 libnet_t *l, libnet_ptag_t ptag);
    01369
    01385 libnet_ptag_t
    01386 libnet_build_ospfv2_lsa(uint16_t age, uint8_t opts, uint8_t type,
    01387 uint lsid, uint32_t advrtr, uint seqnum, uint16_t sum, uint16_t len,
    01388 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01389
    01404 libnet_ptag_t
    01405 libnet_build_ospfv2_lsa_rtr(uint16_t flags, uint16_t num, uint id,
    01406 uint data, uint8_t type, uint8_t tos, uint16_t metric, const uint8_t* payload,
    01407 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01408
    01418 libnet_ptag_t
    01419 libnet_build_ospfv2_lsa_net(uint32_t nmask, uint rtrid, const uint8_t* payload,
    01420 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01421
    01432 libnet_ptag_t
    01433 libnet_build_ospfv2_lsa_sum(uint32_t nmask, uint metric, uint tos,
    01434 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01435
    01447 libnet_ptag_t
    01448 libnet_build_ospfv2_lsa_as(uint32_t nmask, uint metric, uint32_t fwdaddr,
    01449 uint tag, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01450 libnet_ptag_t ptag);
    01451
    01463 libnet_ptag_t
    01464 libnet_build_data(const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01465 libnet_ptag_t ptag);
    01466
    01488 libnet_ptag_t
    01489 libnet_build_dhcpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
    01490 uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
    01491 uint32_t cip, uint32_t yip,  uint32_t sip, uint32_t gip, const uint8_t *chaddr,
    01492 uint8_t *sname, const uint8_t *file, const uint8_t* payload, uint32_t payload_s,
    01493 libnet_t *l, libnet_ptag_t ptag);
    01494
    01516 libnet_ptag_t
    01517 libnet_build_bootpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
    01518 uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
    01519 uint32_t cip, uint32_t yip,  uint32_t sip, uint32_t gip, const uint8_t *chaddr,
    01520 uint8_t *sname, const uint8_t *file, const uint8_t* payload, uint32_t payload_s,
    01521 libnet_t *l, libnet_ptag_t ptag);
    01522
    01527 uint32_t
    01528 libnet_getgre_length(uint16_t fv);
    01529
    01552 libnet_ptag_t
    01553 libnet_build_gre(uint16_t fv, uint16_t type, uint16_t sum,
    01554 uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
    01555 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01556
    01578 libnet_ptag_t
    01579 libnet_build_egre(uint16_t fv, uint16_t type, uint16_t sum,
    01580 uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
    01581 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01582
    01594 libnet_ptag_t
    01595 libnet_build_gre_sre(uint16_t af, uint8_t offset, uint8_t length,
    01596 uint8_t *routing, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01597 libnet_ptag_t ptag);
    01598
    01604 libnet_ptag_t
    01605 libnet_build_gre_last_sre(libnet_t *l, libnet_ptag_t ptag);
    01606
    01628 libnet_ptag_t
    01629 libnet_build_bgp4_header(uint8_t marker[LIBNET_BGP4_MARKER_SIZE],
    01630 uint16_t len, uint8_t type, const uint8_t* payload, uint32_t payload_s,
    01631 libnet_t *l, libnet_ptag_t ptag);
    01632
    01649 libnet_ptag_t
    01650 libnet_build_bgp4_open(uint8_t version, uint16_t src_as, uint16_t hold_time,
    01651 uint32_t bgp_id, uint8_t opt_len, const uint8_t* payload, uint32_t payload_s,
    01652 libnet_t *l, libnet_ptag_t ptag);
    01653
    01669 libnet_ptag_t
    01670 libnet_build_bgp4_update(uint16_t unfeasible_rt_len, const uint8_t *withdrawn_rt,
    01671 uint16_t total_path_attr_len, const uint8_t *path_attributes, uint16_t info_len,
    01672 uint8_t *reachability_info, const uint8_t* payload, uint32_t payload_s,
    01673 libnet_t *l, libnet_ptag_t ptag);
    01674
    01687 libnet_ptag_t
    01688 libnet_build_bgp4_notification(uint8_t err_code, uint8_t err_subcode,
    01689 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01690
    01712 libnet_ptag_t
    01713 libnet_build_sebek(uint32_t magic, uint16_t version, uint16_t type,
    01714 uint32_t counter, uint32_t time_sec, uint32_t time_usec, uint32_t pid,
    01715 uint32_t uid, uint32_t fd, uint8_t cmd[SEBEK_CMD_LENGTH], uint32_t length,
    01716 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01717
    01737 libnet_ptag_t
    01738 libnet_build_hsrp(uint8_t version, uint8_t opcode, uint8_t state,
    01739 uint8_t hello_time, uint8_t hold_time, uint8_t priority, uint8_t group,
    01740 uint8_t reserved, uint8_t authdata[HSRP_AUTHDATA_LENGTH], uint32_t virtual_ip,
    01741 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01742
    01757 libnet_ptag_t
    01758 libnet_build_link(const uint8_t *dst, const uint8_t *src, const uint8_t *oui, uint16_t type,
    01759 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01760
    01771 libnet_ptag_t
    01772 libnet_autobuild_link(const uint8_t *dst, const uint8_t *oui, uint16_t type,
    01773 libnet_t *l);
    01774
    01787 int
    01788 libnet_write(libnet_t *l);
    01789
    01799 uint32_t
    01800 libnet_get_ipaddr4(libnet_t *l);
    01801
    01807 struct libnet_in6_addr
    01808 libnet_get_ipaddr6(libnet_t *l);
    01809
    01818 struct libnet_ether_addr *
    01819 libnet_get_hwaddr(libnet_t *l);
    01820
    01830 uint8_t *
    01831 libnet_hex_aton(const char *s, int *len);
    01832
    01837 const char *
    01838 libnet_version(void);
    01839
    01855 int
    01856 libnet_adv_cull_packet(libnet_t *l, uint8_t **packet, uint32_t *packet_s);
    01857
    01870 int
    01871 libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, uint8_t **header,
    01872 uint32_t *header_s);
    01873
    01887 int
    01888 libnet_adv_write_link(libnet_t *l, const uint8_t *packet, uint32_t packet_s);
    01889
    01903 int
    01904 libnet_adv_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t packet_s);
    01905
    01912 void
    01913 libnet_adv_free_packet(libnet_t *l, uint8_t *packet);
    01914
    01928 int
    01929 libnet_cq_add(libnet_t *l, char *label);
    01930
    01945 libnet_t *
    01946 libnet_cq_remove(libnet_t *l);
    01947
    01959 libnet_t *
    01960 libnet_cq_remove_by_label(char *label);
    01961
    01968 const char *
    01969 libnet_cq_getlabel(libnet_t *l);
    01970
    01977 libnet_t *
    01978 libnet_cq_find_by_label(char *label);
    01979
    01985 void
    01986 libnet_cq_destroy(void);
    01987
    02007 libnet_t *
    02008 libnet_cq_head(void);
    02009
    02015 int
    02016 libnet_cq_last(void);
    02017
    02023 libnet_t *
    02024 libnet_cq_next(void);
    02025
    02031 uint32_t
    02032 libnet_cq_size(void);
    02033
    02037 uint32_t
    02038 libnet_cq_end_loop(void);
    02039
    02045 void
    02046 libnet_diag_dump_context(libnet_t *l);
    02047
    02053 void
    02054 libnet_diag_dump_pblock(libnet_t *l);
    02055
    02062 char *
    02063 libnet_diag_dump_pblock_type(uint8_t type);
    02064
    02078 void
    02079 libnet_diag_dump_hex(const uint8_t *packet, uint32_t len, int swap, FILE *stream);
    02080
    02081 /*
    02082  * [Internal]
    02083  */
    02084 int
    02085 libnet_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t size);
    02086
    02087 /*
    02088  * [Internal]
    02089  */
    02090 int
    02091 libnet_write_raw_ipv6(libnet_t *l, const uint8_t *packet, uint32_t size);
    02092
    02093 /*
    02094  * [Internal]
    02095  */
    02096 int
    02097 libnet_write_link(libnet_t *l, const uint8_t *packet, uint32_t size);
    02098
    02099 #if ((__WIN32__) && !(__CYGWIN__))
    02100 /*
    02101  * [Internal]
    02102  */
    02103 SOCKET
    02104 libnet_open_raw4(libnet_t *l);
    02105 #else
    02106 /*
    02107  * [Internal]
    02108  */
    02109 int
    02110 libnet_open_raw4(libnet_t *l);
    02111 #endif
    02112
    02113 /*
    02114  * [Internal]
    02115  */
    02116 int
    02117 libnet_close_raw4(libnet_t *l);
    02118
    02119 /*
    02120  * [Internal]
    02121  */
    02122 int
    02123 libnet_open_raw6(libnet_t *l);
    02124
    02125 /*
    02126  * [Internal]
    02127  */
    02128 int
    02129 libnet_close_raw6(libnet_t *l);
    02130
    02131 /*
    02132  * [Internal]
    02133  */
    02134 int
    02135 libnet_select_device(libnet_t *l);
    02136
    02137 /*
    02138  * [Internal]
    02139  */
    02140 int
    02141 libnet_open_link(libnet_t *l);
    02142
    02143 /*
    02144  * [Internal]
    02145  */
    02146 int
    02147 libnet_close_link(libnet_t *l);
    02148
    02149 /*
    02150  * [Internal]
    02151  *   THIS FUNCTION IS BROKEN. IT WILL SEGFAULT OR CORRUPT MEMORY, OR JUST SILENTLY DO THE
    02152  *   WRONG THING IF NOT CALLED CORRECTLY, AND CALLING IT CORRECTLY IS UNDOCUMENTED, AND
    02153  *   ALMOST IMPOSSIBLE. YOU HAVE BEEN WARNED.
    02154  */
    02155 int
    02156 libnet_do_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len);
    02157
    02158 /* Calculate internet checksums.
    02159  *
    02160  * IP (TCP, UDP, IGMP, ICMP, etc...) checksums usually need information from
    02161  * the IP header to construct the "pseudo header", this function takes a
    02162  * pointer to that header, the buffer boundaries, the "h_len" (see pblock_t for
    02163  * a description, it is increasinly unused, though, and I'm trying to remove it
    02164  * altogether), and the protocol number for the protocol that is to be
    02165  * checksummed.
    02166  *
    02167  * Finding that protocol requires that the IP header be well-formed... so this
    02168  * won't work well for invalid packets. But then, what is the valid checksum
    02169  * for a valid packet, anyhow?
    02170  *
    02171  * This doesn't work well for non-inet checksums, sorry, that's an original design
    02172  * flaw. pblock_t needs a pointer in it, to a packet assembly function that can be
    02173  * called at runtime to do assembly and checksumming.
    02174  */
    02175 int
    02176 libnet_inet_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len, const uint8_t *beg, const uint8_t * end);
    02177
    02178 /*
    02179  * [Internal]
    02180  */
    02181 uint32_t
    02182 libnet_compute_crc(uint8_t *buf, uint32_t len);
    02183
    02184 /*
    02185  * [Internal]
    02186  */
    02187 uint16_t
    02188 libnet_ip_check(uint16_t *addr, int len);
    02189
    02190 /*
    02191  * [Internal]
    02192  */
    02193 int
    02194 libnet_in_cksum(uint16_t *addr, int len);
    02195
    02196 /*
    02197  * [Internal]
    02198  * If ptag is 0, function will create a pblock for the protocol unit type,
    02199  * append it to the list and return a pointer to it.  If ptag is not 0,
    02200  * function will search the pblock list for the specified protocol block
    02201  * and return a pointer to it.
    02202  */
    02203 libnet_pblock_t *
    02204 libnet_pblock_probe(libnet_t *l, libnet_ptag_t ptag, uint32_t b_len,
    02205 uint8_t type);
    02206
    02207 /*
    02208  * [Internal]
    02209  * Function creates the pblock list if l->protocol_blocks == NULL or appends
    02210  * an entry to the doubly linked list.
    02211  */
    02212 libnet_pblock_t *
    02213 libnet_pblock_new(libnet_t *l, uint32_t b_len);
    02214
    02215 /*
    02216  * [Internal]
    02217  * Function swaps two pblocks in memory.
    02218  */
    02219 int
    02220 libnet_pblock_swap(libnet_t *l, libnet_ptag_t ptag1, libnet_ptag_t ptag2);
    02221
    02222 /*
    02223  * [Internal]
    02224  * Function inserts ptag2 before ptag1 in the doubly linked list.
    02225  */
    02226 int
    02227 libnet_pblock_insert_before(libnet_t *l, libnet_ptag_t ptag1,
    02228 libnet_ptag_t ptag2);
    02229
    02230 /*
    02231  * [Internal]
    02232  * Function removes a pblock from context
    02233  */
    02234 void
    02235 libnet_pblock_delete(libnet_t *l, libnet_pblock_t *p);
    02236
    02237 /*
    02238  * [Internal]
    02239  * Function updates the pblock meta-inforation.  Internally it updates the
    02240  * ptag with a monotonically increasing variable kept in l.  This way each
    02241  * pblock has a succesively increasing ptag identifier.
    02242  */
    02243 libnet_ptag_t
    02244 libnet_pblock_update(libnet_t *l, libnet_pblock_t *p, uint32_t h, uint8_t type);
    02245
    02246
    02247 /*
    02248  * [Internal]
    02249  * Function locates a given block by it's ptag.
    02250  */
    02251 libnet_pblock_t *
    02252 libnet_pblock_find(libnet_t *l, libnet_ptag_t ptag);
    02253
    02254 /*
    02255  * [Internal]
    02256  * Function copies protocol block data over.
    02257  */
    02258 int
    02259 libnet_pblock_append(libnet_t *l, libnet_pblock_t *p, const uint8_t *buf,
    02260 uint32_t len);
    02261
    02262 /*
    02263  * [Internal]
    02264  * Function sets pblock flags.
    02265  */
    02266 void
    02267 libnet_pblock_setflags(libnet_pblock_t *p, uint8_t flags);
    02268
    02269 /*
    02270  * [Internal]
    02271  * Function returns the protocol number for the protocol block type.  If
    02272  * the type is unknown, the function defaults to returning IPPROTO_IP.
    02273  */
    02274 int
    02275 libnet_pblock_p2p(uint8_t type);
    02276
    02277 /*
    02278  * [Internal]
    02279  * Function assembles the protocol blocks into a packet, checksums are
    02280  * calculated if that was requested.
    02281  */
    02282 int
    02283 libnet_pblock_coalesce(libnet_t *l, uint8_t **packet, uint32_t *size);
    02284
    02285 #if !(__WIN32__)
    02286 /*
    02287  * [Internal]
    02288  * By testing if we can retrieve the FLAGS of an iface
    02289  * we can know if it exists or not and if it is up.
    02290  */
    02291 int
    02292 libnet_check_iface(libnet_t *l);
    02293 #endif
    02294
    02295 #if defined(__WIN32__)
    02296 /*
    02297  * [Internal]
    02298  */
    02299 BYTE *
    02300 libnet_win32_get_remote_mac(libnet_t *l, DWORD IP);
    02301
    02302 /*
    02303  * [Internal]
    02304  */
    02305 int
    02306 libnet_close_link_interface(libnet_t *l);
    02307
    02308 /*
    02309  * [Internal]
    02310  */
    02311 BYTE *
    02312 libnet_win32_read_arp_table(DWORD IP);
    02313 #endif
    02314 #endif  /* __LIBNET_FUNCTIONS_H */
    02315
    02316 /* EOF */