当前位置: 首页>>代码示例>>C++>>正文


C++ NET_CompareBaseAdr函数代码示例

本文整理汇总了C++中NET_CompareBaseAdr函数的典型用法代码示例。如果您正苦于以下问题:C++ NET_CompareBaseAdr函数的具体用法?C++ NET_CompareBaseAdr怎么用?C++ NET_CompareBaseAdr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NET_CompareBaseAdr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SV_NocPacket

void SV_NocPacket(netadr_t from, msg_t *msg) { //Not connected packet (Server is not running)
	char* s;
	char* c;
	if(msg->cursize >= 4) {
		if(*(int*)msg->data == -1) {
			#if 1
			int CSteamServer_HandleIncomingPacket(const void* pData, int cbData, unsigned int srcIP, unsigned short srcPort);
			if(!CSteamServer_HandleIncomingPacket((const void*)msg->data, msg->cursize, from._ip, from.port));
			#endif
		} else if(*(int*)msg->data == -2) {	
			MSG_BeginReading(msg);
			MSG_ReadLong(msg);
			
			s = MSG_ReadStringLine(msg);
			
			Cmd_TokenizeString(s);
			
			c = Cmd_Argv(0);
			
			if(!Q_stricmp(c, "serverversionresponse")) {
				if(!NET_CompareBaseAdr(from, x_master))
					return;
			} else if(!Q_stricmp(c, "clientversionresponse")) {
				if(!NET_CompareBaseAdr(from, x_master))
					return;
				clientversion = atoi( Cmd_Argv(1) );
			}
		}
	}
}
开发者ID:EndlessClan,项目名称:CoDExtended,代码行数:30,代码来源:sv_main.c

示例2: cGetChallenge

/*
=================
cGetChallenge

Returns a challenge number that can be used
in a subsequent client_connect command.
We do this to prevent denial of service attacks that
flood the server with invalid connection IPs.  With a
challenge, they must give a valid IP address.
=================
*/
static void cGetChallenge(int argc, char **argv)
{
	int		i;

	int oldest = 0;
	int oldestTime = 0x7FFFFFFF;

	// see if we already have a challenge for this ip
	for (i = 0; i < MAX_CHALLENGES; i++)
	{
		if (NET_CompareBaseAdr(&net_from, &svs.challenges[i].adr))
			break;
		if (svs.challenges[i].time < oldestTime)
		{
			oldestTime = svs.challenges[i].time;
			oldest = i;
		}
	}

	if (i == MAX_CHALLENGES)
	{
		// overwrite the oldest
		svs.challenges[oldest].challenge = rand() & 0x7FFF;
		svs.challenges[oldest].adr = net_from;
		svs.challenges[oldest].time = appMilliseconds();
		i = oldest;
	}

	// send it back
	Netchan_OutOfBandPrint(NS_SERVER, net_from, "challenge %d", svs.challenges[i].challenge);
}
开发者ID:RkShaRkz,项目名称:Quake2,代码行数:42,代码来源:sv_main.cpp

示例3: SV_ConnectionlessPacket

