openflow build environment setup

This commit is contained in:
2025-11-11 16:45:43 +08:00
parent be0a7ad9b3
commit 50ecb9a23f
2767 changed files with 62766 additions and 649828 deletions

View File

@ -0,0 +1,129 @@
#ifndef CLICKNET_DHCP_H
#define CLICKNET_DHCP_H
struct click_dhcp {
uint8_t op; /* message type */
uint8_t htype; /* hardware address type */
uint8_t hlen; /* hardware address length */
uint8_t hops; /* should be zero in client's message */
uint32_t xid; /* transaction id */
uint16_t secs; /* elapsed time in sec. from trying to boot */
uint16_t flags;
uint32_t ciaddr; /* (previously allocated) client IP address */
uint32_t yiaddr; /* 'your' client IP address */
uint32_t siaddr; /* should be zero in client's messages */
uint32_t giaddr; /* should be zero in client's messages */
uint8_t chaddr[16]; /* client's hardware address */
uint8_t sname[64]; /* server host name, null terminated string */
uint8_t file[128]; /* boot file name, null terminated string */
uint32_t magic; /* magic cookie */
uint8_t options[312]; /* message options */
} CLICK_SIZE_PACKED_ATTRIBUTE;
#define ETH_10MB 1 /* htype */
#define ETH_10MB_LEN 6 /* hlen */
/* DHCP message OP code */
#define DHCP_BOOTREQUEST 1
#define DHCP_BOOTREPLY 2
/* DHCP Client State*/
enum dhcp_client_state {
DHCP_CLIENT_INIT_STATE = 1,
DHCP_CLIENT_SELECTING_STATE,
DHCP_CLIENT_REQUESTING_STATE,
DHCP_CLIENT_INIT_REBOOT,
DHCP_CLIENT_REBOOTING,
DHCP_CLIENT_BOUND,
DHCP_CLIENT_RENEWING,
DHCP_CLIENT_REBINDING
};
/* DHCP message type */
#define DHCP_DISCOVER 1
#define DHCP_OFFER 2
#define DHCP_REQUEST 3
#define DHCP_DECLINE 4
#define DHCP_ACK 5
#define DHCP_NACK 6
#define DHCP_RELEASE 7
#define DHCP_INFORM 8
#define DHCP_MAGIC 0x63538263
/* DHCP Option codes: */
#define DHO_PAD 0
#define DHO_SUBNET_MASK 1
#define DHO_TIME_OFFSET 2
#define DHO_ROUTERS 3
#define DHO_TIME_SERVERS 4
#define DHO_NAME_SERVERS 5
#define DHO_DOMAIN_NAME_SERVERS 6
#define DHO_LOG_SERVERS 7
#define DHO_COOKIE_SERVERS 8
#define DHO_LPR_SERVERS 9
#define DHO_IMPRESS_SERVERS 10
#define DHO_RESOURCE_LOCATION_SERVERS 11
#define DHO_HOST_NAME 12
#define DHO_BOOT_SIZE 13
#define DHO_MERIT_DUMP 14
#define DHO_DOMAIN_NAME 15
#define DHO_SWAP_SERVER 16
#define DHO_ROOT_PATH 17
#define DHO_EXTENSIONS_PATH 18
#define DHO_IP_FORWARDING 19
#define DHO_NON_LOCAL_SOURCE_ROUTING 20
#define DHO_POLICY_FILTER 21
#define DHO_MAX_DGRAM_REASSEMBLY 22
#define DHO_DEFAULT_IP_TTL 23
#define DHO_PATH_MTU_AGING_TIMEOUT 24
#define DHO_PATH_MTU_PLATEAU_TABLE 25
#define DHO_INTERFACE_MTU 26
#define DHO_ALL_SUBNETS_LOCAL 27
#define DHO_BROADCAST_ADDRESS 28
#define DHO_PERFORM_MASK_DISCOVERY 29
#define DHO_MASK_SUPPLIER 30
#define DHO_ROUTER_DISCOVERY 31
#define DHO_ROUTER_SOLICITATION_ADDRESS 32
#define DHO_STATIC_ROUTES 33
#define DHO_TRAILER_ENCAPSULATION 34
#define DHO_ARP_CACHE_TIMEOUT 35
#define DHO_IEEE802_3_ENCAPSULATION 36
#define DHO_DEFAULT_TCP_TTL 37
#define DHO_TCP_KEEPALIVE_INTERVAL 38
#define DHO_TCP_KEEPALIVE_GARBAGE 39
#define DHO_NIS_DOMAIN 40
#define DHO_NIS_SERVERS 41
#define DHO_NTP_SERVERS 42
#define DHO_VENDOR_ENCAPSULATED_OPTIONS 43
#define DHO_NETBIOS_NAME_SERVERS 44
#define DHO_NETBIOS_DD_SERVER 45
#define DHO_NETBIOS_NODE_TYPE 46
#define DHO_NETBIOS_SCOPE 47
#define DHO_FONT_SERVERS 48
#define DHO_X_DISPLAY_MANAGER 49
#define DHO_DHCP_REQUESTED_ADDRESS 50
#define DHO_DHCP_LEASE_TIME 51
#define DHO_DHCP_OPTION_OVERLOAD 52
#define DHO_DHCP_MESSAGE_TYPE 53
#define DHO_DHCP_SERVER_IDENTIFIER 54
#define DHO_DHCP_PARAMETER_REQUEST_LIST 55
#define DHO_DHCP_MESSAGE 56
#define DHO_DHCP_MAX_MESSAGE_SIZE 57
#define DHO_DHCP_RENEWAL_TIME 58
#define DHO_DHCP_REBINDING_TIME 59
#define DHO_VENDOR_CLASS_IDENTIFIER 60
#define DHO_DHCP_CLIENT_IDENTIFIER 61
#define DHO_NWIP_DOMAIN_NAME 62
#define DHO_NWIP_SUBOPTIONS 63
#define DHO_USER_CLASS 77
#define DHO_FQDN 81
#define DHO_DHCP_AGENT_OPTIONS 82
#define DHO_SUBNET_SELECTION 118 /* RFC3011! */
#define DHO_END 255
#endif /* CLICKNET_DHCP_H */

View File

