1
0
forked from M-Labs/kirdy

Add default gateway into IpSettings

This commit is contained in:
linuswck 2024-03-06 10:34:57 +08:00
parent 65b757ac3c
commit a579e5c5d5

View File

@ -28,6 +28,7 @@ pub struct IpSettings {
addr: [u8; 4], addr: [u8; 4],
port: u16, port: u16,
prefix_len: u8, prefix_len: u8,
gateway: [u8; 4],
} }
impl Default for IpSettings { impl Default for IpSettings {
@ -36,6 +37,7 @@ impl Default for IpSettings {
addr: [192, 168, 1, 132], addr: [192, 168, 1, 132],
port: 1337, port: 1337,
prefix_len: 24, prefix_len: 24,
gateway: [192, 168, 1, 1]
} }
} }
} }
@ -130,7 +132,7 @@ impl ServerHandle {
let mut routes = smoltcp::iface::Routes::new(); let mut routes = smoltcp::iface::Routes::new();
routes routes
.add_default_ipv4_route(Ipv4Address::new(192, 168, 1, 1)) .add_default_ipv4_route(Ipv4Address::new(ip_settings.gateway[0], ip_settings.gateway[1], ip_settings.gateway[2], ip_settings.gateway[3]))
.ok(); .ok();
dma.enable_interrupt(); dma.enable_interrupt();