/include/net/nexthop.h
C++ Header | 33 lines | 26 code | 7 blank | 0 comment | 0 complexity | 2b550bc47806360a7b030e3e6f61a5f1 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
1#ifndef __NET_NEXTHOP_H 2#define __NET_NEXTHOP_H 3 4#include <linux/rtnetlink.h> 5#include <net/netlink.h> 6 7static inline int rtnh_ok(const struct rtnexthop *rtnh, int remaining) 8{ 9 return remaining >= sizeof(*rtnh) && 10 rtnh->rtnh_len >= sizeof(*rtnh) && 11 rtnh->rtnh_len <= remaining; 12} 13 14static inline struct rtnexthop *rtnh_next(const struct rtnexthop *rtnh, 15 int *remaining) 16{ 17 int totlen = NLA_ALIGN(rtnh->rtnh_len); 18 19 *remaining -= totlen; 20 return (struct rtnexthop *) ((char *) rtnh + totlen); 21} 22 23static inline struct nlattr *rtnh_attrs(const struct rtnexthop *rtnh) 24{ 25 return (struct nlattr *) ((char *) rtnh + NLA_ALIGN(sizeof(*rtnh))); 26} 27 28static inline int rtnh_attrlen(const struct rtnexthop *rtnh) 29{ 30 return rtnh->rtnh_len - NLA_ALIGN(sizeof(*rtnh)); 31} 32 33#endif