]>
git.proxmox.com Git - mirror_frr.git/blob - vrrpd/vrrp_packet.c
2 * VRRPD packet crafting
3 * Copyright (C) 2018 Cumulus Networks, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "vrrp_packet.h"
28 * Builds a VRRP packet.
30 struct vrrp_pkt
*vrrp_pkt_build(uint8_t vrid
, uint8_t prio
,
31 uint16_t max_adver_int
, bool v6
, uint8_t numip
,
34 size_t addrsz
= v6
? sizeof(struct in6_addr
) : sizeof(struct in_addr
);
35 struct vrrp_pkt
*pkt
=
36 XCALLOC(MTYPE_TMP
, sizeof(struct vrrp_pkt
) + addrsz
* numip
);
38 pkt
->version
= VRRP_VERSION
;
39 pkt
->type
= VRRP_TYPE_ADVERTISEMENT
;
43 pkt
->max_adver_int
= max_adver_int
;
44 for (uint8_t i
= 0; i
< numip
; i
++)
45 memcpy(&pkt
->addrs
[i
].v4
, ips
[i
], addrsz
);