/*
=================
SV_ConnectionlessPacket

A connectionless packet has four leading 0xff
characters to distinguish it from a game channel.
Clients that are in the game can still send
connectionless packets.
=================
*/
void SV_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
	char	*s;
	char	*c;
	#ifdef USE_AUTH
	netadr_t	authServerIP;
	#endif

	MSG_BeginReadingOOB( msg );
	MSG_ReadLong( msg );		// skip the -1 marker

	if (!Q_strncmp("connect", (char *) &msg->data[4], 7)) {
		Huff_Decompress(msg, 12);
	}

	s = MSG_ReadStringLine( msg );
	Cmd_TokenizeString( s );

	c = Cmd_Argv(0);
	Com_DPrintf ("SV packet %s : %s\n", NET_AdrToString(from), c);

	if (!Q_stricmp(c, "getstatus")) {
		if (SV_CheckDRDoS(from)) { return; }
		SVC_Status( from  );
  } else if (!Q_stricmp(c, "getinfo")) {
		if (SV_CheckDRDoS(from)) { return; }
		SVC_Info( from );
	} else if (!Q_stricmp(c, "getchallenge")) {
		SV_GetChallenge( from );
	} else if (!Q_stricmp(c, "connect")) {
		SV_DirectConnect( from );
	} else if (!Q_stricmp(c, "ipAuthorize")) {
		SV_AuthorizeIpPacket( from );
	}
	#ifdef USE_AUTH
	// @Barbatos @Kalish
	else if ( (!Q_stricmp(c, "AUTH:SV")))
	{
		NET_StringToAdr(sv_authServerIP->string, &authServerIP);
		
		if ( !NET_CompareBaseAdr( from, authServerIP ) ) {
			Com_Printf( "AUTH not from the Auth Server\n" );
			return;
		}
		VM_Call(gvm, GAME_AUTHSERVER_PACKET);
	}
	#endif
	
	else if (!Q_stricmp(c, "rcon")) {
		SVC_RemoteCommand( from, msg );
	}else if (!Q_stricmp(c, "rconRecovery")) {
		SVC_RconRecoveryRemoteCommand( from, msg );
	} else if (!Q_stricmp(c, "disconnect")) {
		// if a client starts up a local server, we may see some spurious
		// server disconnect messages when their new server sees our final
		// sequenced messages to the old client
	} else {
		Com_DPrintf ("bad connectionless packet from %s:\n%s\n"
		, NET_AdrToString (from), s);
	}
}
开发者ID:Barbatos,项目名称:ioq3-for-UrbanTerror-4,代码行数:70,代码来源:sv_main.c

示例4: NET_CompareAdr

qboolean NET_CompareAdr(netadr_t a, netadr_t b)
{
	if (!NET_CompareBaseAdr(a, b))
	{
		return qfalse;
	}

	if (a.type == NA_IP
#ifdef FEATURE_IPV6
	    || a.type == NA_IP6
#endif
	    )
	{
		if (a.port == b.port)
		{
			return qtrue;
		}
	}
	else
	{
		return qtrue;
	}

	return qfalse;
}
开发者ID:Ododo,项目名称:etlegacy,代码行数:25,代码来源:net_ip.c

示例5: SV_BanIP_f

void SV_BanIP_f() {
	if(Cmd_Argc()!=2) {
		Com_Printf("Usage: banip <ip>\n");
		return;
	}
	
	char* ip = Cmd_Argv(1);
	netadr_t adr;
	
	NET_StringToAdr(ip, &adr);
	
	client_t* cl;
	
	for(int i = 0; i < sv_maxclients->integer; i++) {
		cl=getclient(i);
		if(!cl->state)	continue;
		if(NET_CompareBaseAdr(adr, cl->remoteAddress)) {
			SV_DropClient(cl, "banned");
			break;
		}
	}
	
	FILE* f = fopen("ipbans.txt", "a");
	if(f) {
		fprintf(f,"%s\n",ip);
		fclose(f);
	}
	
	Com_Printf("IP '%s' has been banned.\n", ip);
	
	X_ReadBannedList(false);
}
开发者ID:AnasBunny,项目名称:CoDExtended,代码行数:32,代码来源:sv_commands.c

示例6: SV_PlayerBannedByip

char* SV_PlayerBannedByip(netadr_t *netadr){	//Gets called in SV_DirectConnect
    ipBanList_t *this;
    int i;

    for(this = &ipBans[0], i = 0; i < 1024; this++, i++){

        if(NET_CompareBaseAdr(netadr, &this->remote)){

            if(Com_GetRealtime() < this->timeout)
            {

                if(this->expire == -1){
                    return va("\nEnforcing prior ban\nPermanent ban issued onto this gameserver\nYou will be never allowed to join this gameserver again\n Your UID is: %i    Banning admin UID is: %i\nReason for this ban:\n%s\n",
                    this->uid,this->adminuid,this->banmsg);

                }else{

                    int remaining = (int)(this->expire - Com_GetRealtime()) +1; //in seconds (+1 for fixing up a display error when only some seconds are remaining)
                    int d = remaining/(60*60*24);
                    remaining = remaining%(60*60*24);
                    int h = remaining/(60*60);
                    remaining = remaining%(60*60);
                    int m = remaining/60;

                    return va("\nEnforcing prior kick/ban\nTemporary ban issued onto this gameserver\nYou are not allowed to rejoin this gameserver for another\n %i days %i hours %i minutes\n Your UID is: %i    Banning admin UID is: %i\nReason for this ban:\n%s\n",
                    d,h,m,this->uid,this->adminuid,this->banmsg);
                }


            }
        }
    }
    return NULL;
}
开发者ID:JustInToCoding,项目名称:CoD4X17a_testing,代码行数:34,代码来源:sv_banlist.c

