[Listener] Use lib-client to create output socket
This commit is contained in:
parent
d6a75a10fc
commit
2150dc1cde
|
@ -22,7 +22,8 @@ DEPFLAGS = -MMD
|
||||||
XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
||||||
PICFLAG = -fPIC
|
PICFLAG = -fPIC
|
||||||
OWLPSFLAGS = -D USE_CONFIG_FILE -lconfuse -D USE_PTHREAD -pthread
|
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)
|
LDFLAGS = $(LIBS) $(OWLPSFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
|
|
||||||
#include "../../libowlps/owlps.h"
|
#include "../../libowlps/owlps.h"
|
||||||
|
#include "../libowlps-client/owlps-client.h"
|
||||||
|
|
||||||
#include <pcap.h>
|
#include <pcap.h>
|
||||||
|
|
||||||
#ifdef USE_CONFIG_FILE
|
#ifdef USE_CONFIG_FILE
|
||||||
|
@ -52,7 +54,6 @@ enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ;
|
||||||
|
|
||||||
|
|
||||||
/* Error codes */
|
/* Error codes */
|
||||||
#define ERR_CREATING_SOCKET 1 // Error when creating output socket
|
|
||||||
#define ERR_OPENING_IFACE 2 // Error when opening capture interface
|
#define ERR_OPENING_IFACE 2 // Error when opening capture interface
|
||||||
#define ERR_BAD_USAGE 3 // Bad program call
|
#define ERR_BAD_USAGE 3 // Bad program call
|
||||||
#define ERR_PARSING_CONFIG_FILE 4 // Error reading the configuration file
|
#define ERR_PARSING_CONFIG_FILE 4 // Error reading the configuration file
|
||||||
|
|
|
@ -334,7 +334,6 @@ int capture()
|
||||||
{
|
{
|
||||||
pcap_t *handle ; // Packet capture descriptor
|
pcap_t *handle ; // Packet capture descriptor
|
||||||
char errbuf[PCAP_ERRBUF_SIZE] ; // Error message
|
char errbuf[PCAP_ERRBUF_SIZE] ; // Error message
|
||||||
struct sockaddr_in client ;
|
|
||||||
|
|
||||||
// Start capture:
|
// Start capture:
|
||||||
handle = pcap_open_live(GET_RTAP_IFACE(), BUFSIZ, 1, 1000, errbuf) ;
|
handle = pcap_open_live(GET_RTAP_IFACE(), BUFSIZ, 1, 1000, errbuf) ;
|
||||||
|
@ -347,14 +346,9 @@ int capture()
|
||||||
|
|
||||||
/* Open UDP socket to the aggregator */
|
/* Open UDP socket to the aggregator */
|
||||||
aggregation_sockfd =
|
aggregation_sockfd =
|
||||||
create_udp_sending_socket(GET_AGGREGATION_IP(),
|
owlps_create_socket_to_aggregator(GET_AGGREGATION_IP(),
|
||||||
GET_AGGREGATION_PORT(),
|
GET_AGGREGATION_PORT(),
|
||||||
&aggregation_server, &client) ;
|
&aggregation_server, NULL) ;
|
||||||
if (aggregation_sockfd < 0)
|
|
||||||
{
|
|
||||||
perror("Error! Cannot create socket to the aggregation server");
|
|
||||||
return ERR_CREATING_SOCKET ;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(run)
|
while(run)
|
||||||
// Capture one packet at time, and call read_packet() on it:
|
// Capture one packet at time, and call read_packet() on it:
|
||||||
|
|
Loading…
Reference in New Issue