⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libnet-functions.h

📁 Libnet is a generic networking API that provides access to several protocols. It is not designed as
💻 H
📖 第 1 页 / 共 4 页
字号:
/*
 *  $Id: libnet-functions.h,v 1.1.1.1 2002/09/16 12:58:05 robertol Exp $
 *
 *  libnet-functions.h - function prototypes
 *
 *  Copyright (c) 1998 - 2002 Mike D. Schiffman <mike@infonexus.com>
 *  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

#ifndef __LIBNET_FUNCTIONS_H
#define __LIBNET_FUNCTIONS_H

/*
 *  libnet_init
 *
 *  Function initializes the library for use.  It allocates memory for the
 *  monolithic control structure and sets various bits of state in the
 *  library.  The resulting file context l is passed to nearly every function
 *  in libnet.
 */
libnet_t *              /* libnet file context or NULL on error */
libnet_init(
    int,                /* packet injection_type (raw, raw6, or link) */
    char *,             /* device (for link only NULL for libnet to choose) */
    char *              /* error buffer */
    );


/*
 *  libnet_destroy
 *
 *  Function is a decontructor for libnet.  Should be called at the end of
 *  program or when a fatal error occurs.
 */
void
libnet_destroy(
    libnet_t *          /* libnet context pointer */
    );


/*
 *  libnet_clear_packet
 *
 *  Function clears the current packet that has been assembled and frees
 *  the memory associated.  Should be called when you want to build and
 *  send packet of a different type.
 */
void
libnet_clear_packet(
    libnet_t *          /* libnet context pointer */
    );


/*
 *  libnet_stats
 *
 *  Function fills in a libnet_stats structure with the statisics for the
 *  supplied libnet context.
 */
void
libnet_stats(
    libnet_t *,         /* libnet context pointer */
    struct libnet_stats * /* libnet statistics pointer */
    );


/*
 *  libnet_getfd
 *
 *  Function returns the FILENO of the file descriptor used for packet
 *  injection.
 */
int                     /* FILENO of the fd */
libnet_getfd(
    libnet_t *          /* libnet context pointer */
    );


/*
 *  libnet_getdevice
 *
 *  Function returns the device name used for packet injection.
 */
char *                  /* device name */
libnet_getdevice(
    libnet_t *          /* libnet context pointer */
    );


/*
 *  libnet_getpbuf
 *
 *  Function returns the pblock buffer for the specified ptag.
 */
u_char *                /* the pblock buffer or NULL on error */
libnet_getpbuf(
    libnet_t *,         /* libnet context pointer */
    libnet_ptag_t       /* pblock to return information on */
    );


/*
 *  libnet_getpbuf_size
 *
 *  Function returns the pblock buffer size for the specified ptag.
 */
u_long                  /* size of the pblock buffer or 0 on error */
libnet_getpbuf_size(
    libnet_t *,         /* libnet context pointer */
    libnet_ptag_t       /* pblock to return information on */
    );


/*
 *  libnet_geterror
 *
 *  Function returns the last error string set inside of l.
 */
char *                  /* the error string (could be NULL) */
libnet_geterror(
    libnet_t *          /* libnet context pointer */
    );


/*
 *  libnet_seed_prand
 *
 *  Function seeds the psuedo-random number generator.
 */
int                     /* 1 on success, -1 on failure */
libnet_seed_prand(
    libnet_t *          /* libnet context pointer */
    );


/*
 *  libnet_get_prand
 *
 *  Function returns a psuedo-random integer of the range specified by the
 *  modulous.
 */
u_long                  /* the psuedo-random integer */
libnet_get_prand(
    int                 /* One of the PR* constants */
    );


/*
 *  libnet_toggle_checksum
 *
 *  Function switches the checksum on or off.  If off, libnet will NOT
 *  calculate a checksum for this protocol block, if on libnet WILL calculate
 *  a checksum for this protocol block assuming it has a checksum field.
 */
