tools/testing/selftests/net/tfo.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/tfo.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/tfo.c
Extension
.c
Size
3774 bytes
Lines
178
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.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (c) {
		case 's':
			if (cfg_client)
				error(1, 0, "Pass one of -s or -c");
			cfg_server = 1;
			break;
		case 'c':
			if (cfg_server)
				error(1, 0, "Pass one of -s or -c");
			cfg_client = 1;
			break;
		case 'h':
			addr = optarg;
			break;
		case 'p':
			cfg_port = strtoul(optarg, NULL, 0);
			break;
		case 'o':
			cfg_outfile = strdup(optarg);
			if (!cfg_outfile)
				error(1, 0, "outfile invalid");
			break;
		}
	}

	if (cfg_server && addr)
		error(1, 0, "Server cannot have -h specified");

	memset(addr6, 0, sizeof(*addr6));
	addr6->sin6_family = AF_INET6;
	addr6->sin6_port = htons(cfg_port);
	addr6->sin6_addr = in6addr_any;
	if (addr) {
		ret = parse_address(addr, cfg_port, addr6);
		if (ret)
			error(1, 0, "Client address parse error: %s", addr);
	}
}

int main(int argc, char **argv)
{
	parse_opts(argc, argv);

	if (cfg_server)
		run_server();
	else if (cfg_client)
		run_client();

	return 0;
}

Annotation

Implementation Notes