Commit e6b086f2 authored by Andreas Langer's avatar Andreas Langer

add handling for batman-adv-kernelspace

parent ea336b20
......@@ -22,6 +22,8 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/select.h>
#include <errno.h>
#include <stdio.h>
#include <stdint.h>
......@@ -30,11 +32,8 @@
#include <unistd.h>
#include <getopt.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/select.h>
#include <features.h>
#include <fcntl.h>
#include "battool.h"
#include "functions.h"
......@@ -155,15 +154,19 @@ int batping_main( int argc, char **argv, struct hashtable_t *hash ) {
unix_if.addr.sun_family = AF_LOCAL;
strcpy( unix_if.addr.sun_path, UNIX_PATH );
if ( connect ( unix_if.unix_sock, (struct sockaddr *)&unix_if.addr, sizeof(struct sockaddr_un) ) < 0 ) {
DBG( "can't connect to unix socket '%s': %s ! Is batmand running on this host ?", UNIX_PATH, strerror(errno) );
close( unix_if.unix_sock );
return(EXIT_FAILURE);
if( ( unix_if.unix_sock = open( BAT_DEVICE, O_RDWR | O_NONBLOCK ) ) < 0 ) {
}
if ( connect ( unix_if.unix_sock, (struct sockaddr *)&unix_if.addr, sizeof(struct sockaddr_un) ) < 0 ) {
DBG( "can't connect to unix socket '%s': %s ! Is batmand running on this host ?", UNIX_PATH, strerror(errno) );
close( unix_if.unix_sock );
return(EXIT_FAILURE);
}
}
send_buff = malloc( sbsize );
memset(send_buff, '\0', sbsize );
rec_buff = malloc( rbsize );
......@@ -192,9 +195,10 @@ int batping_main( int argc, char **argv, struct hashtable_t *hash ) {
icmp_packet.seqno = htons( ++seq_counter );
memcpy( send_buff+2, &icmp_packet, rbsize );
if ( write( unix_if.unix_sock, send_buff, sbsize ) < 0 ) {
printf( "Error - can't write to unix socket: %s\n", strerror(errno) );
printf( "Error - can't write to unix socket: %s %d\n", strerror(errno), errno );
close( unix_if.unix_sock );
free( send_buff);
return(EXIT_FAILURE);
......
......@@ -27,6 +27,7 @@
#define SOURCE_VERSION "0.1-alpha"
#define UNIX_PATH "/var/run/batmand-adv.socket"
#define BAT_DEVICE "/dev/batman-adv"
#define HOSTS_FILE "bat-hosts"
#define DBG(msg,args...) do { printf("batgat: [%s:%u] " msg "\n", __func__ ,__LINE__, ##args); } while(0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment