Protocol++® (Protocolpp®)  v5.6.2
ProtocolPP::jtcp Class Reference
Inheritance diagram for ProtocolPP::jtcp:
Collaboration diagram for ProtocolPP::jtcp:

Public Types

enum  tcpopt_t {
  END , NOP , MSS , WINSCALE ,
  SELACK , SACK , TIMESTAMP
}
 Options that TCP may add to the standard header. More...
 
enum  tcpstate_t {
  LISTEN , SYN_SENT , SYN_RCVD , ESTABLISHED ,
  FIN_WAIT_1 , FIN_WAIT_2 , CLOSE_WAIT , LAST_ACK ,
  TIME_WAIT , CLOSED
}
 TCP states of operation. More...
 

Public Member Functions

 jtcp (tcpstate_t state, std::shared_ptr< jtcpsa > &security)
 
 jtcp (tcpstate_t state, std::shared_ptr< jtcpsa > &security, std::string &file)
 
virtual ~jtcp ()=default
 Standard deconstructor.
 
void encap_packet (std::shared_ptr< jarray< uint8_t >> &input, std::shared_ptr< jarray< uint8_t >> &output)
 
void decap_packet (std::shared_ptr< jarray< uint8_t >> &input, std::shared_ptr< jarray< uint8_t >> &output)
 
void set_field (field_t field, uint64_t value)
 
void set_hdr (jarray< uint8_t > &hdr)
 
void add_option (tcpopt_t OPT, jarray< uint8_t > &value)
 
uint64_t get_field (field_t field, jarray< uint8_t > &header)
 
uint64_t get_field (field_t field)
 
jarray< uint8_t > get_hdr ()
 
void get_security (std::shared_ptr< jtcpsa > &sec)
 
void to_xml (tinyxml2::XMLPrinter &myxml, direction_t direction)
 
void to_json (std::ofstream &myjson, direction_t direction, std::string &indent)
 
 jtcp (jtcp &jtcp)=delete
 
 jtcp (const jtcp &jtcp)=delete
 
- Public Member Functions inherited from ProtocolPP::jprotocol
 jprotocol (direction_t dir)
 
 jprotocol (direction_t dir, std::string &file)
 
 jprotocol (direction_t dir, std::shared_ptr< jrand > &rand)
 
 jprotocol (direction_t dir, std::shared_ptr< jrand > &rand, std::string &file)
 
virtual ~jprotocol ()
 Standard deconstructor.
 
virtual void encap_packet (std::shared_ptr< jarray< uint8_t >> &output)
 
virtual void decap_packet (std::shared_ptr< jarray< uint8_t >> &input)
 
bool hasfile ()
 
uint32_t get_status ()
 
jarray< uint8_t > checksum (iana_t prot, direction_t dir, jarray< uint8_t > &check, uint32_t offset=0)
 
jarray< uint8_t > pad (pad_t padtype, uint32_t len)
 
 jprotocol (jprotocol &jprotocol)=delete
 
 jprotocol (const jprotocol &jprotocol)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from ProtocolPP::jprotocol
const static std::string currentDateTime ()
 
static std::string str_status (uint32_t status)
 
static jarray< uint8_t > to_array (uint8_t input)
 
static jarray< uint8_t > to_array (uint16_t input)
 
static jarray< uint8_t > to_array (uint32_t input)
 
static jarray< uint8_t > to_array (uint64_t input)
 
static uint8_t to_u8 (jarray< uint8_t > src_array)
 
static uint16_t to_u16 (jarray< uint8_t > src_array)
 
static uint32_t to_u32 (jarray< uint8_t > src_array)
 
static uint64_t to_u64 (jarray< uint8_t > src_array)
 
static uint32_t fnv_hash (std::shared_ptr< jarray< uint8_t >> &header, jarray< uint8_t > &mask, uint32_t hdrlen)
 
