+int ngadmin_getIGMPConf (struct ngadmin *nga, struct igmp_conf *ic)
+{
+ List *attr;
+ struct attr *at;
+ int ret = ERR_OK;
+ struct attr_igmp_vlan *aiv;
+
+
+ if (nga == NULL || ic == NULL)
+ return ERR_INVARG;
+ else if (nga->current == NULL)
+ return ERR_NOTLOG;
+
+ /*
+ ATTR_IGMP_ENABLE_VLAN
+ ATTR_IGMP_BLOCK_UNK
+ ATTR_IGMP_VALID_V3
+
+ Apparently, read-querying these attributes at the same time causes the switch to reply garbage.
+ Here we are forced to do like the official win app and send a separate request for each attribute.
+ */
+
+
+ attr = createEmptyList();
+ memset(ic, 0, sizeof(struct igmp_conf));
+
+
+ pushBackList(attr, newEmptyAttr(ATTR_IGMP_ENABLE_VLAN));
+ ret = readRequest(nga, attr);
+ if (ret < 0)
+ goto end;
+
+ filterAttributes(attr, ATTR_IGMP_ENABLE_VLAN, ATTR_END);
+
+ if (attr->first != NULL) {
+ at = attr->first->data;
+ aiv = at->data;
+ ic->enable = aiv->enable;
+ ic->vlan = aiv->vlan;
+ }
+
+ clearList(attr, (void(*)(void*))freeAttr);
+
+
+ pushBackList(attr, newEmptyAttr(ATTR_IGMP_BLOCK_UNK));
+ ret = readRequest(nga, attr);
+ if (ret < 0)
+ goto end;
+
+ filterAttributes(attr, ATTR_IGMP_BLOCK_UNK, ATTR_END);
+
+ if (attr->first != NULL) {
+ at = attr->first->data;
+ ic->block = *(char*)at->data;
+ }
+
+ clearList(attr, (void(*)(void*))freeAttr);
+
+
+ pushBackList(attr, newEmptyAttr(ATTR_IGMP_VALID_V3));
+ ret = readRequest(nga, attr);
+ if (ret < 0)
+ goto end;
+
+ filterAttributes(attr, ATTR_IGMP_VALID_V3, ATTR_END);
+
+ if (attr->first != NULL) {
+ at = attr->first->data;
+ ic->validate = *(char*)at->data;
+ }
+
+
+end:
+ destroyList(attr, (void(*)(void*))freeAttr);
+
+
+ return ret;
+}
+