/*-#+func---------------------------------------------------------- FUNCTION: inet_ntoa() PURPOSE: Convert an internet address (in host byte order) to a dotted decimal ascii string, e.g., 255.255.255.255\0 SYNTAX: DESCRIPTION: RETURNS: HISTORY: --#-func----------------------------------------------------------*/ char *inet_ntoa(int32 a) { static char buf[25]; sprintf(buf,"%u.%u.%u.%u", hibyte(hiword(a)), lobyte(hiword(a)), hibyte(loword(a)), lobyte(loword(a)) ); return buf; }
eui.e_vers = SUN_EUI_16_VERS; eui.e_company_id[0] = (SUN_EN >> 16) & 0xff; eui.e_company_id[1] = (SUN_EN >> 8) & 0xff; eui.e_company_id[2] = SUN_EN & 0xff; } else { bzero(&eui, sizeof (eui)); eui.e_vers = SUN_EUI_16_VERS; eui.e_company_id[0] = (SUN_EN >> 16) & 0xff; eui.e_company_id[1] = (SUN_EN >> 8) & 0xff; eui.e_company_id[2] = SUN_EN & 0xff; eui.e_timestamp[0] = hibyte(hiword(tval)); eui.e_timestamp[1] = lobyte(hiword(tval)); eui.e_timestamp[2] = hibyte(loword(tval)); eui.e_timestamp[3] = lobyte(loword(tval)); for (i = 0; i < min(mac_len, sizeof (eui.e_mac)); i++) { eui.e_mac[i] = mac_addr[i]; } /* * To prevent duplicate GUIDs we need to sleep for one * second here since part of the GUID is a time stamp with * a one second resolution. */ (void) sleep(1); } if (tgt_xml_encode((uint8_t *)&eui, sizeof (eui), guid, &guid_size) == False) {
Boolean_t util_create_guid(char **guid) { eui_16_t eui; /* * We only have room for 32bits of data in the GUID. The hiword/loword * macros will not work on 64bit variables. The work, but produce * invalid results on Big Endian based machines. */ uint32_t tval = (uint_t)time((time_t *)0); size_t guid_size; int i, fd; if ((mac_len == 0) && (if_find_mac(NULL) == False)) { /* * By default strict GUID generation is enforced. This can * be disabled by using the correct XML tag in the configuration * file. */ if (enforce_strict_guid == True) return (False); /* * There's no MAC address available and we've even tried * a second time to get one. So fallback to using a random * number for the MAC address. */ if ((fd = open("/dev/random", O_RDONLY)) < 0) return (False); if (read(fd, &eui, sizeof (eui)) != sizeof (eui)) return (False); (void) close(fd); eui.e_vers = SUN_EUI_16_VERS; eui.e_company_id[0] = 0; eui.e_company_id[1] = 0; eui.e_company_id[2] = SUN_EN; } else { bzero(&eui, sizeof (eui)); eui.e_vers = SUN_EUI_16_VERS; /* ---- [0] & [1] are zero for Sun's IEEE identifier ---- */ eui.e_company_id[2] = SUN_EN; eui.e_timestamp[0] = hibyte(hiword(tval)); eui.e_timestamp[1] = lobyte(hiword(tval)); eui.e_timestamp[2] = hibyte(loword(tval)); eui.e_timestamp[3] = lobyte(loword(tval)); for (i = 0; i < min(mac_len, sizeof (eui.e_mac)); i++) { eui.e_mac[i] = mac_addr[i]; } /* * To prevent duplicate GUIDs we need to sleep for one * second here since part of the GUID is a time stamp with * a one second resolution. */ sleep(1); } if (tgt_xml_encode((uint8_t *)&eui, sizeof (eui), guid, &guid_size) == False) { return (False); } else return (True); }