- Protected Member Functions inherited from ProtocolPP::jprotocol
template<typename T , typename TE >
std::shared_ptr< jreplay< T, TE > > update_replay (protocol_t prot, T &seqnum, TE &extseq, bool usext, uint32_t size)
 
template<typename T , typename TE >
std::shared_ptr< jreplay< T, TE > > update_replay (protocol_t prot, T &seqnum, TE &extseq, bool usext, uint32_t size, jarray< uint8_t > &window)
 
void update_status (uint32_t stat)
 
void get_data (std::shared_ptr< jarray< uint8_t >> &data)
 
void put_data (std::shared_ptr< jarray< uint8_t >> &wdata)
 
void encryptdat (std::shared_ptr< jarray< uint8_t >> &red, std::shared_ptr< jarray< uint8_t >> &black)
 
void decryptdat (std::shared_ptr< jarray< uint8_t >> &black, std::shared_ptr< jarray< uint8_t >> &red)
 
uint32_t roundup (uint32_t value, uint32_t mult)
 
- Protected Attributes inherited from ProtocolPP::jprotocol
direction_t m_dir
 direction of processing
 
uint32_t m_status
 
std::shared_ptr< jrandm_rand
 random data generator passed into constructor
 
std::string m_filename
 file input string for this protocol
 
std::fstream m_file
 input file stream object for this protocol
 
endian_t m_endian
 endianess string for this protocol
 

Member Enumeration Documentation

◆ tcpopt_t

Options that TCP may add to the standard header.

Enumerator
END 

This option code indicates the end of the option list. This might not coincide with the end of the TCP header according to the Data Offset field. This is used at the end of all options not the end of each option, and need only be used if the end of the options would not otherwise coincide with the end of the TCP header.

NOP 

This option code may be used between options, for example, to align the beginning of a subsequent option on a word boundary. There is no guarantee that senders will use this option, so receivers must be prepared to process options even if they do not begin on a word boundary.

MSS 

If this option is present, then it communicates the maximum receive segment size at the TCP which sends this segment. This field must only be sent in the initial connection request (i.e., in segments with the SYN control bit set). If this option is not used, any segment size is allowed.

WINSCALE 

Resize the window.

SELACK 

Select acknowledge.

SACK 

Acknowledge.

TIMESTAMP 

Timestamp.

◆ tcpstate_t

TCP states of operation.

Enumerator
LISTEN 

(Server) Waiting for connection request

SYN_SENT 

(Client) Connection request sent, waiting for server request

SYN_RCVD 

(Server) waiting for a confirming connection request acknowledgment having both received and sent a connection request

ESTABLISHED 

(BOTH) Open connection with data flowing. Normal state for a data connection

FIN_WAIT_1 

(BOTH) represents waiting for a connection termination request from the remote TCP, or an acknowledgment of the connection termination request previously sent

FIN_WAIT_2 

(BOTH) represents waiting for a connection termination request from the remote TCP

CLOSE_WAIT 

(BOTH) represents waiting for a connection termination request from the local user

LAST_ACK 

(BOTH) represents waiting for an acknowledgment of the connection termination request previously sent to the remote TCP (which includes an acknowledgment of its connection termination request)

TIME_WAIT 

(BOTH) represents waiting for enough time to pass to be sure the remote TCP received the acknowledgment of its connection termination request. [According to RFC 793 a connection can stay in TIME-WAIT for a maximum of four minutes known as two MSL (maximum segment lifetime).]

CLOSED 

(BOTH) represents no connection state at all

Constructor & Destructor Documentation

◆ jtcp() [1/2]

ProtocolPP::jtcp::jtcp ( tcpstate_t  state,
std::shared_ptr< jtcpsa > &  security 
)

constructor for normal TCP containing all necessary fields to setup and run a TCP connection. All fields are accessible with the set_field() and get_field() functions

Parameters
state- Initial state of the engine (either LISTEN for SERVER or SYN_SENT for CLIENT). Can be ESTABLISHED
security- Parameters to setup a TCP flow

◆ jtcp() [2/2]

