net/llc/af_llc.c
Source file repositories/reference/linux-study-clean/net/llc/af_llc.c
File Facts
- System
- Linux kernel
- Corpus path
net/llc/af_llc.c- Extension
.c- Size
- 32890 bytes
- Lines
- 1304
- 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.
- 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/compiler.hlinux/kernel.hlinux/module.hlinux/rtnetlink.hlinux/init.hlinux/slab.hlinux/sched/signal.hlinux/uio.hnet/llc.hnet/llc_sap.hnet/llc_pdu.hnet/llc_conn.hnet/tcp_states.h
Detected Declarations
function llc_ui_next_link_nofunction llc_proto_typefunction llc_ui_addr_nullfunction llc_ui_header_lenfunction llc_ui_send_datafunction llc_ui_sk_initfunction llc_ui_createfunction llc_ui_releasefunction llc_ui_autoportfunction llc_ui_autobindfunction llc_ui_bindfunction receivesfunction bindfunction llc_ui_listenfunction llc_ui_wait_for_discfunction llc_ui_wait_for_connfunction llc_ui_wait_for_busy_corefunction llc_wait_datafunction llc_cmsg_rcvfunction llc_ui_acceptfunction llc_ui_recvmsgfunction llc_ui_sendmsgfunction llc_ui_getnamefunction llc_ui_ioctlfunction llc_ui_setsockoptfunction llc_ui_getsockoptfunction llc2_initfunction llc2_exitmodule init llc2_init
Annotated Snippet
static const struct proto_ops llc_ui_ops;
static bool llc_ui_wait_for_conn(struct sock *sk, long timeout);
static int llc_ui_wait_for_disc(struct sock *sk, long timeout);
static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout);
#if 0
#define dprintk(args...) printk(KERN_DEBUG args)
#else
#define dprintk(args...) do {} while (0)
#endif
/* Maybe we'll add some more in the future. */
#define LLC_CMSG_PKTINFO 1
/**
* llc_ui_next_link_no - return the next unused link number for a sap
* @sap: Address of sap to get link number from.
*
* Return the next unused link number for a given sap.
*/
static inline u16 llc_ui_next_link_no(int sap)
{
return llc_ui_sap_link_no_max[sap]++;
}
/**
* llc_proto_type - return eth protocol for ARP header type
* @arphrd: ARP header type.
*
* Given an ARP header type return the corresponding ethernet protocol.
*/
static inline __be16 llc_proto_type(u16 arphrd)
{
return htons(ETH_P_802_2);
}
/**
* llc_ui_addr_null - determines if a address structure is null
* @addr: Address to test if null.
*/
static inline u8 llc_ui_addr_null(struct sockaddr_llc *addr)
{
return !memcmp(addr, &llc_ui_addrnull, sizeof(*addr));
}
/**
* llc_ui_header_len - return length of llc header based on operation
* @sk: Socket which contains a valid llc socket type.
* @addr: Complete sockaddr_llc structure received from the user.
*
* Provide the length of the llc header depending on what kind of
* operation the user would like to perform and the type of socket.
* Returns the correct llc header length.
*/
static inline u8 llc_ui_header_len(struct sock *sk, struct sockaddr_llc *addr)
{
u8 rc = LLC_PDU_LEN_U;
if (addr->sllc_test)
rc = LLC_PDU_LEN_U;
else if (addr->sllc_xid)
/* We need to expand header to sizeof(struct llc_xid_info)
* since llc_pdu_init_as_xid_cmd() sets 4,5,6 bytes of LLC header
* as XID PDU. In llc_ui_sendmsg() we reserved header size and then
* filled all other space with user data. If we won't reserve this
* bytes, llc_pdu_init_as_xid_cmd() will overwrite user data
*/
rc = LLC_PDU_LEN_U_XID;
else if (sk->sk_type == SOCK_STREAM)
rc = LLC_PDU_LEN_I;
return rc;
}
/**
* llc_ui_send_data - send data via reliable llc2 connection
* @sk: Connection the socket is using.
* @skb: Data the user wishes to send.
* @noblock: can we block waiting for data?
*
* Send data via reliable llc2 connection.
* Returns 0 upon success, non-zero if action did not succeed.
*
* This function always consumes a reference to the skb.
*/
static int llc_ui_send_data(struct sock* sk, struct sk_buff *skb, int noblock)
{
struct llc_sock* llc = llc_sk(sk);
Annotation
- Immediate include surface: `linux/compiler.h`, `linux/kernel.h`, `linux/module.h`, `linux/rtnetlink.h`, `linux/init.h`, `linux/slab.h`, `linux/sched/signal.h`, `linux/uio.h`.
- Detected declarations: `function llc_ui_next_link_no`, `function llc_proto_type`, `function llc_ui_addr_null`, `function llc_ui_header_len`, `function llc_ui_send_data`, `function llc_ui_sk_init`, `function llc_ui_create`, `function llc_ui_release`, `function llc_ui_autoport`, `function llc_ui_autobind`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern 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.