tools/testing/selftests/net/ovpn/ovpn-cli.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/ovpn/ovpn-cli.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/ovpn/ovpn-cli.c- Extension
.c- Size
- 57418 bytes
- Lines
- 2468
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdint.hstdio.hinttypes.hstdbool.hstring.herrno.hunistd.harpa/inet.hnet/if.hnetinet/in.htime.hlinux/ovpn.hlinux/types.hlinux/netlink.hnetlink/socket.hnetlink/netlink.hnetlink/genl/genl.hnetlink/genl/family.hnetlink/genl/ctrl.hmbedtls/base64.hmbedtls/error.hsys/socket.hkselftest.h
Detected Declarations
struct nl_ctxstruct ovpn_ctxstruct ovpn_link_reqstruct mcast_handler_argsenum ovpn_key_directionenum ovpn_cmdfunction Copyrightfunction ovpn_nl_recvmsgsfunction nl_ctx_freefunction ovpn_nl_cb_errorfunction ovpn_nl_cb_finishfunction ovpn_nl_cb_ackfunction ovpn_nl_msg_sendfunction ovpn_parse_keyfunction ovpn_parse_cipherfunction ovpn_parse_key_directionfunction ovpn_socketfunction ovpn_udp_socketfunction ovpn_listenfunction ovpn_acceptfunction ovpn_connectfunction ovpn_new_peerfunction ovpn_set_peerfunction ovpn_del_peerfunction ovpn_handle_peerfunction ovpn_get_peerfunction ovpn_new_keyfunction ovpn_del_keyfunction ovpn_handle_keyfunction ovpn_get_keyfunction ovpn_swap_keysfunction ovpn_addattrfunction ovpn_nest_endfunction ovpn_rt_socketfunction ovpn_rt_bindfunction ovpn_rt_sendfunction ovpn_new_ifacefunction ovpn_del_ifacefunction nl_seq_checkfunction mcast_family_handlerfunction nla_for_each_nestedfunction mcast_error_handlerfunction mcast_ack_handlerfunction ovpn_handle_msgfunction ovpn_get_mcast_idfunction ovpn_listen_mcastfunction usagefunction ovpn_parse_remote
Annotated Snippet
struct nl_ctx {
struct nl_sock *nl_sock;
struct nl_msg *nl_msg;
struct nl_cb *nl_cb;
int ovpn_dco_id;
};
enum ovpn_cmd {
CMD_INVALID,
CMD_NEW_IFACE,
CMD_DEL_IFACE,
CMD_LISTEN,
CMD_CONNECT,
CMD_NEW_PEER,
CMD_NEW_MULTI_PEER,
CMD_SET_PEER,
CMD_DEL_PEER,
CMD_GET_PEER,
CMD_NEW_KEY,
CMD_DEL_KEY,
CMD_GET_KEY,
CMD_SWAP_KEYS,
CMD_LISTEN_MCAST,
};
struct ovpn_ctx {
enum ovpn_cmd cmd;
__u8 key_enc[KEY_LEN];
__u8 key_dec[KEY_LEN];
__u8 nonce[NONCE_LEN];
enum ovpn_cipher_alg cipher;
sa_family_t sa_family;
unsigned long peer_id, tx_id;
unsigned long lport;
union {
struct sockaddr_in in4;
struct sockaddr_in6 in6;
} remote;
union {
struct sockaddr_in in4;
struct sockaddr_in6 in6;
} peer_ip;
bool peer_ip_set;
unsigned int ifindex;
char ifname[IFNAMSIZ];
enum ovpn_mode mode;
bool mode_set;
int socket;
int cli_sockets[MAX_PEERS];
__u32 keepalive_interval;
__u32 keepalive_timeout;
enum ovpn_key_direction key_dir;
enum ovpn_key_slot key_slot;
int key_id;
uint32_t mark;
bool asymm_id;
const char *peers_file;
};
static int ovpn_nl_recvmsgs(struct nl_ctx *ctx)
{
int ret;
ret = nl_recvmsgs(ctx->nl_sock, ctx->nl_cb);
switch (ret) {
case -NLE_INTR:
fprintf(stderr,
"netlink received interrupt due to signal - ignoring\n");
break;
case -NLE_NOMEM:
fprintf(stderr, "netlink out of memory error\n");
break;
case -NLE_AGAIN:
fprintf(stderr,
"netlink reports blocking read - aborting wait\n");
Annotation
- Immediate include surface: `stdint.h`, `stdio.h`, `inttypes.h`, `stdbool.h`, `string.h`, `errno.h`, `unistd.h`, `arpa/inet.h`.
- Detected declarations: `struct nl_ctx`, `struct ovpn_ctx`, `struct ovpn_link_req`, `struct mcast_handler_args`, `enum ovpn_key_direction`, `enum ovpn_cmd`, `function Copyright`, `function ovpn_nl_recvmsgs`, `function nl_ctx_free`, `function ovpn_nl_cb_error`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.