source: ReferenceDesigns/w3_802.11/c/wlan_mac_high_framework/include/wlan_high_types.h

Last change on this file was 6319, checked in by chunter, 5 years ago

1.8.0 release wlan-mac-se

File size: 6.2 KB
Line 
1#ifndef WLAN_HIGH_TYPES_H_
2#define WLAN_HIGH_TYPES_H_
3
4#include "wlan_common_types.h"
5
6#define ETH_ADDR_SIZE 6 // Length of Ethernet MAC address (in bytes)
7#define IP_ADDR_SIZE 4 // Length of IP address (in bytes)
8
9typedef enum application_role_t{
10    APPLICATION_ROLE_AP         = 1,
11    APPLICATION_ROLE_STA        = 2,
12    APPLICATION_ROLE_IBSS       = 3,
13    APPLICATION_ROLE_UNKNOWN    = 0xFF
14} application_role_t;
15
16/********************************************************************
17 * @brief Channel Type Enum
18 *
19 * This enum described the type of channel that is specified in the
20 * chan_spec_t struct. The size of an enum is compiler dependent. Because
21 * this enum will be used in structs whose contents must be aligned with
22 * wlan_exp in Python, we use a compile time assertion to at least create
23 * a compilation error if the size winds up being different than wlan_exp
24 * expects.
25 *
26 ********************************************************************/
27typedef enum __attribute__((__packed__)) {
28    CHAN_TYPE_BW20 = 0,
29    CHAN_TYPE_BW40_SEC_BELOW = 1,
30    CHAN_TYPE_BW40_SEC_ABOVE = 2
31} chan_type_t;
32ASSERT_TYPE_SIZE(chan_type_t, 1);
33
34/********************************************************************
35 * @brief Channel Specifications Struct
36 *
37 * This struct contains a primary channel number and a chan_type_t.
38 * Together, this tuple of information can be used to calculate the
39 * center frequency and bandwidth of the radio.
40 ********************************************************************/
41typedef struct __attribute__((__packed__)){
42    u8             chan_pri;
43    chan_type_t    chan_type;
44} chan_spec_t;
45ASSERT_TYPE_SIZE(chan_spec_t, 2);
46
47// Scan FSM states
48typedef enum scan_state_t{
49    SCAN_IDLE,
50    SCAN_RUNNING,
51    SCAN_PAUSED
52} scan_state_t;
53
54
55// Interrupt controller started/stopped state
56typedef enum interrupt_state_t{
57    INTERRUPTS_DISABLED,
58    INTERRUPTS_ENABLED
59} interrupt_state_t;
60
61// Ethernet header
62typedef struct ethernet_header_t{
63    u8 dest_mac_addr[ETH_ADDR_SIZE];                      // Destination MAC address
64    u8 src_mac_addr[ETH_ADDR_SIZE];                       // Source MAC address
65    u16 ethertype;                                        // EtherType
66} ethernet_header_t;
67
68// IPv4 Header
69typedef struct ipv4_header_t{
70    u8                       version_ihl;                                      // [7:4] Version; [3:0] Internet Header Length
71    u8                       dscp_ecn;                                         // [7:2] Differentiated Services Code Point; [1:0] Explicit Congestion Notification
72    u16                      total_length;                                     // Total Length (includes header and data - in bytes)
73    u16                      identification;                                   // Identification
74    u16                      fragment_offset;                                  // [15:14] Flags;   [13:0] Fragment offset
75    u8                       ttl;                                              // Time To Live
76    u8                       protocol;                                         // Protocol
77    u16                      header_checksum;                                  // IP header checksum
78    u8                       src_ip_addr[IP_ADDR_SIZE];                        // Source IP address (big endian)
79    u8                       dest_ip_addr[IP_ADDR_SIZE];                       // Destination IP address (big endian)
80} ipv4_header_t;
81
82// UDP Header
83typedef struct udp_header_t{
84    u16                      src_port;                                         // Source port number
85    u16                      dest_port;                                        // Destination port number
86    u16                      length;                                           // Length of UDP header and UDP data (in bytes)
87    u16                      checksum;                                         // Checksum
88} udp_header_t;
89
90// wlan_exp Transport Header
91typedef struct wlan_exp_transport_header{
92    u16                      dest_id;                      // Destination ID
93    u16                      src_id;                       // Source ID
94    u16                      length;                       // Length of the Packet
95    u16                      seq_num;                      // Sequence Number
96    u16                      flags;                        // Transport flags
97} wlan_exp_transport_header;
98
99// ARP Packet
100typedef struct arp_ipv4_packet_t{
101    u16                      htype;                                            // Hardware Type
102    u16                      ptype;                                            // Protocol Type
103    u8                       hlen;                                             // Length of Hardware address
104    u8                       plen;                                             // Length of Protocol address
105    u16                      oper;                                             // Operation
106    u8                       sender_haddr[ETH_ADDR_SIZE];                       // Sender hardware address
107    u8                       sender_paddr[IP_ADDR_SIZE];                        // Sender protocol address
108    u8                       target_haddr[ETH_ADDR_SIZE];                       // Target hardware address
109    u8                       target_paddr[IP_ADDR_SIZE];                        // Target protocol address
110} arp_ipv4_packet_t;
111
112// Socket address structure
113typedef struct __attribute__((__packed__)) sockaddr_t {
114    u16 sa_family;
115    u8 sa_data[14];
116} sockaddr_t;
117ASSERT_TYPE_SIZE(sockaddr_t, 16);
118
119// Internet (IP) address structure
120typedef struct __attribute__((__packed__)) in_addr_t {
121   u8 s_addr[IP_ADDR_LEN];
122} in_addr_t;
123
124// Internet (IP) socket address structure
125typedef struct __attribute__((__packed__)) sockaddr_in_t {
126    u16 sin_family;
127    u16 sin_port;
128    in_addr_t sin_addr;
129    u8 sin_zero[8];
130} sockaddr_in_t;
131ASSERT_TYPE_SIZE(sockaddr_in_t, 16);
132
133
134// Function pointer type (void return, 1 argument) for Interrupt Service Routines
135//  axi_intc and ps_gic use compatible types but different names for interrupt handlers
136typedef void (*wlan_intr_handler_t)(void *data);
137
138#endif /* WLAN_HIGH_TYPES_H_ */
Note: See TracBrowser for help on using the repository browser.