NetSim Source Code Help
Loading...
Searching...
No Matches
IP_Routing.c
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2021 *
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* This source code is licensed per the NetSim license agreement. *
12* *
13* No portion of this source code may be used as the basis for a derivative work, *
14* or used, for any purpose other than its intended use per the NetSim license *
15* agreement. *
16* *
17* This source code and the algorithms contained within it are confidential trade *
18* secrets of TETCOS and may not be used as the basis for any other software, *
19* hardware, product or service. *
20* *
21* Author: Shashi Kant Suman *
22* *
23* ----------------------------------------------------------------------------------*/
24#include "main.h"
25#include "List.h"
26#include "IP.h"
27#include "NetSim_utility.h"
28#include "Protocol.h"
29#include "../Firewall/Firewall.h"
30
31/** This function is used to route the packet */
32typedef struct stru_match
33{
39#define MATCH_ALLOC() (ptrMATCH)list_alloc(sizeof(MATCH),offsetof(MATCH,ele))
40
42{
43 static FILE* fp = NULL;
44#ifdef PRINT_MATCH_TABLE
45 if (!fp)
46 {
47 fp = fopen("MatchTable.csv", "w");
48 fprintf(fp, "Dest,Gateway,Ifcount,Iflist,\n");
49 fflush(fp);
50 }
51#endif
52 if (fp)
53 {
54 fprintf(fp, " Device %d, dest = %s, Src = %s\n", d, dest->str_ip, src->str_ip);
55 while (match)
56 {
57 UINT i;
58 fprintf(fp, "%s,%s,%d,",
60 match->table->gateway?match->table->gateway->str_ip:"EMPTY",
61 match->table->interfaceCount);
62 for (i = 0; i < match->table->interfaceCount; i++)
63 fprintf(fp, "%s,", match->table->Interface[i]->str_ip);
64 fprintf(fp, "\n");
65 match = LIST_NEXT(match);
66 }
67 fprintf(fp, "\n\n");
68 fflush(fp);
69 }
70}
71
73{
74 while (l)
75 LIST_FREE(&l, l);
76}
77
78static int match_check(ptrMATCH m1, ptrMATCH m2)
79{
80 if (m2->bitsCount > m1->bitsCount)
81 return 2;
82 if (m2->bitsCount == m1->bitsCount)
83 {
84 if (m2->metric < m1->metric)
85 return 2;
86 }
87 return 0;
88}
89
91{
93}
94
96{
97 char b1[40];
98
99 IP_TO_BINARY(ip1, b1);
100
101 UINT l = (UINT)strlen(b1);
102 UINT i;
103 for (i = 0; i < l; i++)
104 {
105 if (b1[i] == '0')
106 break;
107 }
108 return i;
109}
110
112{
113 ptrMATCH l = NULL;
114 ptrMATCH c = NULL;
115 NETSIM_IPAddress network1;
116 NETSIM_IPAddress network2;
117
118 while (table)
119 {
120 bool isC = (isStatic && table->type == RoutingType_STATIC) || (!isStatic);
121 if (!isC)
122 {
123 table = LIST_NEXT(table);
124 continue;
125 }
126
127 if (!IP_COMPARE(dest, table->networkDestination) && ICMP_CHECKSTATE(dest))
128 {
129 c = MATCH_ALLOC();
130 c->table = table;
131 c->bitsCount = dest->type == 4 ? 32 : 128;
132 c->metric = 999;
133 add_to_match_list(&l, c);
134 }
135 else if (dest->type == table->networkDestination->type)
136 {
137 network1 = IP_NETWORK_ADDRESS(dest, table->netMask, table->prefix_len);
138 network2 = IP_NETWORK_ADDRESS(table->networkDestination, table->netMask, table->prefix_len);
139 if (!IP_COMPARE(network1, network2))
140 {
141 if (ICMP_CHECKSTATE(table->gateway))
142 {
143 c = MATCH_ALLOC();
144 c->table = table;
145 c->bitsCount = dest->type == 4 ? get_bit_match_count(table->netMask) : table->prefix_len;
146 c->metric = table->Metric;
147 add_to_match_list(&l, c);
148 }
149 }
150 }
151 table = LIST_NEXT(table);
152 }
153
154 return l;
155}
156
158{
159 if (route == NULL)return;
160 free(route->interfaceId);
161 free(route->nextHop);
162 free(route->nextHopId);
163 free(route->gateway);
164 free(route);
165}
166
168{
169 NETSIM_ID i;
170 NETSIM_ID in;
171 if (match)
172 {
173 ptrIP_ROUTINGTABLE table = match->table;
174
175 route->count = table->interfaceCount;
176
177 route->nextHop = calloc(table->interfaceCount, sizeof* route->nextHop);
178 route->gateway = calloc(table->interfaceCount, sizeof* route->gateway);
179 route->interfaceId = calloc(table->interfaceCount, sizeof* route->interfaceId);
180 route->nextHopId = calloc(table->interfaceCount, sizeof* route->nextHopId);
181
182 for (i = 0; i < table->interfaceCount; i++)
183 {
184 if (table->gateway)
185 route->nextHop[i] = table->gateway;
186 else
187 route->nextHop[i] = dest;
188
189 route->gateway[i] = table->Interface[i];
190
191 route->interfaceId[i] = table->nInterfaceId[i];
192
193 if (!table->nGatewayId && table->gateway)
195
196 if (table->nGatewayId)
197 route->nextHopId[i] = table->nGatewayId;
198 else
199 route->nextHopId[i] = 0; //MAC layer will decide
200 }
201 }
202}
203
205 NETSIM_IPAddress dest,
207{
208 bool isResevedAddr = is_reserved_multicast_address(dest);
209 if (!isResevedAddr)
210 return match;
211
212 while (match)
213 {
214 if (isCorrectRoute(&match->table, dest, src))
215 return match;
216 match = LIST_NEXT(match);
217 }
218 return NULL;
219}
220
223 NETSIM_IPAddress dest,
225{
226 NETSIM_ID i;
227 NETSIM_ID c;
228 NETSIM_ID in;
229
230 match = choose_match_for_reserved_address(match, dest, src);
231 if (match)
232 {
233 ptrIP_ROUTINGTABLE table = match->table;
234
235 route->count = table->interfaceCount;
236
237 route->nextHop = calloc(table->interfaceCount, sizeof* route->nextHop);
238 route->gateway = calloc(table->interfaceCount, sizeof* route->gateway);
239 route->interfaceId = calloc(table->interfaceCount, sizeof* route->interfaceId);
240 route->nextHopId = calloc(table->interfaceCount, sizeof* route->nextHopId);
241
242 for (i = 0, c = 0; i < table->interfaceCount; i++, c++)
243 {
245 {
246 c--;
247 route->count--;
248 continue;
249 }
250
251 if (table->gateway)
252 route->nextHop[c] = table->gateway;
253 else
254 route->nextHop[c] = dest;
255
256 route->gateway[c] = table->Interface[i];
257
258 route->interfaceId[c] = table->nInterfaceId[i];
259
260 if (!table->nGatewayId && table->gateway)
262
263 if (table->nGatewayId)
264 route->nextHopId[c] = table->nGatewayId;
265 else
266 route->nextHopId[c] = 0; //MAC layer will decide
267 }
268 }
269}
270
273 NETSIM_IPAddress dest,
275{
276 NETSIM_ID i;
277 UINT c = 0;
278 for (i = 0; i < DEVICE(d)->nNumOfInterface; i++)
279 {
280 if (IP_IS_IN_SAME_NETWORK(src,
281 DEVICE_NWADDRESS(d, i + 1),
282 DEVICE_INTERFACE(d, i + 1)->szSubnetMask,
283 DEVICE_INTERFACE(d, i + 1)->prefix_len))
284 {
285 route->count++;
286 if (route->gateway)
287 {
288 route->gateway = realloc(route->gateway, route->count * sizeof* route->gateway);
289 route->interfaceId = realloc(route->interfaceId, route->count * sizeof* route->interfaceId);
290 route->nextHop = realloc(route->nextHop, route->count * sizeof* route->nextHop);
291 route->nextHopId = realloc(route->nextHopId, route->count * sizeof* route->nextHopId);
292 }
293 else
294 {
295 route->gateway = calloc(1, route->count * sizeof* route->gateway);
296 route->interfaceId = calloc(1, route->count * sizeof* route->interfaceId);
297 route->nextHop = calloc(1, route->count * sizeof* route->nextHop);
298 route->nextHopId = calloc(1, route->count * sizeof* route->nextHopId);
299 }
300 route->gateway[c] = DEVICE_NWADDRESS(d, i + 1);
301 route->interfaceId[c] = i + 1;
302 route->nextHop[c] = dest;
303 route->nextHopId[c] = 0;
304 c++;
305 }
306 }
307}
308
310{
311 NETSIM_ID i;
312 for (i = 0; i < DEVICE(d)->nNumOfInterface; i++)
313 if (!IP_COMPARE(DEVICE_NWADDRESS(d, i + 1), ip))
314 return true;
315 return false;
316}
317
319 NETSIM_ID dev)
320{
321 ptrIP_ROUTINGTABLE routingTable = IP_TABLE_GET(dev);
323
324 ptrMATCH match = get_match_table(routingTable, dest, false);
325
326 ptrMATCH store = match;
327
328 ptrIP_FORWARD_ROUTE route = (ptrIP_FORWARD_ROUTE)calloc(1, sizeof* route);
329
330 update_route_entry(match, route, dest);
331
332 free_match_table(store);
333
334 if (!route->count)
335 {
336 free_ip_route(route);
337 route = NULL;
338 }
339
340 return route;
341}
342
344 NETSIM_ID dev)
345{
346 ptrIP_ROUTINGTABLE routingTable = IP_TABLE_GET(dev);
349
350 ptrMATCH match = get_match_table(routingTable, dest, false);
351#ifdef PRINT_MATCH_TABLE
352 print_match_table(match, dev, dest, src);
353#endif
354 ptrMATCH store = match;
355
356 ptrIP_FORWARD_ROUTE route = (ptrIP_FORWARD_ROUTE)calloc(1, sizeof* route);
357
358 multicast_update_route_entry(match, route, dest, src);
359
360 free_match_table(store);
361
362 if (!route->count)
363 {
364 free(route);
365 route = NULL;
366 }
367
368 return route;
369}
370
372 NETSIM_ID dev)
373{
375
376 if (isMulticastIP(dest))
377 return route_multicast(packet, dev);
378 else
379 return route_unicast(packet, dev);
380}
381
383 NETSIM_IPAddress gateway, NETSIM_ID in, UINT metric)
384{
385 UINT i;
386 bool isfound = false;
387 for (i = 0; i < table->interfaceCount; i++)
388 {
389 if (in == table->nInterfaceId[i])
390 {
391 isfound = true;
392 break;
393 }
394 }
395 if (isfound)
396 {
397 table->gateway = gateway;
398 table->Metric = metric;
399 }
400 else
401 {
402 table->Interface = realloc(table->Interface, (table->interfaceCount + 1) * sizeof* table->Interface);
403 table->nInterfaceId = realloc(table->nInterfaceId, (table->interfaceCount + 1) * sizeof* table->Interface);
404 table->nInterfaceId[table->interfaceCount] = in;
405 table->Interface[table->interfaceCount] = DEVICE_NWADDRESS(d, in);
406 table->gateway = gateway;
407 table->Metric = metric;
408 table->interfaceCount++;
409 }
410}
411
413 NETSIM_IPAddress gateway, NETSIM_ID in, UINT metric)
414{
415 iptable_add(IP_WRAPPER_GET(d), dest, mask, 0, gateway, 1, &DEVICE_NWADDRESS(d, in), &in, metric, "STATIC");
416}
417
418#define display_error(error, line, file) fnNetSimError("Invalid line in route file %s at line %d: %s", file, line, error)
419/** This function is to configure static ip table */
421{
422 UINT line = 0;
423 NETSIM_ID nDevId = 0;
424 char* temp;
425 int metric = 0;
426
427 char input[BUFSIZ];
428 sprintf(input, "%s%s%s", pszIOPath, pathSeperator, file);
429 FILE* fp = fopen(input, "r");
430 if (fp == NULL)
431 {
432 perror(input);
433 fnNetSimError("Unable to open routing file %s", input);
434 return;
435 }
436
437 while (fgets(input, BUFSIZ, fp))
438 {
439 line++;
440 temp = input;
441 temp = lskip(temp);
442 if (*temp == '#' || !*temp)
443 continue; //Comment or empty line
444
445 char* f = find_word(&temp);
446 if (_stricmp(f, "route"))
447 {
448 display_error("Not start with route", file, line);
449 continue;
450 }
451
452 f = find_word(&temp);
453 if (_stricmp(f, "add"))
454 {
455 display_error("Second word is not add", file, line);
456 continue;
457 }
458
459 f = find_word(&temp);
461
462 f = find_word(&temp);
463 if (_stricmp(f, "mask"))
464 {
465 display_error("Fourth word is not mask", file, line);
466 continue;
467 }
468
469 f = find_word(&temp);
471
472 f = find_word(&temp);
473 NETSIM_IPAddress gateway = STR_TO_IP4(f);
474
475 f = find_word(&temp);
476 if (_stricmp(f, "metric"))
477 {
478 display_error("Seventh word is not metric", file, line);
479 continue;
480 }
481
482 f = find_word(&temp);
483 UINT metric = atoi(f);
484
485 f = find_word(&temp);
486 if (_stricmp(f, "IF"))
487 {
488 display_error("Ninth word is not if", file, line);
489 continue;
490 }
491
492 f = find_word(&temp);
493 NETSIM_ID in = atoi(f);
495
496 ptrIP_ROUTINGTABLE table = iptable_check(PIP_TABLE_GET(d), dest, mask);
497 if (table)
498 change_table(d, table, gateway, in, metric);
499 else
500 add_table(d, dest, mask, gateway, in, metric);
501
502 }
503}
504
506 NETSIM_ID dev)
507{
508 ptrIP_ROUTINGTABLE routingTable = IP_TABLE_GET(dev);
510
511 ptrMATCH match = get_match_table(routingTable, dest, true);
512
513 ptrMATCH store = match;
514
515 ptrIP_FORWARD_ROUTE route = (ptrIP_FORWARD_ROUTE)calloc(1, sizeof* route);
516
517 update_route_entry(match, route, dest);
518
519 free_match_table(store);
520
521 if (!route->count)
522 {
523 free(route);
524 route = NULL;
525 }
526
527 return route;
528}
529
531 NETSIM_ID dev)
532{
533 ptrIP_ROUTINGTABLE routingTable = IP_TABLE_GET(dev);
536
537 ptrMATCH match = get_match_table(routingTable, dest, true);
538#ifdef PRINT_MATCH_TABLE
539 print_match_table(match, dev, dest, src);
540#endif
541 ptrMATCH store = match;
542
543 ptrIP_FORWARD_ROUTE route = (ptrIP_FORWARD_ROUTE)calloc(1, sizeof* route);
544
545 multicast_update_route_entry(match, route, dest, src);
546
547 free_match_table(store);
548
549 if (!route->count)
550 {
551 free(route);
552 route = NULL;
553 }
554
555 return route;
556}
557
559{
561
562 if (isMulticastIP(dest))
563 return static_route_multicast(packet, dev);
564 else
565 return static_route_unicast(packet, dev);
566}
567
569{
570 NetSim_EVENTDETAILS pevent;
571 memset(&pevent, 0, sizeof pevent);
572
573 NETSIM_ID d, n, i;
574
576 if (route)
577 {
578 packet->pstruNetworkData->szNextHopIp = route->nextHop[c];
579 packet->pstruNetworkData->szGatewayIP = route->gateway[c];
580 n = route->nextHopId[c];
581 i = route->interfaceId[c];
582 }
583 else
584 {
585 if (!packet->pstruNetworkData->szGatewayIP)
587
591 else
593
594 NETSIM_ID k; //Not used
596 &k);
597
598 }
599
600 //check for firewall
602 {
603 ipMetrics[d - 1]->nFirewallBlocked++;
606 return;
607 }
608
610 {
611 fnNetSimError("Gateway IP and next hop IP are same. IP address=%s\n",
613 }
614
617 packet->pstruNetworkData->dPayload;
618
619
620 //Set the end time
622 packet->pstruNetworkData->nNetworkProtocol = DEVICE_INTERFACE(d, i)->nProtocolId;
623 packet->nTransmitterId = d;
624 packet->nReceiverId = n;
625
626 if (DEVICE_INTERFACE(d, i)->nLocalNetworkProtocol == PROTOCOL_VPN)
628
629 if (pstruEventDetails->pPacket == NULL)
630 return;
631
632 //Increment the count
633 ipMetrics[d - 1]->nPacketSent++;
634
636
637 if (!DEVICE_INTERFACE(d, i)->nLocalNetworkProtocol)
638 {
640 NETSIM_IPAddress szDestIPaddr = packet->pstruNetworkData->szNextHopIp;
641 if (isBroadcastIP(szDestIPaddr))
643 else if (isMulticastIP(szDestIPaddr))
644 packet->pstruMacData->szDestMac = multicastIP_to_Mac(szDestIPaddr);
645 else
647 }
648
649 IP_DEVVAR* ipVar = GET_IP_DEVVAR(d);
650 memset(&pevent, 0, sizeof pevent);
652 pevent.dPacketSize = packet->pstruNetworkData->dPacketSize;
653 if (packet->pstruAppData)
654 {
656 pevent.nSegmentId = packet->pstruAppData->nSegmentId;
657 }
658 pevent.nDeviceId = d;
659 pevent.nDeviceType = DEVICE_TYPE(d);
660 pevent.nEventType = TIMER_EVENT;
661 pevent.nInterfaceId = i;
662 pevent.nPacketId = packet->nPacketId;
665 pevent.pPacket = packet;
666 fnpAddEvent(&pevent);
667
668}
unsigned int NETSIM_ID
Definition: Animation.h:45
@ ACLACTION_DENY
Definition: Firewall.h:34
@ ACLTYPE_OUTBOUND
Definition: Firewall.h:28
void ip_write_to_pcap(NetSim_PACKET *packet, NETSIM_ID d, NETSIM_ID i, double time)
Definition: IP.c:1476
int ICMP_CHECKSTATE(NETSIM_IPAddress ip)
#define IPV4_HEADER_SIZE
Definition: IP.h:45
ptrIP_ROUTINGTABLE iptable_check(ptrIP_ROUTINGTABLE *table, NETSIM_IPAddress dest, NETSIM_IPAddress subnet)
#define GET_IP_DEVVAR(d)
Definition: IP.h:49
#define PROTOCOL_VPN
Definition: IP.h:46
ptrIP_ROUTINGTABLE iptable_add(ptrIP_WRAPPER wrapper, NETSIM_IPAddress dest, NETSIM_IPAddress subnet, unsigned int prefix_len, NETSIM_IPAddress gateway, UINT interfaceCount, NETSIM_IPAddress *interfaceIp, NETSIM_ID *interfaceId, unsigned int metric, char *type)
@ EVENT_IP_PROCESSING_DELAY
Definition: IP.h:117
struct stru_IP_Metrics ** ipMetrics
Definition: IP.h:291
bool isCorrectRoute(pptrIP_ROUTINGTABLE table, NETSIM_IPAddress dest, NETSIM_IPAddress src)
struct ForwardRoute * ptrIP_FORWARD_ROUTE
@ RoutingType_STATIC
Definition: IP.h:57
int fn_NetSim_IP_VPN_Run()
Definition: VPN.c:212
bool is_reserved_multicast_address(NETSIM_IPAddress ip)
void IP_TO_BINARY(NETSIM_IPAddress ip, char *binary)
bool isBroadcastIP(NETSIM_IPAddress ip)
NETSIM_IPAddress IP_NETWORK_ADDRESS(NETSIM_IPAddress ip, NETSIM_IPAddress subnet, unsigned int prefix_len)
#define IP_COMPARE(ip1, ip2)
Definition: IP_Addressing.h:67
#define STR_TO_IP4(ipstr)
Definition: IP_Addressing.h:94
int IP_IS_IN_SAME_NETWORK(NETSIM_IPAddress ip1, NETSIM_IPAddress ip2, NETSIM_IPAddress subnet, unsigned int prefix_len)
bool isMulticastIP(NETSIM_IPAddress ip)
void configure_static_ip_route(NETSIM_ID d, char *file)
Definition: IP_Routing.c:420
static void route_onlink(NETSIM_ID d, NETSIM_IPAddress src, NETSIM_IPAddress dest, ptrIP_FORWARD_ROUTE route)
Definition: IP_Routing.c:271
static ptrMATCH get_match_table(ptrIP_ROUTINGTABLE table, NETSIM_IPAddress dest, bool isStatic)
Definition: IP_Routing.c:111
static int match_check(ptrMATCH m1, ptrMATCH m2)
Definition: IP_Routing.c:78
static void update_route_entry(ptrMATCH match, ptrIP_FORWARD_ROUTE route, NETSIM_IPAddress dest)
Definition: IP_Routing.c:167
static void add_to_match_list(ptrMATCH *l, ptrMATCH c)
Definition: IP_Routing.c:90
ptrIP_FORWARD_ROUTE fn_NetSim_IP_RoutePacketViaStaticEntry(NetSim_PACKET *packet, NETSIM_ID dev)
Definition: IP_Routing.c:558
static void change_table(NETSIM_ID d, ptrIP_ROUTINGTABLE table, NETSIM_IPAddress gateway, NETSIM_ID in, UINT metric)
Definition: IP_Routing.c:382
static ptrIP_FORWARD_ROUTE route_multicast(NetSim_PACKET *packet, NETSIM_ID dev)
Definition: IP_Routing.c:343
ptrIP_FORWARD_ROUTE fn_NetSim_IP_RoutePacket(NetSim_PACKET *packet, NETSIM_ID dev)
Definition: IP_Routing.c:371
void free_ip_route(ptrIP_FORWARD_ROUTE route)
Definition: IP_Routing.c:157
static void free_match_table(ptrMATCH l)
Definition: IP_Routing.c:72
static ptrMATCH choose_match_for_reserved_address(ptrMATCH match, NETSIM_IPAddress dest, NETSIM_IPAddress src)
Definition: IP_Routing.c:204
struct stru_match * ptrMATCH
static UINT get_bit_match_count(NETSIM_IPAddress ip1)
Definition: IP_Routing.c:95
static void add_table(NETSIM_ID d, NETSIM_IPAddress dest, NETSIM_IPAddress mask, NETSIM_IPAddress gateway, NETSIM_ID in, UINT metric)
Definition: IP_Routing.c:412
static ptrIP_FORWARD_ROUTE route_unicast(NetSim_PACKET *packet, NETSIM_ID dev)
Definition: IP_Routing.c:318
static ptrIP_FORWARD_ROUTE static_route_unicast(NetSim_PACKET *packet, NETSIM_ID dev)
Definition: IP_Routing.c:505
#define MATCH_ALLOC()
Definition: IP_Routing.c:39
static bool check_my_ip(NETSIM_ID d, NETSIM_IPAddress ip)
Definition: IP_Routing.c:309
struct stru_match MATCH
#define display_error(error, line, file)
Definition: IP_Routing.c:418
static void multicast_update_route_entry(ptrMATCH match, ptrIP_FORWARD_ROUTE route, NETSIM_IPAddress dest, NETSIM_IPAddress src)
Definition: IP_Routing.c:221
static ptrIP_FORWARD_ROUTE static_route_multicast(NetSim_PACKET *packet, NETSIM_ID dev)
Definition: IP_Routing.c:530
static void print_match_table(ptrMATCH match, NETSIM_ID d, NETSIM_IPAddress dest, NETSIM_IPAddress src)
Definition: IP_Routing.c:41
void pass_to_lower_layer(NetSim_PACKET *packet, ptrIP_FORWARD_ROUTE route, UINT c)
Definition: IP_Routing.c:568
#define c
#define _stricmp
Definition: Linux.h:127
#define UINT
Definition: Linux.h:38
#define fnNetSimError(x,...)
Definition: Linux.h:56
static const char pathSeperator[5]
Definition: Linux.h:71
#define LIST_NEXT(ls)
Definition: List.h:29
#define LIST_ADD(ls, mem, checker)
Definition: List.h:33
#define LIST_FREE(ls, mem)
Definition: List.h:32
#define realloc(p, s)
Definition: Memory.h:32
#define free(p)
Definition: Memory.h:31
#define calloc(c, s)
Definition: Memory.h:29
char * find_word(char **s)
char * lskip(const char *s)
#define PIP_TABLE_GET(DeviceId)
Definition: Stack.h:803
#define DEVICE(DeviceId)
Definition: Stack.h:769
PNETSIM_MACADDRESS multicastIP_to_Mac(NETSIM_IPAddress multicastIP)
EXPORTED char * pszIOPath
Definition: Stack.h:842
EXPORTED PNETSIM_MACADDRESS BROADCAST_MAC
Definition: Stack.h:393
#define DEVICE_TYPE(DeviceId)
Definition: Stack.h:773
#define DEVICE_NWADDRESS(DeviceId, InterfaceId)
Definition: Stack.h:805
@ NW_PROTOCOL_IPV4
Definition: Stack.h:189
NETSIM_ID fn_NetSim_GetInterfaceIdByConfigId(NETSIM_ID devId, NETSIM_ID id)
NETSIM_IPAddress fn_NetSim_Stack_GetFirstIPAddressAsId(NETSIM_ID nDeviceId, unsigned int type)
PNETSIM_MACADDRESS fn_NetSim_Stack_GetMacAddressFromIP(const NETSIM_IPAddress szIPAddress)
NETSIM_ID fn_NetSim_Stack_GetInterfaceIdFromIP(NETSIM_ID nDeviceId, NETSIM_IPAddress ip)
@ TIMER_EVENT
Definition: Stack.h:114
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
#define DEVICE_INTERFACE(DeviceId, InterfaceId)
Definition: Stack.h:780
#define IP_WRAPPER_GET(DeviceId)
Definition: Stack.h:801
NETSIM_ID fn_NetSim_Stack_GetDeviceId_asIP(NETSIM_IPAddress ip, NETSIM_ID *nInterfaceId)
#define IP_TABLE_GET(DeviceId)
Definition: Stack.h:802
uint f(uint state, uchar key[])
Definition: des.c:172
ACL_ACTION fn_NetSim_NETWORK_Firewall(NETSIM_ID nDeviceId, NETSIM_ID interfaceId, NetSim_PACKET *packet, ACL_TYPE type)
Definition: firewall.c:333
#define fn_NetSim_Packet_FreePacket(pstruPacket)
Definition: main.h:177
#define fnpAddEvent(pstruEvent)
Definition: main.h:191
UINT count
Definition: IP.h:146
NETSIM_IPAddress * nextHop
Definition: IP.h:147
NETSIM_ID * nextHopId
Definition: IP.h:150
NETSIM_IPAddress * gateway
Definition: IP.h:148
NETSIM_ID * interfaceId
Definition: IP.h:149
Definition: List.h:43
Structure to store the device ip details.
Definition: IP.h:226
double processingDelay
Definition: IP.h:278
unsigned int nFirewallBlocked
Definition: IP.h:288
unsigned int nPacketSent
Definition: IP.h:284
NETSIM_ID nApplicationId
Definition: Stack.h:752
EVENT_TYPE nEventType
Definition: Stack.h:747
NETSIM_ID nProtocolId
Definition: Stack.h:748
struct stru_NetSim_Packet * pPacket
Definition: Stack.h:754
NETSIM_ID nSubEventType
Definition: Stack.h:757
NETSIM_ID nDeviceId
Definition: Stack.h:750
long long int nPacketId
Definition: Stack.h:755
netsimDEVICE_TYPE nDeviceType
Definition: Stack.h:749
NETSIM_ID nInterfaceId
Definition: Stack.h:751
Structure to store ip routing table.
Definition: IP.h:157
NETSIM_ID * nInterfaceId
Definition: IP.h:170
unsigned int prefix_len
Definition: IP.h:163
NETSIM_ID nGatewayId
Definition: IP.h:171
NETSIM_IPAddress * Interface
Definition: IP.h:162
NETSIM_IPAddress networkDestination
Definition: IP.h:158
NETSIM_IPAddress gateway
Definition: IP.h:160
ROUTING_TYPE type
Definition: IP.h:165
unsigned int Metric
Definition: IP.h:164
NETSIM_IPAddress netMask
Definition: IP.h:159
PNETSIM_MACADDRESS szDestMac
Definition: Packet.h:221
PNETSIM_MACADDRESS szSourceMac
Definition: Packet.h:220
NETSIM_IPAddress szGatewayIP
Definition: Packet.h:200
NETWORK_LAYER_PROTOCOL nNetworkProtocol
Definition: Packet.h:204
NETSIM_IPAddress szDestIP
Definition: Packet.h:199
NETSIM_IPAddress szNextHopIp
Definition: Packet.h:201
NETSIM_IPAddress szSourceIP
Definition: Packet.h:198
long long int nPacketId
Definition: Packet.h:256
struct stru_NetSim_Packet_AppLayer * pstruAppData
Definition: Packet.h:273
struct stru_NetSim_Packet_NetworkLayer * pstruNetworkData
Definition: Packet.h:275
NETSIM_ID nReceiverId
Definition: Packet.h:266
NETSIM_ID nTransmitterId
Definition: Packet.h:265
struct stru_NetSim_Packet_MACLayer * pstruMacData
Definition: Packet.h:276
char str_ip[_NETSIM_IP_LEN]
Definition: IP_Addressing.h:54
ptrIP_ROUTINGTABLE table
Definition: IP_Routing.c:34
_ele * ele
Definition: IP_Routing.c:37
UINT bitsCount
Definition: IP_Routing.c:35
UINT metric
Definition: IP_Routing.c:36