diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2017-12-20 18:47:06 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2017-12-20 18:47:06 +0100 |
commit | 3541aa3bf2e9090e2778e80a8dc20955bbb7654f (patch) | |
tree | 11bb82971cca87c3a54ee5724c230305df9b739b /src/ptunnel.c | |
parent | 0951e9a056dc791cd7a46014f1178b153829c48a (diff) |
ptunnel-ng:
* improved option parsing/error printing
* restrict tunnel destination ip/port only if the user wants it
* print a warning if running on windows wihout pcap enabled
* obey strict aliasing for pcap source
* print available pcap devices if the user supplied an invalid one
Diffstat (limited to 'src/ptunnel.c')
-rw-r--r-- | src/ptunnel.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/ptunnel.c b/src/ptunnel.c index 32bc4df..e7a93de 100644 --- a/src/ptunnel.c +++ b/src/ptunnel.c @@ -144,6 +144,11 @@ int main(int argc, char *argv[]) { pt_log(kLog_error, "Packet capture is not supported (or needed) when using UDP for transport.\n"); opts.pcap = 0; } +#ifdef WIN32 + if (!opts.pcap && !opts.udp) { + pt_log(kLog_info, "WARNING: Running ptunnel-ng on Windows in ICMP mode without WinPcap enabled is not supported and may not work!\n"); + } +#endif #endif pt_log(kLog_info, "Starting %s.\n", PACKAGE_STRING); pt_log(kLog_info, "(c) 2004-2011 Daniel Stoedle, <daniels@cs.uit.no>\n"); @@ -368,6 +373,7 @@ void* pt_proxy(void *args) { proxy_desc_t *cur, *prev, *tmp; #ifdef HAVE_PCAP pcap_info_t pc; + pcap_if_t *alldevs = 0, *pdev; #endif xfer_stats_t xfer; #ifdef HAVE_PCAP @@ -429,8 +435,10 @@ void* pt_proxy(void *args) { pt_log(kLog_error, "pcap error: %s\n", pc.pcap_err_buf); opts.pcap = 0; } - pt_log(kLog_verbose, "Network: %s\n", inet_ntoa(*(struct in_addr*)&pc.netp)); - pt_log(kLog_verbose, "Netmask: %s\n", inet_ntoa(*(struct in_addr*)&pc.netmask)); + in_addr.s_addr = pc.netp; + pt_log(kLog_verbose, "Network: %s\n", inet_ntoa(in_addr)); + in_addr.s_addr = pc.netmask; + pt_log(kLog_verbose, "Netmask: %s\n", inet_ntoa(in_addr)); if (pcap_compile(pc.pcap_desc, &pc.fp, pcap_filter_program, 0, pc.netp) == -1) { pt_log(kLog_error, "Failed to compile pcap filter program.\n"); pcap_close(pc.pcap_desc); @@ -445,6 +453,16 @@ void* pt_proxy(void *args) { else { pt_log(kLog_error, "pcap error: %s\n", pc.pcap_err_buf); opts.pcap = 0; + + if (pcap_findalldevs(&alldevs, pc.pcap_err_buf) == 0) { + idx = 0; + pt_log(kLog_error, "Available pcap devices:\n"); + for (pdev = alldevs; pdev != NULL; pdev = pdev->next) { + pt_log(kLog_error, "[%d] \"%s\": \"%s\"\n", ++idx, + pdev->name, (pdev->description ? pdev->description : "UNKNOWN")); + } + pcap_freealldevs(alldevs); + } } pc.pkt_q.head = 0; pc.pkt_q.tail = 0; |