-
-// ----------------------------------------------------------------
-int ngadmin_getIGMPConf (struct ngadmin *nga, struct igmp_conf *ic) {
-
- List *attr;
- ListNode *ln;
- struct attr *at;
- struct swi_attr *sa;
- int ret=ERR_OK;
- unsigned char *p;
- unsigned short *s;
-
-
- if ( nga==NULL || ic==NULL ) {
- return ERR_INVARG;
- } else if ( (sa=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));
- if ( (ret=readRequest(nga, attr))<0 ) {
- goto end;
- }
-
- for (ln=attr->first; ln!=NULL; ln=ln->next) {
- at=ln->data;
- s=at->data;
- if ( at->attr==ATTR_IGMP_ENABLE_VLAN && at->size>=4 ) {
- ic->enable= ntohs(s[0])!=0 ;
- ic->vlan=htons(s[1]);
- break;
- }
- }
-
- clearList(attr, (void(*)(void*))freeAttr);
-
-
- pushBackList(attr, newEmptyAttr(ATTR_IGMP_BLOCK_UNK));
- if ( (ret=readRequest(nga, attr))<0 ) {
- goto end;
- }
-
- for (ln=attr->first; ln!=NULL; ln=ln->next) {
- at=ln->data;
- p=at->data;
- if ( at->attr==ATTR_IGMP_BLOCK_UNK && at->size>=1 ) {
- ic->block= p[0]!=0 ;
- break;
- }
- }
-
- clearList(attr, (void(*)(void*))freeAttr);
-
-
- pushBackList(attr, newEmptyAttr(ATTR_IGMP_VALID_V3));
- if ( (ret=readRequest(nga, attr))<0 ) {
- goto end;
- }
-
- for (ln=attr->first; ln!=NULL; ln=ln->next) {
- at=ln->data;
- p=at->data;
- if ( at->attr==ATTR_IGMP_VALID_V3 && at->size>=1 ) {
- ic->validate= p[0]!=0 ;
- break;
- }
- }
-
-
-
- end:
- destroyList(attr, (void(*)(void*))freeAttr);
-
-
- return ret;
-
+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;