5 #include <nsdp/protocol.h>
11 int ngadmin_getMirror (struct ngadmin *nga, char *ports)
17 struct attr_mirror *am;
20 if (nga == NULL || ports == NULL)
28 attr = createEmptyList();
29 pushBackList(attr, newEmptyAttr(ATTR_MIRROR));
30 ret = readRequest(nga, attr);
34 filterAttributes(attr, ATTR_MIRROR, ATTR_END);
36 memset(ports, 0, 1 + sa->ports);
38 if (attr->first != NULL) {
39 at = attr->first->data;
42 if (am->outport == 0) {
43 memset(ports, 0, 1 + sa->ports);
44 } else if (am->outport > 0 && at->size >= 1 + sa->ports) {
45 if (at->size < sizeof(struct attr_mirror) + sa->ports) {
49 ports[0] = am->outport;
50 memcpy(ports + 1, am->ports, sa->ports);
56 destroyList(attr, (void(*)(void*))freeAttr);
63 int ngadmin_setMirror (struct ngadmin *nga, const char *ports)
67 struct attr_mirror *am;
78 am = malloc(sizeof(struct attr_mirror) + sa->ports);
85 am->outport = ports[0];
86 memcpy(am->ports, ports + 1, sa->ports);
89 attr = createEmptyList();
90 pushBackList(attr, newAttr(ATTR_MIRROR, sizeof(struct attr_mirror) + sa->ports, am));
93 return writeRequest(nga, attr);