gconnell/gopcap — comment on commit e5bdb61e7b48961a4f01a35359d64a5eb13ec89c
File:  line 0
By gconnell:

This is a slightly more involved change than the first few I've sent. It changes a packet's Headers from interface{} to a new Header interface. Currently, this interface just as a HeaderType() (enumerated in decode.go) and a Bytes() slice, which returns the bytes detected to be part of the header.

This allows for a couple of nice things. First, it makes switching based on header type easy (switch pkt.HeaderType() {}). Also, it opens up the ability to do cursory parsing of certain header types without fully coding them. If, for example, there's a header X that doesn't affect the ending payload, we can decode and skip it without fully coding the decode() function. I'm planning to do this next with IPv6 extensions, basically a quick initial implementation that does nothing but pulls out Bytes() and HeaderType(), and leaves the rest of the decoding for a later time.