nl-phy.c (15a892e728299c5879187c8301c10c14af399a0c) | nl-phy.c (4a9a816a4f8c79260446811bdf80615b36539949) |
---|---|
1/* 2 * Netlink inteface for IEEE 802.15.4 stack 3 * 4 * Copyright 2007, 2008 Siemens AG 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 8 * as published by the Free Software Foundation. --- 16 unchanged lines hidden (view full) --- 25#include <net/genetlink.h> 26#include <net/cfg802154.h> 27#include <net/af_ieee802154.h> 28#include <net/ieee802154_netdev.h> 29#include <net/rtnetlink.h> /* for rtnl_{un,}lock */ 30#include <linux/nl802154.h> 31 32#include "ieee802154.h" | 1/* 2 * Netlink inteface for IEEE 802.15.4 stack 3 * 4 * Copyright 2007, 2008 Siemens AG 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 8 * as published by the Free Software Foundation. --- 16 unchanged lines hidden (view full) --- 25#include <net/genetlink.h> 26#include <net/cfg802154.h> 27#include <net/af_ieee802154.h> 28#include <net/ieee802154_netdev.h> 29#include <net/rtnetlink.h> /* for rtnl_{un,}lock */ 30#include <linux/nl802154.h> 31 32#include "ieee802154.h" |
33#include "rdev-ops.h" 34#include "core.h" |
|
33 34static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid, 35 u32 seq, int flags, struct wpan_phy *phy) 36{ 37 void *hdr; 38 int i, pages = 0; 39 uint32_t *buf = kzalloc(32 * sizeof(uint32_t), GFP_KERNEL); 40 --- 157 unchanged lines hidden (view full) --- 198 phy = wpan_phy_find(name); 199 if (!phy) 200 return -ENODEV; 201 202 msg = ieee802154_nl_new_reply(info, 0, IEEE802154_ADD_IFACE); 203 if (!msg) 204 goto out_dev; 205 | 35 36static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid, 37 u32 seq, int flags, struct wpan_phy *phy) 38{ 39 void *hdr; 40 int i, pages = 0; 41 uint32_t *buf = kzalloc(32 * sizeof(uint32_t), GFP_KERNEL); 42 --- 157 unchanged lines hidden (view full) --- 200 phy = wpan_phy_find(name); 201 if (!phy) 202 return -ENODEV; 203 204 msg = ieee802154_nl_new_reply(info, 0, IEEE802154_ADD_IFACE); 205 if (!msg) 206 goto out_dev; 207 |
206 if (!phy->add_iface) { 207 rc = -EINVAL; 208 goto nla_put_failure; 209 } 210 | |
211 if (info->attrs[IEEE802154_ATTR_HW_ADDR] && 212 nla_len(info->attrs[IEEE802154_ATTR_HW_ADDR]) != 213 IEEE802154_ADDR_LEN) { 214 rc = -EINVAL; 215 goto nla_put_failure; 216 } 217 218 if (info->attrs[IEEE802154_ATTR_DEV_TYPE]) { 219 type = nla_get_u8(info->attrs[IEEE802154_ATTR_DEV_TYPE]); 220 if (type >= __IEEE802154_DEV_MAX) { 221 rc = -EINVAL; 222 goto nla_put_failure; 223 } 224 } 225 | 208 if (info->attrs[IEEE802154_ATTR_HW_ADDR] && 209 nla_len(info->attrs[IEEE802154_ATTR_HW_ADDR]) != 210 IEEE802154_ADDR_LEN) { 211 rc = -EINVAL; 212 goto nla_put_failure; 213 } 214 215 if (info->attrs[IEEE802154_ATTR_DEV_TYPE]) { 216 type = nla_get_u8(info->attrs[IEEE802154_ATTR_DEV_TYPE]); 217 if (type >= __IEEE802154_DEV_MAX) { 218 rc = -EINVAL; 219 goto nla_put_failure; 220 } 221 } 222 |
226 dev = phy->add_iface(phy, devname, type); | 223 dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname, 224 type); |
227 if (IS_ERR(dev)) { 228 rc = PTR_ERR(dev); 229 goto nla_put_failure; 230 } 231 232 if (info->attrs[IEEE802154_ATTR_HW_ADDR]) { 233 struct sockaddr addr; 234 --- 17 unchanged lines hidden (view full) --- 252 dev_put(dev); 253 254 wpan_phy_put(phy); 255 256 return ieee802154_nl_reply(msg, info); 257 258dev_unregister: 259 rtnl_lock(); /* del_iface must be called with RTNL lock */ | 225 if (IS_ERR(dev)) { 226 rc = PTR_ERR(dev); 227 goto nla_put_failure; 228 } 229 230 if (info->attrs[IEEE802154_ATTR_HW_ADDR]) { 231 struct sockaddr addr; 232 --- 17 unchanged lines hidden (view full) --- 250 dev_put(dev); 251 252 wpan_phy_put(phy); 253 254 return ieee802154_nl_reply(msg, info); 255 256dev_unregister: 257 rtnl_lock(); /* del_iface must be called with RTNL lock */ |
260 phy->del_iface(phy, dev); | 258 rdev_del_virtual_intf_deprecated(wpan_phy_to_rdev(phy), dev); |
261 dev_put(dev); 262 rtnl_unlock(); 263nla_put_failure: 264 nlmsg_free(msg); 265out_dev: 266 wpan_phy_put(phy); 267 return rc; 268} --- 45 unchanged lines hidden (view full) --- 314 } 315 316 rc = -ENOBUFS; 317 318 msg = ieee802154_nl_new_reply(info, 0, IEEE802154_DEL_IFACE); 319 if (!msg) 320 goto out_dev; 321 | 259 dev_put(dev); 260 rtnl_unlock(); 261nla_put_failure: 262 nlmsg_free(msg); 263out_dev: 264 wpan_phy_put(phy); 265 return rc; 266} --- 45 unchanged lines hidden (view full) --- 312 } 313 314 rc = -ENOBUFS; 315 316 msg = ieee802154_nl_new_reply(info, 0, IEEE802154_DEL_IFACE); 317 if (!msg) 318 goto out_dev; 319 |
322 if (!phy->del_iface) { 323 rc = -EINVAL; 324 goto nla_put_failure; 325 } 326 | |
327 rtnl_lock(); | 320 rtnl_lock(); |
328 phy->del_iface(phy, dev); | 321 rdev_del_virtual_intf_deprecated(wpan_phy_to_rdev(phy), dev); |
329 330 /* We don't have device anymore */ 331 dev_put(dev); 332 dev = NULL; 333 334 rtnl_unlock(); 335 336 if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || --- 15 unchanged lines hidden --- | 322 323 /* We don't have device anymore */ 324 dev_put(dev); 325 dev = NULL; 326 327 rtnl_unlock(); 328 329 if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || --- 15 unchanged lines hidden --- |