mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-08 04:56:43 +00:00
add a static variable to contain our IPV4 address
this is used to do address binding checking from library calls, so we can reject binding to address that are not our actual IP address.
This commit is contained in:
parent
f2193d64b1
commit
7541d39fd6
1 changed files with 12 additions and 0 deletions
|
|
@ -18,6 +18,11 @@ use num_traits::*;
|
|||
mod connection_manager;
|
||||
mod device;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
#[cfg(feature="btest")]
|
||||
mod btests;
|
||||
|
||||
use std::collections::{BTreeMap, HashMap, BTreeSet};
|
||||
use std::convert::TryInto;
|
||||
use xous::{msg_blocking_scalar_unpack, msg_scalar_unpack, send_message, Message, CID, SID};
|
||||
|
|
@ -43,6 +48,9 @@ use std::sync::mpsc::{channel, Sender};
|
|||
use std::thread;
|
||||
use std::cmp::Ordering as CmpOrdering;
|
||||
|
||||
// 0 indicates no address is currently assigned
|
||||
pub static IPV4_ADDRESS: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
const PING_DEFAULT_TIMEOUT_MS: u32 = 10_000;
|
||||
const MAX_DELAY_THREADS: u32 = 9;
|
||||
const PING_IDENT: u16 = 0x22b;
|
||||
|
|
@ -1074,6 +1082,8 @@ fn main() -> ! {
|
|||
std::net::IpAddr::from(config.addr),
|
||||
xous::BOOKEND_END);
|
||||
net_config = Some(config);
|
||||
// update a static variable that tracks this, useful for e.g. UDP bind address checking
|
||||
IPV4_ADDRESS.store(u32::from_be_bytes(config.addr), Ordering::SeqCst);
|
||||
|
||||
// note: ARP cache is stale. Maybe that's ok?
|
||||
|
||||
|
|
@ -1868,6 +1878,8 @@ fn main() -> ! {
|
|||
}
|
||||
}),
|
||||
Some(Opcode::Reset) => {
|
||||
// reset the DHCP address
|
||||
IPV4_ADDRESS.store(0, Ordering::SeqCst);
|
||||
// ack any pending ints
|
||||
com_int_list.clear();
|
||||
com.ints_get_active(&mut com_int_list).ok();
|
||||
|
|
|
|||
Loading…
Reference in a new issue