• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 /**
10  * @addtogroup WLAN
11  * @{
12  *
13  * @brief Provides cross-OS migration, component adaptation, and modular assembly and compilation.
14  *
15  * Based on the unified APIs provided by the WLAN module, developers of the Hardware Driver Interface
16  * (HDI) are capable of creating, disabling, scanning for, and connecting to WLAN hotspots, managing WLAN chips,
17  * network devices, and power, and applying for, releasing, and moving network data buffers.
18  *
19  * @since 1.0
20  * @version 1.0
21  */
22 
23 /**
24  * @file net_device.h
25  *
26  * @brief Defines WLAN network device interfaces.
27  *
28  * This module provides network device operations for driver development.
29  * The operations are as follows:
30  * <li> Initializes, adds, obtains, and deletes a network device. </li>
31  * <li> Reports network data, informs the network layer of the data link layer status, sets IP addresses,
32  * and starts or stops Dynamic Host Configuration Protocol (DHCP). </li>
33  *
34  * @since 1.0
35  * @version 1.0
36  */
37 
38 #ifndef HDF_NET_DEVICE_MODULE_H
39 #define HDF_NET_DEVICE_MODULE_H
40 #include "hdf_base.h"
41 #include "hdf_netbuf.h"
42 #include "hdf_log.h"
43 #include "net_device_types_adapter.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /**
50  * @brief Indicates a 6-byte MAC address.
51  *
52  * @since 1.0
53  * @version 1.0
54  */
55 #define MAC_ADDR_SIZE 6
56 /**
57  * @brief Indicates that the network port is working.
58  *
59  * @since 1.0
60  * @version 1.0
61  */
62 #define NET_DEVICE_IFF_RUNNING IFF_RUNNING
63 /**
64  * @brief Indicates Reverse Address Resolution Protocol (RARP).
65  *
66  * @since 1.0
67  * @version 1.0
68  */
69 #define ETHER_TYPE_RARP 0x8035
70 /**
71  * @brief Indicates Port Access Entity (PAE).
72  *
73  * @since 1.0
74  * @version 1.0
75  */
76 #define ETHER_TYPE_PAE 0x888e
77 /**
78  * @brief Indicates Internet Protocol (IP).
79  *
80  * @since 1.0
81  * @version 1.0
82  */
83 #define ETHER_TYPE_IP 0x0800
84 /**
85  * @brief Indicates AppleTalk Address Resolution Protocol (AARP).
86  *
87  * @since 1.0
88  * @version 1.0
89  */
90 #define ETHER_TYPE_AARP 0x80f3
91 /**
92  * @brief Indicates Internetwork Packet Exchange (IPX).
93  *
94  * @since 1.0
95  * @version 1.0
96  */
97 #define ETHER_TYPE_IPX 0x8137
98 /**
99  * @brief Indicates Address Resolution Protocol (ARP).
100  *
101  * @since 1.0
102  * @version 1.0
103  */
104 #define ETHER_TYPE_ARP 0x0806
105 /**
106  * @brief Indicates Internet Protocol version 6 (IPv6).
107  *
108  * @since 1.0
109  * @version 1.0
110  */
111 #define ETHER_TYPE_IPV6 0x86dd
112 /**
113  * @brief Indicates Tunneled Direct Link Setup (TDLS).
114  *
115  * @since 1.0
116  * @version 1.0
117  */
118 #define ETHER_TYPE_TDLS 0x890d
119 /**
120  * @brief Indicates Virtual Local Area Network (VLAN).
121  *
122  * @since 1.0
123  * @version 1.0
124  */
125 #define ETHER_TYPE_VLAN 0x8100
126 /**
127  * @brief Indicates WLAN Authentication and Privacy Infrastructure (WAPI).
128  *
129  * @since 1.0
130  * @version 1.0
131  */
132 #define ETHER_TYPE_WAI 0x88b4
133 /**
134  * @brief Indicates Link Layer Topology Discovery (LLTD).
135  *
136  * @since 1.0
137  * @version 1.0
138  */
139 #define ETHER_LLTD_TYPE 0x88D9
140 /**
141  * @brief Indicates 802.1x network port authentication.
142  *
143  * @since 1.0
144  * @version 1.0
145  */
146 #define ETHER_ONE_X_TYPE 0x888E
147 /**
148  * @brief Indicates a tunnel protocol.
149  *
150  * @since 1.0
151  * @version 1.0
152  */
153 #define ETHER_TUNNEL_TYPE 0x88bd
154 /**
155  * @brief Indicates the point-to-point discovery type.
156  *
157  * @since 1.0
158  * @version 1.0
159  */
160 #define ETHER_TYPE_PPP_DISC 0x8863
161 /**
162  * @brief Indicates the point-to-point session discovery type.
163  *
164  * @since 1.0
165  * @version 1.0
166  */
167 #define ETHER_TYPE_PPP_SES 0x8864
168 /**
169  * @brief Indicates IPv6 over Low Power Wireless Personal Area Networks (6LoWPANs).
170  *
171  * @since 1.0
172  * @version 1.0
173  */
174 #define ETHER_TYPE_6LO 0xa0ed
175 
176 /**
177  * @brief Indicates the Transmission Control Protocol (TCP).
178  *
179  * @since 1.0
180  * @version 1.0
181  */
182 #define TCP_PROTOCOL       6
183 /**
184  * @brief Indicates the User Datagram Protocol (UDP).
185  *
186  * @since 1.0
187  * @version 1.0
188  */
189 #define UDP_PROTOCOL       17
190 /**
191  * @brief Indicates the shift in the priority for an IP address.
192  *
193  * @since 1.0
194  * @version 1.0
195  */
196 #define IP_PRI_SHIFT        5
197 
198 /**
199  * @brief Indicates the source port number of DHCP.
200  *
201  * @since 1.0
202  * @version 1.0
203  */
204 #define DHCP_UDP_SRC_PORT   68
205 /**
206  * @brief Indicates the destination port number of DHCP.
207  *
208  * @since 1.0
209  * @version 1.0
210  */
211 #define DHCP_UDP_DES_PORT   67
212 
213 /**
214  * @brief Indicates the default MTU value of the WLAN.
215  *
216  * @since 1.0
217  * @version 1.0
218  */
219 #define DEFAULT_MTU 1500
220 
221 /**
222  * @brief Indicates the maximum MTU value of the WLAN.
223  *
224  * @since 1.0
225  * @version 1.0
226  */
227 #define WLAN_MAX_MTU 1500
228 
229 /**
230  * @brief Indicates the minimum MTU value of the WLAN.
231  *
232  * @since 1.0
233  * @version 1.0
234  */
235 #define WLAN_MIN_MTU 576
236 
237 /**
238  * @brief Enumerates network interface categories, including lightweight OS and full OS.
239  *
240  * @since 1.0
241  * @version 1.0
242  */
243 typedef enum {
244     LITE_OS,   /**< Lightweight OS */
245     FULL_OS   /**< Full OS */
246 } NetIfCategory;
247 
248 /**
249  * @brief Enumerates network interface states, including online and offline.
250  *
251  * @since 1.0
252  * @version 1.0
253  */
254 typedef enum {
255     NETIF_DOWN,  /**< Network interface offline */
256     NETIF_UP     /**< Network interface online */
257 } NetIfStatus;
258 
259 /**
260  * @brief Enumerates network link layer states, including online and offline.
261  *
262  * @since 1.0
263  * @version 1.0
264  */
265 typedef enum {
266     NETIF_LINK_DOWN,  /**< Data link offline */
267     NETIF_LINK_UP     /**< Data link online */
268 } NetIfLinkStatus;
269 
270 /**
271  * @brief Enumerates data link types, including Ethernet and WLAN.
272  *
273  * @since 1.0
274  * @version 1.0
275  */
276 typedef enum {
277     ETHERNET_LINK = 1,  /**< Ethernet */
278     WIFI_LINK = 801     /**< WLAN */
279 } NetLinkType;
280 
281 /**
282  * @brief Enumerates data processing results, including continuing processing, processing completed, and error.
283  *
284  * @since 1.0
285  * @version 1.0
286  */
287 typedef enum {
288     PROCESSING_CONTINUE,  /**< Continuing processing */
289     PROCESSING_COMPLETE,  /**< Processing completed */
290     PROCESSING_ERROR      /**< Error */
291 } ProcessingResult;
292 
293 /**
294  * @brief Enumerates 802.11 network port types, including AP, STA, and P2P.
295  *
296  * @since 1.0
297  * @version 1.0
298  */
299 typedef enum {
300     PROTOCOL_80211_IFTYPE_UNSPECIFIED,                         /**< Unspecified */
301     PROTOCOL_80211_IFTYPE_ADHOC,                               /**< Ad hoc network */
302     PROTOCOL_80211_IFTYPE_STATION,                             /**< Workstation */
303     PROTOCOL_80211_IFTYPE_AP,                                  /**< Access point */
304     PROTOCOL_80211_IFTYPE_AP_VLAN,                             /**< Virtual access point */
305     PROTOCOL_80211_IFTYPE_WDS,                                 /**< Wireless distributed system */
306     PROTOCOL_80211_IFTYPE_MONITOR,                             /**< Listening */
307     PROTOCOL_80211_IFTYPE_MESH_POINT,                          /**< Mesh network */
308     PROTOCOL_80211_IFTYPE_P2P_CLIENT,                          /**< P2P client */
309     PROTOCOL_80211_IFTYPE_P2P_GO,                              /**< P2P group owner */
310     PROTOCOL_80211_IFTYPE_P2P_DEVICE,                          /**< P2P device */
311     PROTOCOL_80211_IFTYPE_NUM,                                 /**< Number of network ports */
312     PROTOCOL_80211_IFTYPE_MAX = PROTOCOL_80211_IFTYPE_NUM - 1  /**< Maximum number of 802.11 network port types */
313 } Protocol80211IfType;
314 
315 /**
316  * @brief Enumerates network device errors, including common errors and errors in adding network devices to LwIP.
317  *
318  * @since 1.0
319  * @version 1.0
320  */
321 typedef enum {
322     COMMON_ERROR = 1,  /**< Common errors */
323     ADD_LWIP_ERROR     /**< Errors in adding network devices to LwIP */
324 } NetdeviceError;
325 
326 /**
327  * @brief Defines the Ethernet header information of a data frame, including the destination address, source address,
328  * and Ethernet type.
329  *
330  * @since 1.0
331  * @version 1.0
332  */
333 struct EtherHeader {
334     uint8_t etherDhost[MAC_ADDR_SIZE];  /**< Destination address {@link MAC_ADDR_SIZE} */
335     uint8_t etherShost[MAC_ADDR_SIZE];  /**< Source address {@link MAC_ADDR_SIZE} */
336     uint16_t etherType;                 /**< Ethernet type, such as 0x8035 (RARP), 0x888e (EAPOL), PAE/802.1x,
337                                          * 0x0800 (IP), 0x86dd (IPV6), and 0x0806 (ARP)
338                                          */
339 };
340 
341 /**
342  * @brief Defines the IP header information of a data frame, including the version number, service type,
343  * and total length.
344  *
345  * @since 1.0
346  * @version 1.0
347  */
348 struct IpHeader {
349     uint8_t    versionAndHl;   /**< Version and header length */
350     uint8_t    tos;            /**< Service type
351                                 * bit7~bit5 | bit4  |  bit3 |  bit2 |   bit1  | bit0
352                                 * ----------|-------|-------|-------|---------|-----
353                                 * Priority | Delay | Throughput | Reliability | Transmission Cost | Reservation
354                                 */
355     uint16_t   totLen;         /**< Total length of an IP data packet */
356     uint16_t   id;             /**< Each data packet sent by the host */
357     uint16_t   fragInfo;       /**< Fragmentation information */
358     uint8_t    ttl;            /**< Generation time */
359     uint8_t    protocol;       /**< Protocol, such as 1 (ICMP), 2 (IGMP), 6 (TCP), 17 (UDP), and 89 (OSPF) */
360     uint16_t   check;          /**< Header check */
361     uint32_t   sAddr;          /**< Source address */
362     uint32_t   dAddr;          /**< Destination address */
363 };
364 
365 /**
366  * @brief Defines the UDP header information of a data frame, including the source port number and destination
367  * port number.
368  *
369  * @since 1.0
370  * @version 1.0
371  */
372 struct UdpHeader {
373     uint16_t source;  /**< Source port number */
374     uint16_t dest;    /**< Destination port number */
375     uint16_t len;     /**< Length of a data packet */
376     uint16_t check;   /**< Header check */
377 };
378 
379 /**
380  * @brief Defines the TCP header information of a data frame, including the source port number and destination
381  * port number.
382  *
383  * @since 1.0
384  * @version 1.0
385  */
386 struct TcpHeader {
387     uint16_t  sPort;   /**< Source port number */
388     uint16_t  dPort;   /**< Destination port number */
389     uint32_t  seqNum;  /**< Sequence number */
390     uint32_t  ackNum;  /**< Acknowledgment number */
391     uint8_t   offset;  /**< Header length */
392     uint8_t   flags;   /**< Flags */
393     uint16_t  window;  /**< Window size */
394     uint16_t  check;   /**< Checksum */
395     uint16_t  urgent;  /**< Urgent pointer */
396 };
397 
398 /**
399  * @brief Defines an IPv4 address.
400  *
401  * @since 1.0
402  * @version 1.0
403  */
404 typedef struct {
405     uint32_t addr;  /**< IPv4 address */
406 } IpV4Addr;
407 
408 /**
409  * @brief Defines a network device notification, including an IP address and the notification type.
410  *
411  * @since 1.0
412  * @version 1.0
413  */
414 typedef struct {
415     uint32_t ipAddr;      /**< IP address */
416     uint32_t notifyType;  /**< Notification type (reserved) */
417 } NetDevNotify;
418 
419 /**
420  * @brief Defines the network port type, for example, the WLAN network port.
421  *
422  * @since 1.0
423  * @version 1.0
424  */
425 typedef union {
426     Protocol80211IfType wlanType;  /**< WLAN network port type: AP or STA */
427 } IfType;
428 
429 /**
430  * @brief Describes the status of a network device.
431  *
432  * @since 1.0
433  * @version 1.0
434  */
435 struct NetDevStats {
436     uint32_t rxPackets; /**< Total number of received packets */
437     uint32_t txPackets; /**< Total number of transmitted packets */
438     uint32_t rxBytes;   /**< Total number of received bits */
439     uint32_t txBytes;   /**< Total number of transmitted bits */
440     uint32_t rxErrors;  /**< Number of received error packets */
441     uint32_t txErrors;  /**< Transmitted error packets */
442     uint32_t rxDropped; /**< Packets that are dropped after being received */
443     uint32_t txDropped; /**< Packets dropped before transmission */
444 };
445 
446 /**
447  * @brief Defines ioctrl data.
448  *
449  * @since 1.0
450  * @version 1.0
451  */
452 typedef struct {
453     uint32_t fake;     /**< magic field */
454     uint8_t *ifrData;  /**< Data pointer */
455 } IfReq;
456 
457 /**
458  * @brief Defines a network device, including the network interface category and name, and network port type.
459  *
460  * @since 1.0
461  * @version 1.0
462  */
463 typedef struct NetDevice {
464     NetIfCategory netifCateg;                 /**< Network interface category {@link NetIfCategory} */
465     char name[IFNAMSIZ];                      /**< Network device name {@link IFNAMSIZ} */
466     NetLinkType LinkLayerType;                /**< Data link layer type */
467     IfType funType;                           /**< Network port type */
468     uint8_t macAddr[MAC_ADDR_SIZE];           /**< MAC address {@link MAC_ADDR_SIZE} */
469     uint32_t flags;                           /**< Network port status */
470     uint32_t mtu;                             /**< Maximum transmission unit */
471     int32_t watchdogTime;                     /**< Watchdog duration */
472     uint32_t lastRxTime;                      /**< Last time when data is received */
473     uint16_t hardHeaderLen;                   /**< Header length */
474     uint16_t neededHeadRoom;                  /**< Length reserved for the header in netbuff{@link NetBuf} */
475     uint16_t neededTailRoom;                  /**< Length reserved for the tail in netbuff{@link NetBuf} */
476     uint8_t addrLen;                          /**< MAC address length */
477     const char* classDriverName;              /**< driver name of class driver */
478     void *classDriverPriv;                    /**< Private structure for the platform */
479     void *mlPriv;                             /**< Private structure for the driver */
480     void *ieee80211Ptr;                       /**< Pointer to a wireless device */
481     void *specialProcPriv;                    /**< Private structure for data processing */
482     struct NetDeviceInterFace *netDeviceIf;   /**< Network device interface */
483     struct NetDevice *owner;                  /**< Network device */
484     struct NetDevStats stats;                 /**< Network statistics */
485 } NetDevice;
486 
487 /**
488  * @brief Defines interfaces that need to be implemented externally by network devices, including initializing,
489  * opening, and closing a network device.
490  *
491  * @since 1.0
492  * @version 1.0
493  */
494 struct NetDeviceInterFace {
495     int32_t (*init)(struct NetDevice *netDev);  /**< Initializes a network device to be added. */
496     void (*deInit)(struct NetDevice *netDev);   /**< Deinitializes a network device to be delete. */
497     int32_t (*open)(struct NetDevice *netDev);  /**< Opens the data link layer. */
498     int32_t (*stop)(struct NetDevice *netDev);  /**< Closes the data link layer. */
499     NetDevTxResult (*xmit)(struct NetDevice *netDev, NetBuf *netBuff);        /**< Sends data. */
500     int32_t (*ioctl)(struct NetDevice *netDev, IfReq *req, int32_t cmd);      /**< Used for the control command word. */
501     int32_t (*setMacAddr)(struct NetDevice *netDev, void *addr);              /**< Sets the MAC address. */
502     struct NetDevStats *(*getStats)(struct NetDevice *netDev);                /**< Obtains the statistics. */
503     void (*setNetIfStatus)(struct NetDevice *netDev, NetIfStatus status);     /**< Sets the network port status. */
504     uint16_t (*selectQueue)(struct NetDevice *netDev, NetBuf *netBuff);       /**< Selects a priority queue. */
505     uint32_t (*netifNotify)(struct NetDevice *netDev, NetDevNotify *notify);  /**< Notifies the network port status. */
506     int32_t (*changeMtu)(struct NetDevice *netDev, int32_t newMtu);           /**< Changes the maximum number of
507                                                                                * transmission units.
508                                                                                */
509     void (*linkStatusChanged)(struct NetDevice *netDev);    /**< Detects the change of
510                                                              * the Ethernet port connection status.
511                                                              */
512     ProcessingResult (*specialEtherTypeProcess)(const struct NetDevice *netDev, NetBuf *buff);
513                                                                               /**< Performs private processing without
514                                                                                * involving network-layer data.
515                                                                                */
516 };
517 
518 /**
519  * @brief Initializes a network device to obtain its instance.
520  *
521  * @param ifName Indicates the pointer to the network device name.
522  * @param len Indicates the length of the network device name.
523  * @param type Indicates the data link type.
524  * @param ifCategory Indicates the network port category.
525  *
526  * @return Returns the structure {@link NetDevice} for the initialized network device if the operation is successful;
527  * returns <b>NULL</b> if the operation fails.
528  *
529  * @since 1.0
530  * @version 1.0
531  */
532 struct NetDevice *NetDeviceInit(const char *ifName, uint32_t len, NetLinkType type, NetIfCategory ifCategory);
533 
534 /**
535  * @brief Deletes a network device.
536  *
537  * @param netDevice Indicates the pointer to the network device structure obtained during initialization.
538  *
539  * @return Returns <b>0</b> if the operation is successful; returns a negative value representing {@link HDF_STATUS}
540  * if the operation fails.
541  *
542  * @since 1.0
543  * @version 1.0
544  */
545 int32_t NetDeviceDeInit(struct NetDevice *netDevice);
546 
547 /**
548  * @brief Adds a network device to a protocol stack.
549  *
550  * @param netDevice Indicates the pointer to the network device structure obtained during initialization.
551  *
552  * @return Returns <b>0</b> if the operation is successful; returns a negative value representing {@link HDF_STATUS}
553  * if the operation fails.
554  *
555  * @since 1.0
556  * @version 1.0
557  */
558 int32_t NetDeviceAdd(struct NetDevice *netDevice);
559 
560 /**
561  * @brief Deletes a network device from a protocol stack.
562  *
563  * @param netDevice Indicates the pointer to the network device structure {@link netDevice} obtained during
564  * initialization.
565  *
566  * @return Returns <b>0</b> if the operation is successful; returns a negative value representing {@link HDF_STATUS}
567  * if the operation fails.
568  *
569  * @since 1.0
570  * @version 1.0
571  */
572 int32_t NetDeviceDelete(struct NetDevice *netDevice);
573 
574 /**
575  * @brief Obtains the initialized network device instance by a specified device name.
576  *
577  * @param name Indicates the pointer to the network device name.
578  *
579  * @return Returns the network device structure {@link NetDevice} matching the network device name if the operation is
580  * successful; returns <b>NULL</b> if the operation fails.
581  *
582  * @since 1.0
583  * @version 1.0
584  */
585 struct NetDevice *NetDeviceGetInstByName(const char *name);
586 
587 /**
588  * @brief Checks whether there are working devices among the added network devices.
589  *
590  * @return Returns <b>true</b> if the added network devices are working; returns <b>false</b> if none of the added
591  * network devices is working.
592  *
593  * @since 1.0
594  * @version 1.0 */
595 bool NetDeviceIsAnyInstRunning(void);
596 
597 /**
598  * @brief Checks whether a specified network device is working.
599  *
600  * @param netDevice Indicates the pointer to the network device structure {@link netDevice} obtained during
601  * initialization.
602  *
603  * @return Returns <b>true</b> if the specified network device is working; returns <b>false</b> otherwise.
604  *
605  * @since 1.0
606  * @version 1.0
607  */
608 bool NetDeviceIsInstRunning(const struct NetDevice *netDevice);
609 
610 /**
611  * @brief Obtains the number of added network devices.
612  *
613  * @return Returns the number of added network devices.
614  *
615  * @since 1.0
616  * @version 1.0
617  */
618 uint32_t NetDevGetRegisterCount(void);
619 
620 /**
621  * @brief Obtains the maximum number of network devices that can be registered with this system at the same time.
622  *
623  * @return Returns the maximum number of network devices.
624  *
625  * @since 1.0
626  * @version 1.0
627  */
628 uint32_t NetDeviceGetCap(void);
629 
630 /**
631  * @brief Obtains a network device instance based on the index number.
632  *
633  * @param index Indicates the index number.
634  *
635  * @return Returns the network device structure {@link NetDevice} if the operation is successful; returns <b>NULL</b>
636  * if the operation fails.
637  *
638  * @since 1.0
639  * @version 1.0
640  */
641 struct NetDevice *NetDeviceGetInstByIndex(uint32_t index);
642 
643 /**
644  * @brief Sets an IP address, mask, and gateway.
645  *
646  * @param netDevice Indicates the pointer to the network device structure {@link netDevice} obtained during
647  * initialization.
648  * @param ipAddr Indicates the IP address to set.
649  * @param netMask Indicates the mask to set.
650  * @param gw Indicates the gateway to set.
651  *
652  * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise.
653  *
654  * @since 1.0
655  * @version 1.0
656  */
657 int32_t NetIfSetAddr(const struct NetDevice *netDevice, const IpV4Addr *ipAddr, const IpV4Addr *netMask,
658     const IpV4Addr *gw);
659 
660 /**
661  * @brief Notifies the network layer of the network port state.
662  *
663  * @param netDevice Indicates the pointer to the network device obtained during initialization.
664  * @param status Indicates the network port state, as enumerated in {@link NetIfSatus}.
665  * @param status Indicates the network port state, as enumerated in {@link NetIfSatus}.
666  *
667  * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise.
668  *
669  * @since 1.0
670  * @version 1.0
671  */
672 int32_t NetIfSetStatus(const struct NetDevice *netDevice, NetIfStatus status);
673 
674 /**
675  * @brief Sets a specified MAC address for a given {@link NetDevice}.
676  *
677  * @param netDevice Indicates the pointer to the {@link NetDevice}.
678  * @param macAddr Indicates the pointer to the MAC address to set.
679  * @param length Indicates the length of the MAC address to set.
680  *
681  * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise.
682  *
683  * @since 1.0
684  * @version 1.0
685  */
686 int32_t NetIfSetMacAddr(struct NetDevice *netDevice, const unsigned char *macAddr, unsigned char length);
687 
688 /**
689  * @brief Notifies the network layer of the data link layer status.
690  *
691  * @param netDevice Indicates the pointer to the network device obtained during initialization.
692  * @param status status Indicates the data link layer status, as enumerated in {@link NetIfLinkSatus}.
693  *
694  * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise.
695  *
696  * @since 1.0
697  * @version 1.0
698  */
699 int32_t NetIfSetLinkStatus(const struct NetDevice *netDevice, NetIfLinkStatus status);
700 
701 /**
702  * @brief Get the netdevice data link layer status.
703  *
704  * @param netDevice Indicates the pointer to the network device obtained during initialization.
705  * @param status save link layer status, as enumerated in {@link NetIfLinkSatus}.
706  *
707  * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise.
708  *
709  * @since 1.0
710  * @version 1.0
711  */
712 int32_t NetIfGetLinkStatus(const struct NetDevice *netDevice, NetIfLinkStatus *status);
713 
714 /**
715  * @brief Transfers data packets from the network side to a protocol stack in an interrupt processing thread.
716  *
717  * @param netDevice Indicates the pointer to the network device structure {@link netDevice} obtained
718  * during initialization.
719  * @param buff Indicates the network-side data, in Ether format.
720  *
721  * @return Returns <b>0</b> if the operation is successful; returns a non-zero value {@link HDF_STATUS} if the
722  * operation fails.
723  *
724  * @since 1.0
725  * @version 1.0
726  */
727 int32_t NetIfRx(const struct NetDevice *netDevice, NetBuf *buff);
728 
729 /**
730  * @brief Transfers the input data packets from the network side to a protocol stack.
731  *
732  * @param netDevice Indicates the pointer to the network device structure {@link netDevice} obtained
733  * during initialization.
734  * @param buff Indicates the network-side data, in Ether format.
735  *
736  * @return Returns <b>0</b> if the operation is successful; returns a non-zero value {@link HDF_STATUS} if the
737  * operation fails.
738  *
739  * @since 1.0
740  * @version 1.0
741  */
742 int32_t NetIfRxNi(const struct NetDevice *netDevice, NetBuf *buff);
743 
744 /**
745  * @brief Starts the DHCP server.
746  *
747  * @param netDevice Indicates the pointer to the network device structure {@link netDevice} obtained
748  * during initialization.
749  * @param ip Indicates the IP address to start.
750  * @param ipNum Indicates the number of IP addresses.
751  *
752  * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise.
753  *
754  * @since 1.0
755  * @version 1.0
756  */
757 int32_t NetIfDhcpsStart(const struct NetDevice *netDevice, char *ip, uint16_t ipNum);
758 
759 /**
760  * @brief Stops the DHCP server.
761  *
762  * @param netDevice Indicates the pointer to the network device structure {@link netDevice} obtained
763  * during initialization.
764  *
765  * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise.
766  *
767  * @since 1.0
768  * @version 1.0
769  */
770 int32_t NetIfDhcpsStop(const struct NetDevice *netDevice);
771 
772 /**
773  * @brief Starts the DHCP client of a specified network device.
774  *
775  * @param netDevice Indicates the pointer to the network device obtained during initialization.
776  *
777  * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise.
778  *
779  * @since 1.0
780  * @version 1.0
781  */
782 int32_t NetIfDhcpStart(const struct NetDevice *netDevice);
783 
784 /**
785  * @brief Stops the DHCP client of a specified network device.
786  *
787  * @param netDevice Indicates the pointer to the network device obtained during initialization.
788  *
789  * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise.
790  *
791  * @since 1.0
792  * @version 1.0
793  */
794 int32_t NetIfDhcpStop(const struct NetDevice *netDevice);
795 
796 /**
797  * @brief Obtains the DHCP negotiation status of a specified network device.
798  *
799  * @param netDevice Indicates the pointer to the network device obtained during initialization.
800  *
801  * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise.
802  *
803  * @since 1.0
804  * @version 1.0
805  */
806 int32_t NetIfDhcpIsBound(const struct NetDevice *netDevice);
807 
808 #define GET_NET_DEV_FLAGS(dev) ((dev)->flags)
809 #define GET_NET_DEV_HEAD_ROOM(dev) ((dev)->neededHeadRoom)
810 #define GET_NET_DEV_TAIL_ROOM(dev) ((dev)->neededTailRoom)
811 #define GET_NET_DEV_MTU(dev) ((dev)->mtu)
812 #define GET_NET_DEV_CFG80211_WIRELESS(dev) ((struct wireless_dev*)((dev)->ieee80211Ptr))
813 #define GET_NET_DEV_PRIV(dev) ((dev)->mlPriv)
814 #define GET_NET_DEV_MAC_ADDR(dev) ((dev)->macAddr)
815 #define GET_NET_DEV_IF(dev) ((dev)->netDeviceIf)
816 #define GET_NET_DEV_LAST_RX_TIME(dev) ((dev)->lastRxTime)
817 #define GET_NET_DEV_OWNER(dev) ((dev)->owner)
818 #define GET_NET_DEV_WATCHDOG_TIME(dev) ((dev)->watchdogTime)
819 #define GET_NET_DEV_SPECIAL_PROC_PRIV(dev) ((dev)->specialProcPriv)
820 #ifdef __cplusplus
821 }
822 #endif
823 
824 #endif /* HDF_NET_DEVICE_MODULE_H */
825 /** @} */
826