@ -0,0 +1,130 @@
/* -*- mode: c; c-basic-offset: 4 -*- */
#ifndef CLICKNET_ETHER_H
#define CLICKNET_ETHER_H
/*
* <clicknet/ether.h> -- Ethernet and ARP headers, based on one of the BSDs.
*
* Relevant RFCs include:
* RFC826 Ethernet Address Resolution Protocol: or, Converting Network
* Protocol Addresses to 48.bit Ethernet Address for Transmission
* on Ethernet Hardware
* RFC894 Standard for the transmission of IP datagrams over Ethernet
* networks
* Also see the relevant IEEE 802 standards.
*/
struct click_ether {
uint8_t ether_dhost[6]; /* 0-5 Ethernet destination address */
uint8_t ether_shost[6]; /* 6-11 Ethernet source address */
uint16_t ether_type; /* 12-13 Ethernet protocol */
} CLICK_SIZE_PACKED_ATTRIBUTE;
#define ETHERTYPE_IP 0x0800
#define ETHERTYPE_ARP 0x0806
#define ETHERTYPE_TRAIL 0x1000
#define ETHERTYPE_8021Q 0x8100
#define ETHERTYPE_IP6 0x86DD
#define ETHERTYPE_MACCONTROL 0x8808
#define ETHERTYPE_PPPOE_DISC 0x8863
#define ETHERTYPE_PPPOE_SESSION 0x8864
#define ETHERTYPE_GRID 0x7fff /* wvlan_cs driver won't transmit frames with high bit of protocol number set */
struct click_arp { /* Offsets relative to ARP (Ethernet) header */
uint16_t ar_hrd; /* 0-1 (14-15) hardware address format */
#define ARPHRD_ETHER 1 /* Ethernet 10Mbps */
#define ARPHRD_IEEE802 6 /* token ring */
#define ARPHRD_ARCNET 7 /* Arcnet */
#define ARPHRD_FRELAY 15 /* frame relay */
#define ARPHRD_STRIP 23 /* Ricochet Starmode Radio */
#define ARPHRD_IEEE1394 24 /* IEEE 1394 (FireWire) */
#define ARPHRD_80211 801 /* IEEE 802.11 (wifi) */
uint16_t ar_pro; /* 2-3 (16-17) protocol address format */
uint8_t ar_hln; /* 4 (18) hardware address length */
uint8_t ar_pln; /* 5 (19) protocol address length */
uint16_t ar_op; /* 6-7 (20-21) opcode (command) */
#define ARPOP_REQUEST 1 /* ARP request */
#define ARPOP_REPLY 2 /* ARP reply */
#define ARPOP_REVREQUEST 3 /* reverse request: hw->proto */
#define ARPOP_REVREPLY 4 /* reverse reply */
#define ARPOP_INVREQUEST 8 /* peer identification req */
#define ARPOP_INVREPLY 9 /* peer identification reply */
};
struct click_ether_arp {
struct click_arp ea_hdr; /* 0-7 (14-21) fixed-size ARP header */
uint8_t arp_sha[6]; /* 8-13 (22-27) sender hardware address */
uint8_t arp_spa[4]; /* 14-17 (28-31) sender protocol address */
uint8_t arp_tha[6]; /* 18-23 (32-37) target hardware address */
uint8_t arp_tpa[4]; /* 24-27 (38-41) target protocol address */
};
/* Ethernet with VLAN (802.1q) */
struct click_ether_vlan {
uint8_t ether_dhost[6]; /* 0-5 Ethernet source address */
uint8_t ether_shost[6]; /* 6-11 Ethernet destination address */
uint16_t ether_vlan_proto; /* 12-13 == ETHERTYPE_8021Q */
uint16_t ether_vlan_tci; /* 14-15 tag control information */
uint16_t ether_vlan_encap_proto; /* 16-17 Ethernet protocol */
} CLICK_SIZE_PACKED_ATTRIBUTE;
/* Ethernet MAC control (802.3) */
struct click_ether_macctl {
uint16_t ether_macctl_opcode;
uint16_t ether_macctl_param;
uint8_t ether_macctl_reserved[42];
};
#define ETHER_MACCTL_OP_PAUSE 0x0001
#define ND_SOL 0x0087 /* Neighborhood Solicitation Message Type */
#define ND_ADV 0x0088 /* Neighborhood Advertisement Message Type */
/* define structure of Neighborhood Solicitation Message */
struct click_nd_sol {
uint8_t type;
uint8_t code;
uint16_t checksum;
uint32_t reserved;
uint8_t nd_tpa[16];
uint8_t option_type; /*option type: 1 (source link-layer add) */
uint8_t option_length; /*option length: 1 (in units of 8 octets) */
uint8_t nd_sha[6]; /*source link-layer address */
};
/* define structure of Neighborhood Advertisement Message -reply to multicast neighborhood solitation message */
struct click_nd_adv {
uint8_t type;
uint8_t code;
uint16_t checksum;
uint8_t flags; /* bit 1: sender_is_router
bit 2: solicited
bit 3: override
all other bits should be zero */
uint8_t reserved[3];
uint8_t nd_tpa[16];
uint8_t option_type; /* option type: 2 (target link-layer add) */
uint8_t option_length; /* option length: 1 (in units of 8 octets) */
uint8_t nd_tha[6]; /* source link-layer address */
};
/* define structure of Neighborhood Advertisement Message - reply to unicast neighborhood solitation message */
struct click_nd_adv2 {
uint8_t type;
uint8_t code;
uint16_t checksum;
uint8_t flags; /* bit 1: sender_is_router
bit 2: solicited
bit 3: override
all other bits should be zero */
uint8_t reserved[3];
uint8_t nd_tpa[16];
};
#endif

View File

@ -0,0 +1,43 @@
/* -*- mode: c; c-basic-offset: 4 -*- */
#ifndef CLICKNET_FDDI_H
#define CLICKNET_FDDI_H
/*
* <clicknet/fddi.h> -- our own definitions of FDDI headers
* based on a file from Linux
*/
struct click_fddi {
uint8_t fc;
uint8_t daddr[6];
uint8_t saddr[6];
} CLICK_SIZE_PACKED_ATTRIBUTE;
struct click_fddi_8022_1 {
struct click_fddi h;
uint8_t dsap;
uint8_t ssap;
uint8_t ctrl;
} CLICK_SIZE_PACKED_ATTRIBUTE;
struct click_fddi_8022_2 {
struct click_fddi h;
uint8_t dsap;
uint8_t ssap;
uint8_t ctrl1;
uint8_t ctrl2;
} CLICK_SIZE_PACKED_ATTRIBUTE;
struct click_fddi_snap {
struct click_fddi h;
uint8_t dsap;
uint8_t ssap;
uint8_t ctrl;
uint8_t oui[3];
uint16_t ether_type;
} CLICK_SIZE_PACKED_ATTRIBUTE;
#define FDDI_FC_LLC_ASYNC 0x50
#define FDDI_FC_LLCMASK 0xF0 /* length/class/format bits */
#endif

View File

@ -0,0 +1,133 @@
/* -*- c-basic-offset: 4 -*- */
#ifndef CLICKNET_ICMP_H
#define CLICKNET_ICMP_H
#include <clicknet/ip.h>
/*
* <clicknet/icmp.h> -- ICMP packet definitions, based on FreeBSD.
*
* Relevant RFCs include:
* RFC792 Internet Control Message Protocol
* RFC1122 Requirements for Internet Hosts - Communication Layers
* RFC1123 Requirements for Internet Hosts - Application and Support
* RFC1812 Requirements for IP Version 4 Routers
*/
/* most icmp request types: ICMP_UNREACH, ICMP_SOURCEQUENCH, ICMP_TIMXCEED */
struct click_icmp {
uint8_t icmp_type; /* 0 ICMP type (see below) */
uint8_t icmp_code; /* 1 ICMP code (see below) */
uint16_t icmp_cksum; /* 2-3 checksum */
uint32_t padding; /* 4-7 should be zero */
/* followed by original IP header and initial portion of data */
};
/* header for types with sequence numbers: ICMP_ECHO, ICMP_ECHOREPLY,
ICMP_IREQ, ICMP_IREQREPLY */
struct click_icmp_sequenced {
uint8_t icmp_type; /* 0 ICMP type (see below) */
uint8_t icmp_code; /* 1 ICMP code (see below) */
uint16_t icmp_cksum; /* 2-3 checksum */
uint16_t icmp_identifier; /* 4-5 flow identifier */
uint16_t icmp_sequence; /* 6-7 sequence number in flow */
};
/* ICMP_PARAMPROB header */
struct click_icmp_paramprob {
uint8_t icmp_type; /* 0 ICMP type (see below) */
uint8_t icmp_code; /* 1 ICMP code (see below) */
uint16_t icmp_cksum; /* 2-3 checksum */
uint8_t icmp_pointer; /* 4 parameter pointer */
uint8_t padding[3]; /* 5-7 should be zero */
/* followed by original IP header and initial portion of data */
};
/* Redirect header: ICMP_REDIRECT */
struct click_icmp_redirect {
uint8_t icmp_type; /* 0 ICMP_REDIRECT (see below) */
uint8_t icmp_code; /* 1 ICMP code (see below) */
uint16_t icmp_cksum; /* 2-3 checksum */
struct in_addr icmp_gateway; /* 4-7 address of gateway */
/* followed by original IP header and initial portion of data */
};
/* Timestamp and TimestampReply header: ICMP_TSTAMP and ICMP_TSTAMPREPLY */
struct click_icmp_tstamp {
uint8_t icmp_type; /* 0 ICMP type (see below) */
uint8_t icmp_code; /* 1 ICMP code (see below) */
uint16_t icmp_cksum; /* 2-3 checksum */
uint16_t icmp_identifier; /* 4-5 flow identifier */
uint16_t icmp_sequence; /* 6-7 sequence number in flow */
uint32_t icmp_originate; /* 8-11 originate timestamp */
uint32_t icmp_receive; /* 12-15 receive timestamp */
uint32_t icmp_transmit; /* 16-19 transmit timestamp */
};
/* Path MTU Discovery header: ICMP_UNREACH_NEEDFRAG */
struct click_icmp_needfrag {
uint8_t icmp_type; /* 0 ICMP_UNREACH (see below) */
uint8_t icmp_code; /* 1 ICMP_UNREACH_NEEDFRAG */
uint16_t icmp_cksum; /* 2-3 checksum */
uint16_t padding; /* 4-5 should be zero */
uint16_t icmp_nextmtu; /* 6-7 Next-Hop MTU */
/* followed by original IP header and initial portion of data */
};
#define click_icmp_unreach click_icmp
#define click_icmp_sourcequench click_icmp
#define click_icmp_timxceed click_icmp
#define click_icmp_echo click_icmp_sequenced
/* ICMP type definitions and (indented) code definitions */
#define ICMP_ECHOREPLY 0 /* echo reply */
#define ICMP_UNREACH 3 /* dest unreachable, codes: */
#define ICMP_UNREACH_NET 0 /* bad net */
#define ICMP_UNREACH_HOST 1 /* bad host */
#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
#define ICMP_UNREACH_PORT 3 /* bad port */
#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
#define ICMP_UNREACH_NET_PROHIB 9 /* net prohibited access */
#define ICMP_UNREACH_HOST_PROHIB 10 /* host prohibited access */
#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */
#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec violation */
#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */
#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
#define ICMP_REDIRECT 5 /* shorter route, codes: */
#define ICMP_REDIRECT_NET 0 /* for network */
#define ICMP_REDIRECT_HOST 1 /* for host */
#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
#define ICMP_ECHO 8 /* echo service */
#define ICMP_ROUTERADVERT 9 /* router advertisement */
#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
#define ICMP_TIMXCEED 11 /* time exceeded, code: */
#define ICMP_TIMXCEED_TRANSIT 0 /* ttl==0 in transit */
#define ICMP_TIMXCEED_REASSEMBLY 1 /* ttl==0 in reassembly */
#define ICMP_PARAMPROB 12 /* ip header bad */
#define ICMP_PARAMPROB_ERRATPTR 0 /* error at param ptr */
#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
#define ICMP_PARAMPROB_LENGTH 2 /* bad length */
#define ICMP_TSTAMP 13 /* timestamp request */
#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
#define ICMP_IREQ 15 /* information request */
#define ICMP_IREQREPLY 16 /* information reply */
#define ICMP_MASKREQ 17 /* address mask request */
#define ICMP_MASKREQREPLY 18 /* address mask reply */
static inline size_t
click_icmp_hl(uint8_t icmp_type)
{
if (icmp_type == ICMP_TSTAMP || icmp_type == ICMP_TSTAMPREPLY)
return sizeof(click_icmp_tstamp);
else
return sizeof(click_icmp);
}
#endif

