Skip to content

Latest commit

 

History

History
1238 lines (1087 loc) · 37.8 KB

openconnect-internal.h

File metadata and controls

1238 lines (1087 loc) · 37.8 KB
 
1
2
3
/*
* OpenConnect (SSL + DTLS) VPN client
*
Jan 26, 2015
Jan 26, 2015
4
* Copyright © 2008-2015 Intel Corporation.
5
* Copyright © 2008 Nick Andrew <nick@nick-andrew.net>
Mar 23, 2013
Mar 23, 2013
6
* Copyright © 2013 John Morrissey <jwm@horde.net>
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
*
* Author: David Woodhouse <dwmw2@infradead.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
#ifndef __OPENCONNECT_INTERNAL_H__
#define __OPENCONNECT_INTERNAL_H__
Dec 31, 2013
Dec 31, 2013
23
24
#define __OPENCONNECT_PRIVATE__
Feb 6, 2014
Feb 6, 2014
25
26
27
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
Jul 4, 2014
Jul 4, 2014
28
29
30
31
#ifndef SECURITY_WIN32
#define SECURITY_WIN32 1
#endif
#include <security.h>
Feb 6, 2014
Feb 6, 2014
32
#else
Jun 30, 2014
Jun 30, 2014
33
#include <sys/types.h>
Feb 6, 2014
Feb 6, 2014
34
35
36
37
38
39
40
41
#include <sys/socket.h>
#include <sys/select.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#endif
42
43
#include "openconnect.h"
Sep 10, 2016
Sep 10, 2016
44
#if defined(OPENCONNECT_OPENSSL)
45
#include <openssl/ssl.h>
Jun 11, 2012
Jun 11, 2012
46
#include <openssl/err.h>
Jun 15, 2012
Jun 15, 2012
47
48
49
50
51
/* Ick */
#if OPENSSL_VERSION_NUMBER >= 0x00909000L
#define method_const const
#else
#define method_const
Jun 11, 2012
Jun 11, 2012
52
#endif
Jun 15, 2012
Jun 15, 2012
53
54
#endif /* OPENSSL */
Mar 10, 2013
Mar 10, 2013
55
#if defined(OPENCONNECT_GNUTLS)
May 29, 2012
May 29, 2012
56
#include <gnutls/gnutls.h>
Jun 14, 2012
Jun 14, 2012
57
#include <gnutls/abstract.h>
May 29, 2012
May 29, 2012
58
#include <gnutls/x509.h>
Jan 26, 2015
Jan 26, 2015
59
#include <gnutls/crypto.h>
May 29, 2012
May 29, 2012
60
61
#endif
Jul 31, 2014
Jul 31, 2014
62
63
64
65
66
#ifdef HAVE_ICONV
#include <langinfo.h>
#include <iconv.h>
#endif
67
68
69
70
71
#include <zlib.h>
#include <stdint.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
Aug 30, 2016
Aug 30, 2016
72
#include <string.h>
May 29, 2012
May 29, 2012
73
Sep 22, 2011
Sep 22, 2011
74
#ifdef LIBPROXY_HDR
75
76
#include LIBPROXY_HDR
#endif
May 29, 2012
May 29, 2012
77
Mar 25, 2013
Mar 25, 2013
78
79
#ifdef HAVE_LIBSTOKEN
#include <stoken.h>
Oct 15, 2012
Oct 15, 2012
80
81
#endif
Jun 19, 2014
Jun 19, 2014
82
#ifdef HAVE_GSSAPI
Jul 1, 2014
Jul 1, 2014
83
#include GSSAPI_HDR
Jun 19, 2014
Jun 19, 2014
84
85
#endif
Aug 13, 2014
Aug 13, 2014
86
87
88
89
#ifdef HAVE_LIBPSKC
#include <pskc/pskc.h>
#endif
Dec 17, 2014
Dec 17, 2014
90
91
92
93
#ifdef HAVE_LIBP11
#include <libp11.h>
#endif
Sep 22, 2011
Sep 22, 2011
94
95
#ifdef ENABLE_NLS
#include <libintl.h>
Sep 22, 2011
Sep 22, 2011
96
#define _(s) dgettext("openconnect", s)
Sep 22, 2011
Sep 22, 2011
97
#else
Dec 30, 2013
Dec 30, 2013
98
#define _(s) ((char *)(s))
Sep 22, 2011
Sep 22, 2011
99
#endif
Sep 22, 2011
Sep 22, 2011
100
#define N_(s) s
Oct 28, 2012
Oct 28, 2012
102
103
#include <libxml/tree.h>
Dec 13, 2016
Dec 13, 2016
104
#define SHA256_SIZE 32
May 29, 2012
May 29, 2012
105
#define SHA1_SIZE 20
May 29, 2012
May 29, 2012
106
#define MD5_SIZE 16
May 29, 2012
May 29, 2012
107
Aug 31, 2016
Aug 31, 2016
108
109
/* FreeBSD provides this in <sys/param.h> */
#ifndef MAX
Jul 4, 2016
Jul 4, 2016
110
#define MAX(x,y) ((x)>(y))?(x):(y)
Aug 31, 2016
Aug 31, 2016
111
#endif
Nov 29, 2017
Nov 29, 2017
112
113
114
#ifndef MIN
#define MIN(x,y) ((x)<(y))?(x):(y)
#endif
115
116
117
118
119
/****************************************************************************/
struct pkt {
int len;
struct pkt *next;
Jan 26, 2015
Jan 26, 2015
120
union {
Jan 26, 2015
Jan 26, 2015
121
122
123
124
125
126
struct {
uint32_t spi;
uint32_t seq;
unsigned char iv[16];
unsigned char payload[];
} esp;
Jan 26, 2015
Jan 26, 2015
127
struct {
Jan 26, 2015
Jan 26, 2015
128
unsigned char pad[2];
Mar 14, 2015
Mar 14, 2015
129
130
unsigned char rec[2];
unsigned char kmp[20];
Jan 26, 2015
Jan 26, 2015
131
} oncp;
Jan 26, 2015
Jan 26, 2015
132
133
struct {
unsigned char pad[16];
Jan 26, 2015
Jan 26, 2015
134
unsigned char hdr[8];
Jan 26, 2015
Jan 26, 2015
135
} cstp;
May 31, 2018
May 31, 2018
136
137
138
139
struct {
unsigned char pad[8];
unsigned char hdr[16];
} gpst;
Jan 26, 2015
Jan 26, 2015
140
};
141
142
143
unsigned char data[];
};
Feb 11, 2014
Feb 11, 2014
144
145
146
147
#define REKEY_NONE 0
#define REKEY_TUNNEL 1
#define REKEY_SSL 2
148
149
150
151
152
153
#define KA_NONE 0
#define KA_DPD 1
#define KA_DPD_DEAD 2
#define KA_KEEPALIVE 3
#define KA_REKEY 4
Mar 8, 2016
Mar 8, 2016
154
155
156
#define DTLS_NOSECRET 0 /* Random secret has not been generated yet */
#define DTLS_SECRET 1 /* Secret is present, ready to attempt DTLS */
#define DTLS_DISABLED 2 /* DTLS was disabled on the *client* side */
Jan 26, 2015
Jan 26, 2015
157
158
159
#define DTLS_SLEEPING 3 /* For ESP, sometimes sending probes */
#define DTLS_CONNECTING 4 /* ESP probe received; must tell server */
#define DTLS_CONNECTED 5 /* Server informed and should be sending ESP */
Feb 11, 2014
Feb 11, 2014
160
Jan 6, 2015
Jan 6, 2015
161
#define COMPR_DEFLATE (1<<0)
Jan 7, 2015
Jan 7, 2015
162
#define COMPR_LZS (1<<1)
Jan 16, 2015
Jan 16, 2015
163
#define COMPR_LZ4 (1<<2)
Aug 2, 2018
Aug 2, 2018
164
165
#define COMPR_LZO (1<<3)
#define COMPR_MAX COMPR_LZO
Jan 16, 2015
Jan 16, 2015
166
167
#ifdef HAVE_LZ4
Aug 2, 2018
Aug 2, 2018
168
#define COMPR_STATELESS (COMPR_LZS | COMPR_LZ4 | COMPR_LZO)
Jan 16, 2015
Jan 16, 2015
169
#else
Jan 25, 2015
Jan 25, 2015
170
#define COMPR_STATELESS (COMPR_LZS)
Jan 16, 2015
Jan 16, 2015
171
#endif
Jan 25, 2015
Jan 25, 2015
172
#define COMPR_ALL (COMPR_STATELESS | COMPR_DEFLATE)
Jan 6, 2015
Jan 6, 2015
173
Sep 21, 2016
Sep 21, 2016
174
175
#define DTLS_APP_ID_EXT 48018
176
177
178
179
struct keepalive_info {
int dpd;
int keepalive;
int rekey;
Feb 11, 2014
Feb 11, 2014
180
int rekey_method;
181
182
183
184
185
186
time_t last_rekey;
time_t last_tx;
time_t last_rx;
time_t last_dpd;
};
Jun 10, 2012
Jun 10, 2012
187
188
189
190
191
192
struct pin_cache {
struct pin_cache *next;
char *token;
char *pin;
};
Jun 19, 2014
Jun 19, 2014
193
194
195
196
197
198
199
struct oc_text_buf {
char *data;
int pos;
int buf_len;
int error;
};
Oct 13, 2018
Oct 13, 2018
200
201
#define TLS_MASTER_KEY_SIZE 48
202
203
204
#define RECONNECT_INTERVAL_MIN 10
#define RECONNECT_INTERVAL_MAX 100
Oct 28, 2012
Oct 28, 2012
205
206
207
208
#define REDIR_TYPE_NONE 0
#define REDIR_TYPE_NEWHOST 1
#define REDIR_TYPE_LOCAL 2
Jun 20, 2014
Jun 20, 2014
209
210
211
212
213
214
215
#define AUTH_TYPE_GSSAPI 0
#define AUTH_TYPE_NTLM 1
#define AUTH_TYPE_DIGEST 2
#define AUTH_TYPE_BASIC 3
#define MAX_AUTH_TYPES 4
Feb 24, 2015
Feb 24, 2015
216
#define AUTH_DEFAULT_DISABLED -3
Jun 20, 2014
Jun 20, 2014
217
#define AUTH_DISABLED -2
Jun 19, 2014
Jun 19, 2014
218
219
220
221
222
223
#define AUTH_FAILED -1 /* Failed */
#define AUTH_UNSEEN 0 /* Server has not offered it */
#define AUTH_AVAILABLE 1 /* Server has offered it, we have not tried it */
/* Individual auth types may use 2 onwards for their own state */
#define AUTH_IN_PROGRESS 2 /* In-progress attempt */
Feb 19, 2015
Feb 19, 2015
224
struct http_auth_state {
Jun 18, 2014
Jun 18, 2014
225
226
int state;
char *challenge;
Feb 24, 2015
Feb 24, 2015
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
union {
#ifdef HAVE_GSSAPI
struct {
gss_name_t gss_target_name;
gss_ctx_id_t gss_context;
};
#endif
#ifdef _WIN32
struct {
CredHandle ntlm_sspi_cred;
CtxtHandle ntlm_sspi_ctx;
};
struct {
CredHandle sspi_cred;
CtxtHandle sspi_ctx;
SEC_WCHAR *sspi_target_name;
};
#else
struct {
int ntlm_helper_fd;
};
#endif
};
Jun 18, 2014
Jun 18, 2014
250
251
};
Jan 26, 2015
Jan 26, 2015
252
struct vpn_proto {
May 16, 2016
May 16, 2016
253
const char *name;
May 14, 2017
May 14, 2017
254
255
const char *pretty_name;
const char *description;
Aug 2, 2018
Aug 2, 2018
256
const char *udp_protocol;
May 14, 2017
May 14, 2017
257
unsigned int flags;
Jan 26, 2015
Jan 26, 2015
258
int (*vpn_close_session)(struct openconnect_info *vpninfo, const char *reason);
Jan 26, 2015
Jan 26, 2015
259
Jan 26, 2015
Jan 26, 2015
260
261
262
/* This does the full authentication, calling back as appropriate */
int (*obtain_cookie)(struct openconnect_info *vpninfo);
Jan 26, 2015
Jan 26, 2015
263
264
265
266
267
/* Establish the TCP connection (and obtain configuration) */
int (*tcp_connect)(struct openconnect_info *vpninfo);
int (*tcp_mainloop)(struct openconnect_info *vpninfo, int *timeout);
Jan 26, 2015
Jan 26, 2015
268
269
270
/* Add headers common to each HTTP request */
void (*add_http_headers)(struct openconnect_info *vpninfo, struct oc_text_buf *buf);
Jan 26, 2015
Jan 26, 2015
271
272
273
274
275
276
277
278
279
280
281
282
/* Set up the UDP (DTLS) connection. Doesn't actually *start* it. */
int (*udp_setup)(struct openconnect_info *vpninfo, int attempt_period);
/* This will actually complete the UDP connection setup/handshake on the wire,
as well as transporting packets */
int (*udp_mainloop)(struct openconnect_info *vpninfo, int *timeout);
/* Close the connection but leave the session setup so it restarts */
void (*udp_close)(struct openconnect_info *vpninfo);
/* Close and destroy the (UDP) session */
void (*udp_shutdown)(struct openconnect_info *vpninfo);
Aug 14, 2017
Aug 14, 2017
283
284
285
286
287
288
/* Send probe packets to start or maintain the (UDP) session */
int (*udp_send_probes)(struct openconnect_info *vpninfo);
/* Catch probe packet confirming the (UDP) session */
int (*udp_catch_probe)(struct openconnect_info *vpninfo, struct pkt *p);
Jan 26, 2015
Jan 26, 2015
289
290
};
Jan 29, 2015
Jan 29, 2015
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
struct pkt_q {
struct pkt *head;
struct pkt **tail;
int count;
};
static inline struct pkt *dequeue_packet(struct pkt_q *q)
{
struct pkt *ret = q->head;
if (ret) {
q->head = ret->next;
if (!--q->count)
q->tail = &q->head;
}
return ret;
}
static inline void requeue_packet(struct pkt_q *q, struct pkt *p)
{
p->next = q->head;
q->head = p;
if (!q->count++)
q->tail = &p->next;
}
static inline int queue_packet(struct pkt_q *q, struct pkt *p)
{
*(q->tail) = p;
p->next = NULL;
q->tail = &p->next;
return ++q->count;
}
static inline void init_pkt_queue(struct pkt_q *q)
{
q->tail = &q->head;
}
Aug 25, 2016
Aug 25, 2016
329
330
#define DTLS_OVERHEAD (1 /* packet + header */ + 13 /* DTLS header */ + \
May 31, 2018
May 31, 2018
331
20 /* biggest supported MAC (SHA1) */ + 32 /* biggest supported IV (AES-256) */ + \
Aug 25, 2016
Aug 25, 2016
332
333
16 /* max padding */)
Jan 26, 2015
Jan 26, 2015
334
struct esp {
Sep 10, 2016
Sep 10, 2016
335
#if defined(OPENCONNECT_GNUTLS)
Jan 26, 2015
Jan 26, 2015
336
337
gnutls_cipher_hd_t cipher;
gnutls_hmac_hd_t hmac;
Sep 10, 2016
Sep 10, 2016
338
#elif defined(OPENCONNECT_OPENSSL)
Jul 8, 2016
Jul 8, 2016
339
340
HMAC_CTX *hmac, *pkt_hmac;
EVP_CIPHER_CTX *cipher;
Jan 26, 2015
Jan 26, 2015
341
#endif
Aug 30, 2016
Aug 30, 2016
342
uint64_t seq_backlog;
Aug 30, 2016
Aug 30, 2016
343
uint64_t seq;
Jan 26, 2015
Jan 26, 2015
344
uint32_t spi; /* Stored network-endian */
May 15, 2017
May 15, 2017
345
346
unsigned char enc_key[0x40]; /* Encryption key */
unsigned char hmac_key[0x40]; /* HMAC key */
Jan 26, 2015
Jan 26, 2015
347
348
};
Oct 3, 2018
Oct 3, 2018
349
struct oc_pcsc_ctx;
Oct 3, 2018
Oct 3, 2018
350
struct oc_tpm1_ctx;
Oct 3, 2018
Oct 3, 2018
351
struct oc_tpm2_ctx;
Oct 3, 2018
Oct 3, 2018
352
353
struct openconnect_info {
May 16, 2016
May 16, 2016
354
const struct vpn_proto *proto;
Jan 26, 2015
Jan 26, 2015
355
Jul 31, 2014
Jul 31, 2014
356
357
358
359
#ifdef HAVE_ICONV
iconv_t ic_legacy_to_utf8;
iconv_t ic_utf8_to_legacy;
#endif
Oct 28, 2012
Oct 28, 2012
361
int redirect_type;
Jan 26, 2015
Jan 26, 2015
363
364
365
366
367
368
369
unsigned char esp_hmac;
unsigned char esp_enc;
unsigned char esp_compr;
uint32_t esp_replay_protect;
uint32_t esp_lifetime_bytes;
uint32_t esp_lifetime_seconds;
uint32_t esp_ssl_fallback;
Jan 26, 2015
Jan 26, 2015
370
371
372
int current_esp_in;
int old_esp_maxseq;
struct esp esp_in[2];
Jan 26, 2015
Jan 26, 2015
373
struct esp esp_out;
May 15, 2017
May 15, 2017
374
375
int enc_key_len;
int hmac_key_len;
May 31, 2018
May 31, 2018
376
uint32_t esp_magic; /* GlobalProtect magic ping address (network-endian) */
Jan 26, 2015
Jan 26, 2015
377
Jan 26, 2015
Jan 26, 2015
378
int tncc_fd; /* For Juniper TNCC */
Jul 12, 2012
Jul 12, 2012
379
const char *csd_xmltag;
Jan 15, 2014
Jan 15, 2014
380
int csd_nostub;
Nov 4, 2014
Nov 4, 2014
381
char *platname;
Jan 15, 2014
Jan 15, 2014
382
383
384
char *mobile_platform_version;
char *mobile_device_type;
char *mobile_device_uniqueid;
385
386
387
388
389
390
391
392
char *csd_token;
char *csd_ticket;
char *csd_stuburl;
char *csd_starturl;
char *csd_waiturl;
char *csd_preurl;
char *csd_scriptname;
Oct 28, 2012
Oct 28, 2012
393
xmlNode *opaque_srvdata;
Jun 17, 2014
Jun 17, 2014
395
396
397
char *profile_url;
char *profile_sha1;
Sep 22, 2011
Sep 22, 2011
398
#ifdef LIBPROXY_HDR
399
400
401
402
403
pxProxyFactory *proxy_factory;
#endif
char *proxy_type;
char *proxy;
int proxy_port;
Jun 18, 2014
Jun 18, 2014
404
int proxy_fd;
Jun 18, 2014
Jun 18, 2014
405
406
char *proxy_user;
char *proxy_pass;
Jul 21, 2014
Jul 21, 2014
407
int proxy_close_during_auth;
Feb 24, 2015
Feb 24, 2015
408
409
int retry_on_auth_fail;
int try_http_auth;
Feb 20, 2015
Feb 20, 2015
410
struct http_auth_state http_auth[MAX_AUTH_TYPES];
Feb 19, 2015
Feb 19, 2015
411
struct http_auth_state proxy_auth[MAX_AUTH_TYPES];
Jan 15, 2014
Jan 15, 2014
413
char *localname;
Feb 22, 2013
Feb 22, 2013
415
char *unique_hostname;
416
417
int port;
char *urlpath;
Sep 29, 2011
Sep 29, 2011
418
int cert_expire_warning;
Nov 4, 2014
Nov 4, 2014
419
420
char *cert;
char *sslkey;
421
char *cert_password;
Jan 15, 2014
Jan 15, 2014
422
char *cafile;
Oct 28, 2014
Oct 28, 2014
423
unsigned no_system_trust;
424
const char *xmlconfig;
May 29, 2012
May 29, 2012
425
char xmlsha1[(SHA1_SIZE * 2) + 1];
426
427
char *authgroup;
int nopasswd;
May 30, 2013
May 30, 2013
428
int xmlpost;
Jan 10, 2019
Jan 10, 2019
430
char *dtls12_ciphers;
431
432
char *csd_wrapper;
int no_http_keepalive;
May 30, 2013
May 30, 2013
433
int dump_http_traffic;
Mar 23, 2013
Mar 23, 2013
435
436
437
438
int token_mode;
int token_bypassed;
int token_tries;
time_t token_time;
Mar 25, 2013
Mar 25, 2013
439
#ifdef HAVE_LIBSTOKEN
Oct 15, 2012
Oct 15, 2012
440
441
struct stoken_ctx *stoken_ctx;
char *stoken_pin;
Aug 2, 2014
Aug 2, 2014
442
443
int stoken_concat_pin;
int stoken_interval;
Mar 23, 2013
Mar 23, 2013
444
#endif
Aug 13, 2014
Aug 13, 2014
445
446
447
448
#ifdef HAVE_LIBPSKC
pskc_t *pskc;
pskc_key_t *pskc_key;
#endif
Mar 23, 2013
Mar 23, 2013
449
450
char *oath_secret;
size_t oath_secret_len;
Jan 30, 2015
Jan 30, 2015
451
452
453
454
455
enum {
OATH_ALG_HMAC_SHA1 = 0,
OATH_ALG_HMAC_SHA256,
OATH_ALG_HMAC_SHA512,
} oath_hmac_alg;
Aug 12, 2014
Aug 12, 2014
456
457
458
459
460
461
enum {
HOTP_SECRET_BASE32 = 1,
HOTP_SECRET_RAW,
HOTP_SECRET_HEX,
HOTP_SECRET_PSKC,
} hotp_secret_format; /* We need to give it back in the same form */
Oct 3, 2018
Oct 3, 2018
462
Nov 12, 2014
Nov 12, 2014
463
#ifdef HAVE_LIBPCSCLITE
Oct 3, 2018
Oct 3, 2018
464
struct oc_pcsc_ctx *pcsc;
Nov 14, 2014
Nov 14, 2014
465
unsigned char yubikey_pwhash[16];
Mar 23, 2013
Mar 23, 2013
466
#endif
Aug 12, 2014
Aug 12, 2014
467
468
469
openconnect_lock_token_vfn lock_token;
openconnect_unlock_token_vfn unlock_token;
void *tok_cbdata;
Oct 15, 2012
Oct 15, 2012
470
Nov 3, 2014
Nov 3, 2014
471
void *peer_cert;
May 15, 2017
May 15, 2017
472
473
474
475
476
/* The SHA1 and SHA256 hashes of the peer's public key */
uint8_t peer_cert_sha1_raw[SHA1_SIZE];
uint8_t peer_cert_sha256_raw[SHA256_SIZE];
/* this value is cache for openconnect_get_peer_cert_hash */
char *peer_cert_hash;
May 6, 2016
May 6, 2016
477
478
void *cert_list_handle;
int cert_list_size;
May 17, 2012
May 17, 2012
479
Mar 17, 2011
Mar 17, 2011
480
char *cookie; /* Pointer to within cookies list */
Jan 15, 2014
Jan 15, 2014
481
482
483
struct oc_vpn_option *cookies;
struct oc_vpn_option *cstp_options;
struct oc_vpn_option *dtls_options;
Oct 30, 2014
Oct 30, 2014
485
struct oc_vpn_option *script_env;
Oct 31, 2014
Oct 31, 2014
486
struct oc_vpn_option *csd_env;
Oct 30, 2014
Oct 30, 2014
487
Feb 3, 2014
Feb 3, 2014
488
unsigned pfs;
Jan 3, 2019
Jan 3, 2019
489
unsigned no_tls13;
May 29, 2012
May 29, 2012
490
#if defined(OPENCONNECT_OPENSSL)
Dec 17, 2014
Dec 17, 2014
491
492
493
494
495
496
497
498
#ifdef HAVE_LIBP11
PKCS11_CTX *pkcs11_ctx;
PKCS11_SLOT *pkcs11_slot_list;
unsigned int pkcs11_slot_count;
PKCS11_SLOT *pkcs11_cert_slot;
unsigned char *pkcs11_cert_id;
size_t pkcs11_cert_id_len;
#endif
May 29, 2012
May 29, 2012
499
X509 *cert_x509;
500
501
SSL_CTX *https_ctx;
SSL *https_ssl;
May 29, 2012
May 29, 2012
502
503
504
#elif defined(OPENCONNECT_GNUTLS)
gnutls_session_t https_sess;
gnutls_certificate_credentials_t https_cred;
Sep 21, 2016
Sep 21, 2016
505
gnutls_psk_client_credentials_t psk_cred;
Nov 17, 2014
Nov 17, 2014
506
char local_cert_md5[MD5_SIZE * 2 + 1]; /* For CSD */
Aug 6, 2015
Aug 6, 2015
507
char gnutls_prio[256];
Jun 13, 2012
Jun 13, 2012
508
#ifdef HAVE_TROUSERS
Oct 3, 2018
Oct 3, 2018
509
struct oc_tpm1_ctx *tpm1;
Jun 13, 2012
Jun 13, 2012
510
#endif
Oct 3, 2018
Oct 3, 2018
511
512
513
#ifdef HAVE_TSS2
struct oc_tpm2_ctx *tpm2;
#endif
Jun 14, 2012
Jun 14, 2012
514
#endif /* OPENCONNECT_GNUTLS */
Dec 17, 2014
Dec 17, 2014
515
struct pin_cache *pin_cache;
516
517
518
struct keepalive_info ssl_times;
int owe_ssl_dpd_response;
Jan 6, 2015
Jan 6, 2015
519
520
521
522
int deflate_pkt_size; /* It may need to be larger than MTU */
struct pkt *deflate_pkt; /* For compressing outbound packets into */
struct pkt *pending_deflated_pkt; /* The original packet associated with above */
struct pkt *current_ssl_pkt; /* Partially sent SSL packet */
Jan 29, 2015
Jan 29, 2015
523
struct pkt_q oncp_control_queue; /* Control packets to be sent on oNCP next */
Mar 14, 2015
Mar 14, 2015
524
int oncp_rec_size; /* For packetising incoming oNCP stream */
Jan 6, 2015
Jan 6, 2015
525
/* Packet buffers for receiving into */
Jan 6, 2015
Jan 6, 2015
526
struct pkt *cstp_pkt;
Jan 6, 2015
Jan 6, 2015
527
struct pkt *dtls_pkt;
Jul 31, 2014
Jul 31, 2014
528
struct pkt *tun_pkt;
Jan 26, 2015
Jan 26, 2015
529
530
int pkt_trailer; /* How many bytes after payload for encryption (ESP HMAC) */
531
532
533
534
535
536
537
538
539
540
z_stream inflate_strm;
uint32_t inflate_adler32;
z_stream deflate_strm;
uint32_t deflate_adler32;
int disable_ipv6;
int reconnect_timeout;
int reconnect_interval;
int dtls_attempt_period;
time_t new_dtls_started;
Sep 10, 2016
Sep 10, 2016
541
#if defined(OPENCONNECT_OPENSSL)
542
543
SSL_CTX *dtls_ctx;
SSL *dtls_ssl;
Sep 10, 2016
Sep 10, 2016
544
#elif defined(OPENCONNECT_GNUTLS)
Feb 11, 2014
Feb 11, 2014
545
546
547
548
/* Call this dtls_ssl rather than dtls_sess because it's just a
pointer, and generic code in dtls.c wants to check if it's
NULL or not or pass it to DTLS_SEND/DTLS_RECV. This way we
have fewer ifdefs and accessor macros for it. */
Jun 7, 2012
Jun 7, 2012
549
gnutls_session_t dtls_ssl;
Oct 28, 2014
Oct 28, 2014
550
char *gnutls_dtls_cipher; /* cached for openconnect_get_dtls_cipher() */
May 29, 2012
May 29, 2012
551
#endif
Nov 4, 2014
Nov 4, 2014
552
553
char *cstp_cipher;
Feb 11, 2014
Feb 11, 2014
554
int dtls_state;
Nov 18, 2014
Nov 18, 2014
555
int dtls_need_reconnect;
556
557
struct keepalive_info dtls_times;
unsigned char dtls_session_id[32];
Oct 13, 2018
Oct 13, 2018
558
unsigned char dtls_secret[TLS_MASTER_KEY_SIZE];
Sep 21, 2016
Sep 21, 2016
559
560
unsigned char dtls_app_id[32];
unsigned dtls_app_id_size;
Jan 9, 2019
Jan 9, 2019
562
int cisco_dtls12;
Jan 15, 2014
Jan 15, 2014
564
char *vpnc_script;
Dec 5, 2015
Dec 5, 2015
565
#ifndef _WIN32
Jan 22, 2016
Jan 22, 2016
566
567
568
int uid_csd_given;
uid_t uid_csd;
gid_t gid_csd;
Dec 5, 2015
Dec 5, 2015
569
uid_t uid;
Dec 5, 2015
Dec 5, 2015
570
gid_t gid;
Dec 5, 2015
Dec 5, 2015
571
572
#endif
int use_tun_script;
573
574
int script_tun;
char *ifname;
Dec 5, 2015
Dec 5, 2015
575
char *cmd_ifname;
Sep 23, 2016
Sep 23, 2016
577
int reqmtu, basemtu; /* Local static configured values */
Jan 15, 2014
Jan 15, 2014
579
580
struct oc_ip_info ip_info;
Sep 23, 2016
Sep 23, 2016
581
int cstp_basemtu; /* Returned by server */
Aug 6, 2018
Aug 6, 2018
582
int idle_timeout; /* Returned by server */
Feb 11, 2014
Feb 11, 2014
584
585
#ifdef _WIN32
long dtls_monitored, ssl_monitored, cmd_monitored, tun_monitored;
Feb 11, 2014
Feb 11, 2014
586
HANDLE dtls_event, ssl_event, cmd_event;
Feb 11, 2014
Feb 11, 2014
587
#else
Feb 11, 2014
Feb 11, 2014
588
589
590
591
int _select_nfds;
fd_set _select_rfds;
fd_set _select_wfds;
fd_set _select_efds;
Feb 11, 2014
Feb 11, 2014
592
#endif
593
594
595
#ifdef __sun__
int ip_fd;
Dec 12, 2011
Dec 12, 2011
596
int ip6_fd;
Feb 10, 2014
Feb 10, 2014
597
598
599
#endif
#ifdef _WIN32
HANDLE tun_fh;
Feb 11, 2014
Feb 11, 2014
600
OVERLAPPED tun_rd_overlap, tun_wr_overlap;
Sep 23, 2016
Sep 23, 2016
601
int tun_idx, tun_rd_pending;
Feb 11, 2014
Feb 11, 2014
602
#else
Feb 11, 2014
Feb 11, 2014
604
#endif
605
606
int ssl_fd;
int dtls_fd;
Jan 15, 2014
Jan 15, 2014
607
Aug 25, 2016
Aug 25, 2016
608
609
610
611
int dtls_tos_current;
int dtls_pass_tos;
int dtls_tos_proto, dtls_tos_optname;
Jan 15, 2014
Jan 15, 2014
612
int cmd_fd;
Jan 15, 2014
Jan 15, 2014
613
int cmd_fd_write;
Jan 15, 2014
Jan 15, 2014
614
int got_cancel_cmd;
Jan 15, 2014
Jan 15, 2014
615
int got_pause_cmd;
Jun 13, 2014
Jun 13, 2014
616
char cancel_type;
Jan 29, 2015
Jan 29, 2015
618
619
struct pkt_q incoming_queue;
struct pkt_q outgoing_queue;
Jan 15, 2014
Jan 15, 2014
621
622
struct oc_stats stats;
openconnect_stats_vfn stats_handler;
623
624
625
626
627
socklen_t peer_addrlen;
struct sockaddr *peer_addr;
struct sockaddr *dtls_addr;
Jun 25, 2012
Jun 25, 2012
628
629
int dtls_local_port;
Jan 6, 2015
Jan 6, 2015
630
631
632
633
int req_compr; /* What we requested */
int cstp_compr; /* Accepted for CSTP */
int dtls_compr; /* Accepted for DTLS */
Dec 5, 2014
Dec 5, 2014
634
int is_dyndns; /* Attempt to redo DNS lookup on each CSTP reconnect */
Oct 15, 2018
Oct 15, 2018
636
char *version_string;
Sep 15, 2011
Sep 15, 2011
638
const char *quit_reason;
Jan 31, 2015
Jan 31, 2015
640
int verbose;
Jun 27, 2011
Jun 27, 2011
641
642
643
644
645
void *cbdata;
openconnect_validate_peer_cert_vfn validate_peer_cert;
openconnect_write_new_config_vfn write_new_config;
openconnect_process_auth_form_vfn process_auth_form;
openconnect_progress_vfn progress;
Jan 15, 2014
Jan 15, 2014
646
openconnect_protect_socket_vfn protect_socket;
Mar 26, 2015
Mar 26, 2015
647
openconnect_getaddrinfo_vfn getaddrinfo_override;
Mar 8, 2016
Mar 8, 2016
648
openconnect_setup_tun_vfn setup_tun;
May 6, 2016
May 6, 2016
649
openconnect_reconnected_vfn reconnected;
Jun 18, 2014
Jun 18, 2014
650
651
652
653
int (*ssl_read)(struct openconnect_info *vpninfo, char *buf, size_t len);
int (*ssl_gets)(struct openconnect_info *vpninfo, char *buf, size_t len);
int (*ssl_write)(struct openconnect_info *vpninfo, char *buf, size_t len);
Feb 11, 2014
Feb 11, 2014
656
657
658
659
660
661
662
663
664
665
666
667
#ifdef _WIN32
#define monitor_read_fd(_v, _n) _v->_n##_monitored |= FD_READ
#define monitor_write_fd(_v, _n) _v->_n##_monitored |= FD_WRITE
#define monitor_except_fd(_v, _n) _v->_n##_monitored |= FD_CLOSE
#define unmonitor_read_fd(_v, _n) _v->_n##_monitored &= ~FD_READ
#define unmonitor_write_fd(_v, _n) _v->_n##_monitored &= ~FD_WRITE
#define unmonitor_except_fd(_v, _n) _v->_n##_monitored &= ~FD_CLOSE
#define monitor_fd_new(_v, _n) do { if (!_v->_n##_event) _v->_n##_event = CreateEvent(NULL, FALSE, FALSE, NULL); } while (0)
#define read_fd_monitored(_v, _n) (_v->_n##_monitored & FD_READ)
#else
Feb 11, 2014
Feb 11, 2014
668
669
670
671
672
673
674
675
676
677
678
679
680
#define monitor_read_fd(_v, _n) FD_SET(_v-> _n##_fd, &vpninfo->_select_rfds)
#define unmonitor_read_fd(_v, _n) FD_CLR(_v-> _n##_fd, &vpninfo->_select_rfds)
#define monitor_write_fd(_v, _n) FD_SET(_v-> _n##_fd, &vpninfo->_select_wfds)
#define unmonitor_write_fd(_v, _n) FD_CLR(_v-> _n##_fd, &vpninfo->_select_wfds)
#define monitor_except_fd(_v, _n) FD_SET(_v-> _n##_fd, &vpninfo->_select_efds)
#define unmonitor_except_fd(_v, _n) FD_CLR(_v-> _n##_fd, &vpninfo->_select_efds)
#define monitor_fd_new(_v, _n) do { \
if (_v->_select_nfds <= vpninfo->_n##_fd) \
vpninfo->_select_nfds = vpninfo->_n##_fd + 1; \
} while (0)
#define read_fd_monitored(_v, _n) FD_ISSET(_v->_n##_fd, &_v->_select_rfds)
Feb 11, 2014
Feb 11, 2014
681
#endif
Feb 11, 2014
Feb 11, 2014
682
Sep 21, 2016
Sep 21, 2016
683
684
685
686
687
/* Key material for DTLS-PSK */
#define PSK_LABEL "EXPORTER-openconnect-psk"
#define PSK_LABEL_SIZE sizeof(PSK_LABEL)-1
#define PSK_KEY_SIZE 32
688
689
690
691
692
693
694
695
696
697
/* Packet types */
#define AC_PKT_DATA 0 /* Uncompressed data */
#define AC_PKT_DPD_OUT 3 /* Dead Peer Detection */
#define AC_PKT_DPD_RESP 4 /* DPD response */
#define AC_PKT_DISCONN 5 /* Client disconnection notice */
#define AC_PKT_KEEPALIVE 7 /* Keepalive */
#define AC_PKT_COMPRESSED 8 /* Compressed data */
#define AC_PKT_TERM_SERVER 9 /* Server kick */
May 15, 2017
May 15, 2017
698
699
700
701
702
703
/* Encryption and HMAC algorithms (matching Juniper's binary encoding) */
#define ENC_AES_128_CBC 2
#define ENC_AES_256_CBC 5
#define HMAC_MD5 1
#define HMAC_SHA1 2
Jan 31, 2015
Jan 31, 2015
704
705
#define vpn_progress(_v, lvl, ...) do { \
if ((_v)->verbose >= (lvl)) \
Feb 4, 2015
Feb 4, 2015
706
(_v)->progress((_v)->cbdata, lvl, __VA_ARGS__); \
Jan 31, 2015
Jan 31, 2015
707
} while(0)
Aug 25, 2016
Aug 25, 2016
708
#define vpn_perror(vpninfo, msg) vpn_progress((vpninfo), PRG_ERR, "%s: %s\n", (msg), strerror(errno))
Jun 27, 2011
Jun 27, 2011
709
Apr 18, 2012
Apr 18, 2012
710
711
/****************************************************************************/
/* Oh Solaris how we hate thee! */
Feb 5, 2014
Feb 5, 2014
712
#ifdef HAVE_SUNOS_BROKEN_TIME
Apr 19, 2012
Apr 19, 2012
713
714
715
#define time(x) openconnect__time(x)
time_t openconnect__time(time_t *t);
#endif
Jul 28, 2014
Jul 28, 2014
716
717
718
719
#ifndef HAVE_VASPRINTF
#define vasprintf openconnect__vasprintf
int openconnect__vasprintf(char **strp, const char *fmt, va_list ap);
#endif
Apr 18, 2012
Apr 18, 2012
720
721
722
723
#ifndef HAVE_ASPRINTF
#define asprintf openconnect__asprintf
int openconnect__asprintf(char **strp, const char *fmt, ...);
#endif
May 3, 2012
May 3, 2012
724
725
726
727
#ifndef HAVE_GETLINE
#define getline openconnect__getline
ssize_t openconnect__getline(char **lineptr, size_t *n, FILE *stream);
#endif
Oct 13, 2012
Oct 13, 2012
728
729
730
731
#ifndef HAVE_STRCASESTR
#define strcasestr openconnect__strcasestr
char *openconnect__strcasestr(const char *haystack, const char *needle);
#endif
Jul 3, 2014
Jul 3, 2014
732
733
734
735
736
#ifndef HAVE_STRNDUP
#undef strndup
#define strndup openconnect__strndup
char *openconnect__strndup(const char *s, size_t n);
#endif
Apr 18, 2012
Apr 18, 2012
737
Feb 6, 2014
Feb 6, 2014
738
739
740
741
742
#ifndef HAVE_INET_ATON
#define inet_aton openconnect__inet_aton
int openconnect__inet_aton(const char *cp, struct in_addr *addr);
#endif
Feb 6, 2014
Feb 6, 2014
743
744
745
static inline int set_sock_nonblock(int fd)
{
#ifdef _WIN32
Feb 10, 2014
Feb 10, 2014
746
unsigned long mode = 1;
Feb 6, 2014
Feb 6, 2014
747
748
749
750
751
752
753
754
755
756
757
758
759
return ioctlsocket(fd, FIONBIO, &mode);
#else
return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
#endif
}
static inline int set_fd_cloexec(int fd)
{
#ifdef _WIN32
return 0; /* Windows has O_INHERIT but... */
#else
return fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
#endif
}
Mar 8, 2016
Mar 8, 2016
760
761
762
763
764
765
766
767
static inline int tun_is_up(struct openconnect_info *vpninfo)
{
#ifdef _WIN32
return vpninfo->tun_fh != NULL;
#else
return vpninfo->tun_fd != -1;
#endif
}
Feb 6, 2014
Feb 6, 2014
768
Feb 6, 2014
Feb 6, 2014
769
#ifdef _WIN32
Feb 6, 2014
Feb 6, 2014
770
#define pipe(fds) _pipe(fds, 4096, O_BINARY)
Oct 29, 2014
Oct 29, 2014
771
int openconnect__win32_sock_init();
Oct 28, 2014
Oct 28, 2014
772
char *openconnect__win32_strerror(DWORD err);
Jul 28, 2014
Jul 28, 2014
773
774
775
#undef inet_pton
#define inet_pton openconnect__win32_inet_pton
int openconnect__win32_inet_pton(int af, const char *src, void *dst);
Sep 15, 2014
Sep 15, 2014
776
777
#define OPENCONNECT_CMD_SOCKET SOCKET
OPENCONNECT_CMD_SOCKET dumb_socketpair(OPENCONNECT_CMD_SOCKET socks[2], int make_overlapped);
Feb 6, 2014
Feb 6, 2014
778
779
#else
#define closesocket close
Sep 15, 2014
Sep 15, 2014
780
#define OPENCONNECT_CMD_SOCKET int
Feb 6, 2014
Feb 6, 2014
781
782
783
#ifndef O_BINARY
#define O_BINARY 0
#endif
Feb 6, 2014
Feb 6, 2014
784
785
#endif
Jul 31, 2014
Jul 31, 2014
786
787
788
789
790
791
/* For systems that don't support O_CLOEXEC, just don't bother.
We don't keep files open for long anyway. */
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
Feb 18, 2013
Feb 18, 2013
792
793
794
795
796
797
798
799
/* I always coded as if it worked like this. Now it does. */
#define realloc_inplace(p, size) do { \
void *__realloc_old = p; \
p = realloc(p, size); \
if (size && !p) \
free(__realloc_old); \
} while (0)
800
801
/****************************************************************************/
Jul 31, 2014
Jul 31, 2014
802
803
804
805
806
807
808
809
810
/* iconv.c */
#ifdef HAVE_ICONV
char *openconnect_utf8_to_legacy(struct openconnect_info *vpninfo, const char *utf8);
char *openconnect_legacy_to_utf8(struct openconnect_info *vpninfo, const char *legacy);
#else
#define openconnect_utf8_to_legacy(v, str) ((char *)str)
#define openconnect_legacy_to_utf8(v, str) ((char *)str)
#endif
Feb 13, 2014
Feb 13, 2014
811
/* script.c */
Jan 26, 2015
Jan 26, 2015
812
unsigned char unhex(const char *data);
Oct 30, 2014
Oct 30, 2014
813
814
815
int script_setenv(struct openconnect_info *vpninfo, const char *opt, const char *val, int append);
int script_setenv_int(struct openconnect_info *vpninfo, const char *opt, int value);
void prepare_script_env(struct openconnect_info *vpninfo);
Feb 13, 2014
Feb 13, 2014
816
int script_config_tun(struct openconnect_info *vpninfo, const char *reason);
Oct 31, 2014
Oct 31, 2014
817
int apply_script_env(struct oc_vpn_option *envs);
Jan 26, 2015
Jan 26, 2015
818
void free_split_routes(struct openconnect_info *vpninfo);
Feb 13, 2014
Feb 13, 2014
819
Feb 13, 2014
Feb 13, 2014
820
/* tun.c / tun-win32.c */
Feb 13, 2014
Feb 13, 2014
821
void os_shutdown_tun(struct openconnect_info *vpninfo);
Mar 11, 2014
Mar 11, 2014
822
int os_read_tun(struct openconnect_info *vpninfo, struct pkt *pkt);
Feb 13, 2014
Feb 13, 2014
823
int os_write_tun(struct openconnect_info *vpninfo, struct pkt *pkt);
Feb 14, 2014
Feb 14, 2014
824
intptr_t os_setup_tun(struct openconnect_info *vpninfo);
Sep 10, 2016
Sep 10, 2016
826
827
828
829
/* {gnutls,openssl}-dtls.c */
int start_dtls_handshake(struct openconnect_info *vpninfo, int dtls_fd);
int dtls_try_handshake(struct openconnect_info *vpninfo);
unsigned dtls_set_mtu(struct openconnect_info *vpninfo, unsigned mtu);
Sep 12, 2016
Sep 12, 2016
830
void dtls_ssl_free(struct openconnect_info *vpninfo);
Sep 10, 2016
Sep 10, 2016
831
Jan 26, 2015
Jan 26, 2015
833
int dtls_setup(struct openconnect_info *vpninfo, int dtls_attempt_period);
834
int dtls_mainloop(struct openconnect_info *vpninfo, int *timeout);
Feb 11, 2014
Feb 11, 2014
835
void dtls_close(struct openconnect_info *vpninfo);
Mar 19, 2014
Mar 19, 2014
836
void dtls_shutdown(struct openconnect_info *vpninfo);
Jan 9, 2019
Jan 9, 2019
837
void gather_dtls_ciphers(struct openconnect_info *vpninfo, struct oc_text_buf *buf, struct oc_text_buf *buf12);
Sep 10, 2016
Sep 10, 2016
838
void dtls_detect_mtu(struct openconnect_info *vpninfo);
Sep 10, 2016
Sep 10, 2016
839
840
int openconnect_dtls_read(struct openconnect_info *vpninfo, void *buf, size_t len, unsigned ms);
int openconnect_dtls_write(struct openconnect_info *vpninfo, void *buf, size_t len);
Dec 13, 2016
Dec 13, 2016
841
char *openconnect_bin2hex(const char *prefix, const uint8_t *data, unsigned len);
May 15, 2017
May 15, 2017
842
char *openconnect_bin2base64(const char *prefix, const uint8_t *data, unsigned len);
Sep 10, 2016
Sep 10, 2016
843
Jan 26, 2015
Jan 26, 2015
845
void cstp_common_headers(struct openconnect_info *vpninfo, struct oc_text_buf *buf);
Jan 26, 2015
Jan 26, 2015
846
int cstp_connect(struct openconnect_info *vpninfo);
847
int cstp_mainloop(struct openconnect_info *vpninfo, int *timeout);
Sep 15, 2011
Sep 15, 2011
848
int cstp_bye(struct openconnect_info *vpninfo, const char *reason);
Feb 18, 2015
Feb 18, 2015
849
int decompress_and_queue_packet(struct openconnect_info *vpninfo, int compr_type,
Jan 7, 2015
Jan 7, 2015
850
unsigned char *buf, int len);
Jan 15, 2015
Jan 15, 2015
851
int compress_packet(struct openconnect_info *vpninfo, int compr_type, struct pkt *this);
Feb 6, 2015
Feb 6, 2015
853
854
855
856
/* auth-juniper.c */
int oncp_obtain_cookie(struct openconnect_info *vpninfo);
void oncp_common_headers(struct openconnect_info *vpninfo, struct oc_text_buf *buf);
Jan 26, 2015
Jan 26, 2015
857
858
859
/* oncp.c */
int oncp_connect(struct openconnect_info *vpninfo);
int oncp_mainloop(struct openconnect_info *vpninfo, int *timeout);
May 14, 2017
May 14, 2017
860
int oncp_bye(struct openconnect_info *vpninfo, const char *reason);
May 30, 2018
May 30, 2018
861
void oncp_esp_close(struct openconnect_info *vpninfo);
Feb 27, 2018
Feb 27, 2018
862
863
int oncp_esp_send_probes(struct openconnect_info *vpninfo);
int oncp_esp_catch_probe(struct openconnect_info *vpninfo, struct pkt *pkt);
Jan 26, 2015
Jan 26, 2015
864
May 31, 2018
May 31, 2018
865
866
867
868
869
870
/* auth-globalprotect.c */
int gpst_obtain_cookie(struct openconnect_info *vpninfo);
void gpst_common_headers(struct openconnect_info *vpninfo, struct oc_text_buf *buf);
int gpst_bye(struct openconnect_info *vpninfo, const char *reason);
/* gpst.c */
Sep 30, 2018
Sep 30, 2018
871
872
873
874
int gpst_xml_or_error(struct openconnect_info *vpninfo, char *response,
int (*xml_cb)(struct openconnect_info *, xmlNode *xml_node, void *cb_data),
int (*challenge_cb)(struct openconnect_info *, char *prompt, char *inputStr, void *cb_data),
void *cb_data);
May 31, 2018
May 31, 2018
875
876
int gpst_setup(struct openconnect_info *vpninfo);
int gpst_mainloop(struct openconnect_info *vpninfo, int *timeout);
May 31, 2018
May 31, 2018
877
878
int gpst_esp_send_probes(struct openconnect_info *vpninfo);
int gpst_esp_catch_probe(struct openconnect_info *vpninfo, struct pkt *pkt);
May 31, 2018
May 31, 2018
879
Jan 7, 2015
Jan 7, 2015
880
881
/* lzs.c */
int lzs_decompress(unsigned char *dst, int dstlen, const unsigned char *src, int srclen);
Jan 7, 2015
Jan 7, 2015
882
int lzs_compress(unsigned char *dst, int dstlen, const unsigned char *src, int srclen);
Jan 7, 2015
Jan 7, 2015
883
Mar 3, 2014
Mar 3, 2014
885
unsigned string_is_hostname(const char* str);
May 29, 2012
May 29, 2012
886
int connect_https_socket(struct openconnect_info *vpninfo);
Oct 29, 2014
Oct 29, 2014
887
888
int __attribute__ ((format(printf, 4, 5)))
request_passphrase(struct openconnect_info *vpninfo, const char *label,
Jun 4, 2012
Jun 4, 2012
889
char **response, const char *fmt, ...);
890
int __attribute__ ((format (printf, 2, 3)))
May 12, 2012
May 12, 2012
891
openconnect_SSL_printf(struct openconnect_info *vpninfo, const char *fmt, ...);
Jun 14, 2012
Jun 14, 2012
892
893
int openconnect_print_err_cb(const char *str, size_t len, void *ptr);
#define openconnect_report_ssl_errors(v) ERR_print_errors_cb(openconnect_print_err_cb, (v))
Mar 11, 2013
Mar 11, 2013
894
#if defined(FAKE_ANDROID_KEYSTORE) || defined(__ANDROID__)
Jun 17, 2012
Jun 17, 2012
895
896
897
#define ANDROID_KEYSTORE
#endif
#ifdef ANDROID_KEYSTORE
Mar 3, 2013
Mar 3, 2013
898
const char *keystore_strerror(int err);
Jun 17, 2012
Jun 17, 2012
899
900
int keystore_fetch(const char *key, unsigned char **result);
#endif
Jan 15, 2014
Jan 15, 2014
901
void cmd_fd_set(struct openconnect_info *vpninfo, fd_set *fds, int *maxfd);
Jan 15, 2014
Jan 15, 2014
902
void check_cmd_fd(struct openconnect_info *vpninfo, fd_set *fds);
Jan 15, 2014
Jan 15, 2014
903
int is_cancel_pending(struct openconnect_info *vpninfo, fd_set *fds);
Jan 15, 2014
Jan 15, 2014
904
void poll_cmd_fd(struct openconnect_info *vpninfo, int timeout);
Aug 3, 2014
Aug 3, 2014
905
906
907
908
int openconnect_open_utf8(struct openconnect_info *vpninfo,
const char *fname, int mode);
FILE *openconnect_fopen_utf8(struct openconnect_info *vpninfo,
const char *fname, const char *mode);
Jan 26, 2015
Jan 26, 2015
909
int udp_sockaddr(struct openconnect_info *vpninfo, int port);
Jan 26, 2015
Jan 26, 2015
910
int udp_connect(struct openconnect_info *vpninfo);
Feb 2, 2015
Feb 2, 2015
911
int ssl_reconnect(struct openconnect_info *vpninfo);
Oct 10, 2014
Oct 10, 2014
912
void openconnect_clear_cookies(struct openconnect_info *vpninfo);
Jan 4, 2019
Jan 4, 2019
913
914
int cancellable_gets(struct openconnect_info *vpninfo, int fd,
char *buf, size_t len);
Oct 10, 2014
Oct 10, 2014
915
Jan 4, 2019
Jan 4, 2019
916
917
918
919
int cancellable_send(struct openconnect_info *vpninfo, int fd,
char *buf, size_t len);
int cancellable_recv(struct openconnect_info *vpninfo, int fd,
char *buf, size_t len);
Dec 17, 2014
Dec 17, 2014
920
921
922
923
/* openssl-pkcs11.c */
int load_pkcs11_key(struct openconnect_info *vpninfo);
int load_pkcs11_certificate(struct openconnect_info *vpninfo);
Jan 26, 2015
Jan 26, 2015
924
925
926
/* esp.c */
int verify_packet_seqno(struct openconnect_info *vpninfo,
struct esp *esp, uint32_t seq);
Jan 26, 2015
Jan 26, 2015
927
928
929
930
int esp_setup(struct openconnect_info *vpninfo, int dtls_attempt_period);
int esp_mainloop(struct openconnect_info *vpninfo, int *timeout);
void esp_close(struct openconnect_info *vpninfo);
void esp_shutdown(struct openconnect_info *vpninfo);
Jan 26, 2015
Jan 26, 2015
931
int print_esp_keys(struct openconnect_info *vpninfo, const char *name, struct esp *esp);
Jan 26, 2015
Jan 26, 2015
932
Jan 26, 2015
Jan 26, 2015
933
/* {gnutls,openssl}-esp.c */
Aug 14, 2017
Aug 14, 2017
934
int setup_esp_keys(struct openconnect_info *vpninfo, int new_keys);
Jan 26, 2015
Jan 26, 2015
935
void destroy_esp_ciphers(struct esp *esp);
Jan 26, 2015
Jan 26, 2015
936
int decrypt_esp_packet(struct openconnect_info *vpninfo, struct esp *esp, struct pkt *pkt);
Jan 26, 2015
Jan 26, 2015
937
int encrypt_esp_packet(struct openconnect_info *vpninfo, struct pkt *pkt);
Jan 26, 2015
Jan 26, 2015
938
Jan 15, 2014
Jan 15, 2014
939
/* {gnutls,openssl}.c */
Jan 26, 2015
Jan 26, 2015
940
941
int ssl_nonblock_read(struct openconnect_info *vpninfo, void *buf, int maxlen);
int ssl_nonblock_write(struct openconnect_info *vpninfo, void *buf, int buflen);
942
int openconnect_open_https(struct openconnect_info *vpninfo);
Jun 9, 2012
Jun 9, 2012
943
void openconnect_close_https(struct openconnect_info *vpninfo, int final);
Feb 16, 2014
Feb 16, 2014
944
int cstp_handshake(struct openconnect_info *vpninfo, unsigned init);
Nov 3, 2014
Nov 3, 2014
945
int get_cert_md5_fingerprint(struct openconnect_info *vpninfo, void *cert,
May 29, 2012
May 29, 2012
947
int openconnect_sha1(unsigned char *result, void *data, int len);
Dec 13, 2016
Dec 13, 2016
948
int openconnect_sha256(unsigned char *result, void *data, int len);
Jun 19, 2014
Jun 19, 2014
949
int openconnect_md5(unsigned char *result, void *data, int len);
May 29, 2012
May 29, 2012
950
int openconnect_random(void *bytes, int len);
May 29, 2012
May 29, 2012
951
952
int openconnect_local_cert_md5(struct openconnect_info *vpninfo,
char *buf);
Nov 14, 2014
Nov 14, 2014
953
954
955
int openconnect_yubikey_chalresp(struct openconnect_info *vpninfo,
const void *challenge, int chall_len, void *result);
int openconnect_hash_yubikey_password(struct openconnect_info *vpninfo,
Feb 4, 2015
Feb 4, 2015
956
957
const char *password, int pwlen,
const void *ident, int id_len);
Jan 30, 2015
Jan 30, 2015
958
int hotp_hmac(struct openconnect_info *vpninfo, const void *challenge);
May 22, 2013
May 22, 2013
959
960
961
962
963
#if defined(OPENCONNECT_OPENSSL)
#define openconnect_https_connected(_v) ((_v)->https_ssl)
#elif defined (OPENCONNECT_GNUTLS)
#define openconnect_https_connected(_v) ((_v)->https_sess)
#endif
May 29, 2012
May 29, 2012
964
Feb 13, 2014
Feb 13, 2014
966
int tun_mainloop(struct openconnect_info *vpninfo, int *timeout);
Jan 29, 2015
Jan 29, 2015
967
int queue_new_packet(struct pkt_q *q, void *buf, int len);
968
int keepalive_action(struct keepalive_info *ka, int *timeout);
Aug 3, 2012
Aug 3, 2012
969
int ka_stalled_action(struct keepalive_info *ka, int *timeout);
May 31, 2018
May 31, 2018
970
int ka_check_deadline(int *timeout, time_t now, time_t due);
Aug 2, 2014
Aug 2, 2014
973
974
ssize_t read_file_into_string(struct openconnect_info *vpninfo, const char *fname,
char **ptr);
975
976
int config_lookup_host(struct openconnect_info *vpninfo, const char *host);
Aug 13, 2014
Aug 13, 2014
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
/* oath.c */
int set_totp_mode(struct openconnect_info *vpninfo, const char *token_str);
int set_hotp_mode(struct openconnect_info *vpninfo, const char *token_str);
int can_gen_totp_code(struct openconnect_info *vpninfo,
struct oc_auth_form *form,
struct oc_form_opt *opt);
int can_gen_hotp_code(struct openconnect_info *vpninfo,
struct oc_auth_form *form,
struct oc_form_opt *opt);
int do_gen_totp_code(struct openconnect_info *vpninfo,
struct oc_auth_form *form,
struct oc_form_opt *opt);
int do_gen_hotp_code(struct openconnect_info *vpninfo,
struct oc_auth_form *form,
struct oc_form_opt *opt);
Aug 13, 2014
Aug 13, 2014
993
994
995
996
997
998
999
1000
/* stoken.c */
int prepare_stoken(struct openconnect_info *vpninfo);
int set_libstoken_mode(struct openconnect_info *vpninfo, const char *token_str);
int can_gen_stoken_code(struct openconnect_info *vpninfo,
struct oc_auth_form *form,
struct oc_form_opt *opt);
int do_gen_stoken_code(struct openconnect_info *vpninfo,
struct oc_auth_form *form,