summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/daemon/source/Makefile15
-rw-r--r--noncore/net/wellenreiter/daemon/source/config.hh1
-rw-r--r--noncore/net/wellenreiter/daemon/source/daemon.cc36
-rw-r--r--noncore/net/wellenreiter/daemon/source/daemon.hh3
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 @@
2 2
3 CPP = g++ 3 CPP = g++
4 4
5 CFLAGS=
6 OPTIMFLAGS= -g 5 OPTIMFLAGS= -g
7 WARNFLAGS= -Wall -pedantic -DDEBUG 6 WARNFLAGS= -Wall -pedantic -DDEBUG
8 LDFLAGS = 7 LDFLAGS =
9 LIBS = -lpcap 8 LIBS = -lpcap ../../libwellenreiter/source/libwellenreiter.a
10 OBJ = daemon.o log.o sendgui.o getgui.o sniffer.o 9 OBJ = daemon.o
11 10
12.SUFFIXES: 11.SUFFIXES:
13 .PHONY: all wellenreiterd clean distclean realclean 12 .PHONY: all wellenreiterd clean distclean realclean
14 13
15%.o : %.cc 14%.o : %.cc
16 $(CPP) $(CFLAGS) $(WARNFLAGS) $(OPTIMFLAGS) -c $< -o $@ 15 $(CPP) $(WARNFLAGS) $(OPTIMFLAGS) -c $< -o $@
17 16
18 all:wellenreiterd 17 all:wellenreiterd
19 18
20 wellenreiterd:$(OBJ) 19 wellenreiterd:$(OBJ)
21 $(CPP) $(OPTIMFLAGS) $(WARNFLAGS) $(CFLAGS) $(OBJ) $(LDFLAGS) $(LIBS) -o $@ 20 $(CPP) $(OPTIMFLAGS) $(WARNFLAGS) $(OBJ) $(LDFLAGS) $(LIBS) -o $@
22 @echo Build wellenreiterd 21 @echo Build wellenreiterd
23 22
24clean distclean realclean: 23clean distclean realclean:
25 @rm -rf wellenreiterd *~ *.o 24 @rm -rf wellenreiterd *~ *.o
26 @echo All dependent files have been removed. 25 @echo All dependent files have been removed.
27 26
28 wellenreiterd.o:config.hh 27 daemon.o:config.hh
29 serve.o: config.hh 28
30 log.o: config.hh
31 sendgui.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 @@
14#define PROGNAME "wellenreiter" /* Name of program (for syslog et.al.) */ 14#define PROGNAME "wellenreiter" /* Name of program (for syslog et.al.) */
15#define VERSION "0.2" /* Version of wellenreiter */ 15#define VERSION "0.2" /* Version of wellenreiter */
16 16
17#define DAEMONADDR "127.0.0.1"
17#define DAEMONPORT 37772 /* Port of Daemon */ 18#define DAEMONPORT 37772 /* Port of Daemon */
18 19
19#define GUIADDR "127.0.0.1" /* Adress of GUI, later specified in configfile */ 20#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 @@
6 6
7#include "config.hh" 7#include "config.hh"
8#include "daemon.hh" 8#include "daemon.hh"
9#include "log.hh"
10#include "sendgui.hh"
11#include "getgui.hh"
12 9
13/* Main function of wellenreiterd */ 10/* Main function of wellenreiterd */
14int main(int argc, char **argv) 11int main(int argc, char **argv)
15{ 12{
16 int sock, maxfd; 13 int sock, maxfd, guiport=GUIPORT;
14 char guihost[]="127.0.0.1";
17 struct sockaddr_in *cliaddr; 15 struct sockaddr_in *cliaddr;
18 socklen_t len=sizeof(struct sockaddr); 16 socklen_t len=sizeof(struct sockaddr);
19 char buffer[128]; 17 char buffer[128];
@@ -23,15 +21,17 @@ int main(int argc, char **argv)
23 fprintf(stderr, "wellenreiterd %s\n\n", VERSION); 21 fprintf(stderr, "wellenreiterd %s\n\n", VERSION);
24 22
25 /* Setup socket for incoming commands */ 23 /* Setup socket for incoming commands */
26 if(!commsock(&sock)) 24 if((sock=commsock(DAEMONADDR, DAEMONPORT)) < 0)
27 return 0; 25 {
28 26 wl_logerr("Cannot setup socket");
29 log_info("Set up socket '%d' for GUI communication", sock); 27 exit(-1);
28 }
29 wl_loginfo("Set up socket '%d' for GUI communication", sock);
30 30
31 FD_ZERO(&rset); 31 FD_ZERO(&rset);
32 32
33 /* Start main loop */ 33 /* Start main loop */
34 log_info("Starting main loop"); 34 wl_loginfo("Starting main loop");
35 while(1) 35 while(1)
36 { 36 {
37 37
@@ -40,7 +40,7 @@ int main(int argc, char **argv)
40 maxfd=sock+fileno(fp)+1; 40 maxfd=sock+fileno(fp)+1;
41 if(select(maxfd, &rset, NULL, NULL, NULL) < 0) 41 if(select(maxfd, &rset, NULL, NULL, NULL) < 0)
42 { 42 {
43 log_err("Error calling select: %s", strerror(errno)); 43 wl_logerr("Error calling select: %s", strerror(errno));
44 break; 44 break;
45 } 45 }
46 46
@@ -50,13 +50,13 @@ int main(int argc, char **argv)
50 memset(buffer, 0, sizeof(buffer)); 50 memset(buffer, 0, sizeof(buffer));
51 if(recvfrom(sock, buffer, sizeof(buffer)-1, 0, (struct sockaddr *)cliaddr, &len) < 0) 51 if(recvfrom(sock, buffer, sizeof(buffer)-1, 0, (struct sockaddr *)cliaddr, &len) < 0)
52 { 52 {
53 log_err("Cannot read from socket: %s", strerror(errno)); 53 wl_logerr("Cannot read from socket: %s", strerror(errno));
54 break; 54 break;
55 } 55 }
56 log_info("Received command from '%s': %s", inet_ntoa(cliaddr->sin_addr), buffer); 56 wl_loginfo("Received command from '%s': %s", inet_ntoa(cliaddr->sin_addr), buffer);
57 57
58 /* Pass string to analyze function */ 58 /* Pass string to analyze function */
59 commstring(buffer); 59 // sendcomm(guihost, guiport, buffer);
60 60
61 } 61 }
62 62
@@ -66,18 +66,16 @@ int main(int argc, char **argv)
66 memset(buffer, 0, sizeof(buffer)); 66 memset(buffer, 0, sizeof(buffer));
67 if(fgets(buffer, sizeof(buffer) - 1, fp) == NULL) 67 if(fgets(buffer, sizeof(buffer) - 1, fp) == NULL)
68 { 68 {
69 log_err("Cannot read from stdin: %s", strerror(errno)); 69 wl_logerr("Cannot read from stdin: %s", strerror(errno));
70 break; 70 break;
71 } 71 }
72 log_info("Sending command to '%s': %s", GUIADDR, buffer); 72 wl_loginfo("Sending command to '%s': %s", GUIADDR, buffer);
73 73
74 /* Send string to GUI */ 74 /* Send string to GUI */
75 sendgui("%d: %s", 1234, buffer); 75 sendcomm(guihost, guiport, "%d: %s", 1234, buffer);
76 76
77 } 77 }
78
79 } 78 }
80
81 close(sock); 79 close(sock);
82 return 0; 80 exit(0);
83} 81}
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 @@
13#include <unistd.h> 13#include <unistd.h>
14#include <errno.h> 14#include <errno.h>
15 15
16#include "../../libwellenreiter/source/sock.hh"
17#include "../../libwellenreiter/source/log.hh"
18
16#endif /* DAEMON_HH */ 19#endif /* DAEMON_HH */