View File

@ -0,0 +1,114 @@
/* -*- c-basic-offset: 4 -*- */
#ifndef CLICKNET_ICMP6_H
#define CLICKNET_ICMP6_H
#include <clicknet/ip6.h>
/*
* <clicknet/icmp6.h> -- our own definitions for ICMP6 packets
* Based on RFC 1885
*/
/* types for ICMP6 packets */
#define ICMP6_UNREACH 1
#define ICMP6_PKTTOOBIG 2
#define ICMP6_TIMXCEED 3
#define ICMP6_PARAMPROB 4
#define ICMP6_ECHO 128
#define ICMP6_ECHOREPLY 129
#define ICMP6_MEMBERSHIPQUERY 130
#define ICMP6_MEMBERSHIPREPORT 131
#define ICMP6_MEMBERSHIPREDUCTION 132
#define ICMP6_REDIRECT 137
/* codes for spefic types of ICMP6 packets */
/* ICMP6 Error Message - Type: 1 */
#define ICMP6_UNREACH_NOROUTE 0
#define ICMP6_UNREACH_ADMIN 1
#define ICMP6_UNREACH_NOTNEIGHBOR 2
#define ICMP6_UNREACH_ADDR 3
#define ICMP6_UNREACH_NOPORT 4
/* ICMP6 Time Exceeded Message - Type: 3 */
#define ICMP6_TIMXCEED_TRANSIT 0
#define ICMP6_TIMXCEED_REASSEMBLY 1
/* ICMP6 Parameter Problem Message - Type: 4 */
#define ICMP6_PARAMPROB_HEADER 0
#define ICMP6_PARAMPROB_NEXTHEADER 1
#define ICMP6_PARAMPROB_OPTION 2
/* remove possible definitions for symbols */
#undef icmp6_identifier
#undef icmp6_sequence
#undef icmp6_pointer
#undef icmp6_maxdelay
/* most ICMP6 request types */
struct click_icmp6 {
uint8_t icmp6_type; /* one of the ICMP6_TYPE_*'s above */
uint8_t icmp6_code; /* one of the ICMP6_CODE_*'s above */
uint16_t icmp6_cksum; /* 16 1's comp csum */
uint32_t padding; /* should be zero */
/* followed by as much of invoking packet as will fit without the ICMPv6 packet exceeding 576 octets*/
};
/* packet too big header */
struct click_icmp6_pkttoobig {
uint8_t icmp6_type; /* one of the ICMP6_TYPE_*'s above */
uint8_t icmp6_code; /* one of the ICMP6_CODE_*'s above */
uint16_t icmp6_cksum; /* 16 1's comp csum */
uint32_t icmp6_mtusize; /* maximum packet size */
/* followed by as much of invoking packet as will fit without the ICMPv6 packet exceeding 576 octets*/
};
/* parameter problem header */
struct click_icmp6_paramprob {
uint8_t icmp6_type; /* one of the ICMP_TYPE_*'s above */
uint8_t icmp6_code; /* one of the ICMP6_CODE_*'s above */
uint16_t icmp6_cksum; /* 16 1's comp csum */
uint32_t icmp6_pointer; /* which octect in orig. IP6 pkt was a problem */
/* followed by as much of invoking packet as will fit without the ICMPv6 packet exceeding 576 octets*/
};
/* struct for things with sequence numbers - echo request & echo reply msgs*/
struct click_icmp6_sequenced {
uint8_t icmp6_type; /* one of the ICMP6_TYPE_*'s above */
uint8_t icmp6_code; /* one of the ICMP6_CODE_*'s above */
uint16_t icmp6_cksum; /* 16 1's comp csum */
uint16_t icmp6_identifier;
uint16_t icmp6_sequence;
/* Followed by: */
/* Echo Request: zero or more octets of arbitary data */
/* Echo Reply: the data fromm the invoking Echo Request msg */
};
/* struct for group membership messages */
struct click_icmp6_membership {
uint8_t icmp6_type; /* one of the ICMP6_TYPE_*'s above */
uint8_t icmp6_code; /* one of the ICMP6_CODE_*'s above */
uint16_t icmp6_cksum; /* 16 1's comp csum */
uint16_t icmp6_maxdelay; /* maximum response delay, in milliseconds */
uint16_t padding;
/* followed by multicast address */
};
/* struct for redirect messages */
struct click_icmp6_redirect {
uint8_t icmp6_type;
uint8_t icmp6_code;
uint16_t icmp6_cksum;
uint32_t padding;
struct in6_addr icmp6_target;
struct in6_addr icmp6_dst;
};
/* different struct names for each type of packet */
#define click_icmp6_unreach click_icmp6
#define click_icmp6_timxceed click_icmp6
#define click_icmp6_echo click_icmp6_sequenced
#endif

View File

