Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic using examples/pcapdump/main.go #175

Closed
cleesmith opened this issue Feb 26, 2016 · 2 comments
Closed

panic using examples/pcapdump/main.go #175

cleesmith opened this issue Feb 26, 2016 · 2 comments

Comments

@cleesmith
Copy link

go version go1.6 darwin/amd64

go get -u github.com/google/gopacket
go get -u github.com/google/gopacket/layers
go get -u github.com/google/gopacket/tcpassembly

using gopacket/examples/pcapdump/main.go:
go run pcapdump.go -r test_ethernet.pcap ... tried with many pcap files
... output is lots of these:
%!v(PANIC=reflect.Value.Interface: cannot return value obtained from unexported field or method)
.layerString() ?
... maybe it's related to this:
https://groups.google.com/forum/#!topic/golang-nuts/iHJcOWmWAag
http://tip.golang.org/doc/go1.6#reflect

other programs work fine ... like: httpassembly.go and bidirectional.go

@cleesmith
Copy link
Author

After trying a bunch more pcap files, the following lame fix to packet.go seems to work:

func layerString(...)
   . . .
   case reflect.Struct:
   . . .
     if ftype.Anonymous {
       // the old line that panics:
       // anonStr := layerString(f.Interface(), true, writeSpace)
       . . .
       // this seems to only affect output like:
       //   "Contents=[..20..] Payload=[..1389..]"
       // which appears to be "type BaseLayer struct", so
       // just using an empty string when it's anonymous seems
       // to work ... and that's not a lot of info to lose
       anonStr := layerString("", true, writeSpace)
       . . .

... back to more testing with Go 1.6

@gconnell
Copy link
Collaborator

Fixed by 4457463, thanks for the heads up. You were 100% right, http://tip.golang.org/doc/go1.6#reflect was the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants