@@ -2,7 +2,7 @@ use clap::ArgMatches;
22use itertools:: Itertools ;
33use oryx_common:: {
44 protocols:: { LinkProtocol , NetworkProtocol , TransportProtocol } ,
5- RawPacket ,
5+ RawFrame ,
66} ;
77use ratatui:: {
88 layout:: { Constraint , Direction , Layout } ,
@@ -19,7 +19,7 @@ use std::{
1919use crate :: {
2020 filter:: Filter ,
2121 help:: Help ,
22- packet:: { direction:: TrafficDirection , NetworkPacket } ,
22+ packet:: { direction:: TrafficDirection , EthFrame } ,
2323} ;
2424use crate :: { filter:: IoChannels , notification:: Notification } ;
2525use crate :: { packet:: AppPacket , section:: Section } ;
@@ -39,7 +39,7 @@ pub enum ActivePopup {
3939
4040#[ derive( Debug ) ]
4141pub struct DataEventHandler {
42- pub sender : kanal:: Sender < [ u8 ; RawPacket :: LEN ] > ,
42+ pub sender : kanal:: Sender < [ u8 ; RawFrame :: LEN ] > ,
4343 pub handler : thread:: JoinHandle < ( ) > ,
4444}
4545
@@ -49,39 +49,39 @@ pub struct App {
4949 pub help : Help ,
5050 pub filter : Filter ,
5151 pub start_sniffing : bool ,
52- pub packets : Arc < RwLock < Vec < AppPacket > > > ,
52+ pub frames : Arc < RwLock < Vec < AppPacket > > > ,
5353 pub notifications : Vec < Notification > ,
5454 pub section : Section ,
55- pub data_channel_sender : kanal:: Sender < ( [ u8 ; RawPacket :: LEN ] , TrafficDirection ) > ,
55+ pub data_channel_sender : kanal:: Sender < ( [ u8 ; RawFrame :: LEN ] , TrafficDirection ) > ,
5656 pub is_editing : bool ,
5757 pub active_popup : Option < ActivePopup > ,
5858 pub start_from_cli : bool ,
5959}
6060
6161impl App {
6262 pub fn new ( cli_args : & ArgMatches ) -> Self {
63- let packets = Arc :: new ( RwLock :: new ( Vec :: with_capacity (
64- RawPacket :: LEN * 1024 * 1024 ,
65- ) ) ) ;
63+ let frames = Arc :: new ( RwLock :: new ( Vec :: with_capacity ( RawFrame :: LEN * 1024 * 1024 ) ) ) ;
6664
6765 let ( sender, receiver) = kanal:: unbounded ( ) ;
6866
6967 let firewall_channels = IoChannels :: new ( ) ;
7068
7169 thread:: spawn ( {
72- let packets = packets . clone ( ) ;
70+ let frames = frames . clone ( ) ;
7371 move || loop {
74- if let Ok ( ( raw_packet, direction) ) = receiver. recv ( ) {
75- let network_packet = NetworkPacket :: from ( raw_packet) ;
76- let mut packets = packets. write ( ) . unwrap ( ) ;
77- if packets. len ( ) == packets. capacity ( ) {
78- packets. reserve ( 1024 * 1024 ) ;
72+ if let Ok ( ( raw_frame, direction) ) = receiver. recv ( ) {
73+ let eth_frame = EthFrame :: from ( raw_frame) ;
74+ let network_packet = eth_frame. payload ;
75+ let mut frames = frames. write ( ) . unwrap ( ) ;
76+ if frames. len ( ) == frames. capacity ( ) {
77+ frames. reserve ( 1024 * 1024 ) ;
7978 }
8079 let app_packet = AppPacket {
80+ eth_header : eth_frame. header ,
8181 packet : network_packet,
8282 direction,
8383 } ;
84- packets . push ( app_packet) ;
84+ frames . push ( app_packet) ;
8585 }
8686 }
8787 } ) ;
@@ -186,9 +186,9 @@ impl App {
186186 direction,
187187 ) ,
188188 start_sniffing : false ,
189- packets : packets . clone ( ) ,
189+ frames : frames . clone ( ) ,
190190 notifications : Vec :: new ( ) ,
191- section : Section :: new ( packets . clone ( ) , firewall_channels. clone ( ) ) ,
191+ section : Section :: new ( frames . clone ( ) , firewall_channels. clone ( ) ) ,
192192 data_channel_sender : sender,
193193 is_editing : false ,
194194 active_popup : None ,
0 commit comments