int
libnet_toggle_checksum(
    libnet_t *,         /* libnet context pointer */
    libnet_ptag_t,      /* pblock to toggle checksum flag on */
    int                 /* 1 == on, 0 == off */
    );


/*
 *  libnet_addr2name4
 *
 *  Function takes a network byte ordered IPv4 address and returns the
 *  DNS name for it (if it has one) or a string of dotted decimals.  This 
 *  may incur a DNS lookup (set mode to 0 to not do the lookup).
 *  XXX - This function is not-reentrant.
 */
u_char *                /* pointer to hostname or dotted decimal IP address */
libnet_addr2name4(
    u_long,             /* network byte ordered (big endian) IP address */
    u_short             /* use domain names or no */
    );


/*
 *  libnet_addr2name4_r
 *
 *  Function takes a network byte ordered IPv4 address and returns the
 *  DNS name for it (if it has one) or a string of dotted decimals.  This 
 *  may incur a DNS lookup (set mode to 0 to not do the lookup).
 */
void
libnet_addr2name4_r(
    u_long,             /* network byte ordered (big endian) IP address */
    u_short,            /* use domain names or no */
    u_char *,           /* pointer to hostname or dotted decimal IP address */
    int                 /* size of the hostname buffer passed in */
    );

/*
 *  libnet_name2addr4
 *
 *  Function takes a dotted decimal string or hostname and returns a big
 *  endian IPv4 address.  This may incur a DNS lookup (set mode to 0 to 
 *  not do the lookup).
 */
u_long                  /* network byte ordered IP address or -1 on error */
libnet_name2addr4(
    libnet_t *,         /* libnet context pointer */
    u_char *,           /* pointer the hostname or dotted decimal IP address */
    u_short             /* use domain names or no */
    );

/*
 *  libnet_name2addr6_r
 */
void
libnet_addr2name6_r(
    struct libnet_in6_addr addr, /* IPv6 address to convert */
    u_short,            /* use domain names or no */
    u_char *,           /* pointer to hostname or dotted decimal IP address */
    int                 /* size of the hostname buffer passed in */
    );

/*
 *  libnet_name2addr6
 *
 */ 
extern const struct libnet_in6_addr in6addr_error;
struct libnet_in6_addr  /* network byte ordered IP address */
libnet_name2addr6(
    libnet_t *,         /* libnet handle pointer */
    u_char *,           /* pointer the hostname or dotted decimal IP address */
    u_short             /* use domain names or no */
    );


/*
 *  libnet_plist_chain_new
 *
 *  Function creates a new port list list.  The token list should be a
 *  character string containing along the lines of the following: "xx-yy,z"
 */
int                     /* 1 on success, -1 on failure */
libnet_plist_chain_new(
    libnet_t *,         /* libnet context pointer */
    libnet_plist_t **,  /* pointer to the head of the list */
    char *              /* token list pointer */
    );


/*
 *  libnet_plist_chain_next_pair
 *
 *  Function returns the next pair of port list numbers, from beginning
 *  to end.  If there is only one port number, bport will == eport.
 */
int                     /* 1 if more nodes, 0 if not */
libnet_plist_chain_next_pair(
    libnet_plist_t *,   /* pointer to the head of the list */
    u_short *,          /* holds bport */
    u_short *           /* holds eport */
    );


/*
 *  libnet_plist_chain_next_dump
 *
 *  Function dumps the port list list to stdout.
 */
int                     /* 1 on success, -1 on failure (if !p) */
libnet_plist_chain_dump(
    libnet_plist_t *    /* pointer to the head of the list */
    );


/*
 *  libnet_plist_chain_dump_string
 *
 *  Function returns the port list list as a string.
 *  XXX - This function is not-reentrant.
 */
u_char *                /* the port list string on success, NULL on failure */
libnet_plist_chain_dump_string(
    libnet_plist_t *    /* pointer to the head of the list */
    );


/*
 *  libnet_plist_chain_free
 *
 *  Function destroys the list and frees memory.
 */
int
libnet_plist_chain_free(
    libnet_plist_t *    /* pointer to the head of the list */
    );


