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;
46 if (am->outport == 0) {
47 memset(ports, 0, 1 + sa->ports);
48 } else if (am->outport > 0 && at->size >= 1 + sa->ports) {
49 if (at->size < sizeof(struct attr_mirror) + sa->ports) {
53 ports[0] = am->outport;
54 memcpy(ports + 1, am->ports, sa->ports);
60 destroyList(attr, (void(*)(void*))freeAttr);
67 int ngadmin_setMirror (struct ngadmin *nga, const char *ports)
71 struct attr_mirror *am;
82 am = malloc(sizeof(struct attr_mirror) + sa->ports);
89 am->outport = ports[0];
90 memcpy(am->ports, ports + 1, sa->ports);
93 attr = createEmptyList();
94 pushBackList(attr, newAttr(ATTR_MIRROR, sizeof(struct attr_mirror) + sa->ports, am));
97 return writeRequest(nga, attr);