From b7281d3c168b12209eb433668dedd55d183ea55b Mon Sep 17 00:00:00 2001 From: darkcoven Date: Fri, 18 Dec 2015 17:49:31 +0100 Subject: [PATCH] lib: fix bug on dhcp setting when switch sends a 1 byte reply --- lib/src/network.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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: -- 2.39.5