- get_interface_by_address() added - HTTP server initials added - code added to strip away padding on processing the IP layer by shrinking overall packet size - load of TCP fixes and improvements - TCP stream interface added - TCP window destroy() added and some bugs fixed
66 lines
1.8 KiB
C
66 lines
1.8 KiB
C
#ifndef ETHERLIB_TCP_WINDOW_H
|
|
#define ETHERLIB_TCP_WINDOW_H
|
|
|
|
#include <stdint.h>
|
|
#include <etherlib_options.h>
|
|
|
|
//#include "../../../memory_pool.h"
|
|
|
|
/**
|
|
* TCP Window
|
|
*/
|
|
typedef struct {
|
|
uint32_t nextWritten; ///< Sequence number of next written octet (Sequence number of next unacknowledged octet)
|
|
uint32_t firstUnACK; ///< Sequence number of last acknowledged octet + 1
|
|
uint32_t firstByteOffset; ///< Sequence number offset of the array's first byte
|
|
uint32_t size; ///< Size of the storage area
|
|
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);
|
|
|
|
/**
|
|
* Destruct TCP Window object.
|
|
* @param tcpw pointer to previously allocated TCP Window object
|
|
*/
|
|
void tcpw_destroy(TcpWindow * tcpw);
|
|
|
|
/**
|
|
* Set sequence number offset
|
|
* @param tcpw
|
|
* @param offset
|
|
*/
|
|
void tcpw_set_seqnum_offset(TcpWindow * tcpw, uint32_t offset);
|
|
|
|
/**
|
|
* 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);
|
|
|
|
/** TODO: rename function
|
|
* 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 number of stored bytes
|
|
*/
|
|
uint32_t tcpw_store(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_TCP_WINDOW_H
|