Main Page | Data Structures | File List | Data Fields | Globals

libnet-functions.h

Go to the documentation of this file.
00001 /*
00002  *  $Id: libnet-functions.h,v 1.31 2004/01/16 22:45:43 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, 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 int8_t *
00107 libnet_getdevice(libnet_t *l);
00108 
00117 u_int8_t *
00118 libnet_getpbuf(libnet_t *l, libnet_ptag_t ptag);
00119 
00128 u_int32_t
00129 libnet_getpbuf_size(libnet_t *l, libnet_ptag_t ptag);
00130 
00138 char *
00139 libnet_geterror(libnet_t *l);
00140 
00146 int
00147 libnet_seed_prand(libnet_t *l);
00148 
00162 u_int32_t
00163 libnet_get_prand(int mod);
00164 
00186 int
00187 libnet_toggle_checksum(libnet_t *l, libnet_ptag_t ptag, int mode);
00188 
00201 char *
00202 libnet_addr2name4(u_int32_t in, u_int8_t use_name);
00203 
00217 u_int32_t
00218 libnet_name2addr4(libnet_t *l, char *host_name, u_int8_t use_name);
00219 
00220 extern const struct libnet_in6_addr in6addr_error;
00221 
00235 struct libnet_in6_addr
00236 libnet_name2addr6(libnet_t *l, char *host_name, u_int8_t use_name);
00237 
00241 void
00242 libnet_addr2name6_r(struct libnet_in6_addr addr, u_int8_t use_name,
00243 char *host_name, int host_name_len);
00244 
00260 int
00261 libnet_plist_chain_new(libnet_t *l, libnet_plist_t **plist, char *token_list);
00262 
00274 int
00275 libnet_plist_chain_next_pair(libnet_plist_t *plist, u_int16_t *bport, 
00276 u_int16_t *eport); 
00277 
00284 int
00285 libnet_plist_chain_dump(libnet_plist_t *plist);
00286 
00295 char *
00296 libnet_plist_chain_dump_string(libnet_plist_t *plist);
00297 
00303 int
00304 libnet_plist_chain_free(libnet_plist_t *plist);
00305 
00393 libnet_ptag_t
00394 libnet_build_802_1q(u_int8_t *dst, u_int8_t *src, u_int16_t tpi,
00395 u_int8_t priority, u_int8_t cfi, u_int16_t vlan_id, u_int16_t len_proto,
00396 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00397 
00409 libnet_ptag_t
00410 libnet_build_802_1x(u_int8_t eap_ver, u_int8_t eap_type, u_int16_t length, 
00411 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00412 
00424 libnet_ptag_t
00425 libnet_build_802_2(u_int8_t dsap, u_int8_t ssap, u_int8_t control,
00426 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00427 
00441 libnet_ptag_t
00442 libnet_build_802_2snap(u_int8_t dsap, u_int8_t ssap, u_int8_t control, 
00443 u_int8_t *oui, u_int16_t type, u_int8_t *payload, u_int32_t payload_s,
00444 libnet_t *l, libnet_ptag_t ptag); 
00445 
00461 libnet_ptag_t
00462 libnet_build_802_3(u_int8_t *dst, u_int8_t *src, u_int16_t len, 
00463 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00464 
00480 libnet_ptag_t
00481 libnet_build_ethernet(u_int8_t *dst, u_int8_t *src, u_int16_t type, 
00482 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00483 
00495 libnet_ptag_t
00496 libnet_autobuild_ethernet(u_int8_t *dst, u_int16_t type, libnet_t *l);
00497 
00514 libnet_ptag_t
00515 libnet_build_fddi(u_int8_t fc, u_int8_t *dst, u_int8_t *src, u_int8_t dsap,
00516 u_int8_t ssap, u_int8_t cf, u_int8_t *org, u_int16_t type, u_int8_t *payload,
00517 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00518 
00531 libnet_ptag_t
00532 libnet_autobuild_fddi(u_int8_t fc, u_int8_t *dst, u_int8_t dsap, u_int8_t ssap,
00533 u_int8_t cf, u_int8_t *org, u_int16_t type, libnet_t *l);
00534 
00554 libnet_ptag_t
00555 libnet_build_arp(u_int16_t hrd, u_int16_t pro, u_int8_t hln, u_int8_t pln,
00556 u_int16_t op, u_int8_t *sha, u_int8_t *spa, u_int8_t *tha, u_int8_t *tpa,
00557 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00558 
00571 libnet_ptag_t
00572 libnet_autobuild_arp(u_int16_t op, u_int8_t *sha, u_int8_t *spa, u_int8_t *tha,
00573 u_int8_t *tpa, libnet_t *l);
00574 
00591 libnet_ptag_t
00592 libnet_build_tcp(u_int16_t sp, u_int16_t dp, u_int32_t seq, u_int32_t ack,
00593 u_int8_t control, u_int16_t win, u_int16_t sum, u_int16_t urg, u_int16_t len, 
00594 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00595 
00611 libnet_ptag_t
00612 libnet_build_tcp_options(u_int8_t *options, u_int32_t options_s, libnet_t *l,
00613 libnet_ptag_t ptag);
00614 
00627 libnet_ptag_t
00628 libnet_build_udp(u_int16_t sp, u_int16_t dp, u_int16_t len, u_int16_t sum,
00629 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00630 
00650 libnet_ptag_t
00651 libnet_build_cdp(u_int8_t version, u_int8_t ttl, u_int16_t sum, u_int16_t type,
00652 u_int16_t len, u_int8_t *value, u_int8_t *payload, u_int32_t payload_s,
00653 libnet_t *l, libnet_ptag_t ptag);
00654 
00669 libnet_ptag_t
00670 libnet_build_icmpv4_echo(u_int8_t type, u_int8_t code, u_int16_t sum,
00671 u_int16_t id, u_int16_t seq, u_int8_t *payload, u_int32_t payload_s,
00672 libnet_t *l, libnet_ptag_t ptag);
00673 
00689 libnet_ptag_t
00690 libnet_build_icmpv4_mask(u_int8_t type, u_int8_t code, u_int16_t sum,
00691 u_int16_t id, u_int16_t seq, u_int32_t mask, u_int8_t *payload,
00692 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00693 
00716 libnet_ptag_t
00717 libnet_build_icmpv4_unreach(u_int8_t type, u_int8_t code, u_int16_t sum,
00718 u_int16_t orig_len, u_int8_t orig_tos, u_int16_t orig_id, u_int16_t orig_frag,
00719 u_int8_t orig_ttl, u_int8_t orig_prot,  u_int16_t orig_check, 
00720 u_int32_t orig_src, u_int32_t orig_dst, u_int8_t *payload, u_int32_t payload_s,
00721 libnet_t *l, libnet_ptag_t ptag);
00722 
00744 libnet_ptag_t
00745 libnet_build_icmpv4_redirect(u_int8_t type, u_int8_t code, u_int16_t sum,
00746 u_int32_t gateway, u_int16_t orig_len, u_int8_t orig_tos, u_int16_t orig_id,
00747 u_int16_t orig_frag, u_int8_t orig_ttl, u_int8_t orig_prot,
00748 u_int16_t orig_check, u_int32_t orig_src, u_int32_t orig_dst,
00749 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00750 
00774 libnet_ptag_t
00775 libnet_build_icmpv4_timeexceed(u_int8_t type, u_int8_t code, u_int16_t sum,
00776 u_int16_t orig_len, u_int8_t orig_tos, u_int16_t orig_id, u_int16_t orig_frag,
00777 u_int8_t orig_ttl, u_int8_t orig_prot, u_int16_t orig_check,
00778 u_int32_t orig_src, u_int32_t orig_dst, u_int8_t *payload, u_int32_t payload_s,
00779 libnet_t *l, libnet_ptag_t ptag);
00780 
00798 libnet_ptag_t
00799 libnet_build_icmpv4_timestamp(u_int8_t type, u_int8_t code, u_int16_t sum,
00800 u_int16_t id, u_int16_t seq, n_time otime, n_time rtime, n_time ttime,
00801 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00802 
00815 libnet_ptag_t
00816 libnet_build_igmp(u_int8_t type, u_int8_t code, u_int16_t sum, u_int32_t ip,
00817 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00818 
00836 libnet_ptag_t 
00837 libnet_build_ipv4(u_int16_t len, u_int8_t tos, u_int16_t id, u_int16_t frag,
00838 u_int8_t ttl, u_int8_t prot, u_int16_t sum, u_int32_t src, u_int32_t dst,
00839 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00840 
00855 libnet_ptag_t 
00856 libnet_build_ipv4_options(u_int8_t *options, u_int32_t options_s, libnet_t *l,
00857 libnet_ptag_t ptag);
00858 
00871 libnet_ptag_t
00872 libnet_autobuild_ipv4(u_int16_t len, u_int8_t prot, u_int32_t dst, libnet_t *l);
00873 
00889 libnet_ptag_t
00890 libnet_build_ipv6(u_int8_t tc, u_int32_t fl, u_int16_t len, u_int8_t nh,
00891 u_int8_t hl, struct libnet_in6_addr src, struct libnet_in6_addr dst, 
00892 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00893 
00906 libnet_ptag_t
00907 libnet_build_ipv6_frag(u_int8_t nh, u_int8_t reserved, u_int16_t frag,
00908 u_int32_t id, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
00909 libnet_ptag_t ptag);
00910 
00928 libnet_ptag_t
00929 libnet_build_ipv6_routing(u_int8_t nh, u_int8_t len, u_int8_t rtype,
00930 u_int8_t segments, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
00931 libnet_ptag_t ptag);
00932 
00947 libnet_ptag_t
00948 libnet_build_ipv6_destopts(u_int8_t nh, u_int8_t len, u_int8_t *payload,
00949 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00950 
00958 libnet_ptag_t
00959 libnet_build_ipv6_hbhopts(u_int8_t nh, u_int8_t len, u_int8_t *payload,
00960 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00961 
00969 libnet_ptag_t
00970 libnet_autobuild_ipv6(u_int16_t len, u_int8_t nh, struct libnet_in6_addr dst,
00971 libnet_t *l);
00972 
00980 libnet_ptag_t
00981 libnet_build_isl(u_int8_t *dhost, u_int8_t type, u_int8_t user, u_int8_t *shost,
00982 u_int16_t len, u_int8_t *snap, u_int16_t vid, u_int16_t index,
00983 u_int16_t reserved, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
00984 libnet_ptag_t ptag);
00985 
00993 libnet_ptag_t
00994 libnet_build_ipsec_esp_hdr(u_int32_t spi, u_int32_t seq, u_int32_t iv,
00995 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00996 
01004 libnet_ptag_t
01005 libnet_build_ipsec_esp_ftr(u_int8_t len, u_int8_t nxt_hdr, int8_t *auth,
01006 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01007 
01015 libnet_ptag_t
01016 libnet_build_ipsec_ah(u_int8_t nxt_hdr, u_int8_t len, u_int16_t res,
01017 u_int32_t spi, u_int32_t seq, u_int32_t auth, u_int8_t *payload,
01018 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01019 
01027 libnet_ptag_t
01028 libnet_build_dnsv4(u_int16_t h_len, u_int16_t id, u_int16_t flags,
01029 u_int16_t num_q, u_int16_t num_anws_rr, u_int16_t num_auth_rr,
01030 u_int16_t num_addi_rr, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
01031 libnet_ptag_t ptag);
01032 
01040 libnet_ptag_t
01041 libnet_build_rip(u_int8_t cmd, u_int8_t version, u_int16_t rd, u_int16_t af,
01042 u_int16_t rt, u_int32_t addr, u_int32_t mask, u_int32_t next_hop,
01043 u_int32_t metric, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
01044 libnet_ptag_t ptag);
01045 
01053 libnet_ptag_t
01054 libnet_build_rpc_call(u_int32_t rm, u_int32_t xid, u_int32_t prog_num,
01055 u_int32_t prog_vers, u_int32_t procedure, u_int32_t cflavor, u_int32_t clength,
01056 u_int8_t *cdata, u_int32_t vflavor, u_int32_t vlength, u_int8_t *vdata,
01057 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01058 
01066 libnet_ptag_t
01067 libnet_build_stp_conf(u_int16_t id, u_int8_t version, u_int8_t bpdu_type,
01068 u_int8_t flags, u_int8_t *root_id, u_int32_t root_pc, u_int8_t *bridge_id,
01069 u_int16_t port_id, u_int16_t message_age, u_int16_t max_age, 
01070 u_int16_t hello_time, u_int16_t f_delay, u_int8_t *payload,
01071 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01072 
01080 libnet_ptag_t
01081 libnet_build_stp_tcn(u_int16_t id, u_int8_t version, u_int8_t bpdu_type,
01082 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01083 
01091 libnet_ptag_t
01092 libnet_build_token_ring(u_int8_t ac, u_int8_t fc, u_int8_t *dst, u_int8_t *src,
01093 u_int8_t dsap, u_int8_t ssap, u_int8_t cf, u_int8_t *org, u_int16_t type,
01094 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01095 
01103 libnet_ptag_t
01104 libnet_autobuild_token_ring(u_int8_t ac, u_int8_t fc, u_int8_t *dst, 
01105 u_int8_t dsap, u_int8_t ssap, u_int8_t cf, u_int8_t *org, u_int16_t type,
01106 libnet_t *l);
01107 
01115 libnet_ptag_t
01116 libnet_build_vrrp(u_int8_t version, u_int8_t type, u_int8_t vrouter_id,
01117 u_int8_t priority, u_int8_t ip_count, u_int8_t auth_type, u_int8_t advert_int,
01118 u_int16_t sum, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
01119 libnet_ptag_t ptag);
01120 
01128 libnet_ptag_t
01129 libnet_build_mpls(u_int32_t label, u_int8_t experimental, u_int8_t bos,
01130 u_int8_t ttl, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
01131 libnet_ptag_t ptag);
01132 
01140 libnet_ptag_t
01141 libnet_build_ntp(u_int8_t leap_indicator, u_int8_t version, u_int8_t mode,
01142 u_int8_t stratum, u_int8_t poll, u_int8_t precision, u_int16_t delay_int,
01143 u_int16_t delay_frac, u_int16_t dispersion_int, u_int16_t dispersion_frac,
01144 u_int32_t reference_id, u_int32_t ref_ts_int, u_int32_t ref_ts_frac,
01145 u_int32_t orig_ts_int, u_int32_t orig_ts_frac, u_int32_t rec_ts_int,
01146 u_int32_t rec_ts_frac, u_int32_t xmt_ts_int, u_int32_t xmt_ts_frac,
01147 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01148 
01156 libnet_ptag_t
01157 libnet_build_ospfv2(u_int16_t len, u_int8_t type, u_int32_t rtr_id,
01158 u_int32_t area_id, u_int16_t sum, u_int16_t autype, u_int8_t *payload,
01159 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01160 
01168 libnet_ptag_t
01169 libnet_build_ospfv2_hello(u_int32_t netmask, u_int16_t interval, u_int8_t opts,
01170 u_int8_t priority, u_int dead_int, u_int32_t des_rtr, u_int32_t bkup_rtr,
01171 u_int32_t neighbor, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
01172 libnet_ptag_t ptag);
01173  
01181 libnet_ptag_t
01182 libnet_build_ospfv2_dbd(u_int16_t dgram_len, u_int8_t opts, u_int8_t type,
01183 u_int seqnum, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
01184 libnet_ptag_t ptag);
01185  
01193 libnet_ptag_t
01194 libnet_build_ospfv2_lsr(u_int type, u_int lsid, u_int32_t advrtr,
01195 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01196  
01204 libnet_ptag_t
01205 libnet_build_ospfv2_lsu(u_int num, u_int8_t *payload, u_int32_t payload_s,
01206 libnet_t *l, libnet_ptag_t ptag);
01207 
01215 libnet_ptag_t
01216 libnet_build_ospfv2_lsa(u_int16_t age, u_int8_t opts, u_int8_t type,
01217 u_int lsid, u_int32_t advrtr, u_int seqnum, u_int16_t sum, u_int16_t len,
01218 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01219  
01227 libnet_ptag_t
01228 libnet_build_ospfv2_lsa_rtr(u_int16_t flags, u_int16_t num, u_int id,
01229 u_int data, u_int8_t type, u_int8_t tos, u_int16_t metric, u_int8_t *payload,
01230 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01231  
01239 libnet_ptag_t
01240 libnet_build_ospfv2_lsa_net(u_int32_t nmask, u_int rtrid, u_int8_t *payload,
01241 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01242  
01250 libnet_ptag_t
01251 libnet_build_ospfv2_lsa_sum(u_int32_t nmask, u_int metric, u_int tos,
01252 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01253  
01261 libnet_ptag_t
01262 libnet_build_ospfv2_lsa_as(u_int32_t nmask, u_int metric, u_int32_t fwdaddr,
01263 u_int tag, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
01264 libnet_ptag_t ptag);
01265 
01273 libnet_ptag_t
01274 libnet_build_data(u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
01275 libnet_ptag_t ptag);
01276 
01284 libnet_ptag_t
01285 libnet_build_dhcpv4(u_int8_t opcode, u_int8_t htype, u_int8_t hlen,
01286 u_int8_t hopcount, u_int32_t xid, u_int16_t secs, u_int16_t flags,
01287 u_int32_t cip, u_int32_t yip,  u_int32_t sip, u_int32_t gip, u_int8_t *chaddr,
01288 u_int8_t *sname, u_int8_t *file, u_int8_t *payload, u_int32_t payload_s, 
01289 libnet_t *l, libnet_ptag_t ptag);
01290 
01298 libnet_ptag_t
01299 libnet_build_bootpv4(u_int8_t opcode, u_int8_t htype, u_int8_t hlen,
01300 u_int8_t hopcount, u_int32_t xid, u_int16_t secs, u_int16_t flags,
01301 u_int32_t cip, u_int32_t yip,  u_int32_t sip, u_int32_t gip, u_int8_t *chaddr,
01302 u_int8_t *sname, u_int8_t *file, u_int8_t *payload, u_int32_t payload_s, 
01303 libnet_t *l, libnet_ptag_t ptag);
01304 
01305 inline u_int32_t libnet_gre_length(u_int16_t fv);
01306 
01307 #define libnet_egre_length libnet_gre_length
01308 
01316 libnet_ptag_t
01317 libnet_build_gre(u_int16_t fv, u_int16_t type, u_int16_t checksum,
01318 u_int16_t offset, u_int32_t key, u_int32_t seq, u_int16_t len,
01319 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01320 
01321 #define libnet_build_egre libnet_build_gre
01322 
01330 libnet_ptag_t
01331 libnet_build_gre_sre(u_int16_t af, u_int8_t offset, u_int8_t length,
01332 u_int8_t *routing, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
01333 libnet_ptag_t ptag);
01334 
01342 libnet_ptag_t
01343 libnet_build_gre_last_sre(libnet_t *l, libnet_ptag_t ptag);
01344 
01352 libnet_ptag_t
01353 libnet_build_bgp4_header(u_int8_t marker[LIBNET_BGP4_MARKER_SIZE],
01354 u_int16_t len, u_int8_t type, u_int8_t *payload, u_int32_t payload_s,
01355 libnet_t *l, libnet_ptag_t ptag);
01356 
01364 libnet_ptag_t
01365 libnet_build_bgp4_open(u_int8_t version, u_int16_t src_as, u_int16_t hold_time,
01366 u_int32_t bgp_id, u_int8_t opt_len, u_int8_t *payload, u_int32_t payload_s,
01367 libnet_t *l, libnet_ptag_t ptag);
01368 
01376 libnet_ptag_t
01377 libnet_build_bgp4_update(u_int16_t unfeasible_rt_len, u_int8_t *withdrawn_rt,
01378 u_int16_t total_path_attr_len, u_int8_t *path_attributes, u_int16_t info_len,
01379 u_int8_t *reachability_info, u_int8_t *payload, u_int32_t payload_s,
01380 libnet_t *l, libnet_ptag_t ptag);
01381 
01389 libnet_ptag_t
01390 libnet_build_bgp4_notification(u_int8_t err_code, u_int8_t err_subcode,
01391 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01392 
01400 libnet_ptag_t
01401 libnet_build_link(u_int8_t *dst, u_int8_t *src, u_int16_t type, 
01402 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01403 
01411 libnet_ptag_t
01412 libnet_autobuild_link(u_int8_t *dst, u_int16_t type, libnet_t *l);
01413 
01414 int
01415 libnet_write(libnet_t *l);
01416 
01417 int
01418 libnet_write_raw_ipv4(libnet_t *l, u_int8_t *packet, u_int32_t size);
01419 
01420 int
01421 libnet_write_raw_ipv6(libnet_t *l, u_int8_t *packet, u_int32_t size);
01422 
01423 int
01424 libnet_write_link(libnet_t *l, u_int8_t *packet, u_int32_t size);
01425 
01426 #if ((__WIN32__) && !(__CYGWIN__))
01427 SOCKET
01428 libnet_open_raw4(libnet_t *l);
01429 #else
01430 int
01431 libnet_open_raw4(libnet_t *l);
01432 #endif
01433 
01434 int
01435 libnet_close_raw4(libnet_t *l);
01436 
01437 int
01438 libnet_open_raw6(libnet_t *l);
01439        
01440 int
01441 libnet_close_raw6(libnet_t *l);
01442 
01443 int
01444 libnet_select_device(libnet_t *l);
01445 
01446 int
01447 libnet_open_link(libnet_t *l);
01448 
01449 int
01450 libnet_close_link(libnet_t *l);
01451 
01452 u_int32_t
01453 libnet_get_ipaddr4(libnet_t *l);
01454 
01455 struct libnet_in6_addr
01456 libnet_get_ipaddr6(libnet_t *l);
01457 
01458 struct libnet_ether_addr *
01459 libnet_get_hwaddr(libnet_t *l);
01460 
01461 int
01462 libnet_do_checksum(libnet_t *l, u_int8_t *packet, int protocol, int len);
01463 
01464 u_int32_t
01465 libnet_compute_crc(u_int8_t *buf, u_int32_t len);
01466 
01467 u_int16_t
01468 libnet_ip_check(u_int16_t *addr, int len);
01469 
01470 int
01471 libnet_in_cksum(u_int16_t *addr, int len);
01472 
01473 
01474 /*
01475  *  libnet_pblock_probe
01476  *
01477  *  If ptag is 0, function will create a pblock for the protocol unit type,
01478  *  append it to the list and return a pointer to it.  If ptag is not 0,
01479  *  function will search the pblock list for the specified protocol block 
01480  *  and return a pointer to it.
01481  */
01482 libnet_pblock_t *
01483 libnet_pblock_probe(libnet_t *l, libnet_ptag_t ptag, u_int32_t n, 
01484 u_int8_t type);
01485 
01486 /*
01487  *  libnet_pblock_new
01488  *
01489  *  Function creates the pblock list if l->protocol_blocks == NULL or appends
01490  *  an entry to the doubly linked list.
01491  */
01492 libnet_pblock_t *
01493 libnet_pblock_new(libnet_t *l, u_int32_t size);
01494 
01495 
01496 /*
01497  *  libnet_pblock_swap
01498  *
01499  *  Function swaps two pblocks in memory.
01500  */
01501 int
01502 libnet_pblock_swap(libnet_t *l, libnet_ptag_t ptag1, libnet_ptag_t ptag2);
01503   
01504 
01505 /*
01506  *  libnet_pblock_insert_before
01507  *
01508  *  Function inserts a pblock into the doubly linked list.
01509  */
01510 int
01511 libnet_pblock_insert_before(libnet_t *l, libnet_ptag_t ptag1,
01512 libnet_ptag_t ptag2);
01513 
01514 /*
01515  *  libnet_pblock_delete
01516  *  
01517  *  Function removes a pblock from context 
01518  */
01519 void
01520 libnet_pblock_delete(libnet_t *l, libnet_pblock_t *p);
01521 
01522 /*
01523  *  libnet_pblock_update
01524  *
01525  *  Function updates the pblock meta-inforation.  Internally it updates the
01526  *  ptag with a monotonically increasing variable kept in l.  This way each
01527  *  pblock has a succesively increasing ptag identifier.
01528  */
01529 libnet_ptag_t
01530 libnet_pblock_update(libnet_t *l, libnet_pblock_t *p, u_int32_t h, 
01531 u_int8_t type);
01532 
01533 
01534 /*
01535  *  libnet_pblock_find
01536  *
01537  *  Function locates a given block by it's ptag. 
01538  */
01539 libnet_pblock_t *
01540 libnet_pblock_find(libnet_t *l, libnet_ptag_t ptag);
01541 
01542 
01543 /*
01544  *  libnet_pblock_append
01545  *
01546  *  Function copies protocol block data over.
01547  */
01548 int
01549 libnet_pblock_append(libnet_t *l, libnet_pblock_t *p, u_int8_t *buf,
01550 u_int32_t len);
01551 
01552 
01553 /*
01554  *  libnet_pblock_setflags
01555  *
01556  *  Function sets pblock flags.
01557  */
01558 void
01559 libnet_pblock_setflags(libnet_pblock_t *p, u_int8_t flags);
01560 
01561 
01562 /*
01563  *  libnet_pblock_p2p
01564  *
01565  *  Function returns the protocol number for the protocol block type.  If
01566  *  the type is unknown, the function defaults to returning IPPROTO_IP.
01567  */
01568 int
01569 libnet_pblock_p2p(u_int8_t type);
01570 
01571 
01572 /*
01573  *  libnet_pblock_coalesce
01574  *
01575  *  Function assembles the packet for subsequent writing.  Function makes two
01576  *  passes through the pblock list:
01577  *  1st & 2nd) determine total size of the packet for contiguous malloc
01578  *             and copy over packet chunks 
01579  *  3rd run) run through the original list and see which protocol blocks had
01580  *           the checksum flag set (checksums usually need to be done over
01581  *           an assembled packet so it's easier to do it here)
01582  */
01583 int
01584 libnet_pblock_coalesce(libnet_t *l, u_int8_t **packet, u_int32_t *size);
01585 
01586 
01587 /*
01588  *  __libnet_dump_context
01589  *
01590  *  Function returns the contents of the libnet file context.  Not meant for
01591  *  the applications programer.
01592  */
01593 void
01594 __libnet_dump_context(libnet_t *l);
01595 
01596 /*
01597  *  __libnet_dump_pblock
01598  *
01599  *  Function returns the contents of each pblock in a given context.  Not meant 
01600  *  for the applications programer.
01601  */
01602 void
01603 __libnet_dump_pblock(libnet_t *l);
01604 
01605 /*
01606  *  __libnet_dump_pblock_type
01607  *
01608  *  Function returns a canonical string referring to the pblock type.
01609  */
01610 int8_t *
01611 __libnet_dump_pblock_type(u_int8_t type);
01612 
01613 /*
01614  *  __libnet_hex_dump
01615  *
01616  *  Function dumps the contents of the supplied buffer to the supplied
01617  *  stream pointer.  Very useful for debugging.  Will swap endianness based
01618  *  disposition of mode variable.  Use requires unwrapping the libnet file
01619  *  context structure so it's hidden down here.  If you find it, consider
01620  *  yourself a trepid adventurer.
01621  */
01622 void
01623 __libnet_dump_hex(u_int8_t *packet, u_int32_t len, int swap, FILE *stream);
01624 
01625 
01626 /*
01627  *  libnet_hex_aton
01628  *
01629  *  hexidecimal strings of the format "##:##:##:## ... :##:##" to a uint8_t.
01630  *
01631  */
01632 u_int8_t *
01633 libnet_hex_aton(int8_t *s, int *len);
01634 
01635 /*
01636  *  libnet_adv_cull_packet
01637  *
01638  *  advanced interface, culls the packet from inside libnet, wraps
01639  *  libnet_pblock_coalesce().
01640  *
01641  */
01642 int
01643 libnet_adv_cull_packet(libnet_t *l, u_int8_t **packet, u_int32_t *packet_s);
01644 
01645 /*
01646  *  libnet_adv_cull_header
01647  *
01648  *  advanced interface, culls the header from referenced ptag from inside
01649  *  libnet.
01650  *
01651  */
01652 int
01653 libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, u_int8_t **header,
01654 u_int32_t *header_s);
01655 
01656 /*
01657  *  libnet_adv_write_link
01658  *
01659  *  advanced interface, writes a prebuilt frame to the wire
01660  *
01661  */
01662 int
01663 libnet_adv_write_link(libnet_t *l, u_int8_t *packet, u_int32_t packet_s);
01664 
01665 /*
01666  *  libnet_cq_add
01667  *  
01668  *  Function adds a context to the libnet context queue.
01669  */
01670 int 
01671 libnet_cq_add(libnet_t *l, char *label);
01672 
01673 /*
01674  *  libnet_cq_remove
01675  *
01676  *  Function removes a context from the libnet context queue.
01677  *
01678  */
01679 libnet_t *
01680 libnet_cq_remove(libnet_t *l);
01681 
01682 /* 
01683  *  libnet_cq_remove_by_label
01684  *
01685  *  Function removes a libnet context from the queue, indexed by it's
01686  *  canonical label.
01687  */   
01688 libnet_t *
01689 libnet_cq_remove_by_label(char *label);
01690  
01691 /* 
01692  *  libnet_cq_getlabel
01693  *
01694  *  Function returns the label (if any) associated with the context.
01695  */   
01696 int8_t *
01697 libnet_cq_getlabel(libnet_t *l);
01698  
01699 /* 
01700  * libnet_cq_find_by_label
01701  * 
01702  *  Function locates a libnet context from the queue, indexed by it's
01703  *  canonical label.
01704  *
01705  */
01706 libnet_t *
01707 libnet_cq_find_by_label(char *label);
01708   
01709 /* 
01710  *  libnet_cq_destroy
01711  * 
01712  *  Function destroys the entire context queue, calling libnet_destory() on
01713  *  each member context.
01714  */
01715 void libnet_cq_destroy();
01716 
01717 /*
01718  *  libnet_cq_head
01719  *
01720  *  Function intiailizes the interator interface and sets a write lock on
01721  *  the context queue.
01722  */
01723 libnet_t *
01724 libnet_cq_head();
01725 
01726 /*
01727  *  libnet_cq_head
01728  *
01729  *  Function returns 1 if at the end of the context queue, 0 otherwise.
01730  */
01731 int
01732 libnet_cq_last();
01733 
01734 /*
01735  *  libnet_cq_head
01736  *
01737  *  Function returns the next context from the context queue.
01738  */
01739 libnet_t *
01740 libnet_cq_next();
01741 
01742 /*
01743  *  libnet_cq_size
01744  *
01745  *  Function returns the number of entries in the context queue.
01746  */
01747 u_int32_t
01748 libnet_cq_size();
01749 
01750 /*
01751  * libnet_check_iface
01752  *
01753  * By testing if we can retrieve the FLAGS of an iface
01754  * we can know if it exists or not and if it is up.
01755  */
01756 #if !(__WIN32__)
01757 int
01758 libnet_check_iface(libnet_t *l);
01759 #endif
01760 
01761 #if defined(__WIN32__)
01762 BYTE *
01763 libnet_win32_get_remote_mac(libnet_t *l, DWORD IP);
01764 int
01765 libnet_close_link_interface(libnet_t *l);
01766 BYTE * 
01767 libnet_win32_read_arp_table(DWORD IP);
01768 #endif
01769 #endif  /* __LIBNET_FUNCTIONS_H */
01770 
01771 /* EOF */

Generated on Fri Jan 16 17:39:57 2004 for libnet by doxygen 1.3.4