17#include "nl-default.h"
19#include <netlink/route/link/ppp.h>
20#include <netlink/netlink.h>
26#define PPP_ATTR_FD (1<<0)
36static struct nla_policy ppp_nl_policy[IFLA_PPP_MAX+1] = {
37 [IFLA_PPP_DEV_FD] = { .
type = NLA_S32 },
40static int ppp_alloc(
struct rtnl_link *link)
42 struct ppp_info *info;
45 memset(link->l_info, 0,
sizeof(*info));
47 if ((info = calloc(1,
sizeof(*info))) == NULL)
56static int ppp_parse(
struct rtnl_link *link,
struct nlattr *data,
57 struct nlattr *xstats)
59 struct nlattr *tb[IFLA_PPP_MAX+1];
60 struct ppp_info *info;
63 NL_DBG(3,
"Parsing PPP link info\n");
68 if ((err = ppp_alloc(link)) < 0)
73 if (tb[IFLA_PPP_DEV_FD]) {
75 info->ce_mask |= PPP_ATTR_FD;
83static void ppp_free(
struct rtnl_link *link)
91 struct ppp_info *vdst, *vsrc = src->l_info;
102 memcpy(vdst, vsrc,
sizeof(
struct ppp_info));
107static int ppp_put_attrs(
struct nl_msg *msg,
struct rtnl_link *link)
109 struct ppp_info *info = link->l_info;
115 if (info->ce_mask & PPP_ATTR_FD)
127 .io_alloc = ppp_alloc,
128 .io_parse = ppp_parse,
129 .io_clone = ppp_clone,
130 .io_put_attrs = ppp_put_attrs,
135#define IS_PPP_LINK_ASSERT(link) \
136 if ((link)->l_info_ops != &ppp_info_ops) { \
137 APPBUG("Link is not a PPP link. set type \"ppp\" first."); \
138 return -NLE_OPNOTSUPP; \
176 struct ppp_info *info = link->l_info;
178 IS_PPP_LINK_ASSERT(link);
181 info->ce_mask |= PPP_ATTR_FD;
194 struct ppp_info *info = link->l_info;
196 IS_PPP_LINK_ASSERT(link);
198 if (!(info->ce_mask & PPP_ATTR_FD))
209static void _nl_init ppp_init(
void)
214static void _nl_exit ppp_exit(
void)
#define NLA_PUT_S32(msg, attrtype, value)
Add 32 bit signed integer attribute to netlink message.
struct nlattr * nla_nest_start(struct nl_msg *msg, int attrtype)
Start a new level of nested attributes.
int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, const struct nla_policy *policy)
Create attribute index based on nested attribute.
int32_t nla_get_s32(const struct nlattr *nla)
Return payload of 32 bit signed integer attribute.
int nla_nest_end(struct nl_msg *msg, struct nlattr *start)
Finalize nesting of attributes.
int rtnl_link_register_info(struct rtnl_link_info_ops *ops)
Register operations for a link info type.
int rtnl_link_unregister_info(struct rtnl_link_info_ops *ops)
Unregister operations for a link info type.
struct rtnl_link * rtnl_link_alloc(void)
Allocate link object.
void rtnl_link_put(struct rtnl_link *link)
Release a link object reference.
int rtnl_link_set_type(struct rtnl_link *link, const char *type)
Set type of link object.
int rtnl_link_ppp_get_fd(struct rtnl_link *link, int32_t *fd)
Get PPP file descriptor.
int rtnl_link_ppp_set_fd(struct rtnl_link *link, int32_t fd)
Set PPP file descriptor.
struct rtnl_link * rtnl_link_ppp_alloc(void)
Allocate link object of type PPP.
Attribute validation policy.
uint16_t type
Type of attribute or NLA_UNSPEC.
Available operations to modules implementing a link info type.
char * io_name
Name of link info type, must match name on kernel side.