11 int ngadmin_getPortsStatus (struct ngadmin *nga, unsigned char *ports)
17 struct attr_port_status *ps;
20 if (nga == NULL || ports == NULL)
22 else if (nga->current == NULL)
26 attr = createEmptyList();
27 pushBackList(attr, newEmptyAttr(ATTR_PORT_STATUS));
28 ret = readRequest(nga, attr);
32 filterAttributes(attr, ATTR_PORT_STATUS, ATTR_END);
34 memset(ports, SPEED_UNK, nga->current->ports);
36 for (ln = attr->first; ln != NULL; ln = ln->next) {
39 ports[ps->port - 1] = ps->status;
43 destroyList(attr, (void(*)(void*))freeAttr);
51 int ngadmin_getPortsStatistics (struct ngadmin *nga, struct port_stats *ps)
57 struct attr_port_stat *aps;
60 if (nga == NULL || ps == NULL)
62 else if (nga->current == NULL)
65 attr = createEmptyList();
66 pushBackList(attr, newEmptyAttr(ATTR_PORT_STATISTICS));
67 ret = readRequest(nga, attr);
71 filterAttributes(attr, ATTR_PORT_STATISTICS, ATTR_END);
73 memset(ps, 0, nga->current->ports * sizeof(struct port_stats));
75 for (ln = attr->first; ln != NULL; ln = ln->next) {
78 ps[aps->port -1].recv = aps->recv;
79 ps[aps->port -1].sent = aps->sent;
80 ps[aps->port -1].crc = aps->crc;
84 destroyList(attr, (void(*)(void*))freeAttr);
91 int ngadmin_resetPortsStatistics (struct ngadmin *nga)
96 attr = createEmptyList();
97 pushBackList(attr, newByteAttr(ATTR_STATS_RESET, 1));
100 return writeRequest(nga, attr);
105 int ngadmin_cabletest (struct ngadmin *nga, struct cabletest *ct, int nb)
111 struct attr_cabletest_do *acd;
112 struct attr_cabletest_result *acr;
115 if (nga == NULL || ct == NULL)
117 else if (nga->current == NULL)
121 attr = createEmptyList();
123 for (i = 0; i < nb; i++) {
125 acd = malloc(sizeof(struct attr_cabletest_do));
128 acd->port = ct[i].port;
130 pushBackList(attr, newAttr(ATTR_CABLETEST_DO, sizeof(struct attr_cabletest_do), acd));
132 ret = writeRequest(nga, attr);
137 /* the list is destroyed by writeRequest, so we need to recreate it */
138 attr = createEmptyList();
139 pushBackList(attr, newByteAttr(ATTR_CABLETEST_RESULT, ct[i].port));
140 ret = readRequest(nga, attr);
144 filterAttributes(attr, ATTR_CABLETEST_RESULT, ATTR_END);
146 for (ln = attr->first; ln != NULL; ln = ln->next) {
149 if (at->size == sizeof(struct attr_cabletest_result) && acr->port == ct[i].port) {
156 /* just empty the list, it will be used at next iteration */
157 clearList(attr, (void(*)(void*))freeAttr);
162 destroyList(attr, (void(*)(void*))freeAttr);