From 171eb75d48dda8ebe9e6c23d7e39ead709b8714b Mon Sep 17 00:00:00 2001 From: gardners Date: Mon, 7 May 2012 16:50:49 +0930 Subject: [PATCH] fixed packet size calculation bug. --- commandline.c | 23 +++++++++++++++++++++++ monitor.c | 4 +++- overlay_buffer.c | 7 +++++-- overlay_mdp.c | 2 +- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/commandline.c b/commandline.c index e25b74aa..e18112e6 100644 --- a/commandline.c +++ b/commandline.c @@ -1231,6 +1231,27 @@ int app_id_self(int argc, const char *const *argv, struct command_line_option *o return 0; } +int app_test_rfs(int argc, const char *const *argv, struct command_line_option *o) +{ + unsigned char bytes[8]; + int i; + + fprintf(stderr,"Testing that RFS coder works properly.\n"); + for(i=0;i<65536;i++) + { + rfs_encode(i,&bytes[0]); + int zero=0; + int r=rfs_decode(&bytes[0],&zero); + if (i!=r) { + fprintf(stderr,"RFS encoding of %d decodes to %d: ",i,r); + int j; + for(j=0;j","[getdid]",NULL},0, "Return information about SID, and optionally ask for DID resolution via network"}, + {app_test_rfs,{"test","rfs",NULL},0, + "Test RFS field calculation"}, #ifdef HAVE_VOIPTEST {app_pa_phone,{"phone",NULL},0, "Run phone test application"}, diff --git a/monitor.c b/monitor.c index 68f86a68..d4eb8be3 100644 --- a/monitor.c +++ b/monitor.c @@ -441,7 +441,9 @@ int monitor_process_data(int index) c->state=MONITOR_STATE_COMMAND; if (vomp_sample_size(c->sample_codec)!=c->data_offset) - return WHY("Ignoring sample block of incorrect size"); + return + WHYF("Ignoring sample block of incorrect size (expected %d, got %d bytes)", + vomp_sample_size(c->sample_codec)!=c->data_offset); fcntl(c->socket,F_SETFL, fcntl(c->socket, F_GETFL, NULL)|O_NONBLOCK); diff --git a/overlay_buffer.c b/overlay_buffer.c index cf66daeb..7c9922dd 100644 --- a/overlay_buffer.c +++ b/overlay_buffer.c @@ -246,8 +246,11 @@ int rfs_encode(int l, unsigned char *b) { if (l<250) { b[0]=l; } else if (l<(255+250+(256*4))) { - b[0]=RFS_PLUS250+(l-250)/256; - b[1]=l-((l-250)/256); + l-=250; + int page=(l>>8); + l&=0xff; + b[0]=RFS_PLUS250+page; + b[1]=l; } else { b[0]=RFS_3BYTE; b[1]=l>>8; diff --git a/overlay_mdp.c b/overlay_mdp.c index 86166066..8440662f 100644 --- a/overlay_mdp.c +++ b/overlay_mdp.c @@ -372,7 +372,7 @@ int overlay_saw_mdp_containing_frame(int interface,overlay_frame *f,long long no } if (crypto_box_curve25519xsalsa20poly1305_open_afternm (plain_block,plain_block,cipher_len+16,nonce,k)) - return WHY("crypto_box_open_afternm() failed (forged or corrupted packet?)"); + return WHYF("crypto_box_open_afternm() failed (forged or corrupted packet of %d bytes)",cipher_len+16); if (0) dump("plain block",&plain_block[zb],cipher_len-16); b=&plain_block[zb]; len=cipher_len-16;