1/** 2 * @brief 3 * net.h 4 */ 5 6/* 7 * Copyright (c) 2017, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15 16#ifndef LIB_NET_INCLUDE_NET_NETIF_H_ 17#define LIB_NET_INCLUDE_NET_NETIF_H_ 18 19// forward declarations 20struct netif; 21struct devq; 22 23 24/* 25 * =============================================================================== 26 * Network Interface Management 27 * =============================================================================== 28 */ 29 30 31/** 32 * @brief initializes a netif structure for LWIP with a device queue 33 * 34 * @param netif the netif to be initialized 35 * @param devq the device queue to be used 36 * 37 * @return SYS_ERR_OK on success, errva on failure 38 */ 39errval_t net_if_init_devq(struct netif *netif, struct devq *devq); 40 41 42/** 43 * @brief adds the netif to the LWIP 44 * 45 * @param netif the netif ot be added 46 * @param state state to be passed 47 * 48 * @return 49 */ 50errval_t net_if_add(struct netif *netif, void *state); 51 52 53/** 54 * @brief removes a network interface 55 * 56 * @param netif the LWIP netif 57 * 58 * @return SYS_ERR_OK on success, errval on failure 59 */ 60errval_t net_if_remove(struct netif *netif); 61 62/* 63 * =============================================================================== 64 * Buffer Management 65 * =============================================================================== 66 */ 67 68 69/** 70 * @brief adds a new receive buffer to the interface 71 * 72 * @param netif the LWIP netif 73 * @param pbuf packet buffer to be added 74 * 75 * @return SYS_ERR_OK on success, errval on failure 76 */ 77errval_t net_if_add_rx_buf(struct netif *netif, struct pbuf *pbuf); 78 79/** 80 * @brief adds a new transmit buffer to the interface 81 * 82 * @param netif the LWIP netif 83 * @param pbuf packt boffer to be transmitted 84 * 85 * @return SYS_ERR_OK on success, errval on failure 86 */ 87errval_t net_if_add_tx_buf(struct netif *netif, struct pbuf *pbuf); 88 89 90/* 91 * =============================================================================== 92 * Polling the interfaces 93 * =============================================================================== 94 */ 95 96 97/** 98 * @brief polls then network interface for new incoming packets 99 * 100 * @param netif the LWIP netif to be polled 101 * 102 * @return SYS_ERR_OK on success, errval on failure 103 */ 104errval_t net_if_poll(struct netif *netif); 105 106/** 107 * @brief polls all added network interfaces 108 * 109 * @return SYS_ERR_OK on success, errval on failure 110 */ 111errval_t net_if_poll_all(void); 112 113#endif /* LIB_NET_INCLUDE_NET_NETIF_H_ */ 114