2 * Acess2 Networking Stack
3 * - By John Hodge (thePowersGang)
6 * - Outbound packet buffer management
8 #ifndef _IPSTACK__BUFFER_H_
9 #define _IPSTACK__BUFFER_H_
11 typedef struct sIPStackBuffer tIPStackBuffer;
12 typedef void (*tIPStackBufferCb)(void *Arg, size_t HeadLen, size_t FootLen, const void *Data);
15 * \brief Create a buffer object, with space for \a MaxSubBuffers calls to IPStack_Buffer_AppendSubBuffer
17 extern tIPStackBuffer *IPStack_Buffer_CreateBuffer(int MaxSubBuffers);
19 * \brief Destory a created buffer object
21 extern void IPStack_Buffer_DestroyBuffer(tIPStackBuffer *Buffer);
24 * \brief Append a buffer to the object
25 * \param Buffer Buffer object from IPStack_Buffer_CreateBuffer
26 * \param HeadLength Number of bytes in \a Data that should be at the beginning of the packet
27 * \param FootLength Number of bytes in \a Data that should be at the end of the packet
28 * \param Data Actual data
29 * \param Cb Unused - eventually will be called when object is destroyed
30 * \param Arg Unused - will be argument for \a Cb
32 extern void IPStack_Buffer_AppendSubBuffer(tIPStackBuffer *Buffer,
33 size_t HeadLength, size_t FootLength, const void *Data,
34 tIPStackBufferCb Cb, void *Arg
38 * \brief Get the total length of a buffer
40 extern size_t IPStack_Buffer_GetLength(tIPStackBuffer *Buffer);
42 * \brief Get a sub-buffer from the buffer object
43 * \param PrevID Previous return value, or -1 to start
44 * \return -1 when the last buffer has been returned (*Length is not valid in this case)
45 * \note Used to iterate though the buffer without compacting it
47 extern int IPStack_Buffer_GetBuffer(tIPStackBuffer *Buffer, int PrevID, size_t *Length, const void **Data);
50 * \brief Compact a buffer into a single contiguous malloc'd buffer
51 * \param Buffer Input buffer object
52 * \param Length Pointer in which to store the length of the allocated buffer
53 * \return malloc'd packet data
55 extern void *IPStack_Buffer_CompactBuffer(tIPStackBuffer *Buffer, size_t *Length);