openflow build environment setup
This commit is contained in:
255
openflow/include/libnet/libnet-asn1.h
Normal file
255
openflow/include/libnet/libnet-asn1.h
Normal file
@ -0,0 +1,255 @@
|
||||
/*
|
||||
* $Id: libnet-asn1.h,v 1.3 2004/01/17 07:51:19 mike Exp $
|
||||
*
|
||||
* libnet-asn1.h - Network routine library ASN.1 header file
|
||||
*
|
||||
* Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Definitions for Abstract Syntax Notation One, ASN.1
|
||||
* As defined in ISO/IS 8824 and ISO/IS 8825
|
||||
*
|
||||
* Copyright 1988, 1989 by Carnegie Mellon University
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and that
|
||||
* both that copyright notice and this permission notice appear in
|
||||
* supporting documentation, and that the name of CMU not be
|
||||
* used in advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
*
|
||||
* CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
* CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Copyright (c) 1998 - 2001 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_ASN1_H
|
||||
#define __LIBNET_ASN1_H
|
||||
|
||||
#ifndef EIGHTBIT_SUBIDS
|
||||
typedef uint32_t oid;
|
||||
#define MAX_SUBID 0xFFFFFFFF
|
||||
#else
|
||||
typedef uint8_t oid;
|
||||
#define MAX_SUBID 0xFF
|
||||
#endif
|
||||
|
||||
#define MAX_OID_LEN 64 /* max subid's in an oid */
|
||||
|
||||
#define ASN_BOOLEAN (0x01)
|
||||
#define ASN_INTEGER (0x02)
|
||||
#define ASN_BIT_STR (0x03)
|
||||
#define ASN_OCTET_STR (0x04)
|
||||
#define ASN_NULL (0x05)
|
||||
#define ASN_OBJECT_ID (0x06)
|
||||
#define ASN_SEQUENCE (0x10)
|
||||
#define ASN_SET (0x11)
|
||||
|
||||
#define ASN_UNIVERSAL (0x00)
|
||||
#define ASN_APPLICATION (0x40)
|
||||
#define ASN_CONTEXT (0x80)
|
||||
#define ASN_PRIVATE (0xC0)
|
||||
|
||||
#define ASN_PRIMITIVE (0x00)
|
||||
#define ASN_CONSTRUCTOR (0x20)
|
||||
|
||||
#define ASN_LONG_LEN (0x80)
|
||||
#define ASN_EXTENSION_ID (0x1F)
|
||||
#define ASN_BIT8 (0x80)
|
||||
|
||||
#define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR)
|
||||
#define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) = ASN_EXTENSION_ID)
|
||||
|
||||
/*
|
||||
* All of the build_asn1_* (build_asn1_length being an exception) functions
|
||||
* take the same first 3 arguments:
|
||||
*
|
||||
* uint8_t *data: This is a pointer to the start of the data object to be
|
||||
* manipulated.
|
||||
* int *datalen: This is a pointer to the number of valid bytes following
|
||||
* "data". This should be not be exceeded in any function.
|
||||
* Upon exiting a function, this value will reflect the
|
||||
* changed "data" and then refer to the new number of valid
|
||||
* bytes until the end of "data".
|
||||
* uint8_t type: The ASN.1 object type.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Builds an ASN object containing an integer.
|
||||
*
|
||||
* Returns NULL upon error or a pointer to the first byte past the end of
|
||||
* this object (the start of the next object).
|
||||
*/
|
||||
|
||||
uint8_t *
|
||||
libnet_build_asn1_int(
|
||||
uint8_t *, /* Pointer to the output buffer */
|
||||
int *, /* Number of valid bytes left in the buffer */
|
||||
uint8_t, /* ASN object type */
|
||||
int32_t *, /* Pointer to a int32_t integer */
|
||||
int /* Size of a int32_t integer */
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Builds an ASN object containing an unsigned integer.
|
||||
*
|
||||
* Returns NULL upon error or a pointer to the first byte past the end of
|
||||
* this object (the start of the next object).
|
||||
*/
|
||||
|
||||
uint8_t *
|
||||
libnet_build_asn1_uint(
|
||||
uint8_t *, /* Pointer to the output buffer */
|
||||
int *, /* Number of valid bytes left in the buffer */
|
||||
uint8_t, /* ASN object type */
|
||||
uint32_t *, /* Pointer to an unsigned int32_t integer */
|
||||
int /* Size of a int32_t integer */
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Builds an ASN object containing an octect string.
|
||||
*
|
||||
* Returns NULL upon error or a pointer to the first byte past the end of
|
||||
* this object (the start of the next object).
|
||||
*/
|
||||
|
||||
uint8_t *
|
||||
libnet_build_asn1_string(
|
||||
uint8_t *, /* Pointer to the output buffer */
|
||||
int *, /* Number of valid bytes left in the buffer */
|
||||
uint8_t, /* ASN object type */
|
||||
uint8_t *, /* Pointer to a string to be built into an object */
|
||||
int /* Size of the string */
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Builds an ASN header for an object with the ID and length specified. This
|
||||
* only works on data types < 30, i.e. no extension octets. The maximum
|
||||
* length is 0xFFFF;
|
||||
*
|
||||
* Returns a pointer to the first byte of the contents of this object or
|
||||
* NULL upon error
|
||||
*/
|
||||
|
||||
uint8_t *
|
||||
libnet_build_asn1_header(
|
||||
uint8_t *, /* Pointer to the start of the object */
|
||||
int *, /* Number of valid bytes left in buffer */
|
||||
uint8_t, /* ASN object type */
|
||||
int /* ASN object length */
|
||||
);
|
||||
|
||||
|
||||
uint8_t *
|
||||
libnet_build_asn1_length(
|
||||
uint8_t *, /* Pointer to start of object */
|
||||
int *, /* Number of valid bytes in buffer */
|
||||
int /* Length of object */
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Builds an ASN header for a sequence with the ID and length specified.
|
||||
*
|
||||
* This only works on data types < 30, i.e. no extension octets.
|
||||
* The maximum length is 0xFFFF;
|
||||
*
|
||||
* Returns a pointer to the first byte of the contents of this object.
|
||||
* Returns NULL on any error.
|
||||
*/
|
||||
|
||||
uint8_t *
|
||||
libnet_build_asn1_sequence(
|
||||
uint8_t *,
|
||||
int *,
|
||||
uint8_t,
|
||||
int
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Builds an ASN object identifier object containing the input string.
|
||||
*
|
||||
* Returns NULL upon error or a pointer to the first byte past the end of
|
||||
* this object (the start of the next object).
|
||||
*/
|
||||
|
||||
uint8_t *
|
||||
libnet_build_asn1_objid(
|
||||
uint8_t *,
|
||||
int *,
|
||||
uint8_t,
|
||||
oid *,
|
||||
int
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Builds an ASN null object.
|
||||
*
|
||||
* Returns NULL upon error or a pointer to the first byte past the end of
|
||||
* this object (the start of the next object).
|
||||
*/
|
||||
|
||||
uint8_t *
|
||||
libnet_build_asn1_null(
|
||||
uint8_t *,
|
||||
int *,
|
||||
uint8_t
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Builds an ASN bitstring.
|
||||
*
|
||||
* Returns NULL upon error or a pointer to the first byte past the end of
|
||||
* this object (the start of the next object).
|
||||
*/
|
||||
|
||||
uint8_t *
|
||||
libnet_build_asn1_bitstring(
|
||||
uint8_t *,
|
||||
int *,
|
||||
uint8_t,
|
||||
uint8_t *, /* Pointer to the input buffer */
|
||||
int /* Length of the input buffer */
|
||||
);
|
||||
|
||||
|
||||
#endif /* __LIBNET_ASN1_H */
|
||||
|
||||
/* EOF */
|
||||
2403
openflow/include/libnet/libnet-functions.h
Normal file
2403
openflow/include/libnet/libnet-functions.h
Normal file
File diff suppressed because it is too large
Load Diff
1826
openflow/include/libnet/libnet-headers.h
Normal file
1826
openflow/include/libnet/libnet-headers.h
Normal file
File diff suppressed because it is too large
Load Diff
204
openflow/include/libnet/libnet-macros.h
Normal file
204
openflow/include/libnet/libnet-macros.h
Normal file
@ -0,0 +1,204 @@
|
||||
/*
|
||||
* $Id: libnet-macros.h,v 1.7 2004/04/13 17:32:28 mike Exp $
|
||||
*
|
||||
* libnet-macros.h - Network routine library macro header file
|
||||
*
|
||||
* Copyright (c) 1998 - 2004 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_MACROS_H
|
||||
#define __LIBNET_MACROS_H
|
||||
/**
|
||||
* @file libnet-macros.h
|
||||
* @brief libnet macros and symbolic constants
|
||||
*/
|
||||
|
||||
/* for systems without snprintf */
|
||||
#if defined(NO_SNPRINTF)
|
||||
#define snprintf(buf, len, args...) sprintf(buf, ##args)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Used for libnet's name resolution functions, specifies that no DNS lookups
|
||||
* should be performed and the IP address should be kept in numeric form.
|
||||
*/
|
||||
#define LIBNET_DONT_RESOLVE 0
|
||||
|
||||
/**
|
||||
* Used for libnet's name resolution functions, specifies that a DNS lookup
|
||||
* can be performed if needed to resolve the IP address to a canonical form.
|
||||
*/
|
||||
#define LIBNET_RESOLVE 1
|
||||
|
||||
/**
|
||||
* Used several places, to specify "on" or "one"
|
||||
*/
|
||||
#define LIBNET_ON 0
|
||||
|
||||
/**
|
||||
* Used several places, to specify "on" or "one"
|
||||
*/
|
||||
#define LIBNET_OFF 1
|
||||
|
||||
/**
|
||||
* IPv6 error code
|
||||
*/
|
||||
#ifndef IN6ADDR_ERROR_INIT
|
||||
#define IN6ADDR_ERROR_INIT { { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
|
||||
0xff, 0xff } } }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Used for libnet_get_prand() to specify function disposition
|
||||
*/
|
||||
#define LIBNET_PR2 0
|
||||
#define LIBNET_PR8 1
|
||||
#define LIBNET_PR16 2
|
||||
#define LIBNET_PRu16 3
|
||||
#define LIBNET_PR32 4
|
||||
#define LIBNET_PRu32 5
|
||||
#define LIBNET_PRAND_MAX 0xffffffff
|
||||
|
||||
/**
|
||||
* The biggest an IP packet can be -- 65,535 bytes.
|
||||
*/
|
||||
#define LIBNET_MAX_PACKET 0xffff
|
||||
#ifndef IP_MAXPACKET
|
||||
#define IP_MAXPACKET 0xffff
|
||||
#endif
|
||||
|
||||
|
||||
/* ethernet addresses are 6 octets long */
|
||||
#ifndef ETHER_ADDR_LEN
|
||||
#define ETHER_ADDR_LEN 0x6
|
||||
#endif
|
||||
|
||||
/* FDDI addresses are 6 octets long */
|
||||
#ifndef FDDI_ADDR_LEN
|
||||
#define FDDI_ADDR_LEN 0x6
|
||||
#endif
|
||||
|
||||
/* token ring addresses are 6 octets long */
|
||||
#ifndef TOKEN_RING_ADDR_LEN
|
||||
#define TOKEN_RING_ADDR_LEN 0x6
|
||||
#endif
|
||||
|
||||
/* LLC Organization Code is 3 bytes long */
|
||||
#define LIBNET_ORG_CODE_SIZE 0x3
|
||||
|
||||
/**
|
||||
* The libnet error buffer is 256 bytes long.
|
||||
*/
|
||||
#define LIBNET_ERRBUF_SIZE 0x100
|
||||
|
||||
/**
|
||||
* IP and TCP options can be up to 40 bytes long.
|
||||
*/
|
||||
#define LIBNET_MAXOPTION_SIZE 0x28
|
||||
|
||||
/* some BSD variants have this endianess problem */
|
||||
#if (LIBNET_BSD_BYTE_SWAP)
|
||||
#define FIX(n) ntohs(n)
|
||||
#define UNFIX(n) htons(n)
|
||||
#else
|
||||
#define FIX(n) (n)
|
||||
#define UNFIX(n) (n)
|
||||
#endif
|
||||
|
||||
/* used internally for packet builders */
|
||||
#define LIBNET_DO_PAYLOAD(l, p) \
|
||||
if (payload_s && !payload) \
|
||||
{ \
|
||||
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, \
|
||||
"%s(): payload inconsistency\n", __func__); \
|
||||
goto bad; \
|
||||
} \
|
||||
if (payload_s) \
|
||||
{ \
|
||||
n = libnet_pblock_append(l, p, payload, payload_s); \
|
||||
if (n == (uint32_t) - 1) \
|
||||
{ \
|
||||
goto bad; \
|
||||
} \
|
||||
} \
|
||||
|
||||
|
||||
/* used internally for checksum stuff */
|
||||
#define LIBNET_CKSUM_CARRY(x) \
|
||||
(x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff))
|
||||
|
||||
/* used interally for OSPF stuff */
|
||||
#define LIBNET_OSPF_AUTHCPY(x, y) \
|
||||
memcpy((uint8_t *)x, (uint8_t *)y, sizeof(y))
|
||||
#define LIBNET_OSPF_CKSUMBUF(x, y) \
|
||||
memcpy((uint8_t *)x, (uint8_t *)y, sizeof(y))
|
||||
|
||||
/* used internally for NTP leap indicator, version, and mode */
|
||||
#define LIBNET_NTP_DO_LI_VN_MODE(li, vn, md) \
|
||||
((uint8_t)((((li) << 6) & 0xc0) | (((vn) << 3) & 0x38) | ((md) & 0x7)))
|
||||
|
||||
/* Not all systems have IFF_LOOPBACK */
|
||||
#ifdef IFF_LOOPBACK
|
||||
#define LIBNET_ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK)
|
||||
#else
|
||||
#define LIBNET_ISLOOPBACK(p) (strcmp((p)->ifr_name, "lo") == 0)
|
||||
#endif
|
||||
|
||||
/* advanced mode check */
|
||||
#define LIBNET_ISADVMODE(x) (x & 0x08)
|
||||
|
||||
/* context queue macros and constants */
|
||||
#define LIBNET_LABEL_SIZE 64
|
||||
#define LIBNET_LABEL_DEFAULT "cardshark"
|
||||
#define CQ_LOCK_UNLOCKED (u_int)0x00000000
|
||||
#define CQ_LOCK_READ (u_int)0x00000001
|
||||
#define CQ_LOCK_WRITE (u_int)0x00000002
|
||||
|
||||
/**
|
||||
* Provides an interface to iterate through the context queue of libnet
|
||||
* contexts. Before calling this macro, be sure to set the queue using
|
||||
* libnet_cq_head().
|
||||
*/
|
||||
#define for_each_context_in_cq(l) \
|
||||
for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next())
|
||||
|
||||
/* return 1 if write lock is set on cq */
|
||||
#define cq_is_wlocked() (l_cqd.cq_lock & CQ_LOCK_WRITE)
|
||||
|
||||
/* return 1 if read lock is set on cq */
|
||||
#define cq_is_rlocked() (l_cqd.cq_lock & CQ_LOCK_READ)
|
||||
|
||||
/* return 1 if any lock is set on cq */
|
||||
#define cq_is_locked() (l_cqd.cq_lock & (CQ_LOCK_READ | CQ_LOCK_WRITE))
|
||||
|
||||
/* check if a context queue is locked */
|
||||
#define check_cq_lock(x) (l_cqd.cq_lock & x)
|
||||
|
||||
#endif /* __LIBNET_MACROS_H */
|
||||
|
||||
/* EOF */
|
||||
260
openflow/include/libnet/libnet-structures.h
Normal file
260
openflow/include/libnet/libnet-structures.h
Normal file
@ -0,0 +1,260 @@
|
||||
/*
|
||||
* $Id: libnet-structures.h,v 1.19 2004/11/09 07:05:07 mike Exp $
|
||||
*
|
||||
* libnet-structures.h - Network routine library structures header file
|
||||
*
|
||||
* Copyright (c) 1998 - 2004 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_STRUCTURES_H
|
||||
#define __LIBNET_STRUCTURES_H
|
||||
|
||||
#if ((__WIN32__) && !(__CYGWIN__))
|
||||
#include "Packet32.h"
|
||||
#endif
|
||||
|
||||
/* port list chain structure */
|
||||
typedef struct libnet_port_list_chain libnet_plist_t;
|
||||
struct libnet_port_list_chain
|
||||
{
|
||||
uint16_t node; /* node number */
|
||||
uint16_t bport; /* beggining port */
|
||||
uint16_t eport; /* terminating port */
|
||||
uint8_t id; /* global array offset */
|
||||
libnet_plist_t *next; /* next node in the list */
|
||||
};
|
||||
|
||||
|
||||
/* libnet statistics structure */
|
||||
struct libnet_stats
|
||||
{
|
||||
#if (!defined(__WIN32__) || (__CYGWIN__))
|
||||
uint64_t packets_sent; /* packets sent */
|
||||
uint64_t packet_errors; /* packets errors */
|
||||
uint64_t bytes_written; /* bytes written */
|
||||
#else
|
||||
__int64 packets_sent; /* packets sent */
|
||||
__int64 packet_errors; /* packets errors */
|
||||
__int64 bytes_written; /* bytes written */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Libnet ptags are how we identify specific protocol blocks inside the
|
||||
* list.
|
||||
*/
|
||||
typedef int32_t libnet_ptag_t;
|
||||
#define LIBNET_PTAG_INITIALIZER 0
|
||||
|
||||
|
||||
/*
|
||||
* Libnet generic protocol block memory object. Sort of a poor man's mbuf.
|
||||
*/
|
||||
struct libnet_protocol_block
|
||||
{
|
||||
uint8_t *buf; /* protocol buffer */
|
||||
uint32_t b_len; /* length of buf */
|
||||
uint16_t h_len; /* header length */
|
||||
/* Passed as last argument to libnet_do_checksum(). Not necessarily used
|
||||
* by that function, it is essentially a pblock specific number, passed
|
||||
* from _builder to the _do_checksum
|
||||
*
|
||||
* Unused for IPV4_H block types.
|
||||
*
|
||||
* For protocols that sit on top of IP, it should be the the amount of
|
||||
* buf that will be included in the checksum, starting from the beginning
|
||||
* of the header.
|
||||
*/
|
||||
uint32_t copied; /* bytes copied - the amount of data copied into buf */
|
||||
/* Used and updated by libnet_pblock_append(). */
|
||||
uint8_t type; /* type of pblock */
|
||||
/* this needs to be updated every time a new packet builder is added */
|
||||
/* libnet_diag_dump_pblock_type() also needs updating for every new pblock tag */
|
||||
#define LIBNET_PBLOCK_ARP_H 0x01 /* ARP header */
|
||||
#define LIBNET_PBLOCK_DHCPV4_H 0x02 /* DHCP v4 header */
|
||||
#define LIBNET_PBLOCK_DNSV4_H 0x03 /* DNS v4 header */
|
||||
#define LIBNET_PBLOCK_ETH_H 0x04 /* Ethernet header */
|
||||
#define LIBNET_PBLOCK_ICMPV4_H 0x05 /* ICMP v4 base header */
|
||||
#define LIBNET_PBLOCK_ICMPV4_ECHO_H 0x06 /* ICMP v4 echo header */
|
||||
#define LIBNET_PBLOCK_ICMPV4_MASK_H 0x07 /* ICMP v4 mask header */
|
||||
#define LIBNET_PBLOCK_ICMPV4_UNREACH_H 0x08 /* ICMP v4 unreach header */
|
||||
#define LIBNET_PBLOCK_ICMPV4_TIMXCEED_H 0x09 /* ICMP v4 exceed header */
|
||||
#define LIBNET_PBLOCK_ICMPV4_REDIRECT_H 0x0a /* ICMP v4 redirect header */
|
||||
#define LIBNET_PBLOCK_ICMPV4_TS_H 0x0b /* ICMP v4 timestamp header */
|
||||
#define LIBNET_PBLOCK_IGMP_H 0x0c /* IGMP header */
|
||||
#define LIBNET_PBLOCK_IPV4_H 0x0d /* IP v4 header */
|
||||
#define LIBNET_PBLOCK_IPO_H 0x0e /* IP v4 options */
|
||||
#define LIBNET_PBLOCK_IPDATA 0x0f /* IP data */
|
||||
#define LIBNET_PBLOCK_OSPF_H 0x10 /* OSPF base header */
|
||||
#define LIBNET_PBLOCK_OSPF_HELLO_H 0x11 /* OSPF hello header */
|
||||
#define LIBNET_PBLOCK_OSPF_DBD_H 0x12 /* OSPF dbd header */
|
||||
#define LIBNET_PBLOCK_OSPF_LSR_H 0x13 /* OSPF lsr header */
|
||||
#define LIBNET_PBLOCK_OSPF_LSU_H 0x14 /* OSPF lsu header */
|
||||
#define LIBNET_PBLOCK_OSPF_LSA_H 0x15 /* OSPF lsa header */
|
||||
#define LIBNET_PBLOCK_OSPF_AUTH_H 0x16 /* OSPF auth header */
|
||||
#define LIBNET_PBLOCK_OSPF_CKSUM 0x17 /* OSPF checksum header */
|
||||
#define LIBNET_PBLOCK_LS_RTR_H 0x18 /* linkstate rtr header */
|
||||
#define LIBNET_PBLOCK_LS_NET_H 0x19 /* linkstate net header */
|
||||
#define LIBNET_PBLOCK_LS_SUM_H 0x1a /* linkstate as sum header */
|
||||
#define LIBNET_PBLOCK_LS_AS_EXT_H 0x1b /* linkstate as ext header */
|
||||
#define LIBNET_PBLOCK_NTP_H 0x1c /* NTP header */
|
||||
#define LIBNET_PBLOCK_RIP_H 0x1d /* RIP header */
|
||||
#define LIBNET_PBLOCK_TCP_H 0x1e /* TCP header */
|
||||
#define LIBNET_PBLOCK_TCPO_H 0x1f /* TCP options */
|
||||
#define LIBNET_PBLOCK_TCPDATA 0x20 /* TCP data */
|
||||
#define LIBNET_PBLOCK_UDP_H 0x21 /* UDP header */
|
||||
#define LIBNET_PBLOCK_VRRP_H 0x22 /* VRRP header */
|
||||
#define LIBNET_PBLOCK_DATA_H 0x23 /* generic data */
|
||||
#define LIBNET_PBLOCK_CDP_H 0x24 /* CDP header */
|
||||
#define LIBNET_PBLOCK_IPSEC_ESP_HDR_H 0x25 /* IPSEC ESP header */
|
||||
#define LIBNET_PBLOCK_IPSEC_ESP_FTR_H 0x26 /* IPSEC ESP footer */
|
||||
#define LIBNET_PBLOCK_IPSEC_AH_H 0x27 /* IPSEC AH header */
|
||||
#define LIBNET_PBLOCK_802_1Q_H 0x28 /* 802.1q header */
|
||||
#define LIBNET_PBLOCK_802_2_H 0x29 /* 802.2 header */
|
||||
#define LIBNET_PBLOCK_802_2SNAP_H 0x2a /* 802.2 SNAP header */
|
||||
#define LIBNET_PBLOCK_802_3_H 0x2b /* 802.3 header */
|
||||
#define LIBNET_PBLOCK_STP_CONF_H 0x2c /* STP configuration header */
|
||||
#define LIBNET_PBLOCK_STP_TCN_H 0x2d /* STP TCN header */
|
||||
#define LIBNET_PBLOCK_ISL_H 0x2e /* ISL header */
|
||||
#define LIBNET_PBLOCK_IPV6_H 0x2f /* IP v6 header */
|
||||
#define LIBNET_PBLOCK_802_1X_H 0x30 /* 802.1x header */
|
||||
#define LIBNET_PBLOCK_RPC_CALL_H 0x31 /* RPC Call header */
|
||||
#define LIBNET_PBLOCK_MPLS_H 0x32 /* MPLS header */
|
||||
#define LIBNET_PBLOCK_FDDI_H 0x33 /* FDDI header */
|
||||
#define LIBNET_PBLOCK_TOKEN_RING_H 0x34 /* TOKEN RING header */
|
||||
#define LIBNET_PBLOCK_BGP4_HEADER_H 0x35 /* BGP4 header */
|
||||
#define LIBNET_PBLOCK_BGP4_OPEN_H 0x36 /* BGP4 open header */
|
||||
#define LIBNET_PBLOCK_BGP4_UPDATE_H 0x37 /* BGP4 update header */
|
||||
#define LIBNET_PBLOCK_BGP4_NOTIFICATION_H 0x38 /* BGP4 notification header */
|
||||
#define LIBNET_PBLOCK_GRE_H 0x39 /* GRE header */
|
||||
#define LIBNET_PBLOCK_GRE_SRE_H 0x3a /* GRE SRE header */
|
||||
#define LIBNET_PBLOCK_IPV6_FRAG_H 0x3b /* IPv6 frag header */
|
||||
#define LIBNET_PBLOCK_IPV6_ROUTING_H 0x3c /* IPv6 routing header */
|
||||
#define LIBNET_PBLOCK_IPV6_DESTOPTS_H 0x3d /* IPv6 dest opts header */
|
||||
#define LIBNET_PBLOCK_IPV6_HBHOPTS_H 0x3e /* IPv6 hop/hop opts header */
|
||||
#define LIBNET_PBLOCK_SEBEK_H 0x3f /* Sebek header */
|
||||
#define LIBNET_PBLOCK_HSRP_H 0x40 /* HSRP header */
|
||||
#define LIBNET_PBLOCK_ICMPV6_H 0x41 /* ICMPv6 header (unused) */
|
||||
#define LIBNET_PBLOCK_ICMPV6_ECHO_H 0x46 /* ICMPv6 echo header */
|
||||
#define LIBNET_PBLOCK_ICMPV6_UNREACH_H 0x42 /* ICMPv6 unreach header */
|
||||
#define LIBNET_PBLOCK_ICMPV6_NDP_NSOL_H 0x43 /* ICMPv6 NDP neighbor solicitation header */
|
||||
#define LIBNET_PBLOCK_ICMPV6_NDP_NADV_H 0x44 /* ICMPv6 NDP neighbor advertisement header */
|
||||
#define LIBNET_PBLOCK_ICMPV6_NDP_OPT_H 0x45 /* ICMPv6 NDP option */
|
||||
|
||||
uint8_t flags; /* control flags */
|
||||
#define LIBNET_PBLOCK_DO_CHECKSUM 0x01 /* needs a checksum */
|
||||
libnet_ptag_t ptag; /* protocol block tag */
|
||||
/* Chains are built from highest level protocol, towards the link level, so
|
||||
* prev traverses away from link level, and next traverses towards the
|
||||
* link level.
|
||||
*/
|
||||
struct libnet_protocol_block *next; /* next pblock */
|
||||
struct libnet_protocol_block *prev; /* prev pblock */
|
||||
};
|
||||
typedef struct libnet_protocol_block libnet_pblock_t;
|
||||
|
||||
|
||||
/*
|
||||
* Libnet context
|
||||
* Opaque structure. Nothing in here should ever been touched first hand by
|
||||
* the applications programmer.
|
||||
*/
|
||||
struct libnet_context
|
||||
{
|
||||
#if ((__WIN32__) && !(__CYGWIN__))
|
||||
SOCKET fd;
|
||||
LPADAPTER lpAdapter;
|
||||
#else
|
||||
int fd; /* file descriptor of packet device */
|
||||
#endif
|
||||
int injection_type; /* one of: */
|
||||
#define LIBNET_NONE 0xf8 /* no injection type, only construct packets */
|
||||
#define LIBNET_LINK 0x00 /* link-layer interface */
|
||||
#define LIBNET_RAW4 0x01 /* raw socket interface (ipv4) */
|
||||
#define LIBNET_RAW6 0x02 /* raw socket interface (ipv6) */
|
||||
/* the following should actually set a flag in the flags variable above */
|
||||
#define LIBNET_LINK_ADV 0x08 /* advanced mode link-layer */
|
||||
#define LIBNET_RAW4_ADV 0x09 /* advanced mode raw socket (ipv4) */
|
||||
#define LIBNET_RAW6_ADV 0x0a /* advanced mode raw socket (ipv6) */
|
||||
#define LIBNET_ADV_MASK 0x08 /* mask to determine adv mode */
|
||||
|
||||
/* _blocks is the highest level, and _end is closest to link-level */
|
||||
libnet_pblock_t *protocol_blocks; /* protocol headers / data */
|
||||
libnet_pblock_t *pblock_end; /* last node in list */
|
||||
uint32_t n_pblocks; /* number of pblocks */
|
||||
|
||||
int link_type; /* link-layer type, a DLT_ value. */
|
||||
/* These are the only values used by libnet (see libnet_build_arp and
|
||||
* libnet_build_link). Other values are assigned by the various
|
||||
* libnet_link_*.c OS support functions, but are not yet used or supported,
|
||||
* they are effectively dead code. <pcap.h> claims these two are invariant
|
||||
* across operating systems... hopefully it is correct!
|
||||
*/
|
||||
#ifndef DLT_EN10MB
|
||||
# define DLT_EN10MB 1 /* Ethernet (10Mb) */
|
||||
#endif
|
||||
#ifndef DLT_IEEE802
|
||||
# define DLT_IEEE802 6 /* IEEE 802 Networks */
|
||||
#endif
|
||||
|
||||
int link_offset; /* link-layer header size */
|
||||
int aligner; /* used to align packets */
|
||||
char *device; /* device name */
|
||||
|
||||
struct libnet_stats stats; /* statistics */
|
||||
libnet_ptag_t ptag_state; /* state holder for pblock tag */
|
||||
char label[LIBNET_LABEL_SIZE]; /* textual label for cq interface */
|
||||
|
||||
char err_buf[LIBNET_ERRBUF_SIZE]; /* error buffer */
|
||||
uint32_t total_size; /* total size */
|
||||
};
|
||||
typedef struct libnet_context libnet_t;
|
||||
|
||||
/*
|
||||
* Libnet context queue structure
|
||||
* Opaque structure. Nothing in here should ever been touched first hand by
|
||||
* the applications programmer.
|
||||
*/
|
||||
typedef struct _libnet_context_queue libnet_cq_t;
|
||||
struct _libnet_context_queue
|
||||
{
|
||||
libnet_t *context; /* pointer to libnet context */
|
||||
libnet_cq_t *next; /* next node in the list */
|
||||
libnet_cq_t *prev; /* previous node in the list */
|
||||
};
|
||||
|
||||
struct _libnet_context_queue_descriptor
|
||||
{
|
||||
uint32_t node; /* number of nodes in the list */
|
||||
uint32_t cq_lock; /* lock status */
|
||||
libnet_cq_t *current; /* current context */
|
||||
};
|
||||
typedef struct _libnet_context_queue_descriptor libnet_cqd_t;
|
||||
|
||||
#endif /* __LIBNET_STRUCTURES_H */
|
||||
|
||||
/* EOF */
|
||||
40
openflow/include/libnet/libnet-types.h
Normal file
40
openflow/include/libnet/libnet-types.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* $Id: libnet-types.h,v 1.3 2004/01/03 20:31:00 mike Exp $
|
||||
*
|
||||
* libnet-types.h - Network routine library macro header file
|
||||
*
|
||||
* Copyright (c) 1998 - 2004 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_TYPES_H
|
||||
#define __LIBNET_TYPES_H
|
||||
|
||||
/* libnet should be using the standard type names, so mapping standard
|
||||
* to non-standard should not be necessary. */
|
||||
|
||||
#endif /* __LIBNET_TYPES_H */
|
||||
|
||||
/* EOF */
|
||||
Reference in New Issue
Block a user