Exemplo n.º 1
0
NMErr
OTIPEnumerator::IdleEnumeration(void)
{
OSStatus	status = kNMNoError;
NMUInt32		timeSinceLastIdle;
	
	if (! bActive)
		return kNMNoError;
		
	if (bDataWaiting)
		status = ReceiveDatagram();
	
	if (bFirstIdle)
	{
		timeSinceLastIdle = 0;
		bFirstIdle = false;
	}
	else
	{
		timeSinceLastIdle = OTElapsedMilliseconds(&mLastIdleTimeStamp);
	}

	OTGetTimeStamp(&mLastIdleTimeStamp);
	IdleList(timeSinceLastIdle);
	
	if (OTElapsedMilliseconds(&mLastQueryTimeStamp) > mEnumPeriod)
	{
		if (mEnumPeriod < kMaxTimeBetweenPings)
			mEnumPeriod *= 2;

		SendQuery();
	}

	return status;
}
Exemplo n.º 2
0
ulong pgp_milliseconds()
{
	// Returns milliseconds since system startup
#ifdef PGP_MACINTOSH
	if(UEnvironment::HasFeature(env_HasOpenTransport))
	{
		OTTimeStamp soundStamp;
		
		OTGetTimeStamp(&soundStamp);
		return OTTimeStampInMilliseconds(&soundStamp);
	}
	else
		return pgp_getticks();
#elif PGP_WIN32
	return GetTickCount();
#endif
}
Exemplo n.º 3
0
// Called only when the module is being unloaded.
NMErr
NMShutdown(void)
{
    gTerminating = true;

    /*#ifndef OP_PLATFORM_MAC_CARBON_FLAG
    	if (OTEndpoint::sServiceEPCacheSystemTask)
    		OTDestroySystemTask(OTEndpoint::sServiceEPCacheSystemTask);
    #endif*/

    //	See if there are any endpoints still trying to close.  If so, give them a moment
    //	this is totally OT dependent, but who cares?  We're never going to do a classic version...
    if (! OTEndpoint::sZombieList.IsEmpty())
    {
        UnsignedWide	startTime;
        NMUInt32			elapsedMilliseconds;

        op_vpause("Stragglers are still trying to close, let's give them a moment...");

        //	signal that the party's over, and anyone left should die NOW!
        EndpointDisposer::sLastChance = true;

        OTGetTimeStamp(&startTime);

        while (! OTEndpoint::sZombieList.IsEmpty())
        {
            elapsedMilliseconds = OTElapsedMilliseconds(&startTime);

            if (elapsedMilliseconds > 5000)
            {
                op_vpause("Timed out waiting for endpoints to finish. OT is probably hosed.");
                break;
            }
        }

    }

    // cleanup any remaining endpoints [gg]
    EndpointHander::CleanupEndpoints();


    return (kNMNoError);
}
Exemplo n.º 4
0
NMErr
OTIPEndpoint::WaitForOpenConfirmation(void)
{
	DEBUG_ENTRY_EXIT("OTIPEndpoint::WaitForOpenConfirmation");

UnsignedWide		startTime;
NMUInt32			elapsedMilliseconds;
NMBoolean			keepWaiting = true;
	
	OTGetTimeStamp(&startTime); 

	while (!bConnectionConfirmed &&
			(elapsedMilliseconds = OTElapsedMilliseconds(&startTime)) < mTimeout) {};

	if (! bConnectionConfirmed)
		return kNMTimeoutErr;
	
	return kNMNoError;
}
Exemplo n.º 5
0
NMErr
OTIPEnumerator::SendQuery(void)
{
	DEBUG_ENTRY_EXIT("IPEnumerator::SendQuery");

TUnitData	udata;
OTResult	result;
InetAddress	broadcastAddr;
	
	//	Set up the unit data structure
	//	fBroadcastAddr doesn't seem to get set right, so construct it
	OTInitInetAddress(&broadcastAddr, mConfig.address.fPort, mInterfaceInfo.fAddress | ~mInterfaceInfo.fNetmask);

	udata.addr.buf = (NMUInt8 *) &broadcastAddr;
	udata.addr.len = sizeof (InetAddress);
	udata.opt.len = 0;
	udata.udata.len = kQuerySize;
	udata.udata.buf = mPacketData;
	
	do
	{
		result = OTSndUData(mEP, &udata);

		if (result < 0)
		{
			DEBUG_PRINT("OTSndUData returned an error: %ld", result);

			if (result == kOTLookErr)
				HandleLookErr();
		}
	} while (result != kNMNoError && result == kOTLookErr);
	
	//	Set the timestamp so that we'll know when to ping again
	OTGetTimeStamp(&mLastQueryTimeStamp);
	
	return result;
}