libnet: libnet-functions.h Source File

libnet 1.1

- Main Page
- Files

- File List
- Globals

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
    00236 int
    00237 libnet_in6_is_error(struct libnet_in6_addr addr);
    00238
    00252 struct libnet_in6_addr
    00253 libnet_name2addr6(libnet_t *l, const char *host_name, uint8_t use_name);
    00254
    00258 void
    00259 libnet_addr2name6_r(struct libnet_in6_addr addr, uint8_t use_name,
    00260 char *host_name, int host_name_len);
    00261
    00277 int
    00278 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **plist, char *token_list);
    00279
    00291 int
    00292 libnet_plist_chain_next_pair(libnet_plist_t *plist, uint16_t *bport,
    00293 uint16_t *eport);
    00294
    00301 int
    00302 libnet_plist_chain_dump(libnet_plist_t *plist);
    00303
    00312 char *
    00313 libnet_plist_chain_dump_string(libnet_plist_t *plist);
    00314
    00320 int
    00321 libnet_plist_chain_free(libnet_plist_t *plist);
    00322
    00410 libnet_ptag_t
    00411 libnet_build_802_1q(const uint8_t *dst, const uint8_t *src, uint16_t tpi,
    00412 uint8_t priority, uint8_t cfi, uint16_t vlan_id, uint16_t len_proto,
    00413 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00414
    00426 libnet_ptag_t
    00427 libnet_build_802_1x(uint8_t eap_ver, uint8_t eap_type, uint16_t length,
    00428 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00429
    00441 libnet_ptag_t
    00442 libnet_build_802_2(uint8_t dsap, uint8_t ssap, uint8_t control,
    00443 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00444
    00458 libnet_ptag_t
    00459 libnet_build_802_2snap(uint8_t dsap, uint8_t ssap, uint8_t control,
    00460 uint8_t *oui, uint16_t type, const uint8_t* payload, uint32_t payload_s,
    00461 libnet_t *l, libnet_ptag_t ptag);
    00462
    00478 libnet_ptag_t
    00479 libnet_build_802_3(const uint8_t *dst, const uint8_t *src, uint16_t len,
    00480 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00481
    00497 libnet_ptag_t
    00498 libnet_build_ethernet(const uint8_t *dst, const uint8_t *src, uint16_t type,
    00499 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00500
    00512 libnet_ptag_t
    00513 libnet_autobuild_ethernet(const uint8_t *dst, uint16_t type, libnet_t *l);
    00514
    00531 libnet_ptag_t
    00532 libnet_build_fddi(uint8_t fc, const uint8_t *dst, const uint8_t *src, uint8_t dsap,
    00533 uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type, const uint8_t* payload,
    00534 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00535
    00548 libnet_ptag_t
    00549 libnet_autobuild_fddi(uint8_t fc, const uint8_t *dst, uint8_t dsap, uint8_t ssap,
    00550 uint8_t cf, const uint8_t *oui, uint16_t type, libnet_t *l);
    00551
    00571 libnet_ptag_t
    00572 libnet_build_arp(uint16_t hrd, uint16_t pro, uint8_t hln, uint8_t pln,
    00573 uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha, const uint8_t *tpa,
    00574 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00575
    00588 libnet_ptag_t
    00589 libnet_autobuild_arp(uint16_t op, const uint8_t *sha, const uint8_t *spa, const uint8_t *tha,
    00590 uint8_t *tpa, libnet_t *l);
    00591
    00609 libnet_ptag_t
    00610 libnet_build_tcp(uint16_t sp, uint16_t dp, uint32_t seq, uint32_t ack,
    00611 uint8_t control, uint16_t win, uint16_t sum, uint16_t urg, uint16_t len,
    00612 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00613
    00629 libnet_ptag_t
    00630 libnet_build_tcp_options(const uint8_t *options, uint32_t options_s, libnet_t *l,
    00631 libnet_ptag_t ptag);
    00632
    00645 libnet_ptag_t
    00646 libnet_build_udp(uint16_t sp, uint16_t dp, uint16_t len, uint16_t sum,
    00647 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00648
    00668 libnet_ptag_t
    00669 libnet_build_cdp(uint8_t version, uint8_t ttl, uint16_t sum, uint16_t type,
    00670 uint16_t value_s, const uint8_t *value, const uint8_t* payload, uint32_t payload_s,
    00671 libnet_t *l, libnet_ptag_t ptag);
    00672
    00687 libnet_ptag_t
    00688 libnet_build_icmpv4_echo(uint8_t type, uint8_t code, uint16_t sum,
    00689 uint16_t id, uint16_t seq, const uint8_t* payload, uint32_t payload_s,
    00690 libnet_t *l, libnet_ptag_t ptag);
    00691
    00707 libnet_ptag_t
    00708 libnet_build_icmpv4_mask(uint8_t type, uint8_t code, uint16_t sum,
    00709 uint16_t id, uint16_t seq, uint32_t mask, const uint8_t* payload,
    00710 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00711
    00725 libnet_ptag_t
    00726 libnet_build_icmpv4_unreach(uint8_t type, uint8_t code, uint16_t sum,
    00727 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00728
    00743 libnet_ptag_t
    00744 libnet_build_icmpv4_redirect(uint8_t type, uint8_t code, uint16_t sum,
    00745 uint32_t gateway, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    00746 libnet_ptag_t ptag);
    00747
    00762 libnet_ptag_t
    00763 libnet_build_icmpv4_timeexceed(uint8_t type, uint8_t code, uint16_t sum,
    00764 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00765
    00783 libnet_ptag_t
    00784 libnet_build_icmpv4_timestamp(uint8_t type, uint8_t code, uint16_t sum,
    00785 uint16_t id, uint16_t seq, uint32_t otime, uint32_t rtime, uint32_t ttime,
    00786 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00787
    00802 libnet_ptag_t libnet_build_icmpv6_echo(uint8_t type, uint8_t code, uint16_t
    00803         sum, uint16_t id, uint16_t seq, uint8_t *payload, uint32_t payload_s,
    00804         libnet_t *l, libnet_ptag_t ptag);
    00805
    00819 libnet_ptag_t
    00820 libnet_build_icmpv6_unreach(uint8_t type, uint8_t code, uint16_t sum,
    00821 uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00822
    00837 libnet_ptag_t libnet_build_icmpv6_ndp_nsol(uint8_t type, uint8_t code,
    00838         uint16_t sum, struct libnet_in6_addr target, uint8_t *payload, uint32_t
    00839         payload_s, libnet_t* l, libnet_ptag_t ptag);
    00840
    00856 libnet_ptag_t libnet_build_icmpv6_ndp_nadv(uint8_t type, uint8_t code,
    00857         uint16_t sum, uint32_t flags, struct libnet_in6_addr target, uint8_t
    00858         *payload, uint32_t payload_s, libnet_t* l, libnet_ptag_t ptag);
    00859
    00869 libnet_ptag_t libnet_build_icmpv6_ndp_opt(uint8_t type, uint8_t* option,
    00870         uint32_t option_s, libnet_t* l, libnet_ptag_t ptag);
    00871
    00886 libnet_ptag_t
    00887 libnet_build_igmp(uint8_t type, uint8_t reserved, uint16_t sum, uint32_t ip,
    00888 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00889
    00909 libnet_ptag_t
    00910 libnet_build_ipv4(uint16_t ip_len, uint8_t tos, uint16_t id, uint16_t frag,
    00911 uint8_t ttl, uint8_t prot, uint16_t sum, uint32_t src, uint32_t dst,
    00912 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00913
    00932 libnet_ptag_t
    00933 libnet_build_ipv4_options(const uint8_t *options, uint32_t options_s, libnet_t *l,
    00934 libnet_ptag_t ptag);
    00935
    00949 libnet_ptag_t
    00950 libnet_autobuild_ipv4(uint16_t len, uint8_t prot, uint32_t dst, libnet_t *l);
    00951
    00967 libnet_ptag_t
    00968 libnet_build_ipv6(uint8_t tc, uint32_t fl, uint16_t len, uint8_t nh,
    00969 uint8_t hl, struct libnet_in6_addr src, struct libnet_in6_addr dst,
    00970 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    00971
    00984 libnet_ptag_t
    00985 libnet_build_ipv6_frag(uint8_t nh, uint8_t reserved, uint16_t frag,
    00986 uint32_t id, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    00987 libnet_ptag_t ptag);
    00988
    01006 libnet_ptag_t
    01007 libnet_build_ipv6_routing(uint8_t nh, uint8_t len, uint8_t rtype,
    01008 uint8_t segments, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01009 libnet_ptag_t ptag);
    01010
    01024 libnet_ptag_t
    01025 libnet_build_ipv6_destopts(uint8_t nh, uint8_t len, const uint8_t* payload,
    01026 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01027
    01042 libnet_ptag_t
    01043 libnet_build_ipv6_hbhopts(uint8_t nh, uint8_t len, const uint8_t* payload,
    01044 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01045
    01062 libnet_ptag_t
    01063 libnet_autobuild_ipv6(uint16_t len, uint8_t nh, struct libnet_in6_addr dst,
    01064 libnet_t *l, libnet_ptag_t ptag);
    01065
    01083 libnet_ptag_t
    01084 libnet_build_isl(uint8_t *dhost, uint8_t type, uint8_t user,
    01085 uint8_t *shost, uint16_t len, const uint8_t *snap, uint16_t vid,
    01086 uint16_t portindex, uint16_t reserved, const uint8_t* payload,
    01087 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01088
    01100 libnet_ptag_t
    01101 libnet_build_ipsec_esp_hdr(uint32_t spi, uint32_t seq, uint32_t iv,
    01102 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01103
    01115 libnet_ptag_t
    01116 libnet_build_ipsec_esp_ftr(uint8_t len, uint8_t nh, int8_t *auth,
    01117 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01118
    01133 libnet_ptag_t
    01134 libnet_build_ipsec_ah(uint8_t nh, uint8_t len, uint16_t res,
    01135 uint32_t spi, uint32_t seq, uint32_t auth, const uint8_t* payload,
    01136 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01137
    01154 libnet_ptag_t
    01155 libnet_build_dnsv4(uint16_t h_len, uint16_t id, uint16_t flags,
    01156 uint16_t num_q, uint16_t num_anws_rr, uint16_t num_auth_rr,
    01157 uint16_t num_addi_rr, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01158 libnet_ptag_t ptag);
    01159
    01177 libnet_ptag_t
    01178 libnet_build_rip(uint8_t cmd, uint8_t version, uint16_t rd, uint16_t af,
    01179 uint16_t rt, uint32_t addr, uint32_t mask, uint32_t next_hop,
    01180 uint32_t metric, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01181 libnet_ptag_t ptag);
    01182
    01205 libnet_ptag_t
    01206 libnet_build_rpc_call(uint32_t rm, uint32_t xid, uint32_t prog_num,
    01207 uint32_t prog_vers, uint32_t procedure, uint32_t cflavor, uint32_t clength,
    01208 uint8_t *cdata, uint32_t vflavor, uint32_t vlength, const uint8_t *vdata,
    01209 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01210
    01233 libnet_ptag_t
    01234 libnet_build_stp_conf(uint16_t id, uint8_t version, uint8_t bpdu_type,
    01235 uint8_t flags, const uint8_t *root_id, uint32_t root_pc, const uint8_t *bridge_id,
    01236 uint16_t port_id, uint16_t message_age, uint16_t max_age,
    01237 uint16_t hello_time, uint16_t f_delay, const uint8_t* payload,
    01238 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01239
    01253 libnet_ptag_t
    01254 libnet_build_stp_tcn(uint16_t id, uint8_t version, uint8_t bpdu_type,
    01255 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01256
    01274 libnet_ptag_t
    01275 libnet_build_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst, const uint8_t *src,
    01276 uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
    01277 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01278
    01292 libnet_ptag_t
    01293 libnet_autobuild_token_ring(uint8_t ac, uint8_t fc, const uint8_t *dst,
    01294 uint8_t dsap, uint8_t ssap, uint8_t cf, const uint8_t *oui, uint16_t type,
    01295 libnet_t *l);
    01296
    01316 libnet_ptag_t
    01317 libnet_build_vrrp(uint8_t version, uint8_t type, uint8_t vrouter_id,
    01318 uint8_t priority, uint8_t ip_count, uint8_t auth_type, uint8_t advert_int,
    01319 uint16_t sum, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01320 libnet_ptag_t ptag);
    01321
    01334 libnet_ptag_t
    01335 libnet_build_mpls(uint32_t label, uint8_t experimental, uint8_t bos,
    01336 uint8_t ttl, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01337 libnet_ptag_t ptag);
    01338
    01366 libnet_ptag_t
    01367 libnet_build_ntp(uint8_t leap_indicator, uint8_t version, uint8_t mode,
    01368 uint8_t stratum, uint8_t poll, uint8_t precision, uint16_t delay_int,
    01369 uint16_t delay_frac, uint16_t dispersion_int, uint16_t dispersion_frac,
    01370 uint32_t reference_id, uint32_t ref_ts_int, uint32_t ref_ts_frac,
    01371 uint32_t orig_ts_int, uint32_t orig_ts_frac, uint32_t rec_ts_int,
    01372 uint32_t rec_ts_frac, uint32_t xmt_ts_int, uint32_t xmt_ts_frac,
    01373 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01374
    01388 libnet_ptag_t
    01389 libnet_build_ospfv2(uint16_t len, uint8_t type, uint32_t rtr_id,
    01390 uint32_t area_id, uint16_t sum, uint16_t autype, const uint8_t* payload,
    01391 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01392
    01407 libnet_ptag_t
    01408 libnet_build_ospfv2_hello(uint32_t netmask, uint16_t interval, uint8_t opts,
    01409 uint8_t priority, uint dead_int, uint32_t des_rtr, uint32_t bkup_rtr,
    01410 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01411
    01423 libnet_ptag_t
    01424 libnet_build_ospfv2_dbd(uint16_t dgram_len, uint8_t opts, uint8_t type,
    01425 uint seqnum, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01426 libnet_ptag_t ptag);
    01427
    01438 libnet_ptag_t
    01439 libnet_build_ospfv2_lsr(uint type, uint lsid, uint32_t advrtr,
    01440 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01441
    01450 libnet_ptag_t
    01451 libnet_build_ospfv2_lsu(uint num, const uint8_t* payload, uint32_t payload_s,
    01452 libnet_t *l, libnet_ptag_t ptag);
    01453
    01469 libnet_ptag_t
    01470 libnet_build_ospfv2_lsa(uint16_t age, uint8_t opts, uint8_t type,
    01471 uint lsid, uint32_t advrtr, uint seqnum, uint16_t sum, uint16_t len,
    01472 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01473
    01488 libnet_ptag_t
    01489 libnet_build_ospfv2_lsa_rtr(uint16_t flags, uint16_t num, uint id,
    01490 uint data, uint8_t type, uint8_t tos, uint16_t metric, const uint8_t* payload,
    01491 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01492
    01502 libnet_ptag_t
    01503 libnet_build_ospfv2_lsa_net(uint32_t nmask, uint rtrid, const uint8_t* payload,
    01504 uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01505
    01516 libnet_ptag_t
    01517 libnet_build_ospfv2_lsa_sum(uint32_t nmask, uint metric, uint tos,
    01518 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01519
    01531 libnet_ptag_t
    01532 libnet_build_ospfv2_lsa_as(uint32_t nmask, uint metric, uint32_t fwdaddr,
    01533 uint tag, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01534 libnet_ptag_t ptag);
    01535
    01547 libnet_ptag_t
    01548 libnet_build_data(const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01549 libnet_ptag_t ptag);
    01550
    01572 libnet_ptag_t
    01573 libnet_build_dhcpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
    01574 uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
    01575 uint32_t cip, uint32_t yip,  uint32_t sip, uint32_t gip, const uint8_t *chaddr,
    01576 const char *sname, const char *file, const uint8_t* payload, uint32_t payload_s,
    01577 libnet_t *l, libnet_ptag_t ptag);
    01578
    01600 libnet_ptag_t
    01601 libnet_build_bootpv4(uint8_t opcode, uint8_t htype, uint8_t hlen,
    01602 uint8_t hopcount, uint32_t xid, uint16_t secs, uint16_t flags,
    01603 uint32_t cip, uint32_t yip,  uint32_t sip, uint32_t gip, const uint8_t *chaddr,
    01604 const char *sname, const char *file, const uint8_t* payload, uint32_t payload_s,
    01605 libnet_t *l, libnet_ptag_t ptag);
    01606
    01611 uint32_t
    01612 libnet_getgre_length(uint16_t fv);
    01613
    01636 libnet_ptag_t
    01637 libnet_build_gre(uint16_t fv, uint16_t type, uint16_t sum,
    01638 uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
    01639 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01640
    01662 libnet_ptag_t
    01663 libnet_build_egre(uint16_t fv, uint16_t type, uint16_t sum,
    01664 uint16_t offset, uint32_t key, uint32_t seq, uint16_t len,
    01665 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01666
    01678 libnet_ptag_t
    01679 libnet_build_gre_sre(uint16_t af, uint8_t offset, uint8_t length,
    01680 uint8_t *routing, const uint8_t* payload, uint32_t payload_s, libnet_t *l,
    01681 libnet_ptag_t ptag);
    01682
    01688 libnet_ptag_t
    01689 libnet_build_gre_last_sre(libnet_t *l, libnet_ptag_t ptag);
    01690
    01712 libnet_ptag_t
    01713 libnet_build_bgp4_header(uint8_t marker[LIBNET_BGP4_MARKER_SIZE],
    01714 uint16_t len, uint8_t type, const uint8_t* payload, uint32_t payload_s,
    01715 libnet_t *l, libnet_ptag_t ptag);
    01716
    01733 libnet_ptag_t
    01734 libnet_build_bgp4_open(uint8_t version, uint16_t src_as, uint16_t hold_time,
    01735 uint32_t bgp_id, uint8_t opt_len, const uint8_t* payload, uint32_t payload_s,
    01736 libnet_t *l, libnet_ptag_t ptag);
    01737
    01753 libnet_ptag_t
    01754 libnet_build_bgp4_update(uint16_t unfeasible_rt_len, const uint8_t *withdrawn_rt,
    01755 uint16_t total_path_attr_len, const uint8_t *path_attributes, uint16_t info_len,
    01756 uint8_t *reachability_info, const uint8_t* payload, uint32_t payload_s,
    01757 libnet_t *l, libnet_ptag_t ptag);
    01758
    01771 libnet_ptag_t
    01772 libnet_build_bgp4_notification(uint8_t err_code, uint8_t err_subcode,
    01773 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01774
    01796 libnet_ptag_t
    01797 libnet_build_sebek(uint32_t magic, uint16_t version, uint16_t type,
    01798 uint32_t counter, uint32_t time_sec, uint32_t time_usec, uint32_t pid,
    01799 uint32_t uid, uint32_t fd, uint8_t cmd[SEBEK_CMD_LENGTH], uint32_t length,
    01800 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01801
    01821 libnet_ptag_t
    01822 libnet_build_hsrp(uint8_t version, uint8_t opcode, uint8_t state,
    01823 uint8_t hello_time, uint8_t hold_time, uint8_t priority, uint8_t group,
    01824 uint8_t reserved, uint8_t authdata[HSRP_AUTHDATA_LENGTH], uint32_t virtual_ip,
    01825 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01826
    01841 libnet_ptag_t
    01842 libnet_build_link(const uint8_t *dst, const uint8_t *src, const uint8_t *oui, uint16_t type,
    01843 const uint8_t* payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
    01844
    01855 libnet_ptag_t
    01856 libnet_autobuild_link(const uint8_t *dst, const uint8_t *oui, uint16_t type,
    01857 libnet_t *l);
    01858
    01871 int
    01872 libnet_write(libnet_t *l);
    01873
    01883 uint32_t
    01884 libnet_get_ipaddr4(libnet_t *l);
    01885
    01895 struct libnet_in6_addr
    01896 libnet_get_ipaddr6(libnet_t *l);
    01897
    01906 struct libnet_ether_addr *
    01907 libnet_get_hwaddr(libnet_t *l);
    01908
    01918 uint8_t *
    01919 libnet_hex_aton(const char *s, int *len);
    01920
    01925 const char *
    01926 libnet_version(void);
    01927
    01943 int
    01944 libnet_adv_cull_packet(libnet_t *l, uint8_t **packet, uint32_t *packet_s);
    01945
    01958 int
    01959 libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, uint8_t **header,
    01960 uint32_t *header_s);
    01961
    01975 int
    01976 libnet_adv_write_link(libnet_t *l, const uint8_t *packet, uint32_t packet_s);
    01977
    01991 int
    01992 libnet_adv_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t packet_s);
    01993
    02000 void
    02001 libnet_adv_free_packet(libnet_t *l, uint8_t *packet);
    02002
    02016 int
    02017 libnet_cq_add(libnet_t *l, char *label);
    02018
    02033 libnet_t *
    02034 libnet_cq_remove(libnet_t *l);
    02035
    02047 libnet_t *
    02048 libnet_cq_remove_by_label(char *label);
    02049
    02056 const char *
    02057 libnet_cq_getlabel(libnet_t *l);
    02058
    02065 libnet_t *
    02066 libnet_cq_find_by_label(char *label);
    02067
    02073 void
    02074 libnet_cq_destroy(void);
    02075
    02095 libnet_t *
    02096 libnet_cq_head(void);
    02097
    02103 int
    02104 libnet_cq_last(void);
    02105
    02111 libnet_t *
    02112 libnet_cq_next(void);
    02113
    02119 uint32_t
    02120 libnet_cq_size(void);
    02121
    02125 uint32_t
    02126 libnet_cq_end_loop(void);
    02127
    02133 void
    02134 libnet_diag_dump_context(libnet_t *l);
    02135
    02141 void
    02142 libnet_diag_dump_pblock(libnet_t *l);
    02143
    02150 char *
    02151 libnet_diag_dump_pblock_type(uint8_t type);
    02152
    02166 void
    02167 libnet_diag_dump_hex(const uint8_t *packet, uint32_t len, int swap, FILE *stream);
    02168
    02169 /*
    02170  * [Internal]
    02171  */
    02172 int
    02173 libnet_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t size);
    02174
    02175 /*
    02176  * [Internal]
    02177  */
    02178 int
    02179 libnet_write_raw_ipv6(libnet_t *l, const uint8_t *packet, uint32_t size);
    02180
    02181 /*
    02182  * [Internal]
    02183  */
    02184 int
    02185 libnet_write_link(libnet_t *l, const uint8_t *packet, uint32_t size);
    02186
    02187 #if ((__WIN32__) && !(__CYGWIN__))
    02188 /*
    02189  * [Internal]
    02190  */
    02191 SOCKET
    02192 libnet_open_raw4(libnet_t *l);
    02193 #else
    02194 /*
    02195  * [Internal]
    02196  */
    02197 int
    02198 libnet_open_raw4(libnet_t *l);
    02199 #endif
    02200
    02201 /*
    02202  * [Internal]
    02203  */
    02204 int
    02205 libnet_close_raw4(libnet_t *l);
    02206
    02207 /*
    02208  * [Internal]
    02209  */
    02210 int
    02211 libnet_open_raw6(libnet_t *l);
    02212
    02213 /*
    02214  * [Internal]
    02215  */
    02216 int
    02217 libnet_close_raw6(libnet_t *l);
    02218
    02219 /*
    02220  * [Internal]
    02221  */
    02222 int
    02223 libnet_select_device(libnet_t *l);
    02224
    02225 /*
    02226  * [Internal]
    02227  */
    02228 int
    02229 libnet_open_link(libnet_t *l);
    02230
    02231 /*
    02232  * [Internal]
    02233  */
    02234 int
    02235 libnet_close_link(libnet_t *l);
    02236
    02237 /*
    02238  * [Internal]
    02239  *   THIS FUNCTION IS BROKEN. IT WILL SEGFAULT OR CORRUPT MEMORY, OR JUST SILENTLY DO THE
    02240  *   WRONG THING IF NOT CALLED CORRECTLY, AND CALLING IT CORRECTLY IS UNDOCUMENTED, AND
    02241  *   ALMOST IMPOSSIBLE. YOU HAVE BEEN WARNED.
    02242  */
    02243 int
    02244 libnet_do_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len);
    02245
    02246 /* Calculate internet checksums.
    02247  *
    02248  * IP (TCP, UDP, IGMP, ICMP, etc...) checksums usually need information from
    02249  * the IP header to construct the "pseudo header", this function takes a
    02250  * pointer to that header, the buffer boundaries, the "h_len" (see pblock_t for
    02251  * a description, it is increasinly unused, though, and I'm trying to remove it
    02252  * altogether), and the protocol number for the protocol that is to be
    02253  * checksummed.
    02254  *
    02255  * Finding that protocol requires that the IP header be well-formed... so this
    02256  * won't work well for invalid packets. But then, what is the valid checksum
    02257  * for a valid packet, anyhow?
    02258  *
    02259  * This doesn't work well for non-inet checksums, sorry, that's an original design
    02260  * flaw. pblock_t needs a pointer in it, to a packet assembly function that can be
    02261  * called at runtime to do assembly and checksumming.
    02262  */
    02263 int
    02264 libnet_inet_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len, const uint8_t *beg, const uint8_t * end);
    02265
    02266 /*
    02267  * [Internal]
    02268  */
    02269 uint32_t
    02270 libnet_compute_crc(uint8_t *buf, uint32_t len);
    02271
    02272 /*
    02273  * [Internal]
    02274  */
    02275 uint16_t
    02276 libnet_ip_check(uint16_t *addr, int len);
    02277
    02278 /*
    02279  * [Internal]
    02280  */
    02281 int
    02282 libnet_in_cksum(uint16_t *addr, int len);
    02283
    02284 /*
    02285  * [Internal]
    02286  * If ptag is 0, function will create a pblock for the protocol unit type,
    02287  * append it to the list and return a pointer to it.  If ptag is not 0,
    02288  * function will search the pblock list for the specified protocol block
    02289  * and return a pointer to it.
    02290  */
    02291 libnet_pblock_t *
    02292 libnet_pblock_probe(libnet_t *l, libnet_ptag_t ptag, uint32_t b_len,
    02293 uint8_t type);
    02294
    02295 /*
    02296  * [Internal]
    02297  * Function creates the pblock list if l->protocol_blocks == NULL or appends
    02298  * an entry to the doubly linked list.
    02299  */
    02300 libnet_pblock_t *
    02301 libnet_pblock_new(libnet_t *l, uint32_t b_len);
    02302
    02303 /*
    02304  * [Internal]
    02305  * Function swaps two pblocks in memory.
    02306  */
    02307 int
    02308 libnet_pblock_swap(libnet_t *l, libnet_ptag_t ptag1, libnet_ptag_t ptag2);
    02309
    02310 /*
    02311  * [Internal]
    02312  * Function inserts ptag2 before ptag1 in the doubly linked list.
    02313  */
    02314 int
    02315 libnet_pblock_insert_before(libnet_t *l, libnet_ptag_t ptag1,
    02316 libnet_ptag_t ptag2);
    02317
    02318 /*
    02319  * [Internal]
    02320  * Function removes a pblock from context
    02321  */
    02322 void
    02323 libnet_pblock_delete(libnet_t *l, libnet_pblock_t *p);
    02324
    02325 /*
    02326  * [Internal]
    02327  * Function updates the pblock meta-inforation.  Internally it updates the
    02328  * ptag with a monotonically increasing variable kept in l.  This way each
    02329  * pblock has a succesively increasing ptag identifier.
    02330  */
    02331 libnet_ptag_t
    02332 libnet_pblock_update(libnet_t *l, libnet_pblock_t *p, uint32_t h, uint8_t type);
    02333
    02334
    02335 /*
    02336  * [Internal]
    02337  * Function locates a given block by it's ptag.
    02338  */
    02339 libnet_pblock_t *
    02340 libnet_pblock_find(libnet_t *l, libnet_ptag_t ptag);
    02341
    02342 /*
    02343  * [Internal]
    02344  * Function copies protocol block data over.
    02345  */
    02346 int
    02347 libnet_pblock_append(libnet_t *l, libnet_pblock_t *p, const void *buf, uint32_t len);
    02348
    02349 /*
    02350  * [Internal]
    02351  * Function sets pblock flags.
    02352  */
    02353 void
    02354 libnet_pblock_setflags(libnet_pblock_t *p, uint8_t flags);
    02355
    02356 /*
    02357  * [Internal]
    02358  * Function returns the protocol number for the protocol block type.  If
    02359  * the type is unknown, the function defaults to returning IPPROTO_IP.
    02360  */
    02361 int
    02362 libnet_pblock_p2p(uint8_t type);
    02363
    02364 /*
    02365  * [Internal]
    02366  * Function assembles the protocol blocks into a packet, checksums are
    02367  * calculated if that was requested.
    02368  */
    02369 int
    02370 libnet_pblock_coalesce(libnet_t *l, uint8_t **packet, uint32_t *size);
    02371
    02372 #if !(__WIN32__)
    02373 /*
    02374  * [Internal]
    02375  * By testing if we can retrieve the FLAGS of an iface
    02376  * we can know if it exists or not and if it is up.
    02377  */
    02378 int
    02379 libnet_check_iface(libnet_t *l);
    02380 #endif
    02381
    02382 #if defined(__WIN32__)
    02383 /*
    02384  * [Internal]
    02385  */
    02386 BYTE *
    02387 libnet_win32_get_remote_mac(libnet_t *l, DWORD IP);
    02388
    02389 /*
    02390  * [Internal]
    02391  */
    02392 int
    02393 libnet_close_link_interface(libnet_t *l);
    02394
    02395 /*
    02396  * [Internal]
    02397  */
    02398 BYTE *
    02399 libnet_win32_read_arp_table(DWORD IP);
    02400 #endif
    02401 #endif  /* __LIBNET_FUNCTIONS_H */
    02402
    02403 /* EOF */