error reporting, removal of stale files, removed warning
This commit is contained in:
4
Makefile
4
Makefile
@@ -12,7 +12,7 @@ all: nethogs
|
|||||||
|
|
||||||
#CFLAGS=-g -Wall
|
#CFLAGS=-g -Wall
|
||||||
CFLAGS=-O2
|
CFLAGS=-O2
|
||||||
OBJS=structs.o packet.o connection.o process.o refresh.o decpcap.o cui.o inode2prog.o
|
OBJS=packet.o connection.o process.o refresh.o decpcap.o cui.o inode2prog.o
|
||||||
.PHONY: tgz
|
.PHONY: tgz
|
||||||
|
|
||||||
tgz: clean
|
tgz: clean
|
||||||
@@ -33,8 +33,6 @@ nethogs: nethogs.cpp $(OBJS)
|
|||||||
|
|
||||||
refresh.o: refresh.cpp refresh.h nethogs.h
|
refresh.o: refresh.cpp refresh.h nethogs.h
|
||||||
$(CXX) $(CFLAGS) -c refresh.cpp
|
$(CXX) $(CFLAGS) -c refresh.cpp
|
||||||
structs.o: structs.cpp structs.h nethogs.h
|
|
||||||
$(CXX) $(CFLAGS) -c structs.cpp
|
|
||||||
process.o: process.cpp process.h nethogs.h
|
process.o: process.cpp process.h nethogs.h
|
||||||
$(CXX) $(CFLAGS) -c process.cpp
|
$(CXX) $(CFLAGS) -c process.cpp
|
||||||
packet.o: packet.cpp packet.h nethogs.h
|
packet.o: packet.cpp packet.h nethogs.h
|
||||||
|
|||||||
15
nethogs.cpp
15
nethogs.cpp
@@ -203,11 +203,22 @@ void quit_cb (int i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void forceExit(const char *msg)
|
void forceExit(const char *msg)
|
||||||
|
{
|
||||||
|
forceExit (msg, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void forceExit(const char *msg, const char* msg2)
|
||||||
{
|
{
|
||||||
if ((!tracemode)&&(!DEBUG)){
|
if ((!tracemode)&&(!DEBUG)){
|
||||||
exit_ui();
|
exit_ui();
|
||||||
}
|
}
|
||||||
std::cerr << msg << std::endl;
|
std::cerr << msg;
|
||||||
|
if (msg2 != NULL)
|
||||||
|
{
|
||||||
|
std::cerr << msg2;
|
||||||
|
}
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +310,9 @@ int main (int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (devices == NULL)
|
if (devices == NULL)
|
||||||
|
{
|
||||||
devices = new device (strdup("eth0"));
|
devices = new device (strdup("eth0"));
|
||||||
|
}
|
||||||
|
|
||||||
if ((!tracemode) && (!DEBUG)){
|
if ((!tracemode) && (!DEBUG)){
|
||||||
init_ui();
|
init_ui();
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
#define PROGNAME_WIDTH 27
|
#define PROGNAME_WIDTH 27
|
||||||
|
|
||||||
void forceExit(const char *msg);
|
void forceExit(const char *msg);
|
||||||
|
void forceExit(const char *msg, const char* msg2);
|
||||||
|
|
||||||
class local_addr {
|
class local_addr {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -38,12 +38,12 @@ void getLocal (const char *device, bool tracemode)
|
|||||||
struct ifreq iFreq;
|
struct ifreq iFreq;
|
||||||
struct sockaddr_in *saddr;
|
struct sockaddr_in *saddr;
|
||||||
|
|
||||||
if((sock=socket(AF_INET, SOCK_PACKET, htons(0x0806)))<0){
|
if((sock=socket(AF_INET, SOCK_RAW, htons(0x0806)))<0){
|
||||||
forceExit("creating socket failed while establishing local IP - are you root?");
|
forceExit("creating socket failed while establishing local IP - are you root?");
|
||||||
}
|
}
|
||||||
strcpy(iFreq.ifr_name, device);
|
strcpy(iFreq.ifr_name, device);
|
||||||
if(ioctl(sock, SIOCGIFADDR, &iFreq)<0){
|
if(ioctl(sock, SIOCGIFADDR, &iFreq)<0){
|
||||||
forceExit("ioctl failed while establishing local IP");
|
forceExit("ioctl failed while establishing local IP for device ", device);
|
||||||
}
|
}
|
||||||
saddr=(struct sockaddr_in*)&iFreq.ifr_addr;
|
saddr=(struct sockaddr_in*)&iFreq.ifr_addr;
|
||||||
local_addrs = new local_addr (saddr->sin_addr.s_addr, local_addrs);
|
local_addrs = new local_addr (saddr->sin_addr.s_addr, local_addrs);
|
||||||
|
|||||||
Reference in New Issue
Block a user