Ty Coon, President of Vice
That's all there is to it!
-
-
#include <config.h>
+#include "openconnect-internal.h"
+
+#include "json.h"
+
#include <unistd.h>
#include <fcntl.h>
-#include <time.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
#include <sys/types.h>
-#include <stdarg.h>
-#include <sys/types.h>
-
#ifdef _WIN32
#include "win32-ipicmp.h"
#else
/* The BSDs require the first two headers before netinet/ip.h
* (Linux and macOS already #include them within netinet/ip.h)
*/
-#include <sys/types.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/icmp6.h>
#endif
-#include "json.h"
-
-#include "openconnect-internal.h"
+#include <time.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
static struct oc_auth_form *plain_auth_form(void)
{
free(res_buf);
return ret;
}
-
#include <config.h>
+#include "openconnect-internal.h"
+
#include <unistd.h>
#include <fcntl.h>
+#include <sys/types.h>
+
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
-#include <sys/types.h>
#include <stdarg.h>
-#include "openconnect-internal.h"
-
int xmlnode_is_named(xmlNode *xml_node, const char *name)
{
return !strcmp((char *)xml_node->name, name);
#include <config.h>
-#include <ctype.h>
-#include <errno.h>
+#include "openconnect-internal.h"
#include <libxml/parser.h>
#include <libxml/tree.h>
-#include "openconnect-internal.h"
+#include <ctype.h>
+#include <errno.h>
struct login_context {
char *username; /* Username that has already succeeded in some form */
#include <config.h>
-#include <errno.h>
+#include "openconnect-internal.h"
#include <libxml/HTMLparser.h>
#include <libxml/HTMLtree.h>
-#include "openconnect-internal.h"
+#include <errno.h>
xmlNodePtr htmlnode_next(xmlNodePtr top, xmlNodePtr node)
{
#include <config.h>
+#include "openconnect-internal.h"
+
+#include <libxml/HTMLparser.h>
+#include <libxml/HTMLtree.h>
+
#include <unistd.h>
#include <fcntl.h>
+#include <sys/types.h>
+#ifndef _WIN32
+#include <sys/wait.h>
+#endif
+
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
-#include <sys/types.h>
#include <stdarg.h>
-#include <sys/types.h>
-#ifndef _WIN32
-#include <sys/wait.h>
-#endif
-
-#include <libxml/HTMLparser.h>
-#include <libxml/HTMLtree.h>
-
-#include "openconnect-internal.h"
/* XX: This is actually a lot of duplication with the CSTP version. */
void oncp_common_headers(struct openconnect_info *vpninfo, struct oc_text_buf *buf)
#include <config.h>
-#include <stdio.h>
+#include "openconnect-internal.h"
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
#include <unistd.h>
#include <fcntl.h>
-#include <time.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifndef _WIN32
#include <grp.h>
#endif
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include "openconnect-internal.h"
+#include <stdio.h>
+#include <time.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
static int xmlpost_append_form_opts(struct openconnect_info *vpninfo,
struct oc_auth_form *form, struct oc_text_buf *body);
#include <config.h>
+#include "openconnect-internal.h"
+
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#endif
#endif
-#include "openconnect-internal.h"
-
#ifdef HAVE_SUNOS_BROKEN_TIME
/*
* On SunOS, time() goes backwards. Thankfully, gethrtime() doesn't.
#include <config.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <time.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <stdarg.h>
+#include "openconnect-internal.h"
+
#ifdef HAVE_LZ4
#include <lz4.h>
#ifndef HAVE_LZ4_COMPRESS_DEFAULT
#endif
#endif
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
#if defined(__linux__)
/* For TCP_INFO */
# include <linux/tcp.h>
#endif
-#include "openconnect-internal.h"
+#include <time.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
/*
* Data packets are encapsulated in the SSL stream as follows:
#include <config.h>
+#include "openconnect-internal.h"
+
#include <errno.h>
#include <string.h>
#include <ctype.h>
-#include "openconnect-internal.h"
-
#define ALGO_MD5 0
#define ALGO_MD5_SESS 1
#include <config.h>
-#include <errno.h>
-#include <sys/types.h>
+#include "openconnect-internal.h"
+
#include <unistd.h>
+#include <sys/types.h>
#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
#ifndef _WIN32
#include <netinet/in.h>
#include <sys/socket.h>
#endif
-#include "openconnect-internal.h"
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
/*
* The master-secret is generated randomly by the client. The server
#include <config.h>
-#include <stdint.h>
+#include "openconnect-internal.h"
+
#include <inttypes.h>
+#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
-#include "openconnect-internal.h"
-
#define DTLS_EMPTY_BITMAP (0xFFFFFFFFFFFFFFFFULL)
/* Eventually we're going to have to have more than one incoming ESP
}
}
}
-
#include <config.h>
+#include "openconnect-internal.h"
+
+#include "lzo.h"
+
+#include <unistd.h>
+
#include <stdio.h>
#include <stdint.h>
-#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
-#include "openconnect-internal.h"
-#include "lzo.h"
-
int print_esp_keys(struct openconnect_info *vpninfo, const char *name, struct esp *esp)
{
int i;
#include <config.h>
+#include "openconnect-internal.h"
+
+#include "ppp.h"
+
+#include <libxml/HTMLparser.h>
+#include <libxml/HTMLtree.h>
+
#include <unistd.h>
#include <fcntl.h>
+#include <sys/types.h>
+
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
-#include <sys/types.h>
#include <stdarg.h>
-#include <sys/types.h>
-
-#include <libxml/HTMLparser.h>
-#include <libxml/HTMLtree.h>
-
-#include "openconnect-internal.h"
-#include "ppp.h"
#define XCAST(x) ((const xmlChar *)(x))
#include <config.h>
+#include "openconnect-internal.h"
+
+#include "ppp.h"
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
#include <unistd.h>
#include <fcntl.h>
+#include <sys/types.h>
+
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
-#include <sys/types.h>
#include <stdarg.h>
-#include <sys/types.h>
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include "openconnect-internal.h"
-#include "ppp.h"
/* clthello/svrhello strings for Fortinet DTLS initialization.
* NB: C string literals implicitly add a final \0 (which is correct for these).
#include <config.h>
-#include <errno.h>
-#include <sys/types.h>
+#include "gnutls.h"
+
+#include <gnutls/dtls.h>
+
#include <unistd.h>
#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
+#include <sys/types.h>
#ifndef _WIN32
#include <netinet/in.h>
#include <sys/socket.h>
#endif
-
-#include <gnutls/dtls.h>
-#include "gnutls.h"
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
#if GNUTLS_VERSION_NUMBER < 0x030400
# define GNUTLS_CIPHER_CHACHA20_POLY1305 23
#include <config.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
+#include "openconnect-internal.h"
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
-#include "openconnect-internal.h"
+#include <unistd.h>
+
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
void destroy_esp_ciphers(struct esp *esp)
{
#include <config.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <stdlib.h>
+#include "openconnect-internal.h"
+
+#include "gnutls.h"
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <p11-kit/pin.h>
#endif
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
#if defined(HAVE_P11KIT) || defined(HAVE_GNUTLS_SYSTEM_KEYS)
static int gnutls_pin_callback(void *priv, int attempt, const char *uri,
const char *token_label, unsigned int flags,
char *pin, size_t pin_max);
#endif /* HAVE_P11KIT || HAVE_GNUTLS_SYSTEM_KEYS */
-#include "gnutls.h"
-#include "openconnect-internal.h"
-
/* GnuTLS 2.x lacked this. But GNUTLS_E_UNEXPECTED_PACKET_LENGTH basically
* does the same thing.
* https://lists.infradead.org/pipermail/openconnect-devel/2014-March/001726.html
#ifndef __OPENCONNECT_GNUTLS_H__
#define __OPENCONNECT_GNUTLS_H__
+#include "openconnect-internal.h"
+
#include <gnutls/gnutls.h>
#include <gnutls/pkcs12.h>
#include <gnutls/abstract.h>
-#include "openconnect-internal.h"
-
int load_tpm1_key(struct openconnect_info *vpninfo, struct cert_info *certinfo,
gnutls_datum_t *fdata, gnutls_privkey_t *pkey, gnutls_datum_t *pkey_sig);
void release_tpm1_ctx(struct openconnect_info *info, struct cert_info *certinfo);
#include <config.h>
-#include <errno.h>
-#include <string.h>
-
-#include <gnutls/gnutls.h>
#include "openconnect-internal.h"
#include "gnutls.h"
+#include <gnutls/gnutls.h>
+
+#include <errno.h>
+#include <string.h>
+
#ifdef HAVE_TROUSERS
#include <trousers/tss.h>
#include <trousers/trousers.h>
#include <config.h>
-#include <errno.h>
-#include <string.h>
-
-#include <gnutls/gnutls.h>
#include "openconnect-internal.h"
+
#include "gnutls.h"
+#include <gnutls/gnutls.h>
+
+#include <errno.h>
+#include <string.h>
+
#ifdef HAVE_TSS2
#include <libtasn1.h>
* THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
-#include "config.h"
+#include <config.h>
#include "openconnect-internal.h"
-#include "gnutls.h"
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
+#include "gnutls.h"
#include <tss2/tss2_mu.h>
#include <tss2/tss2_esys.h>
#include <tss2/tss2_tctildr.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
struct oc_tpm2_ctx {
TSS2_TCTI_CONTEXT *tcti_ctx;
TPM2B_PUBLIC pub;
* Lesser General Public License for more details.
*/
-#include "config.h"
+#include <config.h>
#include "openconnect-internal.h"
+
#include "gnutls.h"
#include <stdio.h>
#include <config.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <time.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#ifndef _WIN32
-#include <sys/wait.h>
-#endif
-#include <stdarg.h>
+#include "openconnect-internal.h"
+
#ifdef HAVE_LZ4
#include <lz4.h>
#endif
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
#ifdef _WIN32
#include "win32-ipicmp.h"
#else
+#include <sys/wait.h>
/* The BSDs require the first two headers before netinet/ip.h
* (Linux and macOS already #include them within netinet/ip.h)
*/
-#include <sys/types.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
# include <linux/tcp.h>
#endif
-#include "openconnect-internal.h"
+#include <time.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
/*
* Data packets are encapsulated in the SSL stream as follows:
#include <config.h>
+#include "openconnect-internal.h"
+
#include <errno.h>
#include <string.h>
-#include "openconnect-internal.h"
-
static void print_gss_err(struct openconnect_info *vpninfo, const char *where,
gss_OID mech, OM_uint32 err_maj, OM_uint32 err_min)
{
#include <config.h>
+#include "openconnect-internal.h"
+
#include <unistd.h>
#include <fcntl.h>
+
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
-#include "openconnect-internal.h"
-
static int basic_authorization(struct openconnect_info *vpninfo, int proxy,
struct http_auth_state *auth_state,
struct oc_text_buf *hdrbuf)
#include <config.h>
+#include "openconnect-internal.h"
+
+#include <libxml/uri.h>
+
#include <unistd.h>
#include <fcntl.h>
+
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
-#include <libxml/uri.h>
-
-#include "openconnect-internal.h"
-
static int proxy_write(struct openconnect_info *vpninfo, char *buf, size_t len);
static int proxy_read(struct openconnect_info *vpninfo, char *buf, size_t len);
#include <config.h>
+#include "openconnect-internal.h"
+
#include <iconv.h>
+
#include <errno.h>
#include <string.h>
-#include "openconnect-internal.h"
-
static char *convert_str(struct openconnect_info *vpninfo, iconv_t ic,
char *instr)
#include <config.h>
+#include "openconnect.h"
+
+#include <jni.h>
+
+#include <unistd.h>
+#include <sys/types.h>
+
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-#include <jni.h>
-#include "openconnect.h"
struct libctx {
JNIEnv *jenv;
#include <config.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
+#include "openconnect-internal.h"
#include "json.h"
-#include "openconnect-internal.h"
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
/*
* Copyright (C) 2015 Mirko Pasqualetti All rights reserved.
dump_json_value(vpninfo, lvl, buf, value, 0);
buf_free(buf);
}
-
#include <config.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
+#include "openconnect-internal.h"
+
+#if defined(OPENCONNECT_GNUTLS)
+#include "gnutls.h"
+#endif
#ifdef HAVE_LIBSTOKEN
#include <stoken.h>
#include <libxml/tree.h>
#include <zlib.h>
-#include "openconnect-internal.h"
-
-#if defined(OPENCONNECT_GNUTLS)
-#include "gnutls.h"
-#endif
-
#if defined(OPENCONNECT_OPENSSL)
#include <openssl/bio.h>
#endif
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <ctype.h>
+
struct openconnect_info *openconnect_vpninfo_new(const char *useragent,
openconnect_validate_peer_cert_vfn validate_peer_cert,
openconnect_write_new_config_vfn write_new_config,
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <string.h>
-#include <limits.h>
-
//#include "avutil.h"
//#include "avassert.h"
//#include "common.h"
//#include "intreadwrite.h"
#include "lzo.h"
+#include <string.h>
+#include <limits.h>
+
/// Define if we may write up to 12 bytes beyond the output buffer.
#define OUTBUF_PADDED 1
/// Define if we may read up to 8 bytes beyond the input buffer.
#include <config.h>
+#include "openconnect-internal.h"
+
#include <errno.h>
#include <string.h>
#include <stdint.h>
-#include "openconnect-internal.h"
-
#define GET_BITS(bits) \
do { \
/* Strictly speaking, this check ought to be on \
#include <config.h>
+#include "openconnect-internal.h"
+
#ifdef HAVE_GETLINE
/* Various BSD systems require this for getline() to be visible */
#define _WITH_GETLINE
#endif
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <string.h>
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#include <errno.h>
+#include <getopt.h>
+
#include <fcntl.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/types.h>
-#include <getopt.h>
-#include <time.h>
#include <locale.h>
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
#ifdef LIBPROXY_HDR
#include LIBPROXY_HDR
#endif
-#include "openconnect-internal.h"
-
#ifdef _WIN32
#include <shlwapi.h>
#include <wtypes.h>
#include <termios.h>
#endif
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+
#ifdef HAVE_NL_LANGINFO
#include <langinfo.h>
#include <config.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdlib.h>
+#include "openconnect-internal.h"
+
#include <unistd.h>
-#include <string.h>
#ifndef _WIN32
/* for setgroups() */
# include <sys/types.h>
# include <grp.h>
#endif
-#include "openconnect-internal.h"
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
int queue_new_packet(struct openconnect_info *vpninfo,
struct pkt_q *q, void *buf, int len)
*/
#include <config.h>
+
#include "openconnect-internal.h"
#if defined(__linux__)
#include <config.h>
+#include "openconnect-internal.h"
+
#include <unistd.h>
#include <fcntl.h>
-#include <time.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <ctype.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include <sys/wait.h>
#endif
-#include "openconnect-internal.h"
+#include <time.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <ctype.h>
#define NTLM_SSO_REQ 2 /* SSO type1 packet sent */
#define NTLM_MANUAL 3 /* SSO challenge/response sent or skipped; manual next */
#include <config.h>
+#include "openconnect-internal.h"
+#include "ppp.h"
+
#include <unistd.h>
#include <fcntl.h>
+#include <sys/types.h>
+
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
-#include <sys/types.h>
#include <stdarg.h>
-#include <sys/types.h>
-
-#include "openconnect-internal.h"
-#include "ppp.h"
int nullppp_obtain_cookie(struct openconnect_info *vpninfo)
{
#include <config.h>
+#include "openconnect-internal.h"
+
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
-#include "openconnect-internal.h"
-
static int b32_char(char in)
{
if (in >= 'A' && in <= 'Z')
#include <config.h>
+#include "openconnect-internal.h"
+
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
-#include "openconnect-internal.h"
-
int set_oidc_token(struct openconnect_info *vpninfo, const char *token_str)
{
int ret;
vpninfo->token_mode = OC_TOKEN_MODE_OIDC;
return 0;
}
-
-
#include <config.h>
+#include "openconnect-internal.h"
+
#include <unistd.h>
#include <fcntl.h>
+#include <sys/types.h>
+
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
-#include <sys/types.h>
#include <stdarg.h>
-#include <sys/types.h>
-
-#include "openconnect-internal.h"
static void buf_append_tlv(struct oc_text_buf *buf, uint16_t val, uint32_t len, void *data)
{
#define __OPENCONNECT_PRIVATE__
+/*
+ * We need to include <winsock2.h> or <winsock.h> before openconnect.h.
+ * Indeed openconnect.h is specifically intended not to be self-sufficient,
+ * so that end-users can choose between <winsock.h> and <winsock2.h>.
+ */
#ifdef _WIN32
#include <winsock2.h>
-#include <ws2tcpip.h>
-#ifndef SECURITY_WIN32
-#define SECURITY_WIN32 1
-#endif
-#include <security.h>
-
-#ifndef _Out_cap_c_
-#define _Out_cap_c_(sz)
-#endif
-#ifndef _Ret_bytecount_
-#define _Ret_bytecount_(sz)
-#endif
-#include "wintun.h"
-#else
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <fcntl.h>
#endif
#include "openconnect.h"
-/* Equivalent of "/dev/null" on Windows.
- * See https://stackoverflow.com/a/44163934
- */
-#ifdef _WIN32
-#define DEVNULL "NUL:"
-#else
-#define DEVNULL "/dev/null"
-#endif
+#include "json.h"
#if defined(OPENCONNECT_OPENSSL)
#include <openssl/ssl.h>
#else
#define method_const
#endif
-#endif /* OPENSSL */
+#endif
#if defined(OPENCONNECT_GNUTLS)
#include <gnutls/gnutls.h>
#include <iconv.h>
#endif
-#include <zlib.h>
-#include <stdint.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
#ifdef LIBPROXY_HDR
#include LIBPROXY_HDR
#endif
#define N_(s) s
#include <libxml/tree.h>
+#include <zlib.h>
-#include <json.h>
+#ifdef _WIN32
+#ifndef _Out_cap_c_
+#define _Out_cap_c_(sz)
+#endif
+#ifndef _Ret_bytecount_
+#define _Ret_bytecount_(sz)
+#endif
+#include "wintun.h"
+
+#include <ws2tcpip.h>
+#ifndef SECURITY_WIN32
+#define SECURITY_WIN32 1
+#endif
+#include <security.h>
+#else
+#include <sys/socket.h>
+#include <sys/select.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+#endif
+
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+
+/* Equivalent of "/dev/null" on Windows.
+ * See https://stackoverflow.com/a/44163934
+ */
+#ifdef _WIN32
+#define DEVNULL "NUL:"
+#else
+#define DEVNULL "/dev/null"
+#endif
#define SHA512_SIZE 64
#define SHA384_SIZE 48
};
};
-struct vpn_proto {
- const char *name;
- const char *pretty_name;
- const char *description;
- const char *secure_cookie;
- const char *udp_protocol;
- int proto;
- unsigned int flags;
- int (*vpn_close_session)(struct openconnect_info *vpninfo, const char *reason);
-
- /* This does the full authentication, calling back as appropriate */
- int (*obtain_cookie)(struct openconnect_info *vpninfo);
-
- /* Establish the TCP connection (and obtain configuration) */
- int (*tcp_connect)(struct openconnect_info *vpninfo);
-
- int (*tcp_mainloop)(struct openconnect_info *vpninfo, int *timeout, int readable);
-
- /* Add headers common to each HTTP request */
- void (*add_http_headers)(struct openconnect_info *vpninfo, struct oc_text_buf *buf);
-
- /* Set up the UDP (DTLS) connection. Doesn't actually *start* it. */
- int (*udp_setup)(struct openconnect_info *vpninfo);
-
- /* 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, int readable);
-
- /* 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);
-
- /* 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);
-};
-
-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;
-}
-
#define TLS_OVERHEAD 5 /* packet + header */
#define DTLS_OVERHEAD (1 /* packet + header */ + 13 /* DTLS header */ + \
20 /* biggest supported MAC (SHA1) */ + 32 /* biggest supported IV (AES-256) */ + \
struct oc_tpm1_ctx;
struct oc_tpm2_ctx;
+struct openconnect_info;
+
struct cert_info {
struct openconnect_info *vpninfo;
char *cert;
#endif
};
+struct pkt_q {
+ struct pkt *head;
+ struct pkt **tail;
+ int count;
+};
+
+struct vpn_proto;
+
struct openconnect_info {
const struct vpn_proto *proto;
int (*ssl_write)(struct openconnect_info *vpninfo, char *buf, size_t len);
};
+struct vpn_proto {
+ const char *name;
+ const char *pretty_name;
+ const char *description;
+ const char *secure_cookie;
+ const char *udp_protocol;
+ int proto;
+ unsigned int flags;
+ int (*vpn_close_session)(struct openconnect_info *vpninfo, const char *reason);
+
+ /* This does the full authentication, calling back as appropriate */
+ int (*obtain_cookie)(struct openconnect_info *vpninfo);
+
+ /* Establish the TCP connection (and obtain configuration) */
+ int (*tcp_connect)(struct openconnect_info *vpninfo);
+
+ int (*tcp_mainloop)(struct openconnect_info *vpninfo, int *timeout, int readable);
+
+ /* Add headers common to each HTTP request */
+ void (*add_http_headers)(struct openconnect_info *vpninfo, struct oc_text_buf *buf);
+
+ /* Set up the UDP (DTLS) connection. Doesn't actually *start* it. */
+ int (*udp_setup)(struct openconnect_info *vpninfo);
+
+ /* 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, int readable);
+
+ /* 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);
+
+ /* 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);
+};
+
+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;
+}
static inline struct pkt *alloc_pkt(struct openconnect_info *vpninfo, int len)
{
#ifndef __OPENCONNECT_H__
#define __OPENCONNECT_H__
-#include <stdint.h>
#include <sys/types.h>
-#include <unistd.h>
+
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
// application icon
IDI_ICON1 ICON DISCARDABLE "openconnect.ico"
-
#include <config.h>
-#include <errno.h>
-#include <sys/types.h>
+#include "openconnect-internal.h"
+
#include <unistd.h>
+#include <sys/types.h>
#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
#ifndef _WIN32
#include <netinet/in.h>
#include <sys/socket.h>
#endif
-#include "openconnect-internal.h"
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
/* In the very early days there were cases where this wasn't found in
* the header files but it did still work somehow. I forget the details
#include <config.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-
#include "openconnect-internal.h"
#include <openssl/evp.h>
#include <openssl/rand.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
#define EVP_CIPHER_CTX_free(c) do { \
#include <config.h>
+#include "openconnect-internal.h"
+
+#include <openssl/rand.h>
+
+#include <sys/types.h>
+
#include <errno.h>
#include <string.h>
-#include <sys/types.h>
#include <ctype.h>
-#include "openconnect-internal.h"
-#include <openssl/rand.h>
-
#ifdef HAVE_LIBP11 /* And p11-kit */
#include <libp11.h>
#include <config.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <ctype.h>
-
#include "openconnect-internal.h"
#include <openssl/crypto.h>
#include <openssl/ui.h>
#include <openssl/rsa.h>
+#include <sys/types.h>
+
+#include <errno.h>
+#include <string.h>
+#include <ctype.h>
+
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
#define X509_up_ref(x) CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_X509)
#define X509_get0_notAfter(x) X509_get_notAfter(x)
#include <config.h>
-#include <errno.h>
-
#include "openconnect-internal.h"
#include "ppp.h"
+#include <errno.h>
+
static const uint16_t fcstab[256] = {
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
#include <config.h>
+#include "openconnect-internal.h"
+
#include <unistd.h>
#include <fcntl.h>
+#include <sys/types.h>
+
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
-#include <sys/types.h>
#include <stdarg.h>
-#include <sys/types.h>
-
-#include "openconnect-internal.h"
#define VENDOR_JUNIPER 0xa4c
#define VENDOR_JUNIPER2 0x583
#include <config.h>
+#include "openconnect-internal.h"
+
+#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <string.h>
#include <fcntl.h>
-#include <unistd.h>
#ifndef _WIN32
#include <sys/wait.h>
#endif
+
#include <errno.h>
#include <ctype.h>
+#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include "openconnect-internal.h"
-
int script_setenv(struct openconnect_info *vpninfo,
const char *opt, const char *val, int trunc, int append)
{
#include <config.h>
+#include "openconnect-internal.h"
+
+#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h>
#include <inttypes.h>
#include <fcntl.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <time.h>
#if defined(__linux__) || defined(__ANDROID__)
#include <sys/vfs.h>
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__APPLE__)
#include <sys/socket.h>
#endif
-#include "openconnect-internal.h"
-
#ifdef ANDROID_KEYSTORE
#include <sys/un.h>
#endif
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <time.h>
+
/* OSX < 1.6 doesn't have AI_NUMERICSERV */
#ifndef AI_NUMERICSERV
#define AI_NUMERICSERV 0
#include <config.h>
-#include <errno.h>
-#include <string.h>
-
#include "openconnect-internal.h"
+#include <errno.h>
+#include <string.h>
static int sspi_setup(struct openconnect_info *vpninfo, struct http_auth_state *auth_state, const char *service, int proxy)
{
#include <config.h>
+#include "openconnect-internal.h"
+
+#include <stoken.h>
+
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
-#include <stoken.h>
-
-#include "openconnect-internal.h"
-
#ifndef STOKEN_CHECK_VER
#define STOKEN_CHECK_VER(x,y) 0
#endif
return -ENOMEM;
return 0;
}
-
#include <config.h>
+#include "openconnect-internal.h"
+
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <stdarg.h>
-#include "openconnect-internal.h"
-
#define BUF_CHUNK_SIZE 4096
#define OC_BUF_MAX ((unsigned)(16*1024*1024))
#include <config.h>
+#include "openconnect-internal.h"
+
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winioctl.h>
#include <errno.h>
#include <stdio.h>
-#include "openconnect-internal.h"
-
/*
* TAP-Windows support inspired by http://i3.cs.berkeley.edu/ (v0.2) with
* permission.
#include <config.h>
+#include "openconnect-internal.h"
+
+#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <string.h>
#include <fcntl.h>
-#include <unistd.h>
-#include <signal.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/ip.h>
#include <net/if.h>
#include <arpa/inet.h>
-#include <errno.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
#if defined(__APPLE__) && defined(HAVE_NET_UTUN_H)
#include <sys/kern_control.h>
#include <sys/sys_domain.h>
#include <net/if_utun.h>
#endif
-
-#include "openconnect-internal.h"
+#include <errno.h>
+#include <ctype.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
/*
* If an if_tun.h include file was found anywhere (by the Makefile), it's
#ifndef __OPENCONNECT_WIN32_IPICMP_H__
#define __OPENCONNECT_WIN32_IPICMP_H__
-#include <stdint.h>
#include <ws2tcpip.h>
+#include <stdint.h>
/* IPv4 header and flags used in gpst.c */
#include <config.h>
+#include "openconnect-internal.h"
+
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winioctl.h>
#include <errno.h>
#include <stdio.h>
-#include "openconnect-internal.h"
-
static WINTUN_CREATE_ADAPTER_FUNC WintunCreateAdapter;
static WINTUN_DELETE_ADAPTER_FUNC WintunDeleteAdapter;
static WINTUN_DELETE_POOL_DRIVER_FUNC WintunDeletePoolDriver;
#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include "openconnect-internal.h"
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
+
#include <string.h>
#include <ctype.h>
#include <errno.h>
-
-#include "openconnect-internal.h"
+#include <stdio.h>
+#include <stdlib.h>
static char *fetch_and_trim(xmlNode *node)
{
#include <config.h>
+#include "openconnect-internal.h"
+
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
-#include "openconnect-internal.h"
-
#define NAME_TAG 0x71
#define NAME_LIST_TAG 0x72
#define KEY_TAG 0x73