mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-21 17:56:47 +00:00
Don't include rhizome adverts in packets with voice frames
This commit is contained in:
parent
8dd7a81c71
commit
a4b392d693
@ -59,6 +59,7 @@ struct outgoing_packet{
|
||||
overlay_interface *interface;
|
||||
int i;
|
||||
int unicast;
|
||||
int add_advertisements;
|
||||
struct sockaddr_in dest;
|
||||
struct overlay_buffer *buffer;
|
||||
};
|
||||
@ -996,6 +997,7 @@ overlay_init_packet(struct outgoing_packet *packet, overlay_interface *interface
|
||||
packet->i = (interface - overlay_interfaces);
|
||||
packet->dest=interface->broadcast_address;
|
||||
packet->buffer=ob_new();
|
||||
packet->add_advertisements=1;
|
||||
ob_limitsize(packet->buffer, packet->interface->mtu);
|
||||
ob_append_bytes(packet->buffer,magic_header,4);
|
||||
|
||||
@ -1168,6 +1170,10 @@ overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, tim
|
||||
// payload was not queued
|
||||
goto skip;
|
||||
|
||||
// don't send rhizome adverts if the packet contains a voice payload
|
||||
if (frame->queue==OQ_ISOCHRONOUS_VOICE)
|
||||
packet->add_advertisements=0;
|
||||
|
||||
// mark the payload as sent
|
||||
int keep_payload = 0;
|
||||
|
||||
@ -1226,7 +1232,8 @@ overlay_fill_send_packet(struct outgoing_packet *packet, time_ms_t now) {
|
||||
// send the packet
|
||||
if (packet->buffer->position>=HEADERFIELDS_LEN){
|
||||
// stuff rhizome announcements at the last moment
|
||||
overlay_rhizome_add_advertisements(packet->i,packet->buffer);
|
||||
if (packet->add_advertisements)
|
||||
overlay_rhizome_add_advertisements(packet->i,packet->buffer);
|
||||
|
||||
if (debug&DEBUG_PACKETCONSTRUCTION)
|
||||
dump("assembled packet",&packet->buffer->bytes[0],packet->buffer->position);
|
||||
|
@ -137,29 +137,17 @@ int bundle_offset[2]={0,0};
|
||||
int overlay_rhizome_add_advertisements(int interface_number, struct overlay_buffer *e)
|
||||
{
|
||||
IN();
|
||||
int voice_mode=0;
|
||||
|
||||
/* behave differently during voice mode.
|
||||
Basically don't encourage people to grab stuff from us, but keep
|
||||
just enough activity going so that it is possible to send a (small)
|
||||
message/file during a call.
|
||||
|
||||
XXX Eventually only advertise small/recently changed files during voice calls.
|
||||
We need to change manifest table to include payload length to make our life
|
||||
/* We need to change manifest table to include payload length to make our life
|
||||
easy here (also would let us order advertisements by size of payload).
|
||||
For now, we will just advertised only occassionally.
|
||||
|
||||
XXX Actually, we will move all processing of Rhizome into a separate process
|
||||
XXX We will move all processing of Rhizome into a separate process
|
||||
so that the CPU delays caused by Rhizome verifying signatures isn't a problem.
|
||||
We will still want to limit network usage during calls, however.
|
||||
*/
|
||||
if (!rhizome_http_server_running() || !rhizome_db)
|
||||
RETURN(0);
|
||||
|
||||
time_ms_t now = gettime_ms();
|
||||
if (now<rhizome_voice_timeout) voice_mode=1;
|
||||
if (voice_mode) if (random()&3) { RETURN(0); }
|
||||
|
||||
int pass;
|
||||
int bytes=e->sizeLimit-e->position;
|
||||
int overhead=1+11+1+2+2; /* maximum overhead */
|
||||
|
Loading…
x
Reference in New Issue
Block a user