Example #1
0
void EM::Acceptor::Accept (const char *signature)
{
	Connection *c = MakeConnection();
	c->Signature = signature;
	Eventables.insert (make_pair (c->Signature, c));
	c->PostInit();
}
Example #2
0
    bool
    Connect(const wxString& host, const wxString& service, const wxString& topic)
    {
        m_conn = MakeConnection(host, service, topic);

        return m_conn != NULL;
    }
Example #3
0
wxConnectionBase* TCPClient::Connect()
{
	wxString topic = "Logon";
	topic += nick;
	conn = (TCPConnection*)MakeConnection("192.168.178.254", "11111", topic.c_str());
	return conn;
}
Example #4
0
bool MyClient::Connect(const wxString& sHost, const wxString& sService, const wxString& sTopic)
{
    // suppress the log messages from MakeConnection()
    wxLogNull nolog;

    m_connection = (MyConnection *)MakeConnection(sHost, sService, sTopic);
    return m_connection    != NULL;
}
Example #5
0
void EM::Acceptor::Accept (const char *signature)
{
	Connection *c = MakeConnection();
	c->Signature = signature;
	#ifdef OS_SOLARIS8
	Eventables.insert (std::map<std::string,EM::Eventable*>::value_type (c->Signature, c));
	#else
	Eventables.insert (make_pair (c->Signature, c));
	#endif
	c->PostInit();
}
int main(int argc, char* argv[])
{
	if (argc != 2){
		printf("Usage: ./server <card name>\n");
		exit(0);
	}

	signal(SIGCHLD,&sig_chld);
	
	MakeConnection(argv[argc-1]);
	return 0;
};
Example #7
0
bool CCAppClient::Connect(const wxString& host, const wxString& service,
    const wxString& topic)
{
    auto oldLogLevel = wxLog::GetLogLevel();
    wxLog::SetLogLevel(wxLOG_FatalError); // Make sure that we don't throw errors
    // to the user if the connection fails;
    // we expect connections to fail when we
    // are testing whether or not there is a
    // server, and the user shouldn't be
    // informed when we cannot find a server
    mConnection = (CCAppClientConnection*)MakeConnection(host, service, topic);
    wxLog::SetLogLevel(oldLogLevel);
    return IsConnected();
}
Example #8
0
bool
MyClient::Connect(const wxString& sHost,
                  const wxString& sService,
                  const wxString& sTopic)
{
    // suppress the log messages from MakeConnection()
    wxLogNull nolog;

    m_connection = (MyConnection *)MakeConnection(sHost, sService, sTopic);
    if ( !m_connection )
        return false;

    Start(1000);

    return true;
}
Example #9
0
    // provide a convenient helper taking care of connecting to the right
    // server/service/topic and returning the connection of the derived type
    // (or NULL if we failed to connect)
    PokeAdviseConn *Connect()
    {
        wxString host = Bench::GetStringParameter();
        if ( host.empty() )
            host = IPC_HOST;

        wxString service;
        int port = Bench::GetNumericParameter();
        if ( !port )
            service = IPC_SERVICE;
        else
            service.Printf("%d", port);

        return static_cast<PokeAdviseConn *>(
                MakeConnection(host, service, IPC_BENCHMARK_TOPIC));
    }
Example #10
0
CLoungeServer* CLoungeServer::ConnectToLounge(u_long addr, u_short port)
{
    // do a few attempts to connect to Lounge server
    // before giving up
    for (int i = 0; i < 5; i++)
    {
        SOCKET sd = MakeConnection(addr, port);
        if (sd != INVALID_SOCKET)
        {
            return new CLoungeServer(sd);
        }
        else
            Sys_Sleep(2000);
    }

    return NULL;
}
int main(int argc, char* argv[])
{
	int proceed;
	
	if (argc < 3){
		printf("Usage: ./pvc_client <card name> <interface name>\n");
		exit(0);
	}

	if (argc == 4){
		send_ok=1;
	}
	
	proceed = MakeConnection(argv[2],argv[1]);
	if (proceed == TRUE){
		process_con( );
		return 0;
	}
	return 1;
};
Example #12
0
struct connection *MkConnection(int SockFd) {
	static struct conn_handlers h = {
		/* 2.1a */
		(int(*)(struct connection *, char))CheckChr,
		NULL,
		NULL,
		NULL,
		NULL,

