Update of /cvsroot/radmind/radmind
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv31525
Modified Files:
connect.c
Log Message:
[ Patch 1833304 ]: Legacy port failover.
Index: connect.c
===================================================================
RCS file: /cvsroot/radmind/radmind/connect.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** connect.c 28 Dec 2006 16:07:17 -0000 1.29
--- connect.c 16 Nov 2007 19:22:08 -0000 1.30
***************
*** 1,4 ****
/*
! * Copyright (c) 2003 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
*/
--- 1,4 ----
/*
! * Copyright (c) 2007 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
*/
***************
*** 34,37 ****
--- 34,40 ----
#include "argcargv.h"
+ #define RADMIND_IANA_PORT 6222
+ #define RADMIND_LEGACY_PORT 6662
+
extern void (*logger)( char * );
extern int verbose;
***************
*** 40,43 ****
--- 43,48 ----
extern SSL_CTX *ctx;
+ int connectsn2_errno = 0;
+
#ifdef HAVE_ZLIB
int zlib_level = 0;
***************
*** 74,83 ****
}
! if ( verbose ) printf( "trying %s... ", inet_ntoa( sin->sin_addr ));
if ( connect( s, (struct sockaddr *)sin,
sizeof( struct sockaddr_in )) != 0 ) {
if ( verbose ) printf( "failed: %s\n", strerror( errno ));
- fprintf( stderr, "connection to %s failed: %s\n",
- inet_ntoa( sin->sin_addr ), strerror( errno ));
(void)close( s );
return( NULL );
--- 79,88 ----
}
! if ( verbose ) printf( "trying %s:%u... ", inet_ntoa( sin->sin_addr ),
! ntohs( sin->sin_port ));
if ( connect( s, (struct sockaddr *)sin,
sizeof( struct sockaddr_in )) != 0 ) {
+ connectsn2_errno = errno;
if ( verbose ) printf( "failed: %s\n", strerror( errno ));
(void)close( s );
return( NULL );
***************
*** 122,129 ****
memcpy( &sin.sin_addr.s_addr, he->h_addr_list[ i ],
(unsigned int)he->h_length );
! if (( sn = connectsn2( &sin )) != NULL ) {
return( sn );
}
}
fprintf( stderr, "%s: connection failed\n", host );
return( NULL );
--- 127,150 ----
memcpy( &sin.sin_addr.s_addr, he->h_addr_list[ i ],
(unsigned int)he->h_length );
!
! /*
! * radmind's original port was 6662, but got
! * registered as 6222 with IANA, and will show
! * up in future /etc/services as 6222. during
! * the transition, fall back to trying the
! * legacy port if the new port connection fails.
! */
! if (( sn = connectsn2( &sin )) == NULL
! && port == htons( RADMIND_IANA_PORT )) {
! /* try connecting to old non-IANA registered port */
! sin.sin_port = htons( RADMIND_LEGACY_PORT );
! sn = connectsn2( &sin );
! }
! if ( sn != NULL ) {
return( sn );
}
}
+ fprintf( stderr, "connection to %s failed: %s\n",
+ inet_ntoa( sin.sin_addr ), strerror( connectsn2_errno ));
fprintf( stderr, "%s: connection failed\n", host );
return( NULL );
|