[Listener] Use lib-client to create output socket

This commit is contained in:
Matteo Cypriani 2010-08-03 11:19:59 +02:00
parent d6a75a10fc
commit 2150dc1cde
3 changed files with 7 additions and 11 deletions

View File

@ -22,7 +22,8 @@ DEPFLAGS = -MMD
XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
PICFLAG = -fPIC
OWLPSFLAGS = -D USE_CONFIG_FILE -lconfuse -D USE_PTHREAD -pthread
LIBS = -L../../libowlps -lowlps -lpcap -liw -lm
LIBS = -L../../libowlps -lowlps -L../libowlps-client -lowlps-client \
-lpcap -liw -lm
LDFLAGS = $(LIBS) $(OWLPSFLAGS)

View File

@ -15,6 +15,8 @@
#include "../../libowlps/owlps.h"
#include "../libowlps-client/owlps-client.h"
#include <pcap.h>
#ifdef USE_CONFIG_FILE
@ -52,7 +54,6 @@ enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ;
/* Error codes */
#define ERR_CREATING_SOCKET 1 // Error when creating output socket
#define ERR_OPENING_IFACE 2 // Error when opening capture interface
#define ERR_BAD_USAGE 3 // Bad program call
#define ERR_PARSING_CONFIG_FILE 4 // Error reading the configuration file

View File

@ -334,7 +334,6 @@ int capture()
{
pcap_t *handle ; // Packet capture descriptor
char errbuf[PCAP_ERRBUF_SIZE] ; // Error message
struct sockaddr_in client ;
// Start capture:
handle = pcap_open_live(GET_RTAP_IFACE(), BUFSIZ, 1, 1000, errbuf) ;
@ -347,14 +346,9 @@ int capture()
/* Open UDP socket to the aggregator */
aggregation_sockfd =
create_udp_sending_socket(GET_AGGREGATION_IP(),
GET_AGGREGATION_PORT(),
&aggregation_server, &client) ;
if (aggregation_sockfd < 0)
{
perror("Error! Cannot create socket to the aggregation server");
return ERR_CREATING_SOCKET ;
}
owlps_create_socket_to_aggregator(GET_AGGREGATION_IP(),
GET_AGGREGATION_PORT(),
&aggregation_server, NULL) ;
while(run)
// Capture one packet at time, and call read_packet() on it: