Commit 45ccb4e4 authored by pdw's avatar pdw

Various changes for portability to FreeBSD.

Added "R" to control service resolution.
parent 94b6ab8f
......@@ -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>
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment