NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
SDNController.c
1/************************************************************************************
2* Copyright (C) 2023 *
3* TETCOS, Bangalore. India *
4* *
5* Tetcos owns the intellectual property rights in the Product and its content. *
6* The copying, redistribution, reselling or publication of any or all of the *
7* Product or its content without express prior written consent of Tetcos is *
8* prohibited. Ownership and / or any other right relating to the software and all *
9* intellectual property rights therein shall remain at all times with Tetcos. *
10* *
11* Author: Shashi Kant Suman *
12* *
13* ---------------------------------------------------------------------------------*/
14#include "main.h"
15#include "OpenFlow.h"
16
17bool isSDNController(NETSIM_ID d)
18{
19 ptrOPENFLOW of = GET_OPENFLOW_VAR(d);
20 if (of)
21 {
22 return of->isSDNController;
23 }
24 return false;
25}
26
27ptrSDNCLIENTINFO openFlow_find_clientInfo(NETSIM_ID ct, NETSIM_ID ci)
28{
29 ptrOPENFLOW of = GET_OPENFLOW_VAR(ct);
30 ptrSDNCLIENTINFO sd = of->INFO.clientInfo;
31 while (sd)
32 {
33 if (sd->clientId == ci)
34 return sd;
35 sd = sd->next;
36 }
37 return NULL;
38}
39
40void openFlow_add_new_client(NETSIM_ID ct,
41 NETSIM_ID ci,
42 UINT16 port)
43{
44 ptrOPENFLOW of = GET_OPENFLOW_VAR(ct);
45 ptrSDNCLIENTINFO sd = calloc(1, sizeof* sd);
46 sd->clientId = ci;
47 sd->clientIP = openFlow_find_client_IP(ci);
48 sd->clientPort = port;
49 sd->sock = fn_NetSim_Socket_CreateNewSocket(ct,
50 APP_PROTOCOL_OPENFLOW,
51 TX_PROTOCOL_TCP,
52 OFMSG_PORT,
53 port);
54
55 if (of->INFO.clientInfo)
56 {
57 ptrSDNCLIENTINFO t = of->INFO.clientInfo;
58 while (t->next)
59 t = t->next;
60 t->next = sd;
61 }
62 else
63 {
64 of->INFO.clientInfo = sd;
65 }
66}