#ifndef ETHERLIB_TCP_WINDOW_H #define ETHERLIB_TCP_WINDOW_H #include //#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); /** * 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 pointer to TcpWindowSegment allocated in the window OR NULL on failure */ uint32_t 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_TCP_WINDOW_H