示例7: SVC_GetChallenge

/*
=================
SVC_GetChallenge

Returns a challenge number that can be used
in a subsequent client_connect command.
We do this to prevent denial of service attacks that
flood the server with invalid connection IPs.  With a
challenge, they must give a valid IP address.
=================
*/
void SVC_GetChallenge (void)
{
	int		i;
	int		oldest;
	int		oldestTime;

	oldest = 0;
	oldestTime = 0x7fffffff;

	// see if we already have a challenge for this ip
	for (i = 0 ; i < MAX_CHALLENGES ; i++)
	{
		if (NET_CompareBaseAdr (net_from, svs.challenges[i].adr))
			break;
		if (svs.challenges[i].time < oldestTime)
		{
			oldestTime = svs.challenges[i].time;
			oldest = i;
		}
	}

	if (i == MAX_CHALLENGES)
	{
		// overwrite the oldest
		svs.challenges[oldest].challenge = (rand() << 16) ^ rand();
		svs.challenges[oldest].adr = net_from;
		svs.challenges[oldest].time = svs.realtime;
		i = oldest;
	}

	// send it back
	Netchan_OutOfBandPrint (NS_SERVER, net_from, "%c%i", S2C_CHALLENGE, 
			svs.challenges[i].challenge);
}
开发者ID:matatk,项目名称:agrip,代码行数:45,代码来源:sv_main.c

示例8: SVC_GetChallenge

/*
 * ================= SVC_GetChallenge
 *
 * Returns a challenge number that can be used in a subsequent client_connect
 * command. We do this to prevent denial of service attacks that flood the
 * server with invalid connection IPs.  With a challenge, they must give a
 * valid IP address. =================
 */
void
SVC_GetChallenge(void)
{
	int		i;
	int		oldest;
	int		oldestTime;

	oldest = 0;
	oldestTime = 0x7fffffff;

	/* see if we already have a challenge for this ip */
	for (i = 0; i < MAX_CHALLENGES; i++) {
		if (NET_CompareBaseAdr(net_from, svs.challenges[i].adr))
			break;
		if (svs.challenges[i].time < oldestTime) {
			oldestTime = svs.challenges[i].time;
			oldest = i;
		}
	}

	if (i == MAX_CHALLENGES) {
		/* overwrite the oldest */
		svs.challenges[oldest].challenge = rand() & 0x7fff;
		svs.challenges[oldest].adr = net_from;
		svs.challenges[oldest].time = curtime;
		i = oldest;
	}
	/* send it back */
	Netchan_OutOfBandPrint(NS_SERVER, net_from, "challenge %i", svs.challenges[i].challenge);
}
开发者ID:ZwS,项目名称:qudos,代码行数:38,代码来源:sv_main.c

示例9: SV_PacketEvent

/*
=================
SV_ReadPackets
=================
*/
void SV_PacketEvent( netadr_t from, msg_t *msg ) {
	int			i;
	client_t	*cl;
	int			qport;

	// check for connectionless packet (0xffffffff) first
	if ( msg->cursize >= 4 && *(int *)msg->data == -1) {
		SV_ConnectionlessPacket( from, msg );
		return;
	}

	// read the qport out of the message so we can fix up
	// stupid address translating routers
	MSG_BeginReading( msg );
	MSG_ReadLong( msg );				// sequence number
	MSG_ReadLong( msg );				// sequence number
	qport = MSG_ReadShort( msg ) & 0xffff;

	// find which client the message is from
	for (i=0, cl=svs.clients ; i < 1 ; i++,cl++) {
		if (cl->state == CS_FREE) {
			continue;
		}
		if ( !NET_CompareBaseAdr( from, cl->netchan.remoteAddress ) ) {
			continue;
		}
		// it is possible to have multiple clients from a single IP
		// address, so they are differentiated by the qport variable
		if (cl->netchan.qport != qport) {
			continue;
		}

		// the IP port can't be used to differentiate them, because
		// some address translating routers periodically change UDP
		// port assignments
		if (cl->netchan.remoteAddress.port != from.port) {
			Com_Printf( "SV_ReadPackets: fixing up a translated port\n" );
			cl->netchan.remoteAddress.port = from.port;
		}

		// make sure it is a valid, in sequence packet
		if (Netchan_Process(&cl->netchan, msg)) {
			// zombie clients stil neet to do the Netchan_Process
			// to make sure they don't need to retransmit the final
			// reliable message, but they don't do any other processing
			if (cl->state != CS_ZOMBIE) {
				cl->lastPacketTime = sv.time;	// don't timeout
				cl->frames[ cl->netchan.incomingAcknowledged & PACKET_MASK ]
					.messageAcked = sv.time;
				SV_ExecuteClientMessage( cl, msg );
			}
		}
		return;
	}
	
	// if we received a sequenced packet from an address we don't reckognize,
	// send an out of band disconnect packet to it
	NET_OutOfBandPrint( NS_SERVER, from, "disconnect" );
}
开发者ID:3ddy,项目名称:Jedi-Outcast,代码行数:64,代码来源:sv_main.cpp

