// make a host cross-project ID.
// Should be unique across hosts with very high probability
//
void HOST_INFO::generate_host_cpid() {
// Assume that get_mac_addresses can be ported to any unix system.
// If not, it can return false.
//
#if defined(__linux__) || defined(_WIN32) || defined(__APPLE__ ) || defined(__unix)
    char buffer[8192] = "";
        // must be big enough to accommodate aa:bb:cc:dd:ee:ff
        // times the number of network interfaces,
        // plus the domain name, IP addr, and OS name.
        // 8K should suffice

    if (!get_mac_addresses(buffer) || ! strcmp(buffer, "")) {
        make_random_string("", host_cpid);
        return;
    }
    strcat(buffer, domain_name);
    strcat(buffer, ip_addr);
    strcat(buffer, os_name);
    md5_block((unsigned char*)buffer, (int)strlen(buffer), host_cpid);
#else
    make_random_string("", host_cpid);
#endif
}
예제 #2
0
// make a host cross-project ID.
// Should be unique across hosts with very high probability
//
void HOST_INFO::generate_host_cpid() {
    make_random_string("", host_cpid);
}