ethernetif.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef __NETIF_ETHERNETIF_H__
  2. #define __NETIF_ETHERNETIF_H__
  3. #include "lwip/netif.h"
  4. #include <rtthread.h>
  5. #define NIOCTL_GADDR 0x01
  6. #ifndef RT_LWIP_ETH_MTU
  7. #define ETHERNET_MTU 1500
  8. #else
  9. #define ETHERNET_MTU RT_LWIP_ETH_MTU
  10. #endif
  11. /* eth flag with auto_linkup or phy_linkup */
  12. #define ETHIF_LINK_AUTOUP 0x0000
  13. #define ETHIF_LINK_PHYUP 0x0100
  14. struct eth_device
  15. {
  16. /* inherit from rt_device */
  17. struct rt_device parent;
  18. /* network interface for lwip */
  19. struct netif *netif;
  20. struct rt_semaphore tx_ack;
  21. rt_uint16_t flags;
  22. rt_uint8_t link_changed;
  23. rt_uint8_t link_status;
  24. rt_uint8_t rx_notice;
  25. /* eth device interface */
  26. struct pbuf* (*eth_rx)(rt_device_t dev);
  27. rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
  28. };
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. rt_err_t eth_device_ready(struct eth_device* dev);
  33. rt_err_t eth_device_init(struct eth_device * dev, const char *name);
  34. rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flag);
  35. rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
  36. void eth_device_deinit(struct eth_device *dev);
  37. int eth_system_device_init(void);
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #endif /* __NETIF_ETHERNETIF_H__ */