Skip to content

Commit 4fbfce1

Browse files
author
Preetam Jinka
committed
add more comments
1 parent e3206cc commit 4fbfce1

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

errors.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ import (
55
)
66

77
var (
8+
// ErrorNotEnoughBytes is returned when the length of the []byte
9+
// to be decoded does not exceed the minimum header length.
810
ErrorNotEnoughBytes = errors.New("proto: not enough bytes available to decode")
911
)

ethernet.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"net"
55
)
66

7+
// EthernetFrame represents an Ethernet frame.
78
type EthernetFrame struct {
89
Destination net.HardwareAddr `json:"source"`
910
Source net.HardwareAddr `json:"destination"`

ipv4.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"net"
55
)
66

7+
// IPv4Packet represents an IPv4 packet.
78
type IPv4Packet struct {
89
Version uint8 `json:"version"`
910
InternetHeaderLength uint8 `json:"internetHeaderLength"`

ipv6.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"net"
55
)
66

7+
// IPv6Packet represents an IPv6 packet.
78
type IPv6Packet struct {
89
Version uint8 `json:"version"`
910
TrafficClass uint8 `json:"trafficClass"`

tcp.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package proto
22

3+
// TCPPacket represents a TCP packet.
34
type TCPPacket struct {
45
SourcePort uint16 `json:"sourcePort"`
56
DestinationPort uint16 `json:"destinationPort"`
@@ -23,38 +24,47 @@ type TCPPacket struct {
2324

2425
const minTCPPacketSize = 2 + 2 + 4 + 4 + 1 + 2 + 2 + 2 + 2
2526

27+
// HasFIN returns true if the FIN flag is set.
2628
func (p TCPPacket) HasFIN() bool {
2729
return p.Flags&(1<<0) > 0
2830
}
2931

32+
// HasSYN returns true if the SYN flag is set.
3033
func (p TCPPacket) HasSYN() bool {
3134
return p.Flags&(1<<1) > 0
3235
}
3336

37+
// HasRST return true if the RST flag is set.
3438
func (p TCPPacket) HasRST() bool {
3539
return p.Flags&(1<<2) > 0
3640
}
3741

42+
// HasPSH returns true if the PSH flag is set.
3843
func (p TCPPacket) HasPSH() bool {
3944
return p.Flags&(1<<3) > 0
4045
}
4146

47+
// HasACK returns true if the ACK flag is set.
4248
func (p TCPPacket) HasACK() bool {
4349
return p.Flags&(1<<4) > 0
4450
}
4551

52+
// HasURG returns true if the URG flag is set.
4653
func (p TCPPacket) HasURG() bool {
4754
return p.Flags&(1<<5) > 0
4855
}
4956

57+
// HasECE returns true if the ECE flag is set.
5058
func (p TCPPacket) HasECE() bool {
5159
return p.Flags&(1<<6) > 0
5260
}
5361

62+
// HasCWR returns true if the CWR flag is set.
5463
func (p TCPPacket) HasCWR() bool {
5564
return p.Flags&(1<<7) > 0
5665
}
5766

67+
// HasNS returns true if the NS flag is set.
5868
func (p TCPPacket) HasNS() bool {
5969
return p.Flags>>8 > 0
6070
}

0 commit comments

Comments
 (0)