NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
LTENR_Buffer.h
1#pragma once
2/************************************************************************************
3 * Copyright (C) 2023
4 * TETCOS, Bangalore. India *
5
6 * Tetcos owns the intellectual property rights in the Product and its content. *
7 * The copying, redistribution, reselling or publication of any or all of the *
8 * Product or its content without express prior written consent of Tetcos is *
9 * prohibited. Ownership and / or any other right relating to the software and all *
10 * intellectual property rights therein shall remain at all times with Tetcos. *
11 * Author: Shashi Kant Suman *
12 * ---------------------------------------------------------------------------------*/
13#ifndef _NETSIM_LTENR_BUFFER_H_
14#define _NETSIM_LTENR_BUFFER_H_
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20#pragma region MACROS
21 typedef void* ptrLTENR_BUFFERITERATOR;
22#define INFINITE_BUFFER 0xFFFFFFFFFFFFFFFF
23#pragma endregion
24
25#pragma region LTENR_BufferPacket
27 {
28 NetSim_PACKET* packet;
29 UINT64 size;
30 double time;
31 void* optionalInfo;
32
33 bool isMarked;
34 struct stru_LTENR_BufferPacket* next;
35 }LTENR_BUFFEREDPACKET, *ptrLTENR_BUFFEREDPACKET;
36#pragma endregion
37
38#pragma region LTENR_BUFFER_AND_MACROS
39 typedef struct stru_LTENR_BUFFER
40 {
41 UINT64 maxSize;
42 UINT64 currentSize;
43 ptrLTENR_BUFFEREDPACKET headPacket;
44 ptrLTENR_BUFFEREDPACKET tailPacket;
45
46 void* iterator;
47 }LTENR_BUFFER, *ptrLTENR_BUFFER;
48
49#define LTENR_BUFFER_ISEMPTY(buffer) (buffer != NULL && buffer->headPacket == NULL)
50#define LTENR_BUFFER_HASPACKET(buffer) (buffer != NULL && buffer->headPacket != NULL)
51#pragma endregion
52
53#pragma region FUN_DEF
54 //Function prototype
55 ptrLTENR_BUFFER LTENR_BUFFER_INIT(UINT64 maxSize/*In Bytes*/);
56 void LTENR_BUFFER_DELETE(ptrLTENR_BUFFER buffer);
57
58 bool LTENR_BUFFER_ADDPACKET(ptrLTENR_BUFFER buffer,
59 NetSim_PACKET* packet,
60 UINT64 size,
61 double time,
62 void* optional);
63 bool LTENR_BUFFER_ADDPACKET_SORTED(ptrLTENR_BUFFER buffer,
64 NetSim_PACKET* packet,
65 UINT64 size,
66 double time,
67 void* optional,
68 bool(*fnSort)(ptrLTENR_BUFFEREDPACKET currBuffered,
69 ptrLTENR_BUFFEREDPACKET newBuffered));
70 NetSim_PACKET* LTENR_BUFFER_GETPACKET(ptrLTENR_BUFFER buffer,
71 UINT64* size /* optional*/,
72 double* time /* optional*/,
73 void** optional /* optional*/);
74 NetSim_PACKET* LTENR_BUFFER_HEADPACKET(ptrLTENR_BUFFER buffer,
75 UINT64* size /* optional*/,
76 double* time /* optional*/,
77 void** optional /* optional*/);
78
79 //Buffer Iterator
80 ptrLTENR_BUFFERITERATOR _LTENR_BUFFER_NEWITERATOR_(ptrLTENR_BUFFER buffer, int line, char* file);
81#define LTENR_BUFFER_NEWITERATOR(buffer) (_LTENR_BUFFER_NEWITERATOR_((buffer),__LINE__,__FILE__))
82
83 void LTENR_BUFFER_DELETEITERATOR(ptrLTENR_BUFFERITERATOR* it);
84 NetSim_PACKET* LTENR_BUFFER_ITERATOR_NEXT(ptrLTENR_BUFFERITERATOR it);
85 void LTENR_BUFFER_ITERATOR_REMOVE(ptrLTENR_BUFFERITERATOR it);
86 NetSim_PACKET* LTENR_BUFFER_ITERATOR_CURRENT(ptrLTENR_BUFFERITERATOR it);
87#pragma endregion
88
89#ifdef __cplusplus
90}
91#endif // __cplusplus
92#endif //_NETSIM_LTENR_BUFFER_H_