📄 libnet-functions.h
字号:
/*
* $Id: libnet-functions.h,v 1.1 2001/08/07 13:15:12 fygrave Exp $
*
* libnet-functions.h - Network routine library function prototype header file
*
* Copyright (c) 1998, 1999, 2000 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
int /* 1 if good, -1 if bad */
libnet_plist_chain_new(
struct libnet_plist_chain **, /* pointer to the head of the list */
char * /* token list pointer */
);
int /* 1 if more nodes, 0 if not */
libnet_plist_chain_next_pair(
struct libnet_plist_chain *, /* pointer to the head of the list */
u_short *bport, /* holds bport */
u_short *eport /* holds eport */
);
int
libnet_plist_chain_dump(
struct libnet_plist_chain * /* pointer to the head of the list */
);
u_char *
libnet_plist_chain_dump_string(
struct libnet_plist_chain * /* pointer to the head of the list */
);
int
libnet_plist_chain_free(
struct libnet_plist_chain * /* pointer to the head of the list */
);
/*
* Standard error handling code.
*/
void
libnet_error(
int, /* severity */
char *, /* error message */
... /* varargs */
);
/*
* Seeds the pseudorandom number generator with gettimeofday.
*/
int
libnet_seed_prand();
/*
* Returns a psuedorandom positive integer.
*/
u_long
libnet_get_prand(
int /* One of the PR* constants */
);
/*
* Calculates IPv4 family checksum on packet headers.
*/
int /* 1 on success, -1 on failure */
libnet_do_checksum(
u_char *, /* Pointer to the packet buffer */
int, /* Protocol */
int /* Packet size */
);
/*
* Network byte order into IP address
* Previous versions had a memory leak (returned a strdup'd pointer -- strdup
* has an implicit malloc which wasn't getting freed). This static var hack
* thingy was used to preserve existing code without having to change much.
* You can simply use the return value of the function directly allowing you
* to write tighter, more obvious code (rather then having to do allocate an
* additional buffer for the output).
* Thanks to Red for the idea.
*/
u_char * /* Pointer to hostname or dotted decimal IP address */
libnet_host_lookup(
u_long, /* Network byte ordered (big endian) IP address */
u_short /* Use domain names or no */
);
/*
* Network byte order into IP address
* Threadsafe version.
*/
void
libnet_host_lookup_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 */
);
/*
* IP address into network byte order
*/
u_long /* Network byte ordered IP address or -1 on error */
libnet_name_resolve(
u_char *, /* Pointer the hostname or dotted decimal IP address */
u_short /* Use domain names or no */
);
/*
* IP checksum wrapper.
*/
u_short /* Standard IP checksum of header and data */
libnet_ip_check(
u_short *, /* Pointer to the buffer to be summed */
int /* Packet length */
);
/*
* IP checksum.
*/
int /* Standard IP checksum */
libnet_in_cksum(
u_short *, /* Pointer to the buffer to be summed */
int /* Packet length */
);
/*
* Opens a socket for writing raw IP datagrams to. Set IP_HDRINCL to let the
* kernel know we've got it all under control.
*/
int /* Opened file desciptor, or -1 on error */
libnet_open_raw_sock(
int /* Protocol of raw socket (from /etc/protocols) */
);
int /* 1 upon success, or -1 on error */
libnet_close_raw_sock(
int /* File descriptor */
);
int
libnet_select_device(
struct sockaddr_in *sin,
u_char **device,
u_char *ebuf
);
/*
* Ethernet packet assembler.
*/
int /* -1 on failure (null buf passed in), 1 on success */
libnet_build_ethernet(
u_char *, /* Pointer to a 6 byte ethernet address */
u_char *, /* Pointer to a 6 byte ethernet address */
u_short, /* Packet IP type */
const u_char *, /* Payload (or NULL) */
int, /* Payload size */
u_char * /* Packet header buffer */
);
/*
* ARP packet assembler.
*/
int /* -1 on failure (null buf passed in), 1 on success */
libnet_build_arp(
u_short, /* hardware address type */
u_short, /* protocol address type */
u_char, /* hardware address length */
u_char, /* protocol address length */
u_short, /* ARP operation type */
u_char *, /* sender hardware address */
u_char *, /* sender protocol address */
u_char *, /* target hardware address */
u_char *, /* target protocol address */
const u_char *, /* payload or NULL if none */
int, /* payload length */
u_char * /* packet buffer memory */
);
/*
* TCP packet assembler.
*/
int /* -1 on failure (null buf passed in), 1 on success */
libnet_build_tcp(
u_short, /* Source port */
u_short, /* Destination port */
u_long, /* Sequence Number */
u_long, /* Acknowledgement Number */
u_char, /* Control bits */
u_short, /* Advertised Window Size */
u_short, /* Urgent Pointer */
const u_char *, /* Pointer to packet data (or NULL) */
int, /* Packet payload size */
u_char * /* Pointer to packet header memory */
);
/*
* UDP packet assembler.
*/
int /* -1 on failure (null buf passed in), 1 on success */
libnet_build_udp(
u_short, /* Source port */
u_short, /* Destination port */
const u_char *, /* Pointer to packet data (or NULL) */
int, /* Packet payload size */
u_char * /* Pointer to packet header memory */
);
/*
* ICMP_ECHO packet assembler.
*/
int /* -1 on failure (null buf passed in), 1 on success */
libnet_build_icmp_echo(
u_char, /* icmp type */
u_char, /* icmp code */
u_short, /* id */
u_short, /* sequence number */
const u_char *, /* Pointer to packet data (or NULL) */
int, /* Packet payload size */
u_char * /* Pointer to packet header memory */
);
/*
* ICMP_MASK packet assembler.
*/
int /* -1 on failure (null buf passed in), 1 on success */
libnet_build_icmp_mask(
u_char, /* icmp type */
u_char, /* icmp code */
u_short, /* id */
u_short, /* sequence number */
u_long, /* address mask */
const u_char *, /* Pointer to packet data (or NULL) */
int, /* Packet payload size */
u_char * /* Pointer to packet header memory */
);
/*
* ICMP_UNREACH packet assembler.
*/
int /* -1 on failure (null buf passed in), 1 on success */
libnet_build_icmp_unreach(
u_char, /* icmp type */
u_char, /* icmp code */
u_short, /* Original Length of packet data */
u_char, /* Original IP tos */
u_short, /* Original IP ID */
u_short, /* Original Fragmentation flags and offset */
u_char, /* Original TTL */
u_char, /* Original Protocol */
u_long, /* Original Source IP Address */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -