NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
IERP.h
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
15
16/************************************************************************************
17https://tools.ietf.org/html/draft-ietf-manet-zone-ierp-02
18************************************************************************************/
19#pragma once
20#ifndef _NETSIM_IERP_H_
21#define _NETSIM_IERP_H_
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#define IERP_ROUTE_REQUEST_SIZE_FIXED 16 //Bytes
27#define IERP_ROUTE_REPLY_SIZE_FIXED 16 //Bytes
28
29//Typedefs struct
30 typedef struct stru_IERP NODE_IERP;
31 typedef struct stru_IERP_Packet IERP_PACKET;
32 typedef struct stru_IERP_RoutingTable IERP_ROUTE_TABLE;
33
34#define NW_PROTOCOL_IERP NW_PROTOCOL_ZRP
35
36 /*
37 A. Packet Format
38 1 2 3
39 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
40 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 | Type | Length | Node Ptr | RESERVED |
42 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 | Query ID | R E S E R V E D |
44 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 | Query/Route Source Address |
46 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+-
47 | Intermediate Node (1) Address | |
48 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
49 | Intermediate Node (2) Address | |
50 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
51 | | |
52 | | route
53 \| |/ |
54 \ / |
55 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-| |
56 | Intermediate Node (N) Address | |
57 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
58 | Query/Route Destination Address | |
59 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+-
60*/
61#define ROUTE_REQUEST 1
62#define ROUTE_REPLY 2
63#define IERP_PACKET_LENGTH(size) size*8/32
65 {
66 unsigned char Type;
67 unsigned char Length;
68 unsigned char NodePtr;
69 unsigned char RESERVED;
70 unsigned short int QueryID;
71 unsigned short int RESERVED1;
72 NETSIM_IPAddress RouteSourceAddress;
73 unsigned int IntermediateNodeCount;
74 NETSIM_IPAddress* IntermediateNodeAddress;
75 NETSIM_IPAddress RouteDestinationAddress;
76 };
77
78/*
79 B.2 IERP Routing Table
80
81 +-----------------------|--------------------------------+
82 | Dest | Subnet | Route | Route |
83 | Addr | Mask | | Metrics |
84 | (node_id) | (node_id) | (node_id list) | (metric list) |
85 |-----------+-----------|----------------+---------------|
86 | | | | |
87 |-----------+-----------|----------------+---------------|
88 | | | | |
89 |-----------+-----------|----------------+---------------|
90 | | | | |
91 +-----------------------|--------------------------------+
92*/
94 {
95 NETSIM_IPAddress DestAddr;
96 NETSIM_IPAddress SubnetMask;
97 unsigned int count;
98 NETSIM_IPAddress* Route;
99 unsigned int* RouteMetrics;
100 bool flag;
101 _ele* ele;
102 };
103#define IERP_ROUTE_TABLE_ALLOC() (IERP_ROUTE_TABLE*)list_alloc(sizeof(IERP_ROUTE_TABLE),offsetof(IERP_ROUTE_TABLE,ele))
104
106 {
107 NetSim_PACKET* buffer; //List of packet thats need to be routed
108 IERP_ROUTE_TABLE* routeTable;
109 unsigned short int nQueryId;
110 };
111
112
113 int fn_NetSim_IERP_Init();
114 IERP_ROUTE_TABLE* checkDestInRouteTable(IERP_ROUTE_TABLE* table,NETSIM_IPAddress dest);
115 int flushIerpTable(NODE_IERP* ierp);
116 int addToIERPTableFromIARP(NODE_IERP* ierp, ptrIP_ROUTINGTABLE iarpTable);
117 int extractRouteFromreply(IERP_PACKET* reply);
118 int flushIERPTableFromIARP(NODE_IERP* ierp, ptrIP_ROUTINGTABLE iarpTable);
119 int fn_NetSim_IERP_CopyIerpHeader(const NetSim_PACKET* destPacket,const NetSim_PACKET* srcPacket);
120 int fn_NetSim_IERP_FreeIerpHeader(NetSim_PACKET* packet);
121 int fn_NetSim_IERP_GenerateRouteReply(NetSim_PACKET* requestPacket);
122 int fn_NetSim_IERP_GenerateRouteRequest(NODE_IERP* ierp,NetSim_PACKET* dataPacket);
123 bool fn_NetSim_IERP_ProcessPacket(NetSim_PACKET* packet);
124 int fn_NetSim_IERP_ProcessRouteReply();
125 int fn_NetSim_IERP_RoutePacket();
126 int routePacketFromBuffer();
127
128
129#ifdef __cplusplus
130}
131#endif
132#endif