net/x25/af_x25.c
Source file repositories/reference/linux-study-clean/net/x25/af_x25.c
File Facts
- System
- Linux kernel
- Corpus path
net/x25/af_x25.c- Extension
.c- Size
- 41332 bytes
- Lines
- 1852
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/capability.hlinux/errno.hlinux/kernel.hlinux/sched/signal.hlinux/timer.hlinux/string.hlinux/net.hlinux/netdevice.hlinux/if_arp.hlinux/skbuff.hlinux/slab.hnet/sock.hnet/tcp_states.hlinux/uaccess.hlinux/fcntl.hlinux/termios.hlinux/notifier.hlinux/init.hlinux/compat.hlinux/ctype.hlinux/uio.hnet/x25.hnet/compat.h
Detected Declarations
struct compat_x25_subscrip_structfunction x25_parse_address_blockfunction x25_addr_ntoafunction x25_addr_atonfunction x25_remove_socketfunction x25_device_eventfunction x25_insert_socketfunction sk_for_eachfunction sk_for_eachfunction x25_new_lcifunction x25_destroy_timerfunction arefunction x25_destroy_socket_from_timerfunction x25_setsockoptfunction x25_getsockoptfunction x25_listenfunction x25_createfunction x25_releasefunction x25_bindfunction x25_wait_for_connection_establishmentfunction x25_connectfunction x25_wait_for_datafunction x25_acceptfunction x25_getnamefunction x25_rx_call_requestfunction x25_sendmsgfunction x25_recvmsgfunction x25_ioctlfunction compat_x25_subscr_ioctlfunction compat_x25_ioctlfunction x25_kill_by_neighfunction sk_for_eachfunction x25_initfunction x25_exitmodule init x25_init
Annotated Snippet
static const struct proto_ops x25_proto_ops;
static const struct x25_address null_x25_address = {" "};
#ifdef CONFIG_COMPAT
struct compat_x25_subscrip_struct {
char device[200-sizeof(compat_ulong_t)];
compat_ulong_t global_facil_mask;
compat_uint_t extended;
};
#endif
int x25_parse_address_block(struct sk_buff *skb,
struct x25_address *called_addr,
struct x25_address *calling_addr)
{
unsigned char len;
int needed;
int rc;
if (!pskb_may_pull(skb, 1)) {
/* packet has no address block */
rc = 0;
goto empty;
}
len = *skb->data;
needed = 1 + ((len >> 4) + (len & 0x0f) + 1) / 2;
if (!pskb_may_pull(skb, needed)) {
/* packet is too short to hold the addresses it claims
to hold */
rc = -1;
goto empty;
}
return x25_addr_ntoa(skb->data, called_addr, calling_addr);
empty:
*called_addr->x25_addr = 0;
*calling_addr->x25_addr = 0;
return rc;
}
int x25_addr_ntoa(unsigned char *p, struct x25_address *called_addr,
struct x25_address *calling_addr)
{
unsigned int called_len, calling_len;
char *called, *calling;
unsigned int i;
called_len = (*p >> 0) & 0x0F;
calling_len = (*p >> 4) & 0x0F;
called = called_addr->x25_addr;
calling = calling_addr->x25_addr;
p++;
for (i = 0; i < (called_len + calling_len); i++) {
if (i < called_len) {
if (i % 2 != 0) {
*called++ = ((*p >> 0) & 0x0F) + '0';
p++;
} else {
*called++ = ((*p >> 4) & 0x0F) + '0';
}
} else {
if (i % 2 != 0) {
*calling++ = ((*p >> 0) & 0x0F) + '0';
p++;
} else {
*calling++ = ((*p >> 4) & 0x0F) + '0';
}
}
}
*called = *calling = '\0';
return 1 + (called_len + calling_len + 1) / 2;
}
int x25_addr_aton(unsigned char *p, struct x25_address *called_addr,
struct x25_address *calling_addr)
{
unsigned int called_len, calling_len;
char *called, *calling;
int i;
Annotation
- Immediate include surface: `linux/module.h`, `linux/capability.h`, `linux/errno.h`, `linux/kernel.h`, `linux/sched/signal.h`, `linux/timer.h`, `linux/string.h`, `linux/net.h`.
- Detected declarations: `struct compat_x25_subscrip_struct`, `function x25_parse_address_block`, `function x25_addr_ntoa`, `function x25_addr_aton`, `function x25_remove_socket`, `function x25_device_event`, `function x25_insert_socket`, `function sk_for_each`, `function sk_for_each`, `function x25_new_lci`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.