Skip to content

Commit

Permalink
fix value parsin
Browse files Browse the repository at this point in the history
  • Loading branch information
pythops committed Sep 22, 2024
1 parent eb5218f commit 3c88be1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 deletions.
16 changes: 8 additions & 8 deletions oryx-tui/src/packets/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl IpPacket {
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Length(20), Constraint::Length(13)])
.flex(ratatui::layout::Flex::SpaceBetween)
.flex(ratatui::layout::Flex::SpaceAround)
.margin(2)
.split(block);

Expand All @@ -41,7 +41,7 @@ impl IpPacket {
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Length(8), Constraint::Length(13)])
.flex(ratatui::layout::Flex::SpaceBetween)
.flex(ratatui::layout::Flex::SpaceAround)
.margin(2)
.split(block);

Expand All @@ -55,7 +55,7 @@ impl IpPacket {
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Length(7), Constraint::Length(13)])
.flex(ratatui::layout::Flex::SpaceBetween)
.flex(ratatui::layout::Flex::SpaceAround)
.margin(2)
.split(block);

Expand All @@ -71,7 +71,7 @@ impl IpPacket {
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Length(20), Constraint::Length(9)])
.flex(ratatui::layout::Flex::SpaceBetween)
.flex(ratatui::layout::Flex::SpaceAround)
.margin(2)
.split(block);

Expand All @@ -86,7 +86,7 @@ impl IpPacket {
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Length(8), Constraint::Length(9)])
.flex(ratatui::layout::Flex::SpaceBetween)
.flex(ratatui::layout::Flex::SpaceAround)
.margin(2)
.split(block);

Expand All @@ -100,7 +100,7 @@ impl IpPacket {
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Length(7), Constraint::Length(9)])
.flex(ratatui::layout::Flex::SpaceBetween)
.flex(ratatui::layout::Flex::SpaceAround)
.margin(2)
.split(block);

Expand Down Expand Up @@ -187,7 +187,7 @@ impl Ipv4Packet {
]),
Row::new(vec![
Span::styled("Checksum", Style::new().bold()),
Span::from(format!("{:0x}", self.checksum)),
Span::from(format!("{:#0x}", self.checksum)),
]),
];

Expand Down Expand Up @@ -326,7 +326,7 @@ impl IcmpPacket {
]),
Row::new(vec![
Span::styled("Checksum", Style::new().bold()),
Span::from(self.checksum.to_string()),
Span::from(format!("{:#0x}", self.checksum)),
]),
];

Expand Down
58 changes: 29 additions & 29 deletions oryx-tui/src/packets/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ impl From<[u8; RawPacket::LEN]> for AppPacket {
dst_port: u16::from_be(tcp_header.dest),
seq: u32::from_be(tcp_header.seq),
ack_seq: u32::from_be(tcp_header.ack_seq),
data_offset: u16::from_be(tcp_header.doff()),
cwr: u16::from_be(tcp_header.cwr()),
ece: u16::from_be(tcp_header.ece()),
urg: u16::from_be(tcp_header.urg()),
ack: u16::from_be(tcp_header.ack()),
psh: u16::from_be(tcp_header.psh()),
rst: u16::from_be(tcp_header.rst()),
syn: u16::from_be(tcp_header.syn()),
fin: u16::from_be(tcp_header.fin()),
data_offset: tcp_header.doff(),
cwr: tcp_header.cwr(),
ece: tcp_header.ece(),
urg: tcp_header.urg(),
ack: tcp_header.ack(),
psh: tcp_header.psh(),
rst: tcp_header.rst(),
syn: tcp_header.syn(),
fin: tcp_header.fin(),
window: u16::from_be(tcp_header.window),
checksum: u16::from_be(tcp_header.check),
urg_ptr: u16::from_be(tcp_header.urg_ptr),
Expand Down Expand Up @@ -90,13 +90,13 @@ impl From<[u8; RawPacket::LEN]> for AppPacket {
AppPacket::Ip(IpPacket::V4(Ipv4Packet {
src_ip,
dst_ip,
ihl: ipv4_packet.ihl(),
tos: ipv4_packet.tos,
total_length: ipv4_packet.tot_len,
id: ipv4_packet.id,
fragment_offset: ipv4_packet.frag_off,
ttl: ipv4_packet.ttl,
checksum: ipv4_packet.check,
ihl: u8::from_be(ipv4_packet.ihl()),
tos: u8::from_be(ipv4_packet.tos),
total_length: u16::from_be(ipv4_packet.tot_len),
id: u16::from_be(ipv4_packet.id),
fragment_offset: u16::from_be(ipv4_packet.frag_off),
ttl: u8::from_be(ipv4_packet.ttl),
checksum: u16::from_be(ipv4_packet.check),
proto,
}))
}
Expand All @@ -110,15 +110,15 @@ impl From<[u8; RawPacket::LEN]> for AppPacket {
dst_port: u16::from_be(tcp_header.dest),
seq: u32::from_be(tcp_header.seq),
ack_seq: u32::from_be(tcp_header.ack_seq),
data_offset: u16::from_be(tcp_header.doff()),
cwr: u16::from_be(tcp_header.cwr()),
ece: u16::from_be(tcp_header.ece()),
urg: u16::from_be(tcp_header.urg()),
ack: u16::from_be(tcp_header.ack()),
psh: u16::from_be(tcp_header.psh()),
rst: u16::from_be(tcp_header.rst()),
syn: u16::from_be(tcp_header.syn()),
fin: u16::from_be(tcp_header.fin()),
data_offset: tcp_header.doff(),
cwr: tcp_header.cwr(),
ece: tcp_header.ece(),
urg: tcp_header.urg(),
ack: tcp_header.ack(),
psh: tcp_header.psh(),
rst: tcp_header.rst(),
syn: tcp_header.syn(),
fin: tcp_header.fin(),
window: u16::from_be(tcp_header.window),
checksum: u16::from_be(tcp_header.check),
urg_ptr: u16::from_be(tcp_header.urg_ptr),
Expand Down Expand Up @@ -156,8 +156,8 @@ impl From<[u8; RawPacket::LEN]> for AppPacket {
AppPacket::Ip(IpPacket::V6(Ipv6Packet {
traffic_class: ipv6_packet.priority(),
flow_label: ipv6_packet.flow_label,
payload_length: ipv6_packet.payload_len,
hop_limit: ipv6_packet.hop_limit,
payload_length: u16::from_be(ipv6_packet.payload_len),
hop_limit: u8::from_be(ipv6_packet.hop_limit),
src_ip,
dst_ip,
proto,
Expand All @@ -174,8 +174,8 @@ impl From<[u8; RawPacket::LEN]> for AppPacket {
Self::Arp(ArpPacket {
htype: packet.ptype,
ptype: packet.ptype,
hlen: packet.hlen,
plen: packet.plen,
hlen: u8::from_be(packet.hlen),
plen: u8::from_be(packet.plen),
arp_type,
src_mac: MacAddr(packet.sha),
src_ip: Ipv4Addr::from(packet.spa),
Expand Down
6 changes: 3 additions & 3 deletions oryx-tui/src/packets/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl TcpPacket {
]),
Row::new(vec![
Span::styled("Checksum", Style::new().bold()),
Span::from(self.checksum.to_string()),
Span::from(format!("{:#0x}", self.checksum)),
]),
Row::new(vec![
Span::styled("Urgent Pointer", Style::new().bold()),
Expand Down Expand Up @@ -169,11 +169,11 @@ impl UdpPacket {
]),
Row::new(vec![
Span::styled("Length", Style::new().bold()),
Span::from(self.length.to_string()),
Span::from(format!("{} bytes", self.length)),
]),
Row::new(vec![
Span::styled("Checksum", Style::new().bold()),
Span::from(self.checksum.to_string()),
Span::from(format!("{:#0x}", self.checksum)),
]),
];

Expand Down

0 comments on commit 3c88be1

Please sign in to comment.