Various changes for portability to FreeBSD.
Added "R" to control service resolution.
This commit is contained in:
2
Makefile
2
Makefile
@@ -29,7 +29,7 @@ MANDIR = man
|
||||
#MANDIR = share/man # FHS-ish
|
||||
|
||||
# You shouldn't need to change anything below this point.
|
||||
VERSION = 0.8
|
||||
VERSION = 0.9pre1
|
||||
CFLAGS += -g -Wall "-DIFTOP_VERSION=\"$(VERSION)\""
|
||||
LDFLAGS += -g
|
||||
LDLIBS += -lpcap -lpthread -lcurses -lm
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#ifndef __ADDR_HASH_H_ /* include guard */
|
||||
#define __ADDR_HASH_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
4
iftop.c
4
iftop.c
@@ -7,6 +7,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <net/ethernet.h>
|
||||
@@ -130,7 +132,7 @@ void assign_addr_pair(addr_pair* ap, struct ip* iptr, int flip) {
|
||||
unsigned short int dst_port = 0;
|
||||
|
||||
/* Does this protocol use ports? */
|
||||
if(iptr->ip_p == SOL_TCP || iptr->ip_p == SOL_UDP) {
|
||||
if(iptr->ip_p == IPPROTO_TCP || iptr->ip_p == IPPROTO_UDP) {
|
||||
/* We take a slight liberty here by treating UDP the same as TCP */
|
||||
|
||||
/* Find the TCP/UDP header */
|
||||
|
||||
8
iftop.h
8
iftop.h
@@ -33,4 +33,12 @@ void ui_init(void);
|
||||
/* options.c */
|
||||
void options_read(int argc, char **argv);
|
||||
|
||||
|
||||
/* Make use of SIOCGIFHWADDR work on FreeBSD */
|
||||
#ifdef __BSD__
|
||||
#define SIOCGIFHWADDR SIOCGIFADDR
|
||||
#define ifr_hwaddr ifr_addr
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __IFTOP_H_ */
|
||||
|
||||
@@ -64,6 +64,7 @@ static void set_defaults() {
|
||||
inet_aton("10.0.1.0", &options.netfilternet);
|
||||
inet_aton("255.255.255.0", &options.netfiltermask);
|
||||
options.dnsresolution = 1;
|
||||
options.portresolution = 1;
|
||||
options.promiscuous = 0;
|
||||
options.showbars = 1;
|
||||
options.showports = OPTION_PORTS_OFF;
|
||||
|
||||
@@ -35,6 +35,7 @@ typedef struct {
|
||||
struct in_addr netfilternet;
|
||||
struct in_addr netfiltermask;
|
||||
int dnsresolution;
|
||||
int portresolution;
|
||||
int promiscuous;
|
||||
int showbars;
|
||||
option_port_t showports;
|
||||
|
||||
7
ui.c
7
ui.c
@@ -328,7 +328,7 @@ void sprint_host(char * line, struct in_addr* addr, unsigned int port, unsigned
|
||||
if(port != 0) {
|
||||
skey.port = port;
|
||||
skey.protocol = protocol;
|
||||
if(hash_find(service_hash, &skey, (void**)&s_name) == HASH_STATUS_OK) {
|
||||
if(options.portresolution && hash_find(service_hash, &skey, (void**)&s_name) == HASH_STATUS_OK) {
|
||||
snprintf(service, HOSTNAME_LENGTH, ":%s", s_name);
|
||||
}
|
||||
else {
|
||||
@@ -513,6 +513,11 @@ void ui_loop() {
|
||||
tick(1);
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
options.portresolution = !options.portresolution;
|
||||
tick(1);
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
options.showbars = !options.showbars;
|
||||
tick(1);
|
||||
|
||||
Reference in New Issue
Block a user