diff options
-rw-r--r-- | base64.c | 22 | ||||
-rw-r--r-- | options.c | 8 | ||||
-rw-r--r-- | options.h | 2 | ||||
-rw-r--r-- | pdesc.h | 10 | ||||
-rw-r--r-- | ptunnel.c | 5 | ||||
-rw-r--r-- | utils.c | 20 | ||||
-rw-r--r-- | utils.h | 4 |
7 files changed, 41 insertions, 30 deletions
@@ -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', @@ -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; } @@ -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 */ @@ -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 @@ -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; @@ -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 @@ -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 |