/** @file wlan_mac_eth_util.h * @brief Ethernet Framework * * Contains code for using Ethernet, including encapsulation and de-encapsulation. * * @copyright Copyright 2013-2019, Mango Communications. All rights reserved. * Distributed under the Mango Communications Reference Design License * See LICENSE.txt included in the design archive or * at http://mangocomm.com/802.11/license * * This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11) */ #ifndef WLAN_MAC_ETH_UTIL_H_ #define WLAN_MAC_ETH_UTIL_H_ /***************************** Include Files *********************************/ #include "wlan_mac_high_sw_config.h" #include "wlan_high_types.h" // Forward declarations struct eth_rx_queue_buffer_t; struct tx_queue_buffer_t; #define PORTAL_MAX_QUEUE_LEN 50 //----------------------------------------------- // Magic numbers used for Ethernet/IP/UDP/DHCP/ARP packet interpretation // #define DHCP_BOOTP_FLAGS_BROADCAST 0x8000 #define DHCP_MAGIC_COOKIE 0x63825363 #define DHCP_OPTION_TAG_TYPE 53 #define DHCP_OPTION_TYPE_DISCOVER 1 #define DHCP_OPTION_TYPE_OFFER 2 #define DHCP_OPTION_TYPE_REQUEST 3 #define DHCP_OPTION_TYPE_ACK 5 #define DHCP_OPTION_TAG_IDENTIFIER 61 #define DHCP_OPTION_END 255 #define DHCP_HOST_NAME 12 #define IPV4_PROT_UDP 0x11 #define UDP_SRC_PORT_BOOTPC 68 #define UDP_SRC_PORT_BOOTPS 67 #define ETH_TYPE_ARP 0x0608 #define ETH_TYPE_IP 0x0008 #define LLC_SNAP 0xAA #define LLC_CNTRL_UNNUMBERED 0x03 #define LLC_TYPE_ARP 0x0608 #define LLC_TYPE_IP 0x0008 #define LLC_TYPE_WLAN_LTG 0x9090 // Non-standard type for LTG packets #define WLAN_MAX_ETH_RX_PROCESS_PER_ISR 2 #define WLAN_MAX_ETH_TX_PROCESS_PER_ISR 1 /*********************** Global Structure Definitions ************************/ // The struct definitions below are used to interpret packet payloads. The // code never creates instances of these structs typedef struct dhcp_packet{ u8 op; u8 htype; u8 hlen; u8 hops; u32 xid; u16 secs; u16 flags; u8 ciaddr[4]; u8 yiaddr[4]; u8 siaddr[4]; u8 giaddr[4]; u8 chaddr[MAC_ADDR_LEN]; u8 chaddr_padding[10]; u8 padding[192]; u32 magic_cookie; } dhcp_packet; #define WLAN_ETH_ENCAP_FLAGS_OVERWRITE_PYLD_ADDRS 0x00000001 /*************************** Function Prototypes *****************************/ int wlan_eth_util_init(); struct tx_queue_buffer_t* wlan_eth_encap( struct eth_rx_queue_buffer_t* eth_rx_queue_buffer, u32 flags ); void wlan_mac_util_set_eth_rx_callback(void(*callback)()); int wlan_enqueue_eth_rx(struct eth_rx_queue_buffer_t* eth_rx_queue_buffer); int wlan_enqueue_eth_tx(dl_entry* queue_entry); u32 wlan_poll_eth_rx_queue(); u32 wlan_poll_eth_tx_queue(); int wlan_eth_decap_and_send( u8* rx_mac_payload, u8* addr_da, u8* addr_sa, u16 rx_length, u32 flags ); void wlan_eth_portal_en(u8 enable); int wlan_process_eth_rx(struct eth_rx_queue_buffer_t* eth_rx_queue_buffer); #endif /* WLAN_MAC_ETH_UTIL_H_ */