OVMS3-idf/components/esp_netif
Angus Gratton d041512022 Merge branch 'feature/mesh_ip_network_example' into 'master'
ESP-MESH: IP internal network example

See merge request espressif/esp-idf!7724
2020-04-30 14:33:16 +08:00
..
include esp-netif: Enable easier configuration of custom DHCP server address 2020-04-24 07:32:58 +02:00
loopback lwip: Enable IPv6 stateless address autoconfiguration 2020-01-14 07:15:26 +00:00
lwip fixbug for set dhcp time fail 2020-04-21 14:28:39 +08:00
private_include esp_netif: added locking for netif list management, unit tests to use unique if_keys, updated comments 2019-11-13 12:36:25 +01:00
test esp-netif: reenabled dhcp unit tests for esp32s2 2020-04-01 07:06:13 +00:00
CMakeLists.txt esp_netif: Support for PPPoS in esp_netif using lwip ppp client 2019-12-16 17:34:10 +00:00
component.mk esp_netif: include tcpip_adapter legacy header by default to provide *implicit* compatiblity 2019-11-13 12:36:25 +01:00
esp_netif_defaults.c esp-netif: Enable easier configuration of custom DHCP server address 2020-04-24 07:32:58 +02:00
esp_netif_handlers.c esp_netif: added locking for netif list management, unit tests to use unique if_keys, updated comments 2019-11-13 12:36:25 +01:00
esp_netif_objects.c esp_netif: minor update of coding style based on clang-tidy 2019-11-13 12:36:25 +01:00
Kconfig esp_netif: update default DHCP IP addresses to be in line with old interface, added loopback implementation, explicit esp-netif init, sanity checks for parameters added 2019-11-13 12:36:25 +01:00
README.md esp_netif: added locking for netif list management, unit tests to use unique if_keys, updated comments 2019-11-13 12:36:25 +01:00

ESP-NETIF architecture

                 |          (A) USER CODE                 |
                 |                                        |
    .............| init          settings      events     |
    .            +----------------------------------------+          
    .               .                |           *
    .               .                V           *                                   
--------+        +===========================+   *     +-----------------------+
        |        | new/config     get/set    |   *     |                       |
        |        |                           |...*.....| init                  |
        |        |---------------------------|   *     |                       |
  init  |        |                           |****     |                       |
  start |********|  event handler            |*********|  DHCP                 |
  stop  |        |                           |         |                       |
        |        |---------------------------|         |                       | 
        |        |                           |         |    NETIF              |
  +-----|        |                           |         +-----------------+     |   
  | glue|----<---|  esp_netif_transmit       |--<------| netif_output    |     |
  |     |        |                           |         |                 |     |
  |     |---->---|  esp_netif_receive        |-->------| netif_input     |     |
  |     |        |                           |         + ----------------+     |
  |     |....<...|  esp_netif_free_rx_buffer |...<.....| packet buffer         |
  +-----|        |                           |         |                       |  
        |        |                           |         |                       |  
  (B)   |        |                           |         +-----------------------+
--------+        +===========================+
communication                                                NETWORK STACK
DRIVER                   ESP-NETIF                          

Components:

A) User code, boiler plate

Overall application interaction with communication media and network stack

  • initialization code
    • create a new instance of ESP-NETIF
    • configure the object with
      1. netif specific options (flags, behaviour, name)
      2. network stack options (netif init and input functions, not publicly available)
      3. IO driver specific options (transmit, tx_free functions, IO driver handle)
    • setup event handlers
    • use default handlers for common interfaces defined in IO drivers; or define a specific handlers for customised behaviour/new interfaces
    • register handlers for app related events (such as IP lost/acquired)
  • interact with network interfaces using ESP-NETIF API

B) Communication driver, IO driver, media driver

  • event handler
    • define behaviour patterns of interaction with ESP-NETIF (example: ehternet link-up -> turn netif on)
  • glue IO layer: adapt the input/output functions to use esp-netif transmit/input/free_rx
    • install driver_transmit to appropriate ESP-NETIF object, so that outgoing packets from network stack are passed to the IO driver
    • calls esp_netif_receive to pass incoming data to network stack

C) ESP-NETIF, former tcpip_adapter

  • init API (new, configure)
  • IO API: for passing data between IO driver and network stack
  • event/action API (esp-netif lifecycle management)
    • building blocks for designing event handlers
  • setters, getters
  • network stack abstraction: enabling user interaction with TCP/IP stack
    • netif up/down
    • DHCP server, client
    • DNS API
  • driver conversion utilities

D) Network stack: no public interaction with user code (wrtt interfaces)

Data/event flow:

  • ........ Initialization line from user code to esp-netif and comm driver

  • --<--->-- Data packets going from communication media to TCP/IP stack and back

  • ******** Events agregated in ESP-NETIP propagates to driver, user code and network stack

  • | User settings and runtime configuration