Mercurial > hg > quicktun-tcp
view include.h @ 0:17cb7cdbb8be draft default tip
Working prototype
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Fri, 07 Feb 2014 23:28:39 +0100 |
parents | |
children |
line wrap: on
line source
/* Copyright 2014 Ivo Smits <Ivo@UCIS.nl>. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of Ivo Smits.*/ #include <stdbool.h> typedef struct tunnel_context tunnel_context; typedef struct connection_context connection_context; struct connection_context { int recv_socket; unsigned char recv_buffer[2000]; int recv_offset; bool recv_encrypted; unsigned char recv_key[32]; unsigned char recv_nonce[24]; int send_socket; bool send_encrypted; unsigned char send_key[32]; unsigned char send_nonce[24]; unsigned char local_seckey_current[32]; unsigned char local_seckey_next[32]; unsigned char remote_pubkey[32]; unsigned char nonce_next[24]; char* password; bool local_tunnelready; bool remote_tunnelready; bool key_updated; bool pong; bool startcryptauthsent; unsigned char remote_pubkey_expect[32]; bool require_key_authentication; bool require_encryption; bool require_password_authentication; tunnel_context* tunnel; }; bool connection_init(connection_context* context); bool connection_init_socket(connection_context* context, const int recvsocket, const int sendsocket); bool connection_init_encryption(connection_context* context, const unsigned char* localseckey, const unsigned char* remotepubkey); bool connection_init_passwordauth(connection_context* context, char* password); bool connection_init_done(connection_context* context); bool connection_update_key(connection_context* context); bool connection_ping(connection_context* context); bool connection_read(connection_context* context); bool connection_write_data(connection_context* context, unsigned char* buffer, int len); struct tunnel_context { int fd; int fake_pi; connection_context* connection; }; bool tunnel_init(tunnel_context* context); bool tunnel_read(tunnel_context* context); bool tunnel_write_data(tunnel_context* tunnel, unsigned char* buffer, int len); extern char* (*getconf)(const char*); int errorexit(const char* text); int errorexitf(const char* text, const char* error); bool errorexitp(const char* text);