net/ieee802154/header_ops.c
Source file repositories/reference/linux-study-clean/net/ieee802154/header_ops.c
File Facts
- System
- Linux kernel
- Corpus path
net/ieee802154/header_ops.c- Extension
.c- Size
- 8014 bytes
- Lines
- 379
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ieee802154.hnet/mac802154.hnet/ieee802154_netdev.h
Detected Declarations
function Copyrightfunction ieee802154_hdr_push_sechdrfunction ieee802154_hdr_pushfunction ieee802154_mac_cmd_pushfunction ieee802154_beacon_pushfunction ieee802154_hdr_get_addrfunction ieee802154_hdr_addr_lenfunction ieee802154_hdr_get_sechdrfunction ieee802154_hdr_sechdr_lenfunction ieee802154_hdr_minlenfunction ieee802154_hdr_get_addrsfunction ieee802154_hdr_pullfunction ieee802154_mac_cmd_pl_pullfunction ieee802154_hdr_peek_addrsfunction ieee802154_hdr_peekfunction ieee802154_max_payloadexport ieee802154_hdr_pushexport ieee802154_mac_cmd_pushexport ieee802154_beacon_pushexport ieee802154_hdr_pullexport ieee802154_mac_cmd_pl_pullexport ieee802154_hdr_peek_addrsexport ieee802154_hdr_peekexport ieee802154_max_payload
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2014 Fraunhofer ITWM
*
* Written by:
* Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
*/
#include <linux/ieee802154.h>
#include <net/mac802154.h>
#include <net/ieee802154_netdev.h>
static int
ieee802154_hdr_push_addr(u8 *buf, const struct ieee802154_addr *addr,
bool omit_pan)
{
int pos = 0;
if (addr->mode == IEEE802154_ADDR_NONE)
return 0;
if (!omit_pan) {
memcpy(buf + pos, &addr->pan_id, 2);
pos += 2;
}
switch (addr->mode) {
case IEEE802154_ADDR_SHORT:
memcpy(buf + pos, &addr->short_addr, 2);
pos += 2;
break;
case IEEE802154_ADDR_LONG:
memcpy(buf + pos, &addr->extended_addr, IEEE802154_ADDR_LEN);
pos += IEEE802154_ADDR_LEN;
break;
default:
return -EINVAL;
}
return pos;
}
static int
ieee802154_hdr_push_sechdr(u8 *buf, const struct ieee802154_sechdr *hdr)
{
int pos = 5;
memcpy(buf, hdr, 1);
memcpy(buf + 1, &hdr->frame_counter, 4);
switch (hdr->key_id_mode) {
case IEEE802154_SCF_KEY_IMPLICIT:
return pos;
case IEEE802154_SCF_KEY_INDEX:
break;
case IEEE802154_SCF_KEY_SHORT_INDEX:
memcpy(buf + pos, &hdr->short_src, 4);
pos += 4;
break;
case IEEE802154_SCF_KEY_HW_INDEX:
memcpy(buf + pos, &hdr->extended_src, IEEE802154_ADDR_LEN);
pos += IEEE802154_ADDR_LEN;
break;
}
buf[pos++] = hdr->key_id;
return pos;
}
int
ieee802154_hdr_push(struct sk_buff *skb, struct ieee802154_hdr *hdr)
{
u8 buf[IEEE802154_MAX_HEADER_LEN];
int pos = 2;
int rc;
struct ieee802154_hdr_fc *fc = &hdr->fc;
buf[pos++] = hdr->seq;
fc->dest_addr_mode = hdr->dest.mode;
rc = ieee802154_hdr_push_addr(buf + pos, &hdr->dest, false);
if (rc < 0)
Annotation
- Immediate include surface: `linux/ieee802154.h`, `net/mac802154.h`, `net/ieee802154_netdev.h`.
- Detected declarations: `function Copyright`, `function ieee802154_hdr_push_sechdr`, `function ieee802154_hdr_push`, `function ieee802154_mac_cmd_push`, `function ieee802154_beacon_push`, `function ieee802154_hdr_get_addr`, `function ieee802154_hdr_addr_len`, `function ieee802154_hdr_get_sechdr`, `function ieee802154_hdr_sechdr_len`, `function ieee802154_hdr_minlen`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.