mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-03-25 13:17:43 +00:00
Fixes for OSX compilation, preparation for adding overlay mesh network.
This commit is contained in:
parent
a2bcb56e1f
commit
5a7381bd2a
16
Makefile
Executable file → Normal file
16
Makefile
Executable file → Normal file
@ -1,10 +1,10 @@
|
||||
OBJS= dna.o server.o client.o peers.o ciphers.o responses.o packetformats.o dataformats.o hlrdata.o srandomdev.o simulate.o batman.o
|
||||
CFILES= dna.c server.c client.c peers.c ciphers.c responses.c packetformats.c dataformats.c hlrdata.c srandomdev.c simulate.c batman.c
|
||||
OBJS= dna.o server.o client.o peers.o ciphers.o responses.o packetformats.o dataformats.o \
|
||||
hlrdata.o srandomdev.o simulate.o batman.o overlay.o
|
||||
HDRS= Makefile mphlr.h
|
||||
LDFLAGS= -Xlinker -I/data/data/org.servalproject/lib/ld-linux.so.3 -R/data/data/org.servalproject/lib -Xlinker -rpath=/data/data/org.servalproject/lib
|
||||
LDFLAGS=
|
||||
DEFS= -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DHAVE_LIBC=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STDIO_H=1 -DHAVE_ERRNO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRINGS_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_POLL_H=1 -DHAVE_NETDB_H=1
|
||||
|
||||
all: dna app_serval.so
|
||||
all: dna
|
||||
|
||||
%.o: %.c $(HDRS)
|
||||
$(CC) $(DEFS) -Os -g -Wall -c $<
|
||||
@ -12,14 +12,6 @@ all: dna app_serval.so
|
||||
dna: $(OBJS)
|
||||
$(CC) -Os -g -Wall -o dna $(OBJS) $(LDFLAGS)
|
||||
|
||||
app_serval.so: app_serval.c
|
||||
gcc -DFORASTERISK -c -o app_serval.o -Iasterisk_include app_serval.c
|
||||
gcc -shared -Wl,-soname,app_serval.so.1 -o app_serval.so app_serval.o
|
||||
|
||||
app_serval.c: asterisk_app.c $(CFILES) $(HDRS)
|
||||
cat asterisk_app.c > app_serval.c
|
||||
cat $(CFILES) | grep -v "#include" >> app_serval.c
|
||||
|
||||
testserver: dna
|
||||
clear
|
||||
rm hlr.dat
|
||||
|
@ -1,4 +1,5 @@
|
||||
OBJS= dna.o server.o client.o peers.o ciphers.o responses.o packetformats.o dataformats.o hlrdata.o srandomdev.o simulate.o batman.o
|
||||
OBJS= dna.o server.o client.o peers.o ciphers.o responses.o packetformats.o dataformats.o \
|
||||
hlrdata.o srandomdev.o simulate.o batman.o overlay.o
|
||||
HDRS= Makefile mphlr.h
|
||||
LDFLAGS= @LDFLAGS@
|
||||
DEFS= @DEFS@
|
||||
|
6
batman.c
6
batman.c
@ -25,7 +25,7 @@ struct reachable_peer {
|
||||
unsigned char tq_avg;
|
||||
};
|
||||
|
||||
int readBatmanPeerFile(char *file_path,in_addr_t peers[],int *peer_count,int peer_max)
|
||||
int readBatmanPeerFile(char *file_path,struct in_addr peers[],int *peer_count,int peer_max)
|
||||
{
|
||||
/* Shiny new code to read the flat file containing peer list */
|
||||
FILE *f;
|
||||
@ -72,7 +72,7 @@ int readBatmanPeerFile(char *file_path,in_addr_t peers[],int *peer_count,int pee
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getBatmanPeerList(char *socket_path,in_addr_t peers[],int *peer_count,int peer_max)
|
||||
int getBatmanPeerList(char *socket_path,struct in_addr peers[],int *peer_count,int peer_max)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return -1;
|
||||
@ -177,7 +177,7 @@ int getBatmanPeerList(char *socket_path,in_addr_t peers[],int *peer_count,int pe
|
||||
for(i=0;ofs+i<bytes;i++)
|
||||
if (buf[i+ofs]==' ') {
|
||||
buf[i+ofs]=0;
|
||||
if (*peer_count<peer_max) peers[(*peer_count)++]=inet_addr((char *)&buf[ofs]);
|
||||
if (*peer_count<peer_max) peers[(*peer_count)++].s_addr=inet_addr((char *)&buf[ofs]);
|
||||
if (debug>1) fprintf(stderr,"Found BATMAN peer '%s'\n",&buf[ofs]);
|
||||
buf[ofs+i]=' ';
|
||||
break;
|
||||
|
6
client.c
6
client.c
@ -27,7 +27,7 @@ int packetSendFollowup(struct in_addr destination,
|
||||
|
||||
bzero(&peer_addr, sizeof(peer_addr));
|
||||
peer_addr.sin_family=AF_INET;
|
||||
peer_addr.sin_port = htons(4110);
|
||||
peer_addr.sin_port = htons( PORT_DNA );
|
||||
peer_addr.sin_addr.s_addr=destination.s_addr;
|
||||
|
||||
if (!serverMode) {
|
||||
@ -315,7 +315,7 @@ int getReplyPackets(int method,int peer,int batchP,
|
||||
while(1) {
|
||||
unsigned char buffer[16384];
|
||||
socklen_t recvaddrlen=sizeof(recvaddr);
|
||||
pollfd fds;
|
||||
struct pollfd fds;
|
||||
|
||||
bzero((void *)&recvaddr,sizeof(recvaddr));
|
||||
fds.fd=sock; fds.events=POLLIN; fds.revents=0;
|
||||
@ -467,7 +467,7 @@ int peerAddress(char *did,char *sid,int flags)
|
||||
|
||||
int i;
|
||||
int pc=0;
|
||||
in_addr_t mypeers[256];
|
||||
struct in_addr mypeers[256];
|
||||
int method;
|
||||
|
||||
bzero(&responses,sizeof(responses));
|
||||
|
10
mphlr.h
10
mphlr.h
@ -71,7 +71,9 @@ struct in_addr {
|
||||
//FIXME #include <getopt.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
/* UDP Port numbers for various Serval services */
|
||||
#define PORT_DNA 4110
|
||||
#define PORT_OVERLAY 4119
|
||||
|
||||
/* OpenWRT libc doesn't have bcopy, but has memmove */
|
||||
#define bcopy(A,B,C) memmove(B,A,C)
|
||||
@ -111,7 +113,7 @@ extern int client_port;
|
||||
|
||||
#define MAX_PEERS 1024
|
||||
extern int peer_count;
|
||||
extern in_addr_t peers[MAX_PEERS];
|
||||
extern struct in_addr peers[MAX_PEERS];
|
||||
|
||||
struct mphlr_variable {
|
||||
unsigned char id;
|
||||
@ -330,8 +332,8 @@ int clearResponses(struct response_set *responses);
|
||||
int responseFromPeerP(struct response_set *responses,int peerId);
|
||||
int responseFromPeer(struct response_set *responses,int peerId);
|
||||
int additionalPeer(char *peer);
|
||||
int readBatmanPeerFile(char *file_path,in_addr_t peers[],int *peer_count,int peer_max);
|
||||
int getBatmanPeerList(char *socket_path,in_addr_t peers[],int *peer_count,int peer_max);
|
||||
int readBatmanPeerFile(char *file_path,struct in_addr peers[],int *peer_count,int peer_max);
|
||||
int getBatmanPeerList(char *socket_path,struct in_addr peers[],int *peer_count,int peer_max);
|
||||
int hlrDump(unsigned char *hlr,int hofs);
|
||||
int peerAddress(char *did,char *sid,int flags);
|
||||
int fixResponses(struct response_set *responses);
|
||||
|
6
peers.c
6
peers.c
@ -23,15 +23,15 @@ char *batman_socket=NULL;
|
||||
char *batman_peerfile="/data/data/org.servalproject/var/batmand.peers";
|
||||
|
||||
int peer_count=0;
|
||||
in_addr_t peers[MAX_PEERS];
|
||||
struct in_addr peers[MAX_PEERS];
|
||||
unsigned char peer_replied[MAX_PEERS];
|
||||
|
||||
in_addr_t nominated_peers[256];
|
||||
struct in_addr nominated_peers[256];
|
||||
int nom_peer_count=0;
|
||||
|
||||
int additionalPeer(char *peer)
|
||||
{
|
||||
in_addr_t pa;
|
||||
struct in_addr pa;
|
||||
|
||||
if (nom_peer_count>255) return setReason("Too many peers. You can only nominate 255 peers in this version.");
|
||||
|
||||
|
8
server.c
8
server.c
@ -85,10 +85,10 @@ int server(char *backing_file,int size,int foregroundMode)
|
||||
}
|
||||
|
||||
bind_addr.sin_family = AF_INET;
|
||||
bind_addr.sin_port = htons( 4110 );
|
||||
bind_addr.sin_port = htons( PORT_DNA );
|
||||
bind_addr.sin_addr.s_addr = htonl( INADDR_ANY );
|
||||
if(bind(sock,(struct sockaddr *)&bind_addr,sizeof(bind_addr))) {
|
||||
fprintf(stderr,"MP HLR server could not bind to UDP port 4110\n");
|
||||
fprintf(stderr,"MP HLR server could not bind to UDP port %d\n", PORT_DNA);
|
||||
perror("bind");
|
||||
exit(-3);
|
||||
}
|
||||
@ -99,8 +99,8 @@ int server(char *backing_file,int size,int foregroundMode)
|
||||
while(1) {
|
||||
unsigned char buffer[16384];
|
||||
socklen_t recvaddrlen=sizeof(recvaddr);
|
||||
pollfd fds;
|
||||
int len;
|
||||
struct pollfd fds;
|
||||
int len;
|
||||
|
||||
bzero((void *)&recvaddr,sizeof(recvaddr));
|
||||
fds.fd=sock; fds.events=POLLIN;
|
||||
|
Loading…
x
Reference in New Issue
Block a user