Skip to content

Commit dcddb4f

Browse files
added cool arrow like in tshark, added window size to tcp summary
1 parent 16b0a7d commit dcddb4f

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

layers/ethernet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (ef *EthernetFrame) String() string {
6363
}
6464

6565
func (ef *EthernetFrame) Summary() string {
66-
return fmt.Sprintf("Ethernet Frame: Src MAC: %s -> Dst MAC: %s", ef.SrcMAC, ef.DstMAC)
66+
return fmt.Sprintf("Ethernet Frame: Src MAC: %s Dst MAC: %s", ef.SrcMAC, ef.DstMAC)
6767
}
6868

6969
func (ef *EthernetFrame) MarshalBinary() ([]byte, error) {

layers/ipv4.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ func newIPv4Flags(flags uint8) *IPv4Flags {
2222
return &IPv4Flags{
2323
Reserved: (flags >> 2) & 1,
2424
DF: (flags >> 1) & 1,
25-
MF: flags & 1}
25+
MF: flags & 1,
26+
}
2627
}
2728

2829
// Internet Protocol version 4 is described in IETF publication RFC 791.
@@ -86,7 +87,7 @@ func (p *IPv4Packet) String() string {
8687
}
8788

8889
func (p *IPv4Packet) Summary() string {
89-
return fmt.Sprintf("IPv4 Packet: Src IP: %s -> Dst IP: %s", p.SrcIP, p.DstIP)
90+
return fmt.Sprintf("IPv4 Packet: Src IP: %s Dst IP: %s", p.SrcIP, p.DstIP)
9091
}
9192

9293
// Parse parses the given byte data into an IPv4 packet struct.

layers/ipv6.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ func newTrafficiClass(tc uint8) *TrafficClass {
2121
Raw: tc,
2222
DSCP: dscpbin,
2323
DSCPDesc: dscpdesc(dscpbin),
24-
ECN: tc & 3}
24+
ECN: tc & 3,
25+
}
2526
}
2627

2728
func (p *TrafficClass) String() string {
@@ -71,7 +72,7 @@ func (p *IPv6Packet) String() string {
7172
}
7273

7374
func (p *IPv6Packet) Summary() string {
74-
return fmt.Sprintf("IPv6 Packet: Src IP: %s -> Dst IP: %s", p.SrcIP, p.DstIP)
75+
return fmt.Sprintf("IPv6 Packet: Src IP: %s Dst IP: %s", p.SrcIP, p.DstIP)
7576
}
7677

7778
// Parse parses the given byte data into an IPv6 packet struct.

layers/tcp.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ func (t *TCPSegment) String() string {
9999
}
100100

101101
func (t *TCPSegment) Summary() string {
102-
return fmt.Sprintf("TCP Segment: Src Port: %d -> Dst Port: %d %s Len: %d", t.SrcPort, t.DstPort, t.Flags, len(t.payload))
102+
return fmt.Sprintf(
103+
"TCP Segment: Src Port: %d → Dst Port: %d [%s] Win: %d Len: %d",
104+
t.SrcPort,
105+
t.DstPort,
106+
t.Flags,
107+
t.WindowSize,
108+
len(t.payload),
109+
)
103110
}
104111

105112
// Parse parses the given byte data into a TCPSegment struct.

layers/udp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (u *UDPSegment) String() string {
3434
}
3535

3636
func (u *UDPSegment) Summary() string {
37-
return fmt.Sprintf("UDP Segment: Src Port: %d -> Dst Port: %d Len: %d", u.SrcPort, u.DstPort, len(u.payload))
37+
return fmt.Sprintf("UDP Segment: Src Port: %d Dst Port: %d Len: %d", u.SrcPort, u.DstPort, len(u.payload))
3838
}
3939

4040
// Parse parses the given byte data into a UDPSegment struct.

0 commit comments

Comments
 (0)