author | mjm <mjm> | 2002-11-22 23:41:17 (UTC) |
---|---|---|
committer | mjm <mjm> | 2002-11-22 23:41:17 (UTC) |
commit | b4affc7067cdc7ede2217607be71fe3091a2a599 (patch) (side-by-side diff) | |
tree | a3c12499038b2700ddc5a259ed664bdeae2deb6a /noncore/net | |
parent | 5a346c71bf5255eb769c9fceb34358c06e60aef3 (diff) | |
download | opie-b4affc7067cdc7ede2217607be71fe3091a2a599.zip opie-b4affc7067cdc7ede2217607be71fe3091a2a599.tar.gz opie-b4affc7067cdc7ede2217607be71fe3091a2a599.tar.bz2 |
uses libwellenreiter now
-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 @@ -2,30 +2,27 @@ CPP = g++ -CFLAGS = OPTIMFLAGS = -g 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 .SUFFIXES: .PHONY: all wellenreiterd clean distclean realclean %.o : %.cc - $(CPP) $(CFLAGS) $(WARNFLAGS) $(OPTIMFLAGS) -c $< -o $@ + $(CPP) $(WARNFLAGS) $(OPTIMFLAGS) -c $< -o $@ all: wellenreiterd wellenreiterd: $(OBJ) - $(CPP) $(OPTIMFLAGS) $(WARNFLAGS) $(CFLAGS) $(OBJ) $(LDFLAGS) $(LIBS) -o $@ + $(CPP) $(OPTIMFLAGS) $(WARNFLAGS) $(OBJ) $(LDFLAGS) $(LIBS) -o $@ @echo Build wellenreiterd clean distclean realclean: @rm -rf wellenreiterd *~ *.o @echo All dependent files have been removed. -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 @@ -14,6 +14,7 @@ #define PROGNAME "wellenreiter" /* Name of program (for syslog et.al.) */ #define VERSION "0.2" /* Version of wellenreiter */ +#define DAEMONADDR "127.0.0.1" #define DAEMONPORT 37772 /* Port of Daemon */ #define GUIADDR "127.0.0.1" /* Adress of GUI, later specified in configfile */ 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 @@ -6,14 +6,12 @@ #include "config.hh" #include "daemon.hh" -#include "log.hh" -#include "sendgui.hh" -#include "getgui.hh" /* Main function of wellenreiterd */ int main(int argc, char **argv) { - int sock, maxfd; + int sock, maxfd, guiport=GUIPORT; + char guihost[]="127.0.0.1"; struct sockaddr_in *cliaddr; socklen_t len=sizeof(struct sockaddr); char buffer[128]; @@ -23,15 +21,17 @@ int main(int argc, char **argv) fprintf(stderr, "wellenreiterd %s\n\n", VERSION); /* 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); FD_ZERO(&rset); /* Start main loop */ - log_info("Starting main loop"); + wl_loginfo("Starting main loop"); while(1) { @@ -40,7 +40,7 @@ int main(int argc, char **argv) maxfd=sock+fileno(fp)+1; if(select(maxfd, &rset, NULL, NULL, NULL) < 0) { - log_err("Error calling select: %s", strerror(errno)); + wl_logerr("Error calling select: %s", strerror(errno)); break; } @@ -50,13 +50,13 @@ int main(int argc, char **argv) memset(buffer, 0, sizeof(buffer)); if(recvfrom(sock, buffer, sizeof(buffer)-1, 0, (struct sockaddr *)cliaddr, &len) < 0) { - 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); } @@ -66,18 +66,16 @@ int main(int argc, char **argv) memset(buffer, 0, sizeof(buffer)); if(fgets(buffer, sizeof(buffer) - 1, fp) == NULL) { - 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 @@ -13,4 +13,7 @@ #include <unistd.h> #include <errno.h> +#include "../../libwellenreiter/source/sock.hh" +#include "../../libwellenreiter/source/log.hh" + #endif /* DAEMON_HH */ |