EtherLib/blocking_fifo.h
Wiesner András 8a5c800fd3 - BlockingFifo implemented
- 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
2023-11-22 20:55:50 +01:00

46 lines
1.2 KiB
C

//
// Created by epagris on 2023.11.22..
//
#ifndef ETHERLIB_TEST_BLOCKING_FIFO_H
#define ETHERLIB_TEST_BLOCKING_FIFO_H
#include <stdint.h>
#include <etherlib_options.h>
/**
* Blocking FIFO
*/
typedef struct {
uint32_t readIdx; ///< Read index
uint32_t absReadIdx; ///< Absolute read index
uint32_t writeIdx; ///< Write index
uint32_t absWriteIdx; ///< Absolute write index
uint32_t size; ///< Size of the storage area
ETHLIB_OS_SEM_TYPE notFull, nonEmpty; ///< Semaphore, protecting read and write operations
uint8_t data[]; ///< Window data storage
} BlockingFifo;
/**
* Create new blocking FIFO.
* @param size size of the FIFO in bytes
* @return newly allocated FIFO
*/
BlockingFifo * bfifo_new(uint32_t size);
void bfifo_destroy(BlockingFifo * bfifo);
uint32_t bfifo_get_used(const BlockingFifo * bfifo);
uint32_t bfifo_get_free(const BlockingFifo * bfifo);
uint32_t bfifo_push(BlockingFifo * bfifo, const uint8_t * data, uint32_t size);
uint32_t bfifo_push_try(BlockingFifo * bfifo, const uint8_t * data, uint32_t size);
uint32_t bfifo_peek(BlockingFifo * bfifo, uint8_t * dst, uint32_t size);
uint32_t bfifo_pop(BlockingFifo *bfifo, uint8_t *dst, uint32_t size);
#endif //ETHERLIB_TEST_BLOCKING_FIFO_H