diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-12-07 23:36:09 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-05-17 00:27:08 +0000 |
| commit | 3eca38577afdd262e72740f16e0b1a6057d0aed6 (patch) | |
| tree | a491a53717d07415459b53deb603b046ef66176b /vrrpd/vrrp_packet.h | |
| parent | ef4cc1ebfffaf74c303fd1b5c96d739f08766751 (diff) | |
vrrpd: fix packet encode
* Properly encode VRRP packets
* Calculate checksum appropriately
* Update signature to provide caller both packet and result length
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'vrrpd/vrrp_packet.h')
| -rw-r--r-- | vrrpd/vrrp_packet.h | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/vrrpd/vrrp_packet.h b/vrrpd/vrrp_packet.h index 5ff08f95fe..245fada064 100644 --- a/vrrpd/vrrp_packet.h +++ b/vrrpd/vrrp_packet.h @@ -30,8 +30,12 @@ * Shared header for VRRPv2/v3 packets. */ struct vrrp_hdr { - uint8_t version : 4; - uint8_t type : 4; + /* + * H L H L + * 0000 0000 + * ver type + */ + uint8_t vertype; uint8_t vrid; uint8_t priority; uint8_t naddr; @@ -42,9 +46,13 @@ struct vrrp_hdr { uint8_t adver_int; } v2; struct { - /* advertisement interval (in centiseconds) */ - uint16_t rsvd : 4; - uint16_t adver_int : 12; + /* + * advertisement interval (in centiseconds) + * H L H L + * 0000 000000000000 + * rsvd adver_int + */ + uint16_t adver_int; } v3; }; uint16_t chksum; @@ -60,7 +68,29 @@ struct vrrp_pkt { /* * Builds a VRRP packet. + * + * pkt + * Pointer to store pointer to result buffer in + * + * vrid + * Virtual Router Identifier + * + * prio + * Virtual Router Priority + * + * max_adver_int + * time between ADVERTISEMENTs + * + * v6 + * whether 'ips' is an array of v4 or v6 addresses + * + * numip + * number of IPvX addresses in 'ips' + * + * ips + * array of pointer to either struct in_addr (v6 = false) or struct in6_addr + * (v6 = true) */ -struct vrrp_pkt *vrrp_pkt_build(uint8_t vrid, uint8_t prio, - uint16_t max_adver_int, bool v6, uint8_t numip, - void **ips); +ssize_t vrrp_pkt_build(struct vrrp_pkt **pkt, uint8_t vrid, uint8_t prio, + uint16_t max_adver_int, bool v6, uint8_t numip, + void **ips); |
