mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
fixed packet size calculation bug.
This commit is contained in:
parent
74634a5068
commit
171eb75d48
@ -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<zero;j++) fprintf(stderr," %02x",bytes[j]);
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_node_info(int argc, const char *const *argv, struct command_line_option *o)
|
||||
{
|
||||
const char *sid;
|
||||
@ -1412,6 +1433,8 @@ command_line_option command_line_options[]={
|
||||
"Return identity of known peers as SIDs"},
|
||||
{app_node_info,{"node","info","<sid>","[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"},
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user