2 net.h -- header for net.c
3 Copyright (C) 1998-2001 Ivo Timmermans <zarq@iname.com>
4 2000,2001 Guus Sliepen <guus@sliepen.warande.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 $Id: net.h,v 1.9.4.36 2001/10/27 13:13:35 guus Exp $
23 #ifndef __TINC_NET_H__
24 #define __TINC_NET_H__
30 #define MAXSIZE 1700 /* should be a bit more than the MTU for the tapdevice */
32 #define SALTLEN 2 /* to spice things up for the NSA... */
34 #define MAC_ADDR_S "%02x:%02x:%02x:%02x:%02x:%02x"
35 #define MAC_ADDR_V(x) ((unsigned char*)&(x))[0],((unsigned char*)&(x))[1], \
36 ((unsigned char*)&(x))[2],((unsigned char*)&(x))[3], \
37 ((unsigned char*)&(x))[4],((unsigned char*)&(x))[5]
39 #define IP_ADDR_S "%d.%d.%d.%d"
41 #ifdef WORDS_BIGENDIAN
42 # define IP_ADDR_V(x) ((unsigned char*)&(x))[0],((unsigned char*)&(x))[1], \
43 ((unsigned char*)&(x))[2],((unsigned char*)&(x))[3]
45 # define IP_ADDR_V(x) ((unsigned char*)&(x))[3],((unsigned char*)&(x))[2], \
46 ((unsigned char*)&(x))[1],((unsigned char*)&(x))[0]
49 #define MAXBUFSIZE 4096 /* Probably way too much, but it must fit every possible request. */
52 #define TAP_TYPE_ETHERTAP 0
53 #define TAP_TYPE_TUNTAP 1
60 typedef unsigned long ipv4_t;
62 typedef struct ip_mask_t {
72 typedef unsigned short port_t;
74 typedef short length_t;
76 typedef struct vpn_packet_t {
77 length_t len; /* the actual number of bytes in the `data' field */
78 unsigned char salt[SALTLEN]; /* two bytes of randomness */
79 unsigned char data[MAXSIZE];
82 typedef struct queue_element_t {
84 struct queue_element_t *prev;
85 struct queue_element_t *next;
88 typedef struct packet_queue_t {
89 queue_element_t *head;
90 queue_element_t *tail;
93 extern int maxtimeout;
94 extern int seconds_till_retry;
96 extern char *request_name[256];
97 extern char *status_text[10];
99 #include "connection.h" /* Yes, very strange placement indeed, but otherwise the typedefs get all tangled up */
101 extern void send_packet(struct node_t *, vpn_packet_t *);
102 extern void receive_packet(struct node_t *, vpn_packet_t *);
103 extern void receive_tcppacket(struct connection_t *, char *, int);
104 extern void broadcast_packet(struct node_t *, vpn_packet_t *);
105 extern int setup_network_connections(void);
106 extern void close_network_connections(void);
107 extern void main_loop(void);
108 extern void terminate_connection(connection_t *, int);
109 extern void flush_queue(struct node_t *);
110 extern int read_rsa_public_key(struct connection_t *);
111 extern RETSIGTYPE try_outgoing_connections(int);
113 #endif /* __TINC_NET_H__ */