1*4f039af1Sjsg /* $OpenBSD: mld6.h,v 1.2 2010/03/22 21:29:22 jsg Exp $ */ 2cc0f2657Sjsg /* $FreeBSD: mld6.h,v 1.1 2009/04/29 11:31:23 bms Exp $ */ 3cc0f2657Sjsg /*- 4cc0f2657Sjsg * Copyright (c) 2009 Bruce Simpson. 5cc0f2657Sjsg * 6cc0f2657Sjsg * Redistribution and use in source and binary forms, with or without 7cc0f2657Sjsg * modification, are permitted provided that the following conditions 8cc0f2657Sjsg * are met: 9cc0f2657Sjsg * 1. Redistributions of source code must retain the above copyright 10cc0f2657Sjsg * notice, this list of conditions and the following disclaimer. 11cc0f2657Sjsg * 2. Redistributions in binary form must reproduce the above copyright 12cc0f2657Sjsg * notice, this list of conditions and the following disclaimer in the 13cc0f2657Sjsg * documentation and/or other materials provided with the distribution. 14cc0f2657Sjsg * 3. The name of the author may not be used to endorse or promote 15cc0f2657Sjsg * products derived from this software without specific prior written 16cc0f2657Sjsg * permission. 17cc0f2657Sjsg * 18cc0f2657Sjsg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19cc0f2657Sjsg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20cc0f2657Sjsg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21cc0f2657Sjsg * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22cc0f2657Sjsg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23cc0f2657Sjsg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24cc0f2657Sjsg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25cc0f2657Sjsg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26cc0f2657Sjsg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27cc0f2657Sjsg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28cc0f2657Sjsg * SUCH DAMAGE. 29cc0f2657Sjsg * 30cc0f2657Sjsg */ 31cc0f2657Sjsg 32cc0f2657Sjsg #ifndef _NETINET6_MLD6_H_ 33cc0f2657Sjsg #define _NETINET6_MLD6_H_ 34cc0f2657Sjsg 35cc0f2657Sjsg /* 36cc0f2657Sjsg * Multicast Listener Discovery (MLD) definitions. 37cc0f2657Sjsg */ 38cc0f2657Sjsg 39cc0f2657Sjsg /* Minimum length of any MLD protocol message. */ 40cc0f2657Sjsg #define MLD_MINLEN sizeof(struct icmp6_hdr) 41cc0f2657Sjsg 42cc0f2657Sjsg /* 43cc0f2657Sjsg * MLD v2 query format. 44cc0f2657Sjsg * See <netinet/icmp6.h> for struct mld_hdr 45cc0f2657Sjsg * (MLDv1 query and host report format). 46cc0f2657Sjsg */ 47cc0f2657Sjsg struct mldv2_query { 48cc0f2657Sjsg struct icmp6_hdr mld_icmp6_hdr; /* ICMPv6 header */ 49cc0f2657Sjsg struct in6_addr mld_addr; /* address being queried */ 50cc0f2657Sjsg uint8_t mld_misc; /* reserved/suppress/robustness */ 51cc0f2657Sjsg uint8_t mld_qqi; /* querier's query interval */ 52cc0f2657Sjsg uint16_t mld_numsrc; /* number of sources */ 53cc0f2657Sjsg /* followed by 1..numsrc source addresses */ 54cc0f2657Sjsg } __packed; 55cc0f2657Sjsg #define MLD_V2_QUERY_MINLEN sizeof(struct mldv2_query) 56cc0f2657Sjsg #define MLD_MRC_EXP(x) ((ntohs((x)) >> 12) & 0x0007) 57cc0f2657Sjsg #define MLD_MRC_MANT(x) (ntohs((x)) & 0x0fff) 58cc0f2657Sjsg #define MLD_QQIC_EXP(x) (((x) >> 4) & 0x07) 59cc0f2657Sjsg #define MLD_QQIC_MANT(x) ((x) & 0x0f) 60cc0f2657Sjsg #define MLD_QRESV(x) (((x) >> 4) & 0x0f) 61cc0f2657Sjsg #define MLD_SFLAG(x) (((x) >> 3) & 0x01) 62cc0f2657Sjsg #define MLD_QRV(x) ((x) & 0x07) 63cc0f2657Sjsg 64cc0f2657Sjsg /* 65cc0f2657Sjsg * MLDv2 host membership report header. 66cc0f2657Sjsg * mld_type: MLDV2_LISTENER_REPORT 67cc0f2657Sjsg */ 68cc0f2657Sjsg struct mldv2_report { 69cc0f2657Sjsg struct icmp6_hdr mld_icmp6_hdr; 70cc0f2657Sjsg /* followed by 1..numgrps records */ 71cc0f2657Sjsg } __packed; 72cc0f2657Sjsg /* overlaid on struct icmp6_hdr. */ 73cc0f2657Sjsg #define mld_numrecs mld_icmp6_hdr.icmp6_data16[1] 74cc0f2657Sjsg 75cc0f2657Sjsg struct mldv2_record { 76cc0f2657Sjsg uint8_t mr_type; /* record type */ 77cc0f2657Sjsg uint8_t mr_datalen; /* length of auxiliary data */ 78cc0f2657Sjsg uint16_t mr_numsrc; /* number of sources */ 79cc0f2657Sjsg struct in6_addr mr_addr; /* address being reported */ 80cc0f2657Sjsg /* followed by 1..numsrc source addresses */ 81cc0f2657Sjsg } __packed; 82cc0f2657Sjsg #define MLD_V2_REPORT_MAXRECS 65535 83cc0f2657Sjsg 84cc0f2657Sjsg /* 85cc0f2657Sjsg * MLDv2 report modes. 86cc0f2657Sjsg */ 87cc0f2657Sjsg #define MLD_DO_NOTHING 0 /* don't send a record */ 88cc0f2657Sjsg #define MLD_MODE_IS_INCLUDE 1 /* MODE_IN */ 89cc0f2657Sjsg #define MLD_MODE_IS_EXCLUDE 2 /* MODE_EX */ 90cc0f2657Sjsg #define MLD_CHANGE_TO_INCLUDE_MODE 3 /* TO_IN */ 91cc0f2657Sjsg #define MLD_CHANGE_TO_EXCLUDE_MODE 4 /* TO_EX */ 92cc0f2657Sjsg #define MLD_ALLOW_NEW_SOURCES 5 /* ALLOW_NEW */ 93cc0f2657Sjsg #define MLD_BLOCK_OLD_SOURCES 6 /* BLOCK_OLD */ 94cc0f2657Sjsg 95cc0f2657Sjsg /* 96cc0f2657Sjsg * MLDv2 query types. 97cc0f2657Sjsg */ 98cc0f2657Sjsg #define MLD_V2_GENERAL_QUERY 1 99cc0f2657Sjsg #define MLD_V2_GROUP_QUERY 2 100cc0f2657Sjsg #define MLD_V2_GROUP_SOURCE_QUERY 3 101cc0f2657Sjsg 102cc0f2657Sjsg /* 103cc0f2657Sjsg * Maximum report interval for MLDv1 host membership reports (in seconds) 104cc0f2657Sjsg */ 105cc0f2657Sjsg #define MLD_V1_MAX_RI 10 106cc0f2657Sjsg 107cc0f2657Sjsg /* 108cc0f2657Sjsg * MLD_TIMER_SCALE denotes that the MLD code field specifies 109cc0f2657Sjsg * time in milliseconds. 110cc0f2657Sjsg */ 111cc0f2657Sjsg #define MLD_TIMER_SCALE 1000 112cc0f2657Sjsg 113cc0f2657Sjsg #endif /* _NETINET6_MLD6_H_ */ 114