tools/testing/selftests/net/cmsg_sender.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/cmsg_sender.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/cmsg_sender.c- Extension
.c- Size
- 14289 bytes
- Lines
- 584
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
errno.herror.hnetdb.hstdbool.hstdio.hstdlib.hstring.htime.hunistd.hlinux/errqueue.hlinux/icmp.hlinux/icmpv6.hlinux/net_tstamp.hlinux/types.hlinux/udp.hsys/socket.hkselftest.h
Detected Declarations
struct option_cmsg_u32struct optionsfunction __attribute__function cs_parse_argsfunction memrndfunction ca_write_cmsg_u32function cs_write_cmsgfunction cs_read_cmsgfunction ca_set_sockoptsfunction main
Annotated Snippet
struct option_cmsg_u32 {
bool ena;
unsigned int val;
};
struct options {
bool silent_send;
const char *host;
const char *service;
unsigned int size;
unsigned int num_pkt;
bool msg_more;
struct {
unsigned int mark;
unsigned int dontfrag;
unsigned int tclass;
unsigned int hlimit;
unsigned int priority;
} sockopt;
struct {
unsigned int family;
unsigned int type;
unsigned int proto;
} sock;
struct option_cmsg_u32 mark;
struct option_cmsg_u32 priority;
struct {
bool ena;
unsigned int delay;
} txtime;
struct {
bool ena;
} ts;
struct {
struct option_cmsg_u32 dontfrag;
struct option_cmsg_u32 tclass;
struct option_cmsg_u32 hlimit;
struct option_cmsg_u32 exthdr;
} cmsg;
} opt = {
.size = 13,
.num_pkt = 1,
.sock = {
.family = AF_UNSPEC,
.type = SOCK_DGRAM,
.proto = IPPROTO_UDP,
},
};
static struct timespec time_start_real;
static struct timespec time_start_mono;
static void __attribute__((noreturn)) cs_usage(const char *bin)
{
printf("Usage: %s [opts] <dst host> <dst port / service>\n", bin);
printf("Options:\n"
"\t\t-s Silent send() failures\n"
"\t\t-S send() size\n"
"\t\t-4/-6 Force IPv4 / IPv6 only\n"
"\t\t-p prot Socket protocol\n"
"\t\t (u = UDP (default); i = ICMP; r = RAW;\n"
"\t\t U = UDP with MSG_MORE)\n"
"\n"
"\t\t-m val Set SO_MARK with given value\n"
"\t\t-M val Set SO_MARK via setsockopt\n"
"\t\t-P val Set SO_PRIORITY via setsockopt\n"
"\t\t-Q val Set SO_PRIORITY via cmsg\n"
"\t\t-d val Set SO_TXTIME with given delay (usec)\n"
"\t\t-t Enable time stamp reporting\n"
"\t\t-f val Set don't fragment via cmsg\n"
"\t\t-F val Set don't fragment via setsockopt\n"
"\t\t-c val Set TOS/TCLASS via cmsg\n"
"\t\t-C val Set TOS/TCLASS via setsockopt\n"
"\t\t-l val Set TTL/HOPLIMIT via cmsg\n"
"\t\t-L val Set TTL/HOPLIMIT via setsockopt\n"
"\t\t-H type Add an IPv6 header option\n"
"\t\t (h = HOP; d = DST; r = RTDST)\n"
"\n");
exit(ERN_HELP);
}
static void cs_parse_args(int argc, char *argv[])
{
int o;
while ((o = getopt(argc, argv, "46sS:p:P:m:M:n:d:tf:F:c:C:l:L:H:Q:")) != -1) {
switch (o) {
case 's':
opt.silent_send = true;
break;
Annotation
- Immediate include surface: `errno.h`, `error.h`, `netdb.h`, `stdbool.h`, `stdio.h`, `stdlib.h`, `string.h`, `time.h`.
- Detected declarations: `struct option_cmsg_u32`, `struct options`, `function __attribute__`, `function cs_parse_args`, `function memrnd`, `function ca_write_cmsg_u32`, `function cs_write_cmsg`, `function cs_read_cmsg`, `function ca_set_sockopts`, `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.