Skip to content

Commit e6b715e

Browse files
author
shadowy-pycoder
committed
Made NextLayer method shorter for those that do not have next layer
1 parent 8c3c0b5 commit e6b715e

File tree

10 files changed

+10
-28
lines changed

10 files changed

+10
-28
lines changed

layers/arp.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ func (ap *ARPPacket) Parse(data []byte) error {
100100
return nil
101101
}
102102

103-
func (ap *ARPPacket) NextLayer() (string, []byte) {
104-
return "", nil
105-
}
103+
func (ap *ARPPacket) NextLayer() (layer string, payload []byte) { return }
106104

107105
func ptypedesc(pt uint16) string {
108106
var proto string

layers/dns.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,7 @@ func (d *DNSMessage) Parse(data []byte) error {
268268
return nil
269269
}
270270

271-
func (d *DNSMessage) NextLayer() (string, []byte) {
272-
return "", nil
273-
}
271+
func (d *DNSMessage) NextLayer() (layer string, payload []byte) { return }
274272

275273
func (d *DNSMessage) printRecords() string {
276274
var sb strings.Builder

layers/ftp.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,4 @@ func (f *FTPMessage) Parse(data []byte) error {
3737
return nil
3838
}
3939

40-
func (f *FTPMessage) NextLayer() (string, []byte) {
41-
return "", nil
42-
}
40+
func (f *FTPMessage) NextLayer() (layer string, payload []byte) { return }

layers/http.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,4 @@ func (h *HTTPMessage) Parse(data []byte) error {
5656
return nil
5757
}
5858

59-
func (h *HTTPMessage) NextLayer() (string, []byte) {
60-
return "", nil
61-
}
59+
func (h *HTTPMessage) NextLayer() (layer string, payload []byte) { return }

layers/icmp.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ func (i *ICMPSegment) Parse(data []byte) error {
6565
i.TypeDesc, i.CodeDesc = i.typecode()
6666
return nil
6767
}
68-
func (i *ICMPSegment) NextLayer() (string, []byte) {
69-
return "", nil
70-
}
68+
func (i *ICMPSegment) NextLayer() (layer string, payload []byte) { return }
7169

7270
func (i *ICMPSegment) typecode() (string, string) {
7371
// https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol

layers/icmpv6.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ func (i *ICMPv6Segment) Parse(data []byte) error {
6868
return nil
6969
}
7070

71-
func (i *ICMPv6Segment) NextLayer() (string, []byte) {
72-
return "", nil
73-
}
71+
func (i *ICMPv6Segment) NextLayer() (layer string, payload []byte) { return }
7472

7573
func (i *ICMPv6Segment) typecode() (string, string) {
7674
// https://en.wikipedia.org/wiki/ICMPv6

layers/layers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var (
3939
type Layer interface {
4040
fmt.Stringer
4141
Parse(data []byte) error
42-
NextLayer() (name string, payload []byte)
42+
NextLayer() (layer string, payload []byte)
4343
Summary() string
4444
}
4545

layers/snmp.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,4 @@ func (s *SNMPMessage) Parse(data []byte) error {
2222
return nil
2323
}
2424

25-
func (s *SNMPMessage) NextLayer() (string, []byte) {
26-
return "", nil
27-
}
25+
func (s *SNMPMessage) NextLayer() (layer string, payload []byte) { return }

layers/ssh.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ func (s *SSHMessage) Parse(data []byte) error {
119119
return nil
120120
}
121121

122-
func (s *SSHMessage) NextLayer() (string, []byte) {
123-
return "", nil
124-
}
122+
func (s *SSHMessage) NextLayer() (layer string, payload []byte) { return }
125123

126124
// https://www.iana.org/assignments/ssh-parameters/ssh-parameters.xhtml
127125
func mtypedesc(mtype uint8) string {

layers/tls.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ func (t *TLSMessage) Parse(data []byte) error {
115115
return nil
116116
}
117117

118-
func (t *TLSMessage) NextLayer() (string, []byte) {
119-
return "", nil
120-
}
118+
func (t *TLSMessage) NextLayer() (layer string, payload []byte) { return }
121119

122120
func ctdesc(ct uint8) string {
123121
// https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-5

0 commit comments

Comments
 (0)