Diffstat (limited to 'noncore/net/wellenreiter/daemon/source/daemon.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.cc | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc index 1f9e98a..a2e1f96 100644 --- a/noncore/net/wellenreiter/daemon/source/daemon.cc +++ b/noncore/net/wellenreiter/daemon/source/daemon.cc @@ -14,5 +14,3 @@ int main(int argc, char **argv) { - int sock, maxfd; - struct sockaddr_in *cliaddr; - socklen_t len=sizeof(struct sockaddr); + int sock, maxfd, retval; char buffer[128]; @@ -27,2 +25,3 @@ int main(int argc, char **argv) +#if 0 /* will be replaced soon, just for max because max is lazy :-) */ @@ -33,2 +32,3 @@ int main(int argc, char **argv) } +#endif @@ -45,3 +45,3 @@ int main(int argc, char **argv) exit(-1); - } + } wl_loginfo("Set up socket '%d' for GUI communication", sock); @@ -56,4 +56,5 @@ int main(int argc, char **argv) FD_SET(sock, &rset); - FD_SET(pcap_fileno(handletopcap), &rset); - maxfd=sock + pcap_fileno(handletopcap) + 1; + // FD_SET(pcap_fileno(handletopcap), &rset); + // maxfd=sock + pcap_fileno(handletopcap) + 1; + maxfd=sock + 1; if(select(maxfd, &rset, NULL, NULL, NULL) < 0) @@ -67,15 +68,32 @@ int main(int argc, char **argv) { - memset(buffer, 0, sizeof(buffer)); - if(recvfrom(sock, buffer, sizeof(buffer)-1, 0, (struct sockaddr *)cliaddr, &len) < 0) + + if((retval=recvcomm(&sock, buffer, sizeof(buffer))) < 0) { - wl_logerr("Cannot read from socket: %s", strerror(errno)); - break; + wl_logerr("Error trying to read: %s", strerror(errno)); + break; } - wl_loginfo("Received command from '%s': %s", inet_ntoa(cliaddr->sin_addr), buffer); - - /* will be passed to analyze function */ - fprintf(stderr, "Received command: %s\n", buffer); - - } - + else + { + switch(retval) + { + case 98: + { + wl_loginfo("Received STARTSNIFF command"); + break; + }; + case 99: + { + wl_loginfo("Received STOPSNIFF command"); + break; + }; + default: + { + wl_logerr("Received unknown command: %d", retval); + break; + }; + } + } + } /* FD_ISSET */ + +#if 0 /* Pcap stuff */ @@ -89,4 +107,4 @@ int main(int argc, char **argv) process_packets(NULL,&header,*&packet); - } +#endif } |