// Ethernet built-in device injection BOOLEAN set_eth_props(pci_dt_t *eth_dev) { #if DEBUG_INJECT CHAR8 *devicepath; #endif DevPropDevice *device; UINT8 builtin = 0x0; BOOLEAN Injected = FALSE; INT32 i; CHAR8 compatible[64]; if (!string) { string = devprop_create_string(); } #if DEBUG_INJECT devicepath = get_pci_dev_path(eth_dev); #endif //device = devprop_add_device(string, devicepath); device = devprop_add_device_pci(string, eth_dev); if (!device) return FALSE; // ------------------------------------------------- DBG("LAN Controller [%04x:%04x] :: %a\n", eth_dev->vendor_id, eth_dev->device_id, devicepath); if (eth_dev->vendor_id != 0x168c && builtin_set == 0) { builtin_set = 1; builtin = 0x01; } if (gSettings.NrAddProperties != 0xFFFE) { for (i = 0; i < gSettings.NrAddProperties; i++) { if (gSettings.AddProperties[i].Device != DEV_LAN) { continue; } Injected = TRUE; devprop_add_value(device, gSettings.AddProperties[i].Key, (UINT8*)gSettings.AddProperties[i].Value, gSettings.AddProperties[i].ValueLen); } } if (Injected) { DBG("custom LAN properties injected, continue\n"); // return TRUE; } // DBG("Setting dev.prop built-in=0x%x\n", builtin); devprop_add_value(device, "device_type", (UINT8*)"Ethernet", 9); if (gSettings.FakeLAN) { UINT32 FakeID = gSettings.FakeLAN >> 16; devprop_add_value(device, "device-id", (UINT8*)&FakeID, 4); AsciiSPrint(compatible, 64, "pci%x,%x", (gSettings.FakeLAN & 0xFFFF), FakeID); LowCase(compatible); devprop_add_value(device, "compatible", (UINT8*)&compatible[0], 12); FakeID = gSettings.FakeLAN & 0xFFFF; devprop_add_value(device, "vendor-id", (UINT8*)&FakeID, 4); }
int bbcp_NetAddrInfo::Resolve() { char hBuff[NI_MAXHOST]; int n, rc; // Free up hostname here // if (hostName) {free(hostName); hostName = 0;} // Determine the actual size of the address structure // if (IP.Addr.sa_family == AF_INET ) n = sizeof(IP.v4); else if (IP.Addr.sa_family == AF_INET6) n = sizeof(IP.v6); else if (IP.Addr.sa_family == AF_UNIX ) {hostName = strdup("localhost"); return 0; } else return EAI_FAMILY; // Do lookup of canonical name. If an error is returned we simply assume that // the name is not resolvable and return the address as the host name. // if ((rc = getnameinfo(&IP.Addr, n, hBuff+1, sizeof(hBuff)-2, 0, 0, 0))) {int ec = errno; if (Format(hBuff, sizeof(hBuff), fmtAddr, noPort)) {hostName = strdup(hBuff); return 0;} errno = ec; return rc; } // Handle the case when the mapping returned an actual name or an address // We always want numeric ipv6 addresses surrounded by brackets. Additionally, // some implementations of getnameinfo() return the scopeid when a numeric // address is returned. We check and remove it. // if (!index(hBuff+1, ':')) hostName = strdup(LowCase(hBuff+1)); else {char *perCent = index(hBuff+1, '%'); if (perCent) *perCent = 0; n = strlen(hBuff+1); hBuff[0] = '['; hBuff[n+1] = ']'; hBuff[n+2] = 0; hostName = strdup(hBuff); } return 0; }