@ -0,0 +1,205 @@
/* -*- mode: c; c-basic-offset: 4 -*- */
#ifndef CLICKNET_IP_H
#define CLICKNET_IP_H
/* get struct in_addr */
#include <click/cxxprotect.h>
CLICK_CXX_PROTECT
#if CLICK_LINUXMODULE
# include <net/checksum.h>
# include <linux/in.h>
#else
# include <sys/types.h>
#undef true
# include <netinet/in.h>
#define true linux_true
#endif
/*
* <clicknet/ip.h> -- IP header definitions, based on one of the BSDs.
*
* Relevant RFCs include:
* RFC791 Internet Protocol
* RFC3168 The Addition of Explicit Congestion Notification (ECN) to IP
*/
struct click_ip {
#if CLICK_BYTE_ORDER == CLICK_BIG_ENDIAN
unsigned ip_v : 4; /* 0 version == 4 */
unsigned ip_hl : 4; /* header length */
#elif CLICK_BYTE_ORDER == CLICK_LITTLE_ENDIAN
unsigned ip_hl : 4; /* 0 header length */
unsigned ip_v : 4; /* version == 4 */
#else
# error "unknown byte order"
#endif
uint8_t ip_tos; /* 1 type of service */
#define IP_DSCPMASK 0xFC /* diffserv code point */
#define IP_ECNMASK 0x03 /* ECN code point */
#define IP_ECN_NOT_ECT 0x00 /* not ECN capable transport */
#define IP_ECN_ECT1 0x01 /* ECN capable transport */
#define IP_ECN_ECT2 0x02 /* ECN capable transport */
#define IP_ECN_CE 0x03 /* ECN congestion exp'd */
uint16_t ip_len; /* 2-3 total length */
uint16_t ip_id; /* 4-5 identification */
uint16_t ip_off; /* 6-7 fragment offset field */
#define IP_RF 0x8000 /* reserved fragment flag */
#define IP_DF 0x4000 /* don't fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0X1FFF /* mask for fragmenting bits */
uint8_t ip_ttl; /* 8 time to live */
uint8_t ip_p; /* 9 protocol */
uint16_t ip_sum; /* 10-11 checksum */
struct in_addr ip_src; /* 12-15 source address */
struct in_addr ip_dst; /* 16-19 destination address */
};
/* ip_protocol */
#define IP_PROTO_ICMP 1
#define IP_PROTO_IGMP 2
#define IP_PROTO_GGP 3
#define IP_PROTO_IPIP 4
#define IP_PROTO_ST 5
#define IP_PROTO_TCP 6
#define IP_PROTO_UCL 7
#define IP_PROTO_EGP 8
#define IP_PROTO_IGP 9
#define IP_PROTO_BBN 10
#define IP_PROTO_NVPII 11
#define IP_PROTO_PUP 12
#define IP_PROTO_ARGUS 13
#define IP_PROTO_EMCON 14
#define IP_PROTO_XNET 15
#define IP_PROTO_CHAOS 16
#define IP_PROTO_UDP 17
#define IP_PROTO_MUX 18
#define IP_PROTO_DCN 19
#define IP_PROTO_HMP 20
#define IP_PROTO_PRM 21
#define IP_PROTO_XNS 22
#define IP_PROTO_TRUNK1 23
#define IP_PROTO_TRUNK2 24
#define IP_PROTO_LEAF1 25
#define IP_PROTO_LEAF2 26
#define IP_PROTO_RDP 27
#define IP_PROTO_IRTP 28
#define IP_PROTO_ISOTP4 29
#define IP_PROTO_NETBLT 30
#define IP_PROTO_MFENSP 31
#define IP_PROTO_MERIT 32
#define IP_PROTO_DCCP 33
#define IP_PROTO_RSVP 46
#define IP_PROTO_GRE 47
#define IP_PROTO_ICMP6 58
#define IP_PROTO_CFTP 62
#define IP_PROTO_SATNET 64
#define IP_PROTO_MITSUBNET 65
#define IP_PROTO_RVD 66
#define IP_PROTO_IPPC 67
#define IP_PROTO_SATMON 69
#define IP_PROTO_IPCV 71
#define IP_PROTO_BRSATMON 76
#define IP_PROTO_WBMON 78
#define IP_PROTO_WBEXPAK 79
#define IP_PROTO_SCTP 132
#define IP_PROTO_UDPLITE 136
#define IP_PROTO_NONE 257
#define IP_PROTO_TRANSP 258
#define IP_PROTO_TCP_OR_UDP 256
#define IP_PROTO_PAYLOAD 259
#define IPOPT_EOL 0 /* end of option list */
#define IPOPT_NOP 1 /* no operation */
#define IPOPT_RR 7 /* record packet route */
#define IPOPT_TS 68 /* timestamp */
#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
#define IPOPT_LSRR 131 /* loose source route */
#define IPOPT_SATID 136 /* satnet id */
#define IPOPT_SSRR 137 /* strict source route */
#define IPOPT_RA 148 /* router alert */
#define IP_ISFRAG(iph) (((iph)->ip_off & htons(IP_MF | IP_OFFMASK)) != 0)
#define IP_FIRSTFRAG(iph) (((iph)->ip_off & htons(IP_OFFMASK)) == 0)
/* checksum functions */
#if !CLICK_LINUXMODULE
/** @brief Calculate an Internet checksum over a data range.
* @param x data to checksum
* @param len number of bytes to checksum
*
* @a x must be two-byte aligned. */
uint16_t click_in_cksum(const unsigned char *x, int len);
uint16_t click_in_cksum_pseudohdr_raw(uint32_t csum, uint32_t src, uint32_t dst, int proto, int packet_len);
#else
# define click_in_cksum(addr, len) \
ip_compute_csum((unsigned char *)(addr), (len))
# define click_in_cksum_pseudohdr_raw(csum, src, dst, proto, transport_len) \
csum_tcpudp_magic((src), (dst), (transport_len), (proto), ~(csum) & 0xFFFF)
#endif
uint16_t click_in_cksum_pseudohdr_hard(uint32_t csum, const struct click_ip *iph, int packet_len);
void click_update_zero_in_cksum_hard(uint16_t *csum, const unsigned char *addr, int len);
/** @brief Adjust an Internet checksum according to a pseudoheader.
* @param data_csum initial checksum (may be a 16-bit checksum)
* @param iph IP header from which to extract pseudoheader information
* @param transport_len length of transport header
*
* This function correctly handles Internet headers that contain source
* routing options. The final destination from the source routing option is
* used to compute the pseudoheader checksum. */
static inline uint16_t
click_in_cksum_pseudohdr(uint32_t data_csum, const struct click_ip *iph,
int transport_len)
{
if (iph->ip_hl == 5)
return click_in_cksum_pseudohdr_raw(data_csum, iph->ip_src.s_addr, iph->ip_dst.s_addr, iph->ip_p, transport_len);
else
return click_in_cksum_pseudohdr_hard(data_csum, iph, transport_len);
}
/** @brief Incrementally adjust an Internet checksum.
* @param[in, out] csum points to checksum
* @param old_hw old halfword
* @param new_hw new halfword
*
* The checksum stored in *@a csum is updated to account for a change of @a
* old_hw to @a new_hw.
*
* Because of the vagaries of one's-complement arithmetic, this function will
* never produce a new checksum of ~+0 = 0xFFFF. This is usually OK, since
* IP, TCP, and UDP checksums will never have this value. (Only all-zero data
* can checksum to ~+0, but IP, TCP, and UDP checksums always cover at least
* one non-zero byte.) If you are checksumming data that is potentially all
* zero, then call click_update_zero_in_cksum() after calling
* click_update_in_cksum(). */
static inline void
click_update_in_cksum(uint16_t *csum, uint16_t old_hw, uint16_t new_hw)
{
/* incrementally update IP checksum according to RFC1624:
new_sum = ~(~old_sum + ~old_halfword + new_halfword) */
uint32_t sum = (~*csum & 0xFFFF) + (~old_hw & 0xFFFF) + new_hw;
sum = (sum & 0xFFFF) + (sum >> 16);
*csum = ~(sum + (sum >> 16));
}
/** @brief Potentially fix a zero-valued Internet checksum.
* @param[in, out] csum points to checksum
* @param x data to checksum
* @param len number of bytes to checksum
*
* If all the data bytes in [x, x+len) are zero, then its checksum should be
* ~+0 = 0xFFFF, but click_update_in_cksum may have set the checksum to ~-0 =
* 0x0000. This function checks for such a case and sets the checksum
* correctly. */
static inline void
click_update_zero_in_cksum(uint16_t *csum, const unsigned char *x, int len)
{
if (*csum == 0)
click_update_zero_in_cksum_hard(csum, x, len);
}
CLICK_CXX_UNPROTECT
#include <click/cxxunprotect.h>
#endif

View File

@ -0,0 +1,98 @@
/* -*- mode: c; c-basic-offset: 4 -*- */
#ifndef CLICKNET_IP6_H
#define CLICKNET_IP6_H
//#include <clicknet/ip.h>
/* get struct in6_addr */
#include <click/cxxprotect.h>
CLICK_CXX_PROTECT
#if CLICK_LINUXMODULE
# include <net/checksum.h>
# include <linux/in6.h>
#else
# include <sys/types.h>
# undef true
# include <netinet/in.h>
# define true linux_true
#endif
struct click_ip6 {
union {
struct {
uint32_t ip6_un1_flow; /* 0-3 bits 0-3: version == 6 */
/* bits 4-11: traffic class */
/* bits 4-9: DSCP */
/* bits 10-11: ECN */
/* bits 12-31: flow label */
uint16_t ip6_un1_plen; /* 4-5 payload length */
uint8_t ip6_un1_nxt; /* 6 next header */
uint8_t ip6_un1_hlim; /* 7 hop limit */
} ip6_un1;
uint8_t ip6_un2_vfc; /* 0 bits 0-3: version == 6 */
/* bits 4-7: top 4 class bits */
struct {
#if CLICK_BYTE_ORDER == CLICK_BIG_ENDIAN
unsigned ip6_un3_v : 4; /* 0 version == 6 */
unsigned ip6_un3_fc : 4; /* header length */
#elif CLICK_BYTE_ORDER == CLICK_LITTLE_ENDIAN
unsigned ip6_un3_fc : 4; /* 0 header length */
unsigned ip6_un3_v : 4; /* version == 6 */
#endif
} ip6_un3;
} ip6_ctlun;
struct in6_addr ip6_src; /* 8-23 source address */
struct in6_addr ip6_dst; /* 24-39 dest address */
};
#define ip6_v ip6_ctlun.ip6_un3.ip6_un3_v
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
#define IP6_FLOW_MASK 0x000FFFFFU
#define IP6_FLOW_SHIFT 0
#define IP6_CLASS_MASK 0x0FF00000U
#define IP6_CLASS_SHIFT 20
#define IP6_DSCP_MASK 0x0FC00000U
#define IP6_DSCP_SHIFT 22
#define IP6_V_MASK 0xF0000000U
#define IP6_V_SHIFT 28
#define IP6_CHECK_V(hdr) (((hdr).ip6_vfc & htonl(IP6_V_MASK)) == htonl(6 << IP6_V_SHIFT))
#ifndef IP6PROTO_FRAGMENT
#define IP6PROTO_FRAGMENT 0x2c
#endif
struct click_ip6_fragment {
uint8_t ip6_frag_nxt;
uint8_t ip6_frag_reserved;
uint16_t ip6_frag_offset;
#define IP6_MF 0x0001
#define IP6_OFFMASK 0xFFF8
/* bits 0-12: Fragment offset */
/* bit 13-14: reserved */
/* bit 15: More Fragment */
uint32_t ip6_frag_id;
};
uint16_t in6_fast_cksum(const struct in6_addr *saddr,
const struct in6_addr *daddr,
uint16_t len,
uint8_t proto,
uint16_t ori_csum,
const unsigned char *addr,
uint16_t len2);
uint16_t in6_cksum(const struct in6_addr *saddr,
const struct in6_addr *daddr,
uint16_t len,
uint8_t proto,
uint16_t ori_csum,
unsigned char *addr,
uint16_t len2);
CLICK_CXX_UNPROTECT
#include <click/cxxunprotect.h>
#endif

