www.pudn.com > RadiusSrv.rar > Client.cpp, change:2003-10-22,size:1152b


#include "../common/GKCommon.h" 
#include "Radiusd.h" 
 
/* 
 *	Find a client in the RADCLIENTS list. 
 */ 
RADCLIENT *client_find(uint32_t ipaddr) 
{ 
//ADCLIENT *cl; 
	RADCLIENT *match = NULL; 
 
/*	for (cl = mainconfig.clients; cl; cl = cl->next) { 
		if ((ipaddr & cl->netmask) == cl->ipaddr) { 
			if ((!match) || 
			    (ntohl(cl->netmask) > ntohl(match->netmask))) { 
				match = cl; 
			} 
		} 
	} 
*/ 
	return match; 
} 
/* 
 *	Find the name of a client (prefer short name). 
 */ 
const char *client_name(uint32_t ipaddr) 
{ 
	/* We don't call this unless we should know about the client. */ 
	RADCLIENT *cl; 
	char host_ipaddr[16]; 
 
	if ((cl = client_find(ipaddr)) != NULL) { 
		if (cl->shortname[0]) 
			return cl->shortname; 
		else 
			return cl->longname; 
	} 
	 
	/*  
	 * this isn't normally reachable, but if a loggable event happens just  
	 * after a client list change and a HUP, then we may not know this  
	 * information any more. 
	 * 
	 * If you see lots of these, then there's something wrong. 
	 */ 
	printf("Trying to look up name of unknown client %s.\n", ip_ntoa(host_ipaddr, ipaddr)); 
 
	return "UNKNOWN-CLIENT"; 
}