From Tony.Li at procket.com Fri Feb 6 13:50:05 2004 From: Tony.Li at procket.com (Tony Li) Date: Fri, 6 Feb 2004 04:50:05 -0800 Subject: [irrtoolset]Some patches... Message-ID: These diffs are relative to 4.8.1 and resolve a number of issues that I was seeing. Tony Index: README =================================================================== RCS file: /cvs/IRRToolSet/README,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -c -w -r1.1.1.1 -r1.2 *** README 21 Jan 2004 08:12:18 -0000 1.1.1.1 --- README 23 Jan 2004 10:59:35 -0000 1.2 *************** *** 22,29 **** available upon request. INSTALLATION ! 0. To install, you need g++ 2.8.0 or higher, libstdc++-2.8.0 or ! higher, bison, flex and gmake. Please note that the toolset is not gcc3 compliant (yet). For roe and aoe, you also need Tk4.0/Tcl7.4 or higher. If Tcl/Tk --- 22,29 ---- available upon request. INSTALLATION ! 0. To install, you need g++ 2.95.3., libstdc++-2.9.0, bison, flex ! and gmake. Please note that the toolset is not gcc3 compliant (yet). For roe and aoe, you also need Tk4.0/Tcl7.4 or higher. If Tcl/Tk Index: src/Core/util/FixedSizeAllocator.hh =================================================================== RCS file: /cvs/IRRToolSet/src/Core/util/FixedSizeAllocator.hh,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -c -w -r1.1.1.1 -r1.2 *** src/Core/util/FixedSizeAllocator.hh 21 Jan 2004 08:12:18 -0000 1.1.1.1 --- src/Core/util/FixedSizeAllocator.hh 23 Jan 2004 10:41:30 -0000 1.2 *************** *** 1,4 **** ! // $Id: FixedSizeAllocator.hh,v 1.1.1.1 2004/01/21 08:12:18 tli Exp $ // Copyright (c) 2001,2002 RIPE NCC // // All Rights Reserved --- 1,4 ---- ! // $Id: FixedSizeAllocator.hh,v 1.2 2004/01/23 10:41:30 tli Exp $ // Copyright (c) 2001,2002 RIPE NCC // // All Rights Reserved *************** *** 74,79 **** --- 74,81 ---- void get_more_memory() { void *p = malloc(size * count + sizeof(void *)); + assert(p); + * (void **) ((char *) p + size * count) = root; root = p; *************** *** 103,108 **** --- 105,112 ---- void *allocate() { if (!free_ptr) get_more_memory(); + + assert(free_ptr); void *p = free_ptr; free_ptr = * (void **) free_ptr; Index: src/RtConfig/command.l =================================================================== RCS file: /cvs/IRRToolSet/src/RtConfig/command.l,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -c -w -r1.1.1.2 -r1.2 *** src/RtConfig/command.l 23 Jan 2004 09:26:31 -0000 1.1.1.2 --- src/RtConfig/command.l 23 Jan 2004 10:28:21 -0000 1.2 *************** *** 18,24 **** // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // ! // $Id: command.l,v 1.1.1.2 2004/01/23 09:26:31 tli Exp $ // // Copyright (c) 1994 by the University of Southern California // All rights reserved. --- 18,24 ---- // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // ! // $Id: command.l,v 1.2 2004/01/23 10:28:21 tli Exp $ // // Copyright (c) 1994 by the University of Southern California // All rights reserved. *************** *** 152,157 **** --- 152,162 ---- LEXER_RETURN((int) *yytext); } + \r { + /* Ignore this character. It's likely that our input is */ + /* a DOS or MAC file. */ + } + . { ECHO; /* simply skip this line, it is not interesting to us */ *************** *** 171,176 **** --- 176,186 ---- LEXER_RETURN((int) *yytext); } + \r { + /* Ignore this character. It's likely that our input is */ + /* a DOS or MAC file. */ + } + [Aa][Ss][0-9]+ { yylval.as = atoi(yytext+2); LEXER_RETURN(TKN_ASNUM); *************** *** 208,213 **** --- 218,229 ---- } filter\ .* { + char *tmp; + + tmp = strchr(yytext, '\r'); + if (tmp) { + *tmp = 0; + } yylval.val = yytext + 7; LEXER_RETURN(TKN_FILTER); } *************** *** 220,225 **** --- 236,246 ---- yylineno++; BEGIN(INITIAL); LEXER_RETURN((int) *yytext); + } + + \r { + /* Ignore this character. It's likely that our input is */ + /* a DOS or MAC file. */ } = { Index: src/RtConfig/command.y =================================================================== RCS file: /cvs/IRRToolSet/src/RtConfig/command.y,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -c -w -r1.1.1.2 -r1.2 *** src/RtConfig/command.y 23 Jan 2004 09:26:31 -0000 1.1.1.2 --- src/RtConfig/command.y 23 Jan 2004 10:27:49 -0000 1.2 *************** *** 18,24 **** // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // ! // $Id: command.y,v 1.1.1.2 2004/01/23 09:26:31 tli Exp $ // // Copyright (c) 1994 by the University of Southern California // All rights reserved. --- 18,24 ---- // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // ! // $Id: command.y,v 1.2 2004/01/23 10:27:49 tli Exp $ // // Copyright (c) 1994 by the University of Southern California // All rights reserved. *************** *** 449,455 **** extern char *yytext; int yyerror(char *s) { ! cerr << "Error in template file\n"; return(0); } --- 449,455 ---- extern char *yytext; int yyerror(char *s) { ! cerr << "Error in template file, line " << yylineno << "\n"; return(0); } Index: src/RtConfig/f_cisco.cc =================================================================== RCS file: /cvs/IRRToolSet/src/RtConfig/f_cisco.cc,v retrieving revision 1.1.1.2 diff -c -w -r1.1.1.2 f_cisco.cc *** src/RtConfig/f_cisco.cc 23 Jan 2004 09:26:31 -0000 1.1.1.2 --- src/RtConfig/f_cisco.cc 6 Feb 2004 12:37:51 -0000 *************** *** 1170,1176 **** for (i = cmp->start; i <= cmp->end; i++) cout << " match community " << i << (cmp->flag ? " exact\n" : "\n"); ! if (!import_flag || forcedInboundMatchIP) { for (prp = prfx_acls->head(); prp; prp =prfx_acls->next(prp)) { for (i = prp->start; i <= prp->end; i++) { if (usePrefixLists) --- 1170,1176 ---- for (i = cmp->start; i <= cmp->end; i++) cout << " match community " << i << (cmp->flag ? " exact\n" : "\n"); ! if ((!import_flag || forcedInboundMatchIP) && prfx_acls) { for (prp = prfx_acls->head(); prp; prp =prfx_acls->next(prp)) { for (i = prp->start; i <= prp->end; i++) { if (usePrefixLists) Index: src/irr/rawhoisc.cc =================================================================== RCS file: /cvs/IRRToolSet/src/irr/rawhoisc.cc,v retrieving revision 1.1.1.2 diff -c -w -r1.1.1.2 rawhoisc.cc *** src/irr/rawhoisc.cc 23 Jan 2004 09:26:31 -0000 1.1.1.2 --- src/irr/rawhoisc.cc 6 Feb 2004 12:37:51 -0000 *************** *** 98,103 **** --- 98,106 ---- #ifndef HAVE_MEMCPY # define memcpy(d, s, n) bcopy ((s), (d), (n)) #endif + #ifndef BUFFER_SIZE + # define BUFFER_SIZE 2048 + #endif } void RAWhoisClient::Open(const char *_host, const int _port, const char *_sources) { *************** *** 168,173 **** --- 171,192 ---- _is_open = 0; } + void RAWhoisClient::CheckConnection() { + + if (!_is_open) + return; + + if (feof(in)) { + Trace(TR_WHOIS_QUERY) << "Whois: Closed" << endl; + + _is_open = 0; + fclose(in); + fclose(out); + + version = 0; // Don't know who we're talking to now + } + } + void RAWhoisClient::GetVersion() { char *buffer = (char *) calloc (80,1); char *start; *************** *** 256,269 **** // Read the "A" line if (! fgets(buffer, sizeof(buffer), in)) { ! error.Die("Error: fgets() failed.\n"); return 0; } Trace(TR_WHOIS_RESPONSE) << "Whois: Response " << buffer << endl; if (*buffer == 'D') { // key not found error ! error.warning("Warning: key not found error for query %s.\n", last_query); return 0; } if (*buffer == 'C') { // returned success --- 275,289 ---- // Read the "A" line if (! fgets(buffer, sizeof(buffer), in)) { ! error.Die("Error: fgets() failed, no answer.\n"); return 0; } Trace(TR_WHOIS_RESPONSE) << "Whois: Response " << buffer << endl; if (*buffer == 'D') { // key not found error ! error.warning("Warning: key not found error for query %s.\n", ! last_query); return 0; } if (*buffer == 'C') { // returned success *************** *** 279,292 **** return 0; } if (is_rpslng()) { ! char result[1024]; ! memset(result, 0, strlen(result)); ! char prev[1024]; ! memset(prev, 0, strlen(prev)); do { if (strstr (buffer, "route") || strstr(buffer, "route6")) { char *prefix; ! char end_prefix[1024]; prefix = strstr(buffer, ":"); do { prefix++; --- 299,321 ---- return 0; } if (is_rpslng()) { ! char prev[BUFFER_SIZE]; ! char result[BUFFER_SIZE]; ! int first = 1; ! ! memset(result, 0, BUFFER_SIZE); ! memset(prev, 0, BUFFER_SIZE); do { + if (first) { + first = 0; + } else { + Trace(TR_WHOIS_RESPONSE) << "Whois: Response " << buffer; + } + if (strstr (buffer, "route") || strstr(buffer, "route6")) { char *prefix; ! char end_prefix[BUFFER_SIZE]; ! prefix = strstr(buffer, ":"); do { prefix++; *************** *** 298,310 **** } } while (fgets(buffer, sizeof(buffer), in) && !((*prev == '\n') && (*buffer == '\n'))); - //} while (fgets(buffer, sizeof(buffer), in) && - // !(*buffer == '\n')); ! int count = atoi(result); response = new char [count]; ! memset(response, 0, strlen(response)); ! strncpy(response, result, strlen(result)); return count; // provide the char count } --- 327,344 ---- } } while (fgets(buffer, sizeof(buffer), in) && !((*prev == '\n') && (*buffer == '\n'))); ! // Unfortunately, the syntax is such that there is no obvious ! // way to tell when this response is complete. The server may ! // just time us out. If so, we need to reopen the connection. ! CheckConnection(); ! ! int count = strlen(result) + 1; response = new char [count]; ! assert(response); ! memset(response, 0, count); ! strncpy(response, result, count); ! response[count - 1] = '\0'; return count; // provide the char count } *************** *** 319,325 **** // Read the return code line if (!fgets(buffer, sizeof(buffer), in)) { ! error.Die("Error: fgets() failed.\n"); return 0; } --- 353,360 ---- // Read the return code line if (!fgets(buffer, sizeof(buffer), in)) { ! error.Die("Error: fgets() of return code failed in " ! "RAWhoisClient::Response\n"); return 0; } Index: src/irr/rawhoisc.hh =================================================================== RCS file: /cvs/IRRToolSet/src/irr/rawhoisc.hh,v retrieving revision 1.1.1.2 diff -c -w -r1.1.1.2 rawhoisc.hh *** src/irr/rawhoisc.hh 23 Jan 2004 09:26:31 -0000 1.1.1.2 --- src/irr/rawhoisc.hh 6 Feb 2004 12:37:51 -0000 *************** *** 131,136 **** --- 131,138 ---- void Close(); + void CheckConnection(); + void SetSources(const char *_sources = dflt_sources); // Modified by wlee at isi.edu From glen.turner at aarnet.edu.au Tue Feb 10 05:30:01 2004 From: glen.turner at aarnet.edu.au (Glen Turner) Date: Tue, 10 Feb 2004 15:00:01 +1030 Subject: [irrtoolset]Making IRRToolSet compile... Message-ID: <1076387401.7108.30.camel@andromache> Tony Li wrote: > prefix.hh:377: parse error before `and' Because ISO C++ says 'and' is a lexical synonym for '&&'. You'll need to rename the function (I used 'pand'). > It seems to me that if you want others to help with this project, > we either need to be a tad more portable in our coding or we > need to be extremely specific about which tools are approved > for use. Hi Katie, Could I encourage you to port the source code to ISO C++? I've made a start, and my compiling but segfaulting patches are at http://www.aarnet.edu.au/~gdt/patch/ I wasn't going to post to the list until they were running, but I felt I should contribute them now as they make the case that the move to ISO C++ is simply drudgery (this is the first time I've used C++, so there can't be any wizard knowledge required). There's only a handful of code that needs rewriting, the same compile errors simply appear many times. When I'm finished, would you accept a patch to move the codebase to ISO C++ (and thus compile under GCC3.2.2)? I don't particularly want to end up maintaining a fork. Finally, I notice the code uses the discontinued libg++ (included as source). Perhaps in the longer term this could be replaced by the STL (and Boost, if needed)? Regards, Glen -- Glen Turner Tel: (08) 8303 3936 or +61 8 8303 3936 Network Engineer Australian Academic & Research Network www.aarnet.edu.au From glen.turner at aarnet.edu.au Tue Feb 17 06:25:48 2004 From: glen.turner at aarnet.edu.au (Glen Turner) Date: Tue, 17 Feb 2004 15:55:48 +1030 Subject: [irrtoolset]Re: Making IRRToolSet compile Message-ID: <1076995548.13951.10.camel@andromache> I have completed porting the IRRToolSet source code to ISO C++ (gcc 3.3). For the patchset see the most recently-dated irrtoolset-*.patch file at http://www.aarnet.edu.au/~gdt/patch/irrtoolset/ The patchset incorporates the patches posted by Tony Li last week. See README-GDT for details. Testing, platform successes/issues and bug reports welcomed. Enjoy, Glen