diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-11-19 20:51:52 +0000 | 
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-05-17 00:27:08 +0000 | 
| commit | 5435a2bf61c4179e8b69af5d3a808b42f5387177 (patch) | |
| tree | f4f0f9f8b0d7304d84360928f31f640740c8fcde /vrrpd/vrrp_packet.c | |
| parent | db95656d48ecc46555fc9e8524849aa73a357dcb (diff) | |
vrrpd: initial commit
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'vrrpd/vrrp_packet.c')
| -rw-r--r-- | vrrpd/vrrp_packet.c | 50 | 
1 files changed, 50 insertions, 0 deletions
diff --git a/vrrpd/vrrp_packet.c b/vrrpd/vrrp_packet.c new file mode 100644 index 0000000000..4cbcd771f2 --- /dev/null +++ b/vrrpd/vrrp_packet.c @@ -0,0 +1,50 @@ +/* + * VRRPD packet crafting + * Copyright (C) 2018 Cumulus Networks, Inc. + *               Quentin Young + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include <zebra.h> + +#include "memory.h" +#include "ipaddr.h" + +#include "vrrp_packet.h" + +/* + * Builds a VRRP packet. + */ +struct vrrp_pkt *vrrp_pkt_build(uint8_t vrid, uint8_t prio, +				uint16_t max_adver_int, bool v6, uint8_t numip, +				void **ips) +{ +	size_t addrsz = v6 ? sizeof(struct in6_addr) : sizeof(struct in_addr); +	struct vrrp_pkt *pkt = +		XCALLOC(MTYPE_TMP, sizeof(struct vrrp_pkt) + addrsz * numip); + +	pkt->version = VRRP_VERSION; +	pkt->type = VRRP_TYPE_ADVERTISEMENT; +	pkt->vrid = vrid; +	pkt->priority = prio; +	pkt->rsvd = 0; +	pkt->max_adver_int = max_adver_int; +	for (uint8_t i = 0; i < numip; i++) +		memcpy(&pkt->addrs[i].v4, ips[i], addrsz); +	/* FIXME */ +	pkt->cksum = 0; + +	return pkt; +}  | 
