]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_msg.h
Merge branch 'frr/pull/250' ("bgpd, zebra: Add ifindex to NEXTHOP_TYPE_IPV4")
[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 #define PIM_MSG_ADDRESS_FAMILY_IPV4 (1)
38
39 /*
40 * Network Order pim_msg_hdr
41 */
42 struct pim_msg_header {
43 uint8_t type:4;
44 uint8_t ver:4;
45 uint8_t reserved;
46 uint16_t checksum;
47 } __attribute__ ((packed));
48
49 struct pim_encoded_ipv4_unicast {
50 uint8_t family;
51 uint8_t reserved;
52 struct in_addr addr;
53 } __attribute__ ((packed));
54
55 struct pim_encoded_group_ipv4 {
56 uint8_t ne;
57 uint8_t family;
58 uint8_t reserved;
59 uint8_t mask;
60 struct in_addr addr;
61 } __attribute__ ((packed));
62
63 struct pim_encoded_source_ipv4 {
64 uint8_t ne;
65 uint8_t family;
66 uint8_t bits;
67 uint8_t mask;
68 struct in_addr addr;
69 } __attribute__ ((packed));
70
71 struct pim_jp_groups {
72 struct pim_encoded_group_ipv4 g;
73 uint16_t joins;
74 uint16_t prunes;
75 struct pim_encoded_source_ipv4 s[1];
76 } __attribute__ ((packed));
77
78 struct pim_jp {
79 struct pim_msg_header header;
80 struct pim_encoded_ipv4_unicast addr;
81 uint8_t reserved;
82 uint8_t num_groups;
83 uint16_t holdtime;
84 struct pim_jp_groups groups[1];
85 } __attribute__ ((packed));
86
87 void pim_msg_build_header(uint8_t *pim_msg, size_t pim_msg_size, uint8_t pim_msg_type);
88 uint8_t *pim_msg_addr_encode_ipv4_ucast(uint8_t *buf, struct in_addr addr);
89 uint8_t *pim_msg_addr_encode_ipv4_group(uint8_t *buf, struct in_addr addr);
90
91 #define PIM_ENCODE_SPARSE_BIT 0x04
92 #define PIM_ENCODE_WC_BIT 0x02
93 #define PIM_ENCODE_RPT_BIT 0x01
94 uint8_t *pim_msg_addr_encode_ipv4_source(uint8_t *buf,
95 struct in_addr addr, uint8_t bits);
96
97
98 size_t pim_msg_get_jp_group_size (struct list *sources);
99 size_t pim_msg_build_jp_groups (struct pim_jp_groups *grp, struct pim_jp_agg_group *sgs);
100 #endif /* PIM_MSG_H */