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