// TCPDataDump provides text debugging information for all the TCP packets in d.
// A result that returns with an error may still have partial information up to
// the packet that caused the error.
TCPDataDump provides text debugging information for all the TCP packets in d.
A result that returns with an error may still have partial information up to
the packet that caused the error.
// TCPDataDump provides text debugging information for all the TCP packets in d . // A result that returns with an error may still have partial information up to // the packet that caused the error .
func TCPDataDump(d []*pkt.Packet) ([]string, error) {
	var tcpHdr *pkt.TcpHdr
	var ipHdr pkt.InetProtoHdr
	var ok bool
	pl := make([]string, len(d))
	for i := range d {
		ipHdr, ok = d[i].Headers[pkt.NetworkLayer].(pkt.InetProtoHdr)
		if !ok || ipHdr == nil {
			return pl, ErrNetworkLayerHeader
		}
		tcpHdr, ok = d[i].Headers[pkt.TransportLayer].(*pkt.TcpHdr)
		if !ok || tcpHdr == nil {
			return pl, ErrTransportLayerHeader
		}
		pl[i] = fmt.Sprintf("%d %d->%d %d %d %d %#x %d %d",
			d[i].Time.UnixNano(),
			tcpHdr.Source,
			tcpHdr.Dest,
			tcpHdr.Seq,
			tcpHdr.AckSeq,
			tcpHdr.Doff,
			tcpHdr.Flags,
			tcpHdr.Window,
			tcpHdr.PayloadLen(ipHdr.PL()))
	}
	return pl, nil
}
func TCPDataDump ( d [ ] * pkt . Packet ) ( [ ] string , error ) { var tcpHdr * pkt . TcpHdr var ipHdr pkt . InetProtoHdr var ok bool pl := make ( [ ] string , len ( d ) ) for i := range d { ipHdr , ok = d [ i ] . Headers [ pkt . NetworkLayer ] . ( pkt . InetProtoHdr ) if ! ok || ipHdr == nil { return pl , ErrNetworkLayerHeader } tcpHdr , ok = d [ i ] . Headers [ pkt . TransportLayer ] . ( * pkt . TcpHdr ) if ! ok || tcpHdr == nil { return pl , ErrTransportLayerHeader } pl [ i ] = fmt . Sprintf ( " " , d [ i ] . Time . UnixNano ( ) , tcpHdr . Source , tcpHdr . Dest , tcpHdr . Seq , tcpHdr . AckSeq , tcpHdr . Doff , tcpHdr . Flags , tcpHdr . Window , tcpHdr . PayloadLen ( ipHdr . PL ( ) ) ) } return pl , nil }
TCPDataDump provides text debugging information for all the TCP packets in d.
A result that returns with an error may still have partial information up to
the packet that caused the error.
TCPDataDump provides text debugging information for all the TCP packets in d . A result that returns with an error may still have partial information up to the packet that caused the error .