1 // Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 /** prevent recursive inclusion **/
24 * @brief Network data buffer
29 /* Length of data buffer */
34 * @brief Network device instance
36 typedef struct netdev * netdev_handle_t;
39 * @brief Network operations implemented by driver
43 int (* netdev_open) (netdev_handle_t netdev);
45 int (* netdev_close) (netdev_handle_t netdev);
47 int (* netdev_xmit) (netdev_handle_t netdev, struct pbuf *net_buf);
51 * @brief Allocate network device instance for given interface name
52 * @param sizeof_priv - sizeof driver private instance
53 * @param name - Interface name
54 * @retval network device instance
56 netdev_handle_t netdev_alloc(uint32_t sizeof_priv, char *name);
59 * @brief Free network device instance
60 * @param netdev - Network device instance
63 void netdev_free(netdev_handle_t netdev);
66 * @brief Returns address of driver priv instance from network device instance
67 * @param netdev - Network device instance
68 * @retval - Driver priv instance
70 void * netdev_get_priv(netdev_handle_t netdev);
73 * @brief Register a network interface
74 * @param netdev - Network device instance
75 * @param netdev_ops - Network operations implemented by driver
76 * @retval - on success: 0
79 int netdev_register(netdev_handle_t netdev, struct netdev_ops *ops);
82 * @brief Unregister network interfcace
83 * @param netdev - Network device instance
84 * @retval - on success: 0
87 int netdev_unregister(netdev_handle_t netdev);
90 * @brief Rx handler of network stack
91 * @param netdev - Network device instance
92 * @param pbuf - received data buffer
94 int netdev_rx(netdev_handle_t netdev, struct pbuf *net_buf);