xref: /openbsd-src/regress/sbin/iked/parser/common.c (revision de8cc8edbc71bd3e3bc7fbffa27ba0e564c37d8b)
1 /*	$OpenBSD: common.c,v 1.10 2021/02/04 20:45:13 tobhe Exp $ */
2 /*
3  * A bunch of stub functions so we can compile and link ikev2_pld.c
4  * in a standalone program for testing purposes.
5  *
6  * Placed in the public domain
7  */
8 
9 #include <sys/socket.h>
10 #include <sys/param.h>
11 #include <sys/time.h>
12 #include <sys/uio.h>
13 
14 #include <event.h>
15 #include <limits.h>
16 
17 #include "iked.h"
18 #include "types.h"
19 #include "test_helper.h"
20 
21 int	 eap_parse(struct iked *, const struct iked_sa *,
22 	    struct iked_message *, void *, int);
23 int	 ikev2_msg_frompeer(struct iked_message *);
24 int	 ikev2_send_ike_e(struct iked *, struct iked_sa *, struct ibuf *,
25 	    u_int8_t, u_int8_t, int);
26 void	 ikev2_ikesa_recv_delete(struct iked *, struct iked_sa *);
27 struct iked_childsa *
28 	 childsa_lookup(struct iked_sa *, u_int64_t, u_int8_t);
29 int	  ikev2_childsa_delete(struct iked *, struct iked_sa *,
30 	    u_int8_t, u_int64_t, u_int64_t *, int);
31 int	 sa_stateok(const struct iked_sa *, int);
32 void	 sa_state(struct iked *, struct iked_sa *, int);
33 void	 ikev2_disable_rekeying(struct iked *, struct iked_sa *);
34 void	 ikev2_init_ike_sa(struct iked *, void *);
35 struct dh_group *
36 	 group_get(u_int32_t);
37 void	 timer_set(struct iked *, struct iked_timer *,
38 	     void (*)(struct iked *, void *), void *);
39 void	 timer_add(struct iked *, struct iked_timer *, int);
40 void	 timer_del(struct iked *, struct iked_timer *);
41 ssize_t	 ikev2_nat_detection(struct iked *, struct iked_message *,
42 	     void *, size_t, u_int, int);
43 int	 ca_setreq(struct iked *, struct iked_sa *, struct iked_static_id *,
44 	     u_int8_t, u_int8_t, u_int8_t *, size_t, enum privsep_procid);
45 int	 ikev2_print_id(struct iked_id *, char *, size_t);
46 int	 config_add_transform(struct iked_proposal *, u_int, u_int, u_int,
47 	     u_int);
48 struct iked_proposal *
49 	 config_add_proposal(struct iked_proposals *, u_int, u_int);
50 void	 config_free_proposal(struct iked_proposals *, struct iked_proposal *);
51 int	 ikev2_send_informational(struct iked *, struct iked_message *);
52 struct ibuf *
53 	 ikev2_msg_decrypt(struct iked *, struct iked_sa *, struct ibuf *,
54 	     struct ibuf *);
55 
56 int
57 eap_parse(struct iked *env, const struct iked_sa *sa, struct iked_message *msg,
58     void *data, int response)
59 {
60 	return (0);
61 }
62 
63 int
64 ikev2_msg_frompeer(struct iked_message *msg)
65 {
66 	return (0);
67 }
68 
69 int
70 ikev2_send_ike_e(struct iked *env, struct iked_sa *sa, struct ibuf *buf,
71     u_int8_t firstpayload, u_int8_t exchange, int response)
72 {
73 	return (0);
74 }
75 
76 void
77 ikev2_ikesa_recv_delete(struct iked *env, struct iked_sa *sa)
78 {
79 }
80 
81 const char *
82 ikev2_ikesa_info(uint64_t spi, const char *msg)
83 {
84 	return "";
85 }
86 
87 struct iked_childsa *
88 childsa_lookup(struct iked_sa *a, u_int64_t b, u_int8_t c)
89 {
90 	return (NULL);
91 }
92 
93 int
94 ikev2_childsa_delete(struct iked *a, struct iked_sa *b, u_int8_t c,
95     u_int64_t d, u_int64_t *e , int f)
96 {
97 	return (0);
98 }
99 
100 int
101 sa_stateok(const struct iked_sa *a, int b)
102 {
103 	return (0);
104 }
105 
106 void
107 sa_state(struct iked * a, struct iked_sa *b, int c)
108 {
109 }
110 
111 void
112 ikev2_disable_rekeying(struct iked *a, struct iked_sa *b)
113 {
114 }
115 
116 void
117 ikev2_init_ike_sa(struct iked *a, void *b)
118 {
119 }
120 
121 const struct group_id *
122 group_getid(u_int32_t id)
123 {
124 	return (NULL);
125 }
126 
127 void
128 timer_set(struct iked *env, struct iked_timer *tmr,
129     void (*cb)(struct iked *, void *), void *arg)
130 {
131 }
132 
133 void
134 timer_add(struct iked *env, struct iked_timer *tmr, int timeout)
135 {
136 }
137 
138 void
139 timer_del(struct iked *env, struct iked_timer *tmr)
140 {
141 }
142 
143 ssize_t
144 ikev2_nat_detection(struct iked *env, struct iked_message *msg,
145     void *ptr, size_t len, u_int type, int frompeer)
146 {
147 	return (0);
148 }
149 
150 int
151 ca_setreq(struct iked *env, struct iked_sa *sh, struct iked_static_id *localid,
152     u_int8_t type, u_int8_t more, u_int8_t *data, size_t len,
153     enum privsep_procid procid)
154 {
155 	return (0);
156 }
157 
158 int
159 ikev2_print_id(struct iked_id *id, char *idstr, size_t idstrlen)
160 {
161 	return (0);
162 }
163 
164 int
165 config_add_transform(struct iked_proposal *prop, u_int type,
166     u_int id, u_int length, u_int keylength)
167 {
168 	return (0);
169 }
170 
171 struct iked_proposal *
172 config_add_proposal(struct iked_proposals *head, u_int id, u_int proto)
173 {
174 	return (NULL);
175 }
176 
177 void
178 config_free_proposal(struct iked_proposals *head, struct iked_proposal *prop)
179 {
180 	return;
181 }
182 
183 void config_free_fragments(struct iked_frag *frag)
184 {
185 	return;
186 }
187 
188 int
189 ikev2_send_informational(struct iked *env, struct iked_message *msg)
190 {
191 	return (0);
192 }
193 
194 struct ibuf *
195 ikev2_msg_decrypt(struct iked *env, struct iked_sa *sa,
196     struct ibuf *msg, struct ibuf *src)
197 {
198 	ASSERT_PTR_NE(src, NULL);
199 
200 	/*
201 	 * Free src as caller uses ikev2_msg_decrypt() like this:
202 	 * src = ikev2_msg_decrypt(..., src);
203 	 */
204 	ibuf_free(src);
205 	return (NULL);
206 }
207 
208 void
209 ikev2_ike_sa_setreason(struct iked_sa *sa, char *r)
210 {
211 }
212