chiark / gitweb /
Support SLIP encapsulation as a tunnelling mechanism.
[tripe] / tripe.h
diff --git a/tripe.h b/tripe.h
index 320a2ca5218f91d4672aabf6e95a8f81ba4f2895..c8ad9ae1a40a42c2a278046f23eac11cf319cc0c 100644 (file)
--- a/tripe.h
+++ b/tripe.h
@@ -40,6 +40,7 @@
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
+#include <limits.h>
 #include <signal.h>
 #include <stdarg.h>
 #include <stddef.h>
 #define TUN_UNET 1
 #define TUN_BSD 2
 #define TUN_LINUX 3
+#define TUN_SLIP 4
 
 /* --- Trace flags --- */
 
@@ -263,6 +265,16 @@ enum {
 #  include <linux/if_tun.h>
 #endif
 
+#if TUN_TYPE == TUN_SLIP
+  typedef struct slipif {
+    struct slipif *next;               /* Next one in the list */
+    int ifd, ofd;                      /* File descriptors to talk on */
+    char *name;                                /* Interface name */
+    unsigned f;                                /* Various flags */
+#     define SLIPIFF_INUSE 1u          /*   Interface is in use */
+  } slipif;
+#endif
+
 typedef struct tunnel {
 #if TUN_TYPE == TUN_UNET 
   sel_file f;                          /* Selector for Usernet device */
@@ -275,6 +287,16 @@ typedef struct tunnel {
   sel_file f;                          /* Selector for tunnel device */
   struct peer *p;                      /* Pointer to my peer */
   unsigned n;                          /* Number of my tunnel device */
+#elif TUN_TYPE == TUN_SLIP
+  slipif *sl;                          /* My interface record */
+  sel_file f;                          /* Selector for SLIP tty */
+  struct peer *p;                      /* Pointer to my peer */
+  unsigned st;                         /* Current parser state */
+#   define SLIPST_ESC 1u               /*   Last saw an escape character */
+#   define SLIPST_BAD 2u               /*   This packet is malformed */
+#   define SLIPST_EOF 4u               /*   File descriptor reported EOF */
+  size_t n;                            /* Number of bytes used in buffer */
+  octet buf[PKBUFSZ];                  /* Buffer for incoming data */
 #else
 #  error "No support for this tunnel type"
 #endif