diff options
Diffstat (limited to 'net/mac802154/cfg.c')
| -rw-r--r-- | net/mac802154/cfg.c | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c index c865ebb2ace2..57b5e94471af 100644 --- a/net/mac802154/cfg.c +++ b/net/mac802154/cfg.c | |||
| @@ -266,6 +266,195 @@ ieee802154_set_ackreq_default(struct wpan_phy *wpan_phy, | |||
| 266 | return 0; | 266 | return 0; |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL | ||
| 270 | static void | ||
| 271 | ieee802154_get_llsec_table(struct wpan_phy *wpan_phy, | ||
| 272 | struct wpan_dev *wpan_dev, | ||
| 273 | struct ieee802154_llsec_table **table) | ||
| 274 | { | ||
| 275 | struct net_device *dev = wpan_dev->netdev; | ||
| 276 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 277 | |||
| 278 | *table = &sdata->sec.table; | ||
| 279 | } | ||
| 280 | |||
| 281 | static void | ||
| 282 | ieee802154_lock_llsec_table(struct wpan_phy *wpan_phy, | ||
| 283 | struct wpan_dev *wpan_dev) | ||
| 284 | { | ||
| 285 | struct net_device *dev = wpan_dev->netdev; | ||
| 286 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 287 | |||
| 288 | mutex_lock(&sdata->sec_mtx); | ||
| 289 | } | ||
| 290 | |||
| 291 | static void | ||
| 292 | ieee802154_unlock_llsec_table(struct wpan_phy *wpan_phy, | ||
| 293 | struct wpan_dev *wpan_dev) | ||
| 294 | { | ||
| 295 | struct net_device *dev = wpan_dev->netdev; | ||
| 296 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 297 | |||
| 298 | mutex_unlock(&sdata->sec_mtx); | ||
| 299 | } | ||
| 300 | |||
| 301 | static int | ||
| 302 | ieee802154_set_llsec_params(struct wpan_phy *wpan_phy, | ||
| 303 | struct wpan_dev *wpan_dev, | ||
| 304 | const struct ieee802154_llsec_params *params, | ||
| 305 | int changed) | ||
| 306 | { | ||
| 307 | struct net_device *dev = wpan_dev->netdev; | ||
| 308 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 309 | int res; | ||
| 310 | |||
| 311 | mutex_lock(&sdata->sec_mtx); | ||
| 312 | res = mac802154_llsec_set_params(&sdata->sec, params, changed); | ||
| 313 | mutex_unlock(&sdata->sec_mtx); | ||
| 314 | |||
| 315 | return res; | ||
| 316 | } | ||
| 317 | |||
| 318 | static int | ||
| 319 | ieee802154_get_llsec_params(struct wpan_phy *wpan_phy, | ||
| 320 | struct wpan_dev *wpan_dev, | ||
| 321 | struct ieee802154_llsec_params *params) | ||
| 322 | { | ||
| 323 | struct net_device *dev = wpan_dev->netdev; | ||
| 324 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 325 | int res; | ||
| 326 | |||
| 327 | mutex_lock(&sdata->sec_mtx); | ||
| 328 | res = mac802154_llsec_get_params(&sdata->sec, params); | ||
| 329 | mutex_unlock(&sdata->sec_mtx); | ||
| 330 | |||
| 331 | return res; | ||
| 332 | } | ||
| 333 | |||
| 334 | static int | ||
| 335 | ieee802154_add_llsec_key(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
| 336 | const struct ieee802154_llsec_key_id *id, | ||
| 337 | const struct ieee802154_llsec_key *key) | ||
| 338 | { | ||
| 339 | struct net_device *dev = wpan_dev->netdev; | ||
| 340 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 341 | int res; | ||
| 342 | |||
| 343 | mutex_lock(&sdata->sec_mtx); | ||
| 344 | res = mac802154_llsec_key_add(&sdata->sec, id, key); | ||
| 345 | mutex_unlock(&sdata->sec_mtx); | ||
| 346 | |||
| 347 | return res; | ||
| 348 | } | ||
| 349 | |||
| 350 | static int | ||
| 351 | ieee802154_del_llsec_key(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
| 352 | const struct ieee802154_llsec_key_id *id) | ||
| 353 | { | ||
| 354 | struct net_device *dev = wpan_dev->netdev; | ||
| 355 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 356 | int res; | ||
| 357 | |||
| 358 | mutex_lock(&sdata->sec_mtx); | ||
| 359 | res = mac802154_llsec_key_del(&sdata->sec, id); | ||
| 360 | mutex_unlock(&sdata->sec_mtx); | ||
| 361 | |||
| 362 | return res; | ||
| 363 | } | ||
| 364 | |||
| 365 | static int | ||
| 366 | ieee802154_add_seclevel(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
| 367 | const struct ieee802154_llsec_seclevel *sl) | ||
| 368 | { | ||
| 369 | struct net_device *dev = wpan_dev->netdev; | ||
| 370 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 371 | int res; | ||
| 372 | |||
| 373 | mutex_lock(&sdata->sec_mtx); | ||
| 374 | res = mac802154_llsec_seclevel_add(&sdata->sec, sl); | ||
| 375 | mutex_unlock(&sdata->sec_mtx); | ||
| 376 | |||
| 377 | return res; | ||
| 378 | } | ||
| 379 | |||
| 380 | static int | ||
| 381 | ieee802154_del_seclevel(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
| 382 | const struct ieee802154_llsec_seclevel *sl) | ||
| 383 | { | ||
| 384 | struct net_device *dev = wpan_dev->netdev; | ||
| 385 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 386 | int res; | ||
| 387 | |||
| 388 | mutex_lock(&sdata->sec_mtx); | ||
| 389 | res = mac802154_llsec_seclevel_del(&sdata->sec, sl); | ||
| 390 | mutex_unlock(&sdata->sec_mtx); | ||
| 391 | |||
| 392 | return res; | ||
| 393 | } | ||
| 394 | |||
| 395 | static int | ||
| 396 | ieee802154_add_device(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
| 397 | const struct ieee802154_llsec_device *dev_desc) | ||
| 398 | { | ||
| 399 | struct net_device *dev = wpan_dev->netdev; | ||
| 400 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 401 | int res; | ||
| 402 | |||
| 403 | mutex_lock(&sdata->sec_mtx); | ||
| 404 | res = mac802154_llsec_dev_add(&sdata->sec, dev_desc); | ||
| 405 | mutex_unlock(&sdata->sec_mtx); | ||
| 406 | |||
| 407 | return res; | ||
| 408 | } | ||
| 409 | |||
| 410 | static int | ||
| 411 | ieee802154_del_device(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
| 412 | __le64 extended_addr) | ||
| 413 | { | ||
| 414 | struct net_device *dev = wpan_dev->netdev; | ||
| 415 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 416 | int res; | ||
| 417 | |||
| 418 | mutex_lock(&sdata->sec_mtx); | ||
| 419 | res = mac802154_llsec_dev_del(&sdata->sec, extended_addr); | ||
| 420 | mutex_unlock(&sdata->sec_mtx); | ||
| 421 | |||
| 422 | return res; | ||
| 423 | } | ||
| 424 | |||
| 425 | static int | ||
| 426 | ieee802154_add_devkey(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
| 427 | __le64 extended_addr, | ||
| 428 | const struct ieee802154_llsec_device_key *key) | ||
| 429 | { | ||
| 430 | struct net_device *dev = wpan_dev->netdev; | ||
| 431 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 432 | int res; | ||
| 433 | |||
| 434 | mutex_lock(&sdata->sec_mtx); | ||
| 435 | res = mac802154_llsec_devkey_add(&sdata->sec, extended_addr, key); | ||
| 436 | mutex_unlock(&sdata->sec_mtx); | ||
| 437 | |||
| 438 | return res; | ||
| 439 | } | ||
| 440 | |||
| 441 | static int | ||
| 442 | ieee802154_del_devkey(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | ||
| 443 | __le64 extended_addr, | ||
| 444 | const struct ieee802154_llsec_device_key *key) | ||
| 445 | { | ||
| 446 | struct net_device *dev = wpan_dev->netdev; | ||
| 447 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 448 | int res; | ||
| 449 | |||
| 450 | mutex_lock(&sdata->sec_mtx); | ||
| 451 | res = mac802154_llsec_devkey_del(&sdata->sec, extended_addr, key); | ||
| 452 | mutex_unlock(&sdata->sec_mtx); | ||
| 453 | |||
| 454 | return res; | ||
| 455 | } | ||
| 456 | #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */ | ||
| 457 | |||
| 269 | const struct cfg802154_ops mac802154_config_ops = { | 458 | const struct cfg802154_ops mac802154_config_ops = { |
| 270 | .add_virtual_intf_deprecated = ieee802154_add_iface_deprecated, | 459 | .add_virtual_intf_deprecated = ieee802154_add_iface_deprecated, |
| 271 | .del_virtual_intf_deprecated = ieee802154_del_iface_deprecated, | 460 | .del_virtual_intf_deprecated = ieee802154_del_iface_deprecated, |
| @@ -284,4 +473,20 @@ const struct cfg802154_ops mac802154_config_ops = { | |||
| 284 | .set_max_frame_retries = ieee802154_set_max_frame_retries, | 473 | .set_max_frame_retries = ieee802154_set_max_frame_retries, |
| 285 | .set_lbt_mode = ieee802154_set_lbt_mode, | 474 | .set_lbt_mode = ieee802154_set_lbt_mode, |
| 286 | .set_ackreq_default = ieee802154_set_ackreq_default, | 475 | .set_ackreq_default = ieee802154_set_ackreq_default, |
| 476 | #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL | ||
| 477 | .get_llsec_table = ieee802154_get_llsec_table, | ||
| 478 | .lock_llsec_table = ieee802154_lock_llsec_table, | ||
| 479 | .unlock_llsec_table = ieee802154_unlock_llsec_table, | ||
| 480 | /* TODO above */ | ||
| 481 | .set_llsec_params = ieee802154_set_llsec_params, | ||
| 482 | .get_llsec_params = ieee802154_get_llsec_params, | ||
| 483 | .add_llsec_key = ieee802154_add_llsec_key, | ||
| 484 | .del_llsec_key = ieee802154_del_llsec_key, | ||
| 485 | .add_seclevel = ieee802154_add_seclevel, | ||
| 486 | .del_seclevel = ieee802154_del_seclevel, | ||
| 487 | .add_device = ieee802154_add_device, | ||
| 488 | .del_device = ieee802154_del_device, | ||
| 489 | .add_devkey = ieee802154_add_devkey, | ||
| 490 | .del_devkey = ieee802154_del_devkey, | ||
| 491 | #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */ | ||
| 287 | }; | 492 | }; |
