mikroSDK Reference Manual
igmp_common.h
Go to the documentation of this file.
1
31#ifndef _IGMP_COMMON_H
32#define _IGMP_COMMON_H
33
34//Dependencies
35#include "core/net.h"
36
37//IGMP tick interval
38#ifndef IGMP_TICK_INTERVAL
39 #define IGMP_TICK_INTERVAL 1000
40#elif (IGMP_TICK_INTERVAL < 10)
41 #error IGMP_TICK_INTERVAL parameter is not valid
42#endif
43
44//Robustness Variable
45#ifndef IGMP_ROBUSTNESS_VARIABLE
46 #define IGMP_ROBUSTNESS_VARIABLE 2
47#elif (IGMP_ROBUSTNESS_VARIABLE < 1)
48 #error IGMP_ROBUSTNESS_VARIABLE parameter is not valid
49#endif
50
51//Query Interval
52#ifndef IGMP_QUERY_INTERVAL
53 #define IGMP_QUERY_INTERVAL 125000
54#elif (IGMP_QUERY_INTERVAL < 1000)
55 #error IGMP_QUERY_INTERVAL parameter is not valid
56#endif
57
58//Query Response Interval
59#ifndef IGMP_QUERY_RESPONSE_INTERVAL
60 #define IGMP_QUERY_RESPONSE_INTERVAL 10000
61#elif (IGMP_QUERY_RESPONSE_INTERVAL < 1000 || IGMP_QUERY_RESPONSE_INTERVAL > IGMP_QUERY_INTERVAL)
62 #error IGMP_QUERY_RESPONSE_INTERVAL parameter is not valid
63#endif
64
65//Group Membership Interval
66#define IGMP_GROUP_MEMBERSHIP_INTERVAL ((IGMP_ROBUSTNESS_VARIABLE * \
67 IGMP_QUERY_INTERVAL) + IGMP_QUERY_RESPONSE_INTERVAL)
68
69//Other Querier Present Interval
70#define IGMP_OTHER_QUERIER_PRESENT_INTERVAL ((IGMP_ROBUSTNESS_VARIABLE * \
71 IGMP_QUERY_INTERVAL) + (IGMP_QUERY_RESPONSE_INTERVAL / 2))
72
73//Startup Query Interval
74#ifndef IGMP_STARTUP_QUERY_INTERVAL
75 #define IGMP_STARTUP_QUERY_INTERVAL (IGMP_QUERY_INTERVAL / 4)
76#elif (IGMP_STARTUP_QUERY_INTERVAL < 1000)
77 #error IGMP_STARTUP_QUERY_INTERVAL parameter is not valid
78#endif
79
80//Startup Query Count
81#ifndef IGMP_STARTUP_QUERY_COUNT
82 #define IGMP_STARTUP_QUERY_COUNT IGMP_ROBUSTNESS_VARIABLE
83#elif (IGMP_STARTUP_QUERY_COUNT < 1)
84 #error IGMP_STARTUP_QUERY_COUNT parameter is not valid
85#endif
86
87//Last Member Query Interval
88#ifndef IGMP_LAST_MEMBER_QUERY_INTERVAL
89 #define IGMP_LAST_MEMBER_QUERY_INTERVAL 1000
90#elif (IGMP_LAST_MEMBER_QUERY_INTERVAL < 100)
91 #error IGMP_LAST_MEMBER_QUERY_INTERVAL parameter is not valid
92#endif
93
94//Last Member Query Count
95#ifndef IGMP_LAST_MEMBER_QUERY_COUNT
96 #define IGMP_LAST_MEMBER_QUERY_COUNT IGMP_ROBUSTNESS_VARIABLE
97#elif (IGMP_LAST_MEMBER_QUERY_COUNT < 1)
98 #error IGMP_LAST_MEMBER_QUERY_COUNT parameter is not valid
99#endif
100
101//Last Member Query Time
102#define IGMP_LAST_MEMBER_QUERY_TIME (IGMP_LAST_MEMBER_QUERY_COUNT * \
103 IGMP_LAST_MEMBER_QUERY_INTERVAL)
104
105//Unsolicited Report Interval
106#ifndef IGMP_UNSOLICITED_REPORT_INTERVAL
107 #define IGMP_UNSOLICITED_REPORT_INTERVAL 10000
108#elif (IGMP_UNSOLICITED_REPORT_INTERVAL < 1000)
109 #error IGMP_UNSOLICITED_REPORT_INTERVAL parameter is not valid
110#endif
111
112//Version 1 Router Present Timeout
113#ifndef IGMP_V1_ROUTER_PRESENT_TIMEOUT
114 #define IGMP_V1_ROUTER_PRESENT_TIMEOUT 400000
115#elif (IGMP_V1_ROUTER_PRESENT_TIMEOUT < 1000)
116 #error IGMP_V1_ROUTER_PRESENT_TIMEOUT parameter is not valid
117#endif
118
119//Maximum response time for IGMPv1 queries
120#ifndef IGMP_V1_MAX_RESPONSE_TIME
121 #define IGMP_V1_MAX_RESPONSE_TIME 10000
122#elif (IGMP_V1_MAX_RESPONSE_TIME < 1000)
123 #error IGMP_V1_MAX_RESPONSE_TIME parameter is not valid
124#endif
125
126//TTL used by IGMP messages
127#define IGMP_TTL 1
128
129//All-Systems address
130#define IGMP_ALL_SYSTEMS_ADDR IPV4_ADDR(224, 0, 0, 1)
131//All-Routers address
132#define IGMP_ALL_ROUTERS_ADDR IPV4_ADDR(224, 0, 0, 2)
133
134//C++ guard
135#ifdef __cplusplus
136extern "C" {
137#endif
138
139
144typedef enum
145{
146 IGMP_TYPE_MEMBERSHIP_QUERY = 0x11,
147 IGMP_TYPE_MEMBERSHIP_REPORT_V1 = 0x12,
148 IGMP_TYPE_MEMBERSHIP_REPORT_V2 = 0x16,
149 IGMP_TYPE_LEAVE_GROUP = 0x17,
150 IGMP_TYPE_MEMBERSHIP_REPORT_V3 = 0x22
151} IgmpType;
152
153
154//CodeWarrior or Win32 compiler?
155#if defined(__CWCC__) || defined(_WIN32)
156 #pragma pack(push, 1)
157#endif
158
159
165{
166 uint8_t type; //0
167 uint8_t maxRespTime; //1
168 uint16_t checksum; //2-3
169 Ipv4Addr groupAddr; //4-7
170} IgmpMessage;
171
172
173//CodeWarrior or Win32 compiler?
174#if defined(__CWCC__) || defined(_WIN32)
175 #pragma pack(pop)
176#endif
177
178//Tick counter to handle periodic operations
179extern systime_t igmpTickCounter;
180
181//IGMP related functions
182error_t igmpInit(NetInterface *interface);
183void igmpTick(NetInterface *interface);
184void igmpLinkChangeEvent(NetInterface *interface);
185
186error_t igmpSendMessage(NetInterface *interface, Ipv4Addr destAddr,
187 const IgmpMessage *message, size_t length);
188
189void igmpProcessMessage(NetInterface *interface,
190 const Ipv4PseudoHeader *pseudoHeader, const NetBuffer *buffer,
191 size_t offset, const NetRxAncillary *ancillary);
192
193void igmpDumpMessage(const IgmpMessage *message);
194
195//C++ guard
196#ifdef __cplusplus
197}
198#endif
199
200#endif
error_t
Error codes.
Definition error.h:43
IgmpType
IGMP message type.
Definition igmp_common.h:145
typedef __packed_struct
General IGMP message format.
Definition igmp_common.h:165
uint32_t Ipv4Addr
IPv4 network address.
Definition ipv4.h:267
TCP/IP stack core.
uint32_t systime_t
System time.
Definition os_port_none.h:90
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89