Rename StaticConfig to StaticConfigV4
This commit is contained in:
parent
44624b2d7a
commit
54bab33c73
@ -68,7 +68,7 @@ impl<const SOCK: usize> StackResources<SOCK> {
|
|||||||
|
|
||||||
/// Static IP address configuration.
|
/// Static IP address configuration.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct StaticConfig {
|
pub struct StaticConfigV4 {
|
||||||
/// IP address and subnet mask.
|
/// IP address and subnet mask.
|
||||||
pub address: Ipv4Cidr,
|
pub address: Ipv4Cidr,
|
||||||
/// Default gateway.
|
/// Default gateway.
|
||||||
@ -114,7 +114,7 @@ impl Default for DhcpConfig {
|
|||||||
/// Network stack configuration.
|
/// Network stack configuration.
|
||||||
pub enum Config {
|
pub enum Config {
|
||||||
/// Use a static IP address configuration.
|
/// Use a static IP address configuration.
|
||||||
Static(StaticConfig),
|
Static(StaticConfigV4),
|
||||||
/// Use DHCP to obtain an IP address configuration.
|
/// Use DHCP to obtain an IP address configuration.
|
||||||
#[cfg(feature = "dhcpv4")]
|
#[cfg(feature = "dhcpv4")]
|
||||||
Dhcp(DhcpConfig),
|
Dhcp(DhcpConfig),
|
||||||
@ -131,7 +131,7 @@ pub struct Stack<D: Driver> {
|
|||||||
struct Inner<D: Driver> {
|
struct Inner<D: Driver> {
|
||||||
device: D,
|
device: D,
|
||||||
link_up: bool,
|
link_up: bool,
|
||||||
config: Option<StaticConfig>,
|
config: Option<StaticConfigV4>,
|
||||||
#[cfg(feature = "dhcpv4")]
|
#[cfg(feature = "dhcpv4")]
|
||||||
dhcp_socket: Option<SocketHandle>,
|
dhcp_socket: Option<SocketHandle>,
|
||||||
#[cfg(feature = "dns")]
|
#[cfg(feature = "dns")]
|
||||||
@ -243,7 +243,7 @@ impl<D: Driver + 'static> Stack<D> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current IP configuration.
|
/// Get the current IP configuration.
|
||||||
pub fn config(&self) -> Option<StaticConfig> {
|
pub fn config(&self) -> Option<StaticConfigV4> {
|
||||||
self.with(|_s, i| i.config.clone())
|
self.with(|_s, i| i.config.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ impl SocketStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Driver + 'static> Inner<D> {
|
impl<D: Driver + 'static> Inner<D> {
|
||||||
fn apply_config(&mut self, s: &mut SocketStack, config: StaticConfig) {
|
fn apply_config(&mut self, s: &mut SocketStack, config: StaticConfigV4) {
|
||||||
#[cfg(feature = "medium-ethernet")]
|
#[cfg(feature = "medium-ethernet")]
|
||||||
let medium = self.device.capabilities().medium;
|
let medium = self.device.capabilities().medium;
|
||||||
|
|
||||||
@ -470,7 +470,7 @@ impl<D: Driver + 'static> Inner<D> {
|
|||||||
None => {}
|
None => {}
|
||||||
Some(dhcpv4::Event::Deconfigured) => self.unapply_config(s),
|
Some(dhcpv4::Event::Deconfigured) => self.unapply_config(s),
|
||||||
Some(dhcpv4::Event::Configured(config)) => {
|
Some(dhcpv4::Event::Configured(config)) => {
|
||||||
let config = StaticConfig {
|
let config = StaticConfigV4 {
|
||||||
address: config.address,
|
address: config.address,
|
||||||
gateway: config.router,
|
gateway: config.router,
|
||||||
dns_servers: config.dns_servers,
|
dns_servers: config.dns_servers,
|
||||||
|
@ -98,7 +98,7 @@ async fn main(spawner: Spawner) {
|
|||||||
unwrap!(spawner.spawn(usb_ncm_task(runner)));
|
unwrap!(spawner.spawn(usb_ncm_task(runner)));
|
||||||
|
|
||||||
let config = embassy_net::Config::Dhcp(Default::default());
|
let config = embassy_net::Config::Dhcp(Default::default());
|
||||||
//let config = embassy_net::Config::Static(embassy_net::StaticConfig {
|
//let config = embassy_net::Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
||||||
// dns_servers: Vec::new(),
|
// dns_servers: Vec::new(),
|
||||||
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
||||||
|
@ -120,7 +120,7 @@ async fn listen_task(stack: &'static Stack<Device<'static>>, id: u8, port: u16)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfig {
|
async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfigV4 {
|
||||||
loop {
|
loop {
|
||||||
if let Some(config) = stack.config() {
|
if let Some(config) = stack.config() {
|
||||||
return config.clone();
|
return config.clone();
|
||||||
|
@ -108,7 +108,7 @@ async fn main(spawner: Spawner) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfig {
|
async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfigV4 {
|
||||||
loop {
|
loop {
|
||||||
if let Some(config) = stack.config() {
|
if let Some(config) = stack.config() {
|
||||||
return config.clone();
|
return config.clone();
|
||||||
|
@ -116,7 +116,7 @@ async fn main(spawner: Spawner) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfig {
|
async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfigV4 {
|
||||||
loop {
|
loop {
|
||||||
if let Some(config) = stack.config() {
|
if let Some(config) = stack.config() {
|
||||||
return config.clone();
|
return config.clone();
|
||||||
|
@ -95,7 +95,7 @@ async fn main(spawner: Spawner) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfig {
|
async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfigV4 {
|
||||||
loop {
|
loop {
|
||||||
if let Some(config) = stack.config() {
|
if let Some(config) = stack.config() {
|
||||||
return config.clone();
|
return config.clone();
|
||||||
|
@ -87,7 +87,7 @@ async fn main(spawner: Spawner) {
|
|||||||
unwrap!(spawner.spawn(usb_ncm_task(runner)));
|
unwrap!(spawner.spawn(usb_ncm_task(runner)));
|
||||||
|
|
||||||
let config = embassy_net::Config::Dhcp(Default::default());
|
let config = embassy_net::Config::Dhcp(Default::default());
|
||||||
//let config = embassy_net::Config::Static(embassy_net::StaticConfig {
|
//let config = embassy_net::Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
||||||
// dns_servers: Vec::new(),
|
// dns_servers: Vec::new(),
|
||||||
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
||||||
|
@ -62,7 +62,7 @@ async fn main(spawner: Spawner) {
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
// Use a link-local address for communication without DHCP server
|
// Use a link-local address for communication without DHCP server
|
||||||
let config = Config::Static(embassy_net::StaticConfig {
|
let config = Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
address: embassy_net::Ipv4Cidr::new(embassy_net::Ipv4Address::new(169, 254, 1, 1), 16),
|
address: embassy_net::Ipv4Cidr::new(embassy_net::Ipv4Address::new(169, 254, 1, 1), 16),
|
||||||
dns_servers: heapless::Vec::new(),
|
dns_servers: heapless::Vec::new(),
|
||||||
gateway: None,
|
gateway: None,
|
||||||
|
@ -62,7 +62,7 @@ async fn main(spawner: Spawner) {
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
let config = Config::Dhcp(Default::default());
|
let config = Config::Dhcp(Default::default());
|
||||||
//let config = embassy_net::Config::Static(embassy_net::Config {
|
//let config = embassy_net::Config::StaticV4(embassy_net::Config {
|
||||||
// address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24),
|
// address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24),
|
||||||
// dns_servers: Vec::new(),
|
// dns_servers: Vec::new(),
|
||||||
// gateway: Some(Ipv4Address::new(192, 168, 69, 1)),
|
// gateway: Some(Ipv4Address::new(192, 168, 69, 1)),
|
||||||
|
@ -42,7 +42,7 @@ async fn main_task(spawner: Spawner) {
|
|||||||
|
|
||||||
// Choose between dhcp or static ip
|
// Choose between dhcp or static ip
|
||||||
let config = if opts.static_ip {
|
let config = if opts.static_ip {
|
||||||
Config::Static(embassy_net::StaticConfig {
|
Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24),
|
address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24),
|
||||||
dns_servers: Vec::new(),
|
dns_servers: Vec::new(),
|
||||||
gateway: Some(Ipv4Address::new(192, 168, 69, 1)),
|
gateway: Some(Ipv4Address::new(192, 168, 69, 1)),
|
||||||
|
@ -40,7 +40,7 @@ async fn main_task(spawner: Spawner) {
|
|||||||
|
|
||||||
// Choose between dhcp or static ip
|
// Choose between dhcp or static ip
|
||||||
let config = if opts.static_ip {
|
let config = if opts.static_ip {
|
||||||
Config::Static(embassy_net::StaticConfig {
|
Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 1), 24),
|
address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 1), 24),
|
||||||
dns_servers: Vec::from_slice(&[Ipv4Address::new(8, 8, 4, 4).into(), Ipv4Address::new(8, 8, 8, 8).into()])
|
dns_servers: Vec::from_slice(&[Ipv4Address::new(8, 8, 4, 4).into(), Ipv4Address::new(8, 8, 8, 8).into()])
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
@ -38,7 +38,7 @@ async fn main_task(spawner: Spawner) {
|
|||||||
|
|
||||||
// Choose between dhcp or static ip
|
// Choose between dhcp or static ip
|
||||||
let config = if opts.static_ip {
|
let config = if opts.static_ip {
|
||||||
Config::Static(embassy_net::StaticConfig {
|
Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24),
|
address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24),
|
||||||
dns_servers: Vec::new(),
|
dns_servers: Vec::new(),
|
||||||
gateway: Some(Ipv4Address::new(192, 168, 69, 1)),
|
gateway: Some(Ipv4Address::new(192, 168, 69, 1)),
|
||||||
|
@ -53,7 +53,7 @@ async fn main_task(spawner: Spawner) {
|
|||||||
|
|
||||||
// Choose between dhcp or static ip
|
// Choose between dhcp or static ip
|
||||||
let config = if opts.static_ip {
|
let config = if opts.static_ip {
|
||||||
Config::Static(embassy_net::StaticConfig {
|
Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24),
|
address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24),
|
||||||
dns_servers: Vec::new(),
|
dns_servers: Vec::new(),
|
||||||
gateway: Some(Ipv4Address::new(192, 168, 69, 1)),
|
gateway: Some(Ipv4Address::new(192, 168, 69, 1)),
|
||||||
|
@ -95,7 +95,7 @@ async fn main(spawner: Spawner) {
|
|||||||
unwrap!(spawner.spawn(usb_ncm_task(runner)));
|
unwrap!(spawner.spawn(usb_ncm_task(runner)));
|
||||||
|
|
||||||
let config = embassy_net::Config::Dhcp(Default::default());
|
let config = embassy_net::Config::Dhcp(Default::default());
|
||||||
//let config = embassy_net::Config::Static(embassy_net::StaticConfig {
|
//let config = embassy_net::Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
||||||
// dns_servers: Vec::new(),
|
// dns_servers: Vec::new(),
|
||||||
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
||||||
|
@ -63,7 +63,7 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let config = embassy_net::Config::Dhcp(Default::default());
|
let config = embassy_net::Config::Dhcp(Default::default());
|
||||||
//let config = embassy_net::Config::Static(embassy_net::StaticConfig {
|
//let config = embassy_net::Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
||||||
// dns_servers: Vec::new(),
|
// dns_servers: Vec::new(),
|
||||||
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
||||||
|
@ -82,7 +82,7 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let config = embassy_net::Config::Dhcp(Default::default());
|
let config = embassy_net::Config::Dhcp(Default::default());
|
||||||
//let config = embassy_net::Config::Static(embassy_net::StaticConfig {
|
//let config = embassy_net::Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
||||||
// dns_servers: Vec::new(),
|
// dns_servers: Vec::new(),
|
||||||
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
||||||
|
@ -64,7 +64,7 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let config = embassy_net::Config::Dhcp(Default::default());
|
let config = embassy_net::Config::Dhcp(Default::default());
|
||||||
//let config = embassy_net::Config::Static(embassy_net::StaticConfig {
|
//let config = embassy_net::Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
||||||
// dns_servers: Vec::new(),
|
// dns_servers: Vec::new(),
|
||||||
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
||||||
|
@ -65,7 +65,7 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let config = embassy_net::Config::Dhcp(Default::default());
|
let config = embassy_net::Config::Dhcp(Default::default());
|
||||||
//let config = embassy_net::Config::StaticConfig(embassy_net::Config {
|
//let config = embassy_net::Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
||||||
// dns_servers: Vec::new(),
|
// dns_servers: Vec::new(),
|
||||||
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
||||||
|
@ -92,7 +92,7 @@ async fn main(spawner: Spawner) {
|
|||||||
unwrap!(spawner.spawn(usb_ncm_task(runner)));
|
unwrap!(spawner.spawn(usb_ncm_task(runner)));
|
||||||
|
|
||||||
let config = embassy_net::Config::Dhcp(Default::default());
|
let config = embassy_net::Config::Dhcp(Default::default());
|
||||||
//let config = embassy_net::Config::Static(embassy_net::StaticConfig {
|
//let config = embassy_net::Config::StaticV4(embassy_net::StaticConfigV4 {
|
||||||
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
|
||||||
// dns_servers: Vec::new(),
|
// dns_servers: Vec::new(),
|
||||||
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
|
||||||
|
Loading…
Reference in New Issue
Block a user