Webserver+3d print
Embed:
(wiki syntax)
Show/hide line numbers
igmp.h
Go to the documentation of this file.
00001 /** 00002 * @file igmp.h 00003 * @brief IGMP (Internet Group Management Protocol) 00004 * 00005 * @section License 00006 * 00007 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. 00008 * 00009 * This file is part of CycloneTCP Open. 00010 * 00011 * This program is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU General Public License 00013 * as published by the Free Software Foundation; either version 2 00014 * of the License, or (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software Foundation, 00023 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00024 * 00025 * @author Oryx Embedded SARL (www.oryx-embedded.com) 00026 * @version 1.7.6 00027 **/ 00028 00029 #ifndef _IGMP_H 00030 #define _IGMP_H 00031 00032 //Dependencies 00033 #include "core/net.h" 00034 00035 //IGMP support 00036 #ifndef IGMP_SUPPORT 00037 #define IGMP_SUPPORT DISABLED 00038 #elif (IGMP_SUPPORT != ENABLED && IGMP_SUPPORT != DISABLED) 00039 #error IGMP_SUPPORT parameter is not valid 00040 #endif 00041 00042 //IGMP tick interval 00043 #ifndef IGMP_TICK_INTERVAL 00044 #define IGMP_TICK_INTERVAL 1000 00045 #elif (IGMP_TICK_INTERVAL < 10) 00046 #error IGMP_TICK_INTERVAL parameter is not valid 00047 #endif 00048 00049 //Unsolicited report interval 00050 #ifndef IGMP_UNSOLICITED_REPORT_INTERVAL 00051 #define IGMP_UNSOLICITED_REPORT_INTERVAL 10000 00052 #elif (IGMP_UNSOLICITED_REPORT_INTERVAL < 1000) 00053 #error IGMP_UNSOLICITED_REPORT_INTERVAL parameter is not valid 00054 #endif 00055 00056 //Maximum response time for IGMPv1 queries 00057 #ifndef IGMP_V1_MAX_RESPONSE_TIME 00058 #define IGMP_V1_MAX_RESPONSE_TIME 10000 00059 #elif (IGMP_V1_MAX_RESPONSE_TIME < 1000) 00060 #error IGMP_V1_MAX_RESPONSE_TIME parameter is not valid 00061 #endif 00062 00063 //Older version querier present timeout 00064 #ifndef IGMP_V1_ROUTER_PRESENT_TIMEOUT 00065 #define IGMP_V1_ROUTER_PRESENT_TIMEOUT 400000 00066 #elif (IGMP_V1_ROUTER_PRESENT_TIMEOUT < 1000) 00067 #error IGMP_V1_ROUTER_PRESENT_TIMEOUT parameter is not valid 00068 #endif 00069 00070 //TTL used by IGMP messages 00071 #define IGMP_TTL 1 00072 00073 //All-Systems address 00074 #define IGMP_ALL_SYSTEMS_ADDR IPV4_ADDR(224, 0, 0, 1) 00075 //All-Routers address 00076 #define IGMP_ALL_ROUTERS_ADDR IPV4_ADDR(224, 0, 0, 2) 00077 00078 00079 /** 00080 * @brief IGMP host states 00081 **/ 00082 00083 typedef enum 00084 { 00085 IGMP_STATE_NON_MEMBER = 0, 00086 IGMP_STATE_DELAYING_MEMBER = 1, 00087 IGMP_STATE_IDLE_MEMBER = 2 00088 } IgmpState; 00089 00090 00091 /** 00092 * @brief IGMP message type 00093 **/ 00094 00095 typedef enum 00096 { 00097 IGMP_TYPE_MEMBERSHIP_QUERY = 0x11, 00098 IGMP_TYPE_MEMBERSHIP_REPORT_V1 = 0x12, 00099 IGMP_TYPE_MEMBERSHIP_REPORT_V2 = 0x16, 00100 IGMP_TYPE_LEAVE_GROUP = 0x17, 00101 IGMP_TYPE_MEMBERSHIP_REPORT_V3 = 0x22 00102 } IgmpType; 00103 00104 00105 //CodeWarrior or Win32 compiler? 00106 #if defined(__CWCC__) || defined(_WIN32) 00107 #pragma pack(push, 1) 00108 #endif 00109 00110 00111 /** 00112 * @brief General IGMP message format 00113 **/ 00114 00115 typedef __start_packed struct 00116 { 00117 uint8_t type; //0 00118 uint8_t maxRespTime; //1 00119 uint16_t checksum; //2-3 00120 Ipv4Addr groupAddr; //4-7 00121 } __end_packed IgmpMessage; 00122 00123 00124 //CodeWarrior or Win32 compiler? 00125 #if defined(__CWCC__) || defined(_WIN32) 00126 #pragma pack(pop) 00127 #endif 00128 00129 00130 //Tick counter to handle periodic operations 00131 extern systime_t igmpTickCounter; 00132 00133 //IGMP related functions 00134 error_t igmpInit(NetInterface *interface); 00135 error_t igmpJoinGroup(NetInterface *interface, Ipv4FilterEntry *entry); 00136 error_t igmpLeaveGroup(NetInterface *interface, Ipv4FilterEntry *entry); 00137 00138 void igmpTick(NetInterface *interface); 00139 void igmpLinkChangeEvent(NetInterface *interface); 00140 00141 void igmpProcessMessage(NetInterface *interface, 00142 const NetBuffer *buffer, size_t offset); 00143 00144 void igmpProcessQueryMessage(NetInterface *interface, 00145 const IgmpMessage *message, size_t length); 00146 00147 void igmpProcessReportMessage(NetInterface *interface, 00148 const IgmpMessage *message, size_t length); 00149 00150 error_t igmpSendReportMessage(NetInterface *interface, Ipv4Addr ipAddr); 00151 error_t igmpSendLeaveGroupMessage(NetInterface *interface, Ipv4Addr ipAddr); 00152 00153 uint32_t igmpRand(uint32_t max); 00154 00155 void igmpDumpMessage(const IgmpMessage *message); 00156 00157 #endif 00158
Generated on Tue Jul 12 2022 17:10:13 by
