Renamed mphlr.h to serval.h

(also some temporary debugging has been added in some places)
This commit is contained in:
gardners 2012-02-23 12:45:42 +10:30
parent 309bff0855
commit 1eb4c34015
34 changed files with 55 additions and 35 deletions

View File

@ -14,7 +14,7 @@ OBJS= dna.o server.o client.o peers.o ciphers.o responses.o packetformats.o data
rhizome_packetformats.o rhizome_fetch.o sqlite3.o encode.o sha2.o randombytes.o \
overlay_broadcast.o dna_identity.o commandline.o serval_packetvisualise.o
HDRS= Makefile mphlr.h sqlite-amalgamation-3070900/sqlite3.h sha2.h rhizome.h
HDRS= Makefile serval.h sqlite-amalgamation-3070900/sqlite3.h sha2.h rhizome.h
LDFLAGS= @LDFLAGS@
CFLAGS= @CFLAGS@
@ -29,7 +29,7 @@ dna: $(OBJS)
$(CC) $(CFLAGS) -Os -g -Wall -o dna $(OBJS) $(LDFLAGS)
serval.c: $(SRCS) $(HDRS)
cat mphlr.h > serval.c
cat serval.h > serval.c
echo '#include <sys/mman.h>' >>serval.c
cat $(SRCS) | grep -v "#include" | sed -e 's/inet_ntoa/ast_inet_ntoa/g' >>serval.c

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
struct reachable_peer {
unsigned char addr_len;

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
int current_sid_set=0;
unsigned char current_sid[SID_SIZE];

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
int packetSendFollowup(struct in_addr destination,
unsigned char *packet,int packet_len)

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
typedef struct command_line_option {
int (*function)(int argc,char **argv,struct command_line_option *o);

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
int extractDid(unsigned char *packet,int *ofs,char *did)
{

2
dna.c
View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
#include "rhizome.h"
#include <stdarg.h>
#include <signal.h>

View File

@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
a given party.
*/
#include "mphlr.h"
#include "serval.h"
#include "rhizome.h"
/*

View File

@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
int nyblValue(int c)
{

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
#include <sys/stat.h>
#include <sys/wait.h>

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
int hlrGetRecordLength(unsigned char *hlr,int hofs);

View File

@ -68,7 +68,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
int overlayMode=0;

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
/*
We use 256bit Curve25519 addresses in the overlay mesh. This means we have very large

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
/* List of prioritised advertisements */
#define OVERLAY_MAX_ADVERTISEMENT_REQUESTS 16

View File

@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
since for things like number resolution we are happy to send repeat requests.
*/
#include "mphlr.h"
#include "serval.h"
/* Determine if an address is broadcast */
int overlay_address_is_broadcast(unsigned char *a)

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
overlay_buffer *ob_new(int size)
{
@ -79,6 +79,10 @@ int ob_makespace(overlay_buffer *b,int bytes)
return -1;
}
}
printf("ob_makespace(%p,%d)\n b->bytes=%p,b->length=%d,b->allocSize=%d\n",
b,bytes,b->bytes,b->length,b->allocSize);
if (b->length+bytes>=b->allocSize)
{
int newSize=b->length+bytes;
@ -90,6 +94,8 @@ int ob_makespace(overlay_buffer *b,int bytes)
if (newSize>65536) {
if (newSize&65535) newSize+=65536-(newSize&65535);
}
if (1) printf(" realloc(b->bytes=%p,newSize=%d)\n",
b->bytes,newSize);
unsigned char *r=realloc(b->bytes,newSize);
if (!r) return WHY("realloc() failed");
b->bytes=r;

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
#ifdef HAVE_IFADDRS_H
#include <ifaddrs.h>

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
struct sockaddr_in loopback = {

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
int overlay_payload_verify(overlay_frame *p)
{

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
/*
Here we implement the actual routing algorithm which is heavily based on BATMAN.

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
int process_packet(unsigned char *packet,int len,
int recvttl,struct sockaddr *sender,int sender_len)

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
char *batman_socket=NULL;
char *batman_peerfile=NULL;

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
int clearResponse(struct response **response)
{

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
#include "rhizome.h"
#include <stdlib.h>

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
#include "rhizome.h"
#include <stdlib.h>

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
#include "rhizome.h"
#include <stdlib.h>

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
#include "rhizome.h"
#include <stdlib.h>

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
#include "rhizome.h"
extern int sigPipeFlag;

View File

@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <sys/socket.h>
#include <signal.h>
#include "mphlr.h"
#include "serval.h"
#include "rhizome.h"
/*

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
#include "rhizome.h"
#include <stdlib.h>
@ -87,6 +87,7 @@ int overlay_rhizome_add_advertisements(int interface_number,overlay_buffer *e)
if (!rhizome_db) return WHY("Rhizome not enabled");
dump("buffer (90)",(unsigned char *)e,sizeof(*e));
if (ob_append_byte(e,OF_TYPE_RHIZOME_ADVERT))
return WHY("could not add rhizome bundle advertisement header");
ob_append_byte(e,1); /* TTL */
@ -98,7 +99,9 @@ int overlay_rhizome_add_advertisements(int interface_number,overlay_buffer *e)
ob_append_byte(e,OA_CODE_BROADCAST);
{ int i; for(i=0;i<8;i++) ob_append_byte(e,random()&0xff); } /* BPI for broadcast */
ob_append_byte(e,OA_CODE_PREVIOUS);
dump("buffer (102)",(unsigned char *)e,sizeof(*e));
ob_append_byte(e,OA_CODE_SELF);
dump("buffer (104)",(unsigned char *)e,sizeof(*e));
/* Randomly choose whether to advertise manifests or BARs first. */
int skipmanifests=random()&1;
@ -191,6 +194,7 @@ int overlay_rhizome_add_advertisements(int interface_number,overlay_buffer *e)
int overhead=0;
int frameFull=0;
if (!pass) overhead=2;
dump("buffer (197)",(unsigned char *)e,sizeof(*e));
if (ob_makespace(e,overhead+blob_bytes)) {
if (debug&DEBUG_RHIZOME)
fprintf(stderr,"Stopped cramming %s into Rhizome advertisement frame.\n",
@ -204,6 +208,7 @@ int overlay_rhizome_add_advertisements(int interface_number,overlay_buffer *e)
if (debug&DEBUG_RHIZOME)
fprintf(stderr,"length bytes written at offset 0x%x\n",e->length);
}
dump("buffer (211)",(unsigned char *)e,sizeof(*e));
if (frameFull) {
goto stopStuffing;
}
@ -217,9 +222,16 @@ int overlay_rhizome_add_advertisements(int interface_number,overlay_buffer *e)
}
if (debug&DEBUG_RHIZOME) WHY("Couldn't read from blob");
sqlite3_blob_close(blob);
dump("buffer (225)",(unsigned char *)e,sizeof(*e));
continue;
}
e->length+=overhead+blob_bytes;
dump("buffer (211)",(unsigned char *)e,sizeof(*e));
e->length+=overhead+blob_bytes;
if (e->length>e->allocSize) {
WHY("e->length > e->size");
abort();
}
bytes_used+=overhead+blob_bytes;
bundles_advertised++;
bundle_offset[pass]=sqlite3_column_int64(statement,1);
@ -229,6 +241,8 @@ int overlay_rhizome_add_advertisements(int interface_number,overlay_buffer *e)
}
sqlite3_finalize(statement);
stopStuffing:
dump("buffer (244)",(unsigned char *)e,sizeof(*e));
if (!pass)
{
/* Mark end of whole manifests by writing 0xff, which is more than the MSB

View File

View File

@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <sys/socket.h>
#include <netinet/in.h>
#include "mphlr.h"
#include "serval.h"
unsigned char *hlr=NULL;
int hlr_size=0;

View File

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mphlr.h"
#include "serval.h"
double simulatedBER=0;

View File

@ -55,7 +55,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <unistd.h>
#endif
#include "mphlr.h"
#include "serval.h"
#include <fcntl.h>
#include <stdlib.h>
#include <time.h>