View File

@ -0,0 +1,153 @@
/*
* <clicknet/llc.h> - contains the definitions for llc frames.
* It was originally taken from freebsd and modified for click use.
* John Bicket
*/
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)if_llc.h 8.1 (Berkeley) 6/10/93
* $FreeBSD: src/sys/net/if_llc.h,v 1.7 1999/08/28 00:48:18 peter Exp $
*/
#ifndef CLICKNET_LLC_H
#define CLICKNET_LLC_H
/*
* IEEE 802.2 Link Level Control headers, for use in conjunction with
* 802.{3,4,5} media access control methods.
*
* Headers here do not use bit fields due to shortcomings in many
* compilers.
*/
struct click_llc {
uint8_t llc_dsap;
uint8_t llc_ssap;
union {
struct {
uint8_t control;
uint8_t format_id;
uint8_t _class;
uint8_t window_x2;
} type_u;
struct {
uint8_t num_snd_x2;
uint8_t num_rcv_x2;
} type_i;
struct {
uint8_t control;
uint8_t num_rcv_x2;
} type_s;
struct {
uint8_t control;
struct frmrinfo {
uint8_t rej_pdu_0;
uint8_t rej_pdu_1;
uint8_t frmr_control;
uint8_t frmr_control_ext;
uint8_t frmr_cause;
} frmrinfo;
} type_frmr;
struct {
uint8_t control;
uint8_t org_code[3];
uint16_t ether_type;
} type_snap;
struct {
uint8_t control;
uint8_t control_ext;
} type_raw;
} llc_un;
} CLICK_SIZE_PACKED_ATTRIBUTE;
#define llc_control llc_un.type_u.control
#define llc_control_ext llc_un.type_raw.control_ext
#define llc_fid llc_un.type_u.format_id
#define llc_class llc_un.type_u._class
#define llc_window llc_un.type_u.window_x2
#define llc_frmrinfo llc_un.type_frmr.frmrinfo
#define llc_frmr_pdu0 llc_un.type_frmr.frmrinfo.rej_pdu0
#define llc_frmr_pdu1 llc_un.type_frmr.frmrinfo.rej_pdu1
#define llc_frmr_control llc_un.type_frmr.frmrinfo.frmr_control
#define llc_frmr_control_ext llc_un.type_frmr.frmrinfo.frmr_control_ext
#define llc_frmr_cause llc_un.type_frmr.frmrinfo.frmr_control_ext
/*
* Don't use sizeof(struct llc_un) for LLC header sizes
*/
#define LLC_ISFRAMELEN 4
#define LLC_UFRAMELEN 3
#define LLC_FRMRLEN 7
/*
* Unnumbered LLC format commands
*/
#define LLC_UI 0x3
#define LLC_UI_P 0x13
#define LLC_DISC 0x43
#define LLC_DISC_P 0x53
#define LLC_UA 0x63
#define LLC_UA_P 0x73
#define LLC_TEST 0xe3
#define LLC_TEST_P 0xf3
#define LLC_FRMR 0x87
#define LLC_FRMR_P 0x97
#define LLC_DM 0x0f
#define LLC_DM_P 0x1f
#define LLC_XID 0xaf
#define LLC_XID_P 0xbf
#define LLC_SABME 0x6f
#define LLC_SABME_P 0x7f
/*
* Supervisory LLC commands
*/
#define LLC_RR 0x01
#define LLC_RNR 0x05
#define LLC_REJ 0x09
/*
* Info format - dummy only
*/
#define LLC_INFO 0x00
/*
* ISO PDTR 10178 contains among others
*/
#define LLC_IP_LSAP 0x06
#define LLC_X25_LSAP 0x7e
#define LLC_SNAP_LSAP 0xaa
#define LLC_ISO_LSAP 0xfe
#endif

View File

@ -0,0 +1,69 @@
#ifndef CLICKNET_PPP_H
#define CLICKNET_PPP_H
/*
* <clicknet/ppp.h> -- our own definition of the PPP header, borrowed from
* tcpdump
*
* Copyright 1989 by Carnegie Mellon.
*
* Permission to use, copy, modify, and distribute this program for any
* purpose and without fee is hereby granted, provided that this copyright
* and permission notice appear on all copies and supporting documentation,
* the name of Carnegie Mellon not be used in advertising or publicity
* pertaining to distribution of the program without specific prior
* permission, and notice be given in supporting documentation that copying
* and distribution is by permission of Carnegie Mellon and Stanford
* University. Carnegie Mellon makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#define PPP_ADDRESS 0xff /* The address byte value */
#define PPP_CONTROL 0x03 /* The control byte value */
/* Protocol numbers */
#define PPP_IP 0x0021 /* Raw IP */
#define PPP_OSI 0x0023 /* OSI Network Layer */
#define PPP_NS 0x0025 /* Xerox NS IDP */
#define PPP_DECNET 0x0027 /* DECnet Phase IV */
#define PPP_APPLE 0x0029 /* Appletalk */
#define PPP_IPX 0x002b /* Novell IPX */
#define PPP_VJC 0x002d /* Van Jacobson Compressed TCP/IP */
#define PPP_VJNC 0x002f /* Van Jacobson Uncompressed TCP/IP */
#define PPP_BRPDU 0x0031 /* Bridging PDU */
#define PPP_STII 0x0033 /* Stream Protocol (ST-II) */
#define PPP_VINES 0x0035 /* Banyan Vines */
#define PPP_IPV6 0x0057 /* IPv6 */
#define PPP_COMP 0x00fd /* Compressed Datagram */
#define PPP_HELLO 0x0201 /* 802.1d Hello Packets */
#define PPP_LUXCOM 0x0231 /* Luxcom */
#define PPP_SNS 0x0233 /* Sigma Network Systems */
#define PPP_MPLS_UCAST 0x0281 /* rfc 3032 */
#define PPP_MPLS_MCAST 0x0283 /* rfc 3022 */
#define PPP_IPCP 0x8021 /* IP Control Protocol */
#define PPP_OSICP 0x8023 /* OSI Network Layer Control Protocol */
#define PPP_NSCP 0x8025 /* Xerox NS IDP Control Protocol */
#define PPP_DECNETCP 0x8027 /* DECnet Control Protocol */
#define PPP_APPLECP 0x8029 /* Appletalk Control Protocol */
#define PPP_IPXCP 0x802b /* Novell IPX Control Protocol */
#define PPP_STIICP 0x8033 /* Strean Protocol Control Protocol */
#define PPP_VINESCP 0x8035 /* Banyan Vines Control Protocol */
#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
#define PPP_CCP 0x80fd /* Compress Control Protocol */
#define PPP_MPLSCP 0x8281 /* rfc 3022 */
#define PPP_LCP 0xc021 /* Link Control Protocol */
#define PPP_PAP 0xc023 /* Password Authentication Protocol */
#define PPP_LQM 0xc025 /* Link Quality Monitoring */
#define PPP_SPAP 0xc027
#define PPP_CHAP 0xc223 /* Challenge Handshake Authentication Protocol */
#define PPP_BACP 0xc02b /* Bandwidth Allocation Control Protocol */
#define PPP_BAP 0xc02d /* BAP */
#define PPP_MP 0xc03d /* Multi-Link */
#define PPP_SPAP_OLD 0xc123
#define PPP_EAP 0xc227
#endif

View File

