mirror of
https://github.com/openbsd/ports.git
synced 2026-06-17 23:13:55 +02:00
net/tcpflow: fix listening on a loopback interface
From maintainer Kirill A. Korinsky
This commit is contained in:
@@ -3,7 +3,7 @@ COMMENT= tool for capturing data from TCP connections
|
||||
V= 1.6.1
|
||||
DISTNAME= tcpflow-${V}
|
||||
CATEGORIES= net
|
||||
REVISION= 1
|
||||
REVISION= 2
|
||||
|
||||
SITES= https://github.com/simsong/tcpflow/releases/download/tcpflow-${V}/
|
||||
|
||||
|
||||
@@ -1,9 +1,32 @@
|
||||
Index: src/datalink.cpp
|
||||
--- src/datalink.cpp.orig
|
||||
+++ src/datalink.cpp
|
||||
@@ -71,6 +71,29 @@ void dl_null(u_char *user, const struct pcap_pkthdr *h
|
||||
@@ -70,7 +70,52 @@ void dl_null(u_char *user, const struct pcap_pkthdr *h
|
||||
}
|
||||
#pragma GCC diagnostic warning "-Wcast-align"
|
||||
|
||||
+#define LOOP_HDRLEN 4
|
||||
+
|
||||
+void dl_loop(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
|
||||
+{
|
||||
+ u_int caplen = h->caplen;
|
||||
+ u_int length = h->len;
|
||||
+
|
||||
+ if (length != caplen) {
|
||||
+ DEBUG(6) ("warning: only captured %d bytes of %d byte null frame",
|
||||
+ caplen, length);
|
||||
+ }
|
||||
+
|
||||
+ if (caplen < LOOP_HDRLEN) {
|
||||
+ DEBUG(6) ("warning: received incomplete null frame");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ struct timeval tv;
|
||||
+ be13::packet_info pi(DLT_LOOP,h,p,tvshift(tv,h->ts),p+LOOP_HDRLEN,caplen - LOOP_HDRLEN);
|
||||
+ be13::plugin::process_packet(pi);
|
||||
+}
|
||||
+
|
||||
static uint64_t counter=0;
|
||||
+
|
||||
+#define PPP_ETHER_HDRLEN 8
|
||||
@@ -31,11 +54,19 @@ Index: src/datalink.cpp
|
||||
/* DLT_RAW: just a raw IP packet, no encapsulation or link-layer
|
||||
* headers. Used for PPP connections under some OSs including Linux
|
||||
* and IRIX. */
|
||||
@@ -278,14 +301,18 @@ dlt_handler_t handlers[] = {
|
||||
{ dl_raw, 101 },
|
||||
@@ -269,7 +314,8 @@ void dl_linux_sll(u_char *user, const struct pcap_pkth
|
||||
|
||||
/* List of callbacks for each data link type */
|
||||
dlt_handler_t handlers[] = {
|
||||
- { dl_null, DLT_NULL },
|
||||
+ { dl_null, DLT_NULL },
|
||||
+ { dl_loop, DLT_LOOP },
|
||||
/* Some systems define DLT_RAW as 12, some as 14, and some as 101.
|
||||
* So it is hard-coded here.
|
||||
*/
|
||||
@@ -279,13 +325,16 @@ dlt_handler_t handlers[] = {
|
||||
{ dl_ethernet, DLT_EN10MB },
|
||||
{ dl_ethernet, DLT_IEEE802 },
|
||||
+ { dl_null, DLT_LOOP },
|
||||
{ dl_ppp, DLT_PPP },
|
||||
+ { dl_ppp_ether, DLT_PPP_ETHER },
|
||||
#ifdef DLT_LINUX_SLL
|
||||
|
||||
Reference in New Issue
Block a user