X-Git-Url: https://git.sur5r.net/?p=ngadmin;a=blobdiff_plain;f=lib%2Fsrc%2Fprotocol.c;h=5f99da233e1130829cfce63216d6c4bb75ee8aa9;hp=61dd6faddc76e4496b170f373287c080ed0ca054;hb=25c375ef21fa0c0d46b6d7a45acd4d613f1fe907;hpb=da3d6caa844822281a009356a36e936e26795bf6 diff --git a/lib/src/protocol.c b/lib/src/protocol.c index 61dd6fa..5f99da2 100644 --- a/lib/src/protocol.c +++ b/lib/src/protocol.c @@ -4,12 +4,6 @@ - -const struct ether_addr nullMac={.ether_addr_octet={0, 0, 0, 0, 0, 0}}; - - - - // ---------------------------- int trim (char *txt, int start) { @@ -43,7 +37,7 @@ void initNgHeader (struct ng_header *nh, char code, const struct ether_addr *cli memset(nh, 0, sizeof(struct ng_header)); - nh->unk1=1; + nh->version=1; nh->code=code; memcpy(nh->client_mac, client_mac, ETH_ALEN); @@ -64,7 +58,7 @@ void initNgHeader (struct ng_header *nh, char code, const struct ether_addr *cli bool validateNgHeader (const struct ng_header *nh, char code, const struct ether_addr *client_mac, const struct ether_addr *switch_mac, unsigned int seqnum) { - if ( nh->unk1!=1 ) { + if ( nh->version!=1 ) { return false; } @@ -72,6 +66,10 @@ bool validateNgHeader (const struct ng_header *nh, char code, const struct ether return false; } + if ( nh->unk1!=0 ) { + return false; + } + if ( *(unsigned short*)nh->unk2!=0 ) { return false; } @@ -257,13 +255,13 @@ void freeAttr (struct attr *at) { -// --------------------------------------------------------------------------------------------------------------- -void extractPacketAttributes (struct ng_packet *np, unsigned short *error, unsigned short *attr_error, List *attr) { +// -------------------------------------------------------------------------------------------------------------- +void extractPacketAttributes (struct ng_packet *np, unsigned char *error, unsigned short *attr_error, List *attr) { struct attr *at; - if ( error!=NULL ) *error=ntohs(np->nh->error); + if ( error!=NULL ) *error=np->nh->error; if ( attr_error!=NULL ) *attr_error=ntohs(np->nh->attr); while ( getPacketTotalSize(np)maxlen ) {