From: darkcoven Date: Fri, 18 Dec 2015 16:49:31 +0000 (+0100) Subject: lib: fix bug on dhcp setting when switch sends a 1 byte reply X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b7281d3c168b12209eb433668dedd55d183ea55b;p=ngadmin lib: fix bug on dhcp setting when switch sends a 1 byte reply --- diff --git a/lib/src/network.c b/lib/src/network.c index f53b475..eae7496 100644 --- a/lib/src/network.c +++ b/lib/src/network.c @@ -371,10 +371,15 @@ int extractSwitchAttributes (struct swi_attr *sa, const List *l) break; case ATTR_DHCP: - /* Note: DHCP attribute is special, it is 2 two bytes long when sent - * by the switch but only 1 byte long when sent by the client + /* Note: DHCP attribute is special, on read request some + * switches send a 2 two bytes attribute and others a + * 1 byte attribute, while all seem to accept a 1 byte + * attribute on write request */ - sa->nc.dhcp = (at->size == 2) && ((*(unsigned short*)at->data) == 1); + if (at->size == 1) + sa->nc.dhcp = ((*(unsigned char*)at->data) == 1); + else if (at->size == 2) + sa->nc.dhcp = ((*(unsigned short*)at->data) == 1); break; case ATTR_FIRM_VER: