Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: Refine connection status reporting. #1389

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ DayOfTheWeek, Month DD, YYYY / The Tcpdump Group
Fix a few device activation bugs.
Count and timestamp packets better.
Add kernel filtering, fix userland filtering.
Linux:
Refine connection status reporting.
DAG:
Always set PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE.
In dag_findalldevs() handle known errors better.
Expand Down
20 changes: 12 additions & 8 deletions pcap-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
// Linux before 3.5
#define ARPHRD_IEEE802154_MONITOR 805
#endif
#ifndef ARPHRD_IP6GRE
// Linux before 3.7
#define ARPHRD_IP6GRE 823
#endif
#ifndef ARPHRD_NETLINK
// Linux before 3.11
#define ARPHRD_NETLINK 824
Expand Down Expand Up @@ -1828,17 +1832,22 @@ get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
switch (arptype) {

case ARPHRD_LOOPBACK:
case ARPHRD_CAN:
case ARPHRD_TUNNEL:
case ARPHRD_TUNNEL6:
case ARPHRD_SIT:
case ARPHRD_IPGRE:
case ARPHRD_IP6GRE:
/*
* These are types to which
* "connected" and "disconnected"
* don't apply, so don't bother
* asking about it.
*
* XXX - add other types?
*/
close(sock);
fclose(fh);
free(pathstr);
*flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE;
return 0;

case ARPHRD_IRDA:
Expand Down Expand Up @@ -1886,13 +1895,8 @@ get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
/*
* OK, this OS version or driver doesn't support
* asking for this information.
* XXX - distinguish between "this doesn't
* support ethtool at all because it's not
* that type of device" vs. "this doesn't
* support ethtool even though it's that
* type of device", and return "unknown".
*/
*flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE;
*flags |= PCAP_IF_CONNECTION_STATUS_UNKNOWN;
close(sock);
return 0;

Expand Down