warp-vpn

point to point VPN implementation
git clone git://git.2f30.org/warp-vpn
Log | Files | Refs | README

warp.h (2122B)


      1 #include <sys/socket.h>
      2 
      3 #include <stddef.h>
      4 #include <stdint.h>
      5 
      6 #define NOPRIVUSER      "nobody"
      7 #define AUTHTIMEO       10 /* in seconds */
      8 #define RECONNECTTIMEO  60 /* in seconds */
      9 #define HDRLEN          2
     10 #define MAXPAYLOADLEN   1404
     11 #define NROUNDS         100000
     12 #define DEFPORT         "12080"
     13 
     14 enum {
     15 	PKTFAILED,
     16 	PKTPARTIAL,
     17 	PKTCOMPLETE
     18 };
     19 
     20 enum {
     21 	TUNDEV,
     22 	TAPDEV
     23 };
     24 
     25 /* log.c */
     26 extern int debug;
     27 
     28 /* warp.c */
     29 extern int devtype;
     30 extern int aftype;
     31 extern int debug;
     32 
     33 /* auth.c */
     34 int challenge(int);
     35 int response(int);
     36 
     37 /* client.c */
     38 int clientconnect(char *, char *);
     39 
     40 /* crypto.c */
     41 void cryptoinit(void);
     42 void derivekey(char *);
     43 size_t cryptononcelen(void);
     44 size_t cryptotaglen(void);
     45 int cryptoseal(unsigned char *, unsigned long long *,
     46                const unsigned char *, unsigned long long,
     47                const unsigned char *, unsigned long long,
     48                const unsigned char *);
     49 int cryptoopen(unsigned char *, unsigned long long *,
     50                const unsigned char *, unsigned long long,
     51                const unsigned char *, unsigned long long,
     52                const unsigned char *);
     53 
     54 /* dev_*.c */
     55 int devopen(char *);
     56 int devwrite(int, unsigned char *, int);
     57 int devread(int, unsigned char *, int);
     58 
     59 /* log.c */
     60 void loginit(char *);
     61 void logdbg(char *, ...);
     62 void logdbgx(char *, ...);
     63 void logwarn(char *, ...);
     64 void logwarnx(char *, ...);
     65 void fatal(char *, ...);
     66 void fatalx(char *, ...);
     67 
     68 /* netpkt.c */
     69 int netwrite(int, unsigned char *, unsigned long long, unsigned long long *);
     70 int netread(int, unsigned char *, unsigned long long, unsigned long long *);
     71 void netreset(void);
     72 void netinit(void);
     73 
     74 /* server.c */
     75 int serverinit(char *, char *);
     76 int serveraccept(int);
     77 
     78 /* tunnel.c */
     79 int tunnel(int, int);
     80 
     81 /* util.c */
     82 void pack16(unsigned char *, uint16_t);
     83 uint16_t unpack16(unsigned char *);
     84 void pack64(unsigned char *, uint64_t);
     85 uint64_t unpack64(unsigned char *);
     86 void revokeprivs(char *);
     87 int setnonblock(int, int);
     88 char *saddr_ntop(struct sockaddr *, socklen_t);
     89 char *peer_ntop(int);
     90 int ipversion(unsigned char *);
     91 int mypledge(const char *, const char *[]);