<commit_before>// Copyright 2012 Google, Inc. All rights reserved.
// Copyright 2009-2012 <NAME>. All rights reserved.

package layers

import (
	"bytes"
	"encoding/binary"
	"fmt"
	"github.com/gconnell/gopacket"
)

// TCP is the layer for TCP headers.
type TCP struct {
	baseLayer
	SrcPort                                    uint16
	DstPort                                    uint16
	Seq                                        uint32
	Ack                                        uint32
	DataOffset                                 uint8
	FIN, SYN, RST, PSH, ACK, URG, ECE, CWR, NS bool
	Window                                     uint16
	Checksum                                   uint16
	Urgent                                     uint16
	sPort, dPort                               []byte
	Options                                    []TCPOption
	Padding                                    []byte
}

type TCPOption struct {
	OptionType   uint8
	OptionLength uint8
	OptionData   []byte
}

func (t *TCPOption) String() string {
	return fmt.Sprintf("TCPOption(%v:%v)", t.OptionType, t.OptionData)
}

// LayerType returns gopacket.LayerTypeTCP
func (t *TCP) LayerType() gopacket.LayerType { return LayerTypeTCP }

// String returns the human-readable string for a TCP layer.
func (t *TCP) String() string {
	var b bytes.Buffer
	fmt.Fprintf(&b, "TCP ports:%v->%v seq:%v ack:%v window:%v cksum:%v urg:%v flags:%v\n",
		t.SrcPort, t.DstPort, t.Seq, t.Ack, t.Window, t.Checksum, t.Urgent, t.flagsString())
	for _, opt := range t.Options {
		fmt.Fprintln(&b, "  option:", opt)
	}
	b.WriteString(t.baseLayer.String())
	return b.String()
}

func (t *TCP) flagsString() string {
	var b bytes.Buffer
	if t.FIN {
		b.WriteByte('F')<commit_msg>Make TCPOptions string func not take ptr.<commit_after>// Copyright 2012 Google, Inc. All rights reserved.
// Copyright 2009-2012 <NAME>. All rights reserved.

package layers

import (
	"bytes"
	"encoding/binary"
	"fmt"
	"github.com/gconnell/gopacket"
)

// TCP is the layer for TCP headers.
type TCP struct {
	baseLayer
	SrcPort                                    uint16
	DstPort                                    uint16
	Seq                                        uint32
	Ack                                        uint32
	DataOffset                                 uint8
	FIN, SYN, RST, PSH, ACK, URG, ECE, CWR, NS bool
	Window                                     uint16
	Checksum                                   uint16
	Urgent                                     uint16
	sPort, dPort                               []byte
	Options                                    []TCPOption
	Padding                                    []byte
}

type TCPOption struct {
	OptionType   uint8
	OptionLength uint8
	OptionData   []byte
}

func (t TCPOption) String() string {
	return fmt.Sprintf("TCPOption(%v:%v)", t.OptionType, t.OptionData)
}

// LayerType returns gopacket.LayerTypeTCP
func (t *TCP) LayerType() gopacket.LayerType { return LayerTypeTCP }

// String returns the human-readable string for a TCP layer.
func (t *TCP) String() string {
	var b bytes.Buffer
	fmt.Fprintf(&b, "TCP ports:%v->%v seq:%v ack:%v window:%v cksum:%v urg:%v flags:%v\n",
		t.SrcPort, t.DstPort, t.Seq, t.Ack, t.Window, t.Checksum, t.Urgent, t.flagsString())
	for _, opt := range t.Options {
		fmt.Fprintln(&b, "  option:", opt)
	}
	b.WriteString(t.baseLayer.String())
	return b.String()
}

func (t *TCP) flagsString() string {
	var b bytes.Buffer
	if t.FIN {
		b.WriteByte('F')
{'fraction_non_alphanumeric': 0.1028440103418558, 'fraction_numerical': 0.016661878770468257, 'mean_word_length': 1.6539634146341464, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1720708', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1040, 'n_words': 301}