@ -0,0 +1,249 @@
/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
/* $NetBSD: ieee80211_radiotap.h,v 1.10 2005/01/04 00:34:58 dyoung Exp $ */
/*-
* Copyright (c) 2003, 2004 David Young. 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.
* 3. The name of David Young may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``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 DAVID
* YOUNG 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 _NET_IF_IEEE80211RADIOTAP_H_
#define _NET_IF_IEEE80211RADIOTAP_H_
/* A generic radio capture format is desirable. There is one for
* Linux, but it is neither rigidly defined (there were not even
* units given for some fields) nor easily extensible.
*
* I suggest the following extensible radio capture format. It is
* based on a bitmap indicating which fields are present.
*
* I am trying to describe precisely what the application programmer
* should expect in the following, and for that reason I tell the
* units and origin of each measurement (where it applies), or else I
* use sufficiently weaselly language ("is a monotonically nondecreasing
* function of...") that I cannot set false expectations for lawyerly
* readers.
*/
#if defined(__KERNEL__) || defined(_KERNEL)
#ifndef DLT_IEEE802_11_RADIO
#define DLT_IEEE802_11_RADIO 127 /* 802.11 plus WLAN header */
#endif
#endif /* defined(__KERNEL__) || defined(_KERNEL) */
/* XXX tcpdump/libpcap do not tolerate variable-length headers,
* yet, so we pad every radiotap header to 64 bytes. Ugh.
*/
#define IEEE80211_RADIOTAP_HDRLEN 64
/* The radio capture header precedes the 802.11 header. */
struct ieee80211_radiotap_header {
u_int8_t it_version; /* Version 0. Only increases
* for drastic changes,
* introduction of compatible
* new fields does not count.
*/
u_int8_t it_pad;
u_int16_t it_len; /* length of the whole
* header in bytes, including
* it_version, it_pad,
* it_len, and data fields.
*/
u_int32_t it_present; /* A bitmap telling which
* fields are present. Set bit 31
* (0x80000000) to extend the
* bitmap by another 32 bits.
* Additional extensions are made
* by setting bit 31.
*/
} __attribute__((__packed__));
/* Name Data type Units
* ---- --------- -----
*
* IEEE80211_RADIOTAP_TSFT u_int64_t microseconds
*
* Value in microseconds of the MAC's 64-bit 802.11 Time
* Synchronization Function timer when the first bit of the
* MPDU arrived at the MAC. For received frames, only.
*
* IEEE80211_RADIOTAP_CHANNEL 2 x u_int16_t MHz, bitmap
*
* Tx/Rx frequency in MHz, followed by flags (see below).
*
* IEEE80211_RADIOTAP_FHSS u_int16_t see below
*
* For frequency-hopping radios, the hop set (first byte)
* and pattern (second byte).
*
* IEEE80211_RADIOTAP_RATE u_int8_t 500kb/s
*
* Tx/Rx data rate
*
* IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
* one milliwatt (dBm)
*
* RF signal power at the antenna, decibel difference from
* one milliwatt.
*
* IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from
* one milliwatt (dBm)
*
* RF noise power at the antenna, decibel difference from one
* milliwatt.
*
* IEEE80211_RADIOTAP_DB_ANTSIGNAL u_int8_t decibel (dB)
*
* RF signal power at the antenna, decibel difference from an
* arbitrary, fixed reference.
*
* IEEE80211_RADIOTAP_DB_ANTNOISE u_int8_t decibel (dB)
*
* RF noise power at the antenna, decibel difference from an
* arbitrary, fixed reference point.
*
* IEEE80211_RADIOTAP_LOCK_QUALITY u_int16_t unitless
*
* Quality of Barker code lock. Unitless. Monotonically
* nondecreasing with "better" lock strength. Called "Signal
* Quality" in datasheets. (Is there a standard way to measure
* this?)
*
* IEEE80211_RADIOTAP_TX_ATTENUATION u_int16_t unitless
*
* Transmit power expressed as unitless distance from max
* power set at factory calibration. 0 is max power.
* Monotonically nondecreasing with lower power levels.
*
* IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t decibels (dB)
*
* Transmit power expressed as decibel distance from max power
* set at factory calibration. 0 is max power. Monotonically
* nondecreasing with lower power levels.
*
* IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from
* one milliwatt (dBm)
*
* Transmit power expressed as dBm (decibels from a 1 milliwatt
* reference). This is the absolute power level measured at
* the antenna port.
*
* IEEE80211_RADIOTAP_FLAGS u_int8_t bitmap
*
* Properties of transmitted and received frames. See flags
* defined below.
*
* IEEE80211_RADIOTAP_ANTENNA u_int8_t antenna index
*
* Unitless indication of the Rx/Tx antenna for this packet.
* The first antenna is antenna 0.
*
* IEEE80211_RADIOTAP_RX_FLAGS u_int16_t bitmap
*
* Properties of received frames. See flags defined below.
*
* IEEE80211_RADIOTAP_TX_FLAGS u_int16_t bitmap
*
* Properties of transmitted frames. See flags defined below.
*
* IEEE80211_RADIOTAP_RTS_RETRIES u_int8_t data
*
* Number of rts retries a transmitted frame used.
*
* IEEE80211_RADIOTAP_DATA_RETRIES u_int8_t data
*
* Number of unicast retries a transmitted frame used.
*
*/
enum ieee80211_radiotap_type {
IEEE80211_RADIOTAP_TSFT = 0,
IEEE80211_RADIOTAP_FLAGS = 1,
IEEE80211_RADIOTAP_RATE = 2,
IEEE80211_RADIOTAP_CHANNEL = 3,
IEEE80211_RADIOTAP_FHSS = 4,
IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
IEEE80211_RADIOTAP_ANTENNA = 11,
IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
IEEE80211_RADIOTAP_RX_FLAGS = 14,
IEEE80211_RADIOTAP_TX_FLAGS = 15,
IEEE80211_RADIOTAP_RTS_RETRIES = 16,
IEEE80211_RADIOTAP_DATA_RETRIES = 17,
IEEE80211_RADIOTAP_XCHANNEL = 18,
IEEE80211_RADIOTAP_MCS = 19,
IEEE80211_RADIOTAP_A_MPDU_STATUS = 20,
IEEE80211_RADIOTAP_VHT = 21,
IEEE80211_RADIOTAP_EXT = 31
};
#if !defined(__KERNEL__) && !defined(_KERNEL)
/* Channel flags. */
#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
#endif /* !defined(__KERNEL__) && !defined(_KERNEL) */
/* For IEEE80211_RADIOTAP_FLAGS */
#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
* during CFP
*/
#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
* with short
* preamble
*/
#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
* with WEP encryption
*/
#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
* with fragmentation
*/
#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
* 802.11 header and payload
* (to 32-bit boundary)
*/
/* For IEEE80211_RADIOTAP_RX_FLAGS */
#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
/* For IEEE80211_RADIOTAP_TX_FLAGS */
#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive
* retries */
#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */
#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
#define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* Receiver will not ack */
#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */

View File

@ -0,0 +1,20 @@
/* -*- mode: c; c-basic-offset: 4 -*- */
#ifndef CLICKNET_RFC1483_H
#define CLICKNET_RFC1483_H
/*
* <clicknet/rfc1483.h>
*/
struct click_rfc1483 {
uint8_t dsap;
uint8_t ssap;
uint8_t ui;
uint8_t orgcode[3];
uint16_t ether_type;
};
#define RFC1483_SNAP_IP_EXPECTED "\xAA\xAA\x03\x00\x00\x00"
#define RFC1483_SNAP_IP_EXPECTED_LEN 6
#endif

View File

@ -0,0 +1,78 @@
/* -*- c-basic-offset: 4 -*- */
#ifndef CLICKNET_TCP_H
#define CLICKNET_TCP_H
/*
* <clicknet/tcp.h> -- TCP header definitions, based on one of the BSDs.
*
* Relevant RFCs include:
* RFC793 Transmission Control Protocol
* RFC1323 TCP Extensions for High Performance
* RFC2018 TCP Selective Acknowledgement Options
* RFC2581 TCP Congestion Control
* RFC2883 An Extension to the Selective Acknowledgement (SACK) Option
* for TCP
* RFC3168 The Addition of Explicit Congestion Notification (ECN) to IP
* RFC3540 Robust Explicit Congestion Notification (ECN) Signaling with
* Nonces
* among many others. See "A Roadmap for TCP Specification Documents",
* currently an Internet-Draft.
*/
typedef uint32_t tcp_seq_t;
struct click_tcp {
uint16_t th_sport; /* 0-1 source port */
uint16_t th_dport; /* 2-3 destination port */
tcp_seq_t th_seq; /* 4-7 sequence number */
tcp_seq_t th_ack; /* 8-11 acknowledgement number */
#if CLICK_BYTE_ORDER == CLICK_LITTLE_ENDIAN
unsigned th_flags2 : 4; /* 12 more flags */
unsigned th_off : 4; /* data offset in words */
#elif CLICK_BYTE_ORDER == CLICK_BIG_ENDIAN
unsigned th_off : 4; /* 12 data offset in words */
unsigned th_flags2 : 4; /* more flags */
#else
# error "unknown byte order"
#endif
#define TH_NS 0x01 /* in 'th_flags2' */
uint8_t th_flags; /* 13 flags */
#define TH_FIN 0x01
#define TH_SYN 0x02
#define TH_RST 0x04
#define TH_PUSH 0x08
#define TH_ACK 0x10
#define TH_URG 0x20
#define TH_ECE 0x40
#define TH_CWR 0x80
uint16_t th_win; /* 14-15 window */
uint16_t th_sum; /* 16-17 checksum */
uint16_t th_urp; /* 18-19 urgent pointer */
};
/*
* TCP sequence number comparisons
*/
#define SEQ_LT(x,y) ((int)((x)-(y)) < 0)
#define SEQ_LEQ(x,y) ((int)((x)-(y)) <= 0)
#define SEQ_GT(x,y) ((int)((x)-(y)) > 0)
#define SEQ_GEQ(x,y) ((int)((x)-(y)) >= 0)
/*
* TCP options
*/
#define TCPOPT_EOL 0
#define TCPOPT_NOP 1
#define TCPOPT_MAXSEG 2
#define TCPOLEN_MAXSEG 4
#define TCPOPT_WSCALE 3
#define TCPOLEN_WSCALE 3
#define TCPOPT_SACK_PERMITTED 4
#define TCPOLEN_SACK_PERMITTED 2
#define TCPOPT_SACK 5
#define TCPOPT_TIMESTAMP 8
#define TCPOLEN_TIMESTAMP 10
#endif

