struct attr *at;
int ret = ERR_OK;
struct attr_port_status *ps;
+ struct swi_attr *sa;
if (nga == NULL || ports == NULL)
return ERR_INVARG;
- else if (nga->current == NULL)
- return ERR_NOTLOG;
+ sa = nga->current;
+ if (sa == NULL)
+ return ERR_NOTLOG;
attr = createEmptyList();
pushBackList(attr, newEmptyAttr(ATTR_PORT_STATUS));
filterAttributes(attr, ATTR_PORT_STATUS, ATTR_END);
- memset(ports, SPEED_UNK, nga->current->ports);
+ memset(ports, SPEED_UNK, sa->ports);
for (ln = attr->first; ln != NULL; ln = ln->next) {
at = ln->data;
ps = at->data;
- ports[ps->port - 1] = ps->status;
+ if (ps->port <= sa->ports)
+ ports[ps->port - 1] = ps->status;
}
end:
}
-
int ngadmin_getPortsStatistics (struct ngadmin *nga, struct port_stats *ps)
{
List *attr;
struct attr *at;
int ret = ERR_OK;
struct attr_port_stat *aps;
+ struct swi_attr *sa;
if (nga == NULL || ps == NULL)
return ERR_INVARG;
- else if (nga->current == NULL)
+
+ sa = nga->current;
+ if (sa == NULL)
return ERR_NOTLOG;
attr = createEmptyList();
filterAttributes(attr, ATTR_PORT_STATISTICS, ATTR_END);
- memset(ps, 0, nga->current->ports * sizeof(struct port_stats));
+ memset(ps, 0, sa->ports * sizeof(struct port_stats));
for (ln = attr->first; ln != NULL; ln = ln->next) {
at = ln->data;
aps = at->data;
- ps[aps->port -1].recv = aps->recv;
- ps[aps->port -1].sent = aps->sent;
- ps[aps->port -1].crc = aps->crc;
+ if (aps->port <= sa->ports) {
+ ps[aps->port -1].recv = aps->recv;
+ ps[aps->port -1].sent = aps->sent;
+ ps[aps->port -1].crc = aps->crc;
+ }
}
end:
}
-
int ngadmin_cabletest (struct ngadmin *nga, struct cabletest *ct, int nb)
{
List *attr;