--- sbbs/src/sbbs3/ident.c 2018/04/24 16:41:23 1.1 +++ sbbs/src/sbbs3/ident.c 2018/04/24 16:43:30 1.1.1.2 @@ -2,13 +2,13 @@ /* Synchronet Indentification (RFC1413) functions */ -/* $Id: ident.c,v 1.1 2018/04/24 16:41:23 root Exp $ */ +/* $Id: ident.c,v 1.1.1.2 2018/04/24 16:43:30 root Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -38,11 +38,10 @@ #include "sbbs.h" #include "ident.h" -char* identify(SOCKADDR_IN* client_addr, u_short local_port, char* buf +BOOL identify(SOCKADDR_IN* client_addr, u_short local_port, char* buf ,size_t maxlen, int timeout) { char req[128]; - char* identity=NULL; int i; int result; int rd; @@ -51,9 +50,10 @@ char* identify(SOCKADDR_IN* client_addr, SOCKADDR_IN addr; struct timeval tv; fd_set socket_set; + BOOL success=FALSE; - if(timeout<0) - timeout=10; + if(timeout<=0) + timeout=IDENT_DEFAULT_TIMEOUT; do { if((sock = open_socket(SOCK_STREAM, "ident")) == INVALID_SOCKET) { @@ -65,7 +65,7 @@ char* identify(SOCKADDR_IN* client_addr, ioctlsocket(sock,FIONBIO,&val); addr=*client_addr; - addr.sin_port=htons(113); /* per RFC1413 */ + addr.sin_port=htons(IPPORT_IDENT); result=connect(sock, (struct sockaddr*)&addr, sizeof(addr)); @@ -99,7 +99,7 @@ char* identify(SOCKADDR_IN* client_addr, break; } - sprintf(req,"%u, %u\r\n", ntohs(client_addr->sin_port), local_port); + sprintf(req,"%u,%u\r\n", ntohs(client_addr->sin_port), local_port); if(sendsocket(sock,req,strlen(req))!=(int)strlen(req)) { sprintf(buf,"ERROR %d sending request",ERROR_VALUE); break; @@ -124,10 +124,10 @@ char* identify(SOCKADDR_IN* client_addr, } buf[rd]=0; truncsp(buf); - identity=buf; + success=TRUE; } while(0); close_socket(sock); - return(identity); + return success; }