This commit is contained in:
gonzalef 2020-03-24 18:23:18 +01:00
parent 3a6d034a95
commit 13bc1e327a
2 changed files with 34 additions and 2 deletions

View File

@ -9,8 +9,40 @@ packet listen_for_packets(){
// We need to make sure the TLV announces a length that will no go onto
// another tlv, as we might end up reading bullshit.
int validate_tlvs(union tlv tlv_to_validate){
int validate_tlv(unsigned char *data, int pos){
switch(data[pos]) {
case 0:
break;
case 1:
break;
case 2:
if(data[pos+1] != 0) return 0;
break;
case 3:
if(data[pos+1] != 18) return 0;
break;
case 4:
if(data[pos+1] != 16) return 0;
break;
case 5:
if(data[pos+1] != 0) return 0;
break;
case 6:
if(data[pos+1] != 26) return 0;
break;
case 7:
if(data[pos+1] != 8) return 0;
break;
case 8:
if(data[pos+1] < 26 || data[pos+1] > 218) return 0;
break;
case 9:
break;
default:
return 0;
}
return 1;
}
void work_with_tlvs(struct tlvs_list receivied_tlvs){

View File

@ -46,7 +46,7 @@ void update_neighbours();
void work_with_tlvs();
int validate_tlvs();
int validate_tlv(unsigned char *data, int pos);
// threaded functions