5 #include <nsdp/protocol.h>
11 int ngadmin_getIGMPConf (struct ngadmin *nga, struct igmp_conf *ic)
16 struct attr_igmp_vlan *aiv;
19 if (nga == NULL || ic == NULL)
21 else if (nga->current == NULL)
29 Apparently, read-querying these attributes at the same time causes the switch to reply garbage.
30 Here we are forced to do like the official win app and send a separate request for each attribute.
34 attr = createEmptyList();
35 memset(ic, 0, sizeof(struct igmp_conf));
38 pushBackList(attr, newEmptyAttr(ATTR_IGMP_ENABLE_VLAN));
39 ret = readRequest(nga, attr);
43 filterAttributes(attr, ATTR_IGMP_ENABLE_VLAN, ATTR_END);
45 if (attr->first != NULL) {
46 at = attr->first->data;
48 ic->enable = aiv->enable;
52 clearList(attr, (void(*)(void*))freeAttr);
55 pushBackList(attr, newEmptyAttr(ATTR_IGMP_BLOCK_UNK));
56 ret = readRequest(nga, attr);
60 filterAttributes(attr, ATTR_IGMP_BLOCK_UNK, ATTR_END);
62 if (attr->first != NULL) {
63 at = attr->first->data;
64 ic->block = *(char*)at->data;
67 clearList(attr, (void(*)(void*))freeAttr);
70 pushBackList(attr, newEmptyAttr(ATTR_IGMP_VALID_V3));
71 ret = readRequest(nga, attr);
75 filterAttributes(attr, ATTR_IGMP_VALID_V3, ATTR_END);
77 if (attr->first != NULL) {
78 at = attr->first->data;
79 ic->validate = *(char*)at->data;
84 destroyList(attr, (void(*)(void*))freeAttr);
91 int ngadmin_setIGMPConf (struct ngadmin *nga, const struct igmp_conf *ic)
94 struct attr_igmp_vlan *aiv;
97 if (nga == NULL || ic == NULL)
99 else if (nga->current == NULL)
103 aiv = malloc(sizeof(struct attr_igmp_vlan));
106 aiv->enable = ic->enable;
107 aiv->vlan = ic->vlan;
110 attr = createEmptyList();
111 pushBackList(attr, newAttr(ATTR_IGMP_ENABLE_VLAN, sizeof(struct attr_igmp_vlan), aiv));
112 pushBackList(attr, newByteAttr(ATTR_IGMP_BLOCK_UNK, ic->block != false));
113 pushBackList(attr, newByteAttr(ATTR_IGMP_VALID_V3, ic->validate != false));
116 return writeRequest(nga, attr);
120 int ngadmin_setNetConf (struct ngadmin *nga, const struct net_conf *nc)
127 if (nga == NULL || nc == NULL)
135 attr = createEmptyList();
138 pushBackList(attr, newShortAttr(ATTR_DHCP, 1));
140 pushBackList(attr, newShortAttr(ATTR_DHCP, 0));
141 /* only add non-null values */
142 if (nc->ip.s_addr != 0)
143 pushBackList(attr, newAddrAttr(ATTR_IP, nc->ip));
144 if (nc->netmask.s_addr != 0)
145 pushBackList(attr, newAddrAttr(ATTR_NETMASK, nc->netmask));
146 if (nc->gw.s_addr != 0)
147 pushBackList(attr, newAddrAttr(ATTR_GATEWAY, nc->gw));
150 ret = writeRequest(nga, attr);
155 /* update local values */
156 sa->nc.dhcp = nc->dhcp;
158 if (nc->ip.s_addr !=0)
160 if (nc->netmask.s_addr != 0)
161 sa->nc.netmask = nc->netmask;
162 if (nc->gw.s_addr != 0)