View File

@ -0,0 +1,18 @@
#ifndef CLICKNET_UDP_H
#define CLICKNET_UDP_H
/*
* <clicknet/udp.h> -- UDP header definitions, based on one of the BSDs.
*
* Relevant RFCs include:
* RFC768 User Datagram Protocol
*/
struct click_udp {
uint16_t uh_sport; /* 0-1 source port */
uint16_t uh_dport; /* 2-3 destination port */
uint16_t uh_ulen; /* 4-5 UDP length */
uint16_t uh_sum; /* 6-7 checksum */
};
#endif

View File

@ -0,0 +1,409 @@
/*
* <clicknet/wifi.h> - contains the definitions for 802.11 frames.
* It was originally taken from freebsd and modified for click use.
* John Bicket
*/
/* $NetBSD: if_ieee80211.h,v 1.5 2000/07/21 04:47:40 onoe Exp $ */
/* $FreeBSD: src/sys/net/if_ieee80211.h,v 1.3.2.3 2001/07/04 00:12:38 brooks Exp $ */
#ifndef _CLICKNET_WIFI_H_
#define _CLICKNET_WIFI_H_
#define WIFI_EXTRA_MAGIC 0x7492001
enum {
WIFI_EXTRA_TX = (1<<0), /* packet transmission */
WIFI_EXTRA_TX_FAIL = (1<<1), /* transmission failed */
WIFI_EXTRA_TX_USED_ALT_RATE = (1<<2), /* used alternate bitrate */
WIFI_EXTRA_RX_ERR = (1<<3), /* failed crc check */
WIFI_EXTRA_RX_MORE = (1<<4), /* first part of a fragmented skb */
WIFI_EXTRA_NO_SEQ = (1<<5),
WIFI_EXTRA_NO_TXF = (1<<6),
WIFI_EXTRA_DO_RTS_CTS = (1<<7),
WIFI_EXTRA_DO_CTS = (1<<8),
WIFI_EXTRA_TX_NOACK = (1<<9)
};
struct click_wifi_extra {
uint32_t magic;
uint32_t flags;
uint8_t rssi;
uint8_t silence;
uint8_t power;
uint8_t pad;
uint8_t rate; /* bitrate in Mbps*2 */
uint8_t rate1; /* bitrate in Mbps*2 */
uint8_t rate2; /* bitrate in Mbps*2 */
uint8_t rate3; /* bitrate in Mbps*2 */
uint8_t max_tries;
uint8_t max_tries1;
uint8_t max_tries2;
uint8_t max_tries3;
uint8_t virt_col;
uint8_t retries;
uint16_t len;
} CLICK_SIZE_PACKED_ATTRIBUTE;
/*
* generic definitions for IEEE 802.11 frames
*/
#define WIFI_ADDR_LEN 6
struct click_wifi {
uint8_t i_fc[2];
uint16_t i_dur;
uint8_t i_addr1[WIFI_ADDR_LEN];
uint8_t i_addr2[WIFI_ADDR_LEN];
uint8_t i_addr3[WIFI_ADDR_LEN];
uint16_t i_seq;
} CLICK_SIZE_PACKED_ATTRIBUTE;
#define WIFI_FC0_VERSION_MASK 0x03
#define WIFI_FC0_VERSION_0 0x00
#define WIFI_FC0_TYPE_MASK 0x0c
#define WIFI_FC0_TYPE_MGT 0x00
#define WIFI_FC0_TYPE_CTL 0x04
#define WIFI_FC0_TYPE_DATA 0x08
#define WIFI_FC0_SUBTYPE_MASK 0xf0
/* for TYPE_MGT */
#define WIFI_FC0_SUBTYPE_ASSOC_REQ 0x00
#define WIFI_FC0_SUBTYPE_ASSOC_RESP 0x10
#define WIFI_FC0_SUBTYPE_REASSOC_REQ 0x20
#define WIFI_FC0_SUBTYPE_REASSOC_RESP 0x30
#define WIFI_FC0_SUBTYPE_PROBE_REQ 0x40
#define WIFI_FC0_SUBTYPE_PROBE_RESP 0x50
#define WIFI_FC0_SUBTYPE_BEACON 0x80
#define WIFI_FC0_SUBTYPE_ATIM 0x90
#define WIFI_FC0_SUBTYPE_DISASSOC 0xa0
#define WIFI_FC0_SUBTYPE_AUTH 0xb0
#define WIFI_FC0_SUBTYPE_DEAUTH 0xc0
/* for TYPE_CTL */
#define WIFI_FC0_SUBTYPE_PS_POLL 0xa0
#define WIFI_FC0_SUBTYPE_RTS 0xb0
#define WIFI_FC0_SUBTYPE_CTS 0xc0
#define WIFI_FC0_SUBTYPE_ACK 0xd0
#define WIFI_FC0_SUBTYPE_CF_END 0xe0
#define WIFI_FC0_SUBTYPE_CF_END_ACK 0xf0
/* for TYPE_DATA (bit combination) */
#define WIFI_FC0_SUBTYPE_DATA 0x00
#define WIFI_FC0_SUBTYPE_CF_ACK 0x10
#define WIFI_FC0_SUBTYPE_CF_POLL 0x20
#define WIFI_FC0_SUBTYPE_CF_ACPL 0x30
#define WIFI_FC0_SUBTYPE_NODATA 0x40
#define WIFI_FC0_SUBTYPE_CFACK 0x50
#define WIFI_FC0_SUBTYPE_CFPOLL 0x60
#define WIFI_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
#define WIFI_FC0_SUBTYPE_QOS 0x80
#define WIFI_FC0_SUBTYPE_QOS_NULL 0xc0
#define WIFI_FC1_DIR_MASK 0x03
#define WIFI_FC1_DIR_NODS 0x00 /* STA->STA */
#define WIFI_FC1_DIR_TODS 0x01 /* STA->AP */
#define WIFI_FC1_DIR_FROMDS 0x02 /* AP ->STA */
#define WIFI_FC1_DIR_DSTODS 0x03 /* AP ->AP */
#define WIFI_FC1_MORE_FRAG 0x04
#define WIFI_FC1_RETRY 0x08
#define WIFI_FC1_PWR_MGT 0x10
#define WIFI_FC1_MORE_DATA 0x20
#define WIFI_FC1_WEP 0x40
#define WIFI_FC1_ORDER 0x80
#define WIFI_NWID_LEN 32
/*
* BEACON management packets
*
* octect timestamp[8]
* octect beacon interval[2]
* octect capability information[2]
* information element
* octect elemid
* octect length
* octect information[length]
*/
typedef uint8_t * wifi_mgt_beacon_t;
#define WIFI_BEACON_INTERVAL(beacon) \
(beacon[8] + (beacon[9] << 8))
#define WIFI_BEACON_CAPABILITY(beacon) \
(beacon[10] + (beacon[11] << 8))
#define WIFI_CAPINFO_ESS 0x01
#define WIFI_CAPINFO_IBSS 0x02
#define WIFI_CAPINFO_CF_POLLABLE 0x04
#define WIFI_CAPINFO_CF_POLLREQ 0x08
#define WIFI_CAPINFO_PRIVACY 0x10
#define WIFI_MAX_RETRIES 11
#define WIFI_QOS_HAS_SEQ(wh) \
(((wh)->i_fc[0] & \
(WIFI_FC0_TYPE_MASK | WIFI_FC0_SUBTYPE_QOS)) == \
(WIFI_FC0_TYPE_DATA | WIFI_FC0_SUBTYPE_QOS))
/*
* Management information elements
*/
struct wifi_information {
char ssid[WIFI_NWID_LEN+1];
struct rates {
uint8_t *p;
} rates;
struct fh {
uint16_t dwell;
uint8_t set;
uint8_t pattern;
uint8_t index;
} fh;
struct ds {
uint8_t channel;
} ds;
struct cf {
uint8_t count;
uint8_t period;
uint8_t maxdur[2];
uint8_t dur[2];
} cf;
struct tim {
uint8_t count;
uint8_t period;
uint8_t bitctl;
/* uint8_t pvt[251]; The driver never needs to use this */
} tim;
struct ibss {
uint16_t atim;
} ibss;
struct challenge {
uint8_t *p;
uint8_t len;
} challenge;
};
#define WIFI_RATES_MAXSIZE 15
#define WIFI_NWID_MAXSIZE 32
enum {
WIFI_ELEMID_SSID = 0,
WIFI_ELEMID_RATES = 1,
WIFI_ELEMID_FHPARMS = 2,
WIFI_ELEMID_DSPARMS = 3,
WIFI_ELEMID_CFPARMS = 4,
WIFI_ELEMID_TIM = 5,
WIFI_ELEMID_IBSSPARMS = 6,
WIFI_ELEMID_CHALLENGE = 16,
WIFI_ELEMID_ERP = 42,
WIFI_ELEMID_XRATES = 50,
WIFI_ELEMID_VENDOR = 221
};
/*
* AUTH management packets
*
* octect algo[2]
* octect seq[2]
* octect status[2]
* octect chal.id
* octect chal.length
* octect chal.text[253]
*/
typedef uint8_t * wifi_mgt_auth_t;
#define WIFI_AUTH_ALGORITHM(auth) \
(auth[0] + (auth[1] << 8))
#define WIFI_AUTH_TRANSACTION(auth) \
(auth[2] + (auth[3] << 8))
#define WIFI_AUTH_STATUS(auth) \
(auth[4] + (auth[5] << 8))
#define WIFI_AUTH_ALG_OPEN 0x0000
#define WIFI_AUTH_ALG_SHARED 0x0001
#define WIFI_AUTH_OPEN_REQUEST 1
#define WIFI_AUTH_OPEN_RESPONSE 2
#define WIFI_AUTH_SHARED_REQUEST 1
#define WIFI_AUTH_SHARED_CHALLENGE 2
#define WIFI_AUTH_SHARED_RESPONSE 3
#define WIFI_AUTH_SHARED_PASS 4
/*
* Reason codes
*
* Unlisted codes are reserved
*/
#define WIFI_REASON_UNSPECIFIED 1
#define WIFI_REASON_AUTH_EXPIRE 2
#define WIFI_REASON_AUTH_LEAVE 3
#define WIFI_REASON_ASSOC_EXPIRE 4
#define WIFI_REASON_ASSOC_TOOMANY 5
#define WIFI_REASON_NOT_AUTHED 6
#define WIFI_REASON_NOT_ASSOCED 7
#define WIFI_REASON_ASSOC_LEAVE 8
#define WIFI_REASON_ASSOC_NOT_AUTHED 9
/*
* Status code
*
* Unlisted codes are reserved
*/
#define WIFI_STATUS_SUCCESS 0x0000
#define WIFI_STATUS_UNSPECIFIED 1
#define WIFI_STATUS_CAPINFO 10
#define WIFI_STATUS_NOT_ASSOCED 11
#define WIFI_STATUS_OTHER 12
#define WIFI_STATUS_ALG 13
#define WIFI_STATUS_SEQUENCE 14
#define WIFI_STATUS_CHALLENGE 15
#define WIFI_STATUS_TIMEOUT 16
#define WIFI_STATUS_BASIC_RATES 18
#define WIFI_STATUS_TOO_MANY_STATIONS 22
#define WIFI_STATUS_RATES 23
#define WIFI_STATUS_SHORTSLOT_REQUIRED 25
#define WIFI_WEP_KEYLEN 5 /* 40bit */
#define WIFI_WEP_IVLEN 3 /* 24bit */
#define WIFI_WEP_KIDLEN 1 /* 1 octet */
#define WIFI_WEP_CRCLEN 4 /* CRC-32 */
#define WIFI_WEP_NKID 4 /* number of key ids */
#define WIFI_WEP_HEADERSIZE (WIFI_WEP_IVLEN + WIFI_WEP_KIDLEN)
#define WIFI_WEP_NOSUP -1
#define WIFI_WEP_OFF 0
#define WIFI_WEP_ON 1
#define WIFI_WEP_MIXED 2
#define WIFI_AUTH_NONE 0
#define WIFI_AUTH_OPEN 1
#define WIFI_AUTH_SHARED 2
#define WIFI_POWERSAVE_NOSUP -1
#define WIFI_POWERSAVE_OFF 0
#define WIFI_POWERSAVE_CAM 1
#define WIFI_POWERSAVE_PSP 2
#define WIFI_POWERSAVE_PSP_CAM 3
#define WIFI_POWERSAVE_ON WIFI_POWERSAVE_CAM
#define WIFI_RATE_BASIC 0x80
#define WIFI_RATE_VAL 0x7f
#define WIFI_RATE_SIZE 0x08
#define WIFI_SEQ_FRAG_MASK 0x000f
#define WIFI_SEQ_FRAG_SHIFT 0
#define WIFI_SEQ_SEQ_MASK 0xfff0
#define WIFI_SEQ_SEQ_SHIFT 4
/*
* 802.11 protocol crypto-related definitions.
*/
#define WIFI_KEYBUF_SIZE 16
#define WIFI_MICBUF_SIZE (8+8) /* space for both tx+rx keys */
#ifndef WIFI_MAX
#define WIFI_MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef WIFI_MIN
#define WIFI_MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header
* (from linux-wlan-ng) */
/*
* For packet capture, define the same physical layer packet header
* structure as used in the wlan-ng driver
*/
enum {
DIDmsg_lnxind_wlansniffrm = 0x00000044,
DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044,
DIDmsg_lnxind_wlansniffrm_mactime = 0x00020044,
DIDmsg_lnxind_wlansniffrm_channel = 0x00030044,
DIDmsg_lnxind_wlansniffrm_rssi = 0x00040044,
DIDmsg_lnxind_wlansniffrm_sq = 0x00050044,
DIDmsg_lnxind_wlansniffrm_signal = 0x00060044,
DIDmsg_lnxind_wlansniffrm_noise = 0x00070044,
DIDmsg_lnxind_wlansniffrm_rate = 0x00080044,
DIDmsg_lnxind_wlansniffrm_istx = 0x00090044,
DIDmsg_lnxind_wlansniffrm_frmlen = 0x000A0044
};
enum {
P80211ENUM_msgitem_status_no_value = 0x00
};
enum {
P80211ENUM_truth_false = 0x00
};
typedef struct {
uint32_t did;
uint16_t status;
uint16_t len;
uint32_t data;
} p80211item_uint32_t;
typedef struct {
uint32_t msgcode;
uint32_t msglen;
#define WLAN_DEVNAMELEN_MAX 16
uint8_t devname[WLAN_DEVNAMELEN_MAX];
p80211item_uint32_t hosttime;
p80211item_uint32_t mactime;
p80211item_uint32_t channel;
p80211item_uint32_t rssi;
p80211item_uint32_t sq;
p80211item_uint32_t signal;
p80211item_uint32_t noise;
p80211item_uint32_t rate;
p80211item_uint32_t istx;
p80211item_uint32_t frmlen;
} wlan_ng_prism2_header;
#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */
#define LWNG_CAPHDR_VERSION 0x80211001
#define WIFI_SLOT_B 20
#define WIFI_DIFS_B 50
#define WIFI_SIFS_B 10
#define WIFI_ACK_B 304
#define WIFI_PLCP_HEADER_LONG_B 192
#define WIFI_PLCP_HEADER_SHORT_B 192
#define WIFI_SLOT_A 9
#define WIFI_DIFS_A 28
#define WIFI_SIFS_A 9
#define WIFI_ACK_A 30
#define WIFI_PLCP_HEADER_A 20
#define is_b_rate(b) ((b == 2) || (b == 4) || (b == 11) || (b == 22))
#define WIFI_CW_MIN 31
#define WIFI_CW_MAX 1023
// 6-byte LLC header (last byte is terminating NUL)
#define WIFI_LLC_HEADER ((const uint8_t *) "\xAA\xAA\x03\x00\x00")
#define WIFI_LLC_HEADER_LEN 6
#endif /* !_CLICKNET_WIFI_H_ */