Wiesner András 8676a392e5 - TCP basic implementation added
- TCPWindow added
- Checksum bug fixed (again)
- CBD introduced
- ConnBlock modified
- PackSieve report funtionality modified to decrease memory consumption
2023-01-30 11:04:46 +01:00

61 lines
1.7 KiB
C

#ifndef ETHERLIB_TEST_TCP_WINDOW_H
#define ETHERLIB_TEST_TCP_WINDOW_H
#include <stdint.h>
#include "etherlib/memory_pool.h"
/**
* TCP segment descriptor
*/
typedef struct TcpWindowSegment_ {
uint32_t seqNum; ///< sequence number (sequence number of the first octet)
uint32_t size; ///< segment size
struct TcpWindowSegment_ * next; ///< pointer to next window segment
uint8_t data[]; ///< Segment data
} TcpWindowSegment;
// TODO TODO TODO...
/**
* TCP Window
*/
typedef struct {
TcpWindowSegment * firstSeg, *lastSeg; ///< Linked list ends of sequential segments
MP *mp; ///< Memory Pool for segment management
uint8_t data[]; ///< Window data storage
} TcpWindow;
/**
* Create new TCP Window object.
* @param size
* @return pointer to newly created TCP Window OR NULL on failure
*/
TcpWindow * tcpw_create(uint32_t size);
/**
* Get maximum allocable TCP window size. (Cannot store bigger incoming contiguous data blocks.)
* @param tcpw pointer to TCP Window object
* @return maximum size of TCP segment window
*/
uint32_t tcpw_get_max_window_size(TcpWindow * tcpw);
/**
* Store TCP segment
* @param tcpw pointer to TCP Window object
* @param data data to store
* @param size data size in bytes
* @param seqNum sequence number of first octet of the block
* @return pointer to TcpWindowSegment allocated in the window OR NULL on failure
*/
TcpWindowSegment * tcpw_store_segment(TcpWindow * tcpw, const uint8_t * data, uint32_t size, uint32_t seqNum);
/**
* Acknowledge segment.
* @param tcpw pointer to TCP Window structure
* @param ackNum acknowledgement number
* @return acknowledge success
*/
bool tcpw_acknowledge(TcpWindow * tcpw, uint32_t ackNum);
#endif //ETHERLIB_TEST_TCP_WINDOW_H