示例#1
0
void COSCStatsSender::SetEnabled(bool enabled) {

	bool statusChanged = (enabled != sendingEnabled);
	this->sendingEnabled = enabled;

	if (statusChanged) {
		if (enabled) {
			oscOutputBuffer = new char[OSC_OUTPUT_BUFFER_SIZE];
			oscPacker = new osc::OutboundPacketStream(oscOutputBuffer,
					OSC_OUTPUT_BUFFER_SIZE);
			network = new NetStruct;
			network->outSocket = new boost::asio::ip::udp::socket(netcode::netservice, boost::asio::ip::udp::endpoint(boost::asio::ip::address_v6::any(), 0));
			boost::asio::socket_base::broadcast option(true);
			network->outSocket->set_option(option);
			UpdateDestination();
			LOG("Sending spring Statistics over OSC to: %s:%u",
					dstAddress.c_str(), dstPort);

			SendInit();
		} else {
			delete oscPacker;
			oscPacker = NULL;
			delete network->outSocket;
			network->outSocket = NULL;
			delete network->destination;
			network->destination = NULL;
			delete network;
			delete [] oscOutputBuffer;
			oscOutputBuffer = NULL;
		}
	}
}
示例#2
0
void
StorageChild::InitRemote()
{
  ContentChild* child = ContentChild::GetSingleton();
  AddIPDLReference();
  child->SendPStorageConstructor(this, null_t());
  SendInit(mUseDB, mCanUseChromePersist, mSessionOnly, mInPrivateBrowsing, mDomain, mScopeDBKey,
           mQuotaDomainDBKey, mQuotaETLDplus1DomainDBKey, mStorageType);
}
示例#3
0
nsresult
StorageChild::CloneFrom(bool aCallerSecure, DOMStorageBase* aThat)
{
  StorageChild* other = static_cast<StorageChild*>(aThat);
  ContentChild* child = ContentChild::GetSingleton();
  StorageClone clone(nullptr, other, aCallerSecure);
  AddIPDLReference();
  child->SendPStorageConstructor(this, clone);
  SendInit(mUseDB, mCanUseChromePersist, mSessionOnly, mInPrivateBrowsing, mDomain,
           mScopeDBKey, mQuotaDomainDBKey, mQuotaETLDplus1DomainDBKey, mStorageType);
  return NS_OK;
}
nsresult
WyciwygChannelChild::Init(nsIURI* uri)
{
  NS_ENSURE_ARG_POINTER(uri);

  mState = WCC_INIT;

  mURI = uri;
  mOriginalURI = uri;

  SendInit(IPC::URI(mURI));
  return NS_OK;
}
示例#5
0
CComChannel* CKadHandler::PrepareChannel(const CNodeAddress& Address, CKadNode* pNode)
{
	CComChannel* pChannel = NULL;
	if(CSafeAddress* pAddress = Address.GetAssistent()) // if node is firewalled
	{
		// Note: we can not send a direct packet we must always stream
		// we dont want to use assistant nodes to relay packets, its enough thay broker the connection for us

		if(!pAddress->IsValid())
			return NULL; //node dont have an assistant and is not directly reachable, we cant communicate right now

		const CMyAddress* pMyAddress = GetParent<CKademlia>()->Fwh()->GetAddress(Address.GetProtocol());
		if(pMyAddress->GetAssistent()) // and we are two
		{
			GetParent<CKademlia>()->Fwh()->SendTunnel(Address, false);
			if(pAddress->GetPort() == 0)
				return NULL; // node can't tunnel, we could only use a callback if we ware open, but we are closed, so we cant communicate at all
			pChannel = Rendevouz(Address); 
		}
		else
		{
			GetParent<CKademlia>()->Fwh()->SendTunnel(Address, true);
			pChannel = CallBack(Address, false);
		}
	}
	else
		pChannel = Connect(Address);
	
	if(pChannel)
	{
		bool bAdded = false;
		SKadData* pData = pChannel->GetData<SKadData>(&bAdded);
		ASSERT(bAdded);

		pData->pNode = pNode;
		pChannel->AddUpLimit(pNode->GetUpLimit());
		pChannel->AddDownLimit(pNode->GetDownLimit());

		SendInit(pNode, pChannel);
		
		// Encrypt and authenticate all channels by default
		bool bEncrypt = true;
		bool bAuthenticate = true;
		pChannel->SetQueueLock(true);

		m_KeyExchanges.insert(TExchangeMap::value_type(SKadNode(pNode, pChannel), SKeyExchange(bEncrypt, bAuthenticate, 0)));
		ResumeExchange(pNode);
	}
	return pChannel;
}
nsresult
GMPDecryptorParent::Init(GMPDecryptorProxyCallback* aCallback)
{
  if (mIsOpen) {
    NS_WARNING("Trying to re-use an in-use GMP decrypter!");
    return NS_ERROR_FAILURE;
  }
  mCallback = aCallback;
  if (!SendInit()) {
    return NS_ERROR_FAILURE;
  }
  mIsOpen = true;
  return NS_OK;
}
nsresult
GMPDecryptorParent::Init(GMPDecryptorProxyCallback* aCallback,
                         bool aDistinctiveIdentifierRequired,
                         bool aPersistentStateRequired)
{
  LOGD(("GMPDecryptorParent[%p]::Init()", this));

  if (mIsOpen) {
    NS_WARNING("Trying to re-use an in-use GMP decrypter!");
    return NS_ERROR_FAILURE;
  }
  mCallback = aCallback;
  if (!SendInit(aDistinctiveIdentifierRequired, aPersistentStateRequired)) {
    return NS_ERROR_FAILURE;
  }
  mIsOpen = true;
  return NS_OK;
}
示例#8
0
void
GPUChild::Init()
{
  // Build a list of prefs the GPU process will need. Note that because we
  // limit the GPU process to prefs contained in gfxPrefs, we can simplify
  // the message in two ways: one, we only need to send its index in gfxPrefs
  // rather than its name, and two, we only need to send prefs that don't
  // have their default value.
  nsTArray<GfxPrefSetting> prefs;
  for (auto pref : gfxPrefs::all()) {
    if (pref->HasDefaultValue()) {
      continue;
    }

    GfxPrefValue value;
    pref->GetCachedValue(&value);
    prefs.AppendElement(GfxPrefSetting(pref->Index(), value));
  }

  SendInit(prefs);
}
示例#9
0
文件: tkMacSend.c 项目: martym/Lens
char *
Tk_SetAppName(
    Tk_Window tkwin,		/* Token for any window in the application
				 * to be named:  it is just used to identify
				 * the application and the display.  */
    char *name)			/* The name that will be used to
				 * refer to the interpreter in later
				 * "send" commands.  Must be globally
				 * unique. */
{
    TkWindow *winPtr = (TkWindow *) tkwin;
    Tcl_Interp *interp = winPtr->mainPtr->interp;
    int i, suffix, offset, result;
    int createCommand = 0;
    RegisteredInterp *riPtr, *prevPtr;
    char *actualName;
    Tcl_DString dString;
    Tcl_Obj *resultObjPtr, *interpNamePtr;
    char *interpName;

    if (!initialized) {
	SendInit(interp);
    }

    /*
     * See if the application is already registered; if so, remove its
     * current name from the registry. The deletion of the command
     * will take care of disposing of this entry.
     */

    for (riPtr = interpListPtr, prevPtr = NULL; riPtr != NULL; 
	    prevPtr = riPtr, riPtr = riPtr->nextPtr) {
	if (riPtr->interp == interp) {
	    if (prevPtr == NULL) {
		interpListPtr = interpListPtr->nextPtr;
	    } else {
		prevPtr->nextPtr = riPtr->nextPtr;
	    }
	    break;
	}
    }

    /*
     * Pick a name to use for the application.  Use "name" if it's not
     * already in use.  Otherwise add a suffix such as " #2", trying
     * larger and larger numbers until we eventually find one that is
     * unique.
     */

    actualName = name;
    suffix = 1;
    offset = 0;
    Tcl_DStringInit(&dString);

    TkGetInterpNames(interp, tkwin);
    resultObjPtr = Tcl_GetObjResult(interp);
    Tcl_IncrRefCount(resultObjPtr);
    for (i = 0; ; ) {
	result = Tcl_ListObjIndex(NULL, resultObjPtr, i, &interpNamePtr);
	if (interpNamePtr == NULL) {
	    break;
	}
	interpName = Tcl_GetStringFromObj(interpNamePtr, NULL);
	if (strcmp(actualName, interpName) == 0) {
	    if (suffix == 1) {
		Tcl_DStringAppend(&dString, name, -1);
		Tcl_DStringAppend(&dString, " #", 2);
		offset = Tcl_DStringLength(&dString);
		Tcl_DStringSetLength(&dString, offset + 10);
		actualName = Tcl_DStringValue(&dString);
	    }
	    suffix++;
	    sprintf(actualName + offset, "%d", suffix);
	    i = 0;
	} else {
	    i++;
	}
    }

    Tcl_DecrRefCount(resultObjPtr);
    Tcl_ResetResult(interp);

    /*
     * We have found a unique name. Now add it to the registry.
     */

    riPtr = (RegisteredInterp *) ckalloc(sizeof(RegisteredInterp));
    riPtr->interp = interp;
    riPtr->name = ckalloc(strlen(actualName) + 1);
    riPtr->nextPtr = interpListPtr;
    interpListPtr = riPtr;
    strcpy(riPtr->name, actualName);

    Tcl_CreateObjCommand(interp, "send", Tk_SendObjCmd, 
	    (ClientData) riPtr, NULL /* TODO: DeleteProc */);
    if (Tcl_IsSafe(interp)) {
	Tcl_HideCommand(interp, "send", "send");
    }
    Tcl_DStringFree(&dString);

    return riPtr->name;
}
示例#10
0
int WaitForInit(string& strCommandLine, string& strWorkingDir, string& strCommandParams)
{
	SMsgHeader MsgHdr;
	TCharVector MessageBuffer;
	MessageBuffer.resize(MSGBUFF_DEFSIZE);

	strCommandLine = "";

	printf("Waiting for INIT - ");
	
	bool bContinueWait = true;
	int nInvalid = 0;


	while (bContinueWait == true)
	{
		//read the header
		EMessageType eType = g_DebugSocket.ReadMessageHdr(&MsgHdr);
	
		//check to see that the socket is still connected
		if (g_DebugSocket.eGetState() != CHeDbgSocket::eSOCKSTATE_CONNECTED)
		{
			dprintf("Socket connection closed - quitting\n");
			return -1;
		}
		
		if (eType > eMSG_INVALID)
		{
			//read the message body (if any)
			int nMsgBytes = MsgHdr.GetMsgSize();	//strtol(MsgHdr.MsgSize, NULL, 10);
			int nMsgSize = 0;
			MessageBuffer.resize(nMsgBytes);
			if (nMsgBytes > 0)
			{
				memset(&(MessageBuffer[0]), 0, MessageBuffer.size());
				nMsgSize = g_DebugSocket.ReadMessageBody(&(MessageBuffer[0]), &MsgHdr);	
			}

			//ignore messages other than INIT and EXIT
			switch (eType)
			{
			case eMSG_INIT:
				//init received, store the command line, parameters and path
				if (MessageBuffer.size() > 0)
				{
					const char* pCurStr = &(MessageBuffer[0]);
					strCommandLine = pCurStr;
					
					pCurStr += strlen(pCurStr) + 1;
					strWorkingDir = pCurStr;
					
					pCurStr += strlen(pCurStr) + 1;
					strCommandParams = pCurStr;

					printf("INIT received\nExecuting: %s\n", &(MessageBuffer[0]));					
				}
				else
					printf("INIT received without command line - exiting\n");
				
				bContinueWait = false;
				break;
			case eMSG_SETOPTION:
				SetOption(&(MessageBuffer[0]));
				break;
				
			case eMSG_EXIT:
				printf("EXIT received while waiting for INIT - exiting\n");
				bContinueWait = false;			
				break;

			case eMSG_PING:
				g_DebugSocket.SendMessage(eMSG_PONG, "");
				break;

			default:
				dprintf("Invalid message for Init state: %d\n", eType);
			}

		}
		else
		{
			//no message received, sleep for a bit.
			Sleep(WAITINIT_SLEEPMS);

			//if we wait for a while and still haven't gotten a response, resend the
			//init - if the socket is closed, this will reset the socket's state, otherwise
			//it will give the debug client another chance to respond
			if (++nInvalid > INIT_RETRY_COUNT)
			{
				//resend init
				SendInit();
			}
		}
	}

	if (strCommandLine.length() > 0)
		return 0;
	
	return -1;

} // WaitForInit
bool Xbox360Peripheral::start(IOService *provider)
{
    const IOUSBConfigurationDescriptor *cd;
    IOUSBFindInterfaceRequest intf;
    IOUSBFindEndpointRequest pipe;
    XBOX360_OUT_LED led;
    IOWorkLoop *workloop = NULL;
    /*
     * Xbox One controller init packets.
     * The Rock Candy Xbox One controller requires more than just 0x05
     * Minimum required packets unknown.
     */
    UInt8 xoneInitFirst[] = { 0x02, 0x20, 0x01, 0x1C, 0x7E, 0xED, 0x8B, 0x11, 0x0F, 0xA8, 0x00, 0x00, 0x5E, 0x04, 0xD1, 0x02, 0x01, 0x00, 0x01, 0x00, 0x17, 0x01, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00 };
    UInt8 xoneInitSecond[] = { 0x05, 0x20, 0x00, 0x09, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x53 };
    UInt8 xoneInitThird[] = { 0x05, 0x20, 0x01, 0x01, 0x00 };
    UInt8 xoneInitFourth[] = { 0x0A, 0x20, 0x02, 0x03, 0x00, 0x01, 0x14 };
    
    if (!super::start(provider))
		return false;
    // Get device
    device=OSDynamicCast(IOUSBDevice,provider);
    if(device==NULL) {
        IOLog("start - invalid provider\n");
        goto fail;
    }
    // Check for configurations
    if(device->GetNumConfigurations()<1) {
        device=NULL;
        IOLog("start - device has no configurations!\n");
        goto fail;
    }
    // Set configuration
    cd=device->GetFullConfigurationDescriptor(0);
    if(cd==NULL) {
        device=NULL;
        IOLog("start - couldn't get configuration descriptor\n");
        goto fail;
    }
    // Open
    if(!device->open(this)) {
        device=NULL;
        IOLog("start - unable to open device\n");
        goto fail;
    }
    if(device->SetConfiguration(this,cd->bConfigurationValue,true)!=kIOReturnSuccess) {
        IOLog("start - unable to set configuration\n");
        goto fail;
    }
    // Get release
    {
        UInt16 release = device->GetDeviceRelease();
        switch (release) {
            default:
                IOLog("Unknown device release %.4x\n", release);
                // fall through
            case 0x0110:
                chatpadInit[0] = 0x01;
                chatpadInit[1] = 0x02;
                break;
            case 0x0114:
                chatpadInit[0] = 0x09;
                chatpadInit[1] = 0x00;
                break;
        }
    }
    // Find correct interface
    controllerType = Xbox360;
    intf.bInterfaceClass=kIOUSBFindInterfaceDontCare;
    intf.bInterfaceSubClass=93;
    intf.bInterfaceProtocol=1;
    intf.bAlternateSetting=kIOUSBFindInterfaceDontCare;
    interface=device->FindNextInterface(NULL,&intf);
    if(interface==NULL) {
        // Find correct interface, Xbox original
        intf.bInterfaceClass=kIOUSBFindInterfaceDontCare;
        intf.bInterfaceSubClass=66;
        intf.bInterfaceProtocol=0;
        intf.bAlternateSetting=kIOUSBFindInterfaceDontCare;
        interface=device->FindNextInterface(NULL,&intf);
        if(interface==NULL) {
            // Find correct interface, Xbox One
            intf.bInterfaceClass=255;
            intf.bInterfaceSubClass=71;
            intf.bInterfaceProtocol=208;
            intf.bAlternateSetting=kIOUSBFindInterfaceDontCare;
            interface=device->FindNextInterface(NULL, &intf);
            if(interface==NULL)
            {
                IOLog("start - unable to find the interface\n");
                goto fail;
            }
            controllerType = XboxOne;
            goto interfacefound;
        }
        controllerType = XboxOriginal;
        goto interfacefound;
    }
interfacefound:
    interface->open(this);
    // Find pipes
    pipe.direction=kUSBIn;
    pipe.interval=0;
    pipe.type=kUSBInterrupt;
    pipe.maxPacketSize=0;
    inPipe=interface->FindNextPipe(NULL,&pipe);
    if(inPipe==NULL) {
        IOLog("start - unable to find in pipe\n");
        goto fail;
    }
    inPipe->retain();
    pipe.direction=kUSBOut;
    outPipe=interface->FindNextPipe(NULL,&pipe);
    if(outPipe==NULL) {
        IOLog("start - unable to find out pipe\n");
        goto fail;
    }
    outPipe->retain();
    // Get a buffer
    inBuffer=IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task,0,GetMaxPacketSize(inPipe));
    if(inBuffer==NULL) {
        IOLog("start - failed to allocate input buffer\n");
        goto fail;
    }
	// Find chatpad interface
	intf.bInterfaceClass = kIOUSBFindInterfaceDontCare;
	intf.bInterfaceSubClass = 93;
	intf.bInterfaceProtocol = 2;
	intf.bAlternateSetting = kIOUSBFindInterfaceDontCare;
	serialIn = device->FindNextInterface(NULL, &intf);
	if (serialIn == NULL) {
		IOLog("start - unable to find chatpad interface\n");
        goto nochat;
    }
	serialIn->open(this);
	// Find chatpad pipe
	pipe.direction = kUSBIn;
	pipe.interval = 0;
	pipe.type = kUSBInterrupt;
	pipe.maxPacketSize = 0;
	serialInPipe = serialIn->FindNextPipe(NULL, &pipe);
	if (serialInPipe == NULL)
	{
		IOLog("start - unable to find chatpad in pipe\n");
		goto fail;
	}
	serialInPipe->retain();
	// Get a buffer for the chatpad
	serialInBuffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, GetMaxPacketSize(serialInPipe));
	if (serialInBuffer == NULL)
	{
		IOLog("start - failed to allocate input buffer for chatpad\n");
		goto fail;
	}
	// Create timer for chatpad
	serialTimer = IOTimerEventSource::timerEventSource(this, ChatPadTimerActionWrapper);
	if (serialTimer == NULL)
	{
		IOLog("start - failed to create timer for chatpad\n");
		goto fail;
	}
    workloop = getWorkLoop();
	if ((workloop == NULL) || (workloop->addEventSource(serialTimer) != kIOReturnSuccess))
	{
		IOLog("start - failed to connect timer for chatpad\n");
		goto fail;
	}
	// Configure ChatPad
	// Send 'configuration'
	SendInit(0xa30c, 0x4423);
	SendInit(0x2344, 0x7f03);
	SendInit(0x5839, 0x6832);
	// Set 'switch'
    if ((!SendSwitch(false)) || (!SendSwitch(true)) || (!SendSwitch(false))) {
        // Commenting goto fail fixes the driver for the Hori Real Arcade Pro EX
        //goto fail;
	}
	// Begin toggle
	serialHeard = false;
	serialActive = false;
	serialToggle = false;
	serialResetCount = 0;
	serialTimerState = tsToggle;
	serialTimer->setTimeoutMS(1000);
    // Begin reading
    if (!QueueSerialRead())
        goto fail;
