Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding netif->input #64

Merged
merged 1 commit into from
Nov 3, 2023
Merged

Allow overriding netif->input #64

merged 1 commit into from
Nov 3, 2023

Conversation

rovo89
Copy link
Contributor

@rovo89 rovo89 commented Oct 20, 2023

Instead of statically calling ethernet_input() (which is actually defined to be ethernet_input_LWIP2), store a pointer to it in netif->input and call that.

This makes it easy to hook into the processing of input packets and implement a little firewall. Of course any code doing this should save the original pointer and call it when applicable. For an example, see:

https://github.com/martin-ger/esp_wifi_repeater/blob/2499913094a707b79ea4e357273a32755e31c723/user/user_main.c#L693-L697

Also remove various lines where netif->input would be reset. Set it once during netif_add(), and then trust that it wouldn't get changed without reason.

Instead of statically calling ethernet_input() (which is actually
defined to be ethernet_input_LWIP2), store a pointer to it in
netif->input and call that.

This makes it easy to hook into the processing of input packets and
implement a little firewall. Of course any code doing this should save
the original pointer and call it when applicable. For an example, see:

  https://github.com/martin-ger/esp_wifi_repeater/blob/2499913094a707b79ea4e357273a32755e31c723/user/user_main.c#L693-L697

Also remove various lines where netif->input would be reset. Set it
once during netif_add(), and then trust that it wouldn't get changed
without reason.
@rovo89
Copy link
Contributor Author

rovo89 commented Oct 20, 2023

Not sure if I'm missing some cases here, but the resulting code looks more straight-forward and closer to upstream to me. Basic tests (including NAT, which I could then filter e.g. by target IP) went fine.

@rovo89
Copy link
Contributor Author

rovo89 commented Nov 3, 2023

@d-a-v Could you please review when you find the time? Thanks!

@d-a-v
Copy link
Owner

d-a-v commented Nov 3, 2023

Looks good

@d-a-v d-a-v merged commit e4051de into d-a-v:master Nov 3, 2023
1 check passed
rovo89 added a commit to rovo89/Arduino_esp8266 that referenced this pull request Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants