net/ieee802154/pan.c
Source file repositories/reference/linux-study-clean/net/ieee802154/pan.c
File Facts
- System
- Linux kernel
- Corpus path
net/ieee802154/pan.c- Extension
.c- Size
- 2699 bytes
- Lines
- 110
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hnet/cfg802154.hnet/af_ieee802154.h
Detected Declarations
function Copyrightfunction cfg802154_device_is_associatedfunction cfg802154_device_is_parentfunction cfg802154_device_is_childfunction cfg802154_get_free_short_addrfunction cfg802154_set_max_associationsexport cfg802154_device_is_parentexport cfg802154_device_is_childexport cfg802154_get_free_short_addrexport cfg802154_set_max_associations
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* IEEE 802.15.4 PAN management
*
* Copyright (C) 2023 Qorvo US, Inc
* Authors:
* - David Girault <david.girault@qorvo.com>
* - Miquel Raynal <miquel.raynal@bootlin.com>
*/
#include <linux/kernel.h>
#include <net/cfg802154.h>
#include <net/af_ieee802154.h>
/* Checks whether a device address matches one from the PAN list.
* This helper is meant to be used only during PAN management, when we expect
* extended addresses to be used.
*/
static bool cfg802154_pan_device_is_matching(struct ieee802154_pan_device *pan_dev,
struct ieee802154_addr *ext_dev)
{
if (!pan_dev || !ext_dev)
return false;
if (ext_dev->mode == IEEE802154_ADDR_SHORT)
return false;
return pan_dev->extended_addr == ext_dev->extended_addr;
}
bool cfg802154_device_is_associated(struct wpan_dev *wpan_dev)
{
bool is_assoc;
mutex_lock(&wpan_dev->association_lock);
is_assoc = !list_empty(&wpan_dev->children) || wpan_dev->parent;
mutex_unlock(&wpan_dev->association_lock);
return is_assoc;
}
bool cfg802154_device_is_parent(struct wpan_dev *wpan_dev,
struct ieee802154_addr *target)
{
lockdep_assert_held(&wpan_dev->association_lock);
return cfg802154_pan_device_is_matching(wpan_dev->parent, target);
}
EXPORT_SYMBOL_GPL(cfg802154_device_is_parent);
struct ieee802154_pan_device *
cfg802154_device_is_child(struct wpan_dev *wpan_dev,
struct ieee802154_addr *target)
{
struct ieee802154_pan_device *child;
lockdep_assert_held(&wpan_dev->association_lock);
list_for_each_entry(child, &wpan_dev->children, node)
if (cfg802154_pan_device_is_matching(child, target))
return child;
return NULL;
}
EXPORT_SYMBOL_GPL(cfg802154_device_is_child);
__le16 cfg802154_get_free_short_addr(struct wpan_dev *wpan_dev)
{
struct ieee802154_pan_device *child;
__le16 addr;
lockdep_assert_held(&wpan_dev->association_lock);
do {
get_random_bytes(&addr, 2);
if (addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST) ||
addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC))
continue;
if (wpan_dev->short_addr == addr)
continue;
if (wpan_dev->parent && wpan_dev->parent->short_addr == addr)
continue;
list_for_each_entry(child, &wpan_dev->children, node)
if (child->short_addr == addr)
continue;
break;
Annotation
- Immediate include surface: `linux/kernel.h`, `net/cfg802154.h`, `net/af_ieee802154.h`.
- Detected declarations: `function Copyright`, `function cfg802154_device_is_associated`, `function cfg802154_device_is_parent`, `function cfg802154_device_is_child`, `function cfg802154_get_free_short_addr`, `function cfg802154_set_max_associations`, `export cfg802154_device_is_parent`, `export cfg802154_device_is_child`, `export cfg802154_get_free_short_addr`, `export cfg802154_set_max_associations`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.