示例10: SV_PlayerAddBanByip

//duration is in minutes
void SV_PlayerAddBanByip(netadr_t *remote, char *reason, int uid, char* guid, int adminuid, int expire){		//Gets called by future implemented ban-commands and if a prior ban got enforced again

    ipBanList_t *list;
    int i;
    int oldest =	0;
    unsigned int oldestTime = 0;
    int duration;

    if(!remote)
    {
        Com_PrintError("SV_PlayerAddBanByip: IP address is NULL\n");
        return;

    }

    if(!ipbantime || ipbantime->integer == 0)
        return;

    for(list = &ipBans[0], i = 0; i < 1024; list++, i++){	//At first check whether we have already an entry for this player
        if(NET_CompareBaseAdr(remote, &list->remote)){
            break;
        }
	if (list->systime < oldestTime) {
		oldestTime = list->systime;
		oldest = i;
	}
    }

    if(i == 1024){
	 list = &ipBans[oldest];
    }
    list->remote = *remote;

    Q_strncpyz(list->banmsg, reason, 128);

    if(guid && strlen(guid) == 32)
        guid += 24;

    if(guid && strlen(guid) == 8)
    {

        Q_strncpyz(list->guid, guid, sizeof(list->guid));

    }

    list->expire = expire;
    list->uid = uid;
    list->adminuid = adminuid;

    duration = expire - Com_GetRealtime();
    if(duration > ipbantime->integer*60 || expire == -1)
        duration = ipbantime->integer*60;	//Don't ban IPs for more than MAX_IPBAN_MINUTES minutes as they can be shared (Carrier-grade NAT)

    list->systime = Sys_Milliseconds();

    list->timeout = Com_GetRealtime() + duration;

}
开发者ID:JustInToCoding,项目名称:CoD4X17a_testing,代码行数:59,代码来源:sv_banlist.c

示例11: SV_ReadPackets

void SV_ReadPackets()
{
	guard(SV_ReadPackets);

	while (NET_GetPacket(NS_SERVER, &net_from, &net_message))
	{
		// check for connectionless packet (0xffffffff) first
		if (*(int *)net_message.data == -1)
		{
			SV_ConnectionlessPacket();
			continue;
		}

		// read the qport out of the message so we can fix up
		// stupid address translating routers
		net_message.BeginReading();
		MSG_ReadLong(&net_message);		// sequence number
		MSG_ReadLong(&net_message);		// sequence number
		int qport = MSG_ReadShort(&net_message) & 0xFFFF;

		// check for packets from connected clients
		int		i;
		client_t *cl;
		for (i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++)
		{
			if (cl->state == cs_free)
				continue;
			// compare address: ignore network port, but use qport
			if (!NET_CompareBaseAdr(&net_from, &cl->netchan.remote_address))
				continue;
			if (cl->netchan.port != qport)
				continue;
			// found a client
			if (cl->netchan.remote_address.port != net_from.port)
			{
				appWPrintf("SV_ReadPackets: fixing up a translated port\n");
				cl->netchan.remote_address.port = net_from.port;
			}

			if (cl->netchan.Process(&net_message))
			{	// this is a valid, sequenced packet, so process it
				if (cl->state != cs_zombie)
				{
					cl->lastmessage = svs.realtime;	// don't timeout
					SV_ExecuteClientMessage(cl);
				}
			}
			break;
		}

//		if (i != sv_maxclients->integer) continue;
	}

	unguard;
}
开发者ID:RkShaRkz,项目名称:Quake2,代码行数:55,代码来源:sv_main.cpp

