More little fixes, especially initialising of overlay_buffers in

overlay_payload structures.
This commit is contained in:
gardners 2011-09-05 12:34:54 +09:30
parent cbb1939241
commit 37c0955494
5 changed files with 33 additions and 24 deletions

15
mphlr.h
View File

@ -566,12 +566,14 @@ typedef struct overlay_txqueue {
*/
} overlay_txqueue;
extern overlay_txqueue overlay_tx[5];
#define OVERLAY_ISOCHRONOUS_VOICE 0
#define OVERLAY_MESH_MANAGEMENT 1
#define OVERLAY_ISOCHRONOUS_VIDEO 2
#define OVERLAY_ORDINARY 3
#define OVERLAY_OPPORTUNISTIC 4
#define OQ_ISOCHRONOUS_VOICE 0
#define OQ_MESH_MANAGEMENT 1
#define OQ_ISOCHRONOUS_VIDEO 2
#define OQ_ORDINARY 3
#define OQ_OPPORTUNISTIC 4
#define OQ_MAX 5
extern overlay_txqueue overlay_tx[OQ_MAX];
int setReason(char *fmt, ...);
#define WHY(X) setReason("%s:%d:%s() %s",__FILE__,__LINE__,__FUNCTION__,X)
@ -773,4 +775,5 @@ int overlay_frame_set_me_as_source(overlay_frame *f);
int overlay_frame_set_neighbour_as_source(overlay_frame *f,overlay_neighbour *n);
int overlay_update_sequence_number();
int packetEncipher(unsigned char *packet,int maxlen,int *len,int cryptoflags);
int overlayServerMode();

View File

@ -47,7 +47,7 @@
int overlayMode=0;
overlay_txqueue overlay_tx[5];
overlay_txqueue overlay_tx[OQ_MAX];
int overlayServerMode()
{

View File

@ -543,14 +543,14 @@ int overlay_tick_interface(int i, long long now)
overlay_add_selfannouncement(i,e);
/* 2. Add any queued high-priority isochronous data (i.e. voice) to the frame. */
p=&overlay_tx[OVERLAY_ISOCHRONOUS_VOICE].first;
p=&overlay_tx[OQ_ISOCHRONOUS_VOICE].first;
overlay_stuff_packet_from_queue(i,e,p,now,pax,&frame_pax,MAX_FRAME_PAX);
/* 3. Add some mesh reachability reports (unlike BATMAN we announce reachability to peers progressively).
Give priority to newly observed nodes so that good news travels quickly to help roaming.
XXX - Don't forget about PONGing reachability reports to allow use of monodirectional links.
*/
p=&overlay_tx[OVERLAY_MESH_MANAGEMENT].first;
p=&overlay_tx[OQ_MESH_MANAGEMENT].first;
overlay_stuff_packet_from_queue(i,e,p,now,pax,&frame_pax,MAX_FRAME_PAX);
/* 4. XXX Add lower-priority queued data */
@ -566,8 +566,10 @@ int overlay_tick_interface(int i, long long now)
fprintf(stderr,"Successfully transmitted tick frame #%d on interface #%d (%d bytes)\n",
overlay_sequence_number,i,e->length);
/* De-queue the passengers who were aboard. */
int j;
overlay_frame **p=&overlay_tx[OVERLAY_ISOCHRONOUS_VOICE].first;
int j,q;
for(q=0;q<OQ_MAX;q++)
{
overlay_frame **p=&overlay_tx[q].first;
for(j=0;j<frame_pax;j++)
{
/* Skip any frames that didn't get queued */
@ -579,6 +581,7 @@ int overlay_tick_interface(int i, long long now)
if (op_free(pax[j])) WHY("op_free() failed");
}
}
}
return 0;
}
else return WHY("overlay_broadcast_ensemble() failed");

View File

@ -160,7 +160,7 @@ int overlay_frame_set_neighbour_as_source(overlay_frame *f,overlay_neighbour *n)
bcopy(n->sid,f->source,SID_SIZE);
f->source_address_status=OA_RESOLVED;
return WHY("Not implemented");
return 0;
}
unsigned char *overlay_get_my_sid()
@ -180,5 +180,5 @@ int overlay_frame_set_me_as_source(overlay_frame *f)
f->source_address_status=OA_RESOLVED;
return WHY("Not implemented");
return 0;
}

View File

@ -422,6 +422,9 @@ int overlay_route_ack_selfannounce(overlay_frame *f,overlay_neighbour *n)
numbers means we can't just take the highest-numbered sequence number.
So we need to take the observation which was most recently received.
*/
out->payload=ob_new(4+32*2+1); /* will grow if it isn't big enough, but let's try to
avoid a realloc() if possible */
int i;
int best_obs_id=-1;
long long best_obs_time=0;