diff --git a/Makefile.in b/Makefile.in index c5a3c1ce..f536d942 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 ' >>serval.c cat $(SRCS) | grep -v "#include" | sed -e 's/inet_ntoa/ast_inet_ntoa/g' >>serval.c diff --git a/batman.c b/batman.c index fbde63d8..34dc284b 100644 --- a/batman.c +++ b/batman.c @@ -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; diff --git a/ciphers.c b/ciphers.c index 0779bead..ec032f09 100644 --- a/ciphers.c +++ b/ciphers.c @@ -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]; diff --git a/client.c b/client.c index 5f83db18..41dbdcc5 100644 --- a/client.c +++ b/client.c @@ -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) diff --git a/commandline.c b/commandline.c index fc657675..6364ec65 100644 --- a/commandline.c +++ b/commandline.c @@ -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); diff --git a/dataformats.c b/dataformats.c index 071a596b..976e9758 100644 --- a/dataformats.c +++ b/dataformats.c @@ -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) { diff --git a/dna.c b/dna.c index 7f484c9e..4789e5fc 100644 --- a/dna.c +++ b/dna.c @@ -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 #include diff --git a/dna_identity.c b/dna_identity.c index 9f8883fd..5174a11e 100644 --- a/dna_identity.c +++ b/dna_identity.c @@ -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" /* diff --git a/export.c b/export.c index e5bb50af..bb37ef13 100644 --- a/export.c +++ b/export.c @@ -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) { diff --git a/gateway.c b/gateway.c index d52095ce..eacb279f 100644 --- a/gateway.c +++ b/gateway.c @@ -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 #include diff --git a/hlrdata.c b/hlrdata.c index 3dd3f0a8..a29e1c52 100644 --- a/hlrdata.c +++ b/hlrdata.c @@ -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); diff --git a/overlay.c b/overlay.c index b1319b26..aa495711 100644 --- a/overlay.c +++ b/overlay.c @@ -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; diff --git a/overlay_abbreviations.c b/overlay_abbreviations.c index a46d9b4e..d1772ba4 100644 --- a/overlay_abbreviations.c +++ b/overlay_abbreviations.c @@ -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 diff --git a/overlay_advertise.c b/overlay_advertise.c index 6d907e65..6b759d3f 100644 --- a/overlay_advertise.c +++ b/overlay_advertise.c @@ -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 diff --git a/overlay_broadcast.c b/overlay_broadcast.c index 1bfd1cce..75224e0a 100644 --- a/overlay_broadcast.c +++ b/overlay_broadcast.c @@ -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) diff --git a/overlay_buffer.c b/overlay_buffer.c index 9055ab6c..1d0959d4 100644 --- a/overlay_buffer.c +++ b/overlay_buffer.c @@ -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; diff --git a/overlay_interface.c b/overlay_interface.c index a009d0ae..ff62aae0 100644 --- a/overlay_interface.c +++ b/overlay_interface.c @@ -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 diff --git a/overlay_packetformats.c b/overlay_packetformats.c index e22b05c4..6b796dfb 100644 --- a/overlay_packetformats.c +++ b/overlay_packetformats.c @@ -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 = { diff --git a/overlay_payload.c b/overlay_payload.c index f9fdedc3..d383a918 100644 --- a/overlay_payload.c +++ b/overlay_payload.c @@ -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) { diff --git a/overlay_route.c b/overlay_route.c index 4c6f5fa6..d6a5678a 100644 --- a/overlay_route.c +++ b/overlay_route.c @@ -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. diff --git a/packetformats.c b/packetformats.c index 00a6f755..575d16db 100644 --- a/packetformats.c +++ b/packetformats.c @@ -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) diff --git a/peers.c b/peers.c index fc1e9066..822c020c 100644 --- a/peers.c +++ b/peers.c @@ -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; diff --git a/responses.c b/responses.c index 440f6602..3f6fb965 100644 --- a/responses.c +++ b/responses.c @@ -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) { diff --git a/rhizome.c b/rhizome.c index e5e8e3b1..df78f5aa 100644 --- a/rhizome.c +++ b/rhizome.c @@ -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 diff --git a/rhizome_bundle.c b/rhizome_bundle.c index 79591502..db41728d 100644 --- a/rhizome_bundle.c +++ b/rhizome_bundle.c @@ -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 diff --git a/rhizome_crypto.c b/rhizome_crypto.c index 8df8f1b6..c4f9c208 100644 --- a/rhizome_crypto.c +++ b/rhizome_crypto.c @@ -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 diff --git a/rhizome_database.c b/rhizome_database.c index 92c81a91..d3099c04 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -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 diff --git a/rhizome_fetch.c b/rhizome_fetch.c index 289ae5ab..0faf054a 100644 --- a/rhizome_fetch.c +++ b/rhizome_fetch.c @@ -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; diff --git a/rhizome_http.c b/rhizome_http.c index 17df0820..581b7e3a 100644 --- a/rhizome_http.c +++ b/rhizome_http.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include -#include "mphlr.h" +#include "serval.h" #include "rhizome.h" /* diff --git a/rhizome_packetformats.c b/rhizome_packetformats.c index 0dad7793..e7d10cb5 100644 --- a/rhizome_packetformats.c +++ b/rhizome_packetformats.c @@ -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 @@ -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 diff --git a/mphlr.h b/serval.h similarity index 100% rename from mphlr.h rename to serval.h diff --git a/server.c b/server.c index 771506bb..070bb707 100644 --- a/server.c +++ b/server.c @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include -#include "mphlr.h" +#include "serval.h" unsigned char *hlr=NULL; int hlr_size=0; diff --git a/simulate.c b/simulate.c index 0bf6c2f7..7a97cd54 100644 --- a/simulate.c +++ b/simulate.c @@ -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; diff --git a/srandomdev.c b/srandomdev.c index 1ed209a4..16c141e5 100644 --- a/srandomdev.c +++ b/srandomdev.c @@ -55,7 +55,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #endif -#include "mphlr.h" +#include "serval.h" #include #include #include