/*
This file is part of PacketDotNet
PacketDotNet is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PacketDotNet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PacketDotNet. If not, see .
*/
/*
* Copyright 2009 Chris Morgan
*/
using System;
namespace PacketDotNet
{
/// IP protocol field encoding information.
///
///
public struct TcpFields
{
#pragma warning disable 1591
// flag bitmasks
public readonly static int TCP_CWR_MASK = 0x0080;
public readonly static int TCP_ECN_MASK = 0x0040;
public readonly static int TCP_URG_MASK = 0x0020;
public readonly static int TCP_ACK_MASK = 0x0010;
public readonly static int TCP_PSH_MASK = 0x0008;
public readonly static int TCP_RST_MASK = 0x0004;
public readonly static int TCP_SYN_MASK = 0x0002;
public readonly static int TCP_FIN_MASK = 0x0001;
#pragma warning restore 1591
/// Length of a TCP port in bytes.
public readonly static int PortLength = 2;
/// Length of the sequence number in bytes.
public readonly static int SequenceNumberLength = 4;
/// Length of the acknowledgment number in bytes.
public readonly static int AckNumberLength = 4;
/// Length of the data offset and flags field in bytes.
public readonly static int DataOffsetLength = 1;
/// The length of the flags field
public readonly static int FlagsLength = 1;
/// Length of the window size field in bytes.
public readonly static int WindowSizeLength = 2;
/// Length of the checksum field in bytes.
public readonly static int ChecksumLength = 2;
/// Length of the urgent field in bytes.
public readonly static int UrgentPointerLength = 2;
/// Position of the source port field.
public readonly static int SourcePortPosition = 0;
/// Position of the destination port field.
public readonly static int DestinationPortPosition;
/// Position of the sequence number field.
public readonly static int SequenceNumberPosition;
/// Position of the acknowledgment number field.
public readonly static int AckNumberPosition;
/// Position of the data offset
public readonly static int DataOffsetPosition;
/// Position of the flags field
public readonly static int FlagsPosition;
/// Position of the window size field.
public readonly static int WindowSizePosition;
/// Position of the checksum field.
public readonly static int ChecksumPosition;
/// Position of the urgent pointer field.
public readonly static int UrgentPointerPosition;
/// Length in bytes of a TCP header.
public readonly static int HeaderLength; // == 20
static TcpFields()
{
DestinationPortPosition = PortLength;
SequenceNumberPosition = DestinationPortPosition + PortLength;
AckNumberPosition = SequenceNumberPosition + SequenceNumberLength;
DataOffsetPosition = AckNumberPosition + AckNumberLength;
FlagsPosition = DataOffsetPosition + DataOffsetLength;
WindowSizePosition = FlagsPosition + FlagsLength;
ChecksumPosition = WindowSizePosition + WindowSizeLength;
UrgentPointerPosition = ChecksumPosition + ChecksumLength;
HeaderLength = UrgentPointerPosition + UrgentPointerLength;
}
}
}