]> git.sur5r.net Git - ngadmin/commitdiff
lib: fix bug on dhcp setting when switch sends a 1 byte reply
authordarkcoven <admin@darkcoven.tk>
Fri, 18 Dec 2015 16:49:31 +0000 (17:49 +0100)
committerdarkcoven <admin@darkcoven.tk>
Fri, 18 Dec 2015 16:49:31 +0000 (17:49 +0100)
lib/src/network.c

index f53b4756d5914a8c05706ffd2eef1cd948ff6db5..eae74965b30aceeafb32027f0d216a3115dea836 100644 (file)
@@ -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: