}
-void extractSwitchAttributes (struct swi_attr *sa, const List *l)
+int extractSwitchAttributes (struct swi_attr *sa, const List *l)
{
const ListNode *ln;
const struct attr *at;
for (ln = l->first; ln != NULL; ln = ln->next) {
at = ln->data;
+ if (at->size == 0)
+ return -EMSGSIZE;
switch (at->attr) {
break;
case ATTR_DHCP:
- sa->nc.dhcp = (ntohs(*(unsigned short*)at->data) == 1);
+ /* 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
+ */
+ sa->nc.dhcp = (at->size == 2) && ((*(unsigned short*)at->data) == 1);
break;
case ATTR_FIRM_VER:
break;
case ATTR_END:
- return;
+ return 0;
}
}
+
+
+ return 0;
}