]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_msg.h
Merge remote-tracking branch 'origin/stable/2.0'
[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
16 along with this program; see the file COPYING; if not, write to the
17 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
18 MA 02110-1301 USA
19 */
20
21 #ifndef PIM_MSG_H
22 #define PIM_MSG_H
23
24 #include <netinet/in.h>
25
26 #include "pim_jp_agg.h"
27 /*
28 Number Description
29 ---------- ------------------
30 0 Reserved
31 1 IP (IP version 4)
32 2 IP6 (IP version 6)
33
34 From:
35 http://www.iana.org/assignments/address-family-numbers
36 */
37 enum pim_msg_address_family {
38 PIM_MSG_ADDRESS_FAMILY_RESERVED,
39 PIM_MSG_ADDRESS_FAMILY_IPV4,
40 PIM_MSG_ADDRESS_FAMILY_IPV6,
41 };
42
43 /*
44 * Network Order pim_msg_hdr
45 */
46 struct pim_msg_header {
47 uint8_t type:4;
48 uint8_t ver:4;
49 uint8_t reserved;
50 uint16_t checksum;
51 } __attribute__ ((packed));
52
53 struct pim_encoded_ipv4_unicast {
54 uint8_t family;
55 uint8_t reserved;
56 struct in_addr addr;
57 } __attribute__ ((packed));
58
59 struct pim_encoded_group_ipv4 {
60 uint8_t ne;
61 uint8_t family;
62 uint8_t reserved;
63 uint8_t mask;
64 struct in_addr addr;
65 } __attribute__ ((packed));
66
67 struct pim_encoded_source_ipv4 {
68 uint8_t ne;
69 uint8_t family;
70 uint8_t bits;
71 uint8_t mask;
72 struct in_addr addr;
73 } __attribute__ ((packed));
74
75 struct pim_jp_groups {
76 struct pim_encoded_group_ipv4 g;
77 uint16_t joins;
78 uint16_t prunes;
79 struct pim_encoded_source_ipv4 s[1];
80 } __attribute__ ((packed));
81
82 struct pim_jp {
83 struct pim_msg_header header;
84 struct pim_encoded_ipv4_unicast addr;
85 uint8_t reserved;
86 uint8_t num_groups;
87 uint16_t holdtime;
88 struct pim_jp_groups groups[1];
89 } __attribute__ ((packed));
90
91 void pim_msg_build_header(uint8_t *pim_msg, size_t pim_msg_size, uint8_t pim_msg_type);
92 uint8_t *pim_msg_addr_encode_ipv4_ucast(uint8_t *buf, struct in_addr addr);
93 uint8_t *pim_msg_addr_encode_ipv4_group(uint8_t *buf, struct in_addr addr);
94
95 #define PIM_ENCODE_SPARSE_BIT 0x04
96 #define PIM_ENCODE_WC_BIT 0x02
97 #define PIM_ENCODE_RPT_BIT 0x01
98 uint8_t *pim_msg_addr_encode_ipv4_source(uint8_t *buf,
99 struct in_addr addr, uint8_t bits);
100
101
102 size_t pim_msg_get_jp_group_size (struct list *sources);
103 size_t pim_msg_build_jp_groups (struct pim_jp_groups *grp, struct pim_jp_agg_group *sgs, size_t size);
104 #endif /* PIM_MSG_H */