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