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