net_device.h

Overview

Related Modules:

WLAN

Description:

Defines WLAN network device interfaces.

This module provides network device operations for driver development. The operations are as follows: Initializes, adds, obtains, and deletes a network device. Reports network data, informs the network layer of the data link layer status, sets IP addresses, and starts or stops Dynamic Host Configuration Protocol (DHCP).

Since:

1.0

Version:

1.0

Summary

Data Structures

Data Structure Name Description
EtherHeader Defines the Ethernet header information of a data frame, including the destination address, source address, and Ethernet type.
IpHeader Defines the IP header information of a data frame, including the version number, service type, and total length.
UdpHeader Defines the UDP header information of a data frame, including the source port number and destination port number.
TcpHeader Defines the TCP header information of a data frame, including the source port number and destination port number.
IpV4Addr Defines an IPv4 address.
NetDevNotify Defines a network device notification, including an IP address and the notification type.
IfType Defines the network port type, for example, the WLAN network port.
IfReq Defines ioctrl data.
NetDevice Defines a network device, including the network interface category and name, and network port type.
NetDeviceInterFace Defines interfaces that need to be implemented externally by network devices, including initializing, opening, and closing a network device.

Macros

Macro Name and Value Description
MAC_ADDR_SIZE   6 Indicates a 6-byte MAC address.
NET_DEVICE_IFF_RUNNING   IFF_RUNNING Indicates that the network port is working.
ETHER_TYPE_RARP   0x8035 Indicates Reverse Address Resolution Protocol (RARP).
ETHER_TYPE_PAE   0x888e Indicates Port Access Entity (PAE).
ETHER_TYPE_IP   0x0800 Indicates Internet Protocol (IP).
ETHER_TYPE_AARP   0x80f3 Indicates AppleTalk Address Resolution Protocol (AARP).
ETHER_TYPE_IPX   0x8137 Indicates Internetwork Packet Exchange (IPX).
ETHER_TYPE_ARP   0x0806 Indicates Address Resolution Protocol (ARP).
ETHER_TYPE_IPV6   0x86dd Indicates Internet Protocol version 6 (IPv6).
ETHER_TYPE_TDLS   0x890d Indicates Tunneled Direct Link Setup (TDLS).
ETHER_TYPE_VLAN   0x8100 Indicates Virtual Local Area Network (VLAN).
ETHER_TYPE_WAI   0x88b4 Indicates WLAN Authentication and Privacy Infrastructure (WAPI).
ETHER_LLTD_TYPE   0x88D9 Indicates Link Layer Topology Discovery (LLTD).
ETHER_ONE_X_TYPE   0x888E Indicates 802.1x network port authentication.
ETHER_TUNNEL_TYPE   0x88bd Indicates a tunnel protocol.
ETHER_TYPE_PPP_DISC   0x8863 Indicates the point-to-point discovery type.
ETHER_TYPE_PPP_SES   0x8864 Indicates the point-to-point session discovery type.
ETHER_TYPE_6LO   0xa0ed Indicates IPv6 over Low Power Wireless Personal Area Networks (6LoWPANs).
TCP_PROTOCAL   6 Indicates the Transmission Control Protocol (TCP).
UDP_PROTOCAL   17 Indicates the User Datagram Protocol (UDP).
IP_PRI_SHIFT   5 Indicates the shift in the priority for an IP address.
DHCP_UDP_SRC_PORT   68 Indicates the source port number of DHCP.
DHCP_UDP_DES_PORT   67 Indicates the destination port number of DHCP.

Typedefs

Typedef Name Description
NetDevice typedef struct NetDevice Defines a network device, including the network interface category and name, and network port type.

Enumerations

