]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_msg.h
Merge pull request #4570 from donaldsharp/route_map_clear
[mirror_frr.git] / pimd / pim_msg.h
1 /*
2 * PIM for Quagga
3 * Copyright (C) 2008 Everton da Silva Marques
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef PIM_MSG_H
21 #define PIM_MSG_H
22
23 #include <netinet/in.h>
24
25 #include "pim_jp_agg.h"
26
27 #define PIM_HDR_LEN sizeof(struct pim_msg_header)
28 /*
29 Number Description
30 ---------- ------------------
31 0 Reserved
32 1 IP (IP version 4)
33 2 IP6 (IP version 6)
34
35 From:
36 http://www.iana.org/assignments/address-family-numbers
37 */
38 enum pim_msg_address_family {
39 PIM_MSG_ADDRESS_FAMILY_RESERVED,
40 PIM_MSG_ADDRESS_FAMILY_IPV4,
41 PIM_MSG_ADDRESS_FAMILY_IPV6,
42 };
43
44 /*
45 * Network Order pim_msg_hdr
46 * =========================
47 * PIM Header definition as per RFC 5059. N bit introduced to indicate
48 * do-not-forward option in PIM Boot strap Message.
49 * 0 1 2 3
50 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 * |PIM Ver| Type |N| Reserved | Checksum |
53 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 */
55 struct pim_msg_header {
56 uint8_t type : 4;
57 uint8_t ver : 4;
58 uint8_t Nbit : 1; /* No Fwd Bit */
59 uint8_t reserved : 7;
60 uint16_t checksum;
61 } __attribute__((packed));
62
63 struct pim_encoded_ipv4_unicast {
64 uint8_t family;
65 uint8_t reserved;
66 struct in_addr addr;
67 } __attribute__((packed));
68
69 /*
70 * Encoded Group format. RFC 4601 Sec 4.9.1
71 * 0 1 2 3
72 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
73 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74 * | Addr Family | Encoding Type |B| Reserved |Z| Mask Len |
75 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76 * | Group multicast Address
77 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...
78 */
79 struct pim_encoded_group_ipv4 {
80 uint8_t family;
81 uint8_t ne;
82 uint8_t bidir : 1; /* Bidir bit */
83 uint8_t reserved : 6; /* Reserved */
84 uint8_t sz : 1; /* scope zone bit */
85 uint8_t mask;
86 struct in_addr addr;
87 } __attribute__((packed));
88
89
90 /*
91 * Encoded Source format. RFC 4601 Sec 4.9.1
92 * 0 1 2 3
93 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
94 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95 * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
96 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
97 * | Source Address
98 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...
99 */
100 struct pim_encoded_source_ipv4 {
101 uint8_t family;
102 uint8_t ne;
103 uint8_t bits;
104 uint8_t mask;
105 struct in_addr addr;
106 } __attribute__((packed));
107
108 struct pim_jp_groups {
109 struct pim_encoded_group_ipv4 g;
110 uint16_t joins;
111 uint16_t prunes;
112 struct pim_encoded_source_ipv4 s[1];
113 } __attribute__((packed));
114
115 struct pim_jp {
116 struct pim_msg_header header;
117 struct pim_encoded_ipv4_unicast addr;
118 uint8_t reserved;
119 uint8_t num_groups;
120 uint16_t holdtime;
121 struct pim_jp_groups groups[1];
122 } __attribute__((packed));
123
124 void pim_msg_build_header(uint8_t *pim_msg, size_t pim_msg_size,
125 uint8_t pim_msg_type, bool no_fwd);
126 uint8_t *pim_msg_addr_encode_ipv4_ucast(uint8_t *buf, struct in_addr addr);
127 uint8_t *pim_msg_addr_encode_ipv4_group(uint8_t *buf, struct in_addr addr);
128
129 #define PIM_ENCODE_SPARSE_BIT 0x04
130 #define PIM_ENCODE_WC_BIT 0x02
131 #define PIM_ENCODE_RPT_BIT 0x01
132 uint8_t *pim_msg_addr_encode_ipv4_source(uint8_t *buf, struct in_addr addr,
133 uint8_t bits);
134
135
136 size_t pim_msg_get_jp_group_size(struct list *sources);
137 size_t pim_msg_build_jp_groups(struct pim_jp_groups *grp,
138 struct pim_jp_agg_group *sgs, size_t size);
139 #endif /* PIM_MSG_H */