net/ieee802154/6lowpan/core.c
Source file repositories/reference/linux-study-clean/net/ieee802154/6lowpan/core.c
File Facts
- System
- Linux kernel
- Corpus path
net/ieee802154/6lowpan/core.c- Extension
.c- Size
- 8009 bytes
- Lines
- 290
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/netdevice.hlinux/ieee802154.hlinux/if_arp.hnet/ipv6.hnet/netdev_lock.h6lowpan_i.h
Detected Declarations
function lowpan_dev_initfunction lowpan_openfunction lowpan_stopfunction lowpan_neigh_constructfunction lowpan_get_iflinkfunction lowpan_setupfunction lowpan_validatefunction lowpan_newlinkfunction lowpan_dellinkfunction lowpan_netlink_initfunction lowpan_netlink_finifunction lowpan_device_eventfunction lowpan_init_modulefunction lowpan_cleanup_modulemodule init lowpan_init_module
Annotated Snippet
static const struct net_device_ops lowpan_netdev_ops = {
.ndo_init = lowpan_dev_init,
.ndo_start_xmit = lowpan_xmit,
.ndo_open = lowpan_open,
.ndo_stop = lowpan_stop,
.ndo_neigh_construct = lowpan_neigh_construct,
.ndo_get_iflink = lowpan_get_iflink,
};
static void lowpan_setup(struct net_device *ldev)
{
memset(ldev->broadcast, 0xff, IEEE802154_ADDR_LEN);
/* We need an ipv6hdr as minimum len when calling xmit */
ldev->hard_header_len = sizeof(struct ipv6hdr);
ldev->flags = IFF_BROADCAST | IFF_MULTICAST;
ldev->priv_flags |= IFF_NO_QUEUE;
ldev->netdev_ops = &lowpan_netdev_ops;
ldev->header_ops = &lowpan_header_ops;
ldev->needs_free_netdev = true;
ldev->netns_immutable = true;
}
static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack)
{
if (tb[IFLA_ADDRESS]) {
if (nla_len(tb[IFLA_ADDRESS]) != IEEE802154_ADDR_LEN)
return -EINVAL;
}
return 0;
}
static int lowpan_newlink(struct net_device *ldev,
struct rtnl_newlink_params *params,
struct netlink_ext_ack *extack)
{
struct nlattr **tb = params->tb;
struct net_device *wdev;
int ret;
ASSERT_RTNL();
pr_debug("adding new link\n");
if (!tb[IFLA_LINK])
return -EINVAL;
if (params->link_net && !net_eq(params->link_net, dev_net(ldev)))
return -EINVAL;
/* find and hold wpan device */
wdev = dev_get_by_index(dev_net(ldev), nla_get_u32(tb[IFLA_LINK]));
if (!wdev)
return -ENODEV;
if (wdev->type != ARPHRD_IEEE802154) {
dev_put(wdev);
return -EINVAL;
}
if (wdev->ieee802154_ptr->lowpan_dev) {
dev_put(wdev);
return -EBUSY;
}
lowpan_802154_dev(ldev)->wdev = wdev;
/* Set the lowpan hardware address to the wpan hardware address. */
__dev_addr_set(ldev, wdev->dev_addr, IEEE802154_ADDR_LEN);
/* We need headroom for possible wpan_dev_hard_header call and tailroom
* for encryption/fcs handling. The lowpan interface will replace
* the IPv6 header with 6LoWPAN header. At worst case the 6LoWPAN
* header has LOWPAN_IPHC_MAX_HEADER_LEN more bytes than the IPv6
* header.
*/
ldev->needed_headroom = LOWPAN_IPHC_MAX_HEADER_LEN +
wdev->needed_headroom;
ldev->needed_tailroom = wdev->needed_tailroom;
ldev->neigh_priv_len = sizeof(struct lowpan_802154_neigh);
ret = lowpan_register_netdevice(ldev, LOWPAN_LLTYPE_IEEE802154);
if (ret < 0) {
dev_put(wdev);
return ret;
}
wdev->ieee802154_ptr->lowpan_dev = ldev;
return 0;
}
static void lowpan_dellink(struct net_device *ldev, struct list_head *head)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/netdevice.h`, `linux/ieee802154.h`, `linux/if_arp.h`, `net/ipv6.h`, `net/netdev_lock.h`, `6lowpan_i.h`.
- Detected declarations: `function lowpan_dev_init`, `function lowpan_open`, `function lowpan_stop`, `function lowpan_neigh_construct`, `function lowpan_get_iflink`, `function lowpan_setup`, `function lowpan_validate`, `function lowpan_newlink`, `function lowpan_dellink`, `function lowpan_netlink_init`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
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.