chat has a vision (idk the state i jus want to commit)
This commit is contained in:
1 parent
a534c58262
commit
0d9d800daf
4 files changed
+53
-6
No files matched your search
@@ -0,0 +1,42 @@
|
||||
//! ts
|
||||
//!
|
||||
//! deals with both ip a (addroutput) and ip l (commonoutput)
|
||||
//!
|
||||
//! lowk why its free but its indirection and its ass
|
||||
|
||||
use macaddr::{MacAddr, MacAddr6};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// i dont include what i dont know about (almost all ts)
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct CommmonOutput {
|
||||
ifindex: u32,
|
||||
ifname: String,
|
||||
/// i imagine UP or DOWN, unknown
|
||||
operstate: String,
|
||||
// 6 has a serde and the enum doesnt? why.
|
||||
address: Option<MacAddr6>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Deserialize)]
|
||||
struct AddrOutput {
|
||||
#[serde(flatten)]
|
||||
c: CommmonOutput,
|
||||
addr_info: Vec<AddrInfo>,
|
||||
}
|
||||
|
||||
// i be copying
|
||||
// Raw JSON shape from ip -j -4 address show
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
struct AddrInfo {
|
||||
family: Option<String>,
|
||||
|
||||
local: Option<String>,
|
||||
prefixlen: Option<u8>,
|
||||
|
||||
broadcast: Option<String>,
|
||||
|
||||
scope: Option<String>,
|
||||
label: Option<String>,
|
||||
// many more exist; we only take what we need
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
pub mod neighbor;
|
||||
pub mod address;
|
||||
@@ -0,0 +1,72 @@
|
||||
//! ```bash
|
||||
//! ip -j n s
|
||||
//! ```
|
||||
//!
|
||||
//! yes. this is a real call.
|
||||
|
||||
use crate::utils::serialize::mac::{des_opm, ser_opm};
|
||||
use std::net::IpAddr;
|
||||
|
||||
use macaddr::MacAddr;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strum::{Display, EnumString};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
|
||||
pub struct NeighborInput {
|
||||
/// supports only the last item (ignore), `to` keyword is optional
|
||||
to: Option<IpAddr>,
|
||||
/// supports only one item (it complains if multiple)
|
||||
dev: Option<String>, // im all for simplicity
|
||||
/// takes multiple, has to have `nud` before bro or it will think you `to`
|
||||
nud: Vec<NUDState>,
|
||||
}
|
||||
|
||||
// as input this must be lowercase. as output it is uppercase
|
||||
/// docs for items come from a random ahh man website idk
|
||||
#[derive(Debug, PartialEq, Eq, EnumString, Display, Clone, Copy, Hash, Serialize, Deserialize)]
|
||||
#[strum(serialize_all = "lowercase", ascii_case_insensitive)]
|
||||
#[serde(rename_all = "UPPERCASE")]
|
||||
pub enum NUDState {
|
||||
/// the neighbour entry is valid forever and can
|
||||
/// be only be removed administratively.
|
||||
Permanent,
|
||||
/// the neighbour entry is valid. No attempts to
|
||||
/// validate this entry will be made but it can
|
||||
/// be removed when its lifetime expires.
|
||||
Noarp,
|
||||
/// the neighbour entry is valid until the
|
||||
/// reachability timeout expires.
|
||||
Reachable,
|
||||
/// the neighbour entry is valid but suspicious.
|
||||
/// This option to ip neigh does not change the
|
||||
/// neighbour state if it was valid and the
|
||||
/// address is not changed by this command.
|
||||
Stale,
|
||||
/// this is a pseudo state used when initially
|
||||
/// creating a neighbour entry or after trying to
|
||||
/// remove it before it becomes free to do so.
|
||||
None,
|
||||
/// the neighbour entry has not (yet) been
|
||||
/// validated/resolved.
|
||||
Incomplete,
|
||||
/// neighbor entry validation is currently
|
||||
/// delayed.
|
||||
Delay,
|
||||
/// neighbor is being probed.
|
||||
Probe,
|
||||
/// max number of probes exceeded without
|
||||
/// success, neighbor validation has ultimately
|
||||
/// failed.
|
||||
Failed,
|
||||
}
|
||||
|
||||
|
||||
/// everything i see
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
|
||||
pub struct NeighborItem {
|
||||
dst: IpAddr,
|
||||
dev: String,
|
||||
#[serde(deserialize_with = "des_opm", serialize_with = "ser_opm")]
|
||||
lladdr: Option<MacAddr>,
|
||||
state: Vec<NUDState>,
|
||||
}
|
||||
Reference in new issue
Block a user