]>
Commit | Line | Data |
---|---|---|
12e41d03 | 1 | /* |
896014f4 DL |
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 | */ | |
12e41d03 DL |
19 | |
20 | #ifndef PIM_MSG_H | |
21 | #define PIM_MSG_H | |
22 | ||
23 | #include <netinet/in.h> | |
24 | ||
982bff89 | 25 | #include "pim_jp_agg.h" |
12e41d03 | 26 | /* |
d62a17ae | 27 | Number Description |
12e41d03 DL |
28 | ---------- ------------------ |
29 | 0 Reserved | |
30 | 1 IP (IP version 4) | |
31 | 2 IP6 (IP version 6) | |
32 | ||
33 | From: | |
34 | http://www.iana.org/assignments/address-family-numbers | |
35 | */ | |
34687162 | 36 | enum pim_msg_address_family { |
d62a17ae | 37 | PIM_MSG_ADDRESS_FAMILY_RESERVED, |
38 | PIM_MSG_ADDRESS_FAMILY_IPV4, | |
39 | PIM_MSG_ADDRESS_FAMILY_IPV6, | |
34687162 | 40 | }; |
12e41d03 | 41 | |
70ce34ae DS |
42 | /* |
43 | * Network Order pim_msg_hdr | |
44 | */ | |
45 | struct pim_msg_header { | |
d62a17ae | 46 | uint8_t type : 4; |
47 | uint8_t ver : 4; | |
48 | uint8_t reserved; | |
49 | uint16_t checksum; | |
50 | } __attribute__((packed)); | |
70ce34ae | 51 | |
74ac496f | 52 | struct pim_encoded_ipv4_unicast { |
d62a17ae | 53 | uint8_t family; |
54 | uint8_t reserved; | |
55 | struct in_addr addr; | |
56 | } __attribute__((packed)); | |
74ac496f DS |
57 | |
58 | struct pim_encoded_group_ipv4 { | |
d62a17ae | 59 | uint8_t ne; |
60 | uint8_t family; | |
61 | uint8_t reserved; | |
62 | uint8_t mask; | |
63 | struct in_addr addr; | |
64 | } __attribute__((packed)); | |
74ac496f DS |
65 | |
66 | struct pim_encoded_source_ipv4 { | |
d62a17ae | 67 | uint8_t ne; |
68 | uint8_t family; | |
69 | uint8_t bits; | |
70 | uint8_t mask; | |
71 | struct in_addr addr; | |
72 | } __attribute__((packed)); | |
74ac496f DS |
73 | |
74 | struct pim_jp_groups { | |
d62a17ae | 75 | struct pim_encoded_group_ipv4 g; |
76 | uint16_t joins; | |
77 | uint16_t prunes; | |
78 | struct pim_encoded_source_ipv4 s[1]; | |
79 | } __attribute__((packed)); | |
74ac496f DS |
80 | |
81 | struct pim_jp { | |
d62a17ae | 82 | struct pim_msg_header header; |
83 | struct pim_encoded_ipv4_unicast addr; | |
84 | uint8_t reserved; | |
85 | uint8_t num_groups; | |
86 | uint16_t holdtime; | |
87 | struct pim_jp_groups groups[1]; | |
88 | } __attribute__((packed)); | |
74ac496f | 89 | |
d62a17ae | 90 | void pim_msg_build_header(uint8_t *pim_msg, size_t pim_msg_size, |
91 | uint8_t pim_msg_type); | |
f8e7d799 DS |
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); | |
984c84f4 DS |
94 | |
95 | #define PIM_ENCODE_SPARSE_BIT 0x04 | |
96 | #define PIM_ENCODE_WC_BIT 0x02 | |
97 | #define PIM_ENCODE_RPT_BIT 0x01 | |
d62a17ae | 98 | uint8_t *pim_msg_addr_encode_ipv4_source(uint8_t *buf, struct in_addr addr, |
99 | uint8_t bits); | |
12e41d03 | 100 | |
346cffe3 | 101 | |
d62a17ae | 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, | |
104 | struct pim_jp_agg_group *sgs, size_t size); | |
12e41d03 | 105 | #endif /* PIM_MSG_H */ |