net/nfc/llcp_commands.c
Source file repositories/reference/linux-study-clean/net/nfc/llcp_commands.c
File Facts
- System
- Linux kernel
- Corpus path
net/nfc/llcp_commands.c- Extension
.c- Size
- 16906 bytes
- Lines
- 831
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/kernel.hlinux/module.hlinux/nfc.hnet/nfc/nfc.hnfc.hllcp.h
Detected Declarations
function llcp_tlv8function llcp_tlv16function llcp_tlv_versionfunction llcp_tlv_miuxfunction llcp_tlv_wksfunction llcp_tlv_ltofunction llcp_tlv_optfunction llcp_tlv_rwfunction nfc_llcp_free_sdp_tlvfunction nfc_llcp_free_sdp_tlv_listfunction hlist_for_each_entry_safefunction nfc_llcp_parse_gb_tlvfunction nfc_llcp_parse_connection_tlvfunction nfc_llcp_send_disconnectfunction nfc_llcp_send_symmfunction nfc_llcp_send_connectfunction nfc_llcp_send_ccfunction nfc_llcp_send_snl_sdresfunction hlist_for_each_entry_safefunction nfc_llcp_send_snl_sdreqfunction hlist_for_each_entry_safefunction nfc_llcp_send_dmfunction nfc_llcp_send_i_framefunction skb_queue_lenfunction skb_queue_lenfunction nfc_llcp_send_ui_framefunction nfc_llcp_send_rr
Annotated Snippet
switch (type) {
case LLCP_TLV_VERSION:
local->remote_version = llcp_tlv_version(tlv);
break;
case LLCP_TLV_MIUX:
local->remote_miu = llcp_tlv_miux(tlv) + 128;
break;
case LLCP_TLV_WKS:
local->remote_wks = llcp_tlv_wks(tlv);
break;
case LLCP_TLV_LTO:
local->remote_lto = llcp_tlv_lto(tlv) * 10;
break;
case LLCP_TLV_OPT:
local->remote_opt = llcp_tlv_opt(tlv);
break;
default:
pr_err("Invalid gt tlv value 0x%x\n", type);
break;
}
offset += length + 2;
tlv += length + 2;
}
pr_debug("version 0x%x miu %d lto %d opt 0x%x wks 0x%x\n",
local->remote_version, local->remote_miu,
local->remote_lto, local->remote_opt,
local->remote_wks);
return 0;
}
int nfc_llcp_parse_connection_tlv(struct nfc_llcp_sock *sock,
const u8 *tlv_array, u16 tlv_array_len)
{
const u8 *tlv = tlv_array;
u8 type, length, offset = 0;
pr_debug("TLV array length %d\n", tlv_array_len);
if (sock == NULL)
return -ENOTCONN;
while (offset < tlv_array_len) {
type = tlv[0];
length = tlv[1];
pr_debug("type 0x%x length %d\n", type, length);
switch (type) {
case LLCP_TLV_MIUX:
sock->remote_miu = llcp_tlv_miux(tlv) + 128;
break;
case LLCP_TLV_RW:
sock->remote_rw = llcp_tlv_rw(tlv);
break;
case LLCP_TLV_SN:
break;
default:
pr_err("Invalid gt tlv value 0x%x\n", type);
break;
}
offset += length + 2;
tlv += length + 2;
}
pr_debug("sock %p rw %d miu %d\n", sock,
sock->remote_rw, sock->remote_miu);
return 0;
}
static struct sk_buff *llcp_add_header(struct sk_buff *pdu,
u8 dsap, u8 ssap, u8 ptype)
{
u8 header[2];
pr_debug("ptype 0x%x dsap 0x%x ssap 0x%x\n", ptype, dsap, ssap);
header[0] = (u8)((dsap << 2) | (ptype >> 2));
header[1] = (u8)((ptype << 6) | ssap);
pr_debug("header 0x%x 0x%x\n", header[0], header[1]);
skb_put_data(pdu, header, LLCP_HEADER_SIZE);
return pdu;
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/nfc.h`, `net/nfc/nfc.h`, `nfc.h`, `llcp.h`.
- Detected declarations: `function llcp_tlv8`, `function llcp_tlv16`, `function llcp_tlv_version`, `function llcp_tlv_miux`, `function llcp_tlv_wks`, `function llcp_tlv_lto`, `function llcp_tlv_opt`, `function llcp_tlv_rw`, `function nfc_llcp_free_sdp_tlv`, `function nfc_llcp_free_sdp_tlv_list`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.