Vde_plug sets automagically the minimum permissions
[vde.git] / vde-2 / src / vde_over_ns / fun.h
blobfa7fd140b5ef5e8bab0f6870a83e64e51adfc685
1 /* ----------------------------------------------------------------------------
3 VDE_OVER_NS
4 (C) 2007 Daniele Lacamera
6 Derived from:
7 NSTX -- tunneling network-packets over DNS
9 (C) 2000 by Florian Heinz and Julien Oster
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License version 2, as
13 published by the Free Software Foundation.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 -------------------------------------------------------------------------- */
25 #include <vde.h>
26 #include <libvdeplug.h>
28 #ifndef _NSTXHDR_H
29 #define _NSTXHDR_H
31 /* constants */
33 #define NSTX_TIMEOUT 30
34 #define NSTX_MAGIC 0xb4 /* Huh? [sky] */
35 /* Well, that seems really like a */
36 /* *magic* number ;-) [frodo] */
38 /* nstx header */
40 struct nstxhdr {
41 unsigned char magic;
42 unsigned char seq:4;
43 unsigned char chan:4; /* Unused yet... */
44 unsigned short id:12;
45 unsigned short flags:4;
48 /* flags... more to come ?! */
49 #define NSTX_LF 0x1 /* last fragment of this packet */
50 #define NSTX_CTL 0x2 /* for control-messages, not yet implemented */
52 #define DEBUG(x) syslog(LOG_DEBUG, x)
54 /* encoding */
56 const char *nstx_encode(const unsigned char *, int);
57 const char *nstx_decode(const unsigned char *, int*);
59 /* DNS */
61 void open_ns (const char *ip);
62 void open_ns_bind(in_addr_t ip);
64 void send_vde (const char*, size_t);
65 void sendns (const char*, size_t, const struct sockaddr*);
67 #define MAXPKT 2000
69 #define FROMNS 0
70 #define FROMTUN 1
72 struct nstxmsg
74 char data[MAXPKT];
75 int len;
76 int src;
77 struct sockaddr_in peer;
80 struct nstxmsg *nstx_select (int);
83 /* Queue-handling functions */
85 #define QUEUETIMEOUT 5
87 struct nstxqueue
89 unsigned short id;
90 time_t timeout;
92 char name[257];
93 struct sockaddr peer;
95 struct nstxqueue *next;
98 struct nstxqueue *finditem (unsigned short);
99 void queueitem (unsigned short, const char *, const struct sockaddr_in *);
100 void queueid (unsigned short);
101 int queuelen (void);
102 void qsettimeout (int);
103 struct nstxqueue *dequeueitem (int);
104 void timeoutqueue (void (*)(struct nstxqueue *));
105 void init_vdesock(char *);
107 #ifdef WITH_PKTDUMP
108 void pktdump (const char *, unsigned short, const char *, size_t, int);
109 #endif
111 #endif /* _NSTXHDR_H */