Rename StaticConfig to StaticConfigV4

This commit is contained in:
Ruben De Smet 2023-06-05 14:57:17 +02:00
parent 44624b2d7a
commit 54bab33c73
No known key found for this signature in database
GPG Key ID: 1AE26A210C14115B
19 changed files with 24 additions and 24 deletions

View File

@ -68,7 +68,7 @@ impl<const SOCK: usize> StackResources<SOCK> {
/// Static IP address configuration.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StaticConfig {
pub struct StaticConfigV4 {
/// IP address and subnet mask.
pub address: Ipv4Cidr,
/// Default gateway.
@ -114,7 +114,7 @@ impl Default for DhcpConfig {
/// Network stack configuration.
pub enum Config {
/// Use a static IP address configuration.
Static(StaticConfig),
Static(StaticConfigV4),
/// Use DHCP to obtain an IP address configuration.
#[cfg(feature = "dhcpv4")]
Dhcp(DhcpConfig),
@ -131,7 +131,7 @@ pub struct Stack<D: Driver> {
struct Inner<D: Driver> {
device: D,
link_up: bool,
config: Option<StaticConfig>,
config: Option<StaticConfigV4>,
#[cfg(feature = "dhcpv4")]
dhcp_socket: Option<SocketHandle>,
#[cfg(feature = "dns")]
@ -243,7 +243,7 @@ impl<D: Driver + 'static> Stack<D> {
}
/// Get the current IP configuration.
pub fn config(&self) -> Option<StaticConfig> {
pub fn config(&self) -> Option<StaticConfigV4> {
self.with(|_s, i| i.config.clone())
}
@ -374,7 +374,7 @@ impl SocketStack {
}
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")]
let medium = self.device.capabilities().medium;
@ -470,7 +470,7 @@ impl<D: Driver + 'static> Inner<D> {
None => {}
Some(dhcpv4::Event::Deconfigured) => self.unapply_config(s),
Some(dhcpv4::Event::Configured(config)) => {
let config = StaticConfig {
let config = StaticConfigV4 {
address: config.address,
gateway: config.router,
dns_servers: config.dns_servers,

View File

@ -98,7 +98,7 @@ async fn main(spawner: Spawner) {
unwrap!(spawner.spawn(usb_ncm_task(runner)));
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),
// dns_servers: Vec::new(),
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),

View File

@ -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 {
if let Some(config) = stack.config() {
return config.clone();

View File

@ -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 {
if let Some(config) = stack.config() {
return config.clone();

View File

@ -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 {
if let Some(config) = stack.config() {
return config.clone();

View File

@ -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 {
if let Some(config) = stack.config() {
return config.clone();

View File

@ -87,7 +87,7 @@ async fn main(spawner: Spawner) {
unwrap!(spawner.spawn(usb_ncm_task(runner)));
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),
// dns_servers: Vec::new(),
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),

View File

@ -62,7 +62,7 @@ async fn main(spawner: Spawner) {
.await;
// 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),
dns_servers: heapless::Vec::new(),
gateway: None,

View File

@ -62,7 +62,7 @@ async fn main(spawner: Spawner) {
.await;
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),
// dns_servers: Vec::new(),
// gateway: Some(Ipv4Address::new(192, 168, 69, 1)),

View File

@ -42,7 +42,7 @@ async fn main_task(spawner: Spawner) {
// Choose between dhcp or 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),
dns_servers: Vec::new(),
gateway: Some(Ipv4Address::new(192, 168, 69, 1)),

View File

@ -40,7 +40,7 @@ async fn main_task(spawner: Spawner) {
// Choose between dhcp or 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),
dns_servers: Vec::from_slice(&[Ipv4Address::new(8, 8, 4, 4).into(), Ipv4Address::new(8, 8, 8, 8).into()])
.unwrap(),

View File

@ -38,7 +38,7 @@ async fn main_task(spawner: Spawner) {
// Choose between dhcp or 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),
dns_servers: Vec::new(),
gateway: Some(Ipv4Address::new(192, 168, 69, 1)),

View File

@ -53,7 +53,7 @@ async fn main_task(spawner: Spawner) {
// Choose between dhcp or 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),
dns_servers: Vec::new(),
gateway: Some(Ipv4Address::new(192, 168, 69, 1)),

View File

@ -95,7 +95,7 @@ async fn main(spawner: Spawner) {
unwrap!(spawner.spawn(usb_ncm_task(runner)));
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),
// dns_servers: Vec::new(),
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),

View File

@ -63,7 +63,7 @@ async fn main(spawner: Spawner) -> ! {
);
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),
// dns_servers: Vec::new(),
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),

View File

@ -82,7 +82,7 @@ async fn main(spawner: Spawner) -> ! {
);
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),
// dns_servers: Vec::new(),
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),

View File

@ -64,7 +64,7 @@ async fn main(spawner: Spawner) -> ! {
);
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),
// dns_servers: Vec::new(),
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),

View File

@ -65,7 +65,7 @@ async fn main(spawner: Spawner) -> ! {
);
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),
// dns_servers: Vec::new(),
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),

View File

@ -92,7 +92,7 @@ async fn main(spawner: Spawner) {
unwrap!(spawner.spawn(usb_ncm_task(runner)));
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),
// dns_servers: Vec::new(),
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),