ProtocolPP::jtcp::jtcp ( tcpstate_t  state,
std::shared_ptr< jtcpsa > &  security,
std::string &  file 
)

constructor for normal TCP with file input containing all necessary fields to setup and run a TCP connection. All fields are accessible with the set_field() and get_field() functions

Parameters
state- Initial state of the engine (either LISTEN for SERVER or SYN_SENT for CLIENT). Can be ESTABLISHED
security- Parameters to setup a TCP flow
file- path to file to use to source packet payloads

Member Function Documentation

◆ add_option()

void ProtocolPP::jtcp::add_option ( tcpopt_t  OPT,
jarray< uint8_t > &  value 
)

Allows the user to add options to the TCP header

Parameters
OPT- option to add to the TCP header
value- value of the option to add to the TCP header

◆ decap_packet()

void ProtocolPP::jtcp::decap_packet ( std::shared_ptr< jarray< uint8_t >> &  input,
std::shared_ptr< jarray< uint8_t >> &  output 
)
virtual

This function is for use with the constructor without a file handle. Decap will produce a payload from the packet passed in check the flags, and update the window

Parameters
input- TCP packet to decapsulate
output- decapsulated payload

Implements ProtocolPP::jprotocol.

◆ encap_packet()

void ProtocolPP::jtcp::encap_packet ( std::shared_ptr< jarray< uint8_t >> &  input,
std::shared_ptr< jarray< uint8_t >> &  output 
)
virtual

This function is for use with the constructor without a file handle. Encap will produce a packet from the payload passed in

Parameters
input- payload to encapsulate with TCP
output- encapsulated TCP packet

Implements ProtocolPP::jprotocol.

◆ get_field() [1/2]

uint64_t ProtocolPP::jtcp::get_field ( field_t  field)
virtual

Retrieves the field from the TCP security association

Parameters
field- field from TCP security association to retrieve
Returns
field from the TCP association

Reimplemented from ProtocolPP::jprotocol.

◆ get_field() [2/2]

uint64_t ProtocolPP::jtcp::get_field ( field_t  field,
jarray< uint8_t > &  header 
)
virtual

Retrieves the field from the TCP header

Parameters
field- field from TCP header to retrieve
header- TCP header to retrieve field from
Returns
field from the TCP header

Implements ProtocolPP::jprotocol.

◆ get_hdr()

jarray<uint8_t> ProtocolPP::jtcp::get_hdr ( )
virtual

Retrieves the complete TCP header

Returns
TCP header

Implements ProtocolPP::jprotocol.

◆ get_security()

void ProtocolPP::jtcp::get_security ( std::shared_ptr< jtcpsa > &  sec)

get_security

Parameters
sec- Shared pointer to hold the security association

◆ set_field()

void ProtocolPP::jtcp::set_field ( field_t  field,
uint64_t  value 
)
virtual

Allows the user to update a field in the header

Parameters
field- field to update in the TCP header
value- new value to add to the TCP header

Implements ProtocolPP::jprotocol.

◆ set_hdr()

void ProtocolPP::jtcp::set_hdr ( jarray< uint8_t > &  hdr)
virtual

Allows the user to update complete TCP header

Parameters
hdr- new header to add to the TCP header

Implements ProtocolPP::jprotocol.

◆ to_json()

void ProtocolPP::jtcp::to_json ( std::ofstream &  myjson,
direction_t  direction,
std::string &  indent 
)
virtual

Writes the protocol and security objects to JSON

Parameters
myjson- JSON object
direction- randomization
indent- indentation for JSON output

Implements ProtocolPP::jprotocol.

◆ to_xml()

void ProtocolPP::jtcp::to_xml ( tinyxml2::XMLPrinter myxml,
direction_t  direction 
)
virtual

Writes the XML protocol and security objects to XML

Parameters
myxml- XMLPrinter object
direction- randomization

Implements ProtocolPP::jprotocol.


The documentation for this class was generated from the following file: