-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathofc_tdfs.h
283 lines (259 loc) · 8.89 KB
/
ofc_tdfs.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
/********************************************************************
*
* Filename: ofc_tdfs.h
*
* Description: This file contains structures and enums used in
* OpenFlow client kernel module.
*
*******************************************************************/
#ifndef __OFC_TDFS_H__
#define __OFC_TDFS_H__
#include "ofc_pkt.h"
/* Common structures */
typedef struct
{
struct task_struct *pOfcDpThread;
struct task_struct *pOfcCpThread;
struct nf_hook_ops netFilterOps;
int aDataIfSockFd[OFC_MAX_OF_IF_NUM];
char aDataIfName[OFC_MAX_IFNAME_LEN];
char aCntrlIfName[OFC_MAX_IFNAME_LEN];
int events;
} tOfcGlobals;
/* Data path structures */
typedef struct
{
struct list_head list;
__u8 *pDataPkt;
__u16 dataPktLen;
int dataIfNum;
} tDataPktRxIfQ;
typedef struct
{
struct socket *aDataSocket[OFC_MAX_OF_IF_NUM];
struct task_struct *aDataPktRxThread[OFC_MAX_OF_IF_NUM];
struct semaphore semId;
struct semaphore dataPktQSemId;
struct semaphore cpMsgQSemId;
struct list_head pktRxIfListHead; /* Queue for interfaces on which
* data packet is received */
struct list_head cpMsgListHead; /* Queue for messages from
* control path sub module */
struct list_head flowTableListHead;
int events;
} tOfcDpGlobals;
/* Control path structures */
typedef struct
{
struct socket *pCntrlSocket;
struct semaphore semId;
struct semaphore dpMsgQSemId;
struct list_head dpMsgListHead; /* Queue for messages rx from
* data path sub module */
int events;
int isModInit;
__u32 numCntrlPktInQ;
} tOfcCpGlobals;
#if 0
typedef struct _tOfcEightByte
{
__u32 hi;
__u32 lo;
} tOfcEightByte;
#endif
typedef struct
{
__u32 targetIpAddr;
} tArpMtchFlds;
typedef struct
{
__u8 inPort;
__u8 aDstMacAddr[OFC_MAC_ADDR_LEN];
__u8 aSrcMacAddr[OFC_MAC_ADDR_LEN];
__u16 vlanId;
__u16 etherType;
__u8 protocolType;
__u32 srcIpAddr;
__u32 dstIpAddr;
__u16 srcPortNum;
__u16 dstPortNum;
__u8 l4HeaderType;
tArpMtchFlds arpFlds;
} tOfcMatchFields;
typedef struct
{
struct list_head list;
struct list_head flowEntryList;
__u32 tableId;
__u8 numMatch;
__u32 activeCount;
__u32 lookupCount;
__u32 matchCount;
__u32 maxEntries;
__u8 aTableName[32];
} tOfcFlowTable;
typedef struct
{
struct list_head list;
__u64 byteMatchCount;
__u64 pktMatchCount;
__u32 hardTimeout;
__u32 idleTimeout;
tOfcEightByte cookie;
tOfcEightByte cookieMask;
__u16 flags;
__u16 priority;
__u32 bufId;
__u32 outPort;
__u32 outGrp;
__u32 tableId;
__u32 matchCount;
struct list_head matchList;
struct list_head instrList;
tOfcMatchFields matchFields;
} tOfcFlowEntry;
typedef struct
{
struct list_head list;
tOfcFlowEntry *pFlowEntry;
struct list_head *pActionListHead;
__u8 *pPkt;
__u32 pktLen;
__u8 inPort;
__u8 msgType;
__u8 tableId;
tOfcEightByte cookie;
} tDpCpMsgQ;
typedef struct
{
struct list_head list;
__u8 field;
__u8 length;
/* TODO: Masks not supported */
__u8 aValue[16];
} tMatchListEntry;
typedef struct
{
struct list_head list;
__u16 instrType;
union
{
__u8 tableId;
struct list_head actionList;
} u;
} tOfcInstrList;
typedef struct
{
struct list_head list;
__u16 actionType;
union
{
__u32 outPort;
struct list_head setFieldList;
} u;
} tOfcActionList;
typedef struct
{
struct list_head list;
__u16 type;
__u8 aPad[2];
__u8 aValue[16];
} tOfcSetFields;
typedef struct
{
struct list_head list;
__u32 outPort;
} tOfcOutPortList;
enum
{
OFC_FLOW_MOD_ADD = 0,
OFC_FLOW_MOD_DEL,
OFC_PACKET_OUT
};
/* Function Declarations */
int OfcDpReceiveEvent (int events, int *pRxEvents);
int OfcDpSendEvent (int events);
void OfcDumpPacket (char *au1Packet, int len);
void OfcDumpFlows (__u8 tableId);
int OfcDumpFlowFields (tOfcFlowEntry *pFlowEntry);
struct net_device *OfcGetNetDevByName (char *pIfName);
struct net_device *OfcGetNetDevByIp (unsigned int ipAddr);
int OfcConvertStringToIp (char *pString, unsigned int *pIpAddr);
int OfcDeleteList (struct list_head *pListHead);
int OfcCalcHdrOffset (__u8 *pPkt, __u16 pktLen, __u8 hdrField,
__u16 *pPktOffset);
int OfcDpMainTask (void *args);
int OfcDpCreateSocketsForDataPkts (void);
int OfcDpCreateThreadsForRxDataPkts (void);
int OfcDpRxDataPacket (void);
int OfcDpSendToDataPktQ (int dataIfNum, __u8 *pDataPkt,
__u16 dataPktLen);
tDataPktRxIfQ *OfcDpRecvFromDataPktQ (void);
tDpCpMsgQ *OfcDpRecvFromCpMsgQ (void);
int OfcDpSendToCpQ (tDpCpMsgQ *pMsgParam);
int OfcDpCreateFlowTables (void);
__u32 OfcDpRcvDataPktFromSock (__u8 dataIfNum, __u8 **ppPkt,
__u32 *pPktLen);
int OfcDpSendDataPktOnSock (__u8 dataIfNum, __u8 *pPkt,
__u32 pktLen);
tOfcFlowTable *OfcDpGetFlowTableEntry (__u8 tableId);
int OfcDpRxDataPktThread (void *args);
int OfcDpProcessPktOpenFlowPipeline (__u8 *pPkt, __u32 pktLen,
__u8 inPort);
int OfcDpExecuteFlowInstr (__u8 *pPkt, __u32 pktLen, __u8 inPort,
struct list_head *pInstrList, __u8 *pTableId,
__u32 *pOutPortList, __u8 *pNumOutPorts);
int OfcDpApplyInstrActions (__u8 *pPkt, __u32 pktLen, __u8 inPort,
struct list_head *pActionsList,
__u32 *pOutPortList, __u8 *pNumOutPorts);
tOfcFlowEntry *OfcDpGetBestMatchFlow (tOfcMatchFields pktMatchFields,
struct list_head *pFlowEntryList,
__u8 *pIsTableMiss);
int OfcDpExtractPktHdrs (__u8 *pPkt, __u32 pktLen, __u8 inPort,
tOfcMatchFields *pPktMatchFields);
int OfcDpRxControlPathMsg (void);
int OfcDpInsertFlowEntry (tOfcFlowEntry *pFlowEntry);
int OfcDpDeleteFlowEntry (tOfcFlowEntry *pFlowEntry);
int OfcDpExecPktOutActions (__u8 *pPkt, __u16 pktLen,
struct list_head *pActionsListHead);
int OfcCpMainTask (void *args);
int OfcCpReceiveEvent (int events, int *pRxEvents);
int OfcCpSendEvent (int events);
int OfcCpCreateCntrlSocket (void);
int OfcCpRxControlPacket (void);
int OfcCpSendToDpQ (tDpCpMsgQ *pMsgParam);
tDpCpMsgQ *OfcCpRecvFromDpMsgQ (void);
int OfcCpSendToCntrlPktQ (void);
__u32 OfcCpRecvFromCntrlPktQ (void);
int OfcCpRecvCntrlPktOnSock (__u8 **ppPkt, __u16 *pPktLen);
int OfcCpSendCntrlPktFromSock (__u8 *pPkt, __u32 pktLen);
void OfcCpRxDataPathMsg (void);
int OfcCpAddOpenFlowHdr (__u8 *pPktHdr, __u16 pktHdrLen,
__u8 msgType, __u32 xid,
__u8 **ppOfPkt);
int OfcCpSendHelloPacket (__u32 xid);
int OfcCpSendEchoReply (__u8 *pCntrlPkt, __u16 cntrlPktLen);
int OfcCpSendFeatureReply (__u8 *pCntrlPkt);
int OfcCpConstructPacketIn (__u8 *pPkt, __u32 pktLen, __u8 inPort,
__u8 msgType, __u8 tableId,
tOfcEightByte cookie,
tOfcMatchFields matchFields,
__u8 **ppOpenFlowPkt);
int OfcCpProcessPktOut (__u8 *pPkt, __u16 pktLen);
int OfcCpProcessFlowMod (__u8 *pPkt, __u16 pktLen);
tOfcFlowEntry *OfcCpExtractFlow (tOfcFlowModHdr *pFlowMod,
__u16 flowModLen);
int OfcCpAddMatchFieldsInFlow (tOfcFlowModHdr *pFlowMod, __u16 flowModLen,
tOfcFlowEntry *pFlowEntry);
int OfcCpAddInstrListInFlow (tOfcFlowModHdr *pFlowMod,
__u16 flowModLen,
tOfcFlowEntry *pFlowEntry);
int OfcCpAddActionListToInstr (tOfcActionTlv *pActionTlv,
__u16 actionTlvLen,
tOfcInstrList *pInstrList);
int OfcCpProcessMultipartReq (__u8 *pCntrlPkt, __u16 cntrlPktLen);
int OfcCpHandleMultipartSwitchDesc (__u8 *pCntrlPkt,
__u16 cntrlPktLen);
int OfcCpHandleMultipartPortDesc (__u8 *pCntrlPkt, __u16 cntrlPktLen);
int OfcCpSendBarrierReply (__u32 xid);
#endif /* __OFC_TDFS_H__ */