/*
 *  libnet_build_802_1q
 *
 *  Function builds an 802.1q header.
 */
libnet_ptag_t           /* packet id on success, -1 on failure */
libnet_build_802_1q(
    u_char *,           /* pointer to a 6 byte ethernet address */
    u_char *,           /* pointer to a 6 byte ethernet address */
    u_short,            /* tag protocol ID */
    u_char,             /* priority */
    u_char,             /* canonical format indicator */
    u_short,            /* vid */
    u_short,            /* length or protocol (802.3 / ethernet II) */
    u_char *,           /* payload (or NULL) */
    u_long,             /* payload length */
    libnet_t *,         /* libnet context pointer */
    libnet_ptag_t       /* packet id */
    );


/*
 *  libnet_build_802_2
 *
 *  Function builds an 802.2 LLC header.
 */
libnet_ptag_t           /* packet id on success, -1 on failure */
libnet_build_802_2(
    u_char,             /* DSAP */
    u_char,             /* SSAP */
    u_char,             /* control */
    u_char *,           /* payload (or NULL) */
    u_long,             /* payload length */
    libnet_t *,         /* libnet context pointer */
    libnet_ptag_t       /* packet id */
    );


/*
 *  libnet_build_802_2snap
 *
 *  Function builds an 802.2 LLC/SNAP header.
 */
libnet_ptag_t           /* packet id on success, -1 on failure */
libnet_build_802_2snap(
    u_char,             /* DSAP */
    u_char,             /* SSAP */
    u_char,             /* control */
    u_char *,           /* OUI */
    u_short,            /* type */
    u_char *,           /* payload (or NULL) */
    u_long,             /* payload length */
    libnet_t *,         /* libnet context pointer */
    libnet_ptag_t       /* packet id */
    );


/*
 *  libnet_build_802.3
 *
 *  Function builds an 802.3 header.
 */
libnet_ptag_t           /* packet id on success, -1 on failure */
libnet_build_802_3(
    u_char *,           /* pointer to a 6 byte ethernet address */
    u_char *,           /* pointer to a 6 byte ethernet address */
    u_short,            /* length */
    u_char *,           /* payload (or NULL) */
    u_long,             /* payload length */
    libnet_t *,         /* libnet context pointer */
    libnet_ptag_t       /* packet id */
    );

/*
 *  libnet_build_802.5
 *
 *  Function builds an 802.5 header.
 */
libnet_ptag_t           /* packet id on success, -1 on failure */
libnet_build_802_5(
    u_char *,           /* pointer to a 6 byte ethernet address */
    u_char *,           /* pointer to a 6 byte ethernet address */
    u_short,            /* type */
    u_char *,           /* payload (or NULL) */
    u_long,             /* payload length */
    libnet_t *,         /* libnet context pointer */
    libnet_ptag_t       /* packet id */
    );

/*
 *  libnet_build_ethernet
 *
 *  Function builds an Ethernet header.
 */
libnet_ptag_t           /* packet id on success, -1 on failure */
libnet_build_ethernet(
    u_char *,           /* pointer to a 6 byte ethernet address */
    u_char *,           /* pointer to a 6 byte ethernet address */
    u_short,            /* type */
    u_char *,           /* payload (or NULL) */
    u_long,             /* payload length */
    libnet_t *,         /* libnet context pointer */
    libnet_ptag_t       /* packet id */
    );


/*
 *  libnet_autobuild_ethernet
 *
 *  Function builds an Ethernet header, automating the process.
 */
libnet_ptag_t           /* packet id on success, -1 on failure */
libnet_autobuild_ethernet(
    u_char *,           /* pointer to a 6 byte ethernet address */
    u_short,            /* packet type */
    libnet_t *          /* libnet context pointer */
    );

/*
 *  libnet_build_token (function suggested by Roberto Larcher)
 *
 *  Function builds an Token Ring header.
 */
libnet_ptag_t           /* packet id on success, -1 on failure */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -