]>
git.proxmox.com Git - mirror_frr.git/blob - lib/mlag.c
2 * Copyright (C) 2018 Cumulus Networks, Inc.
5 * This file is part of FRR.
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
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.
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
26 char *mlag_role2str(enum mlag_role role
, char *buf
, size_t size
)
30 snprintf(buf
, size
, "NONE");
32 case MLAG_ROLE_PRIMARY
:
33 snprintf(buf
, size
, "PRIMARY");
35 case MLAG_ROLE_SECONDARY
:
36 snprintf(buf
, size
, "SECONDARY");
43 char *mlag_lib_msgid_to_str(enum mlag_msg_type msg_type
, char *buf
, size_t size
)
47 snprintf(buf
, size
, "Register");
50 snprintf(buf
, size
, "De-Register");
53 snprintf(buf
, size
, "Mroute add");
56 snprintf(buf
, size
, "Mroute del");
59 snprintf(buf
, size
, "Mlag Replay");
61 case MLAG_MROUTE_ADD_BULK
:
62 snprintf(buf
, size
, "Mroute Add Batch");
64 case MLAG_MROUTE_DEL_BULK
:
65 snprintf(buf
, size
, "Mroute Del Batch");
67 case MLAG_STATUS_UPDATE
:
68 snprintf(buf
, size
, "Mlag Status");
70 case MLAG_VXLAN_UPDATE
:
71 snprintf(buf
, size
, "Mlag vxlan update");
73 case MLAG_PEER_FRR_STATUS
:
74 snprintf(buf
, size
, "Mlag Peer FRR Status");
77 snprintf(buf
, size
, "Unknown %d", msg_type
);
84 int mlag_lib_decode_mlag_hdr(struct stream
*s
, struct mlag_msg
*msg
)
86 if (s
== NULL
|| msg
== NULL
)
89 STREAM_GETL(s
, msg
->msg_type
);
90 STREAM_GETW(s
, msg
->data_len
);
91 STREAM_GETW(s
, msg
->msg_cnt
);
97 int mlag_lib_decode_mroute_add(struct stream
*s
, struct mlag_mroute_add
*msg
)
99 if (s
== NULL
|| msg
== NULL
)
102 STREAM_GET(msg
->vrf_name
, s
, VRF_NAMSIZ
);
103 STREAM_GETL(s
, msg
->source_ip
);
104 STREAM_GETL(s
, msg
->group_ip
);
105 STREAM_GETL(s
, msg
->cost_to_rp
);
106 STREAM_GETL(s
, msg
->owner_id
);
107 STREAM_GETC(s
, msg
->am_i_dr
);
108 STREAM_GETC(s
, msg
->am_i_dual_active
);
109 STREAM_GETL(s
, msg
->vrf_id
);
110 STREAM_GET(msg
->intf_name
, s
, INTERFACE_NAMSIZ
);
116 int mlag_lib_decode_mroute_del(struct stream
*s
, struct mlag_mroute_del
*msg
)
118 if (s
== NULL
|| msg
== NULL
)
121 STREAM_GET(msg
->vrf_name
, s
, VRF_NAMSIZ
);
122 STREAM_GETL(s
, msg
->source_ip
);
123 STREAM_GETL(s
, msg
->group_ip
);
124 STREAM_GETL(s
, msg
->owner_id
);
125 STREAM_GETL(s
, msg
->vrf_id
);
126 STREAM_GET(msg
->intf_name
, s
, INTERFACE_NAMSIZ
);
132 int mlag_lib_decode_mlag_status(struct stream
*s
, struct mlag_status
*msg
)
134 if (s
== NULL
|| msg
== NULL
)
137 STREAM_GET(msg
->peerlink_rif
, s
, INTERFACE_NAMSIZ
);
138 STREAM_GETL(s
, msg
->my_role
);
139 STREAM_GETL(s
, msg
->peer_state
);
145 int mlag_lib_decode_vxlan_update(struct stream
*s
, struct mlag_vxlan
*msg
)
147 if (s
== NULL
|| msg
== NULL
)
150 STREAM_GETL(s
, msg
->anycast_ip
);
151 STREAM_GETL(s
, msg
->local_ip
);
158 int mlag_lib_decode_frr_status(struct stream
*s
, struct mlag_frr_status
*msg
)
160 if (s
== NULL
|| msg
== NULL
)
163 STREAM_GETL(s
, msg
->frr_state
);