Max OS 0.3
Loading...
Searching...
No Matches
tcp.cpp File Reference

Implementation of Transmission Control Protocol (TCP) classes and handlers. More...

#include <net/tcp.h>
#include "net/udp.h"

Go to the source code of this file.

Functions

uint32_t big_endian_32 (uint32_t x)
 Convert a 32-bit integer to big-endian format.
 
uint32_t big_endian_16 (uint16_t x)
 Convert a 16-bit integer to big-endian format.
 

Detailed Description

Implementation of Transmission Control Protocol (TCP) classes and handlers.

Date
26th March 2024
Author
Max Tyson

Definition in file tcp.cpp.

Function Documentation

◆ big_endian_16()

uint32_t big_endian_16 ( uint16_t  x)

Convert a 16-bit integer to big-endian format.

Parameters
xThe 16-bit integer to convert
Returns
The big-endian formatted integer

Definition at line 187 of file tcp.cpp.

187 {
188 return ((x & 0xFF00) >> 8)
189 | ((x & 0x00FF) << 8);
190}

Referenced by MaxOS::net::TransmissionControlProtocolHandler::handle_internet_protocol_payload(), and MaxOS::net::TransmissionControlProtocolHandler::send_transmission_control_protocol_packet().

◆ big_endian_32()

uint32_t big_endian_32 ( uint32_t  x)

Convert a 32-bit integer to big-endian format.

Parameters
xThe 32-bit integer to convert
Returns
The big-endian formatted integer

Definition at line 174 of file tcp.cpp.

174 {
175 return ((x & 0xFF000000) >> 24)
176 | ((x & 0x00FF0000) >> 8)
177 | ((x & 0x0000FF00) << 8)
178 | ((x & 0x000000FF) << 24);
179}

Referenced by MaxOS::net::TransmissionControlProtocolHandler::handle_internet_protocol_payload(), and MaxOS::net::TransmissionControlProtocolHandler::send_transmission_control_protocol_packet().