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,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Protocol {
Tcp,
Udp,
Snmp1,
Snmp2,
Snmp3,
}
#[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 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>>,
}