xref: /openbsd-src/regress/sbin/iked/parser/common.c (revision 1a8dbaac879b9f3335ad7fb25429ce63ac1d6bac)
1 /*	$OpenBSD: common.c,v 1.6 2020/09/20 17:29:55 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 *, struct iked_sa *, struct iked_message *,
22 	    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(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 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);
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 struct iked_transform *
47 	 config_add_transform(struct iked_proposal *, u_int, u_int, u_int,
48 	     u_int);
49 struct iked_proposal *
50 	 config_add_proposal(struct iked_proposals *, u_int, u_int);
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, 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(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)
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 struct iked_transform *
165 config_add_transform(struct iked_proposal *prop, u_int type,
166     u_int id, u_int length, u_int keylength)
167 {
168 	return (NULL);
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 config_free_fragments(struct iked_frag *frag)
178 {
179 	return;
180 }
181 
182 int
183 ikev2_send_informational(struct iked *env, struct iked_message *msg)
184 {
185 	return (0);
186 }
187 
188 struct ibuf *
189 ikev2_msg_decrypt(struct iked *env, struct iked_sa *sa,
190     struct ibuf *msg, struct ibuf *src)
191 {
192 	ASSERT_PTR_NE(src, NULL);
193 
194 	/*
195 	 * Free src as caller uses ikev2_msg_decrypt() like this:
196 	 * src = ikev2_msg_decrypt(..., src);
197 	 */
198 	ibuf_free(src);
199 	return (NULL);
200 }
201 
202 void
203 ikev2_ike_sa_setreason(struct iked_sa *sa, char *r)
204 {
205 }
206