mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-21 01:42:18 +00:00
Fixed issues with recognition of valid packet formats.
This commit is contained in:
parent
f0d5cd172e
commit
0868e30caa
@ -299,7 +299,7 @@ int overlay_rx_messages()
|
||||
bzero(&transaction_id[0],8);
|
||||
bzero(&src_addr,sizeof(src_addr));
|
||||
if ((packet[0]==0x01)&&!(packet[1]|packet[2]|packet[3]))
|
||||
{ if (!packetOk(i,&packet[128],plen,transaction_id,&src_addr,addrlen,1)) WHY("Malformed or unsupported packet from dummy interface (packetOK() failed)"); }
|
||||
{ if (packetOk(i,&packet[128],plen,transaction_id,&src_addr,addrlen,1)) WHY("Malformed or unsupported packet from dummy interface (packetOK() failed)"); }
|
||||
else WHY("Invalid packet version in dummy interface");
|
||||
}
|
||||
else { c[i]=0; count--; }
|
||||
@ -311,7 +311,7 @@ int overlay_rx_messages()
|
||||
/* We have a frame from this interface */
|
||||
if (debug&4)fprintf(stderr,"Received %d bytes on interface #%d\n",plen,i);
|
||||
|
||||
if (!packetOk(i,packet,plen,NULL,&src_addr,addrlen,1)) WHY("Malformed packet");
|
||||
if (packetOk(i,packet,plen,NULL,&src_addr,addrlen,1)) WHY("Malformed packet");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ int packetOkOverlay(int interface,unsigned char *packet,int len,unsigned char *t
|
||||
WHY("negative residual byte count after extracting addresses from frame header");
|
||||
if (debug>3) fprintf(stderr,"f.rfs=%d, offset=%d, ofs=%d\n",
|
||||
f.rfs,offset,ofs);
|
||||
exit(1);
|
||||
return WHY("negative residual byte count after extracting addresses from frame header");
|
||||
}
|
||||
|
||||
/* Finally process the frame */
|
||||
@ -182,7 +182,7 @@ int packetOkOverlay(int interface,unsigned char *packet,int len,unsigned char *t
|
||||
ofs+=f.rfs;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int overlay_frame_resolve_addresses(int interface,overlay_frame *f)
|
||||
|
@ -63,7 +63,9 @@ int packetOk(int interface,unsigned char *packet,int len,unsigned char *transact
|
||||
if (len<HEADERFIELDS_LEN) return setReason("Packet is too short");
|
||||
|
||||
if (packet[0]==0x41&&packet[1]==0x10)
|
||||
return packetOkDNA(packet,len,transaction_id,recvaddr,recvaddrlen,parseP);
|
||||
{
|
||||
return packetOkDNA(packet,len,transaction_id,recvaddr,recvaddrlen,parseP);
|
||||
}
|
||||
|
||||
if (packet[0]==0x4F&&packet[1]==0x10)
|
||||
{
|
||||
|
13
server.c
13
server.c
@ -427,7 +427,7 @@ int processRequest(unsigned char *packet,int len,
|
||||
setReason("Asked to perform unsupported action");
|
||||
if (debug) fprintf(stderr,"Packet offset = 0x%x\n",pofs);
|
||||
if (debug) dump("Packet",packet,len);
|
||||
return -1;
|
||||
return WHY("Asked to perform unsupported action.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -449,7 +449,7 @@ int respondSimple(char *sid,int action,unsigned char *action_text,int action_len
|
||||
/* XXX Complain about invalid crypto flags.
|
||||
XXX We don't do anything with the crypto flags right now
|
||||
XXX Other packet sending routines need this as well. */
|
||||
if (!cryptoFlags) return -1;
|
||||
if (!cryptoFlags) return WHY("Crypto-flags not set.");
|
||||
|
||||
/* ACTION_ERROR is associated with an error message.
|
||||
For syntactic simplicity, we do not require the respondSimple() call to provide
|
||||
@ -462,7 +462,8 @@ int respondSimple(char *sid,int action,unsigned char *action_text,int action_len
|
||||
}
|
||||
|
||||
/* Prepare the request packet */
|
||||
if (packetMakeHeader(packet,8000,packet_len,transaction_id,cryptoFlags)) return -1;
|
||||
if (packetMakeHeader(packet,8000,packet_len,transaction_id,cryptoFlags))
|
||||
return WHY("packetMakeHeader() failed.");
|
||||
if (sid&&sid[0])
|
||||
{ if (packetSetSid(packet,8000,packet_len,sid))
|
||||
return setReason("invalid SID in reply"); }
|
||||
@ -477,11 +478,13 @@ int respondSimple(char *sid,int action,unsigned char *action_text,int action_len
|
||||
|
||||
if (debug>2) dump("Simple response octets",action_text,action_len);
|
||||
|
||||
if (packetFinalise(packet,8000,packet_len,cryptoFlags)) return -1;
|
||||
if (packetFinalise(packet,8000,packet_len,cryptoFlags))
|
||||
return WHY("packetFinalise() failed.");
|
||||
|
||||
if (debug) fprintf(stderr,"Sending response of %d bytes.\n",*packet_len);
|
||||
|
||||
if (packetSendRequest(REQ_REPLY,packet,*packet_len,NONBATCH,transaction_id,recvaddr,NULL)) return -1;
|
||||
if (packetSendRequest(REQ_REPLY,packet,*packet_len,NONBATCH,transaction_id,recvaddr,NULL))
|
||||
return WHY("packetSendRequest() failed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user