Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __NET_RTNH_H
0003 #define __NET_RTNH_H
0004 
0005 #include <linux/rtnetlink.h>
0006 #include <net/netlink.h>
0007 
0008 static inline int rtnh_ok(const struct rtnexthop *rtnh, int remaining)
0009 {
0010     return remaining >= (int)sizeof(*rtnh) &&
0011            rtnh->rtnh_len >= sizeof(*rtnh) &&
0012            rtnh->rtnh_len <= remaining;
0013 }
0014 
0015 static inline struct rtnexthop *rtnh_next(const struct rtnexthop *rtnh,
0016                                          int *remaining)
0017 {
0018     int totlen = NLA_ALIGN(rtnh->rtnh_len);
0019 
0020     *remaining -= totlen;
0021     return (struct rtnexthop *) ((char *) rtnh + totlen);
0022 }
0023 
0024 static inline struct nlattr *rtnh_attrs(const struct rtnexthop *rtnh)
0025 {
0026     return (struct nlattr *) ((char *) rtnh + NLA_ALIGN(sizeof(*rtnh)));
0027 }
0028 
0029 static inline int rtnh_attrlen(const struct rtnexthop *rtnh)
0030 {
0031     return rtnh->rtnh_len - NLA_ALIGN(sizeof(*rtnh));
0032 }
0033 
0034 #endif