aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/options.c12
-rw-r--r--src/pdesc.c18
-rw-r--r--src/pkt.c10
-rw-r--r--src/ptunnel.c5
-rw-r--r--src/ptunnel.h2
5 files changed, 30 insertions, 17 deletions
diff --git a/src/options.c b/src/options.c
index 024e358..f1080aa 100644
--- a/src/options.c
+++ b/src/options.c
@@ -87,7 +87,7 @@ static const struct option_usage usage[] = {
{"port", 0, OPT_DEC32, {.unum = 2222},
"Set TCP listening port (only used when operating in forward mode)\n"
},
- /** --remote-adr */
+ /** --remote-addr */
{"address", 1, OPT_STR, {.str = "127.0.0.1"},
"Set remote proxy destination address if client\n"
"Restrict to only this destination address if server\n"
@@ -188,7 +188,7 @@ static struct option long_options[] = {
{"magic", required_argument, 0, 'm'},
{"proxy", required_argument, 0, 'p'},
{"listen", required_argument, 0, 'l'},
- {"remote-adr", optional_argument, 0, 'r'},
+ {"remote-addr", optional_argument, 0, 'r'},
{"remote-port", optional_argument, 0, 'R'},
{"connections", required_argument, 0, 'c'},
{"verbosity", required_argument, 0, 'v'},
@@ -231,7 +231,7 @@ static void set_options_defaults(void) {
opts.magic = *(uint32_t *) get_default_optval(OPT_HEX32, "magic");
opts.mode = kMode_proxy;
opts.tcp_listen_port = *(uint32_t *) get_default_optval(OPT_DEC32, "listen");
- opts.given_dst_hostname = strdup(*(char **) get_default_optval(OPT_STR, "remote-adr"));
+ opts.given_dst_hostname = strdup(*(char **) get_default_optval(OPT_STR, "remote-addr"));
opts.given_dst_port = *(uint32_t *) get_default_optval(OPT_DEC32, "remote-port");
opts.max_tunnels = *(uint32_t *) get_default_optval(OPT_DEC32, "connections");
opts.log_level = *(int *) get_default_optval(OPT_DEC32, "verbosity");
@@ -380,6 +380,10 @@ int parse_options(int argc, char **argv) {
/* parse command line arguments */
while (1) {
+ /* FIXME: We are using '::' (optional argument values). This is not optimal
+ * since you have to pass long options as '--option=value'. Commonly used
+ * '--option value' is *NOT* allowed for some libc implementations.
+ */
c = getopt_long(argc, argv, "m:p:l:r::R::c:v:L::o::sP:d::Su::g::C::e::w:a:t:h", &long_options[0], &oidx);
if (c == -1) break;
@@ -554,7 +558,7 @@ int parse_options(int argc, char **argv) {
}
if (optind != argc) {
- pt_log(kLog_error, "Unknown argument: %s\n", argv[optind]);
+ pt_log(kLog_error, "Unknown argument: '%s'\n", argv[optind]);
exit(1);
}
diff --git a/src/pdesc.c b/src/pdesc.c
index 819bf4e..b034b8b 100644
--- a/src/pdesc.c
+++ b/src/pdesc.c
@@ -216,12 +216,18 @@ int queue_packet(int icmp_sock, uint8_t type, char *buf, int num_bytes,
pkt->checksum = htons(calc_icmp_checksum((uint16_t*)pkt, pkt_len));
/* Send it! */
- pt_log(kLog_sendrecv, "Send: %d [%d] bytes [seq = %d] "
- "[type = %s] [ack = %d] [icmp = %d] [user = %s]\n",
- pkt_len, num_bytes, *seq, state_name[state & (~kFlag_mask)],
- ack_val, type, ((state & kUser_flag) == kUser_flag ? "yes" : "no"));
- err = sendto(icmp_sock, (const void*)pkt, pkt_len, 0,
- (struct sockaddr*)dest_addr, sizeof(struct sockaddr));
+ pt_log(kLog_sendrecv, "Send: %4d [%4d] bytes "
+ "[id = 0x%04X] [seq = %d] "
+ "[seq_no = %d] [type = %s] "
+ "[ack = %d] [icmp = %d] "
+ "[user = %s]\n",
+ pkt_len, num_bytes,
+ icmp_id, *ping_seq,
+ *seq, state_name[state & (~kFlag_mask)],
+ ack_val, type,
+ ((state & kUser_flag) == kUser_flag ? "yes" : "no"));
+ err = sendto(icmp_sock, (const void*)pkt, pkt_len, 0,
+ (struct sockaddr*)dest_addr, sizeof(struct sockaddr));
if (err < 0) {
pt_log(kLog_error, "Failed to send ICMP packet: %s\n", strerror(errno));
free(pkt);
diff --git a/src/pkt.c b/src/pkt.c
index 410991d..e249ca3 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -128,11 +128,13 @@ void handle_packet(char *buf, unsigned bytes, int is_pcap, struct sockaddr_in *a
pt_log(kLog_error, "Dropping packet with invalid state.\n");
return;
}
- pt_log(kLog_sendrecv, "Recv: %d [%d] bytes "
- "[seq = %d] [type = %s] "
+ pt_log(kLog_sendrecv, "Recv: %4d [%4d] bytes "
+ "[id = 0x%04X] [seq = %d] "
+ "[seq_no = %d] [type = %s] "
"[ack = %d] [icmp = %d] "
- "[user = %s] [pcap = %d]\n",
- bytes, ntohl(pt_pkt->data_len),
+ "[user = %s] [pcap = %d]\n",
+ bytes, ntohl(pt_pkt->data_len),
+ pkt->identifier, ntohs(pkt->seq),
pt_pkt->seq_no, state_name[pt_pkt->state & (~kFlag_mask)],
ntohl(pt_pkt->ack), pkt->type,
(pkt_flag == kUser_flag ? "yes" : "no"), is_pcap);
diff --git a/src/ptunnel.c b/src/ptunnel.c
index 456a747..c87fa3f 100644
--- a/src/ptunnel.c
+++ b/src/ptunnel.c
@@ -34,7 +34,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* Contacting the author:
- * You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe,
+ * You can get in touch with me, Daniel Stoedle (that's the Norwegian letter oe,
* in case your text editor didn't realize), here: <daniels@cs.uit.no>
*
* The official ptunnel website is here:
@@ -98,7 +98,7 @@ char pcap_filter_program[] = "icmp";
/** The chain of client/proxy connections */
proxy_desc_t *chain = 0;
-const char *state_name[kNum_proto_types] = { "start", "ack", "data",
+const char *state_name[kNum_proto_types] = { "start", "ack ", "data ",
"close", "authenticate" };
/* Let the fun begin! */
@@ -641,6 +641,7 @@ void* pt_proxy(void *args) {
if (cur->send_ring[idx].pkt && cur->send_ring[idx].last_resend+cur->resend_interval < now) {
pt_log(kLog_debug, "Resending packet with seq-no %d.\n", cur->send_ring[idx].seq_no);
cur->send_ring[idx].last_resend = now;
+ cur->send_ring[idx].pkt->identifier = htons(cur->icmp_id);
cur->send_ring[idx].pkt->seq = htons(cur->ping_seq);
cur->ping_seq++;
cur->send_ring[idx].pkt->checksum = 0;
diff --git a/src/ptunnel.h b/src/ptunnel.h
index d93f997..5a63acc 100644
--- a/src/ptunnel.h
+++ b/src/ptunnel.h
@@ -32,7 +32,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* Contacting the author:
- * You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe,
+ * You can get in touch with me, Daniel Stoedle (that's the Norwegian letter oe,
* in case your text editor didn't realize), here: <daniels@cs.uit.no>
*
* The official ptunnel website is here: