#include <ngadmin.h>
-#include <attr.h>
-#include <protocol.h>
+#include <nsdp/attr.h>
+#include <nsdp/protocol.h>
#include "lib.h"
#include "network.h"
*t = VLAN_DISABLED;
- if (attr->first != NULL) {
- at = attr->first->data;
- *t =(int)*(char*)at->data;
+ if (attr->first == NULL) {
+ ret = ERR_BADREPLY;
+ goto end;
}
-
+ at = attr->first->data;
+ *t =(int)*(char*)at->data;
end:
destroyList(attr, (void(*)(void*))freeAttr);
List *attr;
- if (nga == NULL || t < 1 || t > 4)
+ if (nga == NULL || t < VLAN_DISABLED || t > VLAN_DOT_ADV)
return ERR_INVARG;
else if (nga->current == NULL)
return ERR_NOTLOG;
filterAttributes(attr, ATTR_VLAN_PORT_CONF, ATTR_END);
if (attr->first == NULL) {
- ret = ERR_INVARG;
+ ret = ERR_BADREPLY;
goto end;
}
at = ln->data;
avc = at->data;
- if (at->size != sizeof(struct attr_vlan_conf) + sa->ports) {
- ret = ERR_INVARG;
+ if (at->size < sizeof(struct attr_vlan_conf) + sa->ports) {
+ ret = ERR_BADREPLY;
goto end;
}
filterAttributes(conf_old, ATTR_VLAN_PORT_CONF, ATTR_END);
if (conf_old->first == NULL) {
- ret = ERR_INVARG;
+ ret = ERR_BADREPLY;
goto end;
}
at = ln->data;
avc_old = at->data;
- if (at->size != sizeof(struct attr_vlan_conf) + sa->ports) {
- ret = ERR_INVARG;
+ if (at->size < sizeof(struct attr_vlan_conf) + sa->ports) {
+ ret = ERR_BADREPLY;
free(avc_new);
goto end;
}
filterAttributes(attr, ATTR_VLAN_DOT_CONF, ATTR_END);
if (attr->first == NULL) {
- ret = ERR_INVARG;
+ ret = ERR_BADREPLY;
goto end;
}
at = ln->data;
avc = at->data;
- if (at->size != sizeof(struct attr_vlan_conf) + sa->ports) {
- ret = ERR_INVARG;
+ if (at->size < sizeof(struct attr_vlan_conf) + sa->ports) {
+ ret = ERR_BADREPLY;
goto end;
}
filterAttributes(attr, ATTR_VLAN_DOT_CONF, ATTR_END);
if (attr->first == NULL) {
- ret = ERR_INVARG;
+ ret = ERR_BADREPLY;
goto end;
}
at = ln->data;
avc = at->data;
- if (at->size != sizeof(struct attr_vlan_conf) + sa->ports) {
- ret = ERR_INVARG;
+ if (at->size < sizeof(struct attr_vlan_conf) + sa->ports) {
+ ret = ERR_BADREPLY;
goto end;
}
/* check if the switch is in 802.1Q mode */
if (attr->first == NULL) {
- ret = ERR_INVARG;
+ ret = ERR_BADREPLY;
goto end;
} else {
at = attr->first->data;
- if (at->size != sizeof(struct attr_vlan_conf) + sa->ports) {
- ret = ERR_INVARG;
+ if (at->size < sizeof(struct attr_vlan_conf) + sa->ports) {
+ ret = ERR_BADREPLY;
goto end;
}
}
struct attr *at;
int ret = ERR_OK;
struct attr_pvid *ap;
+ struct swi_attr *sa;
if (nga == NULL || ports == NULL)
return ERR_INVARG;
- else if (nga->current == NULL)
+
+ sa = nga->current;
+ if (sa == NULL)
return ERR_NOTLOG;
filterAttributes(attr, ATTR_VLAN_PVID, ATTR_END);
- memset(ports, 0, nga->current->ports * sizeof(unsigned short));
+ memset(ports, 0, sa->ports * sizeof(unsigned short));
for (ln = attr->first; ln != NULL; ln = ln->next) {
at = ln->data;
ap = at->data;
- ports[ap->port - 1] = ap->vlan;
+ if (ap->port <= sa->ports)
+ ports[ap->port - 1] = ap->vlan;
}