Enumeration Name Description
NetIfCategory { LITE_OS, RICH_OS } Enumerates network interface categories, including lightweight OS and rich OS.
NetIfStatus { NETIF_DOWN, NETIF_UP } Enumerates network interface states, including online and offline.
NetIfLinkStatus { NETIF_LINK_DOWN, NETIF_LINK_UP } Enumerates network link layer states, including online and offline.
NetLinkType { ETHERNET_LINK = 1, WIFI_LINK = 801 } Enumerates data link types, including Ethernet and WLAN.
ProcessingResult { PROCESSING_CONTINUE, PROCESSING_COMPLETE, PROCESSING_ERROR } Enumerates data processing results, including continuing processing, processing completed, and error.
NetDevTxResult { NETDEV_TX_OK = 0x00, NETDEV_TX_BUSY = 0x10, NETDEV_TX_LOCKED = 0x20 } Enumerates data sending results, including sending succeeded, other data being sent at the link layer, and data link layer being locked.
Protocol80211IfType {   PROTOCOL_80211_IFTYPE_UNSPECIFIED, PROTOCOL_80211_IFTYPE_ADHOC, PROTOCOL_80211_IFTYPE_STATION, PROTOCOL_80211_IFTYPE_AP,   PROTOCOL_80211_IFTYPE_AP_VLAN, PROTOCOL_80211_IFTYPE_WDS, PROTOCOL_80211_IFTYPE_MONITOR, PROTOCOL_80211_IFTYPE_MESH_POINT,   PROTOCOL_80211_IFTYPE_P2P_CLIENT, PROTOCOL_80211_IFTYPE_P2P_GO, PROTOCOL_80211_IFTYPE_P2P_DEVICE, PROTOCOL_80211_IFTYPE_NUM,   PROTOCOL_80211_IFTYPE_MAX = PROTOCOL_80211_IFTYPE_NUM - 1 } Enumerates 802.11 network port types, including AP, STA, and P2P.
NetdeviceError { COMMON_ERROR = 1, ADD_LWIP_ERROR } Enumerates network device errors, including common errors and errors in adding network devices to LwIP.

Functions

Function Name Description
NetDeviceInit (const char ifName, uint32_t len, NetIfCategory ifCategory) struct NetDevice Initializes a network device to obtain its instance.
NetDeviceDeInit (struct NetDevice netDevice) int32_t Deletes a network device.
NetDeviceAdd (struct NetDevice netDevice, Protocol80211IfType ifType) int32_t Adds a network device to a protocol stack.
NetDeviceDelete (struct NetDevice netDevice) int32_t Deletes a network device from a protocol stack.
NetDeviceGetInstByName (const char name) struct NetDevice Obtains the initialized network device instance by a specified device name.
NetDeviceIsAnyInstRunning (void) bool Checks whether there are working devices among the added network devices.
NetDeviceIsInstRunning (const struct NetDevice netDevice) bool Checks whether a specified network device is working.
NetDevGetRegisterCount (void) uint32_t Obtains the number of added network devices.
NetDeviceGetCap (void) uint32_t Obtains the maximum number of network devices that can be registered with this system at the same time.
NetDeviceGetInstByIndex (uint32_t index) struct NetDevice Obtains a network device instance based on the index number.
NetIfSetAddr (const struct NetDevice netDevice, const IpV4Addr ipAddr, const IpV4Addr netMask, const IpV4Addr gw) int32_t Sets an IP address, mask, and gateway.
NetIfSetStatus (const struct NetDevice netDevice, NetIfStatus status) int32_t Notifies the network layer of the network port state.
NetIfSetLinkStatus (const struct NetDevice netDevice, NetIfLinkStatus status) int32_t Notifies the network layer of the data link layer status.
NetIfRx (const struct NetDevice netDevice, struct NetBuf buff) int32_t Transfers the input data packets from the network side to a protocol stack.
NetIfRxNi (const struct NetDevice netDevice, struct NetBuf buff) int32_t Transfers data packets from the network side to a protocol stack in an interrupt processing thread.
NetIfDhcpsStart (const struct NetDevice netDevice, char ip, u16_t ipNum) int32_t Starts the DHCP server.
NetIfDhcpsStop (const struct NetDevice netDevice) int32_t Stops the DHCP server.
NetIfDhcpStart (const struct NetDevice netDevice) int32_t Starts the DHCP client of a specified network device.
NetIfDhcpStop (const struct NetDevice netDevice) int32_t Stops the DHCP client of a specified network device.
NetIfDhcpIsBound (const struct NetDevice *netDevice) int32_t Obtains the DHCP negotiation status of a specified network device.