1/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
2/* Do not edit directly, auto-generated from: */
3/*	Documentation/netlink/specs/handshake.yaml */
4/* YNL-GEN user header */
5
6#ifndef _LINUX_HANDSHAKE_GEN_H
7#define _LINUX_HANDSHAKE_GEN_H
8
9#include <stdlib.h>
10#include <string.h>
11#include <linux/types.h>
12#include <linux/handshake.h>
13
14struct ynl_sock;
15
16extern const struct ynl_family ynl_handshake_family;
17
18/* Enums */
19const char *handshake_op_str(int op);
20const char *handshake_handler_class_str(enum handshake_handler_class value);
21const char *handshake_msg_type_str(enum handshake_msg_type value);
22const char *handshake_auth_str(enum handshake_auth value);
23
24/* Common nested types */
25struct handshake_x509 {
26	struct {
27		__u32 cert:1;
28		__u32 privkey:1;
29	} _present;
30
31	__u32 cert;
32	__u32 privkey;
33};
34
35/* ============== HANDSHAKE_CMD_ACCEPT ============== */
36/* HANDSHAKE_CMD_ACCEPT - do */
37struct handshake_accept_req {
38	struct {
39		__u32 handler_class:1;
40	} _present;
41
42	enum handshake_handler_class handler_class;
43};
44
45static inline struct handshake_accept_req *handshake_accept_req_alloc(void)
46{
47	return calloc(1, sizeof(struct handshake_accept_req));
48}
49void handshake_accept_req_free(struct handshake_accept_req *req);
50
51static inline void
52handshake_accept_req_set_handler_class(struct handshake_accept_req *req,
53				       enum handshake_handler_class handler_class)
54{
55	req->_present.handler_class = 1;
56	req->handler_class = handler_class;
57}
58
59struct handshake_accept_rsp {
60	struct {
61		__u32 sockfd:1;
62		__u32 message_type:1;
63		__u32 timeout:1;
64		__u32 auth_mode:1;
65		__u32 peername_len;
66	} _present;
67
68	__u32 sockfd;
69	enum handshake_msg_type message_type;
70	__u32 timeout;
71	enum handshake_auth auth_mode;
72	unsigned int n_peer_identity;
73	__u32 *peer_identity;
74	unsigned int n_certificate;
75	struct handshake_x509 *certificate;
76	char *peername;
77};
78
79void handshake_accept_rsp_free(struct handshake_accept_rsp *rsp);
80
81/*
82 * Handler retrieves next queued handshake request
83 */
84struct handshake_accept_rsp *
85handshake_accept(struct ynl_sock *ys, struct handshake_accept_req *req);
86
87/* HANDSHAKE_CMD_ACCEPT - notify */
88struct handshake_accept_ntf {
89	__u16 family;
90	__u8 cmd;
91	struct ynl_ntf_base_type *next;
92	void (*free)(struct handshake_accept_ntf *ntf);
93	struct handshake_accept_rsp obj __attribute__ ((aligned (8)));
94};
95
96void handshake_accept_ntf_free(struct handshake_accept_ntf *rsp);
97
98/* ============== HANDSHAKE_CMD_DONE ============== */
99/* HANDSHAKE_CMD_DONE - do */
100struct handshake_done_req {
101	struct {
102		__u32 status:1;
103		__u32 sockfd:1;
104	} _present;
105
106	__u32 status;
107	__u32 sockfd;
108	unsigned int n_remote_auth;
109	__u32 *remote_auth;
110};
111
112static inline struct handshake_done_req *handshake_done_req_alloc(void)
113{
114	return calloc(1, sizeof(struct handshake_done_req));
115}
116void handshake_done_req_free(struct handshake_done_req *req);
117
118static inline void
119handshake_done_req_set_status(struct handshake_done_req *req, __u32 status)
120{
121	req->_present.status = 1;
122	req->status = status;
123}
124static inline void
125handshake_done_req_set_sockfd(struct handshake_done_req *req, __u32 sockfd)
126{
127	req->_present.sockfd = 1;
128	req->sockfd = sockfd;
129}
130static inline void
131__handshake_done_req_set_remote_auth(struct handshake_done_req *req,
132				     __u32 *remote_auth,
133				     unsigned int n_remote_auth)
134{
135	free(req->remote_auth);
136	req->remote_auth = remote_auth;
137	req->n_remote_auth = n_remote_auth;
138}
139
140/*
141 * Handler reports handshake completion
142 */
143int handshake_done(struct ynl_sock *ys, struct handshake_done_req *req);
144
145#endif /* _LINUX_HANDSHAKE_GEN_H */
146