X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=raw%2Fsrc%2Fencoding.c;h=0d8e889977711b5b1534bfb83fc1267941e27847;hb=9e16b606f328f17800a1dab563a191555182fe32;hp=5ac97d85be724b5fcce8f1e27632c78816c539d6;hpb=16cbdbc11750bc2f42fe44ee750228db657afbeb;p=ngadmin diff --git a/raw/src/encoding.c b/raw/src/encoding.c index 5ac97d8..0d8e889 100644 --- a/raw/src/encoding.c +++ b/raw/src/encoding.c @@ -3,7 +3,7 @@ #include #include -#include "encoding.h" +#include #include "encoding_attr.h" @@ -24,7 +24,7 @@ void initNsdpHeader (struct nsdp_header *nh, const struct nsdp_cmd *nc) } -bool validateNsdpHeader (const struct nsdp_header *nh, const struct nsdp_cmd *nc) +bool extractNsdpHeader (const struct nsdp_header *nh, struct nsdp_cmd *nc) { unsigned int i; @@ -34,6 +34,10 @@ bool validateNsdpHeader (const struct nsdp_header *nh, const struct nsdp_cmd *nc if (nc->code > 0 && nh->code != nc->code) return false; + nc->code = nh->code; + + nc->error = nh->error; + nc->attr_error = ntohs(nh->attr); if (nh->unk1 != 0) return false; @@ -44,13 +48,16 @@ bool validateNsdpHeader (const struct nsdp_header *nh, const struct nsdp_cmd *nc for (i = 0; i < ETH_ALEN && nc->client_mac.ether_addr_octet[i] == 0; i++); if (i < ETH_ALEN && memcmp(nh->client_mac, &nc->client_mac, ETH_ALEN) != 0) return false; + memcpy(&nc->client_mac, nh->client_mac, ETH_ALEN); for (i = 0; i < ETH_ALEN && nc->switch_mac.ether_addr_octet[i] == 0; i++); if (i < ETH_ALEN && memcmp(nh->switch_mac, &nc->switch_mac, ETH_ALEN) != 0) return false; + memcpy(&nc->switch_mac, nh->switch_mac, ETH_ALEN); if (nc->seqnum > 0 && ntohl(nh->seqnum) != nc->seqnum) return false; + nc->seqnum = ntohl(nh->seqnum); if (memcmp(nh->proto_id, NSDP_PROTOID, 4) != 0) return false;