/**************************************************************************** load the list of network interfaces ****************************************************************************/ void load_interfaces(void) { const char **ptr; int i; struct iface_struct ifaces[MAX_INTERFACES]; ptr = lp_interfaces(); allones_ip = *interpret_addr2("255.255.255.255"); loopback_ip = *interpret_addr2("127.0.0.1"); SAFE_FREE(probed_ifaces); /* dump the current interfaces if any */ while (local_interfaces) { struct interface *iface = local_interfaces; DLIST_REMOVE(local_interfaces, local_interfaces); ZERO_STRUCTPN(iface); SAFE_FREE(iface); } /* probe the kernel for interfaces */ total_probed = get_interfaces(ifaces, MAX_INTERFACES); if (total_probed > 0) { probed_ifaces = memdup(ifaces, sizeof(ifaces[0])*total_probed); } /* if we don't have a interfaces line then use all broadcast capable interfaces except loopback */ if (!ptr || !*ptr || !**ptr) { if (total_probed <= 0) { DEBUG(0,("ERROR: Could not determine network interfaces, you must use a interfaces config line\n")); exit(1); } for (i=0;i<total_probed;i++) { if (probed_ifaces[i].netmask.s_addr != allones_ip.s_addr && probed_ifaces[i].ip.s_addr != loopback_ip.s_addr) { add_interface(probed_ifaces[i].ip, probed_ifaces[i].netmask); } } return; } if (ptr) { while (*ptr) { char *ptr_cpy = strdup(*ptr); if (ptr_cpy) { interpret_interface(ptr_cpy); free(ptr_cpy); } ptr++; } } if (!local_interfaces) { DEBUG(0,("WARNING: no network interfaces found\n")); } }
void load_interfaces(void) { struct iface_struct *ifaces = NULL; const char **ptr = lp_interfaces(); int i; gfree_interfaces(); /* Probe the kernel for interfaces */ total_probed = get_interfaces(talloc_tos(), &ifaces); if (total_probed > 0) { probed_ifaces = (struct iface_struct *)smb_memdup(ifaces, sizeof(ifaces[0])*total_probed); if (!probed_ifaces) { DEBUG(0,("ERROR: smb_memdup failed\n")); exit(1); } } TALLOC_FREE(ifaces); /* if we don't have a interfaces line then use all broadcast capable interfaces except loopback */ if (!ptr || !*ptr || !**ptr) { if (total_probed <= 0) { DEBUG(0,("ERROR: Could not determine network " "interfaces, you must use a interfaces config line\n")); exit(1); } for (i=0;i<total_probed;i++) { if (probed_ifaces[i].flags & IFF_BROADCAST) { add_interface(&probed_ifaces[i]); } } return; } if (ptr) { while (*ptr) { char *ptr_cpy = SMB_STRDUP(*ptr); if (ptr_cpy) { interpret_interface(ptr_cpy); free(ptr_cpy); } ptr++; } } if (!local_interfaces) { DEBUG(0,("WARNING: no network interfaces found\n")); } }
/** load the list of network interfaces **/ void load_interfaces(TALLOC_CTX *mem_ctx, const char **interfaces, struct interface **local_interfaces) { const char **ptr = interfaces; int i; struct iface_struct ifaces[MAX_INTERFACES]; struct in_addr loopback_ip; int total_probed; *local_interfaces = NULL; loopback_ip = interpret_addr2("127.0.0.1"); /* probe the kernel for interfaces */ total_probed = get_interfaces(ifaces, MAX_INTERFACES); /* if we don't have a interfaces line then use all interfaces except loopback */ if (!ptr || !*ptr || !**ptr) { if (total_probed <= 0) { DEBUG(0,("ERROR: Could not determine network interfaces, you must use a interfaces config line\n")); } for (i=0;i<total_probed;i++) { if (ifaces[i].ip.s_addr != loopback_ip.s_addr) { add_interface(mem_ctx, ifaces[i].ip, ifaces[i].netmask, local_interfaces); } } } while (ptr && *ptr) { interpret_interface(mem_ctx, *ptr, ifaces, total_probed, local_interfaces); ptr++; } if (!*local_interfaces) { DEBUG(0,("WARNING: no network interfaces found\n")); } }
/** load the list of network interfaces **/ void load_interface_list(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, struct interface **local_interfaces) { const char **ptr = lpcfg_interfaces(lp_ctx); int i; struct iface_struct *ifaces; int total_probed; bool enable_ipv6 = lpcfg_parm_bool(lp_ctx, NULL, "ipv6", "enable", true); *local_interfaces = NULL; /* probe the kernel for interfaces */ total_probed = get_interfaces(mem_ctx, &ifaces); /* if we don't have a interfaces line then use all interfaces except loopback */ if (!ptr || !*ptr || !**ptr) { if (total_probed <= 0) { DEBUG(0,("ERROR: Could not determine network interfaces, you must use a interfaces config line\n")); } for (i=0; i<total_probed; i++) { if (!is_loopback_addr((struct sockaddr *)&ifaces[i].ip)) { add_interface(mem_ctx, &ifaces[i], local_interfaces, enable_ipv6); } } } while (ptr && *ptr) { interpret_interface(mem_ctx, *ptr, ifaces, total_probed, local_interfaces, enable_ipv6); ptr++; } if (!*local_interfaces) { DEBUG(0,("WARNING: no network interfaces found\n")); } talloc_free(ifaces); }