		/* 2.1b */
		NULL,
		NULL,
		NULL,

		/* 2.2a */
		GotPromptStart,
		GotPromptEnd,
		GotLoginError,
		GotLoginSuccess,
		GotLogout,
		GotJob,
		NULL,
		NULL,

		/* 2.3a */
		NULL,

		/* 6.0 */
		NULL,
		NULL,

		/* 6.1 */
		NULL,

		// 6.2
		GotConnectionId,
		GotAttach,

		/* 2.1a */
		NULL,
		NULL, //GotUserRequest,

		/* 2.2a */
		NULL,
		NULL,
		NULL,
		NULL,

		/* 0.5pre3 */
		NULL,

		/* 0.5rc2 */
		NULL,

		/* 6.0 */
		NULL,
		NULL,
		NULL,

		/* 6.1 */
		NULL,
		NULL,

		// 6.2
		NULL,
		NULL,
		NULL,

		/* 0.5pre3 */
		NULL,
		NULL,
	};
	connection = MakeConnection(SockFd, &h);
	return connection;
}
Example #13
0
BOOL NDAS_GetStatus(UNIT_DISK_LOCATION *pUnitDisk, PNDAS_STATUS pStatus)
{
	BOOL bReturn = FALSE;
	IDE_COMMAND_IO cmd[2];
	LONG lResult;

	HKEY hKeyNetDisks;
	HKEY hKey;
	UINT i;
    CHAR     achKey[MAX_KEY_LENGTH];   // buffer for subkey name
    DWORD    cbName;                   // size of name string 
    FILETIME ftLastWriteTime;      // last write time 
	CHAR szAddress[MAX_VALUE_NAME], szAddress2[18];
	UCHAR szSerial[MAX_VALUE_NAME];
	DWORD dwType;
	DWORD dwSize;
	
	LPX_ADDRESS address;
	LANSCSI_PATH path;

	DISK_INFORMATION_BLOCK *pDiskInfoV1;
	DISK_INFORMATION_BLOCK_V2 *pDiskInfoV2;
	
	DebugPrint(1, ("[NDASOpLib] NDAS_GetStatus : %02X:%02X:%02X:%02X:%02X:%02X\n",
		(int)pUnitDisk->MACAddr[0],
		(int)pUnitDisk->MACAddr[1],
		(int)pUnitDisk->MACAddr[2],
		(int)pUnitDisk->MACAddr[3],
		(int)pUnitDisk->MACAddr[4],
		(int)pUnitDisk->MACAddr[5]
		));

	ZeroMemory(&path, sizeof(LANSCSI_PATH));
	CopyMemory(address.Node, pUnitDisk->MACAddr, 6);

	if(NULL == pStatus)
		goto out;

	ZeroMemory(pStatus, sizeof(NDAS_STATUS));

	// Registry check start.
	// AING_TO_DO : use NDAS registry functions
	lResult = RegOpenKeyEx(
		HKEY_LOCAL_MACHINE,
		KEY_NAME_NETDISKS,
		0,
		KEY_READ,
		&hKeyNetDisks
		);

	if(ERROR_SUCCESS != lResult)
		goto out;

	sprintf(szAddress2, "%02x:%02x:%02x:%02x:%02x:%02x",
		pUnitDisk->MACAddr[0],
		pUnitDisk->MACAddr[1],
		pUnitDisk->MACAddr[2],
		pUnitDisk->MACAddr[3],
		pUnitDisk->MACAddr[4],
		pUnitDisk->MACAddr[5]);

	i = 0;

	while(1)
	{
		cbName = MAX_KEY_LENGTH;
		lResult = RegEnumKeyEx(
			hKeyNetDisks,
			i++,
			achKey,
			&cbName,
			NULL,
			NULL,
			NULL,
			&ftLastWriteTime);

		if(ERROR_SUCCESS != lResult)
			goto out;

		lResult = RegOpenKeyEx(
			hKeyNetDisks,
			achKey,
			0,
			KEY_READ,
			&hKey
			);

		if(ERROR_SUCCESS != lResult)
			goto out;

		dwSize = MAX_VALUE_NAME;
		
		lResult = RegQueryValueEx(
			hKey,
			"Address",
			0,
			&dwType,
			szAddress,
			&dwSize);

		if(ERROR_SUCCESS != lResult)
			continue;

		if(stricmp(szAddress, szAddress2))
			continue;

		pStatus->IsRegistered = 1;

		dwSize = MAX_VALUE_NAME;
		
		lResult = RegQueryValueEx(
			hKey,
			"SerialKey",
			0,
			&dwType,
			szSerial,
			&dwSize);

		DebugPrint(1, ("[NDASOpLib] NDAS_GetStatus : lResult  = %d szSerial = %x %x %x %x %x %x %x %x %x, %d\n", 
			lResult,
			(int)szSerial[0],
			(int)szSerial[1],
			(int)szSerial[2],
			(int)szSerial[3],
			(int)szSerial[4],
			(int)szSerial[5],
			(int)szSerial[6],
			(int)szSerial[7],
			(int)szSerial[8],
			(szSerial[8] == 0xff)
			));
		
		if(ERROR_SUCCESS == lResult && szSerial[8] == 0xff)
		{
			pStatus->IsRegisteredWritable = 1;
		}

		break;
	}

	// Registry check end.

	// Connect
	if(!MakeConnection(&address, &path) || (unsigned int)NULL == path.connsock)
	{
		DebugPrint(1, ("[NDASOpLib] NDAS_GetStatus : MakeConnection Failed\n"));
		goto out;
	}

	pStatus->IsAlive = 1;

	// Login
	// if we don't write, login read only
	path.iUserID = (pUnitDisk->SlotNumber +1);

	path.iCommandTag = 0;
	path.HPID = 0;
	path.iHeaderEncryptAlgo = 0;
	path.iDataEncryptAlgo = 0;
	NDAS_SetPassword(address.Node, &path.iPassword);
	path.iSessionPhase = LOGOUT_PHASE;

	if(Login(&path, LOGIN_TYPE_NORMAL))
	{
		DebugPrint(1, ("[NDASOpLib] NDAS_GetStatus : Login Failed\n"));
		goto out;
	}
	
	if(GetDiskInfo(&path, pUnitDisk->SlotNumber))
	{
		DebugPrint(1, ("[NDASOpLib] NDAS_GetStatus : GetDiskInfo Failed\n"));
		goto out;
	}

	if(Logout(&path))
	{
		DebugPrint(1, ("[NDASOpLib] NDAS_GetStatus : Logout Failed\n"));
		goto out;
	}

	if(0 != Discovery(&path))
	{
		DebugPrint(1, ("[NDASOpLib] NDAS_GetStatus : Discovery Failed\n"));
		goto out;
	}

	closesocket(path.connsock);

	pStatus->IsDiscovered = 1;
	pStatus->HWVersion = path.HWVersion;
	pStatus->HWProtoVersion = path.HWProtoVersion;
	pStatus->NrUserReadWrite = path.PerTarget[pUnitDisk->SlotNumber].NRRWHost;
	pStatus->NrUserReadOnly = path.PerTarget[pUnitDisk->SlotNumber].NRROHost;

	if(MEDIA_TYPE_BLOCK_DEVICE != path.PerTarget[pUnitDisk->SlotNumber].MediaType)
	{
		switch(path.PerTarget[pUnitDisk->SlotNumber].MediaType)
		{
		case MEDIA_TYPE_CDROM_DEVICE:
			pStatus->DiskType = DISK_TYPE_DVD;
			pStatus->IsSupported = 1;
			break;

		case MEDIA_TYPE_OPMEM_DEVICE:
			pStatus->DiskType = DISK_TYPE_MO;
			pStatus->IsSupported = 1;
			break;
		default:
			pStatus->IsSupported = 0;
		}

		DebugPrint(1, ("[NDASOpLib] NDAS_GetStatus : Packet type %d\n", path.PerTarget[pUnitDisk->SlotNumber].MediaType));
		bReturn = TRUE;
		goto out;
	}

	cmd[0].command = WIN_READ;
	cmd[0].iSector = -1;
	pDiskInfoV1 = (PDISK_INFORMATION_BLOCK)cmd[0].data;
	cmd[1].command = WIN_READ;
	cmd[1].iSector = -2;
	pDiskInfoV2 = (PDISK_INFORMATION_BLOCK_V2)cmd[1].data;

	NDAS_IdeIO(pUnitDisk, 2, cmd, NULL);

	if(DISK_INFORMATION_SIGNATURE_V2 == pDiskInfoV2->Signature)
	{
		pStatus->MajorVersion = pDiskInfoV2->MajorVersion;
		pStatus->MinorVersion = pDiskInfoV2->MinorVersion;

		if(IS_NDAS_DIB_V2_VERSION_HIGH(*pDiskInfoV2))
			goto out;

		pStatus->IsSupported = 1;

		pStatus->DiskType = 
			(1 == pDiskInfoV2->nDiskCount) ? DISK_TYPE_NORMAL :
			(NMT_RAID1 == pDiskInfoV2->iMediaType) ? DISK_TYPE_BIND_RAID1 :
			(NMT_VDVD == pDiskInfoV2->iMediaType) ? DISK_TYPE_VDVD :
			DISK_TYPE_AGGREGATION;
	}
	else if(DISK_INFORMATION_SIGNATURE == pDiskInfoV1->Signature)
	{
		pStatus->MajorVersion = pDiskInfoV1->MajorVersion;
		pStatus->MinorVersion = pDiskInfoV1->MinorVersion;
		
		if(IS_WRONG_VERSION(*pDiskInfoV1))
			goto out;
	
		pStatus->IsSupported = 1;

		pStatus->DiskType = 
			(UNITDISK_TYPE_SINGLE == pDiskInfoV1->DiskType) ? DISK_TYPE_NORMAL :
			(UNITDISK_TYPE_AGGREGATION_FIRST == pDiskInfoV1->DiskType) ? DISK_TYPE_AGGREGATION :
			(UNITDISK_TYPE_AGGREGATION_SECOND == pDiskInfoV1->DiskType) ? DISK_TYPE_AGGREGATION :
			(UNITDISK_TYPE_AGGREGATION_THIRD == pDiskInfoV1->DiskType) ? DISK_TYPE_AGGREGATION :
			(UNITDISK_TYPE_AGGREGATION_FOURTH == pDiskInfoV1->DiskType) ? DISK_TYPE_AGGREGATION :
			(UNITDISK_TYPE_MIRROR_MASTER == pDiskInfoV1->DiskType) ? DISK_TYPE_BIND_RAID1 :
			(UNITDISK_TYPE_MIRROR_SLAVE == pDiskInfoV1->DiskType) ? DISK_TYPE_BIND_RAID1 :
			(UNITDISK_TYPE_VDVD == pDiskInfoV1->DiskType) ? DISK_TYPE_VDVD : 0;
	}
	else
	{
		pStatus->MajorVersion = 0;
		pStatus->MinorVersion = 0;
		pStatus->DiskType = DISK_TYPE_NORMAL;
		pStatus->IsSupported = 1;
	}

	bReturn = TRUE;
out:
	if(path.connsock)
		closesocket(path.connsock);

	return bReturn;
}
Example #14
0
BOOL
NDAS_SetBitmap(UNIT_DISK_LOCATION *pUnitDisk, UINT nCommand, IDE_COMMAND_IO *aCommands, LANSCSI_PATH *pPath)
{
	BOOL bReturn = FALSE;
	LANSCSI_PATH path;
	LPX_ADDRESS address;
	IDE_COMMAND_IO *pCommand = NULL;
	unsigned _int8 response;
	int iResult;
	unsigned int i;

	ZeroMemory(&path, sizeof(LANSCSI_PATH));
	CopyMemory(address.Node, pUnitDisk->MACAddr, 6);

	// Connect
	if(!MakeConnection(&address, &path) || (unsigned int)NULL == path.connsock)
	{
		goto out;
	}

	// Login
	path.iUserID = (pUnitDisk->SlotNumber +1) | (pUnitDisk->SlotNumber +1) << 16;
	path.iCommandTag = 0;
	path.HPID = 0;
	path.iHeaderEncryptAlgo = 0;
	path.iDataEncryptAlgo = 0;
	NDAS_SetPassword(address.Node, &path.iPassword);
	path.iSessionPhase = LOGOUT_PHASE;
	if(Login(&path, LOGIN_TYPE_NORMAL))
		goto out;
	
	if(GetDiskInfo(&path, pUnitDisk->SlotNumber))
		goto out;

	if(NULL != pPath)
	{
		CopyMemory(pPath, &path, sizeof(LANSCSI_PATH));
	}

	for(i = 0; i < nCommand; i++)
	{
		pCommand = &aCommands[i];
		iResult = IdeCommand(
			&path, 
			pUnitDisk->SlotNumber, 
			0, 
			pCommand->command, 
			(pCommand->iSector < 0) ? path.PerTarget[pUnitDisk->SlotNumber].SectorCount + pCommand->iSector : pCommand->iSector,
			1,
			0,
			pCommand->data,
			&response);

		if(iResult || LANSCSI_RESPONSE_SUCCESS != response)
			goto out;
	}
	
	bReturn = TRUE;
out:
	if(path.connsock)
	{
		if(LOGOUT_PHASE != path.iSessionPhase)
		{
			Logout(&path);
		}
		closesocket(path.connsock);
		path.connsock = (UINT)NULL;
	}
	return bReturn;
}
Example #15
0
BOOL
NDAS_IdeIO(UNIT_DISK_LOCATION *pUnitDisk, UINT nCommand, IDE_COMMAND_IO *aCommands, LANSCSI_PATH *pPath)
{
	BOOL bReturn = FALSE;
	LANSCSI_PATH path;
	LPX_ADDRESS address;
	IDE_COMMAND_IO *pCommand = NULL;
	_int8 data[512];
	unsigned _int8 response;
	int iResult;
	unsigned int i;

	ZeroMemory(&path, sizeof(LANSCSI_PATH));
	CopyMemory(address.Node, pUnitDisk->MACAddr, 6);

	// Connect
	if(!MakeConnection(&address, &path) || (unsigned int)NULL == path.connsock)
	{
		DebugPrint(1, ("[NDASOpLib] NDAS_IdeIO : MakeConnection Failed\n"));
		goto out;
	}

	// Login
	// if we don't write, login read only
	path.iUserID = (pUnitDisk->SlotNumber +1);
	for(i = 0; i < nCommand; i++)
	{
		if(WIN_WRITE == aCommands[i].command)
		{
			path.iUserID = (pUnitDisk->SlotNumber +1) | (pUnitDisk->SlotNumber +1) << 16;
			break;
		}
		
	}
	path.iCommandTag = 0;
	path.HPID = 0;
	path.iHeaderEncryptAlgo = 0;
	path.iDataEncryptAlgo = 0;
	NDAS_SetPassword(address.Node, &path.iPassword);
	path.iSessionPhase = LOGOUT_PHASE;
	if(Login(&path, LOGIN_TYPE_NORMAL))
	{
		DebugPrint(1, ("[NDASOpLib] NDAS_IdeIO : Login Failed\n"));
		goto out;
	}
	
	if(GetDiskInfo(&path, pUnitDisk->SlotNumber))
	{
		DebugPrint(1, ("[NDASOpLib] NDAS_IdeIO : GetDiskInfo Failed\n"));
		goto out;
	}

	if(NULL != pPath)
	{
		CopyMemory(pPath, &path, sizeof(LANSCSI_PATH));
	}

	for(i = 0; i < nCommand; i++)
	{
		pCommand = &aCommands[i];
		iResult = IdeCommand(
			&path, 
			pUnitDisk->SlotNumber, 
			0, 
			pCommand->command, 
			(pCommand->iSector < 0) ? path.PerTarget[pUnitDisk->SlotNumber].SectorCount + pCommand->iSector : pCommand->iSector,
			1,
			0,
			(WIN_WRITE == pCommand->command) ? CopyMemory(data, pCommand->data, sizeof(pCommand->data)), data: pCommand->data,
			&response);

		if(iResult || LANSCSI_RESPONSE_SUCCESS != response)
		{
			DebugPrint(1, ("[NDASOpLib] NDAS_IdeIO : IdeCommand cmd : %d, #%d\n", pCommand->command, i));
			goto out;
		}
	}
	
	bReturn = TRUE;
out:
	if(path.connsock)
	{
		if(LOGOUT_PHASE != path.iSessionPhase)
		{
			Logout(&path);
		}
		closesocket(path.connsock);
		path.connsock = (UINT)NULL;
	}
	return bReturn;
}
Example #16
0
bool CslIpcClient::Connect(const wxString& host,const wxString& service,const wxString& topic)
{
    m_connection=(CslIpcConnection*)MakeConnection(host,service,topic);

    return m_connection!=NULL;
}