Diffstat (limited to 'noncore/net/wellenreiter/daemon') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/Makefile | 15 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/config.hh | 1 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.cc | 36 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.hh | 3 |
4 files changed, 27 insertions, 28 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/Makefile b/noncore/net/wellenreiter/daemon/source/Makefile index dc459af..f6efa3d 100644 --- a/noncore/net/wellenreiter/daemon/source/Makefile +++ b/noncore/net/wellenreiter/daemon/source/Makefile @@ -4,3 +4,2 @@ CPP = g++ -CFLAGS = OPTIMFLAGS = -g @@ -8,4 +7,4 @@ WARNFLAGS = -Wall -pedantic -DDEBUG LDFLAGS = -LIBS = -lpcap -OBJ = daemon.o log.o sendgui.o getgui.o sniffer.o +LIBS = -lpcap ../../libwellenreiter/source/libwellenreiter.a +OBJ = daemon.o @@ -15,3 +14,3 @@ OBJ = daemon.o log.o sendgui.o getgui.o sniffer.o %.o : %.cc - $(CPP) $(CFLAGS) $(WARNFLAGS) $(OPTIMFLAGS) -c $< -o $@ + $(CPP) $(WARNFLAGS) $(OPTIMFLAGS) -c $< -o $@ @@ -20,3 +19,3 @@ all: wellenreiterd wellenreiterd: $(OBJ) - $(CPP) $(OPTIMFLAGS) $(WARNFLAGS) $(CFLAGS) $(OBJ) $(LDFLAGS) $(LIBS) -o $@ + $(CPP) $(OPTIMFLAGS) $(WARNFLAGS) $(OBJ) $(LDFLAGS) $(LIBS) -o $@ @echo Build wellenreiterd @@ -27,5 +26,3 @@ clean distclean realclean: -wellenreiterd.o: config.hh -serve.o: config.hh -log.o: config.hh -sendgui.o: config.hh +daemon.o: config.hh + diff --git a/noncore/net/wellenreiter/daemon/source/config.hh b/noncore/net/wellenreiter/daemon/source/config.hh index b124f41..b54ff46 100644 --- a/noncore/net/wellenreiter/daemon/source/config.hh +++ b/noncore/net/wellenreiter/daemon/source/config.hh @@ -16,2 +16,3 @@ +#define DAEMONADDR "127.0.0.1" #define DAEMONPORT 37772 /* Port of Daemon */ diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc index 8724efa..b3a37b6 100644 --- a/noncore/net/wellenreiter/daemon/source/daemon.cc +++ b/noncore/net/wellenreiter/daemon/source/daemon.cc @@ -8,5 +8,2 @@ #include "daemon.hh" -#include "log.hh" -#include "sendgui.hh" -#include "getgui.hh" @@ -15,3 +12,4 @@ int main(int argc, char **argv) { - int sock, maxfd; + int sock, maxfd, guiport=GUIPORT; + char guihost[]="127.0.0.1"; struct sockaddr_in *cliaddr; @@ -25,6 +23,8 @@ int main(int argc, char **argv) /* Setup socket for incoming commands */ - if(!commsock(&sock)) - return 0; - - log_info("Set up socket '%d' for GUI communication", sock); + if((sock=commsock(DAEMONADDR, DAEMONPORT)) < 0) + { + wl_logerr("Cannot setup socket"); + exit(-1); + } + wl_loginfo("Set up socket '%d' for GUI communication", sock); @@ -33,3 +33,3 @@ int main(int argc, char **argv) /* Start main loop */ - log_info("Starting main loop"); + wl_loginfo("Starting main loop"); while(1) @@ -42,3 +42,3 @@ int main(int argc, char **argv) { - log_err("Error calling select: %s", strerror(errno)); + wl_logerr("Error calling select: %s", strerror(errno)); break; @@ -52,9 +52,9 @@ int main(int argc, char **argv) { - log_err("Cannot read from socket: %s", strerror(errno)); + wl_logerr("Cannot read from socket: %s", strerror(errno)); break; } - log_info("Received command from '%s': %s", inet_ntoa(cliaddr->sin_addr), buffer); + wl_loginfo("Received command from '%s': %s", inet_ntoa(cliaddr->sin_addr), buffer); /* Pass string to analyze function */ - commstring(buffer); + // sendcomm(guihost, guiport, buffer); @@ -68,16 +68,14 @@ int main(int argc, char **argv) { - log_err("Cannot read from stdin: %s", strerror(errno)); + wl_logerr("Cannot read from stdin: %s", strerror(errno)); break; } - log_info("Sending command to '%s': %s", GUIADDR, buffer); + wl_loginfo("Sending command to '%s': %s", GUIADDR, buffer); /* Send string to GUI */ - sendgui("%d: %s", 1234, buffer); + sendcomm(guihost, guiport, "%d: %s", 1234, buffer); } - } - close(sock); - return 0; + exit(0); } diff --git a/noncore/net/wellenreiter/daemon/source/daemon.hh b/noncore/net/wellenreiter/daemon/source/daemon.hh index 6776d37..a9a97ac 100644 --- a/noncore/net/wellenreiter/daemon/source/daemon.hh +++ b/noncore/net/wellenreiter/daemon/source/daemon.hh @@ -15,2 +15,5 @@ +#include "../../libwellenreiter/source/sock.hh" +#include "../../libwellenreiter/source/log.hh" + #endif /* DAEMON_HH */ |