[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cistron-radius
Subject:    radtest patch to specify port
From:       Brandon Lee Poyner <poyner () staff ! necanet ! net>
Date:       2000-03-28 20:27:31
[Download RAW message or body]

radtest assumes that the server you wish to query is running radius on
the same port as the local host.  Attached is a patch (don't laugh at
my C please ;) that allows the port to be specified on the command
line.  Example use to query port 1812 on remote.server.com.

radtest username passsword remote.server.com:1812 2532 secret

--
Brandon Lee Poyner                                 bpoyner@thebiz.net
NECAnet, part of the BiznessOnline.com network     http://www.neca.com/

["radtestpatch" (TEXT/PLAIN)]

*** radtest.c.orig	Tue Mar 28 15:10:22 2000
--- radtest.c	Tue Mar 28 15:22:13 2000
***************
*** 246,252 ****
   */
  void usage(void)
  {
! 	fprintf(stderr, "Usage: %s username passwd servername nas_port_id secretkey \
[ppphint] [nasname]\n",  progname);
  	exit(1);
  }
--- 246,252 ----
   */
  void usage(void)
  {
! 	fprintf(stderr, "Usage: %s username passwd servername[:port] nas_port_id secretkey \
[ppphint] [nasname]\n",  progname);
  	exit(1);
  }
***************
*** 300,305 ****
--- 300,306 ----
  	int			secretlen;
  	int			i;
  	int			bogus_packet = 0;
+ 	char			*p;
  
  	progname = argv[0];
  
***************
*** 315,320 ****
--- 316,325 ----
  	username  = argv[1];
  	passwd    = argv[2];
  	server    = argv[3];
+ 	if ((p = strchr(server, ':')) != NULL) {
+ 		*p++ = 0;
+ 		svc_port = atoi(p);
+ 	}
  	secretkey = argv[5];
  	ptr = argv[4];
  	if (*ptr == 's' || *ptr == 'S') ptr++;
***************
*** 332,342 ****
  	/*
  	 *	Open a connection to the server.
  	 */
! 	svp = getservbyname ("radius", "udp");
! 	if (svp == (struct servent *) 0)
! 		svc_port = PW_AUTH_UDP_PORT;
! 	else
! 		svc_port = ntohs((u_short) svp->s_port);
  
  	/* Get the IP address of the authentication server */
  	if((auth_ipaddr = get_ipaddr(server)) == 0) {
--- 337,350 ----
  	/*
  	 *	Open a connection to the server.
  	 */
! 
! 	if (!svc_port) {
! 		svp = getservbyname ("radius", "udp");
! 		if (svp == (struct servent *) 0)
! 			svc_port = PW_AUTH_UDP_PORT;
! 		else
! 			svc_port = ntohs((u_short) svp->s_port);
! 	}
  
  	/* Get the IP address of the authentication server */
  	if((auth_ipaddr = get_ipaddr(server)) == 0) {
***************
*** 497,503 ****
  	sin->sin_addr.s_addr = htonl(auth_ipaddr);
  	sin->sin_port = htons(svc_port);
  
! 	printf("Sending request.\n");
  	for (i = 0; i < 10; i++) {
  		if (i > 0) printf("Re-sending request.\n");
  		sendto(sockfd, (char *)auth, total_length, 0,
--- 505,511 ----
  	sin->sin_addr.s_addr = htonl(auth_ipaddr);
  	sin->sin_port = htons(svc_port);
  
! 	printf("Sending request to server %s, port %d\n", server, svc_port);
  	for (i = 0; i < 10; i++) {
  		if (i > 0) printf("Re-sending request.\n");
  		sendto(sockfd, (char *)auth, total_length, 0,



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic