]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_msdp_packet.h
Merge remote-tracking branch 'origin/master' into bgpafisafi
[mirror_frr.git] / pimd / pim_msdp_packet.h
1 /*
2 * IP MSDP packet helpers
3 * Copyright (C) 2016 Cumulus Networks, Inc.
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 #ifndef PIM_MSDP_PACKET_H
21 #define PIM_MSDP_PACKET_H
22
23 /* type and length of a single tlv can be consider packet header */
24 #define PIM_MSDP_HEADER_SIZE 3
25
26 /* Keepalive TLV
27 0 1 2 3
28 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
29 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
30 | 4 | 3 |
31 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
32 */
33 #define PIM_MSDP_KA_TLV_MAX_SIZE PIM_MSDP_HEADER_SIZE
34
35 /* Source-Active TLV (x=8, y=12xEntryCount)
36 0 1 2 3
37 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
38 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 | 1 | x + y | Entry Count |
40 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 | RP Address |
42 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 | Reserved | Sprefix Len | \
44 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ \
45 | Group Address | ) z
46 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /
47 | Source Address | /
48 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 */
50 #define PIM_MSDP_SA_TLV_MAX_SIZE 9192
51 #define PIM_MSDP_SA_X_SIZE 8
52 #define PIM_MSDP_SA_ONE_ENTRY_SIZE 12
53 #define PIM_MSDP_SA_Y_SIZE(entry_cnt) (PIM_MSDP_SA_ONE_ENTRY_SIZE * entry_cnt)
54 #define PIM_MSDP_SA_ENTRY_CNT2SIZE(entry_cnt) (PIM_MSDP_SA_X_SIZE +\
55 PIM_MSDP_SA_Y_SIZE(entry_cnt))
56 /* SA TLV has to have atleast only one entry in it so x=8 + y=12 */
57 #define PIM_MSDP_SA_TLV_MIN_SIZE PIM_MSDP_SA_ENTRY_CNT2SIZE(1)
58 /* XXX: theoretically we can fix a max of 255 but that may result in packet
59 * fragmentation */
60 #define PIM_MSDP_SA_MAX_ENTRY_CNT 120
61
62 #define PIM_MSDP_MAX_PACKET_SIZE max(PIM_MSDP_SA_TLV_MAX_SIZE, PIM_MSDP_KA_TLV_MAX_SIZE)
63
64 #define PIM_MSDP_PKT_TYPE_STRLEN 16
65
66 void pim_msdp_pkt_ka_tx(struct pim_msdp_peer *mp);
67 int pim_msdp_read(struct thread *thread);
68 void pim_msdp_pkt_sa_tx(void);
69 void pim_msdp_pkt_sa_tx_one(struct pim_msdp_sa *sa);
70 void pim_msdp_pkt_sa_tx_to_one_peer(struct pim_msdp_peer *mp);
71
72 #endif