- rpc = rpc_init_udp_context();
- if (rpc == NULL) {
- return NULL;
- }
-
- if (rpc_bind_udp(rpc, "0.0.0.0", 0) < 0) {
- rpc_destroy_context(rpc);
- return NULL;
- }
-
-
- /* get list of all interfaces */
- size = sizeof(struct ifreq);
- ifc.ifc_buf = NULL;
- ifc.ifc_len = size;
-
- while(ifc.ifc_len > (size - sizeof(struct ifreq))) {
- size *= 2;
-
- free(ifc.ifc_buf);
- ifc.ifc_len = size;
- ifc.ifc_buf = malloc(size);
- memset(ifc.ifc_buf, 0, size);
- if (ioctl(rpc_get_fd(rpc), SIOCGIFCONF, (caddr_t)&ifc) < 0) {
- rpc_destroy_context(rpc);
- free(ifc.ifc_buf);
- return NULL;
- }
- }
-
- for (ptr =(char *)ifc.ifc_buf; ptr < ((char *)ifc.ifc_buf) + ifc.ifc_len; ) {