use alloc::vec::Vec;
use core::net::IpAddr;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HostDef<'a> {
pub name: &'a str,
pub ip: IpAddr,
pub mac: Option<[u8; 6]>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Direction {
LeftToRight, RightToLeft, }
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TcpFlag {
Syn,
Ack,
Fin,
Rst,
Psh,
Urg,
Ece,
Cwr,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Protocol {
Tcp,
Udp,
Snmp1,
Snmp2,
Snmp3,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SnmpPduType {
Trap,
Get,
Set,
Response,
Inform,
GetNext,
GetBulk,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SnmpAuthType {
Md5,
Sha,
Sha256,
Sha384,
Sha512,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SnmpPrivType {
Des,
Aes,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum VarBindType<'a> {
Null,
String(&'a str),
Int(i32),
TimeTicks(u32),
Ip(IpAddr),
OidVal(&'a str),
Counter32(u32),
Gauge32(u32),
Counter64(u64),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct VarBindAst<'a> {
pub oid: &'a str,
pub val: VarBindType<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FrameStatement<'a> {
pub caller: &'a str,
pub dir: Direction,
pub callee: &'a str,
pub protocol: Protocol,
pub src_port: Option<u16>,
pub dst_port: Option<u16>,
pub flags: Vec<TcpFlag>,
pub seq: Option<u32>,
pub ack_num: Option<u32>,
pub win: Option<u16>,
pub payload: Option<&'a str>,
pub community: Option<&'a str>,
pub user: Option<&'a str>,
pub oid: Option<&'a str>,
pub sys_up_time: Option<u32>,
pub pdu_type: Option<SnmpPduType>,
pub enterprise: Option<&'a str>,
pub agent_ip: Option<IpAddr>,
pub gen_trap: Option<u32>,
pub spec_trap: Option<u32>,
pub engine_id: Option<&'a str>,
pub engine_boots: Option<u32>,
pub engine_time: Option<u32>,
pub context_name: Option<&'a str>,
pub auth: Option<(SnmpAuthType, &'a str)>,
pub priv_param: Option<(SnmpPrivType, &'a str)>,
pub varbinds: Vec<VarBindAst<'a>>,
pub non_repeaters: Option<u32>,
pub max_repetitions: Option<u32>,
pub req_id: Option<u32>,
pub wait: Option<u64>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FlowDef<'a> {
pub name: &'a str,
pub params: Vec<&'a str>,
pub statements: Vec<FrameStatement<'a>>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Argument<'a> {
Variable(&'a str),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TemplateInvocation<'a> {
pub name: &'a str,
pub args: Vec<Argument<'a>>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum RunStatement<'a> {
Invocation(TemplateInvocation<'a>),
Loop(u32, Vec<TemplateInvocation<'a>>),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Program<'a> {
pub hosts: Vec<HostDef<'a>>,
pub flows: Vec<FlowDef<'a>>,
pub compile_block: Vec<RunStatement<'a>>,
}