Work towards address abbreviation framework.

This commit is contained in:
gardners 2011-08-14 17:58:27 +02:00
parent 0cf6e545c4
commit 9d4666f9d4
3 changed files with 37 additions and 10 deletions

View File

@ -1,12 +1,12 @@
SRCS= dna.c server.c client.c peers.c ciphers.c responses.c packetformats.c dataformats.c \ SRCS= dna.c server.c client.c peers.c ciphers.c responses.c packetformats.c dataformats.c \
hlrdata.c srandomdev.c simulate.c batman.c export.c gateway.c \ hlrdata.c srandomdev.c simulate.c batman.c export.c gateway.c \
overlay.c overlay_buffer.c overlay_interface.c overlay_payload.c overlay_route.c \ overlay.c overlay_buffer.c overlay_interface.c overlay_payload.c overlay_route.c \
overlay_packetformats.c overlay_packetformats.c overlay_abbreviations.c
OBJS= dna.o server.o client.o peers.o ciphers.o responses.o packetformats.o dataformats.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 export.o gateway.o \ hlrdata.o srandomdev.o simulate.o batman.o export.o gateway.o \
overlay.o overlay_buffer.o overlay_interface.o overlay_payload.o overlay_route.o \ overlay.o overlay_buffer.o overlay_interface.o overlay_payload.o overlay_route.o \
overlay_packetformats.o overlay_packetformats.o overlay_abbreviations.o
HDRS= Makefile mphlr.h HDRS= Makefile mphlr.h
LDFLAGS= -L/Developer/SDKs/MacOSX10.6.sdk/usr/lib LDFLAGS= -L/Developer/SDKs/MacOSX10.6.sdk/usr/lib

View File

@ -1,12 +1,12 @@
SRCS= dna.c server.c client.c peers.c ciphers.c responses.c packetformats.c dataformats.c \ SRCS= dna.c server.c client.c peers.c ciphers.c responses.c packetformats.c dataformats.c \
hlrdata.c srandomdev.c simulate.c batman.c export.c gateway.c \ hlrdata.c srandomdev.c simulate.c batman.c export.c gateway.c \
overlay.c overlay_buffer.c overlay_interface.c overlay_payload.c overlay_route.c \ overlay.c overlay_buffer.c overlay_interface.c overlay_payload.c overlay_route.c \
overlay_packetformats.c overlay_packetformats.c overlay_abbreviations.c
OBJS= dna.o server.o client.o peers.o ciphers.o responses.o packetformats.o dataformats.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 export.o gateway.o \ hlrdata.o srandomdev.o simulate.o batman.o export.o gateway.o \
overlay.o overlay_buffer.o overlay_interface.o overlay_payload.o overlay_route.o \ overlay.o overlay_buffer.o overlay_interface.o overlay_payload.o overlay_route.o \
overlay_packetformats.o overlay_packetformats.o overlay_abbreviations.o
HDRS= Makefile mphlr.h HDRS= Makefile mphlr.h
LDFLAGS= @LDFLAGS@ LDFLAGS= @LDFLAGS@

View File

@ -242,13 +242,15 @@ int overlay_rx_messages()
lseek(overlay_interfaces[i].fd,overlay_interfaces[i].offset,SEEK_SET); lseek(overlay_interfaces[i].fd,overlay_interfaces[i].offset,SEEK_SET);
if (debug&4) fprintf(stderr,"Reading from interface log at offset %d, end of file at %lld.\n", if (debug&4) fprintf(stderr,"Reading from interface log at offset %d, end of file at %lld.\n",
overlay_interfaces[i].offset,length); overlay_interfaces[i].offset,length);
if (read(overlay_interfaces[i].fd,packet,overlay_interfaces[i].mtu)==overlay_interfaces[i].mtu) if (read(overlay_interfaces[i].fd,packet,2048)==2048)
{ {
overlay_interfaces[i].offset+=overlay_interfaces[i].mtu; overlay_interfaces[i].offset+=2048;
plen=overlay_interfaces[i].mtu; plen=2048-128;
bzero(&transaction_id[0],8); bzero(&transaction_id[0],8);
bzero(&src_addr,sizeof(src_addr)); bzero(&src_addr,sizeof(src_addr));
if (!packetOk(packet,plen,transaction_id,&src_addr,addrlen,1)) WHY("Malformed packet from dummy interface"); if ((packet[0]==0x01)&&!(packet[1]|packet[2]|packet[3]))
{ if (!packetOk(&packet[128],plen,transaction_id,&src_addr,addrlen,1)) WHY("Malformed packet from dummy interface"); }
else WHY("Invalid packet version in dummy interface");
} }
else { c[i]=0; count--; } else { c[i]=0; count--; }
} else { } else {
@ -298,8 +300,33 @@ int overlay_broadcast_ensemble(int interface_number,unsigned char *bytes,int len
if (overlay_interfaces[interface_number].fileP) if (overlay_interfaces[interface_number].fileP)
{ {
if (write(overlay_interfaces[interface_number].fd,bytes,overlay_interfaces[interface_number].mtu) char buf[2048];
!=overlay_interfaces[interface_number].mtu) /* Version information */
buf[0]=1; buf[1]=0;
buf[2]=0; buf[3]=0;
/* bytes 4-5 = half-power beam height (uint16) */
/* bytes 6-7 = half-power beam width (uint16) */
/* bytes 8-11 = range in metres, centre beam (uint32) */
/* bytes 16-47 = sender */
/* bytes 48-79 = next hop */
/* bytes 80-83 = latitude (uint32) */
/* bytes 84-87 = longitude (uint32) */
/* bytes 88-89 = X/Z direction (uint16) */
/* bytes 90-91 = Y direction (uint16) */
/* bytes 92-93 = speed in metres per second (uint16) */
/* bytes 94-97 = TX frequency in Hz, uncorrected for doppler (which must be done at the receiving end to take into account
relative motion) */
/* bytes 98-109 = coding method (use for doppler response etc) null terminated string */
/* bytes 110-127 reserved for future use */
if (len>2048-128) {
WHY("Truncating long packet to fit within 1920 byte limit for dummy interface");
len=2048-128;
}
bzero(&buf[128+len],2048-(128+len));
bcopy(bytes,&buf[128],len);
if (write(overlay_interfaces[interface_number].fd,buf,2048)!=2048)
{ {
perror("write()"); perror("write()");
return WHY("write() failed"); return WHY("write() failed");