summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/tcp/connect.go
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@google.com>2019-03-14 10:18:24 -0700
committerShentubot <shentubot@google.com>2019-03-14 10:19:21 -0700
commit5496be7c5ddedd6ec03004143501acb225eda357 (patch)
tree8d343ae925e268f17e91b5db40783b29e28a1892 /pkg/tcpip/transport/tcp/connect.go
parent8f4634997bd97810a85a70b71f000378d9db2e55 (diff)
Remove duplicate TCP flag definitions
PiperOrigin-RevId: 238467634 Change-Id: If4cd8efff7386fbee1195f051d15549b495910a9
Diffstat (limited to 'pkg/tcpip/transport/tcp/connect.go')
-rw-r--r--pkg/tcpip/transport/tcp/connect.go46
1 files changed, 23 insertions, 23 deletions
diff --git a/pkg/tcpip/transport/tcp/connect.go b/pkg/tcpip/transport/tcp/connect.go
index 7b80f7519..4d352b23c 100644
--- a/pkg/tcpip/transport/tcp/connect.go
+++ b/pkg/tcpip/transport/tcp/connect.go
@@ -123,7 +123,7 @@ func (h *handshake) resetState() {
}
h.state = handshakeSynSent
- h.flags = flagSyn
+ h.flags = header.TCPFlagSyn
h.ackNum = 0
h.mss = 0
h.iss = seqnum.Value(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24)
@@ -144,7 +144,7 @@ func (h *handshake) effectiveRcvWndScale() uint8 {
func (h *handshake) resetToSynRcvd(iss seqnum.Value, irs seqnum.Value, opts *header.TCPSynOptions) {
h.active = false
h.state = handshakeSynRcvd
- h.flags = flagSyn | flagAck
+ h.flags = header.TCPFlagSyn | header.TCPFlagAck
h.iss = iss
h.ackNum = irs + 1
h.mss = opts.MSS
@@ -155,13 +155,13 @@ func (h *handshake) resetToSynRcvd(iss seqnum.Value, irs seqnum.Value, opts *hea
// a TCP 3-way handshake is valid. If it's not, a RST segment is sent back in
// response.
func (h *handshake) checkAck(s *segment) bool {
- if s.flagIsSet(flagAck) && s.ackNumber != h.iss+1 {
+ if s.flagIsSet(header.TCPFlagAck) && s.ackNumber != h.iss+1 {
// RFC 793, page 36, states that a reset must be generated when
// the connection is in any non-synchronized state and an
// incoming segment acknowledges something not yet sent. The
// connection remains in the same state.
ack := s.sequenceNumber.Add(s.logicalLen())
- h.ep.sendRaw(buffer.VectorisedView{}, flagRst|flagAck, s.ackNumber, ack, 0)
+ h.ep.sendRaw(buffer.VectorisedView{}, header.TCPFlagRst|header.TCPFlagAck, s.ackNumber, ack, 0)
return false
}
@@ -173,8 +173,8 @@ func (h *handshake) checkAck(s *segment) bool {
func (h *handshake) synSentState(s *segment) *tcpip.Error {
// RFC 793, page 37, states that in the SYN-SENT state, a reset is
// acceptable if the ack field acknowledges the SYN.
- if s.flagIsSet(flagRst) {
- if s.flagIsSet(flagAck) && s.ackNumber == h.iss+1 {
+ if s.flagIsSet(header.TCPFlagRst) {
+ if s.flagIsSet(header.TCPFlagAck) && s.ackNumber == h.iss+1 {
return tcpip.ErrConnectionRefused
}
return nil
@@ -186,7 +186,7 @@ func (h *handshake) synSentState(s *segment) *tcpip.Error {
// We are in the SYN-SENT state. We only care about segments that have
// the SYN flag.
- if !s.flagIsSet(flagSyn) {
+ if !s.flagIsSet(header.TCPFlagSyn) {
return nil
}
@@ -201,15 +201,15 @@ func (h *handshake) synSentState(s *segment) *tcpip.Error {
// Remember the sequence we'll ack from now on.
h.ackNum = s.sequenceNumber + 1
- h.flags |= flagAck
+ h.flags |= header.TCPFlagAck
h.mss = rcvSynOpts.MSS
h.sndWndScale = rcvSynOpts.WS
// If this is a SYN ACK response, we only need to acknowledge the SYN
// and the handshake is completed.
- if s.flagIsSet(flagAck) {
+ if s.flagIsSet(header.TCPFlagAck) {
h.state = handshakeCompleted
- h.ep.sendRaw(buffer.VectorisedView{}, flagAck, h.iss+1, h.ackNum, h.rcvWnd>>h.effectiveRcvWndScale())
+ h.ep.sendRaw(buffer.VectorisedView{}, header.TCPFlagAck, h.iss+1, h.ackNum, h.rcvWnd>>h.effectiveRcvWndScale())
return nil
}
@@ -236,7 +236,7 @@ func (h *handshake) synSentState(s *segment) *tcpip.Error {
// synRcvdState handles a segment received when the TCP 3-way handshake is in
// the SYN-RCVD state.
func (h *handshake) synRcvdState(s *segment) *tcpip.Error {
- if s.flagIsSet(flagRst) {
+ if s.flagIsSet(header.TCPFlagRst) {
// RFC 793, page 37, states that in the SYN-RCVD state, a reset
// is acceptable if the sequence number is in the window.
if s.sequenceNumber.InWindow(h.ackNum, h.rcvWnd) {
@@ -249,16 +249,16 @@ func (h *handshake) synRcvdState(s *segment) *tcpip.Error {
return nil
}
- if s.flagIsSet(flagSyn) && s.sequenceNumber != h.ackNum-1 {
+ if s.flagIsSet(header.TCPFlagSyn) && s.sequenceNumber != h.ackNum-1 {
// We received two SYN segments with different sequence
// numbers, so we reset this and restart the whole
// process, except that we don't reset the timer.
ack := s.sequenceNumber.Add(s.logicalLen())
seq := seqnum.Value(0)
- if s.flagIsSet(flagAck) {
+ if s.flagIsSet(header.TCPFlagAck) {
seq = s.ackNumber
}
- h.ep.sendRaw(buffer.VectorisedView{}, flagRst|flagAck, seq, ack, 0)
+ h.ep.sendRaw(buffer.VectorisedView{}, header.TCPFlagRst|header.TCPFlagAck, seq, ack, 0)
if !h.active {
return tcpip.ErrInvalidEndpointState
@@ -278,7 +278,7 @@ func (h *handshake) synRcvdState(s *segment) *tcpip.Error {
// We have previously received (and acknowledged) the peer's SYN. If the
// peer acknowledges our SYN, the handshake is completed.
- if s.flagIsSet(flagAck) {
+ if s.flagIsSet(header.TCPFlagAck) {
// If the timestamp option is negotiated and the segment does
// not carry a timestamp option then the segment must be dropped
@@ -301,7 +301,7 @@ func (h *handshake) synRcvdState(s *segment) *tcpip.Error {
func (h *handshake) handleSegment(s *segment) *tcpip.Error {
h.sndWnd = s.window
- if !s.flagIsSet(flagSyn) && h.sndWndScale > 0 {
+ if !s.flagIsSet(header.TCPFlagSyn) && h.sndWndScale > 0 {
h.sndWnd <<= uint8(h.sndWndScale)
}
@@ -472,7 +472,7 @@ func (h *handshake) execute() *tcpip.Error {
}
func parseSynSegmentOptions(s *segment) header.TCPSynOptions {
- synOpts := header.ParseSynOptions(s.options, s.flagIsSet(flagAck))
+ synOpts := header.ParseSynOptions(s.options, s.flagIsSet(header.TCPFlagAck))
if synOpts.TS {
s.parsedOptions.TSVal = synOpts.TSVal
s.parsedOptions.TSEcr = synOpts.TSEcr
@@ -596,7 +596,7 @@ func sendTCP(r *stack.Route, id stack.TransportEndpointID, data buffer.Vectorise
}
r.Stats().TCP.SegmentsSent.Increment()
- if (flags & flagRst) != 0 {
+ if (flags & header.TCPFlagRst) != 0 {
r.Stats().TCP.ResetsSent.Increment()
}
@@ -645,7 +645,7 @@ func (e *endpoint) makeOptions(sackBlocks []header.SACKBlock) []byte {
// sendRaw sends a TCP segment to the endpoint's peer.
func (e *endpoint) sendRaw(data buffer.VectorisedView, flags byte, seq, ack seqnum.Value, rcvWnd seqnum.Size) *tcpip.Error {
var sackBlocks []header.SACKBlock
- if e.state == stateConnected && e.rcv.pendingBufSize > 0 && (flags&flagAck != 0) {
+ if e.state == stateConnected && e.rcv.pendingBufSize > 0 && (flags&header.TCPFlagAck != 0) {
sackBlocks = e.sack.Blocks[:e.sack.NumBlocks]
}
options := e.makeOptions(sackBlocks)
@@ -695,7 +695,7 @@ func (e *endpoint) handleClose() *tcpip.Error {
// state with the given error code. This method must only be called from the
// protocol goroutine.
func (e *endpoint) resetConnectionLocked(err *tcpip.Error) {
- e.sendRaw(buffer.VectorisedView{}, flagAck|flagRst, e.snd.sndUna, e.rcv.rcvNxt, 0)
+ e.sendRaw(buffer.VectorisedView{}, header.TCPFlagAck|header.TCPFlagRst, e.snd.sndUna, e.rcv.rcvNxt, 0)
e.state = stateError
e.hardError = err
@@ -727,7 +727,7 @@ func (e *endpoint) handleSegments() *tcpip.Error {
e.probe(e.completeState())
}
- if s.flagIsSet(flagRst) {
+ if s.flagIsSet(header.TCPFlagRst) {
if e.rcv.acceptable(s.sequenceNumber, 0) {
// RFC 793, page 37 states that "in all states
// except SYN-SENT, all reset (RST) segments are
@@ -736,7 +736,7 @@ func (e *endpoint) handleSegments() *tcpip.Error {
s.decRef()
return tcpip.ErrConnectionReset
}
- } else if s.flagIsSet(flagAck) {
+ } else if s.flagIsSet(header.TCPFlagAck) {
// Patch the window size in the segment according to the
// send window scale.
s.window <<= e.snd.sndWndScale
@@ -785,7 +785,7 @@ func (e *endpoint) keepaliveTimerExpired() *tcpip.Error {
// seg.seq = snd.nxt-1.
e.keepalive.unacked++
e.keepalive.Unlock()
- e.snd.sendSegment(buffer.VectorisedView{}, flagAck, e.snd.sndNxt-1)
+ e.snd.sendSegment(buffer.VectorisedView{}, header.TCPFlagAck, e.snd.sndNxt-1)
e.resetKeepaliveTimer(false)
return nil
}