Main Page | File List | Globals

libnet-functions.h

Go to the documentation of this file.
00001 /*
00002  *  $Id: libnet-functions.h,v 1.24 2003/11/11 02:44:06 mike Exp $
00003  *
00004  *  libnet-functions.h - function prototypes
00005  *
00006  *  Copyright (c) 1998 - 2003 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 
00388 libnet_ptag_t
00389 libnet_build_802_1q(u_int8_t *dst, u_int8_t *src, u_int16_t tpi,
00390 u_int8_t priority, u_int8_t cfi, u_int16_t vlan_id, u_int16_t len_proto,
00391 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00392 
00404 libnet_ptag_t
00405 libnet_build_802_1x(u_int8_t eap_ver, u_int8_t eap_type, u_int16_t length, 
00406 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00407 
00419 libnet_ptag_t
00420 libnet_build_802_2(u_int8_t dsap, u_int8_t ssap, u_int8_t control,
00421 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00422 
00436 libnet_ptag_t
00437 libnet_build_802_2snap(u_int8_t dsap, u_int8_t ssap, u_int8_t control, 
00438 u_int8_t *oui, u_int16_t type, u_int8_t *payload, u_int32_t payload_s,
00439 libnet_t *l, libnet_ptag_t ptag); 
00440 
00456 libnet_ptag_t
00457 libnet_build_802_3(u_int8_t *dst, u_int8_t *src, u_int16_t len, 
00458 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00459 
00475 libnet_ptag_t
00476 libnet_build_ethernet(u_int8_t *dst, u_int8_t *src, u_int16_t type, 
00477 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00478 
00490 libnet_ptag_t
00491 libnet_autobuild_ethernet(u_int8_t *dst, u_int16_t type, libnet_t *l);
00492 
00500 libnet_ptag_t
00501 libnet_build_fddi(u_int8_t fc, u_int8_t *dst, u_int8_t *src, u_int8_t dsap,
00502 u_int8_t ssap, u_int8_t cf, u_int8_t *org, u_int16_t type, u_int8_t *payload,
00503 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00504 
00512 libnet_ptag_t
00513 libnet_autobuild_fddi(u_int8_t fc, u_int8_t *dst, u_int8_t dsap, u_int8_t ssap,
00514 u_int8_t cf, u_int8_t *org, u_int16_t type, libnet_t *l);
00515 
00523 libnet_ptag_t
00524 libnet_build_arp(u_int16_t hrd, u_int16_t pro, u_int8_t hln, u_int8_t pln,
00525 u_int16_t op, u_int8_t *sha, u_int8_t *spa, u_int8_t *tha, u_int8_t *tpa,
00526 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00527 
00535 libnet_ptag_t
00536 libnet_autobuild_arp(u_int16_t op, u_int8_t *sha, u_int8_t *spa, u_int8_t *tha,
00537 u_int8_t *tpa, libnet_t *l);
00538 
00546 libnet_ptag_t
00547 libnet_build_tcp(u_int16_t sp, u_int16_t dp, u_int32_t seq, u_int32_t ack,
00548 u_int8_t control, u_int16_t win, u_int16_t sum, u_int16_t urg, u_int16_t len, 
00549 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00550 
00558 libnet_ptag_t
00559 libnet_build_tcp_options(u_int8_t *options, u_int32_t options_s, libnet_t *l,
00560 libnet_ptag_t ptag);
00561 
00569 libnet_ptag_t
00570 libnet_build_udp(u_int16_t sp, u_int16_t dp, u_int16_t len, u_int16_t sum,
00571 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00572 
00580 libnet_ptag_t
00581 libnet_build_cdp(u_int8_t version, u_int8_t ttl, u_int16_t sum, u_int16_t type,
00582 u_int16_t len, u_int8_t *value, u_int8_t *payload, u_int32_t payload_s,
00583 libnet_t *l, libnet_ptag_t ptag);
00584 
00592 libnet_ptag_t
00593 libnet_build_icmpv4_echo(u_int8_t type, u_int8_t code, u_int16_t sum,
00594 u_int16_t id, u_int16_t seq, u_int8_t *payload, u_int32_t payload_s,
00595 libnet_t *l, libnet_ptag_t ptag);
00596 
00604 libnet_ptag_t
00605 libnet_build_icmpv4_mask(u_int8_t type, u_int8_t code, u_int16_t sum,
00606 u_int16_t id, u_int16_t seq, u_int32_t mask, u_int8_t *payload,
00607 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00608 
00616 libnet_ptag_t
00617 libnet_build_icmpv4_unreach(u_int8_t type, u_int8_t code, u_int16_t sum,
00618 u_int16_t orig_len, u_int8_t orig_tos, u_int16_t orig_id, u_int16_t orig_frag,
00619 u_int8_t orig_ttl, u_int8_t orig_prot,  u_int16_t orig_check, 
00620 u_int32_t orig_src, u_int32_t orig_dst, u_int8_t *payload, u_int32_t payload_s,
00621 libnet_t *l, libnet_ptag_t ptag);
00622 
00630 libnet_ptag_t
00631 libnet_build_icmpv4_redirect(u_int8_t type, u_int8_t code, u_int16_t sum,
00632 u_int32_t gateway, u_int16_t orig_len, u_int8_t orig_tos, u_int16_t orig_id,
00633 u_int16_t orig_frag, u_int8_t orig_ttl, u_int8_t orig_prot,
00634 u_int16_t orig_check, u_int32_t orig_src, u_int32_t orig_dst,
00635 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00636 
00644 libnet_ptag_t
00645 libnet_build_icmpv4_timeexceed(u_int8_t type, u_int8_t code, u_int16_t sum,
00646 u_int16_t orig_len, u_int8_t orig_tos, u_int16_t orig_id, u_int16_t orig_frag,
00647 u_int8_t orig_ttl, u_int8_t orig_prot, u_int16_t orig_check,
00648 u_int32_t orig_src, u_int32_t orig_dst, u_int8_t *payload, u_int32_t payload_s,
00649 libnet_t *l, libnet_ptag_t ptag);
00650 
00658 libnet_ptag_t
00659 libnet_build_icmpv4_timestamp(u_int8_t type, u_int8_t code, u_int16_t sum,
00660 u_int16_t id, u_int16_t seq, n_time otime, n_time rtime, n_time ttime,
00661 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00662 
00670 libnet_ptag_t
00671 libnet_build_igmp(u_int8_t type, u_int8_t code, u_int16_t sum, u_int32_t ip,
00672 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00673 
00681 libnet_ptag_t 
00682 libnet_build_ipv4(u_int16_t len, u_int8_t tos, u_int16_t id, u_int16_t frag,
00683 u_int8_t ttl, u_int8_t prot, u_int16_t sum, u_int32_t src, u_int32_t dst,
00684 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00685 
00693 libnet_ptag_t 
00694 libnet_build_ipv4_options(u_int8_t *options, u_int32_t options_s, libnet_t *l,
00695 libnet_ptag_t ptag);
00696 
00704 libnet_ptag_t
00705 libnet_autobuild_ipv4(u_int16_t len, u_int8_t prot, u_int32_t dst,
00706 libnet_t *l);
00707 
00715 libnet_ptag_t
00716 libnet_build_ipv6(u_int8_t tc, u_int32_t fl, u_int16_t len, u_int8_t nh,
00717 u_int8_t hl, struct libnet_in6_addr src, struct libnet_in6_addr dst, 
00718 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00719 
00727 libnet_ptag_t
00728 libnet_autobuild_ipv6(u_int16_t len, u_int8_t nh, struct libnet_in6_addr dst,
00729 libnet_t *l);
00730 
00738 libnet_ptag_t
00739 libnet_build_isl(u_int8_t *dhost, u_int8_t type, u_int8_t user, u_int8_t *shost,
00740 u_int16_t len, u_int8_t *snap, u_int16_t vid, u_int16_t index,
00741 u_int16_t reserved, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
00742 libnet_ptag_t ptag);
00743 
00751 libnet_ptag_t
00752 libnet_build_ipsec_esp_hdr(u_int32_t spi, u_int32_t seq, u_int32_t iv,
00753 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00754 
00762 libnet_ptag_t
00763 libnet_build_ipsec_esp_ftr(u_int8_t len, u_int8_t nxt_hdr, int8_t *auth,
00764 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00765 
00773 libnet_ptag_t
00774 libnet_build_ipsec_ah(u_int8_t nxt_hdr, u_int8_t len, u_int16_t res,
00775 u_int32_t spi, u_int32_t seq, u_int32_t auth, u_int8_t *payload,
00776 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00777 
00785 libnet_ptag_t
00786 libnet_build_dnsv4(u_int16_t h_len, u_int16_t id, u_int16_t flags,
00787 u_int16_t num_q, u_int16_t num_anws_rr, u_int16_t num_auth_rr,
00788 u_int16_t num_addi_rr, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
00789 libnet_ptag_t ptag);
00790 
00798 libnet_ptag_t
00799 libnet_build_rip(u_int8_t cmd, u_int8_t version, u_int16_t rd, u_int16_t af,
00800 u_int16_t rt, u_int32_t addr, u_int32_t mask, u_int32_t next_hop,
00801 u_int32_t metric, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
00802 libnet_ptag_t ptag);
00803 
00811 libnet_ptag_t
00812 libnet_build_rpc_call(u_int32_t rm, u_int32_t xid, u_int32_t prog_num,
00813 u_int32_t prog_vers, u_int32_t procedure, u_int32_t cflavor, u_int32_t clength,
00814 u_int8_t *cdata, u_int32_t vflavor, u_int32_t vlength, u_int8_t *vdata,
00815 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00816 
00824 libnet_ptag_t
00825 libnet_build_stp_conf(u_int16_t id, u_int8_t version, u_int8_t bpdu_type,
00826 u_int8_t flags, u_int8_t *root_id, u_int32_t root_pc, u_int8_t *bridge_id,
00827 u_int16_t port_id, u_int16_t message_age, u_int16_t max_age, 
00828 u_int16_t hello_time, u_int16_t f_delay, u_int8_t *payload,
00829 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00830 
00838 libnet_ptag_t
00839 libnet_build_stp_tcn(u_int16_t id, u_int8_t version, u_int8_t bpdu_type,
00840 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00841 
00849 libnet_ptag_t
00850 libnet_build_token_ring(u_int8_t ac, u_int8_t fc, u_int8_t *dst, u_int8_t *src,
00851 u_int8_t dsap, u_int8_t ssap, u_int8_t cf, u_int8_t *org, u_int16_t type,
00852 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00853 
00861 libnet_ptag_t
00862 libnet_autobuild_token_ring(u_int8_t ac, u_int8_t fc, u_int8_t *dst, 
00863 u_int8_t dsap, u_int8_t ssap, u_int8_t cf, u_int8_t *org, u_int16_t type,
00864 libnet_t *l);
00865 
00873 libnet_ptag_t
00874 libnet_build_vrrp(u_int8_t version, u_int8_t type, u_int8_t vrouter_id,
00875 u_int8_t priority, u_int8_t ip_count, u_int8_t auth_type, u_int8_t advert_int,
00876 u_int16_t sum, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
00877 libnet_ptag_t ptag);
00878 
00886 libnet_ptag_t
00887 libnet_build_mpls(u_int32_t label, u_int8_t experimental, u_int8_t bos,
00888 u_int8_t ttl, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
00889 libnet_ptag_t ptag);
00890 
00898 libnet_ptag_t
00899 libnet_build_ntp(u_int8_t leap_indicator, u_int8_t version, u_int8_t mode,
00900 u_int8_t stratum, u_int8_t poll, u_int8_t precision, u_int16_t delay_int,
00901 u_int16_t delay_frac, u_int16_t dispersion_int, u_int16_t dispersion_frac,
00902 u_int32_t reference_id, u_int32_t ref_ts_int, u_int32_t ref_ts_frac,
00903 u_int32_t orig_ts_int, u_int32_t orig_ts_frac, u_int32_t rec_ts_int,
00904 u_int32_t rec_ts_frac, u_int32_t xmt_ts_int, u_int32_t xmt_ts_frac,
00905 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00906 
00914 libnet_ptag_t
00915 libnet_build_ospfv2(u_int16_t len, u_int8_t type, u_int32_t rtr_id,
00916 u_int32_t area_id, u_int16_t sum, u_int16_t autype, u_int8_t *payload,
00917 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00918 
00926 libnet_ptag_t
00927 libnet_build_ospfv2_hello(u_int32_t netmask, u_int16_t interval, u_int8_t opts,
00928 u_int8_t priority, u_int dead_int, u_int32_t des_rtr, u_int32_t bkup_rtr,
00929 u_int32_t neighbor, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
00930 libnet_ptag_t ptag);
00931  
00939 libnet_ptag_t
00940 libnet_build_ospfv2_dbd(u_int16_t dgram_len, u_int8_t opts, u_int8_t type,
00941 u_int seqnum, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
00942 libnet_ptag_t ptag);
00943  
00951 libnet_ptag_t
00952 libnet_build_ospfv2_lsr(u_int type, u_int lsid, u_int32_t advrtr,
00953 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00954  
00962 libnet_ptag_t
00963 libnet_build_ospfv2_lsu(u_int num, u_int8_t *payload, u_int32_t payload_s,
00964 libnet_t *l, libnet_ptag_t ptag);
00965 
00973 libnet_ptag_t
00974 libnet_build_ospfv2_lsa(u_int16_t age, u_int8_t opts, u_int8_t type,
00975 u_int lsid, u_int32_t advrtr, u_int seqnum, u_int16_t sum, u_int16_t len,
00976 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00977  
00985 libnet_ptag_t
00986 libnet_build_ospfv2_lsa_rtr(u_int16_t flags, u_int16_t num, u_int id,
00987 u_int data, u_int8_t type, u_int8_t tos, u_int16_t metric, u_int8_t *payload,
00988 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
00989  
00997 libnet_ptag_t
00998 libnet_build_ospfv2_lsa_net(u_int32_t nmask, u_int rtrid, u_int8_t *payload,
00999 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01000  
01008 libnet_ptag_t
01009 libnet_build_ospfv2_lsa_sum(u_int32_t nmask, u_int metric, u_int tos,
01010 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01011  
01019 libnet_ptag_t
01020 libnet_build_ospfv2_lsa_as(u_int32_t nmask, u_int metric, u_int32_t fwdaddr,
01021 u_int tag, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
01022 libnet_ptag_t ptag);
01023 
01031 libnet_ptag_t
01032 libnet_build_data(u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
01033 libnet_ptag_t ptag);
01034 
01042 libnet_ptag_t
01043 libnet_build_dhcpv4(u_int8_t opcode, u_int8_t htype, u_int8_t hlen,
01044 u_int8_t hopcount, u_int32_t xid, u_int16_t secs, u_int16_t flags,
01045 u_int32_t cip, u_int32_t yip,  u_int32_t sip, u_int32_t gip, u_int8_t *chaddr,
01046 u_int8_t *sname, u_int8_t *file, u_int8_t *payload, u_int32_t payload_s, 
01047 libnet_t *l, libnet_ptag_t ptag);
01048 
01056 libnet_ptag_t
01057 libnet_build_bootpv4(u_int8_t opcode, u_int8_t htype, u_int8_t hlen,
01058 u_int8_t hopcount, u_int32_t xid, u_int16_t secs, u_int16_t flags,
01059 u_int32_t cip, u_int32_t yip,  u_int32_t sip, u_int32_t gip, u_int8_t *chaddr,
01060 u_int8_t *sname, u_int8_t *file, u_int8_t *payload, u_int32_t payload_s, 
01061 libnet_t *l, libnet_ptag_t ptag);
01062 
01063 inline u_int32_t libnet_gre_length(u_int16_t fv);
01064 
01065 #define libnet_egre_length libnet_gre_length
01066 
01074 libnet_ptag_t
01075 libnet_build_gre(u_int16_t fv, u_int16_t type, u_int16_t checksum,
01076 u_int16_t offset, u_int32_t key, u_int32_t seq, u_int16_t len,
01077 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01078 
01079 #define libnet_build_egre libnet_build_gre
01080 
01088 libnet_ptag_t
01089 libnet_build_gre_sre(u_int16_t af, u_int8_t offset, u_int8_t length,
01090 u_int8_t *routing, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
01091 libnet_ptag_t ptag);
01092 
01100 libnet_ptag_t
01101 libnet_build_gre_last_sre(libnet_t *l, libnet_ptag_t ptag);
01102 
01110 libnet_ptag_t
01111 libnet_build_bgp4_header(u_int8_t marker[LIBNET_BGP4_MARKER_SIZE],
01112 u_int16_t len, u_int8_t type, u_int8_t *payload, u_int32_t payload_s,
01113 libnet_t *l, libnet_ptag_t ptag);
01114 
01122 libnet_ptag_t
01123 libnet_build_bgp4_open(u_int8_t version, u_int16_t src_as, u_int16_t hold_time,
01124 u_int32_t bgp_id, u_int8_t opt_len, u_int8_t *payload, u_int32_t payload_s,
01125 libnet_t *l, libnet_ptag_t ptag);
01126 
01134 libnet_ptag_t
01135 libnet_build_bgp4_update(u_int16_t unfeasible_rt_len, u_int8_t *withdrawn_rt,
01136 u_int16_t total_path_attr_len, u_int8_t *path_attributes, u_int16_t info_len,
01137 u_int8_t *reachability_info, u_int8_t *payload, u_int32_t payload_s,
01138 libnet_t *l, libnet_ptag_t ptag);
01139 
01147 libnet_ptag_t
01148 libnet_build_bgp4_notification(u_int8_t err_code, u_int8_t err_subcode,
01149 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01150 
01158 libnet_ptag_t
01159 libnet_build_link(u_int8_t *dst, u_int8_t *src, u_int16_t type, 
01160 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
01161 
01169 libnet_ptag_t
01170 libnet_autobuild_link(u_int8_t *dst, u_int16_t type, libnet_t *l);
01171 
01172 int
01173 libnet_write(libnet_t *l);
01174 
01175 int
01176 libnet_write_raw_ipv4(libnet_t *l, u_int8_t *packet, u_int32_t size);
01177 
01178 int
01179 libnet_write_raw_ipv6(libnet_t *l, u_int8_t *packet, u_int32_t size);
01180 
01181 int
01182 libnet_write_link(libnet_t *l, u_int8_t *packet, u_int32_t size);
01183 
01184 #if ((_WIN32) && !(__CYGWIN__))
01185 SOCKET
01186 libnet_open_raw4(libnet_t *l);
01187 #else
01188 int
01189 libnet_open_raw4(libnet_t *l);
01190 #endif
01191 
01192 int
01193 libnet_close_raw4(libnet_t *l);
01194 
01195 int
01196 libnet_open_raw6(libnet_t *l);
01197        
01198 int
01199 libnet_close_raw6(libnet_t *l);
01200 
01201 int
01202 libnet_select_device(libnet_t *l);
01203 
01204 int
01205 libnet_open_link(libnet_t *l);
01206 
01207 int
01208 libnet_close_link(libnet_t *l);
01209 
01210 u_int32_t
01211 libnet_get_ipaddr4(libnet_t *l);
01212 
01213 struct libnet_in6_addr
01214 libnet_get_ipaddr6(libnet_t *l);
01215 
01216 struct libnet_ether_addr *
01217 libnet_get_hwaddr(libnet_t *l);
01218 
01219 int
01220 libnet_do_checksum(libnet_t *l, u_int8_t *packet, int protocol, int len);
01221 
01222 u_int32_t
01223 libnet_compute_crc(u_int8_t *buf, u_int32_t len);
01224 
01225 u_int16_t
01226 libnet_ip_check(u_int16_t *addr, int len);
01227 
01228 int
01229 libnet_in_cksum(u_int16_t *addr, int len);
01230 
01231 
01232 /*
01233  *  libnet_pblock_probe
01234  *
01235  *  If ptag is 0, function will create a pblock for the protocol unit type,
01236  *  append it to the list and return a pointer to it.  If ptag is not 0,
01237  *  function will search the pblock list for the specified protocol block 
01238  *  and return a pointer to it.
01239  */
01240 libnet_pblock_t *
01241 libnet_pblock_probe(libnet_t *l, libnet_ptag_t ptag, u_int32_t n, 
01242 u_int8_t type);
01243 
01244 /*
01245  *  libnet_pblock_new
01246  *
01247  *  Function creates the pblock list if l->protocol_blocks == NULL or appends
01248  *  an entry to the doubly linked list.
01249  */
01250 libnet_pblock_t *
01251 libnet_pblock_new(libnet_t *l, u_int32_t size);
01252 
01253 
01254 /*
01255  *  libnet_pblock_swap
01256  *
01257  *  Function swaps two pblocks in memory.
01258  */
01259 int
01260 libnet_pblock_swap(libnet_t *l, libnet_ptag_t ptag1, libnet_ptag_t ptag2);
01261   
01262 
01263 /*
01264  *  libnet_pblock_insert_before
01265  *
01266  *  Function inserts a pblock into the doubly linked list.
01267  */
01268 int
01269 libnet_pblock_insert_before(libnet_t *l, libnet_ptag_t ptag1,
01270 libnet_ptag_t ptag2);
01271 
01272 /*
01273  *  libnet_pblock_delete
01274  *  
01275  *  Function removes a pblock from context 
01276  */
01277 void
01278 libnet_pblock_delete(libnet_t *l, libnet_pblock_t *p);
01279 
01280 /*
01281  *  libnet_pblock_update
01282  *
01283  *  Function updates the pblock meta-inforation.  Internally it updates the
01284  *  ptag with a monotonically increasing variable kept in l.  This way each
01285  *  pblock has a succesively increasing ptag identifier.
01286  */
01287 libnet_ptag_t
01288 libnet_pblock_update(libnet_t *l, libnet_pblock_t *p, u_int32_t h, 
01289 u_int8_t type);
01290 
01291 
01292 /*
01293  *  libnet_pblock_find
01294  *
01295  *  Function locates a given block by it's ptag. 
01296  */
01297 libnet_pblock_t *
01298 libnet_pblock_find(libnet_t *l, libnet_ptag_t ptag);
01299 
01300 
01301 /*
01302  *  libnet_pblock_append
01303  *
01304  *  Function copies protocol block data over.
01305  */
01306 int
01307 libnet_pblock_append(libnet_t *l, libnet_pblock_t *p, u_int8_t *buf,
01308 u_int32_t len);
01309 
01310 
01311 /*
01312  *  libnet_pblock_setflags
01313  *
01314  *  Function sets pblock flags.
01315  */
01316 void
01317 libnet_pblock_setflags(libnet_pblock_t *p, u_int8_t flags);
01318 
01319 
01320 /*
01321  *  libnet_pblock_p2p
01322  *
01323  *  Function returns the protocol number for the protocol block type.  If
01324  *  the type is unknown, the function defaults to returning IPPROTO_IP.
01325  */
01326 int
01327 libnet_pblock_p2p(u_int8_t type);
01328 
01329 
01330 /*
01331  *  libnet_pblock_coalesce
01332  *
01333  *  Function assembles the packet for subsequent writing.  Function makes two
01334  *  passes through the pblock list:
01335  *  1st & 2nd) determine total size of the packet for contiguous malloc
01336  *             and copy over packet chunks 
01337  *  3rd run) run through the original list and see which protocol blocks had
01338  *           the checksum flag set (checksums usually need to be done over
01339  *           an assembled packet so it's easier to do it here)
01340  */
01341 int
01342 libnet_pblock_coalesce(libnet_t *l, u_int8_t **packet, u_int32_t *size);
01343 
01344 
01345 /*
01346  *  __libnet_dump_context
01347  *
01348  *  Function returns the contents of the libnet file context.  Not meant for
01349  *  the applications programer.
01350  */
01351 void
01352 __libnet_dump_context(libnet_t *l);
01353 
01354 /*
01355  *  __libnet_dump_pblock
01356  *
01357  *  Function returns the contents of each pblock in a given context.  Not meant 
01358  *  for the applications programer.
01359  */
01360 void
01361 __libnet_dump_pblock(libnet_t *l);
01362 
01363 /*
01364  *  __libnet_dump_pblock_type
01365  *
01366  *  Function returns a canonical string referring to the pblock type.
01367  */
01368 int8_t *
01369 __libnet_dump_pblock_type(u_int8_t type);
01370 
01371 /*
01372  *  __libnet_hex_dump
01373  *
01374  *  Function dumps the contents of the supplied buffer to the supplied
01375  *  stream pointer.  Very useful for debugging.  Will swap endianness based
01376  *  disposition of mode variable.  Use requires unwrapping the libnet file
01377  *  context structure so it's hidden down here.  If you find it, consider
01378  *  yourself a trepid adventurer.
01379  */
01380 void
01381 __libnet_dump_hex(u_int8_t *packet, u_int32_t len, int swap, FILE *stream);
01382 
01383 
01384 /*
01385  *  libnet_hex_aton
01386  *
01387  *  hexidecimal strings of the format "##:##:##:## ... :##:##" to a uint8_t.
01388  *
01389  */
01390 u_int8_t *
01391 libnet_hex_aton(int8_t *s, int *len);
01392 
01393 /*
01394  *  libnet_adv_cull_packet
01395  *
01396  *  advanced interface, culls the packet from inside libnet, wraps
01397  *  libnet_pblock_coalesce().
01398  *
01399  */
01400 int
01401 libnet_adv_cull_packet(libnet_t *l, u_int8_t **packet, u_int32_t *packet_s);
01402 
01403 /*
01404  *  libnet_adv_cull_header
01405  *
01406  *  advanced interface, culls the header from referenced ptag from inside
01407  *  libnet.
01408  *
01409  */
01410 int
01411 libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, u_int8_t **header,
01412 u_int32_t *header_s);
01413 
01414 /*
01415  *  libnet_adv_write_link
01416  *
01417  *  advanced interface, writes a prebuilt frame to the wire
01418  *
01419  */
01420 int
01421 libnet_adv_write_link(libnet_t *l, u_int8_t *packet, u_int32_t packet_s);
01422 
01423 /*
01424  *  libnet_cq_add
01425  *  
01426  *  Function adds a context to the libnet context queue.
01427  */
01428 int 
01429 libnet_cq_add(libnet_t *l, char *label);
01430 
01431 /*
01432  *  libnet_cq_remove
01433  *
01434  *  Function removes a context from the libnet context queue.
01435  *
01436  */
01437 int
01438 libnet_cq_remove(libnet_t *l);
01439 
01440 /* 
01441  *  libnet_cq_remove_by_label
01442  *
01443  *  Function removes a libnet context from the queue, indexed by it's
01444  *  canonical label.
01445  */   
01446 int
01447 libnet_cq_remove_by_label(char *label);
01448  
01449 /* 
01450  *  libnet_cq_getlabel
01451  *
01452  *  Function returns the label (if any) associated with the context.
01453  */   
01454 int8_t *
01455 libnet_cq_getlabel(libnet_t *l);
01456  
01457 /* 
01458  * libnet_cq_find_by_label
01459  * 
01460  *  Function locates a libnet context from the queue, indexed by it's
01461  *  canonical label.
01462  *
01463  */
01464 libnet_t *
01465 libnet_cq_find_by_label(char *label);
01466   
01467 /* 
01468  *  libnet_cq_destroy
01469  * 
01470  *  Function destroys the entire context queue, calling libnet_destory() on
01471  *  each member context.
01472  */
01473 void libnet_cq_destroy();
01474 
01475 /*
01476  *  libnet_cq_head
01477  *
01478  *  Function intiailizes the interator interface and sets a write lock on
01479  *  the context queue.
01480  */
01481 libnet_t *
01482 libnet_cq_head();
01483 
01484 /*
01485  *  libnet_cq_head
01486  *
01487  *  Function returns 1 if at the end of the context queue, 0 otherwise.
01488  */
01489 int
01490 libnet_cq_last();
01491 
01492 /*
01493  *  libnet_cq_head
01494  *
01495  *  Function returns the next context from the context queue.
01496  */
01497 libnet_t *
01498 libnet_cq_next();
01499 
01500 /*
01501  *  libnet_cq_size
01502  *
01503  *  Function returns the number of entries in the context queue.
01504  */
01505 u_int32_t
01506 libnet_cq_size();
01507 
01508 #if defined(__WIN32__)
01509 BYTE *
01510 libnet_win32_get_remote_mac(libnet_t *l, DWORD IP);
01511 int
01512 libnet_close_link_interface(libnet_t *l);
01513 BYTE * 
01514 libnet_win32_read_arp_table(DWORD IP);
01515 #endif
01516 #endif  /* __LIBNET_FUNCTIONS_H */
01517 
01518 /* EOF */

Generated on Wed Nov 12 09:57:54 2003 for libnet by doxygen 1.3.2