include/linux/socket.h
Source file repositories/reference/linux-study-clean/include/linux/socket.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/socket.h- Extension
.h- Size
- 16559 bytes
- Lines
- 479
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/socket.hlinux/sockios.hlinux/uio.hlinux/types.hlinux/compiler.huapi/linux/socket.h
Detected Declarations
struct filestruct pidstruct credstruct socketstruct sockstruct sk_buffstruct proto_accept_argstruct seq_filestruct sockaddrstruct sockaddr_unsizedstruct lingerstruct msghdrstruct user_msghdrstruct mmsghdrstruct cmsghdrstruct ucredstruct timespec64struct __kernel_timespecstruct old_timespec32struct scm_timestamping_internalfunction __cmsg_nxthdrfunction cmsg_nxthdrfunction msg_data_left
Annotated Snippet
struct sockaddr {
sa_family_t sa_family; /* address family, AF_xxx */
char sa_data[14]; /* 14 bytes of protocol address */
};
/**
* struct sockaddr_unsized - Unspecified size sockaddr for callbacks
* @sa_family: Address family (AF_UNIX, AF_INET, AF_INET6, etc.)
* @sa_data: Flexible array for address data
*
* This structure is designed for callback interfaces where the
* total size is known via the sockaddr_len parameter. Unlike struct
* sockaddr which has a fixed 14-byte sa_data limit or struct
* sockaddr_storage which has a fixed 128-byte sa_data limit, this
* structure can accommodate addresses of any size, but must be used
* carefully.
*/
struct sockaddr_unsized {
__kernel_sa_family_t sa_family; /* address family, AF_xxx */
char sa_data[]; /* flexible address data */
};
struct linger {
int l_onoff; /* Linger active */
int l_linger; /* How long to linger for */
};
#define sockaddr_storage __kernel_sockaddr_storage
/*
* As we do 4.4BSD message passing we use a 4.4BSD message passing
* system, not 4.3. Thus msg_accrights(len) are now missing. They
* belong in an obscure libc emulation or the bin.
*/
struct msghdr {
void *msg_name; /* ptr to socket address structure */
int msg_namelen; /* size of socket address structure */
int msg_inq; /* output, data left in socket */
struct iov_iter msg_iter; /* data */
/*
* Ancillary data. msg_control_user is the user buffer used for the
* recv* side when msg_control_is_user is set, msg_control is the kernel
* buffer used for all other cases.
*/
union {
void *msg_control;
void __user *msg_control_user;
};
bool msg_control_is_user : 1;
bool msg_get_inq : 1;/* return INQ after receive */
unsigned int msg_flags; /* flags on received message */
__kernel_size_t msg_controllen; /* ancillary data buffer length */
struct ubuf_info *msg_ubuf;
int (*sg_from_iter)(struct sk_buff *skb,
struct iov_iter *from, size_t length);
};
struct user_msghdr {
void __user *msg_name; /* ptr to socket address structure */
int msg_namelen; /* size of socket address structure */
struct iovec __user *msg_iov; /* scatter/gather array */
__kernel_size_t msg_iovlen; /* # elements in msg_iov */
void __user *msg_control; /* ancillary data */
__kernel_size_t msg_controllen; /* ancillary data buffer length */
unsigned int msg_flags; /* flags on received message */
};
/* For recvmmsg/sendmmsg */
struct mmsghdr {
struct user_msghdr msg_hdr;
unsigned int msg_len;
};
/*
* POSIX 1003.1g - ancillary data object information
* Ancillary data consists of a sequence of pairs of
* (cmsghdr, cmsg_data[])
*/
struct cmsghdr {
__kernel_size_t cmsg_len; /* data byte count, including hdr */
int cmsg_level; /* originating protocol */
int cmsg_type; /* protocol-specific type */
};
/*
Annotation
- Immediate include surface: `asm/socket.h`, `linux/sockios.h`, `linux/uio.h`, `linux/types.h`, `linux/compiler.h`, `uapi/linux/socket.h`.
- Detected declarations: `struct file`, `struct pid`, `struct cred`, `struct socket`, `struct sock`, `struct sk_buff`, `struct proto_accept_arg`, `struct seq_file`, `struct sockaddr`, `struct sockaddr_unsized`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.