Line data Source code
1 : /* SPDX-License-Identifier: LGPL-2.1+ */ 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 : 32 210 : static inline void* NDISC_ROUTER_RAW(const sd_ndisc_router *rt) { 33 210 : return (uint8_t*) rt + ALIGN(sizeof(sd_ndisc_router)); 34 : } 35 : 36 145 : static inline void *NDISC_ROUTER_OPTION_DATA(const sd_ndisc_router *rt) { 37 145 : return ((uint8_t*) NDISC_ROUTER_RAW(rt)) + rt->rindex; 38 : } 39 : 40 65 : static inline uint8_t NDISC_ROUTER_OPTION_TYPE(const sd_ndisc_router *rt) { 41 65 : return ((uint8_t*) NDISC_ROUTER_OPTION_DATA(rt))[0]; 42 : } 43 80 : static inline size_t NDISC_ROUTER_OPTION_LENGTH(const sd_ndisc_router *rt) { 44 80 : 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_router *rt);