nochat:
    if (!QueueRead())
		goto fail;
    if (controllerType == XboxOne) {
        QueueWrite(&xoneInitFirst, sizeof(xoneInitFirst));
        QueueWrite(&xoneInitSecond, sizeof(xoneInitSecond));
        QueueWrite(&xoneInitThird, sizeof(xoneInitThird));
        QueueWrite(&xoneInitFourth, sizeof(xoneInitFourth));
    } else {
        // Disable LED
        Xbox360_Prepare(led,outLed);
        led.pattern=ledOff;
        QueueWrite(&led,sizeof(led));
    }
    
    // Done
	PadConnect();
	registerService();
    return true;
fail:
    ReleaseAll();
    return false;
}
///////////////////////////////////////////////////////////////////////////////
//
// Check to make sure the message is adequately defined and send it.
//
bool cPipedMailMessage::Send()
{
    // Be sure that everything that needs to be set has been set
    if (!Ready())
    {
        // the message has not been adequately defined and cannot be sent.
        return false;
    }

    SendInit();

    ASSERT(mpFile != 0);
    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    // Get Body and Attachments
    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    // get body
    std::string sNBody = cStringUtil::TstrToStr(mstrBody);

    // get attachments
    std::string sAttachments;
    if (!GetAttachmentsAsString(sAttachments))
    {
        sAttachments.erase();
    }

    std::string sSend = sNBody + sAttachments;


    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    // Make sure that there's no lone LFs
    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    cMailMessageUtil::LFToCRLF(sSend);

    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    // Determine encoding needed for body or attachments
    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    std::string sContentType = "Content-Transfer-Encoding: ";

    if (cMailMessageUtil::HasNonAsciiChars(sSend))
    {
        // encode text
        sSend = iMimeEncoding::GetInstance()->Encode(sSend, cMailMessageUtil::_MAX_RFC822_LINE_LEN);

        // identify content type
        sContentType += iMimeEncoding::GetInstance()->GetContentTypeIdentifier();
    }
    else
    {
        // do no encoding

        // identify content type
        sContentType += "7bit";
    }

    // send content type
    sContentType += "\r\n";
    SendString(cStringUtil::StrToTstr(sContentType));

    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    // Send Body and Attachments
    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    SendString(_T("\r\n"));
    SendString(cStringUtil::StrToTstr(sSend));

    SendFinit();

    return true;
}
示例#13
0
bool CKadHandler::ProcessPacket(const string& Name, const CVariant& Packet, CComChannel* pChannel)
{
	CKadNode* pNode = NULL;
	try
	{
		// Process cahnnel initialisation
		if(Name == KAD_INIT)
		{
			if(GetParent<CKademlia>()->Cfg()->GetBool("DebugTL"))
				LogLine(LOG_DEBUG, L"Recived 'Transaction Init' from %s", CUInt128(Packet["NID"]).ToHex().c_str());

			bool bAdded = false;
			SKadData* pData = pChannel->GetData<SKadData>(&bAdded);
			
			if(!pData->pNode)
			{
				pData->pNode = GetParent<CKademlia>()->Root()->GetNode(Packet["NID"]);
				if(!pData->pNode)
				{
					pData->pNode = new CKadNode(GetParent<CKademlia>()->Root());
					pData->pNode->SetID(Packet["NID"]);
					GetParent<CKademlia>()->Root()->AddNode(pData->pNode);
				}

				pChannel->AddUpLimit(pData->pNode->GetUpLimit());
				pChannel->AddDownLimit(pData->pNode->GetDownLimit());
			}
			else if(pData->pNode->GetID() != Packet["NID"])
				throw CException(LOG_ERROR, L"KadNode Miss Match"); // this should never ever happen!

			pData->pNode->SetProtocol(Packet["PROT"]);
			pData->pNode->SetVersion(Packet.Get("VER")); // Version is optional

			pData->Connected = true;

			if(bAdded) // if it was added it means its an incomming connectziona dnwe have to answer
			{
				SendInit(pData->pNode, pChannel);

				pData->pNode->UpdateAddress(pChannel->GetAddress()); // If this is incomming update addresses
			}
			return true;
		}
		else
		{
			if(SKadData* pData = pChannel->GetData<SKadData>())
				pNode = pData->pNode;
			if(!pNode || !pNode->GetParent())
				throw CException(LOG_WARNING, L"Kad Packet Recived %S on not initialized channel", Name.c_str());
		}

		if(Name.compare(KAD_CRYPTO_REQUEST) == 0)			HandleCryptoRequest(Packet, pNode, pChannel);
		else if(Name.compare(KAD_CRYPTO_RESPONSE) == 0)		HandleCryptoResponse(Packet, pNode, pChannel);

		else if(Name.compare(KAD_HELLO_REQUEST) == 0)		HandleHello(Packet, pNode, pChannel, true);
		else if(Name.compare(KAD_HELLO_RESPONSE) == 0)		HandleHello(Packet, pNode, pChannel, false);

		else if(Name.compare(KAD_NODE_REQUEST) == 0)		HandleNodeReq(Packet, pNode, pChannel);
		else if(Name.compare(KAD_NODE_RESPONSE) == 0)		HandleNodeRes(Packet, pNode, pChannel);

		// Lookup Handling
		else if(Name.compare(KAD_PROXY_REQUEST) == 0)		HandleProxyReq(Packet, pNode, pChannel);
		else if(Name.compare(KAD_PROXY_RESPONSE) == 0)		HandleProxyRes(Packet, pNode, pChannel);

		else if(Name.compare(KAD_CODE_REQUEST) == 0)		HandleCodeReq(Packet, pNode, pChannel);
		else if(Name.compare(KAD_CODE_RESPONSE) == 0)		HandleCodeRes(Packet, pNode, pChannel);

		else if(Name.compare(KAD_LOOKUP_MESSAGE) == 0)		HandleMessagePkt(Packet, pNode, pChannel);

		else if(Name.compare(KAD_EXECUTE_REQUEST) == 0)		HandleExecuteReq(Packet, pNode, pChannel);
		else if(Name.compare(KAD_EXECUTE_RESPONSE) == 0)	HandleExecuteRes(Packet, pNode, pChannel);

		else if(Name.compare(KAD_STORE_REQUEST) == 0)		HandleStoreReq(Packet, pNode, pChannel);
		else if(Name.compare(KAD_STORE_RESPONSE) == 0)		HandleStoreRes(Packet, pNode, pChannel);

		else if(Name.compare(KAD_LOAD_REQUEST) == 0)		HandleLoadReq(Packet, pNode, pChannel);
		else if(Name.compare(KAD_LOAD_RESPONSE) == 0)		HandleLoadRes(Packet, pNode, pChannel);

		else if(Name.compare(KAD_LOOKUP_REPORT) == 0)		HandleReportPkt(Packet, pNode, pChannel);

		// Routing Handling
		else if(Name.compare(KAD_ROUTE_REQUEST) == 0)		HandleRouteReq(Packet, pNode, pChannel);
		else if(Name.compare(KAD_ROUTE_RESPONSE) == 0)		HandleRouteRes(Packet, pNode, pChannel);

		else if(Name.compare(KAD_RELAY_REQUEST) == 0)		HandleRelayReq(Packet, pNode, pChannel);
		else if(Name.compare(KAD_RELAY_RESPONSE) == 0)		HandleRelayRes(Packet, pNode, pChannel);
		else if(Name.compare(KAD_RELAY_RETURN) == 0)		HandleRelayRet(Packet, pNode, pChannel);

		else if(Name.compare(KAD_RELAY_CONTROL) == 0)		HandleRelayCtrl(Packet, pNode, pChannel);
		else if(Name.compare(KAD_RELAY_STATUS) == 0)		HandleRelayStat(Packet, pNode, pChannel);

		else 
			throw CException(LOG_WARNING, L"Unsupported Kad Packet Recived %S", Name.c_str());
	}
	catch(const CException& Exception)
	{
		LogLine(Exception.GetFlag(), L"Packet \'%S\' Error: '%s' from: %s (%s)", Name.c_str(), Exception.GetLine().c_str(), pNode ? pNode->GetID().ToHex().c_str() : L"Unknown", pChannel->GetAddress().ToString().c_str());
		pChannel->Close();
		return false;
	}
	return true;
}