NetSim Source Code Help
Loading...
Searching...
No Matches
IGMP.h
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2020 *
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/*
15Updated by: 3376 PROPOSED STANDARD
16Errata Exist
17Network Working Group W. Fenner
18Request for Comments: 2236 Xerox PARC
19Updates: 1112 November 1997
20Category: Standards Track
21
22
23Internet Group Management Protocol, Version 2
24*/
25#pragma once
26
27#ifndef _NETSIM_IGMP_H_
28#define _NETSIM_IGMP_H_
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33//SECTION 8:List of timers and default values
34#define IGMP_ROBUSTNESS_VARIABLE_DEFAULT 2
35#define IGMP_QUERY_INTERVAL_DEFAULT 125 // 1/10 sec
36#define IGMP_QUERY_RESPONSE_INTERVAL_DEFAULT 100 // 1/10sec
37#define IGMP_GROUP_MEMBERSHIP_INTERVAL_DEFAULT IGMP_ROBUSTNESS_VARIABLE_DEFAULT*IGMP_QUERY_INTERVAL_DEFAULT +\
38 (IGMP_QUERY_RESPONSE_INTERVAL_DEFAULT)
39#define IGMP_QUERIER_PRESENT_INTERVAL_DEFAULT IGMP_ROBUSTNESS_VARIABLE_DEFAULT*IGMP_QUERY_INTERVAL_DEFAULT +\
40 (1/2.0*IGMP_QUERY_RESPONSE_INTERVAL_DEFAULT)
41#define IGMP_STARTUP_QUERY_INTERVAL_DEFAULT (1/4.0*IGMP_QUERY_INTERVAL_DEFAULT)
42#define IGMP_STARTUP_QUERY_COUNT_DEFAULT IGMP_ROBUSTNESS_VARIABLE_DEFAULT
43#define IGMP_LAST_MEMBER_QUERY_INTERVAL_DEFAULT 10
44#define IGMP_LAST_MEMBER_QUERY_COUNT_DEFAULT IGMP_ROBUSTNESS_VARIABLE_DEFAULT
45#define IGMP_UNSOLICITED_REPORT_INTERVAL_DEFAULT (10) //Second
46
47#define IGMP_STARTUP_DELAY 1*MILLISECOND
48
49#define isBroadcastInterface(d,i) (DEVICE_INTERFACE(d,i)->nInterfaceType != INTERFACE_WAN_ROUTER)
50
51 typedef enum
52 {
55 }DEV_TYPE;
56
57 typedef enum
58 {
64#define isIGMPPacket(packet) (packet->nControlDataType / 100 == NW_PROTOCOL_IPV4 && packet->nControlDataType % 100 >= 30 && packet->nControlDataType % 100 < 40)
65
66 /*
67 0 1 2 3
68 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
69 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70 | Type | Max Resp Time | Checksum |
71 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72 | Group Address |
73 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74 */
75 typedef struct stru_igmp_msg
76 {
82#define IGMP_HDR_SIZE 8 //Bytes
83
84 typedef enum
85 {
90
91 typedef struct stru_host_database
92 {
97 double delayTime;
102#define IGMP_HOST_DB_ALLOC() (ptrIGMP_HOST_DB)list_alloc(sizeof(IGMP_HOST_DB),offsetof(IGMP_HOST_DB,ele))
103#define IGMP_HOST_DB_ADD(d,db) LIST_ADD_LAST((void**)&GET_IGMP_HOST(d)->database,db)
104
105 typedef struct stru_igmp_host
106 {
109
110 typedef enum
111 {
115
116 typedef struct stru_router_database
117 {
120
123
125
128
134#define IGMP_ROUTER_DB_ALLOC() (ptrIGMP_ROUTER_DB)list_alloc(sizeof(IGMP_ROUTER_DB),offsetof(IGMP_ROUTER_DB,ele))
135#define IGMP_ROUTER_DB_ADD(d,db) LIST_ADD_LAST((void**)&GET_IGMP_ROUTER(d)->database,db)
136
137 typedef struct stru_igmp_router
138 {
142
143 typedef struct stru_igmpvar
144 {
146 union
147 {
151
152 //Config parameter for host only
154
155 //Config parameter for router only
159
160 //Config parameter
167
168
170#define GET_IGMP_VAR(d) ((ptrIGMP_VAR)GET_IP_DEVVAR(d)->igmp)
171#define SET_IGMP_VAR(d,var) (GET_IP_DEVVAR(d)->igmp = (void*)var)
172#define isIPHOST(d) (GET_IGMP_VAR(d)->devType == IP_HOST)
173#define isIPRouter(d) (GET_IGMP_VAR(d)->devType == IP_ROUTER)
174#define GET_IGMP_HOST(d) ((ptrIGMP_HOST)(GET_IGMP_VAR(d)->DEV.host))
175#define GET_IGMP_ROUTER(d) ((ptrIGMP_ROUTER)(GET_IGMP_VAR(d)->DEV.router))
176#define SET_IGMP_HOST(d,var) (GET_IGMP_VAR(d)->DEV.host = var)
177#define SET_IGMP_ROUTER(d,var) (GET_IGMP_VAR(d)->DEV.router = var)
178
179 //Function used by IGMP module only
180 //IGMP Router
183 NETSIM_ID d,
184 bool* isAlreadyJoined);
188 ptrIGMP_MSG msg,
189 NETSIM_ID d);
191 void router_free(NETSIM_ID d);
192
193
194 //IGMP Host
198 ptrIGMP_MSG msg,
199 NETSIM_ID d);
201 ptrIGMP_MSG msg,
202 NETSIM_ID d);
203 void host_free(NETSIM_ID d);
204
205 //IGMP MSG
207
208 //IGMP
209 void print_igmp_log(char* format, ...);
211 IP_SUBEVENT sev,
212 NETSIM_IPAddress addr,
213 double time);
214
215#ifdef __cplusplus
216}
217#endif
218#endif
219
unsigned int NETSIM_ID
Definition: Animation.h:45
GROUP_MOBILITY * group
Definition: GroupMobility.c:30
bool router_process_report(NetSim_PACKET *packet, ptrIGMP_MSG msg, NETSIM_ID d)
Definition: IGMP_Router.c:274
IGMP_ROUTER_STATE
Definition: IGMP.h:111
@ RouterState_Querier
Definition: IGMP.h:112
@ RouterState_NonQuerier
Definition: IGMP.h:113
struct stru_igmpvar IGMP_VAR
ptrIGMP_ROUTER_DB find_or_alloc_multicast_db_router(NETSIM_IPAddress addr, NETSIM_ID d, bool *isAlreadyJoined)
Definition: IGMP_Router.c:20
IGMP_HOST_STATE
Definition: IGMP.h:85
@ HostState_NonMember
Definition: IGMP.h:86
@ HostState_IdleMember
Definition: IGMP.h:87
@ HostState_DelayingMember
Definition: IGMP.h:88
struct stru_router_database IGMP_ROUTER_DB
void igmp_start_timer(NETSIM_ID d, IP_SUBEVENT sev, NETSIM_IPAddress addr, double time)
Definition: IGMP.c:123
struct stru_igmp_router IGMP_ROUTER
ptrIGMP_ROUTER_DB router_get_multicast_db(NETSIM_ID d, NETSIM_IPAddress ip)
Definition: IGMP_Router.c:59
bool router_process_query(NetSim_PACKET *packet, ptrIGMP_MSG msg, NETSIM_ID d)
Definition: IGMP_Router.c:200
DEV_TYPE
Definition: IGMP.h:52
@ IP_HOST
Definition: IGMP.h:53
@ IP_ROUTER
Definition: IGMP.h:54
bool host_process_report(NetSim_PACKET *packet, ptrIGMP_MSG msg, NETSIM_ID d)
Definition: IGMP_Host.c:140
void router_free(NETSIM_ID d)
Definition: IGMP_Router.c:341
struct stru_igmp_router * ptrIGMP_ROUTER
bool host_process_query(NetSim_PACKET *packet, ptrIGMP_MSG msg, NETSIM_ID d)
Definition: IGMP_Host.c:82
void send_membership_report(NETSIM_ID d, NETSIM_IPAddress group)
Definition: IGMP_Msg.c:152
struct stru_igmp_msg IGMP_MSG
void igmp_host_init(NETSIM_ID d)
Definition: IGMP_Host.c:58
void print_igmp_log(char *format,...)
Definition: IGMP.c:33
struct stru_host_database IGMP_HOST_DB
struct stru_igmp_host IGMP_HOST
void igmp_router_init(NETSIM_ID d)
Definition: IGMP_Router.c:158
void host_free(NETSIM_ID d)
Definition: IGMP_Host.c:205
struct stru_host_database * ptrIGMP_HOST_DB
struct stru_igmp_msg * ptrIGMP_MSG
struct stru_igmpvar * ptrIGMP_VAR
struct stru_router_database * ptrIGMP_ROUTER_DB
ptrIGMP_HOST_DB host_get_multicast_db(NETSIM_ID d, NETSIM_IPAddress addr)
Definition: IGMP_Host.c:45
IGMPMSG_TYPE
Definition: IGMP.h:58
@ IGMPMSG_MembershipQuery
Definition: IGMP.h:59
@ IGMPMSG_LeaveGroup
Definition: IGMP.h:61
@ IGMPMSG_V1MembershipReport
Definition: IGMP.h:62
@ IGMPMSG_V2MembershipReport
Definition: IGMP.h:60
struct stru_igmp_host * ptrIGMP_HOST
IP_SUBEVENT
Enumeration for ip sub-events.
Definition: IP.h:92
#define UINT
Definition: Linux.h:38
#define UINT16
Definition: Linux.h:33
#define UINT8
Definition: Linux.h:31
Definition: List.h:43
_ele * ele
Definition: IGMP.h:100
UINT8 maxResponseTime
Definition: IGMP.h:95
double queryRecvTime
Definition: IGMP.h:96
NETSIM_IPAddress group
Definition: IGMP.h:93
double delayTime
Definition: IGMP.h:97
bool isReportreqd
Definition: IGMP.h:98
UINT reportSentCount
Definition: IGMP.h:99
IGMP_HOST_STATE state
Definition: IGMP.h:94
ptrIGMP_HOST_DB database
Definition: IGMP.h:107
IGMPMSG_TYPE Type
Definition: IGMP.h:77
UINT16 Checksum
Definition: IGMP.h:79
UINT8 MaxRespTime
Definition: IGMP.h:78
NETSIM_IPAddress GroupAddress
Definition: IGMP.h:80
UINT startup_query_sent_count
Definition: IGMP.h:139
ptrIGMP_ROUTER_DB database
Definition: IGMP.h:140
DEV_TYPE devType
Definition: IGMP.h:145
union stru_igmpvar::@10 DEV
double GroupMembershipInterval
Definition: IGMP.h:163
UINT RobustnessVar
Definition: IGMP.h:162
UINT QueryResponseInterval
Definition: IGMP.h:156
ptrIGMP_ROUTER router
Definition: IGMP.h:148
UINT lastMemQueryCount
Definition: IGMP.h:166
UINT QueryPresentInterval
Definition: IGMP.h:164
double UnsolicitedReportInterval
Definition: IGMP.h:153
UINT StartupQueryInterval
Definition: IGMP.h:157
UINT QueryInterval
Definition: IGMP.h:161
UINT StartupQueryCount
Definition: IGMP.h:158
ptrIGMP_HOST host
Definition: IGMP.h:149
double lastMemQueryInterval
Definition: IGMP.h:165
IGMP_ROUTER_STATE state
Definition: IGMP.h:119
double otherQuerierPresentTime
Definition: IGMP.h:122
bool isRouteAlreadyAdded
Definition: IGMP.h:129
bool isGroupMembershipTimerStarted
Definition: IGMP.h:126
double reportRcvTime
Definition: IGMP.h:127
NETSIM_ID * ifids
Definition: IGMP.h:130
bool isOtherquerierTimerStarted
Definition: IGMP.h:121
NETSIM_IPAddress group
Definition: IGMP.h:118