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

Fix crash when enabling napt #545

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9c8a760
gatekeep mdns ipv6 behind feature flag
indexds Nov 25, 2024
ad54aee
fix feature flag typo
indexds Nov 25, 2024
939648c
Merge branch 'esp-rs:master' into master
indexds Nov 30, 2024
4de452b
format
indexds Nov 30, 2024
b482ff5
requested changes
indexds Nov 30, 2024
b18d9a1
erratum
indexds Nov 30, 2024
fa4d63f
add ipv4 feature flag
indexds Nov 30, 2024
e113cdf
Merge branch 'esp-rs:master' into master
indexds Dec 23, 2024
b8e7a92
add wrapper for promiscuous mode
indexds Dec 23, 2024
9dd18df
change warn->info
indexds Dec 23, 2024
5da19ec
add changes
indexds Dec 23, 2024
0f0d186
add changes
indexds Dec 23, 2024
1feeaf3
&mut self -> &self
indexds Dec 23, 2024
85e7271
add documentation, switch to &mut self
indexds Dec 24, 2024
35bfea5
format
indexds Dec 24, 2024
54b89b1
double emac_rx stack size
indexds Dec 25, 2024
cc80832
Revert "double emac_rx stack size"
indexds Dec 25, 2024
b6c012b
Merge branch 'master' of https://github.com/indexds/esp-idf-svc
indexds Dec 27, 2024
1f40587
tryfix
indexds Jan 2, 2025
dc6c677
for real this time
indexds Jan 2, 2025
973c529
format
indexds Jan 2, 2025
5925165
fix weird undeclared bug?
indexds Jan 2, 2025
9d13946
Revert "fix weird undeclared bug?"
indexds Jan 2, 2025
c877440
surely this will work
indexds Jan 2, 2025
3a02f53
fix return type
indexds Jan 2, 2025
93644a9
changelog
indexds Jan 2, 2025
12c18c7
format
indexds Jan 2, 2025
1154b01
clear namespace
indexds Jan 3, 2025
cddc039
Merge branch 'master' into napt
indexds Jan 12, 2025
52bd210
fix changelog conflict
indexds Jan 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Crash when enabling napt in EspNetif (#545)

### Added
- New example, `wifi_dhcp_with_hostname` to demonstrate setting a custom hostname when establishing a DHCP connection

Expand Down
27 changes: 23 additions & 4 deletions src/netif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,14 +599,33 @@ impl EspNetif {
Ok(())
}

/// Enables or disables NAPT on this netif.
///
/// Enable operation can be performed only on one interface at a time.
/// NAPT cannot be enabled on multiple interfaces according to this implementation.
#[cfg(esp_idf_lwip_ipv4_napt)]
pub fn enable_napt(&mut self, enable: bool) {
pub fn enable_napt(&mut self, enable: bool) -> Result<(), EspError> {
unsafe extern "C" fn napt_wrapper(ctx: *mut ffi::c_void) -> i32 {
let ctx = unsafe { *(ctx as *mut (u8, i32)) };

ip_napt_enable_no(ctx.0, ctx.1);

0
}

unsafe {
crate::sys::ip_napt_enable_no(
let ctx = (
(esp_netif_get_netif_impl_index(self.handle) - 1) as u8,
if enable { 1 } else { 0 },
)
};
);

esp!(esp_netif_tcpip_exec(
Some(napt_wrapper),
&ctx as *const _ as *mut _
))?;
}

Ok(())
}
}

Expand Down
Loading