aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--base64.c22
-rw-r--r--options.c8
-rw-r--r--options.h2
-rw-r--r--pdesc.h10
-rw-r--r--ptunnel.c5
-rw-r--r--utils.c20
-rw-r--r--utils.h4
7 files changed, 41 insertions, 30 deletions
diff --git a/base64.c b/base64.c
index 7a25808..0a40354 100644
--- a/base64.c
+++ b/base64.c
@@ -6,28 +6,6 @@
#include "base64.h"
-#if 0
-static const char hextab[] = "0123456789ABCDEF";
-
-void print_hexstr(unsigned char *buf, size_t siz) {
- char *out = (char *) calloc(3, siz+1);
- unsigned char high, low;
-
- for (size_t i = 0; i < siz; ++i) {
- high = (buf[i] & 0xF0) >> 4;
- low = buf[i] & 0x0F;
-
- out[i ] = hextab[high];
- out[i+1] = hextab[low];
- out[i+2] = ' ';
- }
-
- printf("%s\n", out);
- free(out);
-}
-#endif
-
-
static void build_decoding_table(void);
static char encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
diff --git a/options.c b/options.c
index 472a932..3926f61 100644
--- a/options.c
+++ b/options.c
@@ -95,6 +95,9 @@ static const struct option_usage usage[] = {
"Unprivileged mode will only work on some systems, and is in general less reliable\n"
"than running in privileged mode.\n"
},
+ /** --base64 */
+ {NULL, 0, OPT_BOOL, {.num = 0},
+ "Base64 encode/decode all outoging/incoming packets."},
#ifndef WIN32
/** --daemon */
{"pidfile", 0, OPT_STR, {.str = "/run/ptunnel.pid"},
@@ -143,6 +146,7 @@ static struct option long_options[] = {
{"passwd", required_argument, 0, 'x'},
{"udp", no_argument, &opts.udp, 1 },
{"unprivileged", no_argument, &opts.unprivileged, 1 },
+ {"base64", no_argument, &opts.base64, 1 },
#ifndef WIN32
{"daemon", optional_argument, 0, 'd'},
{"syslog", no_argument, 0, 'S'},
@@ -489,5 +493,9 @@ int parse_options(int argc, char **argv) {
} else opts.log_file = tmp_log;
}
+ if (opts.base64 != 0) {
+ pt_log(kLog_debug, "Base64 enabled.");
+ }
+
return 0;
}
diff --git a/options.h b/options.h
index de4a8bf..622ffa4 100644
--- a/options.h
+++ b/options.h
@@ -49,6 +49,8 @@ struct options {
int udp;
/** unpriviledged mode */
int unprivileged;
+ /** use base64 encoded packets */
+ int base64;
#ifndef WIN32
/** run as daemon if non zero value */
diff --git a/pdesc.h b/pdesc.h
index 65ba5fa..4fd8221 100644
--- a/pdesc.h
+++ b/pdesc.h
@@ -116,11 +116,11 @@ typedef struct proxy_desc_t {
} proxy_desc_t;
-proxy_desc_t* create_and_insert_proxy_desc(uint16_t id_no, uint16_t icmp_id,
- int sock, struct sockaddr_in *addr,
- uint32_t dst_ip, uint32_t dst_port,
- uint32_t init_state, uint32_t type);
-void remove_proxy_desc(proxy_desc_t *cur, proxy_desc_t *prev);
+proxy_desc_t* create_and_insert_proxy_desc(uint16_t id_no, uint16_t icmp_id,
+ int sock, struct sockaddr_in *addr,
+ uint32_t dst_ip, uint32_t dst_port,
+ uint32_t init_state, uint32_t type);
+void remove_proxy_desc(proxy_desc_t *cur, proxy_desc_t *prev);
forward_desc_t* create_fwd_desc(uint16_t seq_no, uint32_t data_len, char *data);
#endif
diff --git a/ptunnel.c b/ptunnel.c
index e7d0ba7..ad2c05b 100644
--- a/ptunnel.c
+++ b/ptunnel.c
@@ -76,7 +76,6 @@ static char * print_last_windows_error() {
return errorstr;
}
#define strerror(x) print_last_windows_error()
-#else
#endif /* WIN32 */
/* globals */
@@ -91,7 +90,7 @@ uint32_t num_tunnels = 0;
/** Table indicating when a connection ID is allowable (used by proxy) */
uint32_t *seq_expiry_tbl = NULL;
-/** Some buffer constants */
+/* Some buffer constants */
const int tcp_receive_buf_len = kDefault_buf_size;
const int icmp_receive_buf_len = kDefault_buf_size + kIP_header_size +
kICMP_header_size + sizeof(ping_tunnel_pkt_t);
@@ -105,7 +104,7 @@ proxy_desc_t *chain = 0;
const char *state_name[kNum_proto_types] = { "start", "ack", "data",
"close", "authenticate" };
-/** Let the fun begin! */
+/* Let the fun begin! */
int main(int argc, char *argv[]) {
#ifndef WIN32
pid_t pid;
diff --git a/utils.c b/utils.c
index c1cd6aa..21df7a8 100644
--- a/utils.c
+++ b/utils.c
@@ -49,3 +49,23 @@ double time_as_double(void) {
result = (double)tt.tv_sec + ((double)tt.tv_usec / (double)10e5);
return result;
}
+
+#if 0
+static const char hextab[] = "0123456789ABCDEF";
+
+void print_hexstr(unsigned char *buf, size_t siz) {
+ char *out = (char *) calloc(3, siz+1);
+ unsigned char high, low;
+
+ for (size_t i = 0; i < siz; ++i) {
+ high = (buf[i] & 0xF0) >> 4;
+ low = buf[i] & 0x0F;
+ out[i ] = hextab[high];
+ out[i+1] = hextab[low];
+ out[i+2] = ' ';
+ }
+
+ printf("%s\n", out);
+ free(out);
+}
+#endif
diff --git a/utils.h b/utils.h
index 5bd539a..7a2b551 100644
--- a/utils.h
+++ b/utils.h
@@ -7,4 +7,8 @@ void pt_log(int level, const char *fmt, ...);
double time_as_double(void);
+#if 0
+void print_hexstr(unsigned char *buf, size_t siz);
+#endif
+
#endif