1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #pragma once 3 4 /*** 5 Copyright © 2014 Intel Corporation. All rights reserved. 6 ***/ 7 8 #include "sd-ndisc.h" 9 10 #include "time-util.h" 11 12 struct sd_ndisc_router { 13 unsigned n_ref; 14 15 triple_timestamp timestamp; 16 struct in6_addr address; 17 18 /* The raw packet size. The data is appended to the object, accessible via NDIS_ROUTER_RAW() */ 19 size_t raw_size; 20 21 /* The current read index for the iterative option interface */ 22 size_t rindex; 23 24 uint64_t flags; 25 unsigned preference; 26 uint16_t lifetime; 27 28 uint8_t hop_limit; 29 uint32_t mtu; 30 }; 31 NDISC_ROUTER_RAW(const sd_ndisc_router * rt)32static inline void* NDISC_ROUTER_RAW(const sd_ndisc_router *rt) { 33 return (uint8_t*) rt + ALIGN(sizeof(sd_ndisc_router)); 34 } 35 NDISC_ROUTER_OPTION_DATA(const sd_ndisc_router * rt)36static inline void *NDISC_ROUTER_OPTION_DATA(const sd_ndisc_router *rt) { 37 return ((uint8_t*) NDISC_ROUTER_RAW(rt)) + rt->rindex; 38 } 39 NDISC_ROUTER_OPTION_TYPE(const sd_ndisc_router * rt)40static inline uint8_t NDISC_ROUTER_OPTION_TYPE(const sd_ndisc_router *rt) { 41 return ((uint8_t*) NDISC_ROUTER_OPTION_DATA(rt))[0]; 42 } NDISC_ROUTER_OPTION_LENGTH(const sd_ndisc_router * rt)43static inline size_t NDISC_ROUTER_OPTION_LENGTH(const sd_ndisc_router *rt) { 44 return ((uint8_t*) NDISC_ROUTER_OPTION_DATA(rt))[1] * 8; 45 } 46 47 sd_ndisc_router *ndisc_router_new(size_t raw_size); 48 int ndisc_router_parse(sd_ndisc *nd, sd_ndisc_router *rt); 49