コード例 #1
0
ファイル: net_socket.cpp プロジェクト: HANDS-FREE/ROS_DEMO
int SocketAddress::getPort() const
{
    switch (getAddressType()) {
        case ADDRESS_TYPE_INET:
            return (int)ntohs(reinterpret_cast<const sockaddr_in *>(_platform_data)->sin_port);
        case ADDRESS_TYPE_INET6:
            return (int)ntohs(reinterpret_cast<const sockaddr_in6 *>(_platform_data)->sin6_port);
        default:
            return 0;
    }
}
コード例 #2
0
ファイル: net_socket.cpp プロジェクト: HANDS-FREE/ROS_DEMO
u_result SocketAddress::setPort(int port)
{
    switch (getAddressType()) {
        case ADDRESS_TYPE_INET:
            reinterpret_cast<sockaddr_in *>(_platform_data)->sin_port = htons((short)port);
            break;
        case ADDRESS_TYPE_INET6:
            reinterpret_cast<sockaddr_in6 *>(_platform_data)->sin6_port = htons((short)port);
            break;
        default:
            return RESULT_OPERATION_FAIL;
    }
    return RESULT_OK;
}
コード例 #3
0
ファイル: gsc_player.cpp プロジェクト: M-itch/libcod
void gsc_kick_slot() {
	int id;
	char* msg;
	char* reason;

	if ( ! stackGetParams("is", &id, &msg)) {
		printf("scriptengine> ERROR: gsc_kick_slot(): param \"id\"[1] has to be an int!\n");
		printf("scriptengine> ERROR: gsc_kick_slot(): param \"msg\"[2] has to be an string!\n");
		stackPushUndefined();
		return;
	}
	
	if(getAddressType(id) == NA_LOOPBACK) {
		stackReturnInt(0);
		return; // host
	}
	
	#if COD_VERSION == COD2_1_0
		int guid_offset = 0x765F4;
	#elif COD_VERSION == COD2_1_2
		int guid_offset = 0x76704;
	#elif COD_VERSION == COD2_1_3
		int guid_offset = 0xAE704;
	#else
		#warning gsc_kick_slot() got no working addresses for guid_offset
		int guid_offset = 0x0;
	#endif
	
	int entity = PLAYERBASE(id);
	char* name = Info_ValueForKey((char*)entity+12, "name"); // read before drop client resets the userinfo
	int guid = *(int*)(entity + guid_offset);
	SV_DropClient(entity, msg);
	int * lastPacketTime = (int*)getLastPacketTime(id);
	*lastPacketTime = getSVSTime(); // in case there is a funny zombie (copied from Q3)
	
	if(!stackGetParamString(2, &reason)) {
		Com_Printf("%s (guid %i) was kicked\n", name, guid);
		stackReturnInt(1);
		return;
	}
	
	Com_Printf("%s (guid %i) was kicked for %s\n", name, guid, reason);
	stackReturnInt(1);
}
コード例 #4
0
ファイル: net_socket.cpp プロジェクト: HANDS-FREE/ROS_DEMO
u_result SocketAddress::getRawAddress(_u8 * buffer, size_t bufferSize) const
{
     switch (getAddressType()) {
        case ADDRESS_TYPE_INET:
            if (bufferSize < sizeof(reinterpret_cast<const sockaddr_in *>(_platform_data)->sin_addr.s_addr)) return RESULT_INSUFFICIENT_MEMORY;

            memcpy(buffer, &reinterpret_cast<const sockaddr_in *>(_platform_data)->sin_addr.s_addr, sizeof(reinterpret_cast<const sockaddr_in *>(_platform_data)->sin_addr.s_addr));

            
            break;
        case ADDRESS_TYPE_INET6:
            if (bufferSize < sizeof(reinterpret_cast<const sockaddr_in6 *>(_platform_data)->sin6_addr.s6_addr)) return RESULT_INSUFFICIENT_MEMORY;
            memcpy(buffer, reinterpret_cast<const sockaddr_in6 *>(_platform_data)->sin6_addr.s6_addr, sizeof(reinterpret_cast<const sockaddr_in6 *>(_platform_data)->sin6_addr.s6_addr));

            break;
        default:
            return RESULT_OPERATION_FAIL;
    }
    return RESULT_OK;
}
コード例 #5
0
ファイル: gsc_player.cpp プロジェクト: M-itch/libcod
void gsc_player_addresstype(int id) {
	stackPushInt(getAddressType(id));
}
コード例 #6
0
void NetworkDiscovery::getIP (QString address)
{
    getIP (address, getAddressType (address));
}