espressif / esp-lwip

Fork of lwIP (https://savannah.nongnu.org/projects/lwip/) with ESP-IDF specific patches
Other
79 stars 126 forks source link

add support to LWIP_HOOK_UNKNOWN_ETH_PROTOCOL_CALLBACK (IDFGH-4542) #7

Closed yanzixiang closed 3 years ago

yanzixiang commented 5 years ago

https://github.com/espressif/esp-idf/issues/3526

Wonder If this is the right way, Maybe useful for someone else.

I use https://github.com/espressif/arduino-esp32 , to test this, replace netif.h and liblwip.a after using esp-idf to complie the example, esp-idf/examples/ethernet/ethernet.

err_t Callback(struct pbuf *p, struct netif *inp){
  log_e("Callback");
  ESP_LOG_BUFFER_HEX("Callback",p,sizeof(p));
}

register_eth_unknow_type_callback(1,&Callback);

IN

err_t register_eth_unknow_type_callback(u8_t num,netif_input_fn p);

The num is the netif num, 0 for Wifi (Maybe) 1 For Eth (I Use this)

liuzfesp commented 5 years ago

Thanks @yanzixiang for your contribution.

My suggestion is to put the hook implementation into the port directory. E.g.

We need to minimize ESP-specific modifications in LWIP submodule.

yanzixiang commented 4 years ago

Thanks @yanzixiang for your contribution.

My suggestion is to put the hook implementation into the port directory. E.g.

  • Put HOOKS.h to $IDF_PATH/components/lwip/port/esp32/include/netif
  • Add HOOKS.c to $IDF_PATH/components/lwip/port/esp32/netif/HOOKS.c and put eth_unknow_type_callback(), register_eth_unknow_type_callback() ...

We need to minimize ESP-specific modifications in LWIP submodule.

So I shold gen a Pull Request at esp-idf instead of esp-lwip ?

david-cermak commented 3 years ago

@yanzixiang I agree with @liuzfesp that the hooks shall be defined in specific port layer. Now (in IDF v4.3), we have good a place in IDF, where we could put default lwip hooks: https://github.com/espressif/esp-idf/blob/master/components/lwip/port/esp32/include/lwip_default_hooks.h

Closing this, as the hooks don't really fit into esp-lwip repository. Please don't hesitate to post a PR to IDF repository!