Skip to content

Commit

Permalink
use layer type for string conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
pyther committed Jun 7, 2020
1 parent dc28a41 commit c276123
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,23 @@ func printPacketInfo(src string, dst string, packet gopacket.Packet) {

if eapLayer != nil {
eap, _ := eapLayer.(*layers.EAP)
codeString := EAPTypeString(eap.Code)
codeString := EAPCodeToString(eap.Code)
line += fmt.Sprintf(", %s (%d) id %d", codeString, eap.Code, eap.Id)
}

line += fmt.Sprintf(" > %s", dst)
fmt.Println(line)
}

func EAPTypeString(code layers.EAPCode) string {
func EAPCodeToString(code layers.EAPCode) string {
switch code {
case 1:
case layers.EAPCodeRequest:
return "Request"
case 2:
case layers.EAPCodeResponse:
return "Response"
case 3:
case layers.EAPCodeSuccess:
return "Success"
case 4:
case layers.EAPCodeFailure:
return "Failure"
}
return "Unknown"
Expand Down

0 comments on commit c276123

Please sign in to comment.