// Initialize the chain value. void CallId::initialize() { NetMd5Codec encoder; // Get the start time. OsTime currentTime; OsDateTime::getCurTime(currentTime); encoder.hash(¤tTime, sizeof(currentTime)); // Get the process ID. PID processId; processId = OsProcess::getCurrentPID(); encoder.hash(&processId, sizeof(processId)); // Get the host identity. UtlString thisHost; OsSocket::getHostIp(&thisHost); encoder.hash(thisHost); Os::Logger::instance().log(FAC_SIP, PRI_DEBUG, "CallId::initialize sChainValue"); // Save the initial hash used to seed the sequence encoder.appendBase64Sig(sChainValue); // Note initialization is done. sChainValueInitialized = true; }
// Compute the next chain value. void CallId::nextValue() { NetMd5Codec encoder; // If we haven't initialized yet, do so. if (!sChainValueInitialized) { initialize(); } // Use the previous chain value to seed the next one encoder.hash(sChainValue); // Get the time and hash it into the next value OsTime currentTime; OsDateTime::getCurTime(currentTime); encoder.hash(¤tTime, sizeof(currentTime)); // Replace the old chain value with the new one sChainValue.remove(0); encoder.appendBase64Sig(sChainValue); }