26 #include <linux/kernel.h>
27 #include <linux/netlink.h>
28 #include <linux/phonet.h>
29 #include <linux/slab.h>
47 err = fill_addr(skb, dev, addr, 0, 0, event);
78 err = nlmsg_parse(nlh,
sizeof(*ifm), tb,
IFA_MAX, ifa_phonet_policy);
82 ifm = nlmsg_data(nlh);
109 nlh = nlmsg_put(skb, portid, seq, event,
sizeof(*ifm), 0);
113 ifm = nlmsg_data(nlh);
120 goto nla_put_failure;
121 return nlmsg_end(skb, nlh);
124 nlmsg_cancel(skb, nlh);
132 int dev_idx = 0, dev_start_idx = cb->
args[0];
133 int addr_idx = 0, addr_start_idx = cb->
args[1];
137 list_for_each_entry_rcu(pnd, &pndevs->
list,
list) {
140 if (dev_idx > dev_start_idx)
142 if (dev_idx++ < dev_start_idx)
147 if (addr_idx++ < addr_start_idx)
150 if (fill_addr(skb, pnd->
netdev, addr << 2,
159 cb->
args[0] = dev_idx;
160 cb->
args[1] = addr_idx;
168 u32 portid,
u32 seq,
int event)
173 nlh = nlmsg_put(skb, portid, seq, event,
sizeof(*rtm), 0);
177 rtm = nlmsg_data(nlh);
187 if (nla_put_u8(skb,
RTA_DST, dst) ||
189 goto nla_put_failure;
190 return nlmsg_end(skb, nlh);
193 nlmsg_cancel(skb, nlh);
203 nla_total_size(1) + nla_total_size(4),
GFP_KERNEL);
206 err = fill_route(skb, dev, dst, 0, 0, event);
224 static int route_doit(
struct sk_buff *skb,
struct nlmsghdr *nlh,
void *attr)
226 struct net *net = sock_net(skb->
sk);
238 err = nlmsg_parse(nlh,
sizeof(*rtm), tb,
RTA_MAX, rtm_phonet_policy);
242 rtm = nlmsg_data(nlh);
266 struct net *net = sock_net(skb->
sk);
267 u8 addr, addr_idx = 0, addr_start_idx = cb->
args[0];
270 for (addr = 0; addr < 64; addr++) {
277 if (addr_idx++ < addr_start_idx)
279 if (fill_route(skb, dev, addr << 2,
NETLINK_CB(cb->
skb).portid,
286 cb->
args[0] = addr_idx;