mld6.h revision 191666
1191666Sbms/*- 2191666Sbms * Copyright (c) 2009 Bruce Simpson. 3191666Sbms * 4191666Sbms * Redistribution and use in source and binary forms, with or without 5191666Sbms * modification, are permitted provided that the following conditions 6191666Sbms * are met: 7191666Sbms * 1. Redistributions of source code must retain the above copyright 8191666Sbms * notice, this list of conditions and the following disclaimer. 9191666Sbms * 2. Redistributions in binary form must reproduce the above copyright 10191666Sbms * notice, this list of conditions and the following disclaimer in the 11191666Sbms * documentation and/or other materials provided with the distribution. 12191666Sbms * 3. The name of the author may not be used to endorse or promote 13191666Sbms * products derived from this software without specific prior written 14191666Sbms * permission. 15191666Sbms * 16191666Sbms * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17191666Sbms * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18191666Sbms * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19191666Sbms * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20191666Sbms * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21191666Sbms * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22191666Sbms * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23191666Sbms * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24191666Sbms * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25191666Sbms * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26191666Sbms * SUCH DAMAGE. 27191666Sbms * 28191666Sbms * $FreeBSD: head/sys/netinet6/mld6.h 191666 2009-04-29 11:31:23Z bms $ 29191666Sbms */ 30191666Sbms 31191666Sbms#ifndef _NETINET6_MLD6_H_ 32191666Sbms#define _NETINET6_MLD6_H_ 33191666Sbms 34191666Sbms/* 35191666Sbms * Multicast Listener Discovery (MLD) definitions. 36191666Sbms */ 37191666Sbms 38191666Sbms/* Minimum length of any MLD protocol message. */ 39191666Sbms#define MLD_MINLEN sizeof(struct icmp6_hdr) 40191666Sbms 41191666Sbms/* 42191666Sbms * MLD v2 query format. 43191666Sbms * See <netinet/icmp6.h> for struct mld_hdr 44191666Sbms * (MLDv1 query and host report format). 45191666Sbms */ 46191666Sbmsstruct mldv2_query { 47191666Sbms struct icmp6_hdr mld_icmp6_hdr; /* ICMPv6 header */ 48191666Sbms struct in6_addr mld_addr; /* address being queried */ 49191666Sbms uint8_t mld_misc; /* reserved/suppress/robustness */ 50191666Sbms uint8_t mld_qqi; /* querier's query interval */ 51191666Sbms uint16_t mld_numsrc; /* number of sources */ 52191666Sbms /* followed by 1..numsrc source addresses */ 53191666Sbms} __packed; 54191666Sbms#define MLD_V2_QUERY_MINLEN sizeof(struct mldv2_query) 55191666Sbms#define MLD_MRC_EXP(x) ((ntohs((x)) >> 12) & 0x0007) 56191666Sbms#define MLD_MRC_MANT(x) (ntohs((x)) & 0x0fff) 57191666Sbms#define MLD_QQIC_EXP(x) (((x) >> 4) & 0x07) 58191666Sbms#define MLD_QQIC_MANT(x) ((x) & 0x0f) 59191666Sbms#define MLD_QRESV(x) (((x) >> 4) & 0x0f) 60191666Sbms#define MLD_SFLAG(x) (((x) >> 3) & 0x01) 61191666Sbms#define MLD_QRV(x) ((x) & 0x07) 62191666Sbms 63191666Sbms/* 64191666Sbms * MLDv2 host membership report header. 65191666Sbms * mld_type: MLDV2_LISTENER_REPORT 66191666Sbms */ 67191666Sbmsstruct mldv2_report { 68191666Sbms struct icmp6_hdr mld_icmp6_hdr; 69191666Sbms /* followed by 1..numgrps records */ 70191666Sbms} __packed; 71191666Sbms/* overlaid on struct icmp6_hdr. */ 72191666Sbms#define mld_numrecs mld_icmp6_hdr.icmp6_data16[1] 73191666Sbms 74191666Sbmsstruct mldv2_record { 75191666Sbms uint8_t mr_type; /* record type */ 76191666Sbms uint8_t mr_datalen; /* length of auxiliary data */ 77191666Sbms uint16_t mr_numsrc; /* number of sources */ 78191666Sbms struct in6_addr mr_addr; /* address being reported */ 79191666Sbms /* followed by 1..numsrc source addresses */ 80191666Sbms} __packed; 81191666Sbms#define MLD_V2_REPORT_MAXRECS 65535 82191666Sbms 83191666Sbms/* 84191666Sbms * MLDv2 report modes. 85191666Sbms */ 86191666Sbms#define MLD_DO_NOTHING 0 /* don't send a record */ 87191666Sbms#define MLD_MODE_IS_INCLUDE 1 /* MODE_IN */ 88191666Sbms#define MLD_MODE_IS_EXCLUDE 2 /* MODE_EX */ 89191666Sbms#define MLD_CHANGE_TO_INCLUDE_MODE 3 /* TO_IN */ 90191666Sbms#define MLD_CHANGE_TO_EXCLUDE_MODE 4 /* TO_EX */ 91191666Sbms#define MLD_ALLOW_NEW_SOURCES 5 /* ALLOW_NEW */ 92191666Sbms#define MLD_BLOCK_OLD_SOURCES 6 /* BLOCK_OLD */ 93191666Sbms 94191666Sbms/* 95191666Sbms * MLDv2 query types. 96191666Sbms */ 97191666Sbms#define MLD_V2_GENERAL_QUERY 1 98191666Sbms#define MLD_V2_GROUP_QUERY 2 99191666Sbms#define MLD_V2_GROUP_SOURCE_QUERY 3 100191666Sbms 101191666Sbms/* 102191666Sbms * Maximum report interval for MLDv1 host membership reports. 103191666Sbms */ 104191666Sbms#define MLD_V1_MAX_RI 10 105191666Sbms 106191666Sbms/* 107191666Sbms * MLD_TIMER_SCALE denotes that the MLD code field specifies 108191666Sbms * time in milliseconds. 109191666Sbms */ 110191666Sbms#define MLD_TIMER_SCALE 1000 111191666Sbms 112191666Sbms#endif /* _NETINET6_MLD6_H_ */ 113