// Decode decodes the headers of a Packet.
Decode decodes the headers of a Packet.
// Decode decodes the headers of a Packet .
func (p *Packet) decode() {
	ethHdr, buf := NewEthHdr(p.buf)
	p.Headers[LinkLayer] = ethHdr
	switch ethHdr.EtherType {
	case C.ETHERTYPE_IP, 0:
		p.Headers[NetworkLayer], buf = NewIpHdr(buf)
	case C.ETHERTYPE_IPV6:
		p.Headers[NetworkLayer], buf = NewIp6Hdr(buf)
	case C.ETHERTYPE_ARP:
		return
	default:
		return
	}
	var pl []byte 
	switch p.Headers[NetworkLayer].(InetProtoHdr).Proto() {
	case C.IPPROTO_TCP:
		p.Headers[TransportLayer], _ = NewTcpHdr(buf)
		pl = p.Headers[TransportLayer].(*TcpHdr).GetPayloadBytes(
			p.Headers[NetworkLayer].(InetProtoHdr).PL())
	case C.IPPROTO_UDP:
		p.Headers[TransportLayer], _ = NewUdpHdr(buf)
		return
	case C.IPPROTO_ICMP:
		return
	default:
		return
	}
	if len(pl) > 14 {
		httpHdr := NewHttpHdr(pl)
		if httpHdr != nil {
			p.Headers = append(p.Headers, httpHdr)
		}
	}
}
func ( p * Packet ) decode ( ) { ethHdr , buf := NewEthHdr ( p . buf ) p . Headers [ LinkLayer ] = ethHdr switch ethHdr . EtherType { case C . ETHERTYPE_IP , 0 : p . Headers [ NetworkLayer ] , buf = NewIpHdr ( buf ) case C . ETHERTYPE_IPV6 : p . Headers [ NetworkLayer ] , buf = NewIp6Hdr ( buf ) case C . ETHERTYPE_ARP : return default : return } var pl [ ] byte switch p . Headers [ NetworkLayer ] . ( InetProtoHdr ) . Proto ( ) { case C . IPPROTO_TCP : p . Headers [ TransportLayer ] , _ = NewTcpHdr ( buf ) pl = p . Headers [ TransportLayer ] . ( * TcpHdr ) . GetPayloadBytes ( p . Headers [ NetworkLayer ] . ( InetProtoHdr ) . PL ( ) ) case C . IPPROTO_UDP : p . Headers [ TransportLayer ] , _ = NewUdpHdr ( buf ) return case C . IPPROTO_ICMP : return default : return } if len ( pl ) > 14 { httpHdr := NewHttpHdr ( pl ) if httpHdr != nil { p . Headers = append ( p . Headers , httpHdr ) } } }
Decode decodes the headers of a Packet.
Decode decodes the headers of a Packet .
//TODO(gavaletz) ARP // the transport layer payload //TODO(gavaletz) ICMP // Looks to see if a packet represents the beginning of an  HTTP request // or a HTTP response from the server.  This goes beyond the normal pcap // library operations. //TODO(gavaletz) SDPY