[6319] | 1 | /** @file wlan_mac_eth_util.h |
---|
| 2 | * @brief Ethernet Framework |
---|
| 3 | * |
---|
| 4 | * Contains code for using Ethernet, including encapsulation and de-encapsulation. |
---|
| 5 | * |
---|
| 6 | * @copyright Copyright 2013-2019, Mango Communications. All rights reserved. |
---|
| 7 | * Distributed under the Mango Communications Reference Design License |
---|
| 8 | * See LICENSE.txt included in the design archive or |
---|
| 9 | * at http://mangocomm.com/802.11/license |
---|
| 10 | * |
---|
| 11 | * This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11) |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | #ifndef WLAN_MAC_ETH_UTIL_H_ |
---|
| 15 | #define WLAN_MAC_ETH_UTIL_H_ |
---|
| 16 | |
---|
| 17 | /***************************** Include Files *********************************/ |
---|
| 18 | #include "wlan_mac_high_sw_config.h" |
---|
| 19 | #include "wlan_high_types.h" |
---|
| 20 | |
---|
| 21 | // Forward declarations |
---|
| 22 | struct eth_rx_queue_buffer_t; |
---|
| 23 | struct tx_queue_buffer_t; |
---|
| 24 | |
---|
| 25 | #define PORTAL_MAX_QUEUE_LEN 50 |
---|
| 26 | |
---|
| 27 | //----------------------------------------------- |
---|
| 28 | // Magic numbers used for Ethernet/IP/UDP/DHCP/ARP packet interpretation |
---|
| 29 | // |
---|
| 30 | #define DHCP_BOOTP_FLAGS_BROADCAST 0x8000 |
---|
| 31 | #define DHCP_MAGIC_COOKIE 0x63825363 |
---|
| 32 | #define DHCP_OPTION_TAG_TYPE 53 |
---|
| 33 | #define DHCP_OPTION_TYPE_DISCOVER 1 |
---|
| 34 | #define DHCP_OPTION_TYPE_OFFER 2 |
---|
| 35 | #define DHCP_OPTION_TYPE_REQUEST 3 |
---|
| 36 | #define DHCP_OPTION_TYPE_ACK 5 |
---|
| 37 | #define DHCP_OPTION_TAG_IDENTIFIER 61 |
---|
| 38 | #define DHCP_OPTION_END 255 |
---|
| 39 | #define DHCP_HOST_NAME 12 |
---|
| 40 | |
---|
| 41 | #define IPV4_PROT_UDP 0x11 |
---|
| 42 | |
---|
| 43 | #define UDP_SRC_PORT_BOOTPC 68 |
---|
| 44 | #define UDP_SRC_PORT_BOOTPS 67 |
---|
| 45 | |
---|
| 46 | #define ETH_TYPE_ARP 0x0608 |
---|
| 47 | #define ETH_TYPE_IP 0x0008 |
---|
| 48 | |
---|
| 49 | #define LLC_SNAP 0xAA |
---|
| 50 | #define LLC_CNTRL_UNNUMBERED 0x03 |
---|
| 51 | #define LLC_TYPE_ARP 0x0608 |
---|
| 52 | #define LLC_TYPE_IP 0x0008 |
---|
| 53 | #define LLC_TYPE_WLAN_LTG 0x9090 // Non-standard type for LTG packets |
---|
| 54 | |
---|
| 55 | #define WLAN_MAX_ETH_RX_PROCESS_PER_ISR 2 |
---|
| 56 | |
---|
| 57 | #define WLAN_MAX_ETH_TX_PROCESS_PER_ISR 1 |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | /*********************** Global Structure Definitions ************************/ |
---|
| 61 | |
---|
| 62 | // The struct definitions below are used to interpret packet payloads. The |
---|
| 63 | // code never creates instances of these structs |
---|
| 64 | |
---|
| 65 | typedef struct dhcp_packet{ |
---|
| 66 | u8 op; |
---|
| 67 | u8 htype; |
---|
| 68 | u8 hlen; |
---|
| 69 | u8 hops; |
---|
| 70 | u32 xid; |
---|
| 71 | u16 secs; |
---|
| 72 | u16 flags; |
---|
| 73 | u8 ciaddr[4]; |
---|
| 74 | u8 yiaddr[4]; |
---|
| 75 | u8 siaddr[4]; |
---|
| 76 | u8 giaddr[4]; |
---|
| 77 | u8 chaddr[MAC_ADDR_LEN]; |
---|
| 78 | u8 chaddr_padding[10]; |
---|
| 79 | u8 padding[192]; |
---|
| 80 | u32 magic_cookie; |
---|
| 81 | } dhcp_packet; |
---|
| 82 | |
---|
| 83 | #define WLAN_ETH_ENCAP_FLAGS_OVERWRITE_PYLD_ADDRS 0x00000001 |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | /*************************** Function Prototypes *****************************/ |
---|
| 87 | |
---|
| 88 | int wlan_eth_util_init(); |
---|
| 89 | |
---|
| 90 | struct tx_queue_buffer_t* wlan_eth_encap( struct eth_rx_queue_buffer_t* eth_rx_queue_buffer, u32 flags ); |
---|
| 91 | |
---|
| 92 | void wlan_mac_util_set_eth_rx_callback(void(*callback)()); |
---|
| 93 | int wlan_enqueue_eth_rx(struct eth_rx_queue_buffer_t* eth_rx_queue_buffer); |
---|
| 94 | int wlan_enqueue_eth_tx(dl_entry* queue_entry); |
---|
| 95 | u32 wlan_poll_eth_rx_queue(); |
---|
| 96 | u32 wlan_poll_eth_tx_queue(); |
---|
| 97 | |
---|
| 98 | int wlan_eth_decap_and_send( u8* rx_mac_payload, |
---|
| 99 | u8* addr_da, |
---|
| 100 | u8* addr_sa, |
---|
| 101 | u16 rx_length, |
---|
| 102 | u32 flags ); |
---|
| 103 | |
---|
| 104 | void wlan_eth_portal_en(u8 enable); |
---|
| 105 | |
---|
| 106 | int wlan_process_eth_rx(struct eth_rx_queue_buffer_t* eth_rx_queue_buffer); |
---|
| 107 | |
---|
| 108 | #endif /* WLAN_MAC_ETH_UTIL_H_ */ |
---|