1 /* $OpenBSD: igmp.h,v 1.2 2009/03/06 18:39:13 michele Exp $ */ 2 3 /* 4 * Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /* IGMP protocol definitions */ 20 21 #ifndef _IGMP_H_ 22 #define _IGMP_H_ 23 24 /* misc */ 25 #define AllSystems "224.0.0.1" 26 #define AllRouters "224.0.0.2" 27 #define AllIGMPv3Routers "224.0.0.22" 28 29 #define DEFAULT_ROBUSTNESS 2 30 #define MIN_ROBUSTNESS 1 31 #define MAX_ROBUSTNESS 4 32 33 #define DEFAULT_QUERY_INTERVAL 125 34 #define MIN_QUERY_INTERVAL 1 35 #define MAX_QUERY_INTERVAL 65535 36 37 /* must be less than QUERY_INTERVAL */ 38 #define DEFAULT_QUERY_RESP_INTERVAL 100 /* 10 seconds */ 39 #define MIN_QUERY_RESP_INTERVAL 1 40 #define MAX_QUERY_RESP_INTERVAL 65535 41 42 #define DEFAULT_STARTUP_QUERY_INTERVAL DEFAULT_QUERY_INTERVAL / 4 43 #define MIN_STARTUP_QUERY_INTERVAL MIN_QUERY_INTERVAL 44 #define MAX_STARTUP_QUERY_INTERVAL MAX_QUERY_INTERVAL 45 46 #define DEFAULT_STARTUP_QUERY_CNT DEFAULT_ROBUSTNESS 47 #define MIN_STARTUP_QUERY_CNT MIN_ROBUSTNESS /* XXX */ 48 #define MAX_STARTUP_QUERY_CNT MAX_ROBUSTNESS /* XXX */ 49 50 #define DEFAULT_LAST_MEMBER_QUERY_INTERVAL 10 /* 1 second */ 51 #define MIN_LAST_MEMBER_QUERY_INTERVAL 1 52 #define MAX_LAST_MEMBER_QUERY_INTERVAL 65535 53 54 #define DEFAULT_LAST_MEMBER_QUERY_CNT DEFAULT_ROBUSTNESS 55 #define MIN_LAST_MEMBER_QUERY_CNT 1 56 #define MAX_LAST_MEMBER_QUERY_CNT 255 57 58 /* IGMP packet types */ 59 #define PKT_TYPE_MEMBER_QUERY 0x11 60 #define PKT_TYPE_MEMBER_REPORTv1 0x12 61 #define PKT_TYPE_MEMBER_REPORTv2 0x16 62 #define PKT_TYPE_LEAVE_GROUPv2 0x17 63 #define PKT_TYPE_MEMBER_REPORTv3 0x22 64 65 #define DEFAULT_IGMP_VERSION 2 66 #define MIN_IGMP_VERSION 1 67 #define MAX_IGMP_VERSION 2 68 69 /* IGMP header */ 70 struct igmp_hdr { 71 u_int8_t type; 72 u_int8_t max_resp_time; 73 u_int16_t chksum; 74 u_int32_t grp_addr; 75 }; 76 77 /* group states */ 78 #define GRP_STA_NO_MEMB_PRSNT 0x01 79 #define GRP_STA_MEMB_PRSNT 0x02 80 #define GRP_STA_V1_MEMB_PRSNT 0x04 81 #define GRP_STA_CHECK_MEMB 0x08 82 #define GRP_STA_ANY 0x0e 83 84 /* group events */ 85 enum group_event { 86 GRP_EVT_V2_REPORT_RCVD, 87 GRP_EVT_V1_REPORT_RCVD, 88 GRP_EVT_LEAVE_RCVD, 89 GRP_EVT_TMR_EXPIRED, 90 GRP_EVT_RETRANS_TMR_EXP, 91 GRP_EVT_V1_HOST_TMR_EXP, 92 GRP_EVT_REPORT_RCVD, 93 GRP_EVT_QUERY_RCVD, 94 GRP_EVT_NOTHING 95 }; 96 97 /* group actions */ 98 enum group_action { 99 GRP_ACT_END, 100 GRP_ACT_START_TMR, 101 GRP_ACT_START_TMR_ALL, 102 GRP_ACT_START_RETRANS_TMR, 103 GRP_ACT_START_V1_HOST_TMR, 104 GRP_ACT_SEND_GRP_QUERY, 105 GRP_ACT_ADD_GROUP, 106 GRP_ACT_DEL_GROUP, 107 GRP_ACT_CLR_RETRANS_TMR, 108 GRP_ACT_NOTHING 109 }; 110 111 #endif /* _IGMP_H_ */ 112