net/ieee802154/6lowpan/tx.c
Source file repositories/reference/linux-study-clean/net/ieee802154/6lowpan/tx.c
File Facts
- System
- Linux kernel
- Corpus path
net/ieee802154/6lowpan/tx.c- Extension
.c- Size
- 8448 bytes
- Lines
- 315
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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 or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/6lowpan.hnet/ndisc.hnet/ieee802154_netdev.hnet/mac802154.h6lowpan_i.h
Detected Declarations
struct lowpan_addr_infofunction DGRAMfunction lowpan_alloc_fragfunction lowpan_xmit_fragmentfunction lowpan_xmit_fragmentedfunction lowpan_headerfunction lowpan_xmitfunction skb_tailroom
Annotated Snippet
struct lowpan_addr_info {
struct ieee802154_addr daddr;
struct ieee802154_addr saddr;
};
static inline struct
lowpan_addr_info *lowpan_skb_priv(const struct sk_buff *skb)
{
WARN_ON_ONCE(skb_headroom(skb) < sizeof(struct lowpan_addr_info));
return (struct lowpan_addr_info *)(skb->data -
sizeof(struct lowpan_addr_info));
}
/* This callback will be called from AF_PACKET and IPv6 stack, the AF_PACKET
* sockets gives an 8 byte array for addresses only!
*
* TODO I think AF_PACKET DGRAM (sending/receiving) RAW (sending) makes no
* sense here. We should disable it, the right use-case would be AF_INET6
* RAW/DGRAM sockets.
*/
int lowpan_header_create(struct sk_buff *skb, struct net_device *ldev,
unsigned short type, const void *daddr,
const void *saddr, unsigned int len)
{
struct wpan_dev *wpan_dev = lowpan_802154_dev(ldev)->wdev->ieee802154_ptr;
struct lowpan_addr_info *info = lowpan_skb_priv(skb);
struct lowpan_802154_neigh *llneigh = NULL;
const struct ipv6hdr *hdr = ipv6_hdr(skb);
struct neighbour *n;
if (!daddr)
return -EINVAL;
/* TODO:
* if this package isn't ipv6 one, where should it be routed?
*/
if (type != ETH_P_IPV6)
return 0;
/* intra-pan communication */
info->saddr.pan_id = wpan_dev->pan_id;
info->daddr.pan_id = info->saddr.pan_id;
if (!memcmp(daddr, ldev->broadcast, EUI64_ADDR_LEN)) {
info->daddr.short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
info->daddr.mode = IEEE802154_ADDR_SHORT;
} else {
__le16 short_addr = cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC);
n = neigh_lookup(&nd_tbl, &hdr->daddr, ldev);
if (n) {
llneigh = lowpan_802154_neigh(neighbour_priv(n));
read_lock_bh(&n->lock);
short_addr = llneigh->short_addr;
read_unlock_bh(&n->lock);
}
if (llneigh &&
lowpan_802154_is_valid_src_short_addr(short_addr)) {
info->daddr.short_addr = short_addr;
info->daddr.mode = IEEE802154_ADDR_SHORT;
} else {
info->daddr.mode = IEEE802154_ADDR_LONG;
ieee802154_be64_to_le64(&info->daddr.extended_addr,
daddr);
}
if (n)
neigh_release(n);
}
if (!saddr) {
if (lowpan_802154_is_valid_src_short_addr(wpan_dev->short_addr)) {
info->saddr.mode = IEEE802154_ADDR_SHORT;
info->saddr.short_addr = wpan_dev->short_addr;
} else {
info->saddr.mode = IEEE802154_ADDR_LONG;
info->saddr.extended_addr = wpan_dev->extended_addr;
}
} else {
info->saddr.mode = IEEE802154_ADDR_LONG;
ieee802154_be64_to_le64(&info->saddr.extended_addr, saddr);
}
return 0;
}
static struct sk_buff*
lowpan_alloc_frag(struct sk_buff *skb, int size,
const struct ieee802154_hdr *master_hdr, bool frag1)
Annotation
- Immediate include surface: `net/6lowpan.h`, `net/ndisc.h`, `net/ieee802154_netdev.h`, `net/mac802154.h`, `6lowpan_i.h`.
- Detected declarations: `struct lowpan_addr_info`, `function DGRAM`, `function lowpan_alloc_frag`, `function lowpan_xmit_fragment`, `function lowpan_xmit_fragmented`, `function lowpan_header`, `function lowpan_xmit`, `function skb_tailroom`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.