Struct netflow_parser::NetflowParser
source · pub struct NetflowParser {
pub v9_parser: V9Parser,
pub ipfix_parser: IPFixParser,
}Fields§
§v9_parser: V9Parser§ipfix_parser: IPFixParserImplementations§
source§impl NetflowParser
impl NetflowParser
sourcepub fn parse_bytes(&mut self, packet: &[u8]) -> Vec<NetflowPacketResult>
pub fn parse_bytes(&mut self, packet: &[u8]) -> Vec<NetflowPacketResult>
Takes a Netflow packet slice and returns a vector of Parsed Netflows. If we reach some parse error we return what items be have.
Examples
use serde_json::json;
use netflow_parser::NetflowParser;
let v5_packet = [0, 5, 2, 0, 3, 0, 4, 0, 5, 0, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7,];
println!("{}", json!(NetflowParser::default().parse_bytes(&v5_packet)).to_string());Output:
[{"V5":{"body":{"d_octets":66051,"d_pkts":101124105,"dst_addr":"4.5.6.7","dst_as":515,"dst_mask":5,"dst_port":1029,"first":67438087,"input":515,"last":134807553,"next_hop":"8.9.0.1","output":1029,"pad1":6,"pad2":1543,"protocol":"EGP","src_addr":"0.1.2.3","src_as":1,"src_mask":4,"src_port":515,"tcp_flags":7,"tos":9},"header":{"count":512,"engine_id":7,"engine_type":6,"flow_sequence":33752069,"sampling_interval":2057,"sys_up_time":50332672,"unix_nsecs":134807553,"unix_secs":83887623,"unix_time":{"nanos_since_epoch":134807553,"secs_since_epoch":83887623},"version":5}}}]
Trait Implementations§
source§impl Debug for NetflowParser
impl Debug for NetflowParser
source§impl Default for NetflowParser
impl Default for NetflowParser
source§fn default() -> NetflowParser
fn default() -> NetflowParser
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl RefUnwindSafe for NetflowParser
impl Send for NetflowParser
impl Sync for NetflowParser
impl Unpin for NetflowParser
impl UnwindSafe for NetflowParser
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more