im not sure what im changing
This commit is contained in:
1 parent
e2d33a0db6
commit
6405bb5bf7
16 files changed
+128
-95
No files matched your search
@@ -0,0 +1,28 @@
|
||||
// ip address [ show [ dev IFNAME ] [ scope SCOPE-ID ] [ master DEVICE ]
|
||||
// [ type TYPE ] [ to PREFIX ] [ FLAG-LIST ]
|
||||
// [ label LABEL ] [up] [ vrf NAME ] ]
|
||||
// fuck is this mean
|
||||
|
||||
// do i need all this? do i need anything but `ip -j a show dev br-lan`?
|
||||
|
||||
// TYPE := { vlan | veth | vcan | vxcan | dummy | ifb | macvlan | macvtap |
|
||||
// bridge | bond | ipoib | ip6tnl | ipip | sit | vxlan | lowpan |
|
||||
// gre | gretap | erspan | ip6gre | ip6gretap | ip6erspan | vti |
|
||||
// nlmon | can | bond_slave | ipvlan | geneve | bridge_slave |
|
||||
// hsr | macsec | netdevsim }
|
||||
// FLAG-LIST := [ FLAG-LIST ] FLAG
|
||||
// FLAG := [ permanent | dynamic | secondary | primary |
|
||||
// [-]tentative | [-]deprecated | [-]dadfailed | temporary |
|
||||
// CONFFLAG-LIST ]
|
||||
// CONFFLAG-LIST := [ CONFFLAG-LIST ] CONFFLAG
|
||||
// CONFFLAG := [ home | nodad | mngtmpaddr | noprefixroute | autojoin ]
|
||||
|
||||
// prefix seems to be a cidr. both 6 and 4 works. idfk dog
|
||||
|
||||
use super::AddrInfo;
|
||||
|
||||
|
||||
|
||||
pub async fn get() -> Vec<AddrInfo> {
|
||||
todo!()
|
||||
}
|
||||
@@ -4,39 +4,38 @@
|
||||
//!
|
||||
//! lowk why its free but its indirection and its ass
|
||||
|
||||
use macaddr::MacAddr6;
|
||||
pub mod json;
|
||||
|
||||
use crate::utils::serialize::mac::option_mac;
|
||||
use macaddr::MacAddr;
|
||||
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>,
|
||||
pub struct AddrOutput {
|
||||
pub ifindex: u32,
|
||||
pub ifname: String,
|
||||
/// i imagine UP or DOWN, unknown
|
||||
pub operstate: String,
|
||||
// 6 has a serde and the enum doesnt? why. (serializing ts is ass although... im not given an array. they string formatted ts)
|
||||
#[serde(with = "option_mac", default)]
|
||||
pub address: Option<MacAddr>,
|
||||
#[serde(default)] // i wish we have intellisense for this... fuck you metaprogramming
|
||||
pub 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>,
|
||||
pub struct AddrInfo {
|
||||
pub family: Option<String>,
|
||||
|
||||
local: Option<String>,
|
||||
prefixlen: Option<u8>,
|
||||
pub local: Option<String>,
|
||||
pub prefixlen: Option<u8>,
|
||||
|
||||
broadcast: Option<String>,
|
||||
pub broadcast: Option<String>,
|
||||
|
||||
scope: Option<String>,
|
||||
label: Option<String>,
|
||||
pub scope: Option<String>,
|
||||
pub label: Option<String>,
|
||||
// many more exist; we only take what we need
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
pub mod json;
|
||||
pub mod nl;
|
||||
|
||||
use crate::utils::serialize::mac::{des_opm, ser_opm};
|
||||
use crate::utils::serialize::mac::option_mac;
|
||||
use std::net::IpAddr;
|
||||
|
||||
use macaddr::MacAddr;
|
||||
@@ -17,11 +17,11 @@ 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>,
|
||||
pub to: Option<IpAddr>,
|
||||
/// supports only one item (it complains if multiple)
|
||||
dev: Option<String>, // im all for simplicity
|
||||
pub dev: Option<String>, // im all for simplicity
|
||||
/// takes multiple, has to have `nud` before bro or it will think you `to`
|
||||
nud: Vec<NUDState>,
|
||||
pub nud: Vec<NUDState>,
|
||||
}
|
||||
|
||||
// as input this must be lowercase. as output it is uppercase
|
||||
@@ -64,21 +64,18 @@ pub enum NUDState {
|
||||
/// success, neighbor validation has ultimately
|
||||
/// failed.
|
||||
Failed,
|
||||
|
||||
Other(u16)
|
||||
}
|
||||
|
||||
/// everything i see
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
|
||||
pub struct NeighborItem {
|
||||
#[serde(rename(deserialize = "dst"))]
|
||||
ip: IpAddr,
|
||||
dev: String,
|
||||
#[serde(
|
||||
deserialize_with = "des_opm",
|
||||
serialize_with = "ser_opm",
|
||||
default,
|
||||
rename(deserialize = "lladdr")
|
||||
)]
|
||||
mac: Option<MacAddr>,
|
||||
pub ip: IpAddr,
|
||||
pub dev: String,
|
||||
#[serde(with = "option_mac", default, rename(deserialize = "lladdr"))]
|
||||
pub mac: Option<MacAddr>,
|
||||
#[serde(default)]
|
||||
state: Vec<NUDState>,
|
||||
pub state: Vec<NUDState>,
|
||||
}
|
||||
@@ -134,7 +134,7 @@ impl TryFrom<NeighbourState> for NUDState {
|
||||
NeighbourState::Noarp => Ok(Self::Noarp),
|
||||
NeighbourState::Permanent => Ok(Self::Permanent),
|
||||
NeighbourState::None => Ok(Self::None),
|
||||
NeighbourState::Other(e) => Err(e),
|
||||
NeighbourState::Other(e) => Ok(Self::Other(e)),
|
||||
_ => Err(u16::MAX), // idk
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user