- while (1) {
-
- FD_ZERO(&fs);
- FD_SET(nga->sock, &fs);
- select(nga->sock+1, &fs, NULL, NULL, &rem); /* FIXME: non portable */
-
- len = recvfrom(nga->sock, buffer, sizeof(buffer), MSG_DONTWAIT, (struct sockaddr*)&remote, &slen);
-
- if (len < 0)
- break;
-
- np.maxlen = len;
- initNgPacket(&np);
-
- if (ntohs(remote.sin_port) != SWITCH_PORT ||
- len < (int)sizeof(struct ng_header) ||
- !validateNgHeader(np.nh, code, &nga->localmac, sa == NULL ? NULL : &sa->mac, nga->seq) ||
- extractPacketAttributes(&np, attr, sa == NULL ? 0 : sa->ports) < 0)
- continue;
-
- if (error != NULL)
- *error = np.nh->error;
- if (attr_error != NULL)
- *attr_error = ntohs(np.nh->attr);
-
- len = 0;
- break;
- }
+ memset(nc, 0, sizeof(struct nsdp_cmd));
+ memcpy(&nc->client_mac, &nga->localmac, ETH_ALEN);
+ nc->remote_addr.sin_family = AF_INET;
+ nc->remote_addr.sin_port = htons(SWITCH_PORT);
+ if (sa != NULL)
+ memcpy(&nc->switch_mac, &sa->mac, ETH_ALEN);