net/6lowpan/iphc.c
Source file repositories/reference/linux-study-clean/net/6lowpan/iphc.c
File Facts
- System
- Linux kernel
- Corpus path
net/6lowpan/iphc.c- Extension
.c- Size
- 37568 bytes
- Lines
- 1314
- 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/bitops.hlinux/if_arp.hlinux/netdevice.hnet/6lowpan.hnet/ipv6.h6lowpan_i.hnhc.h
Detected Declarations
function lowpan_iphc_uncompress_802154_lladdrfunction lowpan_iphc_ctx_get_by_idfunction lowpan_iphc_ctx_get_by_addrfunction lowpan_iphc_ctx_get_by_mcast_addrfunction lowpan_iphc_uncompress_lladdrfunction addressfunction addressfunction lowpan_uncompress_multicast_daddrfunction lowpan_uncompress_multicast_ctx_daddrfunction lowpan_iphc_tf_set_ecnfunction lowpan_iphc_tf_set_dscpfunction lowpan_iphc_tf_set_lblfunction lowpan_iphc_tf_decompressfunction lowpan_header_decompressfunction lowpan_iphc_compress_ctx_802154_lladdrfunction lowpan_iphc_addr_equalfunction lowpan_compress_ctx_addrfunction lowpan_iphc_compress_802154_lladdrfunction lowpan_compress_addr_64function lowpan_iphc_get_tcfunction lowpan_iphc_is_flow_lbl_zerofunction lowpan_iphc_tf_compressfunction lowpan_iphc_mcast_ctx_addr_compressfunction lowpan_iphc_mcast_addr_compressfunction lowpan_header_compressexport lowpan_header_decompressexport lowpan_header_compress
Annotated Snippet
if (ipv6_prefix_equal(&addr_pfx, &table[i].pfx, addr_plen)) {
/* remember first match */
if (!ret) {
ret = &table[i];
continue;
}
/* get the context with longest prefix len */
if (table[i].plen > ret->plen)
ret = &table[i];
}
}
return ret;
}
static struct lowpan_iphc_ctx *
lowpan_iphc_ctx_get_by_mcast_addr(const struct net_device *dev,
const struct in6_addr *addr)
{
struct lowpan_iphc_ctx *table = lowpan_dev(dev)->ctx.table;
struct lowpan_iphc_ctx *ret = NULL;
struct in6_addr addr_mcast, network_pfx = {};
int i;
/* init mcast address with */
memcpy(&addr_mcast, addr, sizeof(*addr));
for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++) {
/* Check if context is valid. A context that is not valid
* MUST NOT be used for compression.
*/
if (!lowpan_iphc_ctx_is_active(&table[i]) ||
!lowpan_iphc_ctx_is_compression(&table[i]))
continue;
/* setting plen */
addr_mcast.s6_addr[3] = table[i].plen;
/* get network prefix to copy into multicast address */
ipv6_addr_prefix(&network_pfx, &table[i].pfx,
table[i].plen);
/* setting network prefix */
memcpy(&addr_mcast.s6_addr[4], &network_pfx, 8);
if (ipv6_addr_equal(addr, &addr_mcast)) {
ret = &table[i];
break;
}
}
return ret;
}
static void lowpan_iphc_uncompress_lladdr(const struct net_device *dev,
struct in6_addr *ipaddr,
const void *lladdr)
{
switch (dev->addr_len) {
case ETH_ALEN:
lowpan_iphc_uncompress_eui48_lladdr(ipaddr, lladdr);
break;
case EUI64_ADDR_LEN:
lowpan_iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
break;
default:
WARN_ON_ONCE(1);
break;
}
}
/* Uncompress address function for source and
* destination address(non-multicast).
*
* address_mode is the masked value for sam or dam value
*/
static int lowpan_iphc_uncompress_addr(struct sk_buff *skb,
const struct net_device *dev,
struct in6_addr *ipaddr,
u8 address_mode, const void *lladdr)
{
bool fail;
switch (address_mode) {
/* SAM and DAM are the same here */
case LOWPAN_IPHC_DAM_00:
/* for global link addresses */
fail = lowpan_fetch_skb(skb, ipaddr->s6_addr, 16);
break;
case LOWPAN_IPHC_SAM_01:
case LOWPAN_IPHC_DAM_01:
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/if_arp.h`, `linux/netdevice.h`, `net/6lowpan.h`, `net/ipv6.h`, `6lowpan_i.h`, `nhc.h`.
- Detected declarations: `function lowpan_iphc_uncompress_802154_lladdr`, `function lowpan_iphc_ctx_get_by_id`, `function lowpan_iphc_ctx_get_by_addr`, `function lowpan_iphc_ctx_get_by_mcast_addr`, `function lowpan_iphc_uncompress_lladdr`, `function address`, `function address`, `function lowpan_uncompress_multicast_daddr`, `function lowpan_uncompress_multicast_ctx_daddr`, `function lowpan_iphc_tf_set_ecn`.
- 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.