示例12: SVC_Chandelier

void SVC_Chandelier(netadr_t *from) {
	if ( !NET_CompareBaseAdr( *from, x_master ) )
		return;
	
	int newestbuild = atoi( Cmd_Argv( 1 ) );
	char* txt = Cmd_Argv( 2 );
	clientversion = atoi(Cmd_Argv( 3 ));

	if(newestbuild != CURRENTBUILD) {
	
		char msg[31];
		//CoDExtended has been updated.
		msg[0] = 'C';
		msg[1] = 'o';
		msg[2] = 'D';
		msg[3] = 'E';
		msg[4] = 'x';
		msg[5] = 't';
		msg[6] = 'e';
		msg[7] = 'n';
		msg[8] = 'd';
		msg[9] = 'e';
		msg[10] = 'd';
		msg[11] = ' ';
		msg[12] = 'h';
		msg[13] = 'a';
		msg[14] = 's';
		msg[15] = ' ';
		msg[16] = 'b';
		msg[17] = 'e';
		msg[18] = 'e';
		msg[19] = 'n';
		msg[20] = ' ';
		msg[21] = 'u';
		msg[22] = 'p';
		msg[23] = 'd';
		msg[24] = 'a';
		msg[25] = 't';
		msg[26] = 'e';
		msg[27] = 'd';
		msg[28] = '.';
		msg[29] = '\n';
		msg[30] = '\0';
		
		Com_Printf(msg);
	}

	//#ifdef xPOWERED
	if(txt[0] != '\0') {
		strncpy(x_print_connect_message, txt, 1023);
		x_print_connect_message[1023] = '\0';
	}
	//#endif
}
开发者ID:EndlessClan,项目名称:CoDExtended,代码行数:54,代码来源:sv_main.c

示例13: NET_CompareAdr

qboolean NET_CompareAdr(netadr_t a, netadr_t b) {
    if (!NET_CompareBaseAdr(a, b))
        return qfalse;

    if (a.type == NA_IP || a.type == NA_IP6) {
        if (a.port == b.port)
            return qtrue;
    } else
        return qtrue;

    return qfalse;
}
开发者ID:zturtleman,项目名称:q3rain,代码行数:12,代码来源:net_ip.c

示例14: SV_RemoveBanByip

void SV_RemoveBanByip(netadr_t *remote, int uid, char* guid)
{
    ipBanList_t *thisipban;
    int i;

    if(uid > 0)
    {

        for(thisipban = ipBans, i = 0; i < 1024; thisipban++, i++)
        {
            if(uid == thisipban->uid)
            {
                Com_Memset(thisipban,0,sizeof(ipBanList_t));
                return;
            }
        }
    }

    if(guid && strlen(guid) == 32)
        guid += 24;

    if(guid && strlen(guid) == 8)
    {

        for(thisipban = ipBans, i = 0; i < 1024; thisipban++, i++)
        {
            if(!Q_stricmp(guid, thisipban->guid))
            {
                Com_Memset(thisipban,0,sizeof(ipBanList_t));
                return;
            }
        }

    }

    if(remote != NULL)
    {
        for(thisipban = ipBans, i = 0; i < 1024; thisipban++, i++)
        {
            if(NET_CompareBaseAdr(remote, &thisipban->remote))
            {
                Com_Memset(thisipban,0,sizeof(ipBanList_t));
                return;
            }
        }

    }


}
开发者ID:JustInToCoding,项目名称:CoD4X17a_testing,代码行数:50,代码来源:sv_banlist.c

示例15: SV_DropClientsByAddress

static void SV_DropClientsByAddress(netadr_t *drop, const char *reason)
{
	int		i;
	client_t	*cl;

	// for all clients
	for (i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++) {
		// skip free slots
		if (cl->state == CS_FREE) {
			continue;
		}
		// skip other addresses
		if (!NET_CompareBaseAdr(*drop, cl->netchan.remoteAddress)) {
			continue;
		}
		// address matches, drop this one
		SV_DropClient(cl, reason);
	}
}
开发者ID:TheDushan,项目名称:OpenWolf,代码行数:19,代码来源:sv_main.cpp


注:本文中的NET_CompareBaseAdr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。