]> git.proxmox.com Git - mirror_frr.git/blob - lib/mlag.h
Merge pull request #5625 from qlyoung/fix-zapi-ipset-name-nullterm
[mirror_frr.git] / lib / mlag.h
1 /* mlag header.
2 * Copyright (C) 2018 Cumulus Networks, Inc.
3 * Donald Sharp
4 *
5 * This file is part of FRR.
6 *
7 * FRR is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * FRR is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with FRR; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22 #ifndef __MLAG_H__
23 #define __MLAG_H__
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include "lib/if.h"
30 #include "lib/vrf.h"
31 #include "lib/stream.h"
32
33 #define MLAG_MSG_NULL_PAYLOAD 0
34 #define MLAG_MSG_NO_BATCH 1
35 #define MLAG_BUF_LIMIT 2048
36
37 enum mlag_role {
38 MLAG_ROLE_NONE,
39 MLAG_ROLE_PRIMARY,
40 MLAG_ROLE_SECONDARY
41 };
42
43 enum mlag_state {
44 MLAG_STATE_DOWN,
45 MLAG_STATE_RUNNING,
46 };
47
48 enum mlag_frr_state {
49 MLAG_FRR_STATE_NONE,
50 MLAG_FRR_STATE_DOWN,
51 MLAG_FRR_STATE_UP,
52 };
53
54 enum mlag_owner {
55 MLAG_OWNER_NONE,
56 MLAG_OWNER_INTERFACE,
57 MLAG_OWNER_VXLAN,
58 };
59
60 /*
61 * This message definition should match mlag.proto
62 * Because message registration is based on this
63 */
64 enum mlag_msg_type {
65 MLAG_MSG_NONE = 0,
66 MLAG_REGISTER = 1,
67 MLAG_DEREGISTER = 2,
68 MLAG_STATUS_UPDATE = 3,
69 MLAG_MROUTE_ADD = 4,
70 MLAG_MROUTE_DEL = 5,
71 MLAG_DUMP = 6,
72 MLAG_MROUTE_ADD_BULK = 7,
73 MLAG_MROUTE_DEL_BULK = 8,
74 MLAG_PIM_CFG_DUMP = 10,
75 MLAG_VXLAN_UPDATE = 11,
76 MLAG_PEER_FRR_STATUS = 12,
77 };
78
79 struct mlag_frr_status {
80 enum mlag_frr_state frr_state;
81 };
82
83 struct mlag_status {
84 char peerlink_rif[INTERFACE_NAMSIZ];
85 enum mlag_role my_role;
86 enum mlag_state peer_state;
87 };
88
89 #define MLAG_ROLE_STRSIZE 16
90
91 struct mlag_vxlan {
92 uint32_t anycast_ip;
93 uint32_t local_ip;
94 };
95
96 struct mlag_mroute_add {
97 char vrf_name[VRF_NAMSIZ];
98 uint32_t source_ip;
99 uint32_t group_ip;
100 uint32_t cost_to_rp;
101 enum mlag_owner owner_id;
102 bool am_i_dr;
103 bool am_i_dual_active;
104 vrf_id_t vrf_id;
105 char intf_name[INTERFACE_NAMSIZ];
106 };
107
108 struct mlag_mroute_del {
109 char vrf_name[VRF_NAMSIZ];
110 uint32_t source_ip;
111 uint32_t group_ip;
112 enum mlag_owner owner_id;
113 vrf_id_t vrf_id;
114 char intf_name[INTERFACE_NAMSIZ];
115 };
116
117 struct mlag_msg {
118 enum mlag_msg_type msg_type;
119 uint16_t data_len;
120 uint16_t msg_cnt;
121 uint8_t data[0];
122 } __attribute__((packed));
123
124
125 extern char *mlag_role2str(enum mlag_role role, char *buf, size_t size);
126 extern char *mlag_lib_msgid_to_str(enum mlag_msg_type msg_type, char *buf,
127 size_t size);
128 extern int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg);
129 extern int mlag_lib_decode_mroute_add(struct stream *s,
130 struct mlag_mroute_add *msg);
131 extern int mlag_lib_decode_mroute_del(struct stream *s,
132 struct mlag_mroute_del *msg);
133 extern int mlag_lib_decode_mlag_status(struct stream *s,
134 struct mlag_status *msg);
135 extern int mlag_lib_decode_vxlan_update(struct stream *s,
136 struct mlag_vxlan *msg);
137 extern int mlag_lib_decode_frr_status(struct stream *s,
138 struct mlag_frr_status *msg);
139 #ifdef __cplusplus
140 }
141 #endif
142
143 #endif