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