OpenSDN source code
mld_proto.h
Go to the documentation of this file.
1 /* $Id: mld_proto.h 346474 2009-11-14 10:18:58Z ssiano $
2  *
3  * mld_proto.h - MLD protocol message definitions
4  *
5  * Dave Katz, March 2008
6  *
7  * Copyright (c) 2008, Juniper Networks, Inc.
8  * Copyright Contributors to the OpenSDN project
9  * All rights reserved.
10  */
11 
12 #ifndef __MLD_PROTO_H__
13 #define __MLD_PROTO_H__
14 
15 /*
16  * This module defines the message formats for MLD, as well as some
17  * helper routines.
18  */
19 
20 
21 /*
22  * MLD packet header format
23  *
24  * The MLD header qualifies the contents of the rest of the packet.
25  */
26 typedef struct mld_hdr_ {
27  uint8_t mld_hdr_type; /* packet type */
28  uint8_t mld_hdr_resv; /* Reserved */
29  uint16_t mld_hdr_cksum; /* Checksum */
31 
32 #define MLD_TYPE_QUERY 130 /* Query (all versions) */
33 #define MLD_TYPE_V1_REPORT 131 /* Version 1 Report */
34 #define MLD_TYPE_V1_LEAVE 132 /* Version 1 Leave */
35 #define MLD_TYPE_V2_REPORT 143 /* Version 2 Report */
36 
37 /*
38  * Version 1 packets
39  *
40  * All MLD v1 packets have the same format.
41  */
42 typedef struct mld_v1_pkt_ {
43  mld_hdr mld_v1_pkt_hdr; /* Packet header */
44  uint16_t mld_v1_max_resp; /* Maximum Response Delay */
45  uint16_t mld_v1_resv; /* Reserved */
46  uint8_t mld_v1_pkt_group[IPV6_ADDR_LEN]; /* Group address */
48 
49 
50 /*
51  * Version 2 Query packet
52  */
53 typedef struct mld_v2_query_ {
54  mld_hdr mld_v2_query_hdr; /* Packet header */
55  uint16_t mld_v2_max_resp; /* Max resp code */
56  uint16_t mld_v2_resv; /* Reserved */
57  uint8_t mld_v2_query_group[IPV6_ADDR_LEN]; /* Group address */
58  uint8_t mld_v2_query_s_qrv; /* S/QRV fields */
59  uint8_t mld_v2_query_qqic; /* QQIC */
60  uint16_t mld_v2_query_num_srcs; /* Number of sources */
61  uint8_t mld_v2_query_source[0]; /* Array of sources */
63 
64 #define MLD_SUPP_RTR_PROC_MASK 0x8 /* "S" bit in s_qrv field */
65 #define MLD_QRV_MASK 0x7 /* QRV value in s_qrv field */
66 
67 
68 /*
69  * Version 2 Report packet
70  *
71  * Version 2 reports have one or more group records.
72  */
73 typedef struct mld_v2_rpt_rcrd_ {
74  uint8_t mld_v2_rpt_rec_type; /* Record type */
75  uint8_t mld_v2_rpt_aux_len; /* Auxiliary data length */
76  uint16_t mld_v2_rpt_num_srcs; /* Number of sources */
77  uint8_t mld_v2_rpt_group[IPV6_ADDR_LEN]; /* Group address */
79 
80 /* Array of sources */
81 static inline uint8_t* get_mld_v2_rpt_source(mld_v2_rpt_rcrd *ptr) {
82  return (uint8_t*)(ptr + 1);
83 }
84 
85 typedef struct mld_v2_report_ {
86  mld_hdr mld_v2_report_hdr; /* Packet header */
87  uint16_t mld_v2_report_rsvd; /* Reserved */
88  uint16_t mld_v2_report_num_rcrds; /* Number of records */
89  mld_v2_rpt_rcrd mld_v2_report_rcrd[0]; /* Set records */
91 
92 
93 /*
94  * Naked header
95  *
96  * This is a hack to access the header to determine the packet type.
97  */
98 typedef struct mld_naked_header_ {
99  mld_hdr mld_naked_header_hdr; /* Packet header */
100  uint16_t mld_naked_max_resp; /* Max resp code */
102 
103 
104 /*
105  * MLD Packet
106  *
107  * This is a union of all types to aid in type coercion.
108  */
109 typedef union mld_packet_ {
110  mld_naked_header mld_pkt_naked; /* Naked header */
111  mld_v1_pkt mld_pkt_v1; /* V1 packet */
113  mld_v2_report mld_pkt_v2_rpt; /* V2 report */
115 
116 
117 /*
118  * Max Resp field
119  *
120  * The Max Resp field in version 2 can be fixed or floating point.
121  */
122 #define MLD_MAXRSP_FIXFLOAT_FLAG 0x8000 /* Set if floating point */
123 #define MLD_MAXRSP_EXP_MASK 0x7000 /* Floating point exponent mask */
124 #define MLD_MAXRSP_EXP_SHIFT 12 /* Shift count for exponent */
125 #define MLD_MAXRSP_MANT_MASK 0x0FFF /* Floating point mantissa mask */
126 #define MLD_MAXRSP_MANT_HIGHBIT 0x1000 /* High bit of mantissa */
127 #define MLD_MAXRSP_MAX_MANT 0x1FFF /* Max mantissa portion */
128 #define MLD_MAXRSP_MANT_SHIFT 0 /* Shift count for mantissa */
129 #define MLD_MAXRSP_EXP_OFFSET 3 /* Offset bits to add */
130 #define MLD_MAXRSP_MAX_EXP 0x07 /* Maximum exponent value */
131 #define MLD_MAX_MAXRSP_ENCODABLE \
132  ((MLD_MAXRSP_MANT_MASK | MLD_MAXRSP_MANT_HIGHBIT) << \
133  (MLD_MAXRSP_MAX_EXP + MLD_MAXRSP_EXP_OFFSET))
134  /* Maximum encodable value */
135 
136 /*
137  * QQIC field
138  *
139  * The QQIC field in version 2 can be fixed or floating point.
140  */
141 #define MLD_QQIC_FIXFLOAT_FLAG 0x80 /* Set if floating point */
142 #define MLD_QQIC_EXP_MASK 0x70 /* Floating point exponent mask */
143 #define MLD_QQIC_EXP_SHIFT 4 /* Shift count for exponent */
144 #define MLD_QQIC_MANT_MASK 0x0F /* Floating point mantissa mask */
145 #define MLD_QQIC_MANT_HIGHBIT 0x10 /* High bit of mantissa */
146 #define MLD_QQIC_MAX_MANT 0x1F /* Max mantissa portion */
147 #define MLD_QQIC_MANT_SHIFT 0 /* Shift count for mantissa */
148 #define MLD_QQIC_EXP_OFFSET 3 /* Offset bits to add */
149 #define MLD_QQIC_MAX_EXP 0x07 /* Maximum exponent value */
150 #define MLD_MAX_QQIC_ENCODABLE \
151  ((MLD_QQIC_MANT_MASK | MLD_QQIC_MANT_HIGHBIT) << \
152  (MLD_QQIC_MAX_EXP + MLD_QQIC_EXP_OFFSET))
153  /* Maximum encodable value */
154 
155 
156 #define MLD_MAX_RESP_MSEC 1 /* Max Resp is in units of msec */
157 #define MLD_MAX_RESP_DEFAULT 10000 /* Default Max Resp val msec) */
158 #define MLD_V1_MAX_MAX_RESP 0xFFFF /* Maximum Max Resp value for V1 */
159 
160 
161 
162 #endif /* __MLD_PROTO_H__ */
#define IPV6_ADDR_LEN
Definition: gmp.h:26
struct mld_v2_report_ mld_v2_report
struct mld_naked_header_ mld_naked_header
static uint8_t * get_mld_v2_rpt_source(mld_v2_rpt_rcrd *ptr)
Definition: mld_proto.h:81
union mld_packet_ mld_packet
struct mld_v2_rpt_rcrd_ mld_v2_rpt_rcrd
struct mld_v1_pkt_ mld_v1_pkt
struct mld_v2_query_ mld_v2_query
struct mld_hdr_ mld_hdr
uint8_t mld_hdr_type
Definition: mld_proto.h:27
uint8_t mld_hdr_resv
Definition: mld_proto.h:28
uint16_t mld_hdr_cksum
Definition: mld_proto.h:29
mld_hdr mld_naked_header_hdr
Definition: mld_proto.h:99
uint16_t mld_naked_max_resp
Definition: mld_proto.h:100
uint16_t mld_v1_resv
Definition: mld_proto.h:45
mld_hdr mld_v1_pkt_hdr
Definition: mld_proto.h:43
uint8_t mld_v1_pkt_group[IPV6_ADDR_LEN]
Definition: mld_proto.h:46
uint16_t mld_v1_max_resp
Definition: mld_proto.h:44
uint8_t mld_v2_query_s_qrv
Definition: mld_proto.h:58
uint16_t mld_v2_max_resp
Definition: mld_proto.h:55
uint16_t mld_v2_query_num_srcs
Definition: mld_proto.h:60
uint8_t mld_v2_query_source[0]
Definition: mld_proto.h:61
uint8_t mld_v2_query_group[IPV6_ADDR_LEN]
Definition: mld_proto.h:57
uint16_t mld_v2_resv
Definition: mld_proto.h:56
mld_hdr mld_v2_query_hdr
Definition: mld_proto.h:54
uint8_t mld_v2_query_qqic
Definition: mld_proto.h:59
mld_hdr mld_v2_report_hdr
Definition: mld_proto.h:86
uint16_t mld_v2_report_num_rcrds
Definition: mld_proto.h:88
uint16_t mld_v2_report_rsvd
Definition: mld_proto.h:87
mld_v2_rpt_rcrd mld_v2_report_rcrd[0]
Definition: mld_proto.h:89
uint16_t mld_v2_rpt_num_srcs
Definition: mld_proto.h:76
uint8_t mld_v2_rpt_group[IPV6_ADDR_LEN]
Definition: mld_proto.h:77
uint8_t mld_v2_rpt_rec_type
Definition: mld_proto.h:74
uint8_t mld_v2_rpt_aux_len
Definition: mld_proto.h:75
mld_v2_query mld_pkt_v2_query
Definition: mld_proto.h:112
mld_v1_pkt mld_pkt_v1
Definition: mld_proto.h:111
mld_naked_header mld_pkt_naked
Definition: mld_proto.h:110
mld_v2_report mld_pkt_v2_rpt
Definition: mld_proto.h:113