/
Protocol.h
115 lines (112 loc) · 4.73 KB
/
Protocol.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/************************************************************************************
* Copyright (C) 2013 *
* TETCOS, Bangalore. India *
* *
* Tetcos owns the intellectual property rights in the Product and its content. *
* The copying, redistribution, reselling or publication of any or all of the *
* Product or its content without express prior written consent of Tetcos is *
* prohibited. Ownership and / or any other right relating to the software and all *
* intellectual property rights therein shall remain at all times with Tetcos. *
* *
* Author: Shashi Kant Suman *
* *
* ---------------------------------------------------------------------------------*/
#ifndef _NETSIM_PROTOCOL_H_
#define _NETSIM_PROTOCOL_H_
#ifdef __cplusplus
extern "C" {
#endif
# define MAX_NAME_CHAR 50
# define MAX_CONTROL_PACKET 50
enum enum_isConfigured
{
DISABLE=0,
ENABLE=1,
};
enum dll_id
{
libTCP=0,
libIP,
libUDP,
libRIP,
libOSPF,
libDSR,
libAODV,
libWLAN,
libEthernet,
libZigbee,
libWiMax,
libBGP,
libGSM,
libCDMA,
libARP,
libCR,
libMobility,
libApplication,
libLTE,
libTDMA,
libDTDMA,
libZRP,
libOLSR,
libAloha,
libCSMACD,
libToken_BR,
nProtocolCount, //Keep this at last
};
struct stru_ProtocolInfo
{
int nComponentId;
char dllName[MAX_NAME_CHAR];
char protocolName[MAX_NAME_CHAR];
int protocolId;
ISCONFIGURED status;
char pszControlPacketName[MAX_CONTROL_PACKET][MAX_NAME_CHAR];
};
#ifndef _NETSIM_CODE_
_declspec(dllimport) struct stru_ProtocolInfo pstruProtocolInfo[nProtocolCount];
#else
#ifndef _NETSIM_PROTOCOL_INTERFACE_CODE_
extern struct stru_ProtocolInfo pstruProtocolInfo[nProtocolCount];
#endif
#endif
HINSTANCE hProtocolDll[nProtocolCount];
/*****************************************************************************
Common function for all protocol. These are the interface function present in
protocol dll by which stack interact with protocol.
******************************************************************************/
//Function Pointer for protocol main function
typedef int (*protocol_run)(); //Function name must be fn_NetSim_[Protocol Name]_run
protocol_run fnpProtocol_Run[nProtocolCount];
//Function pointer for protocol initialization function
typedef int (*protocol_init)(const struct stru_NetSim_Network*,const struct stru_NetSim_EventDetails*,const char*,const char*,int);
protocol_init fnpProtocol_Init[nProtocolCount]; //Function name must be fn_NetSim_[Protocol Name]_init
//Function pointer for event trace
typedef char* (*protocol_trace)(int); //Function name must be fn_NetSim_[Protocol Name]_trace
protocol_trace fnpProtocol_Trace[nProtocolCount];
//Function pointer for copy packet
typedef int (*protocol_CopyPacket)(const NetSim_PACKET* pstruDestPacket,const NetSim_PACKET* pstruSrcPacket);
protocol_CopyPacket fnpProtocol_CopyPacket[nProtocolCount]; //Function name must be fn_NetSim_[Protocol Name]_CopyPacket
//Function pointer for free packet
typedef int (*protocol_FreePacket)(const NetSim_PACKET* pstruPacket);
protocol_FreePacket fnpProtocol_FreePacket[nProtocolCount]; //Function name must be fn_NetSim_[Protocol Name]_FreePacket
//Function pointer for metrics
typedef int (*protocol_Metrics)(const char* szMetricsFile);
protocol_Metrics fnpProtocol_Metrics[nProtocolCount]; //Function name must be fn_NetSim_[Protocol Name]_Metrics
//Function pointer for finish
typedef int (*protocol_Finish)();
protocol_Finish fnpProtocol_Finish[nProtocolCount]; //Function name must be fn_NetSim_[Protocol Name]_Finish
//Function pointer for configure
typedef int (*protocol_Configure)(void**);
protocol_Configure fnpProtocol_Configure[nProtocolCount]; //Function name must be fn_NetSim_[Protocol Name]_Configure
//Function pointer to configure packet trace
typedef char* (*protocol_ConfigPacketTrace)(const void* xmlNetSimNode);
protocol_ConfigPacketTrace fnpProtocol_ConfigPacketTrace[nProtocolCount]; //Function name must be fn_NetSim_[Protocol Name]_ConfigPacketTrace
//Function pointer to write packet trace
typedef int (*protocol_WritePacketTrace)(const NetSim_PACKET*,char**);
protocol_WritePacketTrace fnpProtocol_WritePacketTrace[nProtocolCount]; //Function name must be fn_NetSim_[Protocol Name]_WritePacketTrace
_declspec(dllexport) int fnCallProtocol(int nProtocol);
_declspec(dllexport) int fn_NetSim_LoadProtocolDll(int nId,const char* name,const char* dllName);
#ifdef __cplusplus
}
#endif
#endif