From greearb at candelatech.com Sat Mar 3 14:06:22 2012 From: greearb at candelatech.com (Ben Greear) Date: Sat, 03 Mar 2012 14:06:22 -0800 Subject: [Xorp-hackers] [PATCH] xorp: Automatically generate lex and yacc files + added support for uint64 type In-Reply-To: <1330535244-28820-1-git-send-email-igorm@etf.rs> References: <1330535244-28820-1-git-send-email-igorm@etf.rs> Message-ID: <4F5295DE.1090102@candelatech.com> On 02/29/2012 09:07 AM, igorm at etf.rs wrote: > From: Igor Maravic > > In xorp/site_scons/config/allconfig.py added checks if 'flex' and 'bison' are installed. > If they aren't instructs user how to install them (instructions are for Ubuntu and Fedora). > Flex and Bison could install on Windows, but I didn't check that. As far as I know, the only want to compile xorp for windows is to use a mingw cross-compiler on Linux (at least, that is how I do it), so that might be OK. > Deleted all yacc and lex files from xorp/rtrmgr. They should be automatically generated with flex. > > Change xorp/rtrmgr/SConscript to automatically generate yacc and lex files with bison and flex. > In CPPPATH added env['xorp_sorcedir'] so generated files could include necessary files. > Also did minor changes in .yy and .ll files, so they would compile. > > In all .yy and .ll files added support for uint64 and uin64range types. Their nodes are called > NODE_ULONG and NODE_ULONGRANGE respectively. > > In range.hh added U64Range class. Does everything as U32Range, but with uint64_t instead of uint32_t variables. > > In template_tree_node.cc and template_tree_node.hh added ULongTemplate and ULongRangeTemplate to handle new types. > > Unfortunately Eclipse striped whitespaces from changed files, so they are meshed up with the changed code. This patch is huge. I understand that most of it is just deleting files, but can you please split this up so that the file deletes are one commit and the other changes are in one or more commits? Maybe do the changes to sconscript, update the .yy and .lo files, add the new u64 types, and then as a last commit, remove the auto-generated files? And, instead of sending a git patch to remove the files, maybe just post the 'git rm ...' command and I'll just run that? Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From vvm at tut.by Sun Mar 11 07:22:05 2012 From: vvm at tut.by (Victor Miasnikov) Date: Sun, 11 Mar 2012 17:22:05 +0300 Subject: [Xorp-hackers] [PATCH] add copy libstdc++-6.dll in win32_pkg.bash Message-ID: <290361B22AB84E82BBCF54179229C89D@local.st.by> Hi! Patch for add copy libstdc++-6.dll in win32_pkg.bash == --- xorp/win32_pkg.bash.orig Wed Feb 29 09:11:46 2012 +++ xorp/win32_pkg.bash Sun Mar 11 16:40:29 2012 @@ -55,6 +55,7 @@ cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libcrypto-10.dll /usr/local/xorp/sbin/ || exit 3 cp /usr/i686-pc-mingw32/sys-root/mingw/bin/zlib1.dll /usr/local/xorp/sbin/ || exit 4 cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libgcc_s_sjlj-1.dll /usr/local/xorp/sbin/ || exit 5 +cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libstdc++-6.dll /usr/local/xorp/sbin/ || exit 8 cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libgnurx-0.dll /usr/local/xorp/sbin/ || exit 6 == Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ P.S. + small patch == --- README.orig Wed Feb 29 09:11:46 2012 +++ README Sun Mar 11 16:37:16 2012 @@ -51,7 +51,7 @@ 2. Status ========= -This is XORP Release 1.8.3 +This is XORP Release 1.8.5 Supported platforms: == From greearb at candelatech.com Sun Mar 11 19:59:08 2012 From: greearb at candelatech.com (Ben Greear) Date: Sun, 11 Mar 2012 19:59:08 -0700 Subject: [Xorp-hackers] [PATCH] add copy libstdc++-6.dll in win32_pkg.bash In-Reply-To: <290361B22AB84E82BBCF54179229C89D@local.st.by> References: <290361B22AB84E82BBCF54179229C89D@local.st.by> Message-ID: <4F5D667C.8010005@candelatech.com> On 03/11/2012 07:22 AM, Victor Miasnikov wrote: > > Hi! > > Patch for add copy libstdc++-6.dll in win32_pkg.bash Can you use git format-patch to create the patch and then git send-email to send it? That way I can just apply it and you will get credit for the patch in the commit log. Thanks, Ben > > == > --- xorp/win32_pkg.bash.orig Wed Feb 29 09:11:46 2012 > +++ xorp/win32_pkg.bash Sun Mar 11 16:40:29 2012 > @@ -55,6 +55,7 @@ > cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libcrypto-10.dll > /usr/local/xorp/sbin/ || exit 3 > cp /usr/i686-pc-mingw32/sys-root/mingw/bin/zlib1.dll /usr/local/xorp/sbin/ > || exit 4 > cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libgcc_s_sjlj-1.dll > /usr/local/xorp/sbin/ || exit 5 > +cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libstdc++-6.dll > /usr/local/xorp/sbin/ || exit 8 > cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libgnurx-0.dll > /usr/local/xorp/sbin/ || exit 6 > == > > > Best regards, Victor Miasnikov > Blog: http://vvm.blog.tut.by/ > > P.S. > > + small patch > > == > --- README.orig Wed Feb 29 09:11:46 2012 > +++ README Sun Mar 11 16:37:16 2012 > @@ -51,7 +51,7 @@ > 2. Status > ========= > > -This is XORP Release 1.8.3 > +This is XORP Release 1.8.5 > > Supported platforms: > == > > _______________________________________________ > Xorp-hackers mailing list > Xorp-hackers at icir.org > http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers -- Ben Greear Candela Technologies Inc http://www.candelatech.com From vvm at tut.by Mon Mar 12 04:19:38 2012 From: vvm at tut.by (Victor Miasnikov) Date: Mon, 12 Mar 2012 14:19:38 +0300 Subject: [Xorp-hackers] [PATCH] README This is XORP Release 1.8.5 {-- 1.8.3 Message-ID: <99294C96FD904775B4E10CE5FE3FFDFD@local.st.by> From: Victor Miasnikov README This is XORP Release 1.8.5 {-- 1.8.3 Signed-off-by: Victor Miasnikov --- README | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/README b/README index 43a6a48..1496de6 100644 --- a/README +++ b/README @@ -51,7 +51,7 @@ paper available from http://www.xorp.org/ : 2. Status ========= -This is XORP Release 1.8.3 +This is XORP Release 1.8.5 Supported platforms: -- 1.7.9.msysgit.0 From vvm at tut.by Mon Mar 12 05:35:03 2012 From: vvm at tut.by (Victor Miasnikov) Date: Mon, 12 Mar 2012 15:35:03 +0300 Subject: [Xorp-hackers] [PATCH] windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash 1) libstdc++-6.dll 2) change order exit errors 3) update notes mingw32 packages Message-ID: From: Victor Miasnikov windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash 1) add copy libstdc++-6.dll in win32_pkg.bash 2) change order exit errors numbers i.e. first common issue, last -- copy *.dll related 3) update notes about Fedora cross-compile packages ( mingw32-* ) Signed-off-by: Victor Miasnikov --- xorp/win32_pkg.bash | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-) diff --git a/xorp/win32_pkg.bash b/xorp/win32_pkg.bash index a7fa284..b0a5030 100755 --- a/xorp/win32_pkg.bash +++ b/xorp/win32_pkg.bash @@ -4,20 +4,20 @@ # This needs to be run as root (or via sudo) to have a good # chance of working... -# This works on modern Fedora, with these pkgs installed: +# This works on modern Fedora ( on 2012-03-12: Fedora 16), with these pkgs installed: #mingw32-pdcurses-3.4-8.fc15.noarch -#mingw32-cpp-4.5.3-1.fc15.i686 -#mingw32-binutils-2.21-1.fc15.i686 -#mingw32-w32api-3.15-2.fc15.noarch -#mingw32-openssl-1.0.0d-1.fc15.noarch +#mingw32-cpp-4.6.1-3.fc16.i686 +#mingw32-binutils-2.21-2.fc16.i686 +#mingw32-w32api-3.17-1.fc16.noarch +#mingw32-openssl-1.0.0d-1.fc16.noarch #mingw32-libgnurx-2.5.1-7.fc15.noarch -#mingw32-zlib-1.2.5-3.fc15.noarch -#mingw32-gcc-c++-4.5.3-1.fc15.i686 -#mingw32-gcc-4.5.3-1.fc15.i686 -#mingw32-runtime-3.15.2-5.fc13.noarch -#mingw32-pthreads-2.8.0-13.fc15.noarch -#mingw32-filesystem-69-3.fc15.noarch +#mingw32-zlib-1.2.5-5.fc16.noarch +#mingw32-gcc-c++-4.6.1-3.fc16.i686 +#mingw32-gcc-4.6.1-3.fc16.i686 +#mingw32-runtime-3.18-4.fc16.noarch +#mingw32-pthreads-2.8.0-15.20110511cvs.fc16.noarch +#mingw32-filesystem-69-11.fc16.noarch # In addition, you need the fix listed in this bug: #http://lists.fedoraproject.org/pipermail/mingw/2011-February/003442.html @@ -52,10 +52,12 @@ scons $SARGS install || exit 2 echo "Copy some files..." # Copy some run-time libraries to the xorp dir for packaging -cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libcrypto-10.dll /usr/local/xorp/sbin/ || exit 3 cp /usr/i686-pc-mingw32/sys-root/mingw/bin/zlib1.dll /usr/local/xorp/sbin/ || exit 4 cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libgcc_s_sjlj-1.dll /usr/local/xorp/sbin/ || exit 5 cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libgnurx-0.dll /usr/local/xorp/sbin/ || exit 6 +cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libcrypto-10.dll /usr/local/xorp/sbin/ || exit 7 +cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libstdc++-6.dll /usr/local/xorp/sbin/ || exit 8 + PWD=$(pwd) @@ -66,7 +68,7 @@ then userdir = "./" fi -cd /usr/local || exit 7 +cd /usr/local || exit 3 if [ ! -d ${userdir}tmp ] then -- 1.7.9.msysgit.0 From vvm at tut.by Mon Mar 12 08:35:50 2012 From: vvm at tut.by (Victor Miasnikov) Date: Mon, 12 Mar 2012 18:35:50 +0300 Subject: [Xorp-hackers] xorprtm4.dll / xorprtm6.dll Fw: RTMv2 Or XORP and RRAS ( Routing and Remote Access Services) Fw: XORP on Windows Message-ID: Hi! Please, "undelete" on GIT source code of xorprtm4.dll / xorprtm6.dll xorp.ct/contrib/win32/xorprtm/ Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ From greearb at candelatech.com Mon Mar 12 11:33:57 2012 From: greearb at candelatech.com (Ben Greear) Date: Mon, 12 Mar 2012 11:33:57 -0700 Subject: [Xorp-hackers] [PATCH] windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash 1) libstdc++-6.dll 2) change order exit errors 3) update notes mingw32 packages In-Reply-To: References: Message-ID: <4F5E4195.5080703@candelatech.com> On 03/12/2012 05:35 AM, Victor Miasnikov wrote: > From: Victor Miasnikov > > windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash > > 1) add copy libstdc++-6.dll in win32_pkg.bash > > 2) change order exit errors numbers > i.e. first common issue, last -- copy *.dll related > > 3) update notes about Fedora cross-compile packages ( mingw32-* ) > > Signed-off-by: Victor Miasnikov > --- > xorp/win32_pkg.bash | 28 +++++++++++++++------------- > 1 files changed, 15 insertions(+), 13 deletions(-) > > diff --git a/xorp/win32_pkg.bash b/xorp/win32_pkg.bash > index a7fa284..b0a5030 100755 > --- a/xorp/win32_pkg.bash > +++ b/xorp/win32_pkg.bash > @@ -4,20 +4,20 @@ > # This needs to be run as root (or via sudo) to have a good > # chance of working... > > -# This works on modern Fedora, with these pkgs installed: > +# This works on modern Fedora ( on 2012-03-12: Fedora 16), with these pkgs installed: > > #mingw32-pdcurses-3.4-8.fc15.noarch > -#mingw32-cpp-4.5.3-1.fc15.i686 > -#mingw32-binutils-2.21-1.fc15.i686 > -#mingw32-w32api-3.15-2.fc15.noarch > -#mingw32-openssl-1.0.0d-1.fc15.noarch > +#mingw32-cpp-4.6.1-3.fc16.i686 > +#mingw32-binutils-2.21-2.fc16.i686 > +#mingw32-w32api-3.17-1.fc16.noarch > +#mingw32-openssl-1.0.0d-1.fc16.noarch > #mingw32-libgnurx-2.5.1-7.fc15.noarch > -#mingw32-zlib-1.2.5-3.fc15.noarch > -#mingw32-gcc-c++-4.5.3-1.fc15.i686 > -#mingw32-gcc-4.5.3-1.fc15.i686 > -#mingw32-runtime-3.15.2-5.fc13.noarch > -#mingw32-pthreads-2.8.0-13.fc15.noarch > -#mingw32-filesystem-69-3.fc15.noarch > +#mingw32-zlib-1.2.5-5.fc16.noarch > +#mingw32-gcc-c++-4.6.1-3.fc16.i686 > +#mingw32-gcc-4.6.1-3.fc16.i686 > +#mingw32-runtime-3.18-4.fc16.noarch > +#mingw32-pthreads-2.8.0-15.20110511cvs.fc16.noarch > +#mingw32-filesystem-69-11.fc16.noarch > > # In addition, you need the fix listed in this bug: > #http://lists.fedoraproject.org/pipermail/mingw/2011-February/003442.html > @@ -52,10 +52,12 @@ scons $SARGS install || exit 2 > > echo "Copy some files..." > # Copy some run-time libraries to the xorp dir for packaging > -cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libcrypto-10.dll /usr/local/xorp/sbin/ || exit 3 > cp /usr/i686-pc-mingw32/sys-root/mingw/bin/zlib1.dll /usr/local/xorp/sbin/ || exit 4 > cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libgcc_s_sjlj-1.dll /usr/local/xorp/sbin/ || exit 5 > cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libgnurx-0.dll /usr/local/xorp/sbin/ || exit 6 > +cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libcrypto-10.dll /usr/local/xorp/sbin/ || exit 7 > +cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libstdc++-6.dll /usr/local/xorp/sbin/ || exit 8 > + This is going to break builds on Fedora 13 (and/or with older mingw packages). Can you change it so that if the copy of the libstdc++-6.dll fails it just prints a warning and continues? And, instead of removing the older mingw packages, just add a new section documenting what you are using on F16. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Mon Mar 12 11:35:17 2012 From: noreply at github.com (GitHub) Date: Mon, 12 Mar 2012 11:35:17 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] a1a2b4: README This is XORP Release 1.8.5 {-- 1.8.3 Message-ID: <4f5e41e57b8f_50b1acbaec2853e@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: a1a2b4f1b9f98fedb5c53487137a52f0d6076e38 https://github.com/greearb/xorp.ct/commit/a1a2b4f1b9f98fedb5c53487137a52f0d6076e38 Author: Victor Miasnikov Date: 2012-03-12 (Mon, 12 Mar 2012) Changed paths: M README Log Message: ----------- README This is XORP Release 1.8.5 {-- 1.8.3 README This is XORP Release 1.8.5 {-- 1.8.3 Signed-off-by: Victor Miasnikov From igorm at etf.rs Tue Mar 13 03:10:56 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:10:56 +0100 Subject: [Xorp-hackers] [PATCH] trivial: trailing ws removed In-Reply-To: References: Message-ID: <1331633456-840-1-git-send-email-igorm@etf.rs> From: Igor Maravic Signed-off-by: Igor Maravic --- xorp/cli/cli_client.cc | 140 ++++++++++++++++++++++++------------------------ 1 files changed, 70 insertions(+), 70 deletions(-) diff --git a/xorp/cli/cli_client.cc b/xorp/cli/cli_client.cc index d9aea1f..a2d8e3b 100644 --- a/xorp/cli/cli_client.cc +++ b/xorp/cli/cli_client.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -144,7 +144,7 @@ CliClient::~CliClient() string dummy_error_msg; stop_connection(dummy_error_msg); - + set_log_output(false); // Remove the input file descriptor from the eventloop @@ -174,7 +174,7 @@ CliClient::~CliClient() if (_gl != NULL) _gl = del_GetLine(_gl); - + delete_pipe_all(); } @@ -208,7 +208,7 @@ CliClient::set_log_output(bool v) _is_log_output = false; return (XORP_OK); } - + // NOTERACHED return (XORP_ERROR); } @@ -257,7 +257,7 @@ CliPipe * CliClient::add_pipe(const string& pipe_name) { CliPipe *cli_pipe; - + cli_pipe = new CliPipe(pipe_name); if (cli_pipe->is_invalid()) { delete cli_pipe; @@ -266,7 +266,7 @@ CliClient::add_pipe(const string& pipe_name) _pipe_list.push_back(cli_pipe); cli_pipe->set_cli_client(this); set_pipe_mode(true); - + return (cli_pipe); } @@ -274,18 +274,18 @@ CliPipe * CliClient::add_pipe(const string& pipe_name, const list& args_list) { CliPipe *cli_pipe; - + cli_pipe = add_pipe(pipe_name); if (cli_pipe == NULL) return (NULL); - + // Add the list of arguments list::const_iterator iter; for (iter = args_list.begin(); iter != args_list.end(); ++iter) { string arg = *iter; cli_pipe->add_pipe_arg(arg); } - + return (cli_pipe); } @@ -315,10 +315,10 @@ void CliClient::process_line_through_pipes(string& pipe_line) { list::iterator iter; - + if (! is_pipe_mode()) return; - + for (iter = _pipe_list.begin(); iter != _pipe_list.end(); ++iter) { CliPipe *cli_pipe = *iter; cli_pipe->process_func(pipe_line); @@ -332,13 +332,13 @@ void CliClient::set_page_mode(bool v) { const char *s; - + if (v) { // TRUE if (_is_page_mode) return; _is_page_mode = v; - + // // Save the key bind commands // @@ -383,7 +383,7 @@ CliClient::set_page_mode(bool v) = (s = gl_get_key_binding_action_name(gl(), "^U")) ? (s) : ""; _action_name_ctrl_x = (s = gl_get_key_binding_action_name(gl(), "^X")) ? (s) : ""; - + // // Set new binding // @@ -470,14 +470,14 @@ CliClient::set_page_mode(bool v) bind_command = "bind ^X user-event4"; gl_configure_getline(gl(), bind_command.c_str(), NULL, NULL); } - + return; } else { // FALSE if (! _is_page_mode) return; _is_page_mode = v; - + // // Restore the key bind commands // @@ -562,7 +562,7 @@ CliClient::set_page_mode(bool v) bind_command = "bind ^X " + _action_name_ctrl_x; gl_configure_getline(gl(), bind_command.c_str(), NULL, NULL); } - + return; } } @@ -687,7 +687,7 @@ CliClient::cli_print(const string& msg) is_incomplete_last_line = true; break; } while (false); - + // Process the data throught the pipe pipe_line += _buffer_line; _buffer_line = ""; @@ -715,7 +715,7 @@ CliClient::cli_print(const string& msg) pipe_result += pipe_line; pipe_line = ""; } - + // If a terminal connection, add '\r' before each '\n' // (unless the previous character to print is indeed '\r'). pipe_line = ""; @@ -773,12 +773,12 @@ CliClient::cli_print(const string& msg) if (pipe_line.size()) output_string += pipe_line; // XXX: the remaining partial line } - + ret_value = output_string.size(); // if (! (is_page_buffer_mode() && is_page_mode())) if (output_string.size()) ret_value = fprintf(_output_fd_file, "%s", output_string.c_str()); - + return (ret_value); } @@ -814,7 +814,7 @@ CliClient::process_char_page_mode(uint8_t val) { string restore_cli_prompt = current_cli_prompt(); // The current prompt bool old_page_buffer_mode = is_page_buffer_mode(); - + // // Reset the line and clear the current prompt // @@ -823,8 +823,8 @@ CliClient::process_char_page_mode(uint8_t val) set_current_cli_prompt(""); gl_reset_line(gl()); cli_flush(); - - + + // // Page commands // @@ -872,7 +872,7 @@ CliClient::process_char_page_mode(uint8_t val) } goto redisplay_screen_label; } - + // // Interrupt the display of output // @@ -886,7 +886,7 @@ CliClient::process_char_page_mode(uint8_t val) } goto exit_page_mode_label; } - + // // Scroll down one line // @@ -904,7 +904,7 @@ CliClient::process_char_page_mode(uint8_t val) } goto redisplay_line_label; } - + // // Scroll down one-half screen // @@ -925,7 +925,7 @@ CliClient::process_char_page_mode(uint8_t val) } goto redisplay_line_label; } - + // // Scroll down one whole screen // @@ -944,7 +944,7 @@ CliClient::process_char_page_mode(uint8_t val) } goto redisplay_line_label; } - + // // Scroll down to the bottom of the output // @@ -953,7 +953,7 @@ CliClient::process_char_page_mode(uint8_t val) set_page_buffer_last_line_n(page_buffer_lines_n()); goto redisplay_screen_label; } - + // // Display the output all at once instead of oen screen at a time. // (Same as specifying the "| no-more" command.) @@ -970,7 +970,7 @@ CliClient::process_char_page_mode(uint8_t val) // goto exit_page_mode_label; goto redisplay_line_label; } - + // // Display the previous line of output // @@ -982,7 +982,7 @@ CliClient::process_char_page_mode(uint8_t val) decr_page_buffer_last_line_n(); goto redisplay_screen_label; } - + // // Scroll up one-half screen // @@ -995,7 +995,7 @@ CliClient::process_char_page_mode(uint8_t val) } goto redisplay_screen_label; } - + // // Scroll up one whole screen // @@ -1008,7 +1008,7 @@ CliClient::process_char_page_mode(uint8_t val) } goto redisplay_screen_label; } - + // // Scroll up to the top of the output // @@ -1017,7 +1017,7 @@ CliClient::process_char_page_mode(uint8_t val) set_page_buffer_last_line_n(0); goto redisplay_screen_label; } - + // // Redraw the output of the screen // @@ -1048,9 +1048,9 @@ CliClient::process_char_page_mode(uint8_t val) set_page_buffer_mode(old_page_buffer_mode); goto redisplay_line_label; } - + goto redisplay_line_label; - + exit_page_mode_label: reset_page_buffer(); if (is_interactive()) @@ -1071,7 +1071,7 @@ CliClient::process_char_page_mode(uint8_t val) goto redisplay_screen_label; } // FALLTHROUGH - + redisplay_line_label: cli_flush(); if (is_page_mode()) { @@ -1096,7 +1096,7 @@ CliClient::post_process_command() // We are waiting for the result; silently return. return; } - + // // Reset the state for the currently executed command // @@ -1108,7 +1108,7 @@ CliClient::post_process_command() // Pipe-process the result // string final_string = ""; - + cli_print(""); // XXX: EOF: clear-out the pipe list::iterator iter; for (iter = _pipe_list.begin(); iter != _pipe_list.end(); ++iter) { @@ -1127,10 +1127,10 @@ CliClient::post_process_command() set_hold_mode(false); } delete_pipe_all(); - + if (! is_page_mode()) reset_page_buffer(); - + // // Page-related state // @@ -1145,7 +1145,7 @@ CliClient::post_process_command() if (is_interactive()) set_nomore_mode(false); } - + // // Reset buffer, cursor, prompt // @@ -1210,7 +1210,7 @@ CliClient::process_char(const string& line, uint8_t val, bool& stop_processing) { int gl_buff_curpos = gl_get_buff_curpos(gl()); int ret_value = XORP_OK; - + stop_processing = false; if ((val == '\n') || (val == '\r')) { @@ -1230,7 +1230,7 @@ CliClient::process_char(const string& line, uint8_t val, bool& stop_processing) return (XORP_OK); } - + if (val == '?') { // Command-line help //set_page_buffer_mode(true); @@ -1250,7 +1250,7 @@ CliClient::process_char(const string& line, uint8_t val, bool& stop_processing) //set_buff_curpos(0); return (XORP_OK); } - + // // XXX: The (val == ' ') and 'Ctrl-C' cases are handled by the // parent function. @@ -1280,7 +1280,7 @@ CliClient::process_char(const string& line, uint8_t val, bool& stop_processing) return (XORP_ERROR); } set_buff_curpos(gl_buff_curpos); - + return (XORP_OK); } @@ -1290,7 +1290,7 @@ CliClient::process_char(const string& line, uint8_t val, bool& stop_processing) * @line: The current command line. * @word_end: The cursor position. * @remove_last_input_char: If true, then remove the last input character. - * + * * Print the help for the same-line command. **/ void @@ -1300,7 +1300,7 @@ CliClient::command_line_help(const string& line, int word_end, CliCommand *curr_cli_command = _current_cli_command; set command_help_strings; bool is_found = false; - + if (remove_last_input_char) word_end--; // XXX: exclude the '?' character @@ -1327,7 +1327,7 @@ CliClient::command_line_help(const string& line, int word_end, cli_print(c_format("\nsyntax error, command \"%s\" is not recognized.\n", token_line.c_str())); } - + gl_redisplay_line(gl()); if (remove_last_input_char) { // XXX: Move the cursor over the '?' @@ -1352,7 +1352,7 @@ CliClient::process_command(const string& command_line) int i, old_len, new_len; vector command_global_name; bool found_type_match_cb = false; - + token_line = command_line; new_len = token_line.size(); old_len = new_len; @@ -1383,7 +1383,7 @@ CliClient::process_command(const string& command_line) command_global_name.push_back(copy_token(token)); continue; } - + if (parent_cli_command->has_cli_process_callback()) { // The parent command has processing function, so the rest // of the tokens could be arguments for that function @@ -1395,7 +1395,7 @@ CliClient::process_command(const string& command_line) token_line = copy_token(token) + token_line; break; } - + if (parent_cli_command->has_cli_process_callback()) { // Process the rest of the tokens as arguments for this function vector args_vector; @@ -1413,7 +1413,7 @@ CliClient::process_command(const string& command_line) // We cannot use pipe with this command goto print_syntax_error_label; } - + // Start of a pipe command is_process_func_arguments = false; is_pipe_command_arguments = false; @@ -1447,20 +1447,20 @@ CliClient::process_command(const string& command_line) pipe_command_name = ""; pipe_command_args_list.clear(); } - + if (pipe_command_empty) { // Empty pipe command parent_cli_command = parent_cli_command->cli_command_pipe(); goto print_syntax_error_label; } - + // Run the command function { int ret_value; string final_string = ""; bool is_error = false; string error_msg; - + if (parent_cli_command->default_nomore_mode()) set_nomore_mode(true); list::iterator iter; @@ -1492,7 +1492,7 @@ CliClient::process_command(const string& command_line) set_pipe_mode(old_pipe_mode); } final_string = ""; - + _executed_cli_command = parent_cli_command; _executed_cli_command_name = command_global_name; _executed_cli_command_args = args_vector; @@ -1505,9 +1505,9 @@ CliClient::process_command(const string& command_line) return (ret_value); } } - + // The rest of the tokens (if any) cannot be processed as arguments - + // Test if we can "cd" to this function. token = pop_token(token_line); if (token.empty()) { @@ -1516,10 +1516,10 @@ CliClient::process_command(const string& command_line) set_current_cli_command(parent_cli_command); return (XORP_OK); } - + // Error. Will print the list of child commands (done below). } - + print_syntax_error_label: // // If there are more tokens, the first one has to be a sub-command. @@ -1578,7 +1578,7 @@ CliClient::process_command(const string& command_line) cli_print(c_format(" `%s'", child_cli_command->name().c_str())); } cli_print(".\n"); - + return (XORP_ERROR); } @@ -1645,10 +1645,10 @@ CliClient::command_completion_func(WordCompletion *cpl, void *data, CliCommand *curr_cli_command = cli_client->_current_cli_command; list cli_command_match_list; set type_names, no_type_names; - + if (cpl == NULL) return (1); - + list::iterator iter; for (iter = curr_cli_command->child_command_list().begin(); iter != curr_cli_command->child_command_list().end(); @@ -1690,7 +1690,7 @@ CliClient::command_completion_func(WordCompletion *cpl, void *data, // Prepare and print the initial message(s) string token_line = string(line, word_end); string token; - + // Get the lastest token do { string next_token = pop_token(token_line); @@ -1698,7 +1698,7 @@ CliClient::command_completion_func(WordCompletion *cpl, void *data, break; token = next_token; } while (true); - + cli_client->cli_print(c_format("\n`%s' is ambiguous.", token.c_str())); cli_client->cli_print("\nPossible completions:"); } else { @@ -1706,10 +1706,10 @@ CliClient::command_completion_func(WordCompletion *cpl, void *data, cli_client->command_line_help(line, word_end, false); } } - + if (ret_value != 0) { cpl_record_error(cpl, "Not a XORP command!"); } - + return (ret_value); } -- 1.7.5.4 From vvm at tut.by Tue Mar 13 03:20:04 2012 From: vvm at tut.by (Victor Miasnikov) Date: Tue, 13 Mar 2012 13:20:04 +0300 Subject: [Xorp-hackers] [PATCH] windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash 1) libstdc++-6.dll 2) change order exit errors 3) update notes mingw32 packages 4) add URLs /w32api/include/routprot.h 51: error: 'IP_LOCAL_BINDING' References: <4F5E4195.5080703@candelatech.com> Message-ID: <24DA3CC239704500B43F218ADB325BEC@local.st.by> From: Victor Miasnikov windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash 1) add copy libstdc++-6.dll in win32_pkg.bash 1b) add backward compatibility with old mingw GCC runtime i.e. in case run builds on Fedora 13 (and/or with older mingw packages) 2) change order exit errors numbers i.e. first -- common issue, last -- copy *.dll related 3) update notes about Fedora cross-compile packages ( mingw32-* ) 3b) but not removing info the older mingw packages ( see section "works on Fedora 13") 4) update notes and URLs related with Error 51 in w32api headers file routprot.h See screenshot of error: == . . . include/routprot.h:51: error: 'IP_LOCAL_BINDING' does not name a type == Signed-off-by: Victor Miasnikov --- xorp/win32_pkg.bash | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 42 insertions(+), 4 deletions(-) diff --git a/xorp/win32_pkg.bash b/xorp/win32_pkg.bash index a7fa284..59a71b0 100755 --- a/xorp/win32_pkg.bash +++ b/xorp/win32_pkg.bash @@ -4,7 +4,24 @@ # This needs to be run as root (or via sudo) to have a good # chance of working... -# This works on modern Fedora, with these pkgs installed: +# This works on modern Fedora ( on 2012-03-12: Fedora 16), +# with these pkgs installed: + +#mingw32-gcc-4.6.1-3.fc16.i686 +#mingw32-gcc-c++-4.6.1-3.fc16.i686 +#mingw32-cpp-4.6.1-3.fc16.i686 +#mingw32-filesystem-69-11.fc16.noarch +#mingw32-binutils-2.21-2.fc16.i686 +#mingw32-runtime-3.18-4.fc16.noarch +#mingw32-w32api-3.17-1.fc16.noarch +#mingw32-pthreads-2.8.0-15.20110511cvs.fc16.noarch +#mingw32-zlib-1.2.5-5.fc16.noarch +#mingw32-openssl-1.0.0d-1.fc16.noarch +#mingw32-pdcurses-3.4-8.fc15.noarch +#mingw32-libgnurx-2.5.1-7.fc15.noarch + + +# This works on Fedora 13, with these pkgs installed: #mingw32-pdcurses-3.4-8.fc15.noarch #mingw32-cpp-4.5.3-1.fc15.i686 @@ -19,8 +36,24 @@ #mingw32-pthreads-2.8.0-13.fc15.noarch #mingw32-filesystem-69-3.fc15.noarch -# In addition, you need the fix listed in this bug: + + +# In addition, you need ( on 2012-03-12) the fix this bug: +#== +# . . . include/routprot.h:51: error: +# 'IP_LOCAL_BINDING' does not name a type +#== +# Bug listed in +#http://sourceforge.net/tracker/?func=detail&aid=3388721&group_id=2435&atid=102435 +# or #http://lists.fedoraproject.org/pipermail/mingw/2011-February/003442.html +# +# But first check "src/winsup/w32api/include/" on cygwin.com : +#http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/?cvsroot=src +# or directly +# "CVS log for src/winsup/w32api/include/routprot.h" on +#http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/routprot.h?cvsroot=src +# # mingw cross-compile arguments SARGS="strip=yes shared=no build=mingw32 STRIP=i686-pc-mingw32-strip \ @@ -52,10 +85,15 @@ scons $SARGS install || exit 2 echo "Copy some files..." # Copy some run-time libraries to the xorp dir for packaging -cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libcrypto-10.dll /usr/local/xorp/sbin/ || exit 3 cp /usr/i686-pc-mingw32/sys-root/mingw/bin/zlib1.dll /usr/local/xorp/sbin/ || exit 4 cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libgcc_s_sjlj-1.dll /usr/local/xorp/sbin/ || exit 5 cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libgnurx-0.dll /usr/local/xorp/sbin/ || exit 6 +cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libcrypto-10.dll /usr/local/xorp/sbin/ || exit 7 +if [ -d /usr/i686-pc-mingw32/sys-root/mingw/bin/libstdc++-6.dll ] ; then + ( + cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libstdc++-6.dll /usr/local/xorp/sbin/ || exit 8 + ) +fi PWD=$(pwd) @@ -66,7 +104,7 @@ then userdir = "./" fi -cd /usr/local || exit 7 +cd /usr/local || exit 3 if [ ! -d ${userdir}tmp ] then -- 1.7.9.msysgit.0 From igorm at etf.rs Tue Mar 13 03:39:34 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:39:34 +0100 Subject: [Xorp-hackers] [PATCH 01/10] xorp: rtrmgr: Removed y.tplt_tab.h In-Reply-To: <1331635183-3800-1-git-send-email-igorm@etf.rs> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> Message-ID: <1331635183-3800-2-git-send-email-igorm@etf.rs> From: Igor Maravic It will be automatically generated with bison. Signed-off-by: Igor Maravic --- xorp/rtrmgr/y.tplt_tab.h | 48 ---------------------------------------------- 1 files changed, 0 insertions(+), 48 deletions(-) delete mode 100644 xorp/rtrmgr/y.tplt_tab.h diff --git a/xorp/rtrmgr/y.tplt_tab.h b/xorp/rtrmgr/y.tplt_tab.h deleted file mode 100644 index 96b9183..0000000 --- a/xorp/rtrmgr/y.tplt_tab.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef YYERRCODE -#define YYERRCODE 256 -#endif - -#define UPLEVEL 257 -#define DOWNLEVEL 258 -#define END 259 -#define COLON 260 -#define ASSIGN_DEFAULT 261 -#define LISTNEXT 262 -#define RETURN 263 -#define TEXT_TYPE 264 -#define INT_TYPE 265 -#define UINT_TYPE 266 -#define UINTRANGE_TYPE 267 -#define BOOL_TYPE 268 -#define TOGGLE_TYPE 269 -#define IPV4_TYPE 270 -#define IPV4RANGE_TYPE 271 -#define IPV4NET_TYPE 272 -#define IPV6_TYPE 273 -#define IPV6RANGE_TYPE 274 -#define IPV6NET_TYPE 275 -#define MACADDR_TYPE 276 -#define URL_FILE_TYPE 277 -#define URL_FTP_TYPE 278 -#define URL_HTTP_TYPE 279 -#define URL_TFTP_TYPE 280 -#define BOOL_VALUE 281 -#define INTEGER_VALUE 282 -#define UINTRANGE_VALUE 283 -#define IPV4_VALUE 284 -#define IPV4RANGE_VALUE 285 -#define IPV4NET_VALUE 286 -#define IPV6_VALUE 287 -#define IPV6RANGE_VALUE 288 -#define IPV6NET_VALUE 289 -#define MACADDR_VALUE 290 -#define URL_FILE_VALUE 291 -#define URL_FTP_VALUE 292 -#define URL_HTTP_VALUE 293 -#define URL_TFTP_VALUE 294 -#define VARDEF 295 -#define COMMAND 296 -#define VARIABLE 297 -#define LITERAL 298 -#define STRING 299 -#define SYNTAX_ERROR 300 -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:39:33 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:39:33 +0100 Subject: [Xorp-hackers] [PATCH 00/10] Automatically generate lex and yacc files In-Reply-To: References: Message-ID: <1331635183-3800-1-git-send-email-igorm@etf.rs> From: Igor Maravic Hi, I removed files in individual patches. 10th patch is where I introduced auto generation of lex and yacc files BR Igor Igor Maravic (10): xorp: rtrmgr: Removed y.tplt_tab.h xorp: rtrmgr: Removed y.tplt_tab.cc xorp: rtrmgr: Removed y.opcmd_tab.h xorp: rtrmgr: Removed y.opcmd_tab.cc xorp: rtrmgr: Removed y.boot_tab.c xorp: rtrmgr: Removed y.boot_tab.h xorp: rtrmgr: Removed lex.tplt.cc xorp: rtrmgr: Removed lex.boot.cc xorp: rtrmgr: Removed lex.opcmd.cc xorp: Automatically generate lex and yacc files xorp/rtrmgr/SConscript | 79 +- xorp/rtrmgr/boot.ll | 6 +- xorp/rtrmgr/boot.yy | 64 +- xorp/rtrmgr/lex.boot.cc |10991 ----------------------------------- xorp/rtrmgr/lex.opcmd.cc | 1830 ------ xorp/rtrmgr/lex.tplt.cc |10216 -------------------------------- xorp/rtrmgr/op_commands.cc | 8 +- xorp/rtrmgr/op_commands.ll | 4 +- xorp/rtrmgr/op_commands.yy | 132 +- xorp/rtrmgr/template.ll | 4 +- xorp/rtrmgr/template.yy | 97 +- xorp/rtrmgr/y.boot_tab.cc | 890 --- xorp/rtrmgr/y.boot_tab.h | 28 - xorp/rtrmgr/y.opcmd_tab.cc | 954 --- xorp/rtrmgr/y.opcmd_tab.h | 19 - xorp/rtrmgr/y.tplt_tab.cc | 1081 ---- xorp/rtrmgr/y.tplt_tab.h | 48 - xorp/site_scons/config/allconfig.py | 15 + 18 files changed, 295 insertions(+), 26171 deletions(-) delete mode 100644 xorp/rtrmgr/lex.boot.cc delete mode 100644 xorp/rtrmgr/lex.opcmd.cc delete mode 100644 xorp/rtrmgr/lex.tplt.cc delete mode 100644 xorp/rtrmgr/y.boot_tab.cc delete mode 100644 xorp/rtrmgr/y.boot_tab.h delete mode 100644 xorp/rtrmgr/y.opcmd_tab.cc delete mode 100644 xorp/rtrmgr/y.opcmd_tab.h delete mode 100644 xorp/rtrmgr/y.tplt_tab.cc delete mode 100644 xorp/rtrmgr/y.tplt_tab.h -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:39:36 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:39:36 +0100 Subject: [Xorp-hackers] [PATCH 03/10] xorp: rtrmgr: Removed y.opcmd_tab.h In-Reply-To: <1331635183-3800-1-git-send-email-igorm@etf.rs> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> Message-ID: <1331635183-3800-4-git-send-email-igorm@etf.rs> From: Igor Maravic It will be automatically generated with bison. Signed-off-by: Igor Maravic --- xorp/rtrmgr/y.opcmd_tab.h | 19 ------------------- 1 files changed, 0 insertions(+), 19 deletions(-) delete mode 100644 xorp/rtrmgr/y.opcmd_tab.h diff --git a/xorp/rtrmgr/y.opcmd_tab.h b/xorp/rtrmgr/y.opcmd_tab.h deleted file mode 100644 index 1541948..0000000 --- a/xorp/rtrmgr/y.opcmd_tab.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef YYERRCODE -#define YYERRCODE 256 -#endif - -#define UPLEVEL 257 -#define DOWNLEVEL 258 -#define END 259 -#define COLON 260 -#define CMD_MODULE 261 -#define CMD_COMMAND 262 -#define CMD_HELP 263 -#define CMD_OPT_PARAMETER 264 -#define CMD_TAG 265 -#define CMD_NOMORE_MODE 266 -#define VARIABLE 267 -#define WILDCARD 268 -#define LITERAL 269 -#define STRING 270 -#define SYNTAX_ERROR 271 -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:39:35 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:39:35 +0100 Subject: [Xorp-hackers] [PATCH 02/10] xorp: rtrmgr: Removed y.tplt_tab.cc In-Reply-To: <1331635183-3800-1-git-send-email-igorm@etf.rs> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> Message-ID: <1331635183-3800-3-git-send-email-igorm@etf.rs> From: Igor Maravic It will be automatically generated with bison. Signed-off-by: Igor Maravic --- xorp/rtrmgr/y.tplt_tab.cc | 1081 --------------------------------------------- 1 files changed, 0 insertions(+), 1081 deletions(-) delete mode 100644 xorp/rtrmgr/y.tplt_tab.cc diff --git a/xorp/rtrmgr/y.tplt_tab.cc b/xorp/rtrmgr/y.tplt_tab.cc deleted file mode 100644 index abcb3c5..0000000 --- a/xorp/rtrmgr/y.tplt_tab.cc +++ /dev/null @@ -1,1081 +0,0 @@ -#ifndef lint - -#endif -#include -#define YYBYACC 1 -#define YYMAJOR 1 -#define YYMINOR 9 -#define YYLEX yylex() -#define YYEMPTY -1 -#define yyclearin (yychar=(YYEMPTY)) -#define yyerrok (yyerrflag=0) -#define YYRECOVERING() (yyerrflag!=0) -#if defined(__cplusplus) || __STDC__ -static int yygrowstack(void); -#else -static int yygrowstack(); -#endif -#define yyparse tpltparse -#define yylex tpltlex -#define yyerror tplterror -#define yychar tpltchar -#define yyval tpltval -#define yylval tpltlval -#define yydebug tpltdebug -#define yynerrs tpltnerrs -#define yyerrflag tplterrflag -#define yyss tpltss -#define yyssp tpltssp -#define yyvs tpltvs -#define yyvsp tpltvsp -#define yylhs tpltlhs -#define yylen tpltlen -#define yydefred tpltdefred -#define yydgoto tpltdgoto -#define yysindex tpltsindex -#define yyrindex tpltrindex -#define yygindex tpltgindex -#define yytable tplttable -#define yycheck tpltcheck -#define yyname tpltname -#define yyrule tpltrule -#define yysslim tpltsslim -#define yystacksize tpltstacksize -#define YYPREFIX "tplt" -#line 2 "template.yy" -#define YYSTYPE char* - -#include -#include - -#include "rtrmgr_module.h" -#include "libxorp/xorp.h" -#include "libxorp/xlog.h" - -#include "template_tree_node.hh" -#include "template_tree.hh" -extern void add_cmd_adaptor(char *cmd, TemplateTree* tt) throw (ParseError); -extern void add_cmd_action_adaptor(const string& cmd, - const list& action, - TemplateTree* tt) throw (ParseError); - -/* XXX: sigh, the -p flag to yacc should do this for us */ -#define yystacksize tpltstacksize -#define yysslim tpltsslim -#line 67 "y.tplt_tab.c" -#define YYERRCODE 256 -#define UPLEVEL 257 -#define DOWNLEVEL 258 -#define END 259 -#define COLON 260 -#define ASSIGN_DEFAULT 261 -#define LISTNEXT 262 -#define RETURN 263 -#define TEXT_TYPE 264 -#define INT_TYPE 265 -#define UINT_TYPE 266 -#define UINTRANGE_TYPE 267 -#define BOOL_TYPE 268 -#define TOGGLE_TYPE 269 -#define IPV4_TYPE 270 -#define IPV4RANGE_TYPE 271 -#define IPV4NET_TYPE 272 -#define IPV6_TYPE 273 -#define IPV6RANGE_TYPE 274 -#define IPV6NET_TYPE 275 -#define MACADDR_TYPE 276 -#define URL_FILE_TYPE 277 -#define URL_FTP_TYPE 278 -#define URL_HTTP_TYPE 279 -#define URL_TFTP_TYPE 280 -#define BOOL_VALUE 281 -#define INTEGER_VALUE 282 -#define UINTRANGE_VALUE 283 -#define IPV4_VALUE 284 -#define IPV4RANGE_VALUE 285 -#define IPV4NET_VALUE 286 -#define IPV6_VALUE 287 -#define IPV6RANGE_VALUE 288 -#define IPV6NET_VALUE 289 -#define MACADDR_VALUE 290 -#define URL_FILE_VALUE 291 -#define URL_FTP_VALUE 292 -#define URL_HTTP_VALUE 293 -#define URL_TFTP_VALUE 294 -#define VARDEF 295 -#define COMMAND 296 -#define VARIABLE 297 -#define LITERAL 298 -#define STRING 299 -#define SYNTAX_ERROR 300 -const short tpltlhs[] = { -1, - 0, 0, 0, 1, 3, 3, 6, 6, 5, 5, - 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 4, 9, 9, 10, 10, - 10, 11, 11, 14, 13, 12, 12, 15, 16, 17, - 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 20, 20, 20, 20, 2, -}; -const short tpltlen[] = { 2, - 0, 2, 1, 2, 1, 1, 2, 4, 1, 2, - 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 0, 2, 1, 1, - 1, 1, 1, 4, 4, 1, 1, 4, 3, 1, - 1, 3, 1, 2, 4, 3, 2, 3, 1, 2, - 1, 1, 2, 2, 3, 1, -}; -const short tpltdefred[] = { 0, - 0, 76, 0, 0, 3, 0, 0, 6, 0, 2, - 0, 4, 0, 11, 0, 60, 0, 51, 0, 0, - 49, 50, 52, 53, 56, 57, 0, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 8, 0, 46, 48, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 59, 0, - 0, 0, 72, 0, 61, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 54, 55, 73, 0, 0, 0, 0, - 0, 58, 0, 0, 74, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 66, 68, 0, 62, 75, 65, -}; -const short tpltdgoto[] = { 3, - 4, 5, 6, 12, 7, 8, 45, 68, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 74, 75, 76, -}; -const short tpltsindex[] = { -249, - -289, 0, 0, -249, 0, -240, -257, 0, -169, 0, - -210, 0, -289, 0, -244, 0, -241, 0, -173, -210, - 0, 0, 0, 0, 0, 0, -168, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -209, 0, 0, -251, -167, - -166, -165, -164, -163, -162, -161, -160, -159, -158, -157, - -156, -155, -154, -153, -152, -151, -148, -147, 0, -146, - -292, -287, 0, -187, 0, -281, -206, -150, -149, -170, - -145, -144, -143, -142, -171, -141, -172, -140, -139, -174, - -138, -137, -176, 0, 0, 0, -281, -244, -178, -136, - -281, 0, -259, -135, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -177, 0, 0, 0, -}; -const short tpltrindex[] = { 119, - -256, 0, 0, 119, 0, 0, -134, 0, -255, 0, - -173, 0, -254, 0, 0, 0, -256, 0, 0, -173, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, -133, - -131, -130, -129, -128, -125, -124, -121, -120, -119, -117, - -115, -114, -112, -111, -109, -107, 0, 0, 0, 0, - -186, -185, 0, 0, 0, -181, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, -180, 0, -179, -246, - -175, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -}; -const short tpltgindex[] = { 116, - -6, 0, 0, 0, 0, 117, -46, 0, 133, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 52, 18, -}; -#define YYTABLESIZE 156 -const short tplttable[] = { 67, - 9, 7, 10, 70, 18, 9, 73, 69, 70, 98, - 99, 100, 72, 18, 104, 72, 11, 105, 46, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 70, 71, 72, 73, - 13, 9, 7, 10, 70, 71, 72, 73, 1, 72, - 2, 123, 72, 9, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 102, 69, 71, 103, 69, 71, 63, 70, 67, - 63, 70, 67, 64, 47, 16, 64, 17, 97, 101, - 15, 49, 106, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - 94, 95, 109, 96, 114, 116, 119, 122, 1, 10, - 124, 128, 5, 14, 127, 12, 125, 13, 14, 15, - 16, 107, 108, 17, 18, 110, 111, 19, 20, 21, - 112, 22, 113, 23, 24, 115, 25, 26, 117, 27, - 118, 28, 48, 120, 126, 121, -}; -const short tpltcheck[] = { 46, - 257, 257, 257, 296, 11, 295, 299, 259, 296, 297, - 298, 299, 259, 20, 296, 262, 257, 299, 260, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 296, 297, 298, 299, - 298, 298, 298, 298, 296, 297, 298, 299, 298, 296, - 300, 98, 299, 295, 264, 265, 266, 267, 268, 269, - 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, - 280, 259, 259, 259, 262, 262, 262, 259, 259, 259, - 262, 262, 262, 259, 258, 296, 262, 298, 71, 72, - 260, 260, 299, 261, 261, 261, 261, 261, 261, 261, - 261, 261, 261, 261, 261, 261, 261, 261, 261, 261, - 259, 259, 283, 260, 286, 288, 291, 294, 0, 4, - 299, 299, 257, 7, 260, 259, 263, 259, 259, 259, - 259, 282, 282, 259, 259, 281, 281, 259, 259, 259, - 284, 259, 285, 259, 259, 287, 259, 259, 289, 259, - 290, 259, 20, 292, 103, 293, -}; -#define YYFINAL 3 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 300 -#if YYDEBUG -const char * const tpltname[] = { -"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"UPLEVEL","DOWNLEVEL","END", -"COLON","ASSIGN_DEFAULT","LISTNEXT","RETURN","TEXT_TYPE","INT_TYPE","UINT_TYPE", -"UINTRANGE_TYPE","BOOL_TYPE","TOGGLE_TYPE","IPV4_TYPE","IPV4RANGE_TYPE", -"IPV4NET_TYPE","IPV6_TYPE","IPV6RANGE_TYPE","IPV6NET_TYPE","MACADDR_TYPE", -"URL_FILE_TYPE","URL_FTP_TYPE","URL_HTTP_TYPE","URL_TFTP_TYPE","BOOL_VALUE", -"INTEGER_VALUE","UINTRANGE_VALUE","IPV4_VALUE","IPV4RANGE_VALUE", -"IPV4NET_VALUE","IPV6_VALUE","IPV6RANGE_VALUE","IPV6NET_VALUE","MACADDR_VALUE", -"URL_FILE_VALUE","URL_FTP_VALUE","URL_HTTP_VALUE","URL_TFTP_VALUE","VARDEF", -"COMMAND","VARIABLE","LITERAL","STRING","SYNTAX_ERROR", -}; -const char * const tpltrule[] = { -"$accept : input", -"input :", -"input : definition input", -"input : syntax_error", -"definition : nodename nodegroup", -"nodename : literals", -"nodename : named_literal", -"named_literal : LITERAL VARDEF", -"named_literal : LITERAL VARDEF COLON type", -"literals : LITERAL", -"literals : literals LITERAL", -"literals : literals named_literal", -"type : TEXT_TYPE", -"type : INT_TYPE", -"type : UINT_TYPE", -"type : UINTRANGE_TYPE", -"type : BOOL_TYPE", -"type : TOGGLE_TYPE", -"type : IPV4_TYPE", -"type : IPV4RANGE_TYPE", -"type : IPV4NET_TYPE", -"type : IPV6_TYPE", -"type : IPV6RANGE_TYPE", -"type : IPV6NET_TYPE", -"type : MACADDR_TYPE", -"type : URL_FILE_TYPE", -"type : URL_FTP_TYPE", -"type : URL_HTTP_TYPE", -"type : URL_TFTP_TYPE", -"init_type : TEXT_TYPE ASSIGN_DEFAULT STRING", -"init_type : INT_TYPE ASSIGN_DEFAULT INTEGER_VALUE", -"init_type : UINT_TYPE ASSIGN_DEFAULT INTEGER_VALUE", -"init_type : UINTRANGE_TYPE ASSIGN_DEFAULT UINTRANGE_VALUE", -"init_type : BOOL_TYPE ASSIGN_DEFAULT BOOL_VALUE", -"init_type : TOGGLE_TYPE ASSIGN_DEFAULT BOOL_VALUE", -"init_type : IPV4_TYPE ASSIGN_DEFAULT IPV4_VALUE", -"init_type : IPV4RANGE_TYPE ASSIGN_DEFAULT IPV4RANGE_VALUE", -"init_type : IPV4NET_TYPE ASSIGN_DEFAULT IPV4NET_VALUE", -"init_type : IPV6_TYPE ASSIGN_DEFAULT IPV6_VALUE", -"init_type : IPV6RANGE_TYPE ASSIGN_DEFAULT IPV6RANGE_VALUE", -"init_type : IPV6NET_TYPE ASSIGN_DEFAULT IPV6NET_VALUE", -"init_type : MACADDR_TYPE ASSIGN_DEFAULT MACADDR_VALUE", -"init_type : URL_FILE_TYPE ASSIGN_DEFAULT URL_FILE_VALUE", -"init_type : URL_FTP_TYPE ASSIGN_DEFAULT URL_FTP_VALUE", -"init_type : URL_HTTP_TYPE ASSIGN_DEFAULT URL_HTTP_VALUE", -"init_type : URL_TFTP_TYPE ASSIGN_DEFAULT URL_TFTP_VALUE", -"nodegroup : UPLEVEL statements DOWNLEVEL", -"statements :", -"statements : statement statements", -"statement : terminal", -"statement : command", -"statement : definition", -"terminal : default_terminal", -"terminal : regular_terminal", -"regular_terminal : LITERAL COLON type END", -"default_terminal : LITERAL COLON init_type END", -"command : cmd_val", -"command : cmd_default", -"cmd_val : command_name COLON cmd_list END", -"cmd_default : command_name COLON END", -"command_name : COMMAND", -"cmd_list : cmd", -"cmd_list : cmd_list LISTNEXT cmd", -"cmd : list_of_cmd_strings", -"cmd : LITERAL list_of_cmd_strings", -"cmd : LITERAL STRING RETURN STRING", -"cmd : LITERAL VARIABLE type", -"cmd : LITERAL LITERAL", -"cmd : LITERAL LITERAL STRING", -"cmd : VARIABLE", -"cmd : VARIABLE list_of_cmd_strings", -"cmd : LITERAL", -"list_of_cmd_strings : STRING", -"list_of_cmd_strings : COMMAND COLON", -"list_of_cmd_strings : list_of_cmd_strings STRING", -"list_of_cmd_strings : list_of_cmd_strings COMMAND COLON", -"syntax_error : SYNTAX_ERROR", -}; -#endif -#ifndef YYSTYPE -typedef int YYSTYPE; -#endif -#if YYDEBUG -#include -#endif -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif -#define YYINITSTACKSIZE 200 -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -short *yyssp; -YYSTYPE *yyvsp; -YYSTYPE yyval; -YYSTYPE yylval; -short *yyss; -short *yysslim; -YYSTYPE *yyvs; -int yystacksize; -#line 293 "template.yy" - -extern char *lstr; -extern char *vstr; -extern char *cstr; -extern char *sstr; -extern char *istr; -extern FILE *tpltin; -extern int tplt_linenum; -extern "C" int tpltparse(); -extern int tpltlex(); - -static TemplateTree* tt = NULL; -static string tplt_filename; -static string lastsymbol; -static int tplt_type; -static char *tplt_initializer = NULL; -static string current_cmd; -static list cmd_list; - - -static void -extend_path(char *segment, bool is_tag) -{ - lastsymbol = segment; - - string segname; - segname = segment; - tt->extend_path(segname, is_tag); - free(segment); -} - -static void -push_path() -{ - tt->push_path(tplt_type, tplt_initializer); - tplt_type = NODE_VOID; - if (tplt_initializer != NULL) { - free(tplt_initializer); - tplt_initializer = NULL; - } -} - -static void -pop_path() -{ - tt->pop_path(); - tplt_type = NODE_VOID; - if (tplt_initializer != NULL) { - free(tplt_initializer); - tplt_initializer = NULL; - } -} - -static void -terminal(char *segment) -{ - extend_path(segment, false); - push_path(); - pop_path(); -} - -static void -add_cmd(char *cmd) -{ - lastsymbol = cmd; - - add_cmd_adaptor(cmd, tt); - current_cmd = cmd; - free(cmd); - cmd_list.clear(); -} - -static void -append_cmd(char *s) -{ - lastsymbol = s; - - cmd_list.push_back(string(s)); - free(s); -} - -static void -prepend_cmd(char *s) -{ - lastsymbol = s; - - cmd_list.push_front(string(s)); - free(s); -} - -static void -end_cmd() -{ - add_cmd_action_adaptor(current_cmd, cmd_list, tt); - cmd_list.clear(); -} - -void -tplterror(const char *s) throw (ParseError) -{ - string errmsg; - - errmsg = c_format("PARSE ERROR [Template File: %s line %d]: %s", - tplt_filename.c_str(), tplt_linenum, s); - errmsg += c_format("; Last symbol parsed was \"%s\"", lastsymbol.c_str()); - - xorp_throw(ParseError, errmsg); -} - -int -init_template_parser(const char *filename, TemplateTree *c) -{ - tt = c; - tplt_linenum = 1; - - tpltin = fopen(filename, "r"); - if (tpltin == NULL) - return -1; - - tplt_type = NODE_VOID; - tplt_initializer = NULL; - tplt_filename = filename; - return 0; -} - -void -complete_template_parser() -{ - if (tpltin != NULL) - fclose(tpltin); -} - -void -parse_template() throw (ParseError) -{ - if (tpltparse() != 0) - tplterror("unknown error"); -} -#line 495 "y.tplt_tab.c" -/* allocate initial stack or double stack size, up to YYMAXDEPTH */ -static int yygrowstack() -{ - int newsize, i; - short *newss; - YYSTYPE *newvs; - - if ((newsize = yystacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return -1; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - i = yyssp - yyss; - newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) : - (short *)malloc(newsize * sizeof *newss); - if (newss == NULL) - return -1; - yyss = newss; - yyssp = newss + i; - newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) : - (YYSTYPE *)malloc(newsize * sizeof *newvs); - if (newvs == NULL) - return -1; - yyvs = newvs; - yyvsp = newvs + i; - yystacksize = newsize; - yysslim = yyss + newsize - 1; - return 0; -} - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab - -#ifndef YYPARSE_PARAM -#if defined(__cplusplus) || __STDC__ -#define YYPARSE_PARAM_ARG void -#define YYPARSE_PARAM_DECL -#else /* ! ANSI-C/C++ */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* ANSI-C/C++ */ -#else /* YYPARSE_PARAM */ -#ifndef YYPARSE_PARAM_TYPE -#define YYPARSE_PARAM_TYPE void * -#endif -#if defined(__cplusplus) || __STDC__ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* ! ANSI-C/C++ */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM; -#endif /* ANSI-C/C++ */ -#endif /* ! YYPARSE_PARAM */ - -int -yyparse (YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - register int yym, yyn, yystate; -#if YYDEBUG - register const char *yys; - - if ((yys = getenv("YYDEBUG"))) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yynerrs = 0; - yyerrflag = 0; - yychar = (-1); - - if (yyss == NULL && yygrowstack()) goto yyoverflow; - yyssp = yyss; - yyvsp = yyvs; - *yyssp = yystate = 0; - -yyloop: - if ((yyn = yydefred[yystate])) goto yyreduce; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yyssp >= yysslim && yygrowstack()) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - yychar = (-1); - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; -#if defined(lint) || defined(__GNUC__) - goto yynewerror; -#endif -yynewerror: - yyerror("syntax error"); -#if defined(lint) || defined(__GNUC__) - goto yyerrlab; -#endif -yyerrlab: - ++yynerrs; -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); -#endif - if (yyssp >= yysslim && yygrowstack()) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yyssp); -#endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; - } - } - } - else - { - if (yychar == 0) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = (-1); - goto yyloop; - } -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - yyval = yyvsp[1-yym]; - switch (yyn) - { -case 5: -#line 79 "template.yy" -{ push_path(); } -break; -case 6: -#line 80 "template.yy" -{ push_path(); } -break; -case 7: -#line 83 "template.yy" -{ - extend_path(yyvsp[-1], true); - extend_path(yyvsp[0], false); - } -break; -case 8: -#line 87 "template.yy" -{ - extend_path(yyvsp[-3], true); - extend_path(yyvsp[-2], false); - } -break; -case 9: -#line 93 "template.yy" -{ extend_path(yyvsp[0], false); } -break; -case 10: -#line 94 "template.yy" -{ extend_path(yyvsp[0], false); } -break; -case 12: -#line 98 "template.yy" -{ tplt_type = NODE_TEXT; } -break; -case 13: -#line 99 "template.yy" -{ tplt_type = NODE_INT; } -break; -case 14: -#line 100 "template.yy" -{ tplt_type = NODE_UINT; } -break; -case 15: -#line 101 "template.yy" -{ tplt_type = NODE_UINTRANGE; } -break; -case 16: -#line 102 "template.yy" -{ tplt_type = NODE_BOOL; } -break; -case 17: -#line 103 "template.yy" -{ tplt_type = NODE_TOGGLE; } -break; -case 18: -#line 104 "template.yy" -{ tplt_type = NODE_IPV4; } -break; -case 19: -#line 105 "template.yy" -{ tplt_type = NODE_IPV4RANGE; } -break; -case 20: -#line 106 "template.yy" -{ tplt_type = NODE_IPV4NET; } -break; -case 21: -#line 107 "template.yy" -{ tplt_type = NODE_IPV6; } -break; -case 22: -#line 108 "template.yy" -{ tplt_type = NODE_IPV6RANGE; } -break; -case 23: -#line 109 "template.yy" -{ tplt_type = NODE_IPV6NET; } -break; -case 24: -#line 110 "template.yy" -{ tplt_type = NODE_MACADDR; } -break; -case 25: -#line 111 "template.yy" -{ tplt_type = NODE_URL_FILE; } -break; -case 26: -#line 112 "template.yy" -{ tplt_type = NODE_URL_FTP; } -break; -case 27: -#line 113 "template.yy" -{ tplt_type = NODE_URL_HTTP; } -break; -case 28: -#line 114 "template.yy" -{ tplt_type = NODE_URL_TFTP; } -break; -case 29: -#line 117 "template.yy" -{ - tplt_type = NODE_TEXT; - tplt_initializer = yyvsp[0]; - } -break; -case 30: -#line 121 "template.yy" -{ - tplt_type = NODE_INT; - tplt_initializer = yyvsp[0]; - } -break; -case 31: -#line 125 "template.yy" -{ - tplt_type = NODE_UINT; - tplt_initializer = yyvsp[0]; - } -break; -case 32: -#line 129 "template.yy" -{ - tplt_type = NODE_UINTRANGE; - tplt_initializer = yyvsp[0]; - } -break; -case 33: -#line 133 "template.yy" -{ - tplt_type = NODE_BOOL; - tplt_initializer = yyvsp[0]; - } -break; -case 34: -#line 137 "template.yy" -{ - tplt_type = NODE_TOGGLE; - tplt_initializer = yyvsp[0]; - } -break; -case 35: -#line 141 "template.yy" -{ - tplt_type = NODE_IPV4; - tplt_initializer = yyvsp[0]; - } -break; -case 36: -#line 145 "template.yy" -{ - tplt_type = NODE_IPV4RANGE; - tplt_initializer = yyvsp[0]; - } -break; -case 37: -#line 149 "template.yy" -{ - tplt_type = NODE_IPV4NET; - tplt_initializer = yyvsp[0]; - } -break; -case 38: -#line 153 "template.yy" -{ - tplt_type = NODE_IPV6; - tplt_initializer = yyvsp[0]; - } -break; -case 39: -#line 157 "template.yy" -{ - tplt_type = NODE_IPV6RANGE; - tplt_initializer = yyvsp[0]; - } -break; -case 40: -#line 161 "template.yy" -{ - tplt_type = NODE_IPV6NET; - tplt_initializer = yyvsp[0]; - } -break; -case 41: -#line 165 "template.yy" -{ - tplt_type = NODE_MACADDR; - tplt_initializer = yyvsp[0]; - } -break; -case 42: -#line 169 "template.yy" -{ - tplt_type = NODE_URL_FILE; - tplt_initializer = yyvsp[0]; - } -break; -case 43: -#line 173 "template.yy" -{ - tplt_type = NODE_URL_FTP; - tplt_initializer = yyvsp[0]; - } -break; -case 44: -#line 177 "template.yy" -{ - tplt_type = NODE_URL_HTTP; - tplt_initializer = yyvsp[0]; - } -break; -case 45: -#line 181 "template.yy" -{ - tplt_type = NODE_URL_TFTP; - tplt_initializer = yyvsp[0]; - } -break; -case 46: -#line 187 "template.yy" -{ pop_path(); } -break; -case 54: -#line 203 "template.yy" -{ terminal(yyvsp[-3]); } -break; -case 55: -#line 206 "template.yy" -{ terminal(yyvsp[-3]); } -break; -case 59: -#line 216 "template.yy" -{ end_cmd(); } -break; -case 60: -#line 219 "template.yy" -{ add_cmd(yyvsp[0]); } -break; -case 63: -#line 226 "template.yy" -{ - end_cmd(); - } -break; -case 64: -#line 229 "template.yy" -{ - prepend_cmd(yyvsp[-1]); - end_cmd(); - } -break; -case 65: -#line 233 "template.yy" -{ - append_cmd(yyvsp[-3]); - append_cmd(yyvsp[-2]); - append_cmd(yyvsp[-1]); - append_cmd(yyvsp[0]); - end_cmd(); - } -break; -case 66: -#line 240 "template.yy" -{ /* e.g.: set FOOBAR ipv4 */ - append_cmd(yyvsp[-2]); - append_cmd(yyvsp[-1]); - append_cmd(yyvsp[0]); - end_cmd(); - } -break; -case 67: -#line 246 "template.yy" -{ - append_cmd(yyvsp[-1]); - append_cmd(yyvsp[0]); - end_cmd(); - } -break; -case 68: -#line 251 "template.yy" -{ - append_cmd(yyvsp[-2]); - append_cmd(yyvsp[-1]); - append_cmd(yyvsp[0]); - end_cmd(); - } -break; -case 69: -#line 257 "template.yy" -{ - append_cmd(yyvsp[0]); - end_cmd(); - } -break; -case 70: -#line 261 "template.yy" -{ - prepend_cmd(yyvsp[-1]); - end_cmd(); - } -break; -case 71: -#line 265 "template.yy" -{ - append_cmd(yyvsp[0]); - end_cmd(); - } -break; -case 72: -#line 272 "template.yy" -{ - append_cmd(yyvsp[0]); - } -break; -case 73: -#line 275 "template.yy" -{ - append_cmd(yyvsp[-1]); - } -break; -case 74: -#line 278 "template.yy" -{ - append_cmd(yyvsp[0]); - } -break; -case 75: -#line 281 "template.yy" -{ - append_cmd(yyvsp[-1]); - } -break; -case 76: -#line 286 "template.yy" -{ - tplterror("syntax error"); - } -break; -#line 1027 "y.tplt_tab.c" - } - yyssp -= yym; - yystate = *yyssp; - yyvsp -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == 0) goto yyaccept; - goto yyloop; - } - if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yyssp, yystate); -#endif - if (yyssp >= yysslim && yygrowstack()) - { - goto yyoverflow; - } - *++yyssp = yystate; - *++yyvsp = yyval; - goto yyloop; -yyoverflow: - yyerror("yacc stack overflow"); -yyabort: - return (1); -yyaccept: - return (0); -} -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:39:39 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:39:39 +0100 Subject: [Xorp-hackers] [PATCH 06/10] xorp: rtrmgr: Removed y.boot_tab.h In-Reply-To: <1331635183-3800-1-git-send-email-igorm@etf.rs> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> Message-ID: <1331635183-3800-7-git-send-email-igorm@etf.rs> From: Igor Maravic It will be automatically generated with bison. Signed-off-by: Igor Maravic --- xorp/rtrmgr/y.boot_tab.h | 28 ---------------------------- 1 files changed, 0 insertions(+), 28 deletions(-) delete mode 100644 xorp/rtrmgr/y.boot_tab.h diff --git a/xorp/rtrmgr/y.boot_tab.h b/xorp/rtrmgr/y.boot_tab.h deleted file mode 100644 index 3faddac..0000000 --- a/xorp/rtrmgr/y.boot_tab.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef YYERRCODE -#define YYERRCODE 256 -#endif - -#define UPLEVEL 257 -#define DOWNLEVEL 258 -#define END 259 -#define ASSIGN_OPERATOR 260 -#define BOOL_VALUE 261 -#define UINT_VALUE 262 -#define UINTRANGE_VALUE 263 -#define IPV4_VALUE 264 -#define IPV4RANGE_VALUE 265 -#define IPV4NET_VALUE 266 -#define IPV6_VALUE 267 -#define IPV6RANGE_VALUE 268 -#define IPV6NET_VALUE 269 -#define MACADDR_VALUE 270 -#define URL_FILE_VALUE 271 -#define URL_FTP_VALUE 272 -#define URL_HTTP_VALUE 273 -#define URL_TFTP_VALUE 274 -#define LITERAL 275 -#define STRING 276 -#define ARITH 277 -#define INFIX_OPERATOR 278 -#define SYNTAX_ERROR 279 -#define CONFIG_NODE_ID 280 -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:39:38 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:39:38 +0100 Subject: [Xorp-hackers] [PATCH 05/10] xorp: rtrmgr: Removed y.boot_tab.c In-Reply-To: <1331635183-3800-1-git-send-email-igorm@etf.rs> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> Message-ID: <1331635183-3800-6-git-send-email-igorm@etf.rs> From: Igor Maravic It will be automatically generated with bison. Signed-off-by: Igor Maravic --- xorp/rtrmgr/y.boot_tab.cc | 890 --------------------------------------------- 1 files changed, 0 insertions(+), 890 deletions(-) delete mode 100644 xorp/rtrmgr/y.boot_tab.cc diff --git a/xorp/rtrmgr/y.boot_tab.cc b/xorp/rtrmgr/y.boot_tab.cc deleted file mode 100644 index 0d563a0..0000000 --- a/xorp/rtrmgr/y.boot_tab.cc +++ /dev/null @@ -1,890 +0,0 @@ -#ifndef lint - -#endif -#include -#define YYBYACC 1 -#define YYMAJOR 1 -#define YYMINOR 9 -#define YYLEX yylex() -#define YYEMPTY -1 -#define yyclearin (yychar=(YYEMPTY)) -#define yyerrok (yyerrflag=0) -#define YYRECOVERING() (yyerrflag!=0) -#if defined(__cplusplus) || __STDC__ -static int yygrowstack(void); -#else -static int yygrowstack(); -#endif -#define yyparse bootparse -#define yylex bootlex -#define yyerror booterror -#define yychar bootchar -#define yyval bootval -#define yylval bootlval -#define yydebug bootdebug -#define yynerrs bootnerrs -#define yyerrflag booterrflag -#define yyss bootss -#define yyssp bootssp -#define yyvs bootvs -#define yyvsp bootvsp -#define yylhs bootlhs -#define yylen bootlen -#define yydefred bootdefred -#define yydgoto bootdgoto -#define yysindex bootsindex -#define yyrindex bootrindex -#define yygindex bootgindex -#define yytable boottable -#define yycheck bootcheck -#define yyname bootname -#define yyrule bootrule -#define yysslim bootsslim -#define yystacksize bootstacksize -#define YYPREFIX "boot" -#line 2 "boot.yy" -#define YYSTYPE char* - -#include -#include - - -#include "rtrmgr_module.h" -#include "libxorp/xorp.h" -#include "libxorp/xlog.h" - -#include "conf_tree.hh" -#include "conf_tree_node.hh" -#include "template_tree.hh" -#include "template_tree_node.hh" -#include "config_operators.hh" - -/* XXX: sigh - -p flag to yacc should do this for us */ -#define yystacksize bootstacksize -#define yysslim bootsslim -#line 67 "y.boot_tab.c" -#define YYERRCODE 256 -#define UPLEVEL 257 -#define DOWNLEVEL 258 -#define END 259 -#define ASSIGN_OPERATOR 260 -#define BOOL_VALUE 261 -#define UINT_VALUE 262 -#define UINTRANGE_VALUE 263 -#define IPV4_VALUE 264 -#define IPV4RANGE_VALUE 265 -#define IPV4NET_VALUE 266 -#define IPV6_VALUE 267 -#define IPV6RANGE_VALUE 268 -#define IPV6NET_VALUE 269 -#define MACADDR_VALUE 270 -#define URL_FILE_VALUE 271 -#define URL_FTP_VALUE 272 -#define URL_HTTP_VALUE 273 -#define URL_TFTP_VALUE 274 -#define LITERAL 275 -#define STRING 276 -#define ARITH 277 -#define INFIX_OPERATOR 278 -#define SYNTAX_ERROR 279 -#define CONFIG_NODE_ID 280 -const short bootlhs[] = { -1, - 0, 0, 0, 0, 1, 1, 6, 4, 8, 8, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 5, 5, 7, - 10, 10, 11, 11, 11, 2, 13, 13, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 3, -}; -const short bootlen[] = { 2, - 0, 2, 2, 1, 2, 2, 1, 1, 1, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 1, 1, 3, - 0, 2, 1, 1, 1, 1, 1, 2, 2, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 1, -}; -const short bootdefred[] = { 0, - 36, 9, 56, 0, 0, 0, 0, 4, 0, 0, - 0, 0, 10, 2, 3, 0, 29, 5, 28, 6, - 14, 16, 15, 18, 17, 19, 21, 20, 22, 23, - 24, 25, 26, 27, 13, 12, 11, 0, 0, 34, - 35, 0, 0, 33, 0, 0, 30, 32, 39, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 41, 43, 42, 45, - 44, 46, 48, 47, 49, 50, 51, 52, 53, 54, - 40, 55, -}; -const short bootdgoto[] = { 5, - 6, 7, 8, 9, 18, 10, 19, 11, 12, 42, - 43, 44, 45, -}; -const short bootsindex[] = { -210, - 0, 0, 0, -270, 0, -210, -210, 0, -233, -225, - -171, -250, 0, 0, 0, -208, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -222, 0, - 0, -201, -208, 0, -256, 0, 0, 0, 0, -188, - -200, -199, -198, -197, -196, -195, -193, -191, -172, -153, - -152, -151, -150, -149, -148, -147, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -const short bootrindex[] = { 58, - 0, 0, 0, 0, 0, 58, 58, 0, 0, 0, - -186, -205, 0, 0, 0, -145, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -255, 0, 0, - 0, 0, -145, 0, 0, -228, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -const short bootgindex[] = { 49, - -16, -15, 0, 0, 0, 0, 104, 103, 0, 73, - 0, 0, 0, -}; -#define YYTABLESIZE 116 -const short boottable[] = { 40, - 41, 9, 49, 37, 13, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 50, 37, 16, 2, 17, 40, 41, 10, 4, - 38, 16, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 1, 38, - 1, 8, 46, 8, 14, 15, 47, 1, 67, 68, - 69, 70, 71, 72, 2, 73, 38, 74, 3, 4, - 7, 39, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 75, 65, 66, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 76, 77, 78, 79, 80, - 81, 82, 31, 20, 37, 48, -}; -const short bootcheck[] = { 16, - 16, 257, 259, 259, 275, 261, 262, 263, 264, 265, - 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, - 276, 278, 278, 257, 275, 259, 43, 43, 257, 280, - 259, 257, 261, 262, 263, 264, 265, 266, 267, 268, - 269, 270, 271, 272, 273, 274, 275, 276, 259, 278, - 259, 257, 275, 259, 6, 7, 258, 0, 259, 259, - 259, 259, 259, 259, 275, 259, 275, 259, 279, 280, - 257, 280, 261, 262, 263, 264, 265, 266, 267, 268, - 269, 270, 271, 272, 273, 274, 259, 276, 277, 261, - 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, - 272, 273, 274, 275, 276, 259, 259, 259, 259, 259, - 259, 259, 258, 10, 12, 43, -}; -#define YYFINAL 5 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 280 -#if YYDEBUG -const char * const bootname[] = { -"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"UPLEVEL","DOWNLEVEL","END", -"ASSIGN_OPERATOR","BOOL_VALUE","UINT_VALUE","UINTRANGE_VALUE","IPV4_VALUE", -"IPV4RANGE_VALUE","IPV4NET_VALUE","IPV6_VALUE","IPV6RANGE_VALUE", -"IPV6NET_VALUE","MACADDR_VALUE","URL_FILE_VALUE","URL_FTP_VALUE", -"URL_HTTP_VALUE","URL_TFTP_VALUE","LITERAL","STRING","ARITH","INFIX_OPERATOR", -"SYNTAX_ERROR","CONFIG_NODE_ID", -}; -const char * const bootrule[] = { -"$accept : input", -"input :", -"input : definition input", -"input : emptystatement input", -"input : syntax_error", -"definition : long_nodename nodegroup", -"definition : short_nodename long_nodegroup", -"short_nodename : literal", -"long_nodename : literals", -"literal : LITERAL", -"literal : CONFIG_NODE_ID LITERAL", -"literals : literals literal", -"literals : literal STRING", -"literals : literal LITERAL", -"literals : literal BOOL_VALUE", -"literals : literal UINTRANGE_VALUE", -"literals : literal UINT_VALUE", -"literals : literal IPV4RANGE_VALUE", -"literals : literal IPV4_VALUE", -"literals : literal IPV4NET_VALUE", -"literals : literal IPV6RANGE_VALUE", -"literals : literal IPV6_VALUE", -"literals : literal IPV6NET_VALUE", -"literals : literal MACADDR_VALUE", -"literals : literal URL_FILE_VALUE", -"literals : literal URL_FTP_VALUE", -"literals : literal URL_HTTP_VALUE", -"literals : literal URL_TFTP_VALUE", -"nodegroup : long_nodegroup", -"nodegroup : END", -"long_nodegroup : UPLEVEL statements DOWNLEVEL", -"statements :", -"statements : statement statements", -"statement : terminal", -"statement : definition", -"statement : emptystatement", -"emptystatement : END", -"term_literal : LITERAL", -"term_literal : CONFIG_NODE_ID LITERAL", -"terminal : term_literal END", -"terminal : term_literal INFIX_OPERATOR STRING END", -"terminal : term_literal INFIX_OPERATOR BOOL_VALUE END", -"terminal : term_literal INFIX_OPERATOR UINTRANGE_VALUE END", -"terminal : term_literal INFIX_OPERATOR UINT_VALUE END", -"terminal : term_literal INFIX_OPERATOR IPV4RANGE_VALUE END", -"terminal : term_literal INFIX_OPERATOR IPV4_VALUE END", -"terminal : term_literal INFIX_OPERATOR IPV4NET_VALUE END", -"terminal : term_literal INFIX_OPERATOR IPV6RANGE_VALUE END", -"terminal : term_literal INFIX_OPERATOR IPV6_VALUE END", -"terminal : term_literal INFIX_OPERATOR IPV6NET_VALUE END", -"terminal : term_literal INFIX_OPERATOR MACADDR_VALUE END", -"terminal : term_literal INFIX_OPERATOR URL_FILE_VALUE END", -"terminal : term_literal INFIX_OPERATOR URL_FTP_VALUE END", -"terminal : term_literal INFIX_OPERATOR URL_HTTP_VALUE END", -"terminal : term_literal INFIX_OPERATOR URL_TFTP_VALUE END", -"terminal : term_literal INFIX_OPERATOR ARITH END", -"syntax_error : SYNTAX_ERROR", -}; -#endif -#ifndef YYSTYPE -typedef int YYSTYPE; -#endif -#if YYDEBUG -#include -#endif -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif -#define YYINITSTACKSIZE 200 -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -short *yyssp; -YYSTYPE *yyvsp; -YYSTYPE yyval; -YYSTYPE yylval; -short *yyss; -short *yysslim; -YYSTYPE *yyvs; -int yystacksize; -#line 192 "boot.yy" - -extern void boot_scan_string(const char *configuration); -extern int boot_linenum; -extern "C" int bootparse(); -extern int bootlex(); - -void booterror(const char *s) throw (ParseError); - -static ConfigTree *config_tree = NULL; -static string boot_filename; -static string lastsymbol; -static string node_id; - - -static void -extend_path(char* segment, int type, const string& node_id_str) -{ - lastsymbol = segment; - - string segment_copy = segment; - free(segment); - - try { - ConfigNodeId config_node_id(node_id_str); - config_tree->extend_path(segment_copy, type, config_node_id); - } catch (const InvalidString& e) { - string s = c_format("Invalid config tree node ID: %s", - e.str().c_str()); - booterror(s.c_str()); - } -} - -static void -push_path() -{ - config_tree->push_path(); -} - -static void -pop_path() -{ - config_tree->pop_path(); -} - -static void -terminal(char* value, int type, ConfigOperator op) -{ - push_path(); - - lastsymbol = value; - - config_tree->terminal_value(string(value), type, op); - free(value); - pop_path(); -} - -void -booterror(const char *s) throw (ParseError) -{ - string errmsg; - - if (! boot_filename.empty()) { - errmsg = c_format("PARSE ERROR [Config File %s, line %d]: %s", - boot_filename.c_str(), - boot_linenum, s); - } else { - errmsg = c_format("PARSE ERROR [line %d]: %s", boot_linenum, s); - } - errmsg += c_format("; Last symbol parsed was \"%s\"", lastsymbol.c_str()); - - xorp_throw(ParseError, errmsg); -} - -int -init_bootfile_parser(const char *configuration, - const char *filename, - ConfigTree *ct) -{ - config_tree = ct; - boot_filename = filename; - boot_linenum = 1; - boot_scan_string(configuration); - return 0; -} - -void -parse_bootfile() throw (ParseError) -{ - if (bootparse() != 0) - booterror("unknown error"); -} - -ConfigOperator boot_lookup_operator(const char* s) -{ - char *s0, *s1, *s2; - - /* skip leading spaces */ - s0 = strdup(s); - s1 = s0; - while (*s1 != '\0' && *s1 == ' ') { - s1++; - } - - /* trim trailing spaces */ - s2 = s1; - while (*s2 != '\0') { - if (*s2 == ' ') { - *s2 = 0; - break; - } - s2++; - } - - ConfigOperator op; - string str = s1; - free(s1); - try { - op = lookup_operator(str); - return op; - } catch (const ParseError& pe) { - string errmsg = pe.why(); - errmsg += c_format("\n[Line %d]\n", boot_linenum); - errmsg += c_format("Last symbol parsed was \"%s\"", lastsymbol.c_str()); - xorp_throw(ParseError, errmsg); - } - XLOG_UNREACHABLE(); -} -#line 417 "y.boot_tab.c" -/* allocate initial stack or double stack size, up to YYMAXDEPTH */ -static int yygrowstack() -{ - int newsize, i; - short *newss; - YYSTYPE *newvs; - - if ((newsize = yystacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return -1; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - i = yyssp - yyss; - newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) : - (short *)malloc(newsize * sizeof *newss); - if (newss == NULL) - return -1; - yyss = newss; - yyssp = newss + i; - newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) : - (YYSTYPE *)malloc(newsize * sizeof *newvs); - if (newvs == NULL) - return -1; - yyvs = newvs; - yyvsp = newvs + i; - yystacksize = newsize; - yysslim = yyss + newsize - 1; - return 0; -} - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab - -#ifndef YYPARSE_PARAM -#if defined(__cplusplus) || __STDC__ -#define YYPARSE_PARAM_ARG void -#define YYPARSE_PARAM_DECL -#else /* ! ANSI-C/C++ */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* ANSI-C/C++ */ -#else /* YYPARSE_PARAM */ -#ifndef YYPARSE_PARAM_TYPE -#define YYPARSE_PARAM_TYPE void * -#endif -#if defined(__cplusplus) || __STDC__ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* ! ANSI-C/C++ */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM; -#endif /* ANSI-C/C++ */ -#endif /* ! YYPARSE_PARAM */ - -int -yyparse (YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - register int yym, yyn, yystate; -#if YYDEBUG - register const char *yys; - - if ((yys = getenv("YYDEBUG"))) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yynerrs = 0; - yyerrflag = 0; - yychar = (-1); - - if (yyss == NULL && yygrowstack()) goto yyoverflow; - yyssp = yyss; - yyvsp = yyvs; - *yyssp = yystate = 0; - -yyloop: - if ((yyn = yydefred[yystate])) goto yyreduce; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yyssp >= yysslim && yygrowstack()) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - yychar = (-1); - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; -#if defined(lint) || defined(__GNUC__) - goto yynewerror; -#endif -yynewerror: - yyerror("syntax error"); -#if defined(lint) || defined(__GNUC__) - goto yyerrlab; -#endif -yyerrlab: - ++yynerrs; -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); -#endif - if (yyssp >= yysslim && yygrowstack()) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yyssp); -#endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; - } - } - } - else - { - if (yychar == 0) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = (-1); - goto yyloop; - } -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - yyval = yyvsp[1-yym]; - switch (yyn) - { -case 7: -#line 60 "boot.yy" -{ push_path(); } -break; -case 8: -#line 63 "boot.yy" -{ push_path(); } -break; -case 9: -#line 66 "boot.yy" -{ node_id = ""; extend_path(yyvsp[0], NODE_VOID, node_id); } -break; -case 10: -#line 67 "boot.yy" -{ node_id = yyvsp[-1]; - free(yyvsp[-1]); - extend_path(yyvsp[0], NODE_VOID, node_id); } -break; -case 12: -#line 73 "boot.yy" -{ extend_path(yyvsp[0], NODE_TEXT, node_id); } -break; -case 13: -#line 74 "boot.yy" -{ extend_path(yyvsp[0], NODE_TEXT, node_id); } -break; -case 14: -#line 75 "boot.yy" -{ extend_path(yyvsp[0], NODE_BOOL, node_id); } -break; -case 15: -#line 76 "boot.yy" -{ extend_path(yyvsp[0], NODE_UINTRANGE, node_id); } -break; -case 16: -#line 77 "boot.yy" -{ extend_path(yyvsp[0], NODE_UINT, node_id); } -break; -case 17: -#line 78 "boot.yy" -{ extend_path(yyvsp[0], NODE_IPV4RANGE, node_id); } -break; -case 18: -#line 79 "boot.yy" -{ extend_path(yyvsp[0], NODE_IPV4, node_id); } -break; -case 19: -#line 80 "boot.yy" -{ extend_path(yyvsp[0], NODE_IPV4NET, node_id); } -break; -case 20: -#line 81 "boot.yy" -{ extend_path(yyvsp[0], NODE_IPV6RANGE, node_id); } -break; -case 21: -#line 82 "boot.yy" -{ extend_path(yyvsp[0], NODE_IPV6, node_id); } -break; -case 22: -#line 83 "boot.yy" -{ extend_path(yyvsp[0], NODE_IPV6NET, node_id); } -break; -case 23: -#line 84 "boot.yy" -{ extend_path(yyvsp[0], NODE_MACADDR, node_id); } -break; -case 24: -#line 85 "boot.yy" -{ extend_path(yyvsp[0], NODE_URL_FILE, node_id); } -break; -case 25: -#line 86 "boot.yy" -{ extend_path(yyvsp[0], NODE_URL_FTP, node_id); } -break; -case 26: -#line 87 "boot.yy" -{ extend_path(yyvsp[0], NODE_URL_HTTP, node_id); } -break; -case 27: -#line 88 "boot.yy" -{ extend_path(yyvsp[0], NODE_URL_TFTP, node_id); } -break; -case 29: -#line 92 "boot.yy" -{ pop_path(); } -break; -case 30: -#line 95 "boot.yy" -{ pop_path(); } -break; -case 37: -#line 110 "boot.yy" -{ node_id = ""; extend_path(yyvsp[0], NODE_VOID, node_id); } -break; -case 38: -#line 111 "boot.yy" -{ node_id = yyvsp[-1]; - free(yyvsp[-1]); - extend_path(yyvsp[0], NODE_VOID, node_id);} -break; -case 39: -#line 116 "boot.yy" -{ - terminal(strdup(""), NODE_VOID, OP_NONE); - } -break; -case 40: -#line 119 "boot.yy" -{ - terminal(yyvsp[-1], NODE_TEXT, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 41: -#line 123 "boot.yy" -{ - terminal(yyvsp[-1], NODE_BOOL, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 42: -#line 127 "boot.yy" -{ - terminal(yyvsp[-1], NODE_UINTRANGE, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 43: -#line 131 "boot.yy" -{ - terminal(yyvsp[-1], NODE_UINT, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 44: -#line 135 "boot.yy" -{ - terminal(yyvsp[-1], NODE_IPV4RANGE, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 45: -#line 139 "boot.yy" -{ - terminal(yyvsp[-1], NODE_IPV4, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 46: -#line 143 "boot.yy" -{ - terminal(yyvsp[-1], NODE_IPV4NET, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 47: -#line 147 "boot.yy" -{ - terminal(yyvsp[-1], NODE_IPV6RANGE, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 48: -#line 151 "boot.yy" -{ - terminal(yyvsp[-1], NODE_IPV6, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 49: -#line 155 "boot.yy" -{ - terminal(yyvsp[-1], NODE_IPV6NET, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 50: -#line 159 "boot.yy" -{ - terminal(yyvsp[-1], NODE_MACADDR, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 51: -#line 163 "boot.yy" -{ - terminal(yyvsp[-1], NODE_URL_FILE, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 52: -#line 167 "boot.yy" -{ - terminal(yyvsp[-1], NODE_URL_FTP, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 53: -#line 171 "boot.yy" -{ - terminal(yyvsp[-1], NODE_URL_HTTP, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 54: -#line 175 "boot.yy" -{ - terminal(yyvsp[-1], NODE_URL_TFTP, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 55: -#line 179 "boot.yy" -{ - terminal(yyvsp[-1], NODE_ARITH, boot_lookup_operator(yyvsp[-2])); - free(yyvsp[-2]); - } -break; -case 56: -#line 185 "boot.yy" -{ - booterror("syntax error"); - } -break; -#line 836 "y.boot_tab.c" - } - yyssp -= yym; - yystate = *yyssp; - yyvsp -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == 0) goto yyaccept; - goto yyloop; - } - if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yyssp, yystate); -#endif - if (yyssp >= yysslim && yygrowstack()) - { - goto yyoverflow; - } - *++yyssp = yystate; - *++yyvsp = yyval; - goto yyloop; -yyoverflow: - yyerror("yacc stack overflow"); -yyabort: - return (1); -yyaccept: - return (0); -} -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:39:37 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:39:37 +0100 Subject: [Xorp-hackers] [PATCH 04/10] xorp: rtrmgr: Removed y.opcmd_tab.cc In-Reply-To: <1331635183-3800-1-git-send-email-igorm@etf.rs> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> Message-ID: <1331635183-3800-5-git-send-email-igorm@etf.rs> From: Igor Maravic It will be automatically generated with bison. Signed-off-by: Igor Maravic --- xorp/rtrmgr/y.opcmd_tab.cc | 954 -------------------------------------------- 1 files changed, 0 insertions(+), 954 deletions(-) delete mode 100644 xorp/rtrmgr/y.opcmd_tab.cc diff --git a/xorp/rtrmgr/y.opcmd_tab.cc b/xorp/rtrmgr/y.opcmd_tab.cc deleted file mode 100644 index ca9c08d..0000000 --- a/xorp/rtrmgr/y.opcmd_tab.cc +++ /dev/null @@ -1,954 +0,0 @@ -#ifndef lint - -#endif -#include -#define YYBYACC 1 -#define YYMAJOR 1 -#define YYMINOR 9 -#define YYLEX yylex() -#define YYEMPTY -1 -#define yyclearin (yychar=(YYEMPTY)) -#define yyerrok (yyerrflag=0) -#define YYRECOVERING() (yyerrflag!=0) -#if defined(__cplusplus) || __STDC__ -static int yygrowstack(void); -#else -static int yygrowstack(); -#endif -#define yyparse opcmdparse -#define yylex opcmdlex -#define yyerror opcmderror -#define yychar opcmdchar -#define yyval opcmdval -#define yylval opcmdlval -#define yydebug opcmddebug -#define yynerrs opcmdnerrs -#define yyerrflag opcmderrflag -#define yyss opcmdss -#define yyssp opcmdssp -#define yyvs opcmdvs -#define yyvsp opcmdvsp -#define yylhs opcmdlhs -#define yylen opcmdlen -#define yydefred opcmddefred -#define yydgoto opcmddgoto -#define yysindex opcmdsindex -#define yyrindex opcmdrindex -#define yygindex opcmdgindex -#define yytable opcmdtable -#define yycheck opcmdcheck -#define yyname opcmdname -#define yyrule opcmdrule -#define yysslim opcmdsslim -#define yystacksize opcmdstacksize -#define YYPREFIX "opcmd" -#line 2 "op_commands.yy" -#define YYSTYPE char* - -#include -#include - - - -#include "rtrmgr_module.h" -#include "libxorp/xorp.h" -#include "libxorp/xlog.h" -#include "libxorp/utils.hh" - -#include "op_commands.hh" -#include "util.hh" - -/* XXX: sigh - -p flag to yacc should do this for us */ -#define yystacksize opcmdstacksize -#define yysslim opcmdsslim -#line 66 "y.opcmd_tab.c" -#define YYERRCODE 256 -#define UPLEVEL 257 -#define DOWNLEVEL 258 -#define END 259 -#define COLON 260 -#define CMD_MODULE 261 -#define CMD_COMMAND 262 -#define CMD_HELP 263 -#define CMD_OPT_PARAMETER 264 -#define CMD_TAG 265 -#define CMD_NOMORE_MODE 266 -#define VARIABLE 267 -#define WILDCARD 268 -#define LITERAL 269 -#define STRING 270 -#define SYNTAX_ERROR 271 -const short opcmdlhs[] = { -1, - 0, 0, 0, 1, 4, 4, 6, 6, 6, 3, - 7, 8, 5, 9, 11, 10, 10, 12, 12, 12, - 12, 12, 13, 14, 15, 16, 18, 18, 17, 2, -}; -const short opcmdlen[] = { 2, - 0, 2, 1, 3, 0, 2, 1, 1, 1, 1, - 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, - 1, 1, 4, 5, 5, 5, 3, 3, 2, 1, -}; -const short opcmddefred[] = { 0, - 10, 30, 0, 0, 3, 0, 2, 11, 12, 7, - 0, 0, 8, 9, 14, 4, 0, 6, 0, 0, - 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, - 0, 0, 0, 0, 29, 15, 13, 17, 0, 0, - 0, 0, 23, 0, 0, 0, 0, 0, 24, 25, - 26, 27, 28, -}; -const short opcmddgoto[] = { 3, - 4, 5, 6, 11, 16, 12, 13, 14, 17, 24, - 37, 25, 26, 27, 28, 29, 30, 45, -}; -const short opcmdsindex[] = { -259, - 0, 0, 0, -259, 0, -266, 0, 0, 0, 0, - -246, -266, 0, 0, 0, 0, -257, 0, -245, -244, - -243, -242, -240, -238, -257, 0, 0, 0, 0, 0, - -248, -247, -241, -239, 0, 0, 0, 0, -237, -236, - -236, -235, 0, -234, -231, -228, -227, -256, 0, 0, - 0, 0, 0, -}; -const short opcmdrindex[] = { 24, - 0, 0, 0, 24, 0, -232, 0, 0, 0, 0, - 0, -232, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -225, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, -}; -const short opcmdgindex[] = { 30, - 0, 0, -6, 25, 0, 0, 0, 0, 0, 11, - 0, 0, 0, 0, 0, 0, 0, -3, -}; -#define YYTABLESIZE 38 -const short opcmdtable[] = { 10, - 8, 9, 1, 19, 20, 10, 21, 22, 23, 1, - 15, 2, 52, 53, 31, 32, 33, 34, 35, 36, - 39, 43, 40, 1, 5, 48, 44, 49, 41, 42, - 50, 51, 16, 7, 47, 38, 18, 46, -}; -const short opcmdcheck[] = { 6, - 267, 268, 269, 261, 262, 12, 264, 265, 266, 269, - 257, 271, 269, 270, 260, 260, 260, 260, 259, 258, - 269, 259, 270, 0, 257, 260, 263, 259, 270, 269, - 259, 259, 258, 4, 270, 25, 12, 41, -}; -#define YYFINAL 3 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 271 -#if YYDEBUG -const char * const opcmdname[] = { -"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"UPLEVEL","DOWNLEVEL","END", -"COLON","CMD_MODULE","CMD_COMMAND","CMD_HELP","CMD_OPT_PARAMETER","CMD_TAG", -"CMD_NOMORE_MODE","VARIABLE","WILDCARD","LITERAL","STRING","SYNTAX_ERROR", -}; -const char * const opcmdrule[] = { -"$accept : input", -"input :", -"input : definition input", -"input : syntax_error", -"definition : word word_or_variable_list specification", -"word_or_variable_list :", -"word_or_variable_list : word_or_variable word_or_variable_list", -"word_or_variable : word", -"word_or_variable : variable", -"word_or_variable : wildcard", -"word : LITERAL", -"variable : VARIABLE", -"wildcard : WILDCARD", -"specification : startspec attributes endspec", -"startspec : UPLEVEL", -"endspec : DOWNLEVEL", -"attributes : attribute", -"attributes : attribute attributes", -"attribute : cmd_module", -"attribute : cmd_command", -"attribute : cmd_opt_parameter", -"attribute : cmd_tag", -"attribute : cmd_nomore_mode", -"cmd_module : CMD_MODULE COLON LITERAL END", -"cmd_command : CMD_COMMAND COLON STRING cmd_help END", -"cmd_opt_parameter : CMD_OPT_PARAMETER COLON STRING cmd_help END", -"cmd_tag : CMD_TAG COLON LITERAL STRING END", -"cmd_help : CMD_HELP COLON LITERAL", -"cmd_help : CMD_HELP COLON STRING", -"cmd_nomore_mode : CMD_NOMORE_MODE END", -"syntax_error : SYNTAX_ERROR", -}; -#endif -#ifndef YYSTYPE -typedef int YYSTYPE; -#endif -#if YYDEBUG -#include -#endif -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif -#define YYINITSTACKSIZE 200 -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -short *yyssp; -YYSTYPE *yyvsp; -YYSTYPE yyval; -YYSTYPE yylval; -short *yyss; -short *yysslim; -YYSTYPE *yyvs; -int yystacksize; -#line 125 "op_commands.yy" - -extern "C" int opcmdparse(); -extern int opcmdlex(); -extern FILE *opcmdin; -extern int opcmd_linenum; - -void opcmderror(const char *s) throw (ParseError); -void opcmd_warning(const char *s); - -static OpCommandList *ocl = NULL; -static list path_segments; -static list >path_segments_stack; -static list op_command_stack; -static list op_command_tag_help_stack; -static list > opt_params_tag_help_stack; -static list > tags_stack; -static bool is_help_tag = false; -static string help_tag; -static string help_string; - -static string opcmd_filename; -static string lastsymbol; - - -// Strip the quotes, the heading and trailing empty space -static string -strip_quotes_and_empty_space(const string& s) -{ - string res; - - // Strip the quotes - if ((s.length() < 2) || (s[0] != '"') || (s[s.length() - 1] != '"')) { - string errmsg = c_format("Internal parser error: %s " - "is not a quoted string", - s.c_str()); - opcmderror(errmsg.c_str()); - } - res = unquote(s); - - // Strip the heading and trailing empty spaces - res = strip_empty_spaces(res); - - return res; -} - -static void -resolve_tag(const string& tag, string& value) -{ - map& tags = tags_stack.back(); - map::iterator iter; - - iter = tags.find(tag); - if (iter == tags.end()) { - string errmsg = c_format("Cannot resolve tag %s", tag.c_str()); - opcmderror(errmsg.c_str()); - } - - value = iter->second; -} - -static void -append_path_word(char *s) -{ - string word = s; - lastsymbol = s; - free(s); - - path_segments.push_back(word); -} - -static void -append_path_variable(char *s) -{ - string variable = s; - lastsymbol = s; - free(s); - - // Check if a valid variable name - if (ocl->check_variable_name(variable) == false) { - string errmsg = c_format("Bad variable name: %s", variable.c_str()); - opcmderror(errmsg.c_str()); - } - path_segments.push_back(variable); -} - -static void -push_path() -{ - if (! path_segments_stack.empty()) { - // Extend the nested path - list& tmp_prefix = path_segments_stack.back(); - path_segments.insert(path_segments.begin(), - tmp_prefix.begin(), tmp_prefix.end()); - } - path_segments_stack.push_back(path_segments); - - OpCommand *existing_command = ocl->find_op_command(path_segments); - if (existing_command != NULL) { - string errmsg = c_format("Duplicate command: %s", - existing_command->command_name().c_str()); - opcmderror(errmsg.c_str()); - } - - // Push all temporary state storage into the stack - map dummy_map; - OpCommand op_command(*ocl, path_segments); - op_command_stack.push_back(op_command); - op_command_tag_help_stack.push_back(""); - opt_params_tag_help_stack.push_back(dummy_map); - tags_stack.push_back(dummy_map); -} - -static void -pop_path() -{ - string help; - - if (op_command_stack.empty()) - opcmderror("Invalid end of block"); - - OpCommand& op_command = op_command_stack.back(); - - if (! op_command.is_invalid()) { - // Resolve the command help (if tagged) - string& op_command_tag_help = op_command_tag_help_stack.back(); - if (! op_command_tag_help.empty()) { - resolve_tag(op_command_tag_help, help); - op_command.set_help_string(help); - } - - // Resolve the optional parameters help (if tagged) - map& opt_params_tag_help = opt_params_tag_help_stack.back(); - map::iterator iter; - for (iter = opt_params_tag_help.begin(); - iter != opt_params_tag_help.end(); - ++iter) { - string opt_param = iter->first; - string tag = iter->second; - resolve_tag(tag, help); - op_command.add_opt_param(opt_param, help); - } - - // Add the command - if (ocl->add_op_command(op_command) == NULL) { - string errmsg = c_format("Cannot add command %s: internal error", - op_command.command_name().c_str()); - opcmderror(errmsg.c_str()); - } - } - - // Clear the path segments - path_segments.clear(); - - // Pop from the stack all temporary state - path_segments_stack.pop_back(); - op_command_stack.pop_back(); - op_command_tag_help_stack.pop_back(); - opt_params_tag_help_stack.pop_back(); - tags_stack.pop_back(); -} - -static void -add_cmd_module(char *s) -{ - string module = s; - lastsymbol = s; - free(s); - - OpCommand& op_command = op_command_stack.back(); - if (! op_command.module().empty()) { - string errmsg = c_format("Module name already set to %s " - "(only one module allowed per command)", - op_command.module().c_str()); - opcmderror(errmsg.c_str()); - } - op_command.set_module(module); -} - -static void -add_cmd_command(char *s) -{ - string command = s; - lastsymbol = s; - free(s); - - // - // XXX: note that we allow the command itself to be empty - // (e.g., if the entry is for an intermediate node in the hierarchy). - // - command = strip_quotes_and_empty_space(command); - - // Split the command filename from the arguments - string filename, arguments; - for (size_t i = 0; i < command.length(); i++) { - if ((command[i] == ' ') || (command[i] == '\t')) { - filename = command.substr(0, i); - arguments = command.substr(i); - break; - } - } - if (filename.empty()) - filename = command; - - // Get a reference to the OpCommand instance - OpCommand& op_command = op_command_stack.back(); - if (! op_command.command_action().empty()) { - string errmsg = c_format("Command action already set to %s " - "(only one action allowed per command)", - op_command.command_action().c_str()); - opcmderror(errmsg.c_str()); - } - - // Find the executable filename - string executable_filename; - if (! filename.empty()) { - executable_filename = find_executable_filename(filename); - if (executable_filename.empty()) { - op_command.set_is_invalid(true); - string errmsg = c_format("Executable file not found: %s", - filename.c_str()); - opcmd_warning(errmsg.c_str()); - return; - } - } - - // - // Split the arguments and verify that the positional arguments - // (e.g., $0, $1, etc) are resolvable. - // - list command_action_argument_list; - string current_argument; - for (size_t i = 0; i < arguments.length(); i++) { - if ((arguments[i] == ' ') || (arguments[i] == '\t')) { - if (! current_argument.empty()) { - command_action_argument_list.push_back(current_argument); - current_argument.erase(); - } - continue; - } - current_argument += arguments[i]; - } - // Add the last argument - if (! current_argument.empty()) { - command_action_argument_list.push_back(current_argument); - current_argument.erase(); - } - // Verify the positional arguments - list::const_iterator iter; - for (iter = command_action_argument_list.begin(); - iter != command_action_argument_list.end(); - ++iter) { - const string& arg = *iter; - if (arg.empty()) { - string errmsg = c_format("Internal error spliting the positional " - "arguments"); - opcmderror(errmsg.c_str()); - } - if (arg[0] == '$') { - string errmsg; - list resolved_arguments; - resolved_arguments = op_command.select_positional_argument( - op_command.command_parts(), arg, errmsg); - if (resolved_arguments.empty()) { - opcmderror(errmsg.c_str()); - } - } - } - - op_command.set_command_action(command); - op_command.set_command_action_filename(filename); - op_command.set_command_action_argument_list(command_action_argument_list); - op_command.set_command_executable_filename(executable_filename); - - if (is_help_tag) { - string& op_command_tag_help = op_command_tag_help_stack.back(); - op_command_tag_help = help_tag; - return; - } - - op_command.set_help_string(help_string); -} - -static void -add_cmd_opt_parameter(char *s) -{ - string opt_parameter = s; - lastsymbol = s; - free(s); - - opt_parameter = strip_quotes_and_empty_space(opt_parameter); - if (opt_parameter.empty()) { - opcmderror("Invalid emtpy optional parameter"); - } - - OpCommand& op_command = op_command_stack.back(); - map& opt_params_tag_help = opt_params_tag_help_stack.back(); - if (op_command.has_opt_param(opt_parameter) - || (opt_params_tag_help.find(opt_parameter) - != opt_params_tag_help.end())) { - string errmsg = c_format("Duplicated optional parameter %s", - opt_parameter.c_str()); - opcmderror(errmsg.c_str()); - } - - if (is_help_tag) { - opt_params_tag_help.insert(make_pair(opt_parameter, help_tag)); - return; - } - - op_command.add_opt_param(opt_parameter, help_string); -} - -static void -add_cmd_tag(char *t, char *v) -{ - string tag = t; - string value = v; - lastsymbol = v; - free(t); - free(v); - - map& tags = tags_stack.back(); - if (tags.find(tag) != tags.end()) { - string errmsg = c_format("Duplicated tag %s", tag.c_str()); - opcmderror(errmsg.c_str()); - } - - // Strip the quotes - value = strip_quotes_and_empty_space(value); - - tags.insert(make_pair(tag, value)); -} - -static void -add_cmd_help_tag(char *s) -{ - string tag = s; - lastsymbol = s; - free(s); - - help_tag = tag; - is_help_tag = true; -} - -static void -add_cmd_help_string(char *s) -{ - string help = s; - lastsymbol = s; - free(s); - - // Strip the quotes - help = strip_quotes_and_empty_space(help); - - help_string = help; - is_help_tag = false; -} - -static void -set_nomore_mode(bool v) -{ - OpCommand& op_command = op_command_stack.back(); - op_command.set_default_nomore_mode(v); -} - -void -opcmderror(const char *s) throw (ParseError) -{ - string errmsg; - - errmsg = c_format("PARSE ERROR [Operational Command File: %s line %d]: %s", - opcmd_filename.c_str(), opcmd_linenum, s); - errmsg += c_format("; Last symbol parsed was \"%s\"", lastsymbol.c_str()); - - xorp_throw(ParseError, errmsg); -} - -void -opcmd_warning(const char *s) -{ - string errmsg; - - errmsg = c_format("[Operational Command File: %s line %d]: %s", - opcmd_filename.c_str(), opcmd_linenum, s); - XLOG_WARNING("%s", errmsg.c_str()); -} - -int -init_opcmd_parser(const char *filename, OpCommandList *o) -{ - ocl = o; - opcmd_linenum = 1; - - opcmdin = fopen(filename, "r"); - if (opcmdin == NULL) - return -1; - - opcmd_filename = filename; - return 0; -} - -void -parse_opcmd() throw (ParseError) -{ - if (opcmdparse() != 0) - opcmderror("unknown error"); -} -#line 627 "y.opcmd_tab.c" -/* allocate initial stack or double stack size, up to YYMAXDEPTH */ -static int yygrowstack() -{ - int newsize, i; - short *newss; - YYSTYPE *newvs; - - if ((newsize = yystacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return -1; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - i = yyssp - yyss; - newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) : - (short *)malloc(newsize * sizeof *newss); - if (newss == NULL) - return -1; - yyss = newss; - yyssp = newss + i; - newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) : - (YYSTYPE *)malloc(newsize * sizeof *newvs); - if (newvs == NULL) - return -1; - yyvs = newvs; - yyvsp = newvs + i; - yystacksize = newsize; - yysslim = yyss + newsize - 1; - return 0; -} - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab - -#ifndef YYPARSE_PARAM -#if defined(__cplusplus) || __STDC__ -#define YYPARSE_PARAM_ARG void -#define YYPARSE_PARAM_DECL -#else /* ! ANSI-C/C++ */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* ANSI-C/C++ */ -#else /* YYPARSE_PARAM */ -#ifndef YYPARSE_PARAM_TYPE -#define YYPARSE_PARAM_TYPE void * -#endif -#if defined(__cplusplus) || __STDC__ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* ! ANSI-C/C++ */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM; -#endif /* ANSI-C/C++ */ -#endif /* ! YYPARSE_PARAM */ - -int -yyparse (YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - register int yym, yyn, yystate; -#if YYDEBUG - register const char *yys; - - if ((yys = getenv("YYDEBUG"))) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yynerrs = 0; - yyerrflag = 0; - yychar = (-1); - - if (yyss == NULL && yygrowstack()) goto yyoverflow; - yyssp = yyss; - yyvsp = yyvs; - *yyssp = yystate = 0; - -yyloop: - if ((yyn = yydefred[yystate])) goto yyreduce; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yyssp >= yysslim && yygrowstack()) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - yychar = (-1); - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; -#if defined(lint) || defined(__GNUC__) - goto yynewerror; -#endif -yynewerror: - yyerror("syntax error"); -#if defined(lint) || defined(__GNUC__) - goto yyerrlab; -#endif -yyerrlab: - ++yynerrs; -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); -#endif - if (yyssp >= yysslim && yygrowstack()) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yyssp); -#endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; - } - } - } - else - { - if (yychar == 0) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = (-1); - goto yyloop; - } -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - yyval = yyvsp[1-yym]; - switch (yyn) - { -case 4: -#line 46 "op_commands.yy" -{ } -break; -case 6: -#line 50 "op_commands.yy" -{ } -break; -case 10: -#line 58 "op_commands.yy" -{ append_path_word(yyvsp[0]); } -break; -case 11: -#line 61 "op_commands.yy" -{ append_path_variable(yyvsp[0]); } -break; -case 12: -#line 64 "op_commands.yy" -{ append_path_word(yyvsp[0]); } -break; -case 13: -#line 67 "op_commands.yy" -{ } -break; -case 14: -#line 70 "op_commands.yy" -{ push_path(); } -break; -case 15: -#line 73 "op_commands.yy" -{ pop_path(); } -break; -case 23: -#line 87 "op_commands.yy" -{ - add_cmd_module(yyvsp[-1]); - } -break; -case 24: -#line 92 "op_commands.yy" -{ - add_cmd_command(yyvsp[-2]); - } -break; -case 25: -#line 97 "op_commands.yy" -{ - add_cmd_opt_parameter(yyvsp[-2]); - } -break; -case 26: -#line 102 "op_commands.yy" -{ - add_cmd_tag(yyvsp[-2], yyvsp[-1]); - } -break; -case 27: -#line 107 "op_commands.yy" -{ - add_cmd_help_tag(yyvsp[0]); - } -break; -case 28: -#line 110 "op_commands.yy" -{ - add_cmd_help_string(yyvsp[0]); - } -break; -case 29: -#line 115 "op_commands.yy" -{ - set_nomore_mode(true); - } -break; -case 30: -#line 120 "op_commands.yy" -{ opcmderror("syntax error"); } -break; -#line 900 "y.opcmd_tab.c" - } - yyssp -= yym; - yystate = *yyssp; - yyvsp -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == 0) goto yyaccept; - goto yyloop; - } - if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yyssp, yystate); -#endif - if (yyssp >= yysslim && yygrowstack()) - { - goto yyoverflow; - } - *++yyssp = yystate; - *++yyvsp = yyval; - goto yyloop; -yyoverflow: - yyerror("yacc stack overflow"); -yyabort: - return (1); -yyaccept: - return (0); -} -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:39:43 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:39:43 +0100 Subject: [Xorp-hackers] [PATCH 10/10] xorp: Automatically generate lex and yacc files In-Reply-To: <1331635183-3800-1-git-send-email-igorm@etf.rs> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> Message-ID: <1331635183-3800-11-git-send-email-igorm@etf.rs> From: Igor Maravic In xorp/site_scons/config/allconfig.py added checks if 'flex' and 'bison' are installed. If they aren't instructs user how to install them (instructions are for Ubuntu and Fedora). Change xorp/rtrmgr/SConscript to automatically generate yacc and lex files with bison and flex. In CPPPATH added env['xorp_sorcedir'] so generated files could include necessary files. Also did minor changes in .yy and .ll files, so they would compile. Unfortunately Eclipse striped whitespaces from changed files, so they are meshed up with the changed code. Signed-off-by: Igor Maravic --- xorp/rtrmgr/SConscript | 79 +++++++++++++++------ xorp/rtrmgr/boot.ll | 6 +- xorp/rtrmgr/boot.yy | 64 ++++++++++++----- xorp/rtrmgr/op_commands.cc | 8 +- xorp/rtrmgr/op_commands.ll | 4 +- xorp/rtrmgr/op_commands.yy | 132 +++++++++++++++++++++++++---------- xorp/rtrmgr/template.ll | 4 +- xorp/rtrmgr/template.yy | 97 ++++++++++++++++++------- xorp/site_scons/config/allconfig.py | 15 ++++ 9 files changed, 295 insertions(+), 114 deletions(-) diff --git a/xorp/rtrmgr/SConscript b/xorp/rtrmgr/SConscript index adf2f1c..ebe930c 100644 --- a/xorp/rtrmgr/SConscript +++ b/xorp/rtrmgr/SConscript @@ -30,9 +30,10 @@ SConscript(dirs = subdirs, exports='env') env = env.Clone() env.AppendUnique(CPPPATH = [ - '#', - '$BUILDDIR', - ]) + '.', + '$BUILDDIR', + env['xorp_sourcedir'], #this is needed for lex and yacc generated files + ]) env.PrependUnique(LIBPATH = [ '$BUILDDIR/libxorp', @@ -50,20 +51,52 @@ env.PrependUnique(LIBPATH = [ libxorp_rtrmgr_env = env.Clone() -# FIXME generate lex/yacc from source -# shorthand this plz -# see http://209.85.229.132/search?q=cache:3j0AsRORc6MJ:https://gforge.inria.fr/plugins/scmsvn/viewcvs.php/scons_util/trunk/src/platform.py%3Frev%3D18%26root%3Dopenalea%26view%3Dmarkup+scons+lexflags+append&cd=2&hl=en&ct=clnk&gl=uk&client=firefox-a -# ... needs toolchain check for flex 2.5.4 or poss more recent. -# known to work with freebsd base system flex. -#tplt_env = env.Clone() -#tplt_env.AppendUnique(LEXFLAGS='-Ptplt') -#tplt_env.CXXFile(source='template.ll', target='lex.tplt.cc') -#boot_env = env.Clone() -#boot_env.AppendUnique(LEXFLAGS='-Pboot') -#boot_env.CXXFile(source='boot.ll', target='lex.boot.cc') -#opcmd_env = env.Clone() -#opcmd_env.AppendUnique(LEXFLAGS='-Popcmd') -#opcmd_env.CXXFile(source='op_commands.ll', target='lex.opcmd.cc') +# Automatically generate flex and yacc files + +#Create yacc files +yacc_env = env.Clone() +yacc_env.Replace(YACCHXXFILESUFFIX='.hh') +yacc_env.AppendUnique(YACCFLAGS='-d') + + +tplt_env_y = yacc_env.Clone() +tplt_env_y.AppendUnique(YACCFLAGS='-ptplt') + +tplt_yacc = tplt_env_y.CXXFile(target='y.tplt_tab.cc', + source='template.yy') + +boot_env_y = yacc_env.Clone() +boot_env_y.AppendUnique(YACCFLAGS='-pboot') + +boot_yacc = boot_env_y.CXXFile(target='y.boot_tab.cc', + source='boot.yy') + +opcmd_env_y = yacc_env.Clone() +opcmd_env_y.AppendUnique(YACCFLAGS='-popcmd') + +opcmd_yacc = opcmd_env_y.CXXFile(target='y.opcmd_tab.cc', + source='op_commands.yy') + +#create lex files +lex_env = env.Clone() + +tplt_env_l = lex_env.Clone() +tplt_env_l.AppendUnique(LEXFLAGS='-Ptplt') + +tplt_lex = tplt_env_l.CXXFile(target='lex.tplt.cc', + source='template.ll') + +boot_env_l = lex_env.Clone() +boot_env_l.AppendUnique(LEXFLAGS='-Pboot') + +boot_lex = boot_env_l.CXXFile(target='lex.boot.cc', + source='boot.ll') + +opcmd_env_l = lex_env.Clone() +opcmd_env_l.AppendUnique(LEXFLAGS='-Popcmd') + +opcmd_lex = opcmd_env_l.CXXFile(target='lex.opcmd.cc', + source='op_commands.ll') libxorp_rtrmgr_srcs = [ 'command_tree.cc', @@ -72,9 +105,12 @@ libxorp_rtrmgr_srcs = [ 'config_operators.cc', 'generic_module_manager.cc', 'glob_win32.c', - 'lex.boot.cc', - 'lex.opcmd.cc', - 'lex.tplt.cc', + tplt_lex[0], + opcmd_lex[0], + boot_lex[0], + opcmd_yacc[0], + boot_yacc[0], + tplt_yacc[0], 'master_conf_tree.cc', 'master_conf_tree_node.cc', 'master_template_tree.cc', @@ -95,9 +131,6 @@ libxorp_rtrmgr_srcs = [ 'unexpanded_xrl.cc', 'userdb.cc', 'xorp_client.cc', - 'y.boot_tab.cc', - 'y.opcmd_tab.cc', - 'y.tplt_tab.cc', ] # Runtime XRL syntax validation for developers. diff --git a/xorp/rtrmgr/boot.ll b/xorp/rtrmgr/boot.ll index 6ea8991..3f1d5c4 100644 --- a/xorp/rtrmgr/boot.ll +++ b/xorp/rtrmgr/boot.ll @@ -9,16 +9,18 @@ #undef __unused #endif +#define YYSTYPE char* + #include "libxorp/xorp.h" -#include "y.boot_tab.h" +#include "y.boot_tab.hh" #ifdef __xorp_unused #define __unused __xorp_unused #undef __xorp_unused #endif + %} int boot_linenum = 1; - extern char* bootlval; string parsebuf; int arith_nesting; bool arith_op_allowed; diff --git a/xorp/rtrmgr/boot.yy b/xorp/rtrmgr/boot.yy index 6fb5939..f815477 100644 --- a/xorp/rtrmgr/boot.yy +++ b/xorp/rtrmgr/boot.yy @@ -18,6 +18,49 @@ /* XXX: sigh - -p flag to yacc should do this for us */ #define yystacksize bootstacksize #define yysslim bootsslim + +/** + * Forward declarations + */ +extern void boot_scan_string(const char *configuration); +extern int boot_linenum; +extern "C" int bootparse(); +extern int bootlex(); + +void booterror(const char *s) throw (ParseError); + +static ConfigTree *config_tree = NULL; +static string boot_filename; +static string lastsymbol; +static string node_id; + +/** + * Function declarations + */ +static void +extend_path(char* segment, int type, const string& node_id_str); + +static void +push_path(); + +static void +pop_path(); + +static void +terminal(char* value, int type, ConfigOperator op); + +void +booterror(const char *s) throw (ParseError); + +int +init_bootfile_parser(const char *configuration, + const char *filename, + ConfigTree *ct); + +void +parse_bootfile() throw (ParseError); + +ConfigOperator boot_lookup_operator(const char* s); %} %token UPLEVEL @@ -190,20 +233,7 @@ syntax_error: SYNTAX_ERROR { %% -extern void boot_scan_string(const char *configuration); -extern int boot_linenum; -extern "C" int bootparse(); -extern int bootlex(); - -void booterror(const char *s) throw (ParseError); - -static ConfigTree *config_tree = NULL; -static string boot_filename; -static string lastsymbol; -static string node_id; - - -static void +void extend_path(char* segment, int type, const string& node_id_str) { lastsymbol = segment; @@ -221,19 +251,19 @@ extend_path(char* segment, int type, const string& node_id_str) } } -static void +void push_path() { config_tree->push_path(); } -static void +void pop_path() { config_tree->pop_path(); } -static void +void terminal(char* value, int type, ConfigOperator op) { push_path(); diff --git a/xorp/rtrmgr/op_commands.cc b/xorp/rtrmgr/op_commands.cc index a169714..10c48c3 100644 --- a/xorp/rtrmgr/op_commands.cc +++ b/xorp/rtrmgr/op_commands.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -48,7 +48,7 @@ #include "slave_conf_tree.hh" #include "template_tree.hh" #include "slave_module_manager.hh" -#include "y.opcmd_tab.h" +#include "y.opcmd_tab.hh" #ifdef HOST_OS_WINDOWS @@ -358,7 +358,7 @@ OpCommand::execute(EventLoop& eventloop, const list& command_line, _command_executable_filename, resolved_command_argument_list, print_cb, done_cb); - + return opinst; } diff --git a/xorp/rtrmgr/op_commands.ll b/xorp/rtrmgr/op_commands.ll index d3faae7..765cf6c 100644 --- a/xorp/rtrmgr/op_commands.ll +++ b/xorp/rtrmgr/op_commands.ll @@ -9,9 +9,10 @@ #undef __unused #endif +#define YYSTYPE char* #include "libxorp/xorp.h" #include -#include "y.opcmd_tab.h" +#include "y.opcmd_tab.hh" #ifdef __xorp_unused #define __unused __xorp_unused @@ -19,7 +20,6 @@ #endif %} int opcmd_linenum = 1; - extern char* opcmdlval; string opcmd_parsebuf; %option noyywrap %option nounput diff --git a/xorp/rtrmgr/op_commands.yy b/xorp/rtrmgr/op_commands.yy index 0eb653f..63cdfa1 100644 --- a/xorp/rtrmgr/op_commands.yy +++ b/xorp/rtrmgr/op_commands.yy @@ -3,6 +3,7 @@ #include #include +#include #include @@ -17,6 +18,86 @@ /* XXX: sigh - -p flag to yacc should do this for us */ #define yystacksize opcmdstacksize #define yysslim opcmdsslim + +/** + * Forward declarations + */ +extern "C" int opcmdparse(); +extern int opcmdlex(); +extern FILE *opcmdin; +extern int opcmd_linenum; + +void opcmderror(const char *s) throw (ParseError); +void opcmd_warning(const char *s); + +static OpCommandList *ocl = NULL; +static list path_segments; +static list >path_segments_stack; +static list op_command_stack; +static list op_command_tag_help_stack; +static list > opt_params_tag_help_stack; +static list > tags_stack; +static bool is_help_tag = false; +static string help_tag; +static string help_string; + +static string opcmd_filename; +static string lastsymbol; + +/** + * Function declarations + */ +static string +strip_quotes_and_empty_space(const string& s); + +static void +resolve_tag(const string& tag, string& value); + +static void +append_path_word(char *s); + +static void +append_path_variable(char *s); + +static void +push_path(); + +static void +pop_path(); + +static void +add_cmd_module(char *s); + +static void +add_cmd_command(char *s); + +static void +add_cmd_opt_parameter(char *s); + +static void +add_cmd_tag(char *t, char *v); + +static void +add_cmd_help_tag(char *s); + +static void +add_cmd_help_string(char *s); + +static void +set_nomore_mode(bool v); + +void +opcmderror(const char *s) throw (ParseError); + +void +opcmd_warning(const char *s); + +int +init_opcmd_parser(const char *filename, OpCommandList *o); + +void +parse_opcmd() throw (ParseError); + %} %token UPLEVEL @@ -123,31 +204,8 @@ syntax_error: SYNTAX_ERROR { opcmderror("syntax error"); } %% -extern "C" int opcmdparse(); -extern int opcmdlex(); -extern FILE *opcmdin; -extern int opcmd_linenum; - -void opcmderror(const char *s) throw (ParseError); -void opcmd_warning(const char *s); - -static OpCommandList *ocl = NULL; -static list path_segments; -static list >path_segments_stack; -static list op_command_stack; -static list op_command_tag_help_stack; -static list > opt_params_tag_help_stack; -static list > tags_stack; -static bool is_help_tag = false; -static string help_tag; -static string help_string; - -static string opcmd_filename; -static string lastsymbol; - - // Strip the quotes, the heading and trailing empty space -static string +string strip_quotes_and_empty_space(const string& s) { string res; @@ -167,7 +225,7 @@ strip_quotes_and_empty_space(const string& s) return res; } -static void +void resolve_tag(const string& tag, string& value) { map& tags = tags_stack.back(); @@ -182,7 +240,7 @@ resolve_tag(const string& tag, string& value) value = iter->second; } -static void +void append_path_word(char *s) { string word = s; @@ -192,7 +250,7 @@ append_path_word(char *s) path_segments.push_back(word); } -static void +void append_path_variable(char *s) { string variable = s; @@ -207,7 +265,7 @@ append_path_variable(char *s) path_segments.push_back(variable); } -static void +void push_path() { if (! path_segments_stack.empty()) { @@ -234,7 +292,7 @@ push_path() tags_stack.push_back(dummy_map); } -static void +void pop_path() { string help; @@ -283,7 +341,7 @@ pop_path() tags_stack.pop_back(); } -static void +void add_cmd_module(char *s) { string module = s; @@ -300,7 +358,7 @@ add_cmd_module(char *s) op_command.set_module(module); } -static void +void add_cmd_command(char *s) { string command = s; @@ -404,7 +462,7 @@ add_cmd_command(char *s) op_command.set_help_string(help_string); } -static void +void add_cmd_opt_parameter(char *s) { string opt_parameter = s; @@ -434,7 +492,7 @@ add_cmd_opt_parameter(char *s) op_command.add_opt_param(opt_parameter, help_string); } -static void +void add_cmd_tag(char *t, char *v) { string tag = t; @@ -455,7 +513,7 @@ add_cmd_tag(char *t, char *v) tags.insert(make_pair(tag, value)); } -static void +void add_cmd_help_tag(char *s) { string tag = s; @@ -466,7 +524,7 @@ add_cmd_help_tag(char *s) is_help_tag = true; } -static void +void add_cmd_help_string(char *s) { string help = s; @@ -480,11 +538,11 @@ add_cmd_help_string(char *s) is_help_tag = false; } -static void +void set_nomore_mode(bool v) { OpCommand& op_command = op_command_stack.back(); - op_command.set_default_nomore_mode(v); + op_command.set_default_nomore_mode(v); } void diff --git a/xorp/rtrmgr/template.ll b/xorp/rtrmgr/template.ll index 7361530..abcb2aa 100644 --- a/xorp/rtrmgr/template.ll +++ b/xorp/rtrmgr/template.ll @@ -9,8 +9,9 @@ #undef __unused #endif +#define YYSTYPE char* #include "libxorp/xorp.h" -#include "y.tplt_tab.h" +#include "y.tplt_tab.hh" #ifdef __xorp_unused #define __unused __xorp_unused @@ -18,7 +19,6 @@ #endif %} int tplt_linenum = 1; - extern char* tpltlval; string tplt_parsebuf; %option noyywrap %option nounput diff --git a/xorp/rtrmgr/template.yy b/xorp/rtrmgr/template.yy index c0b9747..9eadafe 100644 --- a/xorp/rtrmgr/template.yy +++ b/xorp/rtrmgr/template.yy @@ -18,6 +18,68 @@ extern void add_cmd_action_adaptor(const string& cmd, /* XXX: sigh, the -p flag to yacc should do this for us */ #define yystacksize tpltstacksize #define yysslim tpltsslim + +/** + * Forward declarations + */ +extern char *lstr; +extern char *vstr; +extern char *cstr; +extern char *sstr; +extern char *istr; +extern FILE *tpltin; +extern int tplt_linenum; +extern "C" int tpltparse(); +extern int tpltlex(); + +static TemplateTree* tt = NULL; +static string tplt_filename; +static string lastsymbol; +static int tplt_type; +static char *tplt_initializer = NULL; +static string current_cmd; +static list cmd_list; + +/** + * Function declarations + */ + +static void +extend_path(char *segment, bool is_tag); + +static void +push_path(); + +static void +pop_path(); + +static void +terminal(char *segment); + +static void +add_cmd(char *cmd); + +static void +append_cmd(char *s); + +static void +prepend_cmd(char *s); + +static void +end_cmd(); + +void +tplterror(const char *s) throw (ParseError); + +int +init_template_parser(const char *filename, TemplateTree *c); + +void +complete_template_parser(); + +void +parse_template() throw (ParseError); + %} %token UPLEVEL @@ -291,26 +353,7 @@ syntax_error: SYNTAX_ERROR { %% -extern char *lstr; -extern char *vstr; -extern char *cstr; -extern char *sstr; -extern char *istr; -extern FILE *tpltin; -extern int tplt_linenum; -extern "C" int tpltparse(); -extern int tpltlex(); - -static TemplateTree* tt = NULL; -static string tplt_filename; -static string lastsymbol; -static int tplt_type; -static char *tplt_initializer = NULL; -static string current_cmd; -static list cmd_list; - - -static void +void extend_path(char *segment, bool is_tag) { lastsymbol = segment; @@ -321,7 +364,7 @@ extend_path(char *segment, bool is_tag) free(segment); } -static void +void push_path() { tt->push_path(tplt_type, tplt_initializer); @@ -332,7 +375,7 @@ push_path() } } -static void +void pop_path() { tt->pop_path(); @@ -343,7 +386,7 @@ pop_path() } } -static void +void terminal(char *segment) { extend_path(segment, false); @@ -351,7 +394,7 @@ terminal(char *segment) pop_path(); } -static void +void add_cmd(char *cmd) { lastsymbol = cmd; @@ -362,7 +405,7 @@ add_cmd(char *cmd) cmd_list.clear(); } -static void +void append_cmd(char *s) { lastsymbol = s; @@ -371,7 +414,7 @@ append_cmd(char *s) free(s); } -static void +void prepend_cmd(char *s) { lastsymbol = s; @@ -380,7 +423,7 @@ prepend_cmd(char *s) free(s); } -static void +void end_cmd() { add_cmd_action_adaptor(current_cmd, cmd_list, tt); diff --git a/xorp/site_scons/config/allconfig.py b/xorp/site_scons/config/allconfig.py index f90f6ae..60f4a24 100644 --- a/xorp/site_scons/config/allconfig.py +++ b/xorp/site_scons/config/allconfig.py @@ -56,6 +56,21 @@ def DoAllConfig(env, conf, host_os): print " existence of gcc and g++ compilers." print " Will assume the exist and function properly...\n" + # Check for Flex and Bison + if not (env.has_key('LEX') and env['LEX']): + print "\nERROR: Cannot find flex." + print " On Ubuntu: sudo apt-get install flex" + print " On Fedora/RedHat: yum install flex" + sys.exit(1); + print "OK: flex appears functional." + + if not (env.has_key('YACC') and env['YACC']): + print "\nERROR: Cannot find bison." + print " On Ubuntu: sudo apt-get install bison" + print " On Fedora/RedHat: yum install bison" + sys.exit(1); + print "OK: bison appears functional." + # Mingw/windows stuff has_iphlpapi_h = conf.CheckHeader(['winsock2.h', 'iphlpapi.h']) has_routprot_h = conf.CheckHeader('routprot.h') -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:39:42 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:39:42 +0100 Subject: [Xorp-hackers] [PATCH 09/10] xorp: rtrmgr: Removed lex.opcmd.cc In-Reply-To: <1331635183-3800-1-git-send-email-igorm@etf.rs> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> Message-ID: <1331635183-3800-10-git-send-email-igorm@etf.rs> From: Igor Maravic It will be automatically generated with flex. Signed-off-by: Igor Maravic --- xorp/rtrmgr/lex.opcmd.cc | 1830 ---------------------------------------------- 1 files changed, 0 insertions(+), 1830 deletions(-) delete mode 100644 xorp/rtrmgr/lex.opcmd.cc diff --git a/xorp/rtrmgr/lex.opcmd.cc b/xorp/rtrmgr/lex.opcmd.cc deleted file mode 100644 index 13729de..0000000 --- a/xorp/rtrmgr/lex.opcmd.cc +++ /dev/null @@ -1,1830 +0,0 @@ -#define yy_create_buffer opcmd_create_buffer -#define yy_delete_buffer opcmd_delete_buffer -#define yy_scan_buffer opcmd_scan_buffer -#define yy_scan_string opcmd_scan_string -#define yy_scan_bytes opcmd_scan_bytes -#define yy_flex_debug opcmd_flex_debug -#define yy_init_buffer opcmd_init_buffer -#define yy_flush_buffer opcmd_flush_buffer -#define yy_load_buffer_state opcmd_load_buffer_state -#define yy_switch_to_buffer opcmd_switch_to_buffer -#define yyin opcmdin -#define yyleng opcmdleng -#define yylex opcmdlex -#define yyout opcmdout -#define yyrestart opcmdrestart -#define yytext opcmdtext - -#line 19 "lex.opcmd.cc" -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header$ - * $FreeBSD: src/usr.bin/lex/flex.skl,v 1.8 2004/01/06 19:03:44 nectar Exp $ - */ - -#if defined(__FreeBSD__) -#include -#else -#define __unused -#endif - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 - -#include - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include -#include - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include -#include -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern int yyleng; -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext_ptr ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ -typedef unsigned int yy_size_t; - - -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - }; - -static YY_BUFFER_STATE yy_current_buffer = 0; - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart YY_PROTO(( FILE *input_file )); - -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) - -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); - -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )) __unused; -static void yy_flex_free YY_PROTO(( void * )); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) - - -#define yywrap() 1 -#define YY_SKIP_YYWRAP -typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; -typedef int yy_state_type; -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 29 -#define YY_END_OF_BUFFER 30 -static yyconst short int yy_accept[90] = - { 0, - 0, 0, 24, 24, 17, 17, 30, 28, 3, 4, - 16, 28, 28, 15, 15, 6, 5, 28, 1, 2, - 24, 26, 25, 17, 20, 22, 29, 3, 0, 0, - 0, 0, 0, 0, 0, 15, 23, 0, 7, 24, - 25, 25, 27, 17, 18, 19, 21, 0, 0, 0, - 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, - 0, 12, 0, 10, 0, 0, 0, 0, 0, 0, - 0, 0, 8, 0, 0, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 13, 0, 0, 11, 0 - } ; - -static yyconst int yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 4, 1, 5, 6, 1, 1, 7, - 8, 9, 1, 1, 10, 11, 12, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 14, 15, 16, - 1, 17, 1, 18, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 1, 20, 1, 1, 21, 1, 22, 19, 23, 24, - - 25, 19, 26, 27, 19, 19, 19, 28, 29, 30, - 31, 32, 19, 33, 19, 34, 35, 19, 19, 19, - 19, 19, 36, 1, 37, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst int yy_meta[38] = - { 0, - 1, 2, 3, 4, 1, 1, 1, 5, 6, 7, - 8, 9, 7, 1, 1, 1, 2, 10, 11, 4, - 7, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 1, 1 - } ; - -static yyconst short int yy_base[99] = - { 0, - 0, 0, 35, 36, 37, 39, 177, 178, 174, 178, - 178, 168, 37, 0, 165, 178, 178, 156, 178, 178, - 0, 178, 37, 0, 178, 178, 43, 170, 0, 140, - 145, 138, 137, 135, 144, 0, 178, 148, 178, 0, - 39, 41, 178, 0, 178, 50, 178, 156, 134, 134, - 137, 131, 123, 117, 178, 134, 102, 91, 85, 85, - 94, 178, 92, 178, 84, 78, 78, 79, 81, 54, - 56, 53, 178, 55, 42, 178, 45, 50, 38, 36, - 38, 36, 33, 22, 178, 30, 19, 178, 178, 80, - 91, 96, 106, 117, 128, 139, 141, 148 - - } ; - -static yyconst short int yy_def[99] = - { 0, - 89, 1, 90, 90, 91, 91, 89, 89, 89, 89, - 89, 89, 89, 92, 92, 89, 89, 93, 89, 89, - 94, 89, 95, 96, 89, 89, 89, 89, 97, 89, - 89, 89, 89, 89, 89, 92, 89, 93, 89, 94, - 95, 95, 89, 96, 89, 89, 89, 98, 89, 89, - 89, 89, 89, 89, 89, 98, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 0, 89, - 89, 89, 89, 89, 89, 89, 89, 89 - - } ; - -static yyconst short int yy_nxt[216] = - { 0, - 8, 9, 10, 11, 12, 13, 8, 8, 8, 8, - 14, 15, 14, 16, 17, 18, 8, 8, 14, 8, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 19, 20, 22, 22, 25, - 26, 25, 26, 23, 23, 42, 45, 89, 43, 42, - 89, 88, 43, 45, 87, 86, 27, 85, 27, 30, - 84, 83, 46, 31, 82, 32, 33, 34, 81, 46, - 35, 80, 47, 79, 78, 77, 76, 75, 74, 47, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 24, 24, 24, 24, 24, 24, 24, 24, 24, - - 24, 24, 36, 36, 36, 73, 36, 38, 72, 71, - 70, 69, 38, 68, 67, 66, 38, 40, 40, 65, - 40, 40, 64, 40, 40, 40, 40, 40, 41, 41, - 63, 41, 41, 41, 41, 41, 41, 41, 41, 44, - 44, 55, 62, 44, 44, 44, 44, 44, 44, 44, - 48, 48, 56, 56, 56, 56, 61, 56, 56, 60, - 59, 58, 57, 55, 39, 54, 53, 52, 51, 50, - 49, 28, 39, 37, 29, 28, 89, 7, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89 - } ; - -static yyconst short int yy_chk[216] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 4, 5, - 5, 6, 6, 3, 4, 23, 27, 41, 23, 42, - 41, 87, 42, 46, 86, 84, 5, 83, 6, 13, - 82, 81, 27, 13, 80, 13, 13, 13, 79, 46, - 13, 78, 27, 77, 75, 74, 72, 71, 70, 46, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 91, 91, 91, 91, 91, 91, 91, 91, 91, - - 91, 91, 92, 92, 92, 69, 92, 93, 68, 67, - 66, 65, 93, 63, 61, 60, 93, 94, 94, 59, - 94, 94, 58, 94, 94, 94, 94, 94, 95, 95, - 57, 95, 95, 95, 95, 95, 95, 95, 95, 96, - 96, 56, 54, 96, 96, 96, 96, 96, 96, 96, - 97, 97, 98, 98, 98, 98, 53, 98, 98, 52, - 51, 50, 49, 48, 38, 35, 34, 33, 32, 31, - 30, 28, 18, 15, 12, 9, 7, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "op_commands.ll" -#define INITIAL 0 -#line 2 "op_commands.ll" -/* - * XXX: A hack to get rid of problematic __unused definition that might - * be inserted by lex itself and that might be conflicting when including - * some of the system header files. - */ -#ifdef __unused -#define __xorp_unused __unused -#undef __unused -#endif - -#include "libxorp/xorp.h" -#include -#include "y.opcmd_tab.h" - -#ifdef __xorp_unused -#define __unused __xorp_unused -#undef __xorp_unused -#endif -int opcmd_linenum = 1; -extern char* opcmdlval; -string opcmd_parsebuf; -#define YY_NO_UNPUT 1 -#define YY_NEVER_INTERACTIVE 1 -#define comment 1 - -#define string 2 - -#line 496 "lex.opcmd.cc" - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); -#else -extern int yywrap YY_PROTO(( void )); -#endif -#endif - -#ifndef YY_NO_UNPUT -static void yyunput YY_PROTO(( int c, char *buf_ptr )); -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen YY_PROTO(( yyconst char * )); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif - -#else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 -#endif - -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ - -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( yy_current_buffer->yy_is_interactive ) \ - { \ - int c = '*', n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ - && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 31 "op_commands.ll" - - -#line 650 "lex.opcmd.cc" - - if ( yy_init ) - { - yy_init = 0; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! yy_current_buffer ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 90 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 178 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - -do_action: /* This label is used only to access EOF actions. */ - - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 33 "op_commands.ll" -{ - return UPLEVEL; - } - YY_BREAK -case 2: -YY_RULE_SETUP -#line 37 "op_commands.ll" -{ - return DOWNLEVEL; - } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 41 "op_commands.ll" -/* whitespace */ - YY_BREAK -case 4: -YY_RULE_SETUP -#line 43 "op_commands.ll" -{ - /* newline is not significant */ - opcmd_linenum++; - } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 48 "op_commands.ll" -{ - return END; - } - YY_BREAK -case 6: -YY_RULE_SETUP -#line 52 "op_commands.ll" -{ - return COLON; - } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 56 "op_commands.ll" -{ - opcmdlval = strdup(opcmdtext); - return WILDCARD; - } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 61 "op_commands.ll" -{ - return CMD_MODULE; - } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 65 "op_commands.ll" -{ - return CMD_COMMAND; - } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 69 "op_commands.ll" -{ - return CMD_HELP; - } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 73 "op_commands.ll" -{ - return CMD_OPT_PARAMETER; - } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 77 "op_commands.ll" -{ - return CMD_TAG; - } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 81 "op_commands.ll" -{ - return CMD_NOMORE_MODE; - } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 85 "op_commands.ll" -{ - opcmdlval = strdup(opcmdtext); - return VARIABLE; - } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 90 "op_commands.ll" -{ - /* - * Note that we explicitly allow a literal to start with not only - * by a letter and '/', but a digit, '_' or '.' . - * Also, allow '.' to be part of the literal elsewhere. - * Thus, we can specify more liberally a filename (e.g., now a filename - * can start with a digit, it can contain dots, etc). - */ - opcmdlval = strdup(opcmdtext); - return LITERAL; - } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 102 "op_commands.ll" -{ - BEGIN(string); - /* XXX: include the original quote */ - opcmd_parsebuf="\""; - } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 108 "op_commands.ll" -/* normal text */ { - opcmd_parsebuf += opcmdtext; - } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 112 "op_commands.ll" -/* allow quoted quotes */ { - opcmd_parsebuf += "\""; - } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 116 "op_commands.ll" -/* allow quoted backslash */ { - opcmd_parsebuf += "\\"; - } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 120 "op_commands.ll" -/* allow unquoted newlines */ { - opcmd_linenum++; - opcmd_parsebuf += "\n"; - } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 125 "op_commands.ll" -/* allow C-style quoted newlines */ { - /* XXX: don't increment the line number */ - opcmd_parsebuf += "\n"; - } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 130 "op_commands.ll" -{ - BEGIN(INITIAL); - /* XXX: include the original quote */ - opcmd_parsebuf += "\""; - opcmdlval = strdup(opcmd_parsebuf.c_str()); - return STRING; - } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 138 "op_commands.ll" -BEGIN(comment); - YY_BREAK -case 24: -YY_RULE_SETUP -#line 140 "op_commands.ll" -/* eat up anything that's not a '*' */ - YY_BREAK -case 25: -YY_RULE_SETUP -#line 142 "op_commands.ll" -/* eat up '*'s not followed by "/"s */ - YY_BREAK -case 26: -YY_RULE_SETUP -#line 144 "op_commands.ll" -opcmd_linenum++; - YY_BREAK -case 27: -YY_RULE_SETUP -#line 146 "op_commands.ll" -BEGIN(INITIAL); - YY_BREAK -case 28: -YY_RULE_SETUP -#line 148 "op_commands.ll" -{ - /* everything else is a syntax error */ - return SYNTAX_ERROR; - } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 154 "op_commands.ll" -ECHO; - YY_BREAK -#line 942 "lex.opcmd.cc" -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(comment): -case YY_STATE_EOF(string): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of yylex */ - - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( yy_current_buffer->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_current_buffer->yy_n_chars = yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - int yy_c_buf_p_offset = - (int) (yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; - - return ret_val; - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state() - { - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = yy_start; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 90 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 90 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 89); - - return yy_is_jam ? 0 : yy_current_state; - } - - -#ifndef YY_NO_UNPUT -#ifdef YY_USE_PROTOS -static void yyunput( int c, register char *yy_bp ) -#else -static void yyunput( c, yy_bp ) -int c; -register char *yy_bp; -#endif - { - register char *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; - register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - yy_current_buffer->yy_n_chars = - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - - yytext_ptr = yy_bp; - yy_hold_char = *yy_cp; - yy_c_buf_p = yy_cp; - } -#endif /* ifndef YY_NO_UNPUT */ - - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - { - int c; - - *yy_c_buf_p = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yy_c_buf_p - yytext_ptr; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin ); - - /* fall through */ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - return EOF; - - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - - - return c; - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { - if ( ! b ) - return; - - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); - - yy_flex_free( (void *) b ); - } - - -#ifndef YY_ALWAYS_INTERACTIVE -#ifndef YY_NEVER_INTERACTIVE -extern int isatty YY_PROTO(( int )); -#endif -#endif - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - - { - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - -#if YY_ALWAYS_INTERACTIVE - b->yy_is_interactive = 1; -#else -#if YY_NEVER_INTERACTIVE - b->yy_is_interactive = 0; -#else - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; -#endif -#endif - } - - -#ifdef YY_USE_PROTOS -void yy_flush_buffer( YY_BUFFER_STATE b ) -#else -void yy_flush_buffer( b ) -YY_BUFFER_STATE b; -#endif - - { - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == yy_current_buffer ) - yy_load_buffer_state(); - } - - -#ifndef YY_NO_SCAN_BUFFER -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) -#else -YY_BUFFER_STATE yy_scan_buffer( base, size ) -char *base; -yy_size_t size; -#endif - { - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b ); - - return b; - } -#endif - - -#ifndef YY_NO_SCAN_STRING -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) -#else -YY_BUFFER_STATE yy_scan_string( yy_str ) -yyconst char *yy_str; -#endif - { - int len; - for ( len = 0; yy_str[len]; ++len ) - ; - - return yy_scan_bytes( yy_str, len ); - } -#endif - - -#ifndef YY_NO_SCAN_BYTES -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) -#else -YY_BUFFER_STATE yy_scan_bytes( bytes, len ) -yyconst char *bytes; -int len; -#endif - { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yy_flex_alloc( n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; - - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; - } -#endif - - -#ifndef YY_NO_PUSH_STATE -#ifdef YY_USE_PROTOS -static void yy_push_state( int new_state ) -#else -static void yy_push_state( new_state ) -int new_state; -#endif - { - if ( yy_start_stack_ptr >= yy_start_stack_depth ) - { - yy_size_t new_size; - - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof( int ); - - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); - - else - yy_start_stack = (int *) yy_flex_realloc( - (void *) yy_start_stack, new_size ); - - if ( ! yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } - - yy_start_stack[yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); - } -#endif - - -#ifndef YY_NO_POP_STATE -static void yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif - - -#ifndef YY_NO_TOP_STATE -static int yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -#ifdef YY_USE_PROTOS -static void yy_fatal_error( yyconst char msg[] ) -#else -static void yy_fatal_error( msg ) -char msg[]; -#endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); - } - - - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) - - -/* Internal utility routines. */ - -#ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; - } -#endif - -#ifdef YY_NEED_STRLEN -#ifdef YY_USE_PROTOS -static int yy_flex_strlen( yyconst char *s ) -#else -static int yy_flex_strlen( s ) -yyconst char *s; -#endif - { - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; - } -#endif - - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); - } - -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } - -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif -#line 154 "op_commands.ll" - -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:49:11 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:49:11 +0100 Subject: [Xorp-hackers] =?utf-8?q?=5BPATCH_0/4=5D_Support_for_u64_type_and?= =?utf-8?q?_fix_i32_type?= In-Reply-To: References: Message-ID: <1331635755-4320-1-git-send-email-igorm@etf.rs> From: Igor Maravic Hi, In these patches I introduced u64 type and fixed behavior for i32 type. BR Igor Maravi? Igor Maravic (4): xorp: Added support for uint64 type xorp: rtrmgr: Add option to read negative int values xorp: rtrmgr: Enable reading of positive integers xorp: rtrmgr: Enable i32 and u64 multi value nodes to boot up xorp/libxorp/range.hh | 133 +++++++++++++++++++++++++++++++++++- xorp/rtrmgr/boot.ll | 5 ++ xorp/rtrmgr/boot.yy | 6 ++ xorp/rtrmgr/conf_tree.cc | 31 +++++++-- xorp/rtrmgr/template.ll | 10 +++ xorp/rtrmgr/template.yy | 12 ++++ xorp/rtrmgr/template_tree.cc | 28 ++++++-- xorp/rtrmgr/template_tree_node.cc | 124 +++++++++++++++++++++++++++++++++-- xorp/rtrmgr/template_tree_node.hh | 129 +++++++++++++++++++++++------------- 9 files changed, 406 insertions(+), 72 deletions(-) -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:49:13 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:49:13 +0100 Subject: [Xorp-hackers] [PATCH 2/4] xorp: rtrmgr: Add option to read negative int values In-Reply-To: <1331635755-4320-1-git-send-email-igorm@etf.rs> References: <1331635755-4320-1-git-send-email-igorm@etf.rs> Message-ID: <1331635755-4320-3-git-send-email-igorm@etf.rs> From: Igor Maravic In boot.ll and boot.yy added option to read negative int values. Positive int values are read as uint values. Signed-off-by: Igor Maravic --- xorp/rtrmgr/boot.ll | 5 +++++ xorp/rtrmgr/boot.yy | 6 ++++++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/xorp/rtrmgr/boot.ll b/xorp/rtrmgr/boot.ll index 3f1d5c4..3e639ef 100644 --- a/xorp/rtrmgr/boot.ll +++ b/xorp/rtrmgr/boot.ll @@ -282,6 +282,11 @@ RE_ARITH_OPERATOR [" "]*({RE_BIN_OPERATOR})[" "]* return UINT_VALUE; } +[-][0-9]+ { + bootlval = strdup(boottext); + return INT_VALUE; + } + {RE_IPV4}".."{RE_IPV4} { bootlval = strdup(boottext); return IPV4RANGE_VALUE; diff --git a/xorp/rtrmgr/boot.yy b/xorp/rtrmgr/boot.yy index f815477..8f47eff 100644 --- a/xorp/rtrmgr/boot.yy +++ b/xorp/rtrmgr/boot.yy @@ -68,6 +68,7 @@ ConfigOperator boot_lookup_operator(const char* s); %token END %left ASSIGN_OPERATOR %token BOOL_VALUE +%token INT_VALUE %token UINT_VALUE %token UINTRANGE_VALUE %token IPV4_VALUE @@ -117,6 +118,7 @@ literals: literals literal | literal LITERAL { extend_path($2, NODE_TEXT, node_id); } | literal BOOL_VALUE { extend_path($2, NODE_BOOL, node_id); } | literal UINTRANGE_VALUE { extend_path($2, NODE_UINTRANGE, node_id); } + | literal INT_VALUE { extend_path($2, NODE_INT, node_id); } | literal UINT_VALUE { extend_path($2, NODE_UINT, node_id); } | literal IPV4RANGE_VALUE { extend_path($2, NODE_IPV4RANGE, node_id); } | literal IPV4_VALUE { extend_path($2, NODE_IPV4, node_id); } @@ -175,6 +177,10 @@ terminal: term_literal END { terminal($3, NODE_UINT, boot_lookup_operator($2)); free($2); } + | term_literal INFIX_OPERATOR INT_VALUE END { + terminal($3, NODE_INT, boot_lookup_operator($2)); + free($2); + } | term_literal INFIX_OPERATOR IPV4RANGE_VALUE END { terminal($3, NODE_IPV4RANGE, boot_lookup_operator($2)); free($2); -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:49:14 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:49:14 +0100 Subject: [Xorp-hackers] [PATCH 3/4] xorp: rtrmgr: Enable reading of positive integers In-Reply-To: <1331635755-4320-1-git-send-email-igorm@etf.rs> References: <1331635755-4320-1-git-send-email-igorm@etf.rs> Message-ID: <1331635755-4320-4-git-send-email-igorm@etf.rs> From: Igor Maravic Positive integers are read as uint. Change type from NODE_UINT to NODE_INT so they could be read. Signed-off-by: Igor Maravic --- xorp/rtrmgr/conf_tree.cc | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/xorp/rtrmgr/conf_tree.cc b/xorp/rtrmgr/conf_tree.cc index 77cd3b9..f74430c 100644 --- a/xorp/rtrmgr/conf_tree.cc +++ b/xorp/rtrmgr/conf_tree.cc @@ -293,9 +293,13 @@ ConfigTree::terminal_value(const string& value, int type, ConfigOperator op) * If ctn_type() == NODE_ULONG, then * type will be NODE_UINT, because * we read uint64 values just as uint values + * + * Other case is when we read positive integers */ if (ctn->type() == NODE_ULONG && type == NODE_UINT) type = NODE_ULONG; + else if (ctn->type() == NODE_INT && type == NODE_UINT) + type = NODE_INT; if ((ctn->type() == NODE_TEXT) && (type == NODE_TEXT)) { svalue = unquote(svalue); -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:49:15 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:49:15 +0100 Subject: [Xorp-hackers] [PATCH 4/4] xorp: rtrmgr: Enable i32 and u64 multi value nodes to boot up In-Reply-To: <1331635755-4320-1-git-send-email-igorm@etf.rs> References: <1331635755-4320-1-git-send-email-igorm@etf.rs> Message-ID: <1331635755-4320-5-git-send-email-igorm@etf.rs> From: Igor Maravic Positive int and u64 values are read as uint. If our node is of type NODE_ULONG or NODE_INT and read type is of type NODE_UINT, than we have a match. Signed-off-by: Igor Maravic --- xorp/rtrmgr/template_tree.cc | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/xorp/rtrmgr/template_tree.cc b/xorp/rtrmgr/template_tree.cc index 6b51a3a..fa04132 100644 --- a/xorp/rtrmgr/template_tree.cc +++ b/xorp/rtrmgr/template_tree.cc @@ -491,6 +491,12 @@ TemplateTree::find_node_by_type(const list& path_segments) if (t->type() == type) { matches.push_back(t); continue; + } else if ((t->type() == NODE_ULONG || t->type() == NODE_INT) && type == NODE_UINT) { + // u64 values are read as u32 values, because their + // regexp is the same. + // Same is for the positive int values. + matches.push_back(t); + continue; } // // XXX: the type check failed. -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:49:12 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:49:12 +0100 Subject: [Xorp-hackers] [PATCH 1/4] xorp: Added support for uint64 type In-Reply-To: <1331635755-4320-1-git-send-email-igorm@etf.rs> References: <1331635755-4320-1-git-send-email-igorm@etf.rs> Message-ID: <1331635755-4320-2-git-send-email-igorm@etf.rs> From: Igor Maravic In template.yy and template.ll files added support for uint64 and uin64range types. Their nodes are called NODE_ULONG and NODE_ULONGRANGE respectively. In range.hh added U64Range class. Does everything as U32Range, but with uint64_t instead of uint32_t variables. In template_tree_node.cc and template_tree_node.hh added ULongTemplate and ULongRangeTemplate to handle new types. Unfortunately Eclipse striped whitespaces from changed files, so they are meshed up with the changed code. Signed-off-by: Igor Maravic --- xorp/libxorp/range.hh | 133 +++++++++++++++++++++++++++++++++++- xorp/rtrmgr/conf_tree.cc | 27 +++++-- xorp/rtrmgr/template.ll | 10 +++ xorp/rtrmgr/template.yy | 12 ++++ xorp/rtrmgr/template_tree.cc | 22 ++++-- xorp/rtrmgr/template_tree_node.cc | 124 +++++++++++++++++++++++++++++++++-- xorp/rtrmgr/template_tree_node.hh | 129 +++++++++++++++++++++++------------- 7 files changed, 385 insertions(+), 72 deletions(-) diff --git a/xorp/libxorp/range.hh b/xorp/libxorp/range.hh index 538610f..1acb0ef 100644 --- a/xorp/libxorp/range.hh +++ b/xorp/libxorp/range.hh @@ -9,13 +9,13 @@ // Redistribution and/or modification of this program under the terms of // any other version of the GNU Lesser General Public License is not // permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU Lesser General Public License, Version 2.1, a copy of // which can be found in the XORP LICENSE.lgpl file. -// +// // XORP, Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -76,7 +76,7 @@ public: /** * Default constructor */ - U32Range() { Range::_low = + U32Range() { Range::_low = Range::_high = 0; } /** @@ -110,6 +110,54 @@ public: }; /** + * @short A linear range class (uint64_t low)..(uint64_t high) + * + * Inherits from templatized general Range class. + * Provides specialized constructor from string and str() method. + */ +class U64Range: public Range { +public: + /** + * Default constructor + */ + U64Range() { Range::_low = + Range::_high = 0; } + + /** + * Constructor from a string. + */ + U64Range(const char *from_cstr) { + string from_string = string(from_cstr); + string::size_type delim = from_string.find("..", 0); + if (delim == string::npos) { + _low = _high = strtoul(from_cstr, NULL, 10); + } else if (delim > 0 && (from_string.length() - delim > 2)) { + _low = strtoul(from_string.substr(0, delim).c_str(), NULL, 10); + _high = strtoul(from_string.substr(delim + 2, from_string.length()).c_str(), NULL, 10); + } else { + xorp_throw(InvalidString, "Syntax error"); + } + } + + /** + * Convert the range to a human-readable format. + * + * @return C++ string. + */ + string str() const { + ostringstream os; + os << _low; + if (_low < _high) + os << ".." << _high; + return os.str(); + } +}; + +/** + * Operators for uint32_t and U32Range + */ + +/** * Equality Operator for @ref uint32_t against @ref U32Range operand. * * @param lhs the left-hand @ref uint32_t type operand. @@ -182,6 +230,83 @@ inline bool operator>=(const uint32_t& lhs, const U32Range& rhs) { return (lhs >= rhs.low()); } +/** + * Operators for uint64_t and U64Range + */ + +/** + * Equality Operator for @ref uint64_t against @ref U64Range operand. + * + * @param lhs the left-hand @ref uint64_t type operand. + * @param rhs the right-hand @ref U64Range operand. + * @return true if the value of the left-hand operand falls inside + * the range defined by the right-hand operand. + */ +inline bool operator==(const uint64_t& lhs, const U64Range& rhs) { + return (lhs >= rhs.low() && lhs <= rhs.high()); +} + + +/** + * Non-equality Operator for @ref uint64_t against @ref U64Range operand. + * + * @param lhs the left-hand @ref uint64_t type operand. + * @param rhs the right-hand @ref U64Range operand. + * @return true if the value of the left-hand operand falls outside + * the range defined by the right-hand operand. + */ +inline bool operator!=(const uint64_t& lhs, const U64Range& rhs) { + return (lhs < rhs.low() || lhs > rhs.high()); +} + +/** + * Less-than comparison for @ref uint64_t against @ref U64Range operand. + * + * @param lhs the left-hand @ref uint64_t type operand. + * @param rhs the right-hand @ref U64Range operand. + * @return true if the value of the left-hand operand is bellow + * the range defined by the right-hand operand. + */ +inline bool operator<(const uint64_t& lhs, const U64Range& rhs) { + return (lhs < rhs.low()); +} + +/** + * Less-than or equal comparison for @ref uint64_t against @ref U64Range + * + * @param lhs the left-hand @ref uint64_t type operand. + * @param rhs the right-hand @ref U64Range operand. + * @return true if the value of the left-hand operand is bellow or within + * the range defined by the right-hand operand. + */ +inline bool operator<=(const uint64_t& lhs, const U64Range& rhs) { + return (lhs <= rhs.high()); +} + +/** + * Greater-than comparison for @ref uint64_t against @ref U64Range operand. + * + * @param lhs the left-hand @ref uint64_t type operand. + * @param rhs the right-hand @ref U64Range operand. + * @return true if the value of the left-hand operand is above + * the range defined by the right-hand operand. + */ +inline bool operator>(const uint64_t& lhs, const U64Range& rhs) { + return (lhs > rhs.high()); +} + +/** + * Greater-than or equal comparison for @ref uint64_t against @ref U64Range + * + * @param lhs the left-hand @ref uint64_t type operand. + * @param rhs the right-hand @ref U64Range operand. + * @return true if the value of the left-hand operand is above or within + * the range defined by the right-hand operand. + */ +inline bool operator>=(const uint64_t& lhs, const U64Range& rhs) { + return (lhs >= rhs.low()); +} + /** * @short A linear IPvX class template (IPvX low)..(IPvX high) @@ -207,7 +332,7 @@ public: Range::_low = Range::_high = T(from_cstr); else if (delim > 0 && (from_string.length() - delim > 2)) { Range::_low = T(from_string.substr(0, delim).c_str()); - Range::_high = T(from_string.substr(delim + 2, + Range::_high = T(from_string.substr(delim + 2, from_string.length()) .c_str()); } else { diff --git a/xorp/rtrmgr/conf_tree.cc b/xorp/rtrmgr/conf_tree.cc index f52ace5..77cd3b9 100644 --- a/xorp/rtrmgr/conf_tree.cc +++ b/xorp/rtrmgr/conf_tree.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -112,7 +112,7 @@ ConfigTree::path_as_segments() const ConfigTreeNode* ctn = _current_node; while (ctn->parent() != NULL) { - path_segments.push_front(ConfPathSegment(ctn->segname(), + path_segments.push_front(ConfPathSegment(ctn->segname(), ctn->type(), ctn->node_id())); ctn = ctn->parent(); } @@ -271,7 +271,7 @@ ConfigTree::add_node(const string& segment, int type, void -ConfigTree::terminal_value(const string& value, int type, ConfigOperator op) +ConfigTree::terminal_value(const string& value, int type, ConfigOperator op) throw (ParseError) { string error_msg; @@ -289,12 +289,22 @@ ConfigTree::terminal_value(const string& value, int type, ConfigOperator op) svalue = "true"; } } + /** + * If ctn_type() == NODE_ULONG, then + * type will be NODE_UINT, because + * we read uint64 values just as uint values + */ + if (ctn->type() == NODE_ULONG && type == NODE_UINT) + type = NODE_ULONG; + if ((ctn->type() == NODE_TEXT) && (type == NODE_TEXT)) { svalue = unquote(svalue); } else if ((ctn->type() == NODE_TEXT) && (type != NODE_TEXT)) { // We'll accept anything as text - } else if ((ctn->type() == NODE_UINTRANGE) && (type == NODE_UINT)) { + } else if (((ctn->type() == NODE_UINTRANGE) && (type == NODE_UINT)) || + ((ctn->type() == NODE_ULONGRANGE) && (type == NODE_ULONG))) { // Expand a single uint to a uintrange + // or a single uint64 to uint64range svalue += ".." + value; } else if ((ctn->type() == NODE_IPV4RANGE) && (type == NODE_IPV4)) { // Expand a single IPv4 to a ipv4range @@ -315,6 +325,7 @@ ConfigTree::terminal_value(const string& value, int type, ConfigOperator op) // Not clear what to do here break; case NODE_UINT: + case NODE_ULONG: for (size_t i = 0; i < svalue.size(); i++) { if ((svalue[i] < '0') || (svalue[i] > '9')) { goto parse_error; @@ -440,7 +451,7 @@ ConfigTree::find_config_node(const list& path_segments) const string -ConfigTree::show_subtree(bool show_top, const list& path_segments, +ConfigTree::show_subtree(bool show_top, const list& path_segments, bool numbered, bool suppress_default_values) const { const ConfigTreeNode *found = find_config_node(path_segments); @@ -464,7 +475,7 @@ ConfigTree::show_tree(bool numbered) const return const_root_node().show_subtree(/* show_top */ false, /* depth */ 0, /* indent */ 0, - /* do_indent */ true, + /* do_indent */ true, numbered, /* annotate */ true, /* suppress_default_values */ false); @@ -476,7 +487,7 @@ ConfigTree::show_unannotated_tree(bool numbered) const return const_root_node().show_subtree(/* show_top */ false, /* depth */ 0, /* indent */ 0, - /* do_indent */ true, + /* do_indent */ true, numbered, /* annotate */ false, /* suppress_default_values */ false); diff --git a/xorp/rtrmgr/template.ll b/xorp/rtrmgr/template.ll index abcb2aa..fbe3ad7 100644 --- a/xorp/rtrmgr/template.ll +++ b/xorp/rtrmgr/template.ll @@ -285,6 +285,16 @@ RE_URL_SUBDELIMS "!"|"$"|"&"|"'"|"("|")"|"*"|"+"|","|";"|"=" return UINT_TYPE; } +"u64range" { + tpltlval = strdup(tplttext); + return ULONGRANGE_TYPE; + } + +"u64" { + tpltlval = strdup(tplttext); + return ULONG_TYPE; + } + "bool" { tpltlval = strdup(tplttext); return BOOL_TYPE; diff --git a/xorp/rtrmgr/template.yy b/xorp/rtrmgr/template.yy index 9eadafe..b02b5bc 100644 --- a/xorp/rtrmgr/template.yy +++ b/xorp/rtrmgr/template.yy @@ -93,6 +93,8 @@ parse_template() throw (ParseError); %token INT_TYPE %token UINT_TYPE %token UINTRANGE_TYPE +%token ULONG_TYPE +%token ULONGRANGE_TYPE %token BOOL_TYPE %token TOGGLE_TYPE %token IPV4_TYPE @@ -161,6 +163,8 @@ type: TEXT_TYPE { tplt_type = NODE_TEXT; } | INT_TYPE { tplt_type = NODE_INT; } | UINT_TYPE { tplt_type = NODE_UINT; } | UINTRANGE_TYPE { tplt_type = NODE_UINTRANGE; } + | ULONG_TYPE { tplt_type = NODE_ULONG; } + | ULONGRANGE_TYPE { tplt_type = NODE_ULONGRANGE; } | BOOL_TYPE { tplt_type = NODE_BOOL; } | TOGGLE_TYPE { tplt_type = NODE_TOGGLE; } | IPV4_TYPE { tplt_type = NODE_IPV4; } @@ -192,6 +196,14 @@ init_type: TEXT_TYPE ASSIGN_DEFAULT STRING { tplt_type = NODE_UINTRANGE; tplt_initializer = $3; } + | ULONG_TYPE ASSIGN_DEFAULT INTEGER_VALUE { + tplt_type = NODE_ULONG; + tplt_initializer = $3; + } + | ULONGRANGE_TYPE ASSIGN_DEFAULT UINTRANGE_VALUE { + tplt_type = NODE_ULONGRANGE; + tplt_initializer = $3; + } | BOOL_TYPE ASSIGN_DEFAULT BOOL_VALUE { tplt_type = NODE_BOOL; tplt_initializer = $3; diff --git a/xorp/rtrmgr/template_tree.cc b/xorp/rtrmgr/template_tree.cc index e228bb5..6b51a3a 100644 --- a/xorp/rtrmgr/template_tree.cc +++ b/xorp/rtrmgr/template_tree.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -64,7 +64,7 @@ TemplateTree::~TemplateTree() delete _root_node; } -bool +bool TemplateTree::load_template_tree(const string& config_template_dir, string& error_msg) { @@ -123,9 +123,9 @@ TemplateTree::load_template_tree(const string& config_template_dir, return true; } -bool +bool TemplateTree::parse_file(const string& filename, - const string& config_template_dir, string& error_msg) + const string& config_template_dir, string& error_msg) { if (init_template_parser(filename.c_str(), this) < 0) { complete_template_parser(); @@ -142,7 +142,7 @@ TemplateTree::parse_file(const string& filename, } if (_path_segments.size() != 0) { complete_template_parser(); - error_msg = c_format("File %s is not terminated properly", + error_msg = c_format("File %s is not terminated properly", filename.c_str()); return false; } @@ -228,6 +228,12 @@ TemplateTree::new_node(TemplateTreeNode* parent, case NODE_UINTRANGE: ttn = new UIntRangeTemplate(*this, parent, path, varname, initializer); break; + case NODE_ULONG: + ttn = new ULongTemplate(*this, parent, path, varname, initializer); + break; + case NODE_ULONGRANGE: + ttn = new ULongRangeTemplate(*this, parent, path, varname, initializer); + break; case NODE_INT: ttn = new IntTemplate(*this, parent, path, varname, initializer); break; @@ -443,7 +449,7 @@ TemplateTree::find_node(const list& path_segments) const } const TemplateTreeNode* -TemplateTree::find_node_by_type(const list& path_segments) +TemplateTree::find_node_by_type(const list& path_segments) const { TemplateTreeNode* ttn = _root_node; @@ -490,7 +496,7 @@ TemplateTree::find_node_by_type(const list& path_segments) // XXX: the type check failed. // If there is a matching template node type of type NODE_TEXT, // then we accept this node. - // + // // The upside of this is that we can use a single template // node like "foo @: txt" that can be used with, say, // IPv4 or IPv6 addresses, a host name, or any other text string. diff --git a/xorp/rtrmgr/template_tree_node.cc b/xorp/rtrmgr/template_tree_node.cc index b4d7d50..7ae9698 100644 --- a/xorp/rtrmgr/template_tree_node.cc +++ b/xorp/rtrmgr/template_tree_node.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -946,7 +946,7 @@ TemplateTreeNode::find_child_varname_node(const list& var_parts) // The name might refer to this node if (var_parts.size() == 1) { - if ((var_parts.front() == "@") + if ((var_parts.front() == "@") || (var_parts.front() == _segname) || (var_parts.front() == "<>") || (var_parts.front() == "#")) { @@ -1544,6 +1544,120 @@ UIntRangeTemplate::type_match(const string& s, string& error_msg) const /************************************************************************** + * ULongTemplate + **************************************************************************/ + +ULongTemplate::ULongTemplate(TemplateTree& template_tree, + TemplateTreeNode* parent, + const string& path, const string& varname, + const string& initializer) throw (ParseError) + : TemplateTreeNode(template_tree, parent, path, varname) +{ + string error_msg; + + if (initializer.empty()) + return; + + string s = strip_quotes(initializer); + if (! type_match(s, error_msg)) { + error_msg = c_format("Bad ULong type value \"%s\": %s.", + initializer.c_str(), error_msg.c_str()); + xorp_throw(ParseError, error_msg); + } + _default = strtoll(s.c_str(), (char **)NULL, 10); + set_has_default(); +} + +bool +ULongTemplate::type_match(const string& orig, string& error_msg) const +{ + string s = strip_quotes(orig); + + for (size_t i = 0; i < s.length(); i++) { + if (s[i] < '0' || s[i] > '9') { + if (s[i]=='-') { + error_msg = "value cannot be negative"; + } else if (s[i]=='.') { + error_msg = "value must be an integer"; + } else { + error_msg = "value must be numeric"; + } + return false; + } + } + return true; +} + +string +ULongTemplate::default_str() const +{ + return c_format("%lu", _default); +} + + +/************************************************************************** + * ULongRangeTemplate + **************************************************************************/ + +ULongRangeTemplate::ULongRangeTemplate(TemplateTree& template_tree, + TemplateTreeNode* parent, + const string& path, const string& varname, + const string& initializer) throw (ParseError) + : TemplateTreeNode(template_tree, parent, path, varname), + _default(NULL) +{ + string error_msg; + + if (initializer.empty()) + return; + + try { + _default = new U64Range(initializer.c_str()); + } catch (InvalidString) { + error_msg = c_format("Bad U64Range type value \"%s\".", + initializer.c_str()); + xorp_throw(ParseError, error_msg); + } + set_has_default(); +} + +ULongRangeTemplate::~ULongRangeTemplate() +{ + if (_default != NULL) + delete _default; +} + +string +ULongRangeTemplate::default_str() const +{ + if (_default != NULL) + return _default->str(); + + return ""; +} + +bool +ULongRangeTemplate::type_match(const string& s, string& error_msg) const +{ + string tmp = strip_quotes(s); + + if (tmp.empty()) { + error_msg = "value must be a valid range of unsigned 64-bit integers"; + return false; + } + + try { + U64Range* u64range = new U64Range(tmp.c_str()); + delete u64range; + } catch (InvalidString) { + error_msg = "value must be a valid range of unsigned 64-bit integers"; + return false; + } + return true; +} + + +/************************************************************************** * IntTemplate **************************************************************************/ @@ -1586,7 +1700,7 @@ IntTemplate::type_match(const string& orig, string& error_msg) const error_msg = "value must be an integer"; } else { error_msg = "value must be numeric"; - } + } return false; } return true; @@ -1613,7 +1727,7 @@ BoolTemplate::BoolTemplate(TemplateTree& template_tree, if (initializer.empty()) return; - + if (! type_match(initializer, error_msg)) { error_msg = c_format("Bad Bool type value \"%s\": %s.", initializer.c_str(), error_msg.c_str()); diff --git a/xorp/rtrmgr/template_tree_node.hh b/xorp/rtrmgr/template_tree_node.hh index 88e257e..f681fd5 100644 --- a/xorp/rtrmgr/template_tree_node.hh +++ b/xorp/rtrmgr/template_tree_node.hh @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -42,22 +42,24 @@ enum TTNodeType { NODE_VOID = 0, NODE_TEXT = 1, NODE_UINT = 2, - NODE_INT = 3, - NODE_BOOL = 4, - NODE_TOGGLE = 4, - NODE_IPV4 = 5, - NODE_IPV4NET = 6, - NODE_IPV6 = 7, - NODE_IPV6NET = 8, - NODE_MACADDR = 9, - NODE_URL_FILE = 10, - NODE_URL_FTP = 11, - NODE_URL_HTTP = 12, - NODE_URL_TFTP = 13, - NODE_ARITH = 14, - NODE_UINTRANGE = 15, - NODE_IPV4RANGE = 16, - NODE_IPV6RANGE = 17 + NODE_ULONG = 3, + NODE_INT = 4, + NODE_BOOL = 5, + NODE_TOGGLE = 5, + NODE_IPV4 = 6, + NODE_IPV4NET = 7, + NODE_IPV6 = 8, + NODE_IPV6NET = 9, + NODE_MACADDR = 10, + NODE_URL_FILE = 11, + NODE_URL_FTP = 12, + NODE_URL_HTTP = 13, + NODE_URL_TFTP = 14, + NODE_ARITH = 15, + NODE_UINTRANGE = 16, + NODE_ULONGRANGE = 17, + NODE_IPV4RANGE = 18, + NODE_IPV6RANGE = 19 }; enum TTSortOrder { @@ -73,7 +75,7 @@ class TemplateTree; class TemplateTreeNode { public: - TemplateTreeNode(TemplateTree& template_tree, TemplateTreeNode* parent, + TemplateTreeNode(TemplateTree& template_tree, TemplateTreeNode* parent, const string& path, const string& varname); virtual ~TemplateTreeNode(); @@ -115,7 +117,7 @@ public: #if 0 bool check_template_tree(string& error_msg) const; #endif - bool check_command_tree(const list& commands, + bool check_command_tree(const list& commands, bool include_intermediate_nodes, bool include_read_only_nodes, bool include_permanent_nodes, @@ -238,8 +240,8 @@ private: class UIntTemplate : public TemplateTreeNode { public: - UIntTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + UIntTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); string typestr() const { return string("uint"); } @@ -254,8 +256,8 @@ private: class UIntRangeTemplate : public TemplateTreeNode { public: - UIntRangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + UIntRangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~UIntRangeTemplate(); @@ -269,10 +271,43 @@ private: U32Range* _default; }; +class ULongTemplate : public TemplateTreeNode { +public: + ULongTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, + const string& initializer) throw (ParseError); + + string typestr() const { return string("uint64"); } + TTNodeType type() const { return NODE_ULONG; } + unsigned int default_value() const { return _default; } + string default_str() const; + bool type_match(const string& s, string& error_msg) const; + +private: + uint64_t _default; +}; + +class ULongRangeTemplate : public TemplateTreeNode { +public: + ULongRangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, + const string& initializer) throw (ParseError); + ~ULongRangeTemplate(); + + string typestr() const { return string("uint64range"); } + TTNodeType type() const { return NODE_ULONGRANGE; } + U64Range* default_value() const { return _default; } + string default_str() const; + bool type_match(const string& s, string& error_msg) const; + +private: + U64Range* _default; +}; + class IntTemplate : public TemplateTreeNode { public: - IntTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + IntTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); string typestr() const { return string("int"); } TTNodeType type() const { return NODE_INT; } @@ -286,8 +321,8 @@ private: class ArithTemplate : public TemplateTreeNode { public: - ArithTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + ArithTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); string typestr() const { return string("uint"); } TTNodeType type() const { return NODE_ARITH; } @@ -301,8 +336,8 @@ private: class TextTemplate : public TemplateTreeNode { public: - TextTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + TextTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); string typestr() const { return string("text"); } @@ -317,8 +352,8 @@ private: class BoolTemplate : public TemplateTreeNode { public: - BoolTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + BoolTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); string typestr() const { return string("bool"); } @@ -333,7 +368,7 @@ private: class IPv4Template : public TemplateTreeNode { public: - IPv4Template(TemplateTree& template_tree, TemplateTreeNode* parent, + IPv4Template(TemplateTree& template_tree, TemplateTreeNode* parent, const string& path, const string& varname, const string& initializer) throw (ParseError); ~IPv4Template(); @@ -350,8 +385,8 @@ private: class IPv4NetTemplate : public TemplateTreeNode { public: - IPv4NetTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + IPv4NetTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~IPv4NetTemplate(); @@ -367,8 +402,8 @@ private: class IPv4RangeTemplate : public TemplateTreeNode { public: - IPv4RangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + IPv4RangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~IPv4RangeTemplate(); @@ -385,7 +420,7 @@ private: class IPv6Template : public TemplateTreeNode { public: IPv6Template(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~IPv6Template(); @@ -401,8 +436,8 @@ private: class IPv6NetTemplate : public TemplateTreeNode { public: - IPv6NetTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + IPv6NetTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~IPv6NetTemplate(); @@ -419,7 +454,7 @@ private: class IPv6RangeTemplate : public TemplateTreeNode { public: IPv6RangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~IPv6RangeTemplate(); @@ -435,8 +470,8 @@ private: class MacaddrTemplate : public TemplateTreeNode { public: - MacaddrTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + MacaddrTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~MacaddrTemplate(); @@ -452,7 +487,7 @@ private: class UrlFileTemplate : public TemplateTreeNode { public: - UrlFileTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + UrlFileTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, const string& path, const string& varname, const string& initializer) throw (ParseError); @@ -468,7 +503,7 @@ private: class UrlFtpTemplate : public TemplateTreeNode { public: - UrlFtpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + UrlFtpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, const string& path, const string& varname, const string& initializer) throw (ParseError); @@ -484,7 +519,7 @@ private: class UrlHttpTemplate : public TemplateTreeNode { public: - UrlHttpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + UrlHttpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, const string& path, const string& varname, const string& initializer) throw (ParseError); @@ -500,7 +535,7 @@ private: class UrlTftpTemplate : public TemplateTreeNode { public: - UrlTftpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + UrlTftpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, const string& path, const string& varname, const string& initializer) throw (ParseError); -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:55:49 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:55:49 +0100 Subject: [Xorp-hackers] [PATCH 0/1] Fix command completion for multi value nodes In-Reply-To: References: Message-ID: <1331636150-4816-1-git-send-email-igorm@etf.rs> From: Igor Maravic Hi, In this patche I fixed command completion when multi-value node has %allow-range option. BR Igor Maravic Igor Maravic (2): xorp: rtrmgr: Fix command completion with %allow-range option on multi-value nodes xorp: rtrmgr: Fix command completion for multi value i32 and u64 nodes xorp/rtrmgr/template_tree.cc | 45 +++++++++++++++++++++++++++++++----- xorp/rtrmgr/template_tree_node.cc | 6 ++-- 2 files changed, 41 insertions(+), 10 deletions(-) -- 1.7.5.4 From igorm at etf.rs Tue Mar 13 03:55:50 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 13 Mar 2012 11:55:50 +0100 Subject: [Xorp-hackers] [PATCH] xorp: rtrmgr: Fix command completion with %allow-range option on multi-value nodes In-Reply-To: <1331636150-4816-1-git-send-email-igorm@etf.rs> References: <1331636150-4816-1-git-send-email-igorm@etf.rs> Message-ID: <1331636150-4816-2-git-send-email-igorm@etf.rs> From: Igor Maravic Fixed problem of command completion for multi-value nodes with allow-range option. Without this fix, if we would enter number within the allowed range, and then we would enter " " + "\t" we wouldn't get any command propositions. Signed-off-by: Igor Maravic --- xorp/rtrmgr/template_tree.cc | 45 +++++++++++++++++++++++++++++++----- xorp/rtrmgr/template_tree_node.cc | 6 ++-- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/xorp/rtrmgr/template_tree.cc b/xorp/rtrmgr/template_tree.cc index fa04132..08c9280 100644 --- a/xorp/rtrmgr/template_tree.cc +++ b/xorp/rtrmgr/template_tree.cc @@ -38,6 +38,17 @@ #include "template_tree.hh" #include "template_tree_node.hh" +#ifdef HAVE_REGEX_H +# include +#else // ! HAVE_REGEX_H +# ifdef HAVE_PCRE_H +# include +# endif +# ifdef HAVE_PCREPOSIX_H +# include +# endif +#endif // ! HAVE_REGEX_H + #ifdef HOST_OS_WINDOWS #define stat _stat @@ -422,18 +433,38 @@ TemplateTree::find_node(const list& path_segments) const // There's no exact name match, so we're probably looking for a // match of an encoded typestr or a value against a typed variable. for (ti = ttn->children().begin(); ti != ttn->children().end(); ++ti) { - TemplateTreeNode* t = *ti; - if (t->type() == NODE_VOID) + TemplateTreeNode* t = *ti; + if (t->type() == NODE_VOID) continue; - if ((t->parent() == NULL) || (! t->parent()->is_tag())) + if ((t->parent() == NULL) || (! t->parent()->is_tag())) continue; - if (t->encoded_typestr() == segname) { + if (t->encoded_typestr() == segname) { matches.push_back(t); continue; - } - string s; - if (t->type_match(segname, s)) + } + + /** + * Check if this segname represents some kind of range. + * If it does, it will match regexp below, and we + * are expecting t->encoded_typestr to be "" or "" or "" + */ + regex_t range_reg; + if (regcomp(&range_reg, "[\[][-]{0,1}[0-9]+[.][.][-]{0,1}[0-9]+]", REG_EXTENDED)) + XLOG_UNREACHABLE(); + + bool is_range = !regexec(&range_reg, segname.c_str(), 0, 0, 0); + regfree(&range_reg); + if (is_range && + (t->encoded_typestr() == "" + || t->encoded_typestr() == "" + || t->encoded_typestr() == "")) { matches.push_back(t); + continue; + } + + string s; + if (t->type_match(segname, s)) + matches.push_back(t); } if (matches.size() == 0) return NULL; diff --git a/xorp/rtrmgr/template_tree_node.cc b/xorp/rtrmgr/template_tree_node.cc index 7ae9698..4c858e8 100644 --- a/xorp/rtrmgr/template_tree_node.cc +++ b/xorp/rtrmgr/template_tree_node.cc @@ -1471,7 +1471,7 @@ UIntTemplate::type_match(const string& orig, string& error_msg) const return false; } } - return true; + return check_allowed_value(orig, error_msg); } string @@ -1585,7 +1585,7 @@ ULongTemplate::type_match(const string& orig, string& error_msg) const return false; } } - return true; + return check_allowed_value(orig, error_msg); } string @@ -1703,7 +1703,7 @@ IntTemplate::type_match(const string& orig, string& error_msg) const } return false; } - return true; + return check_allowed_value(orig, error_msg); } string -- 1.7.5.4 From markus.xorp at gmail.com Tue Mar 13 07:17:05 2012 From: markus.xorp at gmail.com (Markus Zehnder) Date: Tue, 13 Mar 2012 15:17:05 +0100 Subject: [Xorp-hackers] xrl calls from xorp_ospf to xorp_fea start failing when generating lots of calls. Message-ID: Hi there, In my setup i have a problem in ospf/ospf.cc Ospf::transmit(). Around line 333, the call to _io->send() returns 'false'. Setup: two linux boxes (virtual) with xorp 1.8.5, configured to run OSPF, both boxes in the same area 0.0.0.0. The two machines are connected with two links on different interfaces. The neighbor state of the interfaces is "FULL". OSPF is configured to distribute the static routes. Scenario to trigger above problem: - Modify the configfile of one box and add somewhat around 100 static routes. - Reload the configfile with "load " in xorpsh. Result: - only about 60 to 70 routes get distributed with the first try. rest comes later (with the retransmit when it works (see #109)) Debugging: - ospf is trying to send LSA Updates, one packet for each route and interface. The packets are passed to xorp_fea as mentioned at the top with the transmit() method. ..but that fails after 120..140 packets. Can anybody give me some hint how that intented to work ? Is there some queue overflowing in the xorp_fea? should xorp_fea run with higher priority then the xorp_ospf. I guess i do not yet understand the XRL stuff good enough... Don't tell me that my scenario is not realistic. I try to reconfigure xorp with a reload of the config file because that should be faster than a complete restart. And i would like to know the limits..when does it work and under which condition will it fail. regards Markus -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120313/2d3fd1c3/attachment.html From vvm at tut.by Tue Mar 13 07:51:30 2012 From: vvm at tut.by (Victor Miasnikov) Date: Tue, 13 Mar 2012 17:51:30 +0300 Subject: [Xorp-hackers] xorprtm4.dll / xorprtm6.dll Fw: RTMv2 Or XORP and RRAS ( Routing and Remote Access Services) Fw: XORP on Windows Message-ID: <7DD51393B44C46F9B9B384531EA1D897@local.st.by> Hi! ----- Original Message ----- From: "Victor Miasnikov" To: "Ben Greear" Sent: Tuesday, March 13, 2012 5:46 PM Subject: Fw: xorprtm4.dll / xorprtm6.dll Fw: RTMv2 Or XORP and RRAS ( Routing and Remote Access Services) Fw: XORP on Windows Hi! Please, unpack to You build folder ( for save rigfh date+time of files in future xorp-1.8.6-src.tar.bz2 ) and upload to GIT -- I'm have patches [as minimum] to xorprtm a) == SourceForge.net > Find Software > xorp > SCM Repositories > xorp > trunk > xorp > contrib > win32 > xorprtm http://xorp.svn.sourceforge.net/viewvc/xorp/trunk/xorp/contrib/win32/xorprtm/?pathrev=11384 [ http://xorp.svn.sourceforge.net/viewvc/xorp/trunk/xorp/contrib/win32/xorprtm/?view=tar&pathrev=11384 ] == b) == SourceForge.net > Find Software > xorp > SCM Repositories > xorp > trunk > xorp > contrib > win32 > installer http://xorp.svn.sourceforge.net/viewvc/xorp/trunk/xorp/contrib/win32/installer/?pathrev=11383 [ http://xorp.svn.sourceforge.net/viewvc/xorp/trunk/xorp/contrib/win32/installer/?view=tar&pathrev=11383 ] == Best regards, Victor Miasnikov -- Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ P.S. ----- Original Message ----- From: "Victor Miasnikov" To: Sent: Monday, March 12, 2012 6:35 PM Subject: xorprtm4.dll / xorprtm6.dll Fw: RTMv2 Or XORP and RRAS ( Routing and Remote Access Services) Fw: XORP on Windows > Hi! > > Please, "undelete" on GIT source code of xorprtm4.dll / xorprtm6.dll > > xorp.ct/contrib/win32/xorprtm/ > > Best regards, Victor Miasnikov From greearb at candelatech.com Tue Mar 13 09:22:14 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 09:22:14 -0700 Subject: [Xorp-hackers] xorprtm4.dll / xorprtm6.dll Fw: RTMv2 Or XORP and RRAS ( Routing and Remote Access Services) Fw: XORP on Windows In-Reply-To: <7DD51393B44C46F9B9B384531EA1D897@local.st.by> References: <7DD51393B44C46F9B9B384531EA1D897@local.st.by> Message-ID: <4F5F7436.9060308@candelatech.com> On 03/13/2012 07:51 AM, Victor Miasnikov wrote: > > Hi! > > > > ----- Original Message ----- > From: "Victor Miasnikov" > To: "Ben Greear" > Sent: Tuesday, March 13, 2012 5:46 PM > Subject: Fw: xorprtm4.dll / xorprtm6.dll Fw: RTMv2 Or XORP and RRAS ( Routing and Remote Access Services) Fw: XORP on > Windows > > Hi! > > Please, unpack to You build folder ( for save rigfh date+time of files in future xorp-1.8.6-src.tar.bz2 ) and upload to > GIT -- I'm have patches [as minimum] to xorprtm The sourceforge repository is just for historical purposes. If you want me to add patches, they need to be against the github repository. If you want to add files to the git repository, copy them into your xorp git tree and run 'git add [files]' Then: get commit -a And then, generate a patch with 'git format-patch' and send it with 'git send-email'. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Tue Mar 13 09:29:05 2012 From: noreply at github.com (GitHub) Date: Tue, 13 Mar 2012 09:29:05 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] c28499: windows: mingw cross compiler update for F16. Message-ID: <4f5f75d14ffb_8e517dcae88563@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: c28499dcbd608927ca06016db587a5cf7af82fa7 https://github.com/greearb/xorp.ct/commit/c28499dcbd608927ca06016db587a5cf7af82fa7 Author: Victor Miasnikov Date: 2012-03-13 (Tue, 13 Mar 2012) Changed paths: M xorp/win32_pkg.bash Log Message: ----------- windows: mingw cross compiler update for F16. windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash 1) add copy libstdc++-6.dll in win32_pkg.bash 1b) add backward compatibility with old mingw GCC runtime i.e. in case run builds on Fedora 13 (and/or with older mingw packages) 2) change order exit errors numbers i.e. first -- common issue, last -- copy *.dll related 3) update notes about Fedora cross-compile packages ( mingw32-* ) 3b) but not removing info the older mingw packages ( see section "works on Fedora 13") 4) update notes and URLs related with Error 51 in w32api headers file routprot.h See screenshot of error: == . . . include/routprot.h:51: error: 'IP_LOCAL_BINDING' does not name a type == Signed-off-by: Victor Miasnikov From greearb at candelatech.com Tue Mar 13 09:30:33 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 09:30:33 -0700 Subject: [Xorp-hackers] [PATCH] windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash 1) libstdc++-6.dll 2) change order exit errors 3) update notes mingw32 packages 4) add URLs /w32api/include/routprot.h 51: error: 'IP_LOCAL_BINDING' In-Reply-To: <24DA3CC239704500B43F218ADB325BEC@local.st.by> References: <4F5E4195.5080703@candelatech.com> <24DA3CC239704500B43F218ADB325BEC@local.st.by> Message-ID: <4F5F7629.7080807@candelatech.com> On 03/13/2012 03:20 AM, Victor Miasnikov wrote: > From: Victor Miasnikov > > windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash Please make the patch title shorter in the future. I also fixed up your check for file existence. I think it should be -f instead of -d (-d is for directory, right??). The change has been committed. Please test that it works for you in a clean build. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Tue Mar 13 09:47:50 2012 From: noreply at github.com (GitHub) Date: Tue, 13 Mar 2012 09:47:50 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 31b0f5: Remove auto-generated lex/yac files. Message-ID: <4f5f7a363c3b7_e3a3fe3c696aafc110673@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 31b0f5edafd890554b3d18ac29f4971d9a8ba896 https://github.com/greearb/xorp.ct/commit/31b0f5edafd890554b3d18ac29f4971d9a8ba896 Author: Ben Greear Date: 2012-03-13 (Tue, 13 Mar 2012) Changed paths: R xorp/rtrmgr/lex.boot.cc R xorp/rtrmgr/lex.opcmd.cc R xorp/rtrmgr/lex.tplt.cc R xorp/rtrmgr/y.boot_tab.cc R xorp/rtrmgr/y.boot_tab.h R xorp/rtrmgr/y.opcmd_tab.cc R xorp/rtrmgr/y.opcmd_tab.h R xorp/rtrmgr/y.tplt_tab.cc R xorp/rtrmgr/y.tplt_tab.h Log Message: ----------- Remove auto-generated lex/yac files. Patches by Igor Maravic, but I just did a 'git rm' instead of applying the patches that did the same work. NOTE: This probably breaks the build until the next patch is applied. --Ben Signed-off-by: Igor Maravic Commit: e7a9b50727675488f84767e34ab9a98cbabf2989 https://github.com/greearb/xorp.ct/commit/e7a9b50727675488f84767e34ab9a98cbabf2989 Author: Igor Maravic Date: 2012-03-13 (Tue, 13 Mar 2012) Changed paths: M xorp/rtrmgr/SConscript M xorp/rtrmgr/boot.ll M xorp/rtrmgr/boot.yy M xorp/rtrmgr/op_commands.cc M xorp/rtrmgr/op_commands.ll M xorp/rtrmgr/op_commands.yy M xorp/rtrmgr/template.ll M xorp/rtrmgr/template.yy M xorp/site_scons/config/allconfig.py Log Message: ----------- xorp: Automatically generate lex and yacc files In xorp/site_scons/config/allconfig.py added checks if 'flex' and 'bison' are installed. If they aren't instructs user how to install them (instructions are for Ubuntu and Fedora). Change xorp/rtrmgr/SConscript to automatically generate yacc and lex files with bison and flex. In CPPPATH added env['xorp_sorcedir'] so generated files could include necessary files. Also did minor changes in .yy and .ll files, so they would compile. Unfortunately Eclipse striped whitespaces from changed files, so they are meshed up with the changed code. Signed-off-by: Igor Maravic Compare: https://github.com/greearb/xorp.ct/compare/c28499d...e7a9b50 From greearb at candelatech.com Tue Mar 13 10:11:35 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 10:11:35 -0700 Subject: [Xorp-hackers] [PATCH 1/4] xorp: Added support for uint64 type In-Reply-To: <1331635755-4320-2-git-send-email-igorm@etf.rs> References: <1331635755-4320-1-git-send-email-igorm@etf.rs> <1331635755-4320-2-git-send-email-igorm@etf.rs> Message-ID: <4F5F7FC7.9060405@candelatech.com> On 03/13/2012 03:49 AM, igorm at etf.rs wrote: > From: Igor Maravic > > In template.yy and template.ll files added support for uint64 and uin64range types. Their nodes are called > NODE_ULONG and NODE_ULONGRANGE respectively. > > In range.hh added U64Range class. Does everything as U32Range, but with uint64_t instead of uint32_t variables. > > In template_tree_node.cc and template_tree_node.hh added ULongTemplate and ULongRangeTemplate to handle new types. > > Unfortunately Eclipse striped whitespaces from changed files, so they are meshed up with the changed code. First, it is best if you can at least not mix un-related whitespace changes with code changes. But, I can deal with it. It have several questions on this patch. Please see below. > /** > + * @short A linear range class (uint64_t low)..(uint64_t high) > + * > + * Inherits from templatized general Range class. > + * Provides specialized constructor from string and str() method. > + */ > +class U64Range: public Range { > +public: > + /** > + * Default constructor > + */ > + U64Range() { Range::_low = > + Range::_high = 0; } > + > + /** > + * Constructor from a string. > + */ > + U64Range(const char *from_cstr) { > + string from_string = string(from_cstr); > + string::size_type delim = from_string.find("..", 0); > + if (delim == string::npos) { > + _low = _high = strtoul(from_cstr, NULL, 10); > + } else if (delim> 0&& (from_string.length() - delim> 2)) { > + _low = strtoul(from_string.substr(0, delim).c_str(), NULL, 10); > + _high = strtoul(from_string.substr(delim + 2, from_string.length()).c_str(), NULL, 10); > + } else { > + xorp_throw(InvalidString, "Syntax error"); > + } > + } > + > + /** > + * Convert the range to a human-readable format. > + * > + * @return C++ string. > + */ > + string str() const { > + ostringstream os; > + os<< _low; > + if (_low< _high) > + os<< ".."<< _high; > + return os.str(); > + } > +}; The indentation for the above code is bad. Please fix this. Maybe you need to configure Eclipse to always use spaces instead of tabs? (That seems to be the way Xorp code is written for the most part.) > + /** > + * If ctn_type() == NODE_ULONG, then > + * type will be NODE_UINT, because > + * we read uint64 values just as uint values > + */ > + if (ctn->type() == NODE_ULONG&& type == NODE_UINT) > + type = NODE_ULONG; Indent 4 spaces instead of whatever this is. > + > if ((ctn->type() == NODE_TEXT)&& (type == NODE_TEXT)) { > svalue = unquote(svalue); > } else if ((ctn->type() == NODE_TEXT)&& (type != NODE_TEXT)) { > // We'll accept anything as text > - } else if ((ctn->type() == NODE_UINTRANGE)&& (type == NODE_UINT)) { > + } else if (((ctn->type() == NODE_UINTRANGE)&& (type == NODE_UINT)) || > + ((ctn->type() == NODE_ULONGRANGE)&& (type == NODE_ULONG))) { > // Expand a single uint to a uintrange > + // or a single uint64 to uint64range > svalue += ".." + value; > } else if ((ctn->type() == NODE_IPV4RANGE)&& (type == NODE_IPV4)) { > // Expand a single IPv4 to a ipv4range Fix the indentation above. > @@ -228,6 +228,12 @@ TemplateTree::new_node(TemplateTreeNode* parent, > case NODE_UINTRANGE: > ttn = new UIntRangeTemplate(*this, parent, path, varname, initializer); > break; > + case NODE_ULONG: > + ttn = new ULongTemplate(*this, parent, path, varname, initializer); > + break; > + case NODE_ULONGRANGE: > + ttn = new ULongRangeTemplate(*this, parent, path, varname, initializer); > + break; > case NODE_INT: > ttn = new IntTemplate(*this, parent, path, varname, initializer); > break; My preference is to indent after the case statement. > +ULongTemplate::ULongTemplate(TemplateTree& template_tree, > + TemplateTreeNode* parent, > + const string& path, const string& varname, > + const string& initializer) throw (ParseError) > + : TemplateTreeNode(template_tree, parent, path, varname) > +{ > + string error_msg; > + > + if (initializer.empty()) > + return; > + > + string s = strip_quotes(initializer); > + if (! type_match(s, error_msg)) { > + error_msg = c_format("Bad ULong type value \"%s\": %s.", > + initializer.c_str(), error_msg.c_str()); > + xorp_throw(ParseError, error_msg); > + } > + _default = strtoll(s.c_str(), (char **)NULL, 10); > + set_has_default(); > +} > + > +bool > +ULongTemplate::type_match(const string& orig, string& error_msg) const > +{ > + string s = strip_quotes(orig); > + > + for (size_t i = 0; i< s.length(); i++) { > + if (s[i]< '0' || s[i]> '9') { > + if (s[i]=='-') { > + error_msg = "value cannot be negative"; > + } else if (s[i]=='.') { > + error_msg = "value must be an integer"; > + } else { > + error_msg = "value must be numeric"; > + } > + return false; > + } > + } > + return true; > +} Maybe more tabs instead of spaces or something? Indentation looks funny to me. > + > +string > +ULongTemplate::default_str() const > +{ > + return c_format("%lu", _default); > +} > + > + > +/************************************************************************** > + * ULongRangeTemplate > + **************************************************************************/ > + > +ULongRangeTemplate::ULongRangeTemplate(TemplateTree& template_tree, > + TemplateTreeNode* parent, > + const string& path, const string& varname, > + const string& initializer) throw (ParseError) > + : TemplateTreeNode(template_tree, parent, path, varname), > + _default(NULL) > +{ > + string error_msg; > + > + if (initializer.empty()) > + return; > + > + try { > + _default = new U64Range(initializer.c_str()); > + } catch (InvalidString) { > + error_msg = c_format("Bad U64Range type value \"%s\".", > + initializer.c_str()); > + xorp_throw(ParseError, error_msg); > + } > + set_has_default(); > +} > + > +ULongRangeTemplate::~ULongRangeTemplate() > +{ > + if (_default != NULL) > + delete _default; > +} > + > +string > +ULongRangeTemplate::default_str() const > +{ > + if (_default != NULL) > + return _default->str(); > + > + return ""; > +} > + > +bool > +ULongRangeTemplate::type_match(const string& s, string& error_msg) const > +{ > + string tmp = strip_quotes(s); > + > + if (tmp.empty()) { > + error_msg = "value must be a valid range of unsigned 64-bit integers"; > + return false; > + } > + > + try { > + U64Range* u64range = new U64Range(tmp.c_str()); > + delete u64range; > + } catch (InvalidString) { > + error_msg = "value must be a valid range of unsigned 64-bit integers"; > + return false; > + } > + return true; > +} More indentation issues above. > @@ -42,22 +42,24 @@ enum TTNodeType { > NODE_VOID = 0, > NODE_TEXT = 1, > NODE_UINT = 2, > - NODE_INT = 3, > - NODE_BOOL = 4, > - NODE_TOGGLE = 4, > - NODE_IPV4 = 5, > - NODE_IPV4NET = 6, > - NODE_IPV6 = 7, > - NODE_IPV6NET = 8, > - NODE_MACADDR = 9, > - NODE_URL_FILE = 10, > - NODE_URL_FTP = 11, > - NODE_URL_HTTP = 12, > - NODE_URL_TFTP = 13, > - NODE_ARITH = 14, > - NODE_UINTRANGE = 15, > - NODE_IPV4RANGE = 16, > - NODE_IPV6RANGE = 17 > + NODE_ULONG = 3, > + NODE_INT = 4, > + NODE_BOOL = 5, > + NODE_TOGGLE = 5, > + NODE_IPV4 = 6, > + NODE_IPV4NET = 7, > + NODE_IPV6 = 8, > + NODE_IPV6NET = 9, > + NODE_MACADDR = 10, > + NODE_URL_FILE = 11, > + NODE_URL_FTP = 12, > + NODE_URL_HTTP = 13, > + NODE_URL_TFTP = 14, > + NODE_ARITH = 15, > + NODE_UINTRANGE = 16, > + NODE_ULONGRANGE = 17, > + NODE_IPV4RANGE = 18, > + NODE_IPV6RANGE = 19 > }; Why are you adding in the middle? It would seem to be better to add at the end to me..less code change and less risk of something weird happening?? Please fix this up and re-submit. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From greearb at candelatech.com Tue Mar 13 10:12:45 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 10:12:45 -0700 Subject: [Xorp-hackers] [PATCH 4/4] xorp: rtrmgr: Enable i32 and u64 multi value nodes to boot up In-Reply-To: <1331635755-4320-5-git-send-email-igorm@etf.rs> References: <1331635755-4320-1-git-send-email-igorm@etf.rs> <1331635755-4320-5-git-send-email-igorm@etf.rs> Message-ID: <4F5F800D.4020602@candelatech.com> On 03/13/2012 03:49 AM, igorm at etf.rs wrote: > From: Igor Maravic > > Positive int and u64 values are read as uint. If our node is of type > NODE_ULONG or NODE_INT and read type is of type NODE_UINT, than we have a match. > > Signed-off-by: Igor Maravic > --- > xorp/rtrmgr/template_tree.cc | 6 ++++++ > 1 files changed, 6 insertions(+), 0 deletions(-) > > diff --git a/xorp/rtrmgr/template_tree.cc b/xorp/rtrmgr/template_tree.cc > index 6b51a3a..fa04132 100644 > --- a/xorp/rtrmgr/template_tree.cc > +++ b/xorp/rtrmgr/template_tree.cc > @@ -491,6 +491,12 @@ TemplateTree::find_node_by_type(const list& path_segments) > if (t->type() == type) { > matches.push_back(t); > continue; > + } else if ((t->type() == NODE_ULONG || t->type() == NODE_INT)&& type == NODE_UINT) { > + // u64 values are read as u32 values, because their > + // regexp is the same. > + // Same is for the positive int values. > + matches.push_back(t); > + continue; > } Fix code indentation of the comments please. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From greearb at candelatech.com Tue Mar 13 10:27:47 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 10:27:47 -0700 Subject: [Xorp-hackers] [PATCH] xorp: rtrmgr: Fix command completion with %allow-range option on multi-value nodes In-Reply-To: <1331636150-4816-2-git-send-email-igorm@etf.rs> References: <1331636150-4816-1-git-send-email-igorm@etf.rs> <1331636150-4816-2-git-send-email-igorm@etf.rs> Message-ID: <4F5F8393.5070605@candelatech.com> On 03/13/2012 03:55 AM, igorm at etf.rs wrote: > From: Igor Maravic > > Fixed problem of command completion for multi-value nodes with allow-range option. > Without this fix, if we would enter number within the allowed range, and then we would enter > " " + "\t" we wouldn't get any command propositions. > > Signed-off-by: Igor Maravic > --- > xorp/rtrmgr/template_tree.cc | 45 +++++++++++++++++++++++++++++++----- > xorp/rtrmgr/template_tree_node.cc | 6 ++-- > 2 files changed, 41 insertions(+), 10 deletions(-) > > diff --git a/xorp/rtrmgr/template_tree.cc b/xorp/rtrmgr/template_tree.cc > index fa04132..08c9280 100644 > #ifdef HOST_OS_WINDOWS > #define stat _stat > @@ -422,18 +433,38 @@ TemplateTree::find_node(const list& path_segments) const > // There's no exact name match, so we're probably looking for a > // match of an encoded typestr or a value against a typed variable. > for (ti = ttn->children().begin(); ti != ttn->children().end(); ++ti) { > - TemplateTreeNode* t = *ti; > - if (t->type() == NODE_VOID) > + TemplateTreeNode* t = *ti; > + if (t->type() == NODE_VOID) > continue; > - if ((t->parent() == NULL) || (! t->parent()->is_tag())) > + if ((t->parent() == NULL) || (! t->parent()->is_tag())) > continue; > - if (t->encoded_typestr() == segname) { > + if (t->encoded_typestr() == segname) { > matches.push_back(t); > continue; > - } > - string s; > - if (t->type_match(segname, s)) > + } > + > + /** > + * Check if this segname represents some kind of range. > + * If it does, it will match regexp below, and we > + * are expecting t->encoded_typestr to be "" or"" or"" > + */ > + regex_t range_reg; > + if (regcomp(&range_reg, "[\[][-]{0,1}[0-9]+[.][.][-]{0,1}[0-9]+]", REG_EXTENDED)) > + XLOG_UNREACHABLE(); > + > + bool is_range = !regexec(&range_reg, segname.c_str(), 0, 0, 0); > + regfree(&range_reg); > + if (is_range&& > + (t->encoded_typestr() == "" > + || t->encoded_typestr() == "" > + || t->encoded_typestr() == "")) { > matches.push_back(t); > + continue; > + } > + > + string s; > + if (t->type_match(segname, s)) > + matches.push_back(t); > } The formatting is all weird above. Maybe using tabs instead of spaces? Please fix this and re-submit. Also, I'm not sure you sent both patches in this series? Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From greearb at candelatech.com Tue Mar 13 10:35:33 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 10:35:33 -0700 Subject: [Xorp-hackers] xrl calls from xorp_ospf to xorp_fea start failing when generating lots of calls. In-Reply-To: References: Message-ID: <4F5F8565.7040708@candelatech.com> On 03/13/2012 07:17 AM, Markus Zehnder wrote: > Hi there, > > In my setup i have a problem in ospf/ospf.cc Ospf::transmit(). > Around line 333, the call to _io->send() returns 'false'. > > > Setup: two linux boxes (virtual) with xorp 1.8.5, configured to run OSPF, both boxes in the same area 0.0.0.0. The two machines > are connected with two links on different interfaces. The neighbor state of the interfaces is "FULL". > OSPF is configured to distribute the static routes. > > Scenario to trigger above problem: > - Modify the configfile of one box and add somewhat around 100 static routes. > - Reload the configfile with "load " in xorpsh. > Result: > - only about 60 to 70 routes get distributed with the first try. rest comes later (with the retransmit when it works (see #109)) Thanks for the bug and the patch. I'm going to look over that now. > Debugging: > - ospf is trying to send LSA Updates, one packet for each route and interface. The packets are passed to xorp_fea as > mentioned at the top with the transmit() method. ..but that fails after 120..140 packets. > > Can anybody give me some hint how that intented to work ? Is there some queue overflowing in the xorp_fea? should > xorp_fea run with higher priority then the xorp_ospf. Probably whatever is sending needs to queue and retry sends that fail (and preserve ordering, most likely..so after first failure, start queueing or otherwise stop sending pkts, set a short timer, and try again soon). XRL is tricky code to deal with, so it's usually easier to hack around it's deficiencies than try to fix the core code to be more flexible. But, I'd welcome patches that make the core more robust! > I guess i do not yet understand the XRL stuff good enough... > > Don't tell me that my scenario is not realistic. I try to reconfigure xorp with a reload of the config file because that > should be faster than a complete restart. And i would like to know the limits..when does it work and under which > condition will it fail. If anyone ever tries to ignore a bug by complaining about unrealistic scenarios, then yell at them loudly :) But, that said..you may have to be the one to fix it... Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Tue Mar 13 10:36:44 2012 From: noreply at github.com (GitHub) Date: Tue, 13 Mar 2012 10:36:44 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 3e7f35: trivial: trailing ws removed Message-ID: <4f5f85ace0e9_384b3fe0d38182f8581e8@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 3e7f353c2ce0cdedaea7f4b03ada165d909f54ed https://github.com/greearb/xorp.ct/commit/3e7f353c2ce0cdedaea7f4b03ada165d909f54ed Author: Igor Maravic Date: 2012-03-13 (Tue, 13 Mar 2012) Changed paths: M xorp/cli/cli_client.cc Log Message: ----------- trivial: trailing ws removed Signed-off-by: Igor Maravic From greearb at candelatech.com Tue Mar 13 10:39:57 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 10:39:57 -0700 Subject: [Xorp-hackers] [PATCH 00/10] Automatically generate lex and yacc files In-Reply-To: <1331635183-3800-1-git-send-email-igorm@etf.rs> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> Message-ID: <4F5F866D.8010806@candelatech.com> On 03/13/2012 03:39 AM, igorm at etf.rs wrote: > From: Igor Maravic > > Hi, > I removed files in individual patches. > 10th patch is where I introduced auto generation of lex and yacc files > BR > Igor Applied and pushed. I see this error on the 32-bit FC8 build-bot machine: gcc -o obj/i686-pc-linux-gnu/rtrmgr/glob_win32.o -c -std=gnu99 -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wcast-qual -Wmissing-declarations -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wnested-externs -pipe -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i686-pc-linux-gnu -I. -Iobj/i686-pc-linux-gnu/rtrmgr -Irtrmgr -I. rtrmgr/glob_win32.c flex -Ptplt -t rtrmgr/template.ll > obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.cc bison -d -ptplt -o obj/i686-pc-linux-gnu/rtrmgr/y.tplt_tab.cc rtrmgr/template.yy g++ -o obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i686-pc-linux-gnu -I. -Iobj/i686-pc-linux-gnu/rtrmgr -Irtrmgr -I. obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.cc cc1plus: warnings being treated as errors : In function ???int yy_get_next_buffer()???: :9666: warning: comparison between signed and unsigned integer expressions scons: *** [obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.o] Error 1 scons: building terminated because of errors. program finished with exit code 2 elapsedTime=811.975911 Any ideas on how to fix that? Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From greearb at candelatech.com Tue Mar 13 10:43:13 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 10:43:13 -0700 Subject: [Xorp-hackers] [PATCH] xorp: rtrmgr: Fix command completion with %allow-range option on multi-value nodes In-Reply-To: <4F5F8393.5070605@candelatech.com> References: <1331636150-4816-1-git-send-email-igorm@etf.rs> <1331636150-4816-2-git-send-email-igorm@etf.rs> <4F5F8393.5070605@candelatech.com> Message-ID: <4F5F8731.6010304@candelatech.com> On 03/13/2012 10:27 AM, Ben Greear wrote: > On 03/13/2012 03:55 AM, igorm at etf.rs wrote: >> From: Igor Maravic >> >> Fixed problem of command completion for multi-value nodes with allow-range option. >> Without this fix, if we would enter number within the allowed range, and then we would enter >> " " + "\t" we wouldn't get any command propositions. >> >> Signed-off-by: Igor Maravic >> --- >> xorp/rtrmgr/template_tree.cc | 45 +++++++++++++++++++++++++++++++----- >> xorp/rtrmgr/template_tree_node.cc | 6 ++-- >> 2 files changed, 41 insertions(+), 10 deletions(-) >> >> diff --git a/xorp/rtrmgr/template_tree.cc b/xorp/rtrmgr/template_tree.cc >> index fa04132..08c9280 100644 > >> #ifdef HOST_OS_WINDOWS >> #define stat _stat >> @@ -422,18 +433,38 @@ TemplateTree::find_node(const list& path_segments) const >> // There's no exact name match, so we're probably looking for a >> // match of an encoded typestr or a value against a typed variable. >> for (ti = ttn->children().begin(); ti != ttn->children().end(); ++ti) { >> - TemplateTreeNode* t = *ti; >> - if (t->type() == NODE_VOID) >> + TemplateTreeNode* t = *ti; >> + if (t->type() == NODE_VOID) >> continue; >> - if ((t->parent() == NULL) || (! t->parent()->is_tag())) >> + if ((t->parent() == NULL) || (! t->parent()->is_tag())) >> continue; >> - if (t->encoded_typestr() == segname) { >> + if (t->encoded_typestr() == segname) { >> matches.push_back(t); >> continue; >> - } >> - string s; >> - if (t->type_match(segname, s)) >> + } >> + >> + /** >> + * Check if this segname represents some kind of range. >> + * If it does, it will match regexp below, and we >> + * are expecting t->encoded_typestr to be "" or"" or"" >> + */ >> + regex_t range_reg; >> + if (regcomp(&range_reg, "[\[][-]{0,1}[0-9]+[.][.][-]{0,1}[0-9]+]", REG_EXTENDED)) >> + XLOG_UNREACHABLE(); >> + >> + bool is_range = !regexec(&range_reg, segname.c_str(), 0, 0, 0); >> + regfree(&range_reg); >> + if (is_range&& >> + (t->encoded_typestr() == "" >> + || t->encoded_typestr() == "" >> + || t->encoded_typestr() == "")) { >> matches.push_back(t); >> + continue; >> + } >> + >> + string s; >> + if (t->type_match(segname, s)) >> + matches.push_back(t); >> } > > The formatting is all weird above. Maybe using tabs instead of spaces? > > Please fix this and re-submit. > > Also, I'm not sure you sent both patches in this series? Actually, xorp is using tabs for indentation. Maybe your patch will look better outside of email. Let me double-check that before you spend more time re-writing it. Thanks, Ben > > Thanks, > Ben > > -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Tue Mar 13 11:00:21 2012 From: noreply at github.com (GitHub) Date: Tue, 13 Mar 2012 11:00:21 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] f720db: ospf: Fix full-state timer logic. Message-ID: <4f5f8b35e123e_fa91cc3ae88077@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: f720db3712462fca67e6c868ea12350b3ee27dc4 https://github.com/greearb/xorp.ct/commit/f720db3712462fca67e6c868ea12350b3ee27dc4 Author: Ben Greear Date: 2012-03-13 (Tue, 13 Mar 2012) Changed paths: M xorp/ospf/peer.cc Log Message: ----------- ospf: Fix full-state timer logic. Original patch & problem diagnosis is by Markus Zehnder In OSPF, the timer which should fire after 5 seconds and trigger a retransmission of unacknowledged LSA Updates is never restarted. After the timer has once fired, it is never (re)started again. The code which checks if the timer is still running is buggy. It always returns true after the timer wrapper object was once created. Introduced with another bugfix from 1.8.3 to 1.8.6 Signed-off-by: Ben Greear From B37785 at freescale.com Tue Mar 13 11:14:53 2012 From: B37785 at freescale.com (Gorja Prasad-B37785) Date: Tue, 13 Mar 2012 18:14:53 +0000 Subject: [Xorp-hackers] XORP compilation for power pc Message-ID: <4A02723C7D5B444A906BBD657C5503EB08567D49@039-SN1MPN1-006.039d.mgd.msft.net> Ben, Thanks for the reply and I have registered with my coreID. I have compiled openssl-1.0.0 and installed at default location /usr/local/ssl/ and can see /usr/local/ssl/lib and /usr/local/ssl/bin directories. scons build= powerpc-none-linux-gnuspe \ STRIP=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-strip \ CC=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc \ CXX=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-g++ CFLAGS=-I=-I/usr/local/ssl/include \ CXXFLAGS=-I/usr/local/ssl/include \ LINKFLAGS=-L/usr/local/ssl/lib I hit the road either ERROR: Cannot find required openssl/md5.h or ERROR: cannot find fpclassify,tried -std=gnu99 as well. >>>>>>>I think I compiled openssl and placed it in the standard include & library paths for the cross-compiler when using ARM Could you provide the paths where you have placed opensssl for ARM. Thanks, Prasad Gorja On 03/13/2012 10:05 AM, Gorja Prasad-B37785 wrote: > Some how, my mail got bounced back to me. Please help me!. Please make sure you are subscribed with the proper email. > Hi, > > I am trying to compile tried to compile XORP-1.8.5 for PowerPC. > 1.Compiled openssl-1.0.0 for PowerPC by using command and installed successsfully: > CC=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnus > pe-gcc \ > RANLIB=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux- > gnuspe-ranlib \ > AR==$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnu > spe-ar\ Perl Configure --prefix=$(HOME)/openssl-1.0.0 linux-ppc > > Make > Make install > > > 2. Build XORP-1.8.5 by the following command: > > scons build= powerpc-none-linux-gnuspe \ > STRIP=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-strip \ > CC=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc \ > > CXX=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnu > spe-g++ > > It Throws an error that could not find openssl/md5.h and build exited, but I do not see an option of --with-openssl in scons -help or scons -H. > But in step3(cross compilation heading),BUILD_NOTES, it is mentioned that "Build xorp with the cross-compiler, specifying the path to openssl." > > I am aware that xorp-1.6 can be compiled by using the command > xorp-1.6#./Configure --with-openssl=$(HOME)/openssl-1.0.0 --host= > powerpc-none-linux-gnuspe > > Please let me know how to set up the path for openssl for XORP-1.8.5 for scons. I think I compiled openssl and placed it in the standard include & library paths for the cross-compiler when using ARM. If you patch scons files to allow specifying openssl, please post them for inclusion. Or, maybe someone else on the list knows how to do this... Thanks, Ben -- Ben Greear > Candela Technologies Inc http://www.candelatech.com - Prasad Gorja -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120313/b171c554/attachment.html From greearb at candelatech.com Tue Mar 13 11:21:44 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 11:21:44 -0700 Subject: [Xorp-hackers] XORP compilation for power pc In-Reply-To: <4A02723C7D5B444A906BBD657C5503EB08567D49@039-SN1MPN1-006.039d.mgd.msft.net> References: <4A02723C7D5B444A906BBD657C5503EB08567D49@039-SN1MPN1-006.039d.mgd.msft.net> Message-ID: <4F5F9038.5010701@candelatech.com> On 03/13/2012 11:14 AM, Gorja Prasad-B37785 wrote: > Ben, > > Thanks for the reply and I have registered with my coreID. > > I have compiled openssl-1.0.0 and installed at default location /usr/local/ssl/ and can see /usr/local/ssl/lib and /usr/local/ssl/bin directories. > > scons build= powerpc-none-linux-gnuspe \ > > STRIP=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-strip \ > > CC=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc \ > > CXX=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-g++ > > CFLAGS=-I=-I/usr/local/ssl/include \ > > CXXFLAGS=-I/usr/local/ssl/include \ > > LINKFLAGS=-L/usr/local/ssl/lib > > I hit the road either ERROR: Cannot find required openssl/md5.h or ERROR: cannot find fpclassify,tried ?std=gnu99 as well. > > >>>>>>>I think I compiled openssl and placed it in the standard include & library paths for the cross-compiler when using ARM > > Could you provide the paths where you have placed opensssl for ARM. Please post the last bit of your compile log where the error occurs. That fpclassify thing is something else I think. Please post the few lines around that message as well. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From B37785 at freescale.com Tue Mar 13 11:44:40 2012 From: B37785 at freescale.com (Gorja Prasad-B37785) Date: Tue, 13 Mar 2012 18:44:40 +0000 Subject: [Xorp-hackers] XORP compilation for power pc In-Reply-To: <4F5F9038.5010701@candelatech.com> References: <4A02723C7D5B444A906BBD657C5503EB08567D49@039-SN1MPN1-006.039d.mgd.msft.net> <4F5F9038.5010701@candelatech.com> Message-ID: <4A02723C7D5B444A906BBD657C5503EB08567D79@039-SN1MPN1-006.039d.mgd.msft.net> Log1:(when included CFLAGS=-I=-I/usr/local/ssl/include \ CXXFLAGS=-I/usr/local/ssl/include \ > LINKFLAGS=-L/usr/local/ssl/lib)\ Checking whether system has sysctl IPCTL_FORWARDING... no Checking whether __KAME__ is declared... no Checking whether inet6_opt_init is declared... no Checking whether C type struct sockaddr_in6 has member sin6_len... no Checking whether C type struct sockaddr_in6 has member sin6_scope_id... yes Checking for C header file netinet/ip6.h... yes Checking for C header file netinet/icmp6.h... yes Checking for C type struct mld_hdr... yes Checking for C header file netinet6/in6_var.h... no Checking for C header file netinet6/nd6.h... no Checking for C++ header file netinet6/nd6.h... no Checking whether system has sysctl IPV6CTL_FORWARDING... no Checking whether system has sysctl IPV6CTL_ACCEPT_RTADV... no Checking whether IPV6_MULTICAST_IF is declared... yes Checking whether IPV6_MULTICAST_LOOP is declared... yes Checking whether fpclassify is declared... no Checking whether fpclassify is declared... no ERROR: Cannot find fpclassify, tried -std=gnu99 as well Log2( when not included the CFLAGS,CXX FLAGS and LINKFLAGS): Checking whether C type struct mfcctl2 has member mfcc_flags... no Checking whether C type struct mfcctl2 has member mfcc_rp... no Checking for C header file netinet/pim.h... no Checking for C type struct pim... no Checking whether C type struct pim has member pim_vt... no Checking for C header file netinet6/ip6_mroute.h... no Checking for C header file linux/mroute6.h... yes Checking whether inet6_option_space is declared... no Checking for C type struct mf6cctl2... no Checking whether C type struct mf6cctl2 has member mf6cc_flags... no Checking whether C type struct mf6cctl2 has member mf6cc_rp... no WARNING: inet6_option_* and inet6_opt_* are not supported on this system. this might cause some problems with IPv6 multicast routing. Checking whether C type struct mif6ctl has member vifc_threshold... yes Checking for C header file netinet/ip_compat.h... no Checking for C header file netinet/ip_fil.h... no Checking for C header file netinet/ip_fw.h... no Checking for C header file net/pfvar.h... no Checking for C++ header file linux/netfilter_ipv4/ip_tables.h... no Checking for C++ header file linux/netfilter_ipv6/ip6_tables.h... no Checking for C header file net/if_vlanvar.h... no Checking for C header file net/if_vlan_var.h... no Checking for C header file net/vlan/if_vlan_var.h... no Checking for C header file linux/if_vlan.h... yes Checking whether GET_VLAN_REALDEV_NAME_CMD is declared... yes Checking whether GET_VLAN_VID_CMD is declared... yes Checking for C header file pcre.h... no Checking for C header file pcreposix.h... no Checking for C library pcre... no Checking for C library pcreposix... no Checking for C header file openssl/md5.h... no ERROR: Cannot find required openssl/md5.h. On Fedora/RedHat: yum install openssl-devel On Ubuntu: apt-get install libssl-dev After install, rm -fr xorp/obj build directory to clear the configure cache before re-building. Log3(config.log): cons: Configure: Checking for C header file openssl/md5.h... obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.c <- |#include | |#include | | /opt/freescale/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc -o obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.o -c -std=gnu99 -Iobj/powerpc-none-linux-gnuspe obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.c obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.c:3:25: error: openssl/md5.h: No such file or directory scons: Configure: no Thanks, Prasad Gorja -----Original Message----- From: Ben Greear [mailto:greearb at candelatech.com] Sent: Tuesday, March 13, 2012 11:52 PM To: Gorja Prasad-B37785 Cc: xorp-hackers at icir.org Subject: Re: XORP compilation for power pc On 03/13/2012 11:14 AM, Gorja Prasad-B37785 wrote: > Ben, > > Thanks for the reply and I have registered with my coreID. > > I have compiled openssl-1.0.0 and installed at default location /usr/local/ssl/ and can see /usr/local/ssl/lib and /usr/local/ssl/bin directories. > > scons build= powerpc-none-linux-gnuspe \ > > STRIP=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-g > nuspe-strip \ > > CC=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnus > pe-gcc \ > > CXX=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnu > spe-g++ > > CFLAGS=-I=-I/usr/local/ssl/include \ > > CXXFLAGS=-I/usr/local/ssl/include \ > > LINKFLAGS=-L/usr/local/ssl/lib > > I hit the road either ERROR: Cannot find required openssl/md5.h or ERROR: cannot find fpclassify,tried -std=gnu99 as well. > > >>>>>>>I think I compiled openssl and placed it in the standard > include & library paths for the cross-compiler when using ARM > > Could you provide the paths where you have placed opensssl for ARM. Please post the last bit of your compile log where the error occurs. That fpclassify thing is something else I think. Please post the few lines around that message as well. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From greearb at candelatech.com Tue Mar 13 11:50:41 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 11:50:41 -0700 Subject: [Xorp-hackers] XORP compilation for power pc In-Reply-To: <4A02723C7D5B444A906BBD657C5503EB08567D79@039-SN1MPN1-006.039d.mgd.msft.net> References: <4A02723C7D5B444A906BBD657C5503EB08567D49@039-SN1MPN1-006.039d.mgd.msft.net> <4F5F9038.5010701@candelatech.com> <4A02723C7D5B444A906BBD657C5503EB08567D79@039-SN1MPN1-006.039d.mgd.msft.net> Message-ID: <4F5F9701.20300@candelatech.com> On 03/13/2012 11:44 AM, Gorja Prasad-B37785 wrote: > Log1:(when included CFLAGS=-I=-I/usr/local/ssl/include \ > CXXFLAGS=-I/usr/local/ssl/include \ > > LINKFLAGS=-L/usr/local/ssl/lib)\ This doesn't seem to be working, as I see no mention of those flags in the openssl compile check that fails. Please post your exact commands that you are using to compile. > Checking whether fpclassify is declared... no > Checking whether fpclassify is declared... no > ERROR: Cannot find fpclassify, tried -std=gnu99 as well Not sure about this..maybe it's OK...if not, it should blow up later in the compile. > Checking for C header file openssl/md5.h... no > > ERROR: Cannot find required openssl/md5.h. > On Fedora/RedHat: yum install openssl-devel > On Ubuntu: apt-get install libssl-dev > After install, rm -fr xorp/obj build directory to > clear the configure cache before re-building. > > > Log3(config.log): > > cons: Configure: Checking for C header file openssl/md5.h... > obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.c<- > |#include > | > |#include > | > | > /opt/freescale/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc -o obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.o -c -std=gnu99 -Iobj/powerpc-none-linux-gnuspe obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.c > obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.c:3:25: error: openssl/md5.h: No such file or directory > scons: Configure: no I'd expect to see -I.../usr/local/... in this command since you are specifying the flags. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From greearb at candelatech.com Tue Mar 13 12:20:59 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 12:20:59 -0700 Subject: [Xorp-hackers] [PATCH 00/10] Automatically generate lex and yacc files In-Reply-To: <4F5F866D.8010806@candelatech.com> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> <4F5F866D.8010806@candelatech.com> Message-ID: <4F5F9E1B.4040104@candelatech.com> On 03/13/2012 10:39 AM, Ben Greear wrote: > On 03/13/2012 03:39 AM, igorm at etf.rs wrote: >> From: Igor Maravic >> >> Hi, >> I removed files in individual patches. >> 10th patch is where I introduced auto generation of lex and yacc files >> BR >> Igor > > Applied and pushed. I see this error on the 32-bit FC8 build-bot machine: > > gcc -o obj/i686-pc-linux-gnu/rtrmgr/glob_win32.o -c -std=gnu99 -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wcast-qual > -Wmissing-declarations -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wnested-externs -pipe -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i686-pc-linux-gnu -I. > -Iobj/i686-pc-linux-gnu/rtrmgr -Irtrmgr -I. rtrmgr/glob_win32.c > flex -Ptplt -t rtrmgr/template.ll> obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.cc > bison -d -ptplt -o obj/i686-pc-linux-gnu/rtrmgr/y.tplt_tab.cc rtrmgr/template.yy > g++ -o obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align -Woverloaded-virtual > -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i686-pc-linux-gnu -I. -Iobj/i686-pc-linux-gnu/rtrmgr -Irtrmgr -I. > obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.cc > cc1plus: warnings being treated as errors > : In function ???int yy_get_next_buffer()???: > :9666: warning: comparison between signed and unsigned integer expressions > scons: *** [obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.o] Error 1 > scons: building terminated because of errors. > program finished with exit code 2 > elapsedTime=811.975911 > > Any ideas on how to fix that? I can just disable -Werror on FC8 systems...but there is also this error on FreeBSD: http://dmz2.candelatech.com:8010/builders/v-freebsd-32/builds/88/steps/shell_1/logs/stdio This looks a bit harder to fix... g++ -o obj/i386-unknown-freebsd8.1/rtrmgr/config_operators.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 -I. -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. rtrmgr/config_operators.cc g++ -o obj/i386-unknown-freebsd8.1/rtrmgr/generic_module_manager.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 -I. -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. rtrmgr/generic_module_manager.cc gcc -o obj/i386-unknown-freebsd8.1/rtrmgr/glob_win32.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wcast-qual -Wmissing-declarations -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wnested-externs -pipe -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 -I. -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. rtrmgr/glob_win32.c flex -Ptplt -t rtrmgr/template.ll > obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.cc yacc -d -ptplt -o obj/i386-unknown-freebsd8.1/rtrmgr/y.tplt_tab.cc rtrmgr/template.yy g++ -o obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 -I. -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.cc rtrmgr/template.ll:14:25: error: y.tplt_tab.hh: No such file or directory rtrmgr/template.ll: In function 'int tpltlex()': rtrmgr/template.ll:233: error: 'UPLEVEL' was not declared in this scope rtrmgr/template.ll:237: error: 'DOWNLEVEL' was not declared in this scope rtrmgr/template.ll:248: error: 'END' was not declared in this scope rtrmgr/template.ll:252: error: 'COLON' was not declared in this scope We need to get a fix for this so we can compile on BSD or I'm going to have to revert the changes... Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Tue Mar 13 12:22:07 2012 From: noreply at github.com (GitHub) Date: Tue, 13 Mar 2012 12:22:07 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 8a06fc: scons: Allow disabling -Werror at build time. Message-ID: <4f5f9e5fe9640_4f383fde74d63afc87371@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 8a06fc46052129d9b12d01a4630b813c3a17d294 https://github.com/greearb/xorp.ct/commit/8a06fc46052129d9b12d01a4630b813c3a17d294 Author: Ben Greear Date: 2012-03-13 (Tue, 13 Mar 2012) Changed paths: M xorp/SConstruct Log Message: ----------- scons: Allow disabling -Werror at build time. Use: scons disable_werror=true This can be used to work around warnings on less-supported platforms. In particular, the bison/lex changes introduced some build warnings on Fedora Core 8, and this patch lets it compile there again. Signed-off-by: Ben Greear From B37785 at freescale.com Tue Mar 13 12:25:47 2012 From: B37785 at freescale.com (Gorja Prasad-B37785) Date: Tue, 13 Mar 2012 19:25:47 +0000 Subject: [Xorp-hackers] XORP compilation for power pc In-Reply-To: <4F5F9701.20300@candelatech.com> References: <4A02723C7D5B444A906BBD657C5503EB08567D49@039-SN1MPN1-006.039d.mgd.msft.net> <4F5F9038.5010701@candelatech.com> <4A02723C7D5B444A906BBD657C5503EB08567D79@039-SN1MPN1-006.039d.mgd.msft.net> <4F5F9701.20300@candelatech.com> Message-ID: <4A02723C7D5B444A906BBD657C5503EB08567DB4@039-SN1MPN1-006.039d.mgd.msft.net> This is the exact command I have used and Imade sure that openssl compiled and installed at /usr/loac/ssl. scons build= powerpc-none-linux-gnuspe \ STRIP=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-strip \ CC=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc \ CXX=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-g++ \ CFLAGS=-I=-I/usr/local/ssl/include \ CXXFLAGS=-I/usr/local/ssl/include \ LINKFLAGS=-L/usr/local/ssl/lib Config.log > /opt/freescale/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-li > nux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc -o > obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.o -c -std=gnu99 > -Iobj/powerpc-none-linux-gnuspe > obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.c > obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.c:3:25: error: > openssl/md5.h: No such file or directory > scons: Configure: no Thanks, Prasad gorja -----Original Message----- From: Ben Greear [mailto:greearb at candelatech.com] Sent: Wednesday, March 14, 2012 12:21 AM To: Gorja Prasad-B37785 Cc: xorp-hackers at icir.org Subject: Re: XORP compilation for power pc On 03/13/2012 11:44 AM, Gorja Prasad-B37785 wrote: > Log1:(when included CFLAGS=-I=-I/usr/local/ssl/include \ > CXXFLAGS=-I/usr/local/ssl/include \ > > LINKFLAGS=-L/usr/local/ssl/lib)\ This doesn't seem to be working, as I see no mention of those flags in the openssl compile check that fails. Please post your exact commands that you are using to compile. > Checking whether fpclassify is declared... no Checking whether > fpclassify is declared... no > ERROR: Cannot find fpclassify, tried -std=gnu99 as well Not sure about this..maybe it's OK...if not, it should blow up later in the compile. > Checking for C header file openssl/md5.h... no > > ERROR: Cannot find required openssl/md5.h. > On Fedora/RedHat: yum install openssl-devel > On Ubuntu: apt-get install libssl-dev > After install, rm -fr xorp/obj build directory to > clear the configure cache before re-building. > > > Log3(config.log): > > cons: Configure: Checking for C header file openssl/md5.h... > obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.c<- > |#include > | > |#include > | > | > /opt/freescale/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-li > nux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc -o > obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.o -c -std=gnu99 > -Iobj/powerpc-none-linux-gnuspe > obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.c > obj/powerpc-none-linux-gnuspe/.sconf_temp/conftest_198.c:3:25: error: > openssl/md5.h: No such file or directory > scons: Configure: no I'd expect to see -I.../usr/local/... in this command since you are specifying the flags. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From greearb at candelatech.com Tue Mar 13 13:31:10 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 13:31:10 -0700 Subject: [Xorp-hackers] XORP compilation for power pc In-Reply-To: <4A02723C7D5B444A906BBD657C5503EB08567DB4@039-SN1MPN1-006.039d.mgd.msft.net> References: <4A02723C7D5B444A906BBD657C5503EB08567D49@039-SN1MPN1-006.039d.mgd.msft.net> <4F5F9038.5010701@candelatech.com> <4A02723C7D5B444A906BBD657C5503EB08567D79@039-SN1MPN1-006.039d.mgd.msft.net> <4F5F9701.20300@candelatech.com> <4A02723C7D5B444A906BBD657C5503EB08567DB4@039-SN1MPN1-006.039d.mgd.msft.net> Message-ID: <4F5FAE8E.1070300@candelatech.com> On 03/13/2012 12:25 PM, Gorja Prasad-B37785 wrote: > This is the exact command I have used and Imade sure that openssl compiled and installed at /usr/loac/ssl. > > scons build= powerpc-none-linux-gnuspe \ > STRIP=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-strip \ > CC=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc \ > CXX=$(TOOL_CHAIN)/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-g++ \ > CFLAGS=-I=-I/usr/local/ssl/include \ > CXXFLAGS=-I/usr/local/ssl/include \ > LINKFLAGS=-L/usr/local/ssl/lib Well, that looks like how I'm doing the ARM cross-compile, so I'm not sure why it doesn't work for you. If you want to give me an account on your build machine, or send me a link to your cross-compile toolchain, I'll see if I can figure it out. If you want to look at it, you might add some debug logic to SConstruct to see if it's handling the CXXFLAGS logic properly. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From greearb at candelatech.com Tue Mar 13 13:59:46 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 13:59:46 -0700 Subject: [Xorp-hackers] [PATCH 00/10] Automatically generate lex and yacc files In-Reply-To: <4F5F9E1B.4040104@candelatech.com> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> <4F5F866D.8010806@candelatech.com> <4F5F9E1B.4040104@candelatech.com> Message-ID: <4F5FB542.7030501@candelatech.com> On 03/13/2012 12:20 PM, Ben Greear wrote: > On 03/13/2012 10:39 AM, Ben Greear wrote: >> On 03/13/2012 03:39 AM, igorm at etf.rs wrote: >>> From: Igor Maravic >>> >>> Hi, >>> I removed files in individual patches. >>> 10th patch is where I introduced auto generation of lex and yacc files >>> BR >>> Igor >> >> Applied and pushed. I see this error on the 32-bit FC8 build-bot machine: >> >> gcc -o obj/i686-pc-linux-gnu/rtrmgr/glob_win32.o -c -std=gnu99 -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wcast-qual >> -Wmissing-declarations -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wnested-externs -pipe -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i686-pc-linux-gnu -I. >> -Iobj/i686-pc-linux-gnu/rtrmgr -Irtrmgr -I. rtrmgr/glob_win32.c >> flex -Ptplt -t rtrmgr/template.ll> obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.cc >> bison -d -ptplt -o obj/i686-pc-linux-gnu/rtrmgr/y.tplt_tab.cc rtrmgr/template.yy >> g++ -o obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align -Woverloaded-virtual >> -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i686-pc-linux-gnu -I. -Iobj/i686-pc-linux-gnu/rtrmgr -Irtrmgr -I. >> obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.cc >> cc1plus: warnings being treated as errors >> : In function ???int yy_get_next_buffer()???: >> :9666: warning: comparison between signed and unsigned integer expressions >> scons: *** [obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.o] Error 1 >> scons: building terminated because of errors. >> program finished with exit code 2 >> elapsedTime=811.975911 >> >> Any ideas on how to fix that? > > I can just disable -Werror on FC8 systems...but there is also this error on FreeBSD: > > http://dmz2.candelatech.com:8010/builders/v-freebsd-32/builds/88/steps/shell_1/logs/stdio > > This looks a bit harder to fix... > > g++ -o obj/i386-unknown-freebsd8.1/rtrmgr/config_operators.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align > -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 -I. > -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. rtrmgr/config_operators.cc > g++ -o obj/i386-unknown-freebsd8.1/rtrmgr/generic_module_manager.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align > -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 -I. > -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. rtrmgr/generic_module_manager.cc > gcc -o obj/i386-unknown-freebsd8.1/rtrmgr/glob_win32.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wcast-qual > -Wmissing-declarations -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wnested-externs -pipe -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 > -I. -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. rtrmgr/glob_win32.c > flex -Ptplt -t rtrmgr/template.ll> obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.cc > yacc -d -ptplt -o obj/i386-unknown-freebsd8.1/rtrmgr/y.tplt_tab.cc rtrmgr/template.yy > g++ -o obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align -Woverloaded-virtual > -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 -I. -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. > obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.cc > rtrmgr/template.ll:14:25: error: y.tplt_tab.hh: No such file or directory > rtrmgr/template.ll: In function 'int tpltlex()': > rtrmgr/template.ll:233: error: 'UPLEVEL' was not declared in this scope > rtrmgr/template.ll:237: error: 'DOWNLEVEL' was not declared in this scope > rtrmgr/template.ll:248: error: 'END' was not declared in this scope > rtrmgr/template.ll:252: error: 'COLON' was not declared in this scope > > > We need to get a fix for this so we can compile on BSD or I'm going to have > to revert the changes... Ok, seems that yacc on BSD generates .h files instead of .hh, so that is likely the issue. I'm not sure about the proper way to go about fixing that. Maybe could get scons to create a soft-link on BSD platforms? Thanks, Ben > > Thanks, > Ben > -- Ben Greear Candela Technologies Inc http://www.candelatech.com From igorm at etf.rs Tue Mar 13 14:18:56 2012 From: igorm at etf.rs (=?ISO-8859-2?Q?Igor_Maravi=E6?=) Date: Tue, 13 Mar 2012 22:18:56 +0100 Subject: [Xorp-hackers] [PATCH 00/10] Automatically generate lex and yacc files In-Reply-To: <4F5FB542.7030501@candelatech.com> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> <4F5F866D.8010806@candelatech.com> <4F5F9E1B.4040104@candelatech.com> <4F5FB542.7030501@candelatech.com> Message-ID: Hi Ben, I saw all the mails just now. :) It's 10 pm here, so I'll going to fix all that tomorrow. There should be a flag in yacc to define header sufix. I used YACCHXXFILESUFFIX='.hh' in scons, but that doesn't seam to do the trick. I'll see what I can do tomorrow. BR Igor 2012/3/13 Ben Greear : > On 03/13/2012 12:20 PM, Ben Greear wrote: >> >> On 03/13/2012 10:39 AM, Ben Greear wrote: >>> >>> On 03/13/2012 03:39 AM, igorm at etf.rs wrote: >>>> >>>> From: Igor Maravic >>>> >>>> Hi, >>>> I removed files in individual patches. >>>> 10th patch is where I introduced auto generation of lex and yacc files >>>> BR >>>> Igor >>> >>> >>> Applied and pushed. ?I see this error on the 32-bit FC8 build-bot >>> machine: >>> >>> gcc -o obj/i686-pc-linux-gnu/rtrmgr/glob_win32.o -c -std=gnu99 -O2 -g3 >>> -Werror -W -Wall -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes >>> -Wcast-qual >>> -Wmissing-declarations -Wpointer-arith -Wcast-align -Wstrict-prototypes >>> -Wnested-externs -pipe -DXRL_PF=120 -DXORP_VERSION=1.8.5 >>> -Iobj/i686-pc-linux-gnu -I. >>> -Iobj/i686-pc-linux-gnu/rtrmgr -Irtrmgr -I. rtrmgr/glob_win32.c >>> flex -Ptplt -t rtrmgr/template.ll> >>> obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.cc >>> bison -d -ptplt -o obj/i686-pc-linux-gnu/rtrmgr/y.tplt_tab.cc >>> rtrmgr/template.yy >>> g++ -o obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.o -c -O2 -g3 -Werror -W >>> -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align >>> -Woverloaded-virtual >>> -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 >>> -DXORP_VERSION=1.8.5 -Iobj/i686-pc-linux-gnu -I. >>> -Iobj/i686-pc-linux-gnu/rtrmgr -Irtrmgr -I. >>> obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.cc >>> cc1plus: warnings being treated as errors >>> : In function ???int yy_get_next_buffer()???: >>> :9666: warning: comparison between signed and unsigned integer >>> expressions >>> scons: *** [obj/i686-pc-linux-gnu/rtrmgr/lex.tplt.o] Error 1 >>> scons: building terminated because of errors. >>> program finished with exit code 2 >>> elapsedTime=811.975911 >>> >>> Any ideas on how to fix that? >> >> >> I can just disable -Werror on FC8 systems...but there is also this error >> on FreeBSD: >> >> >> http://dmz2.candelatech.com:8010/builders/v-freebsd-32/builds/88/steps/shell_1/logs/stdio >> >> This looks a bit harder to fix... >> >> g++ -o obj/i386-unknown-freebsd8.1/rtrmgr/config_operators.o -c -O2 -g3 >> -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align >> -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO >> -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 -I. >> -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. >> rtrmgr/config_operators.cc >> g++ -o obj/i386-unknown-freebsd8.1/rtrmgr/generic_module_manager.o -c -O2 >> -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith >> -Wcast-align >> -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO >> -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 -I. >> -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. >> rtrmgr/generic_module_manager.cc >> gcc -o obj/i386-unknown-freebsd8.1/rtrmgr/glob_win32.o -c -O2 -g3 -Werror >> -W -Wall -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes >> -Wcast-qual >> -Wmissing-declarations -Wpointer-arith -Wcast-align -Wstrict-prototypes >> -Wnested-externs -pipe -DXRL_PF=120 -DXORP_VERSION=1.8.5 >> -Iobj/i386-unknown-freebsd8.1 >> -I. -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. rtrmgr/glob_win32.c >> flex -Ptplt -t rtrmgr/template.ll> >> ?obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.cc >> yacc -d -ptplt -o obj/i386-unknown-freebsd8.1/rtrmgr/y.tplt_tab.cc >> rtrmgr/template.yy >> g++ -o obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.o -c -O2 -g3 -Werror -W >> -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align >> -Woverloaded-virtual >> -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 >> -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 -I. >> -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. >> obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.cc >> rtrmgr/template.ll:14:25: error: y.tplt_tab.hh: No such file or directory >> rtrmgr/template.ll: In function 'int tpltlex()': >> rtrmgr/template.ll:233: error: 'UPLEVEL' was not declared in this scope >> rtrmgr/template.ll:237: error: 'DOWNLEVEL' was not declared in this scope >> rtrmgr/template.ll:248: error: 'END' was not declared in this scope >> rtrmgr/template.ll:252: error: 'COLON' was not declared in this scope >> >> >> We need to get a fix for this so we can compile on BSD or I'm going to >> have >> to revert the changes... > > > Ok, seems that yacc on BSD generates .h files instead of .hh, > so that is likely the issue. ?I'm not sure about the proper > way to go about fixing that. ?Maybe could get scons to create > a soft-link on BSD platforms? > > Thanks, > Ben > >> >> Thanks, >> Ben >> > > > -- > Ben Greear > Candela Technologies Inc ?http://www.candelatech.com > From greearb at candelatech.com Tue Mar 13 14:23:31 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 13 Mar 2012 14:23:31 -0700 Subject: [Xorp-hackers] [PATCH 00/10] Automatically generate lex and yacc files In-Reply-To: References: <1331635183-3800-1-git-send-email-igorm@etf.rs> <4F5F866D.8010806@candelatech.com> <4F5F9E1B.4040104@candelatech.com> <4F5FB542.7030501@candelatech.com> Message-ID: <4F5FBAD3.2000307@candelatech.com> On 03/13/2012 02:18 PM, Igor Maravi? wrote: > Hi Ben, > I saw all the mails just now. :) > It's 10 pm here, so I'll going to fix all that tomorrow. > > There should be a flag in yacc to define header sufix. > I used YACCHXXFILESUFFIX='.hh' in scons, but that doesn't seam to do the trick. > I'll see what I can do tomorrow. Seems you might be able to make Linux (flex/bison) to a .h, but I saw no way to make bsd to a .hh (from reading man pages). Take it easy, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From vvm at tut.by Wed Mar 14 01:13:39 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 14 Mar 2012 11:13:39 +0300 Subject: [Xorp-hackers] Yes: "if [ -d" Re: [PATCH] windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash 1) libstdc++-6.dll 2) change order exit errors 3) update notes mingw32 packages 4) add URLs /w32api/include/routprot.h 51: error: 'IP_LOCAL_BINDING' References: <4F5E4195.5080703@candelatech.com> <24DA3CC239704500B43F218ADB325BEC@local.st.by> <4F5F7629.7080807@candelatech.com> Message-ID: Hi! > I also fixed up your check for file existence. Thanks! > I think it should be -f instead of -d (-d is for directory, right??). Yes . . . Sorry -- "-f" is my "copy-paste" error :-( for history ;-) log only diff-for-diff : == --- ..\2012-03-13 12-31\0001-windows-mingw-cross-compiler-build-xorp_win32.zip-wi.patch Tue Mar 13 12:31:29 2012 +++ 0001-windows-mingw-cross-compiler-build-xorp_win32.zip-wi.patch Wed Mar 14 11:07:51 2012 @@ -93,7 +93,7 @@ cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libgcc_s_sjlj-1.dll /usr/local/xorp/sbin/ || exit 5 cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libgnurx-0.dll /usr/local/xorp/sbin/ || exit 6 +cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libcrypto-10.dll /usr/local/xorp/sbin/ || exit 7 -+if [ -d /usr/i686-pc-mingw32/sys-root/mingw/bin/libstdc++-6.dll ] ; then ++if [ -f /usr/i686-pc-mingw32/sys-root/mingw/bin/libstdc++-6.dll ] ; then + ( + cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libstdc++-6.dll /usr/local/xorp/sbin/ || exit 8 + ) == > Please test that it works for you in a clean build. Ok Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ P.S. > Thanks, No problem :-) > The change has been committed. Thanks! >> windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash >Please make the patch title shorter in the future. Ok ----- Original Message ----- From: "Ben Greear" To: "Victor Miasnikov" Cc: xorp-hackers Sent: Tuesday, March 13, 2012 7:30 PM Subject: Re: [PATCH] windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash 1) libstdc++-6.dll 2) change order exit errors 3) update notes mingw32 packages 4) add URLs /w32api/include/routprot.h 51: error: 'IP_LOCAL_BINDING' On 03/13/2012 03:20 AM, Victor Miasnikov wrote: > From: Victor Miasnikov > > windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash Please make the patch title shorter in the future. I also fixed up your check for file existence. I think it should be -f instead of -d (-d is for directory, right??). The change has been committed. Please test that it works for you in a clean build. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com -- From vvm at tut.by Wed Mar 14 01:20:06 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 14 Mar 2012 11:20:06 +0300 Subject: [Xorp-hackers] Yes: "if [ -f" Re: [PATCH] windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash 1) libstdc++-6.dll 2) change order exit errors 3) update notes mingw32 packages 4) add URLs /w32api/include/routprot.h 51: error: 'IP_LOCAL_BINDING' Message-ID: <07534580884446E292F255278CE2CC9A@local.st.by> Hi! if [ -f /usr/i686-pc-mingw32/sys-root/mingw/bin/libstdc++-6.dll ] ; then ^^^ Yes: "if [ -f" Sorry again, need read: == -- "-d" is my "copy-paste" error :-( == Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ From igorm at etf.rs Wed Mar 14 03:01:39 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Wed, 14 Mar 2012 11:01:39 +0100 Subject: [Xorp-hackers] [PATCH] Fix compiling of lex and yacc on BSD OSs In-Reply-To: References: Message-ID: <1331719300-9653-1-git-send-email-igorm@etf.rs> From: Igor Maravic Hi Ben, I included check which OS are we using. Depending on that, we include appropriate files. I assumed that bison on NetBSD have similar behavior as on FreeBSD. Other OSs can be included easily. Hope it works. It works on my Ubuntu 11.10 :) BR Igor PS Should I fix indentation on other patches or not? Any how, I'm going to separate code changes from ws fixes. I'll only going to send ws fixes, for now. Igor Maravic (1): xorp: rtrmgr: Fix compiling of lex and yacc on BSD OSs xorp/SConstruct | 3 +++ xorp/rtrmgr/SConscript | 9 +++++++-- xorp/rtrmgr/boot.ll | 5 +++++ xorp/rtrmgr/op_commands.ll | 5 +++++ xorp/rtrmgr/template.ll | 5 +++++ 5 files changed, 25 insertions(+), 2 deletions(-) -- 1.7.5.4 From igorm at etf.rs Wed Mar 14 03:01:40 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Wed, 14 Mar 2012 11:01:40 +0100 Subject: [Xorp-hackers] [PATCH] xorp: rtrmgr: Fix compiling of lex and yacc on BSD OSs In-Reply-To: <1331719300-9653-1-git-send-email-igorm@etf.rs> References: <1331719300-9653-1-git-send-email-igorm@etf.rs> Message-ID: <1331719300-9653-2-git-send-email-igorm@etf.rs> From: Igor Maravic On BSD bison generates header files with .h suffix. On other OSs it generates header files with .hh suffix. Check which OS we use and include appropriate files. Signed-off-by: Igor Maravic --- xorp/SConstruct | 3 +++ xorp/rtrmgr/SConscript | 9 +++++++-- xorp/rtrmgr/boot.ll | 5 +++++ xorp/rtrmgr/op_commands.ll | 5 +++++ xorp/rtrmgr/template.ll | 5 +++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/xorp/SConstruct b/xorp/SConstruct index b60ab6a..7e6c7fd 100644 --- a/xorp/SConstruct +++ b/xorp/SConstruct @@ -632,6 +632,9 @@ if not env.GetOption('clean') and \ osname = sys.platform.upper() conf.Define('HOST_OS_NAME', '"' + osname + '"') + #export osname - needed for lex and yacc + env['osname'] = osname + # toolchain conf.Define('CPP_SUPPORTS_C99_VA_ARGS') conf.Define('CPP_SUPPORTS_GNU_VA_ARGS') diff --git a/xorp/rtrmgr/SConscript b/xorp/rtrmgr/SConscript index ebe930c..7dccf32 100644 --- a/xorp/rtrmgr/SConscript +++ b/xorp/rtrmgr/SConscript @@ -55,9 +55,14 @@ libxorp_rtrmgr_env = env.Clone() #Create yacc files yacc_env = env.Clone() -yacc_env.Replace(YACCHXXFILESUFFIX='.hh') -yacc_env.AppendUnique(YACCFLAGS='-d') +# bison on BSD generates headers files with .h suffix, +# while on other OSs it generates header files with .hh suffix +if (env['osname'] == "FreeBSD" or env['osname'] == "NetBSD"): + yacc_env.Replace(YACCHXXFILESUFFIX='.h') +else: + yacc_env.Replace(YACCHXXFILESUFFIX='.hh') +yacc_env.AppendUnique(YACCFLAGS='-d') tplt_env_y = yacc_env.Clone() tplt_env_y.AppendUnique(YACCFLAGS='-ptplt') diff --git a/xorp/rtrmgr/boot.ll b/xorp/rtrmgr/boot.ll index 3e639ef..d2a4064 100644 --- a/xorp/rtrmgr/boot.ll +++ b/xorp/rtrmgr/boot.ll @@ -12,7 +12,12 @@ #define YYSTYPE char* #include "libxorp/xorp.h" + +#if defined(HOST_OS_FREEBSD) || defined(HOST_OS_NETBSD) +#include "y.boot_tab.h" +#else #include "y.boot_tab.hh" +#endif #ifdef __xorp_unused #define __unused __xorp_unused diff --git a/xorp/rtrmgr/op_commands.ll b/xorp/rtrmgr/op_commands.ll index 765cf6c..65b917a 100644 --- a/xorp/rtrmgr/op_commands.ll +++ b/xorp/rtrmgr/op_commands.ll @@ -12,7 +12,12 @@ #define YYSTYPE char* #include "libxorp/xorp.h" #include + +#if defined(HOST_OS_FREEBSD) || defined(HOST_OS_NETBSD) +#include "y.opcmd_tab.h" +#else #include "y.opcmd_tab.hh" +#endif #ifdef __xorp_unused #define __unused __xorp_unused diff --git a/xorp/rtrmgr/template.ll b/xorp/rtrmgr/template.ll index fbe3ad7..bf9ca48 100644 --- a/xorp/rtrmgr/template.ll +++ b/xorp/rtrmgr/template.ll @@ -11,7 +11,12 @@ #define YYSTYPE char* #include "libxorp/xorp.h" + +#if defined(HOST_OS_FREEBSD) || defined(HOST_OS_NETBSD) +#include "y.tplt_tab.h" +#else #include "y.tplt_tab.hh" +#endif #ifdef __xorp_unused #define __unused __xorp_unused -- 1.7.5.4 From igorm at etf.rs Wed Mar 14 03:13:12 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Wed, 14 Mar 2012 11:13:12 +0100 Subject: [Xorp-hackers] [PATCH] trivial: ws fixes In-Reply-To: References: Message-ID: <1331719992-10433-1-git-send-email-igorm@etf.rs> From: Igor Maravic Automaticaly fixed trailing ws with Eclipse --- xorp/libxorp/range.hh | 8 ++-- xorp/rtrmgr/conf_tree.cc | 14 ++++---- xorp/rtrmgr/template_tree.cc | 16 +++++----- xorp/rtrmgr/template_tree_node.cc | 10 +++--- xorp/rtrmgr/template_tree_node.hh | 62 ++++++++++++++++++------------------ 5 files changed, 55 insertions(+), 55 deletions(-) diff --git a/xorp/libxorp/range.hh b/xorp/libxorp/range.hh index 538610f..a059788 100644 --- a/xorp/libxorp/range.hh +++ b/xorp/libxorp/range.hh @@ -9,13 +9,13 @@ // Redistribution and/or modification of this program under the terms of // any other version of the GNU Lesser General Public License is not // permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU Lesser General Public License, Version 2.1, a copy of // which can be found in the XORP LICENSE.lgpl file. -// +// // XORP, Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -76,7 +76,7 @@ public: /** * Default constructor */ - U32Range() { Range::_low = + U32Range() { Range::_low = Range::_high = 0; } /** @@ -207,7 +207,7 @@ public: Range::_low = Range::_high = T(from_cstr); else if (delim > 0 && (from_string.length() - delim > 2)) { Range::_low = T(from_string.substr(0, delim).c_str()); - Range::_high = T(from_string.substr(delim + 2, + Range::_high = T(from_string.substr(delim + 2, from_string.length()) .c_str()); } else { diff --git a/xorp/rtrmgr/conf_tree.cc b/xorp/rtrmgr/conf_tree.cc index f52ace5..3889ecf 100644 --- a/xorp/rtrmgr/conf_tree.cc +++ b/xorp/rtrmgr/conf_tree.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -112,7 +112,7 @@ ConfigTree::path_as_segments() const ConfigTreeNode* ctn = _current_node; while (ctn->parent() != NULL) { - path_segments.push_front(ConfPathSegment(ctn->segname(), + path_segments.push_front(ConfPathSegment(ctn->segname(), ctn->type(), ctn->node_id())); ctn = ctn->parent(); } @@ -271,7 +271,7 @@ ConfigTree::add_node(const string& segment, int type, void -ConfigTree::terminal_value(const string& value, int type, ConfigOperator op) +ConfigTree::terminal_value(const string& value, int type, ConfigOperator op) throw (ParseError) { string error_msg; @@ -440,7 +440,7 @@ ConfigTree::find_config_node(const list& path_segments) const string -ConfigTree::show_subtree(bool show_top, const list& path_segments, +ConfigTree::show_subtree(bool show_top, const list& path_segments, bool numbered, bool suppress_default_values) const { const ConfigTreeNode *found = find_config_node(path_segments); @@ -464,7 +464,7 @@ ConfigTree::show_tree(bool numbered) const return const_root_node().show_subtree(/* show_top */ false, /* depth */ 0, /* indent */ 0, - /* do_indent */ true, + /* do_indent */ true, numbered, /* annotate */ true, /* suppress_default_values */ false); @@ -476,7 +476,7 @@ ConfigTree::show_unannotated_tree(bool numbered) const return const_root_node().show_subtree(/* show_top */ false, /* depth */ 0, /* indent */ 0, - /* do_indent */ true, + /* do_indent */ true, numbered, /* annotate */ false, /* suppress_default_values */ false); diff --git a/xorp/rtrmgr/template_tree.cc b/xorp/rtrmgr/template_tree.cc index e228bb5..a4d3e98 100644 --- a/xorp/rtrmgr/template_tree.cc +++ b/xorp/rtrmgr/template_tree.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -64,7 +64,7 @@ TemplateTree::~TemplateTree() delete _root_node; } -bool +bool TemplateTree::load_template_tree(const string& config_template_dir, string& error_msg) { @@ -123,9 +123,9 @@ TemplateTree::load_template_tree(const string& config_template_dir, return true; } -bool +bool TemplateTree::parse_file(const string& filename, - const string& config_template_dir, string& error_msg) + const string& config_template_dir, string& error_msg) { if (init_template_parser(filename.c_str(), this) < 0) { complete_template_parser(); @@ -142,7 +142,7 @@ TemplateTree::parse_file(const string& filename, } if (_path_segments.size() != 0) { complete_template_parser(); - error_msg = c_format("File %s is not terminated properly", + error_msg = c_format("File %s is not terminated properly", filename.c_str()); return false; } @@ -443,7 +443,7 @@ TemplateTree::find_node(const list& path_segments) const } const TemplateTreeNode* -TemplateTree::find_node_by_type(const list& path_segments) +TemplateTree::find_node_by_type(const list& path_segments) const { TemplateTreeNode* ttn = _root_node; @@ -490,7 +490,7 @@ TemplateTree::find_node_by_type(const list& path_segments) // XXX: the type check failed. // If there is a matching template node type of type NODE_TEXT, // then we accept this node. - // + // // The upside of this is that we can use a single template // node like "foo @: txt" that can be used with, say, // IPv4 or IPv6 addresses, a host name, or any other text string. diff --git a/xorp/rtrmgr/template_tree_node.cc b/xorp/rtrmgr/template_tree_node.cc index b4d7d50..b89e5ec 100644 --- a/xorp/rtrmgr/template_tree_node.cc +++ b/xorp/rtrmgr/template_tree_node.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -946,7 +946,7 @@ TemplateTreeNode::find_child_varname_node(const list& var_parts) // The name might refer to this node if (var_parts.size() == 1) { - if ((var_parts.front() == "@") + if ((var_parts.front() == "@") || (var_parts.front() == _segname) || (var_parts.front() == "<>") || (var_parts.front() == "#")) { @@ -1586,7 +1586,7 @@ IntTemplate::type_match(const string& orig, string& error_msg) const error_msg = "value must be an integer"; } else { error_msg = "value must be numeric"; - } + } return false; } return true; @@ -1613,7 +1613,7 @@ BoolTemplate::BoolTemplate(TemplateTree& template_tree, if (initializer.empty()) return; - + if (! type_match(initializer, error_msg)) { error_msg = c_format("Bad Bool type value \"%s\": %s.", initializer.c_str(), error_msg.c_str()); diff --git a/xorp/rtrmgr/template_tree_node.hh b/xorp/rtrmgr/template_tree_node.hh index 88e257e..427dee6 100644 --- a/xorp/rtrmgr/template_tree_node.hh +++ b/xorp/rtrmgr/template_tree_node.hh @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -73,7 +73,7 @@ class TemplateTree; class TemplateTreeNode { public: - TemplateTreeNode(TemplateTree& template_tree, TemplateTreeNode* parent, + TemplateTreeNode(TemplateTree& template_tree, TemplateTreeNode* parent, const string& path, const string& varname); virtual ~TemplateTreeNode(); @@ -115,7 +115,7 @@ public: #if 0 bool check_template_tree(string& error_msg) const; #endif - bool check_command_tree(const list& commands, + bool check_command_tree(const list& commands, bool include_intermediate_nodes, bool include_read_only_nodes, bool include_permanent_nodes, @@ -238,8 +238,8 @@ private: class UIntTemplate : public TemplateTreeNode { public: - UIntTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + UIntTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); string typestr() const { return string("uint"); } @@ -254,8 +254,8 @@ private: class UIntRangeTemplate : public TemplateTreeNode { public: - UIntRangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + UIntRangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~UIntRangeTemplate(); @@ -271,8 +271,8 @@ private: class IntTemplate : public TemplateTreeNode { public: - IntTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + IntTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); string typestr() const { return string("int"); } TTNodeType type() const { return NODE_INT; } @@ -286,8 +286,8 @@ private: class ArithTemplate : public TemplateTreeNode { public: - ArithTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + ArithTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); string typestr() const { return string("uint"); } TTNodeType type() const { return NODE_ARITH; } @@ -301,8 +301,8 @@ private: class TextTemplate : public TemplateTreeNode { public: - TextTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + TextTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); string typestr() const { return string("text"); } @@ -317,8 +317,8 @@ private: class BoolTemplate : public TemplateTreeNode { public: - BoolTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + BoolTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); string typestr() const { return string("bool"); } @@ -333,7 +333,7 @@ private: class IPv4Template : public TemplateTreeNode { public: - IPv4Template(TemplateTree& template_tree, TemplateTreeNode* parent, + IPv4Template(TemplateTree& template_tree, TemplateTreeNode* parent, const string& path, const string& varname, const string& initializer) throw (ParseError); ~IPv4Template(); @@ -350,8 +350,8 @@ private: class IPv4NetTemplate : public TemplateTreeNode { public: - IPv4NetTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + IPv4NetTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~IPv4NetTemplate(); @@ -367,8 +367,8 @@ private: class IPv4RangeTemplate : public TemplateTreeNode { public: - IPv4RangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + IPv4RangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~IPv4RangeTemplate(); @@ -385,7 +385,7 @@ private: class IPv6Template : public TemplateTreeNode { public: IPv6Template(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~IPv6Template(); @@ -401,8 +401,8 @@ private: class IPv6NetTemplate : public TemplateTreeNode { public: - IPv6NetTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + IPv6NetTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~IPv6NetTemplate(); @@ -419,7 +419,7 @@ private: class IPv6RangeTemplate : public TemplateTreeNode { public: IPv6RangeTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~IPv6RangeTemplate(); @@ -435,8 +435,8 @@ private: class MacaddrTemplate : public TemplateTreeNode { public: - MacaddrTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, - const string& path, const string& varname, + MacaddrTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + const string& path, const string& varname, const string& initializer) throw (ParseError); ~MacaddrTemplate(); @@ -452,7 +452,7 @@ private: class UrlFileTemplate : public TemplateTreeNode { public: - UrlFileTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + UrlFileTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, const string& path, const string& varname, const string& initializer) throw (ParseError); @@ -468,7 +468,7 @@ private: class UrlFtpTemplate : public TemplateTreeNode { public: - UrlFtpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + UrlFtpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, const string& path, const string& varname, const string& initializer) throw (ParseError); @@ -484,7 +484,7 @@ private: class UrlHttpTemplate : public TemplateTreeNode { public: - UrlHttpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + UrlHttpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, const string& path, const string& varname, const string& initializer) throw (ParseError); @@ -500,7 +500,7 @@ private: class UrlTftpTemplate : public TemplateTreeNode { public: - UrlTftpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, + UrlTftpTemplate(TemplateTree& template_tree, TemplateTreeNode* parent, const string& path, const string& varname, const string& initializer) throw (ParseError); -- 1.7.5.4 From igorm at etf.rs Wed Mar 14 03:42:43 2012 From: igorm at etf.rs (=?ISO-8859-2?Q?Igor_Maravi=E6?=) Date: Wed, 14 Mar 2012 11:42:43 +0100 Subject: [Xorp-hackers] [PATCH 00/10] Automatically generate lex and yacc files In-Reply-To: <4F5FBAD3.2000307@candelatech.com> References: <1331635183-3800-1-git-send-email-igorm@etf.rs> <4F5F866D.8010806@candelatech.com> <4F5F9E1B.4040104@candelatech.com> <4F5FB542.7030501@candelatech.com> <4F5FBAD3.2000307@candelatech.com> Message-ID: In Xorp, indentation with tabs and spaces is meshed up. On some places indent is set with both tabs and spaces. BR Igor 2012/3/13 Ben Greear : > On 03/13/2012 02:18 PM, Igor Maravi? wrote: >> >> Hi Ben, >> I saw all the mails just now. :) >> It's 10 pm here, so I'll going to fix all that tomorrow. >> >> There should be a flag in yacc to define header sufix. >> I used YACCHXXFILESUFFIX='.hh' in scons, but that doesn't seam to do the >> trick. >> I'll see what I can do tomorrow. > > > Seems you might be able to make Linux (flex/bison) to a .h, but I saw no way > to make > bsd to a .hh (from reading man pages). > > Take it easy, > > Ben > > -- > Ben Greear > Candela Technologies Inc ?http://www.candelatech.com > From vvm at tut.by Wed Mar 14 04:33:11 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 14 Mar 2012 14:33:11 +0300 Subject: [Xorp-hackers] Tested, work Re: [PATCH] windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash References: <4F5E4195.5080703@candelatech.com> <24DA3CC239704500B43F218ADB325BEC@local.st.by> <4F5F7629.7080807@candelatech.com> Message-ID: <2DA952AAB8B64B099CEB524DE950C1EF@local.st.by> Hi! >> windows: mingw cross compiler : build xorp_win32.zip : win32_pkg.bash i.e. == . . . if [ -f /usr/i686-pc-mingw32/sys-root/mingw/bin/libstdc++-6.dll ] then cp /usr/i686-pc-mingw32/sys-root/mingw/bin/libstdc++-6.dll /usr/local/xorp/sbin/ || exit 8 fi . . . == > The change has been committed. Please test that it works for you in a clean build. Tested, work i.e. xorp_win32.zip contain libstdc++-6.dll , *.exe start on Win 2003 with config.boot == /*XORP Configuration File, v1.0*/ fea { unicast-forwarding4 { disable: false forwarding-entries { retain-on-startup: true retain-on-shutdown: true } } } interfaces { restore-original-config-on-shutdown: true /* VVM: dc0 is renamed "Local Area Connection" dc0/dc0: Flags: mtu 1500 speed unknown inet 10.99.95.119 subnet 10.99.95.0/24 broadcast 10.99.95.255 physical index 65539 ether 0:3:ff:19:98:96 */ interface dc0 { description: "dc0 LanCard" disable: false discard: false default-system-config /* unreachable: false management: false vif dc0 { disable: false address 10.99.95.119 { prefix-length: 24 disable: false } } */ } /* MS TCP Loopback interface/MS TCP Loopback interface: Flags: mtu 1520 speed unknown inet 127.0.0.1 subnet 127.0.0.1/32 physical index 1 */ interface "MS TCP Loopback interface" { disable: false discard: false description: "MS TCP Loopback interface -- Win 2003" default-system-config } } protocols { fib2mrib { disable: true } static { disable: false route 10.91.93.0/24 { next-hop: 10.99.95.1 metric: 20 } route 10.91.92.0/24 { next-hop: 10.99.95.1 metric: 20 } route 10.91.98.0/24 { next-hop: 10.99.95.1 metric: 20 } route 0.0.0.0/0 { next-hop: 10.99.95.1 metric: 20 } } } == static route ok ( show by "route show" in cmd.exe) Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ From vvm at tut.by Wed Mar 14 06:58:56 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 14 Mar 2012 16:58:56 +0300 Subject: [Xorp-hackers] xorprtm4.dll / xorprtm6.dll Fw: RTMv2 Or XORP and RRAS ( Routing and Remote Access Services) Fw: XORP on Windows References: <7DD51393B44C46F9B9B384531EA1D897@local.st.by> <4F5F7436.9060308@candelatech.com> Message-ID: <818574CFCB8F424B8C2282A3B98510B8@local.st.by> Hi! > The sourceforge repository is just for historical purposes. I'm known, but it contain latest public release of xorprtm > If you want me to add patches, they need to be against the github repository. Ok See e-mail with Subj == [PATCH] xorp/contrib/win32/xorprtm SVN Rev 11384 == Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ P.S. > If you want me to add patches, they need to be against the github repository. GIT not transfer date+time atribute of files . . . How about: == right date+time of files in future xorp-1.8.6-src.tar.bz2 == ----- Original Message ----- From: "Ben Greear" To: "Victor Miasnikov" Cc: xorp-hackers at icir.org Sent: Tuesday, March 13, 2012 7:22 PM Subject: Re: [Xorp-hackers] xorprtm4.dll / xorprtm6.dll Fw: RTMv2 Or XORP and RRAS ( Routing and Remote Access Services) Fw: XORP on Windows On 03/13/2012 07:51 AM, Victor Miasnikov wrote: > ----- Original Message ----- > From: "Victor Miasnikov" > To: "Ben Greear" > Sent: Tuesday, March 13, 2012 5:46 PM > Subject: Fw: xorprtm4.dll / xorprtm6.dll Fw: RTMv2 Or XORP and RRAS ( Routing and Remote Access Services) Fw: XORP on > Windows > > Hi! > > Please, unpack to You build folder ( for save right date+time of files in future xorp-1.8.6-src.tar.bz2 ) and upload to > GIT -- I'm have patches [as minimum] to xorprtm The sourceforge repository is just for historical purposes. If you want me to add patches, they need to be against the github repository. If you want to add files to the git repository, copy them into your xorp git tree and run 'git add [files]' Then: get commit -a And then, generate a patch with 'git format-patch' and send it with 'git send-email'. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120314/122ca3f8/attachment.html From vvm at tut.by Wed Mar 14 07:10:06 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 14 Mar 2012 17:10:06 +0300 Subject: [Xorp-hackers] [PATCH] xorp/contrib/win32/xorprtm SVN Rev 11384 Message-ID: From: Victor Miasnikov xorp/contrib/win32/xorprtm SVN Rev 11384 Signed-off-by: Victor Miasnikov --- xorp/contrib/xorprtm/BUGS | 80 + xorp/contrib/xorprtm/BUILD_NOTES | 2 + xorp/contrib/xorprtm/README | 12 + xorp/contrib/xorprtm/TODO | 22 + xorp/contrib/xorprtm/xorprtm/bsdroute.h | 285 +++ xorp/contrib/xorprtm/xorprtm/defs.h | 93 + xorp/contrib/xorprtm/xorprtm/list.h | 175 ++ xorp/contrib/xorprtm/xorprtm/loadprotocol.c | 365 ++++ xorp/contrib/xorprtm/xorprtm/mibmgr.c | 124 ++ xorp/contrib/xorprtm/xorprtm/mibmgr.h | 50 + xorp/contrib/xorprtm/xorprtm/pchsample.h | 64 + xorp/contrib/xorprtm/xorprtm/print_rtmsg.c | 737 ++++++++ xorp/contrib/xorprtm/xorprtm/rmapi.c | 752 ++++++++ xorp/contrib/xorprtm/xorprtm/rmapi.h | 35 + xorp/contrib/xorprtm/xorprtm/sync.c | 101 + xorp/contrib/xorprtm/xorprtm/sync.h | 145 ++ xorp/contrib/xorprtm/xorprtm/test_monitor.c | 98 + xorp/contrib/xorprtm/xorprtm/test_routeadd.c | 126 ++ xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c | 199 ++ xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c | 138 ++ xorp/contrib/xorprtm/xorprtm/utils.c | 93 + xorp/contrib/xorprtm/xorprtm/utils.h | 41 + xorp/contrib/xorprtm/xorprtm/xorprtm.c | 1905 ++++++++++++++++++++ xorp/contrib/xorprtm/xorprtm/xorprtm.h | 32 + xorp/contrib/xorprtm/xorprtm/xorprtm_internal.h | 175 ++ xorp/contrib/xorprtm/xorprtm4/xorprtm4.def | 4 + xorp/contrib/xorprtm/xorprtm6/xorprtm6.def | 4 + 27 files changed, 5857 insertions(+), 0 deletions(-) create mode 100644 xorp/contrib/xorprtm/BUGS create mode 100644 xorp/contrib/xorprtm/BUILD_NOTES create mode 100644 xorp/contrib/xorprtm/README create mode 100644 xorp/contrib/xorprtm/TODO create mode 100644 xorp/contrib/xorprtm/xorprtm/bsdroute.h create mode 100644 xorp/contrib/xorprtm/xorprtm/defs.h create mode 100644 xorp/contrib/xorprtm/xorprtm/list.h create mode 100644 xorp/contrib/xorprtm/xorprtm/loadprotocol.c create mode 100644 xorp/contrib/xorprtm/xorprtm/mibmgr.c create mode 100644 xorp/contrib/xorprtm/xorprtm/mibmgr.h create mode 100644 xorp/contrib/xorprtm/xorprtm/pchsample.h create mode 100644 xorp/contrib/xorprtm/xorprtm/print_rtmsg.c create mode 100644 xorp/contrib/xorprtm/xorprtm/rmapi.c create mode 100644 xorp/contrib/xorprtm/xorprtm/rmapi.h create mode 100644 xorp/contrib/xorprtm/xorprtm/sync.c create mode 100644 xorp/contrib/xorprtm/xorprtm/sync.h create mode 100644 xorp/contrib/xorprtm/xorprtm/test_monitor.c create mode 100644 xorp/contrib/xorprtm/xorprtm/test_routeadd.c create mode 100644 xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c create mode 100644 xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c create mode 100644 xorp/contrib/xorprtm/xorprtm/utils.c create mode 100644 xorp/contrib/xorprtm/xorprtm/utils.h create mode 100644 xorp/contrib/xorprtm/xorprtm/xorprtm.c create mode 100644 xorp/contrib/xorprtm/xorprtm/xorprtm.h create mode 100644 xorp/contrib/xorprtm/xorprtm/xorprtm_internal.h create mode 100644 xorp/contrib/xorprtm/xorprtm4/xorprtm4.def create mode 100644 xorp/contrib/xorprtm/xorprtm6/xorprtm6.def diff --git a/xorp/contrib/xorprtm/BUGS b/xorp/contrib/xorprtm/BUGS new file mode 100644 index 0000000..9bb3157 --- /dev/null +++ b/xorp/contrib/xorprtm/BUGS @@ -0,0 +1,80 @@ +Known issues: + + - Routes appear in the RTM routing table but do not propagate to + the FIB. + This can be verified by comparing the output of 'route print' + with that of 'netsh routing ip show rtmroutes'. + + * Feedback from Microsoft is needed to fix this issue. + + - We use WriteFile() to broadcast data to multiple clients. + If one of the clients does not read the data, then the server thread + will hang as a result. + The alternative is to use overlapped I/O, but this means + recording lots of state for each write. + + * Therefore, clients MUST read from the pipe after issuing commands. + This should not affect XORP, as we do not rely on the SO_USELOOPBACK + socket option when dealing with routing sockets, and the socket is + polled for input as part of the FEA's event loop. + + - The use of the BSD routing socket message format is not completely + identical. + + * We only accept a DST, GATEWAY and NETMASK for RTM_ADD. + * We only accept a DST and a NETMASK for RTM_DELETE. + * Any other combinations are not acceptable. + + * RTM_IFANNOUNCE messages DO NOT contain the interface name for deletions. + Microsoft's Router Manager does not provide this, only the index. + + * The InterfaceStatus() callback does not get called when link sense + changes on the media, therefore, RTM_IFINFO messages are not sent + when carrier is dropped or regained. + + * RTM_NEWADDR messages are sent whenever the interface address list + changes. This is incomplete and the semantics are not the same as + that of the BSD routing socket; it would be necessary to record all + the state to just send the deltas, as InterfaceStatus() has the + entire address list for each interface passed to it on a change. + + - The regression tests read the first 'reply' which is actually + the echo of the command they sent. The next 'reply' is the kernel's. + + * PF_ROUTE is a broadcast domain in BSD, with specific semantics. + The DLL does not always broadcast the client's inbound command message first. + It should do so, and do it separately, following by broadcasting + the and separately; followed by the kernel's reply. This maintains POLA. + + On BSD, the option SO_USELOOPBACK can be used to squelch the inbound + command message from being echoed to the process which is sending it, + thus maintaining the assumption of 'write once, read twice'. + + Given that the DLL can block if client's don't read, this is particularly + important! + + - Routing and Remote Access will signal that all interfaces are going + away when it shuts down. Client processes will see these notifications. + + - Currently we squelch notifications about all-1s broadcast and multicast + destinations. This is because they show up as equal-cost multihop + rules in the table, although this doesn't tell the whole story. + + * Separate DLLs for IPv4 and IPv6 shim support are needed because of + how DLLs are loaded. The image is loaded once into the MS Router Manager. + There is no copy-on-write for data sections because everything runs in + a single NT process. A common global instance variable is needed. We + can't use thread-local storage because we may be reentered by multiple + pool threads, and we can't tell them apart usefully at initialization. + + * XXX: The following identifiers seem to be missing from the Windows SDK + build 5284 headers: + IPV6_ADDRESS_LEN_IN_BYTES + ConvertAddressAndLengthToNetAddress() + ConvertNetAddressToAddressAndLength() + referenced by: + RTM_IPV6_SET_ADDR_AND_LEN() + RTM_IPV6_GET_ADDR_AND_LEN() + There also seems to be no RTM_IPV6_MASK_FROM_LEN() function, which + we'd need for converting our IPv6 prefix lengths to socket address + structures for the modified BSD message format we currently use. diff --git a/xorp/contrib/xorprtm/BUILD_NOTES b/xorp/contrib/xorprtm/BUILD_NOTES new file mode 100644 index 0000000..093d222 --- /dev/null +++ b/xorp/contrib/xorprtm/BUILD_NOTES @@ -0,0 +1,2 @@ +Building this code requires the use of FreeType Jam 2.5.2, the +Microsoft Visual C++ Toolkit 2003, and the latest Windows SDK. diff --git a/xorp/contrib/xorprtm/README b/xorp/contrib/xorprtm/README new file mode 100644 index 0000000..4aafae8 --- /dev/null +++ b/xorp/contrib/xorprtm/README @@ -0,0 +1,12 @@ +# +# $XORP$ +# + +This is XORPRTM; a loadable protocol DLL for Microsoft's Routing and +Remote Access Service. XORPRTM implements a named pipe server with +asynchronous I/O which translates Router Manager V2 events into +BSD routing socket messages, and vice versa. + +Using this mechanism, XORP is able to participate fully in the exchange +of routes as part of Microsoft's Routing and Remote Access Server on +Windows Server 2003 and Windows 'Longhorn' Server. diff --git a/xorp/contrib/xorprtm/TODO b/xorp/contrib/xorprtm/TODO new file mode 100644 index 0000000..ef19da1 --- /dev/null +++ b/xorp/contrib/xorprtm/TODO @@ -0,0 +1,22 @@ +# +# $XORP$ +# + +Clean up the code. + Push header inclusion down to individual files. + Sort the functions in xorprtm.c somewhat. + Do a final pass to clean up function names and style. + Do a final indent pass. + +Write a GNU makefile for this code. +Check it into the main repository. + +Make 'restart rras' a command line option for loadprotocol. +Make 'unload protocol' a command line option for loadprotocol. + +Tasks depending on Microsoft feedback: + Fix route adds so they are pushed to the FIB. + Blocked awaiting feedback. + Refine and test IPv6 support. + Blocked on missing defines in SDK. + Blocked awaiting feedback. diff --git a/xorp/contrib/xorprtm/xorprtm/bsdroute.h b/xorp/contrib/xorprtm/xorprtm/bsdroute.h new file mode 100644 index 0000000..87e6972 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/bsdroute.h @@ -0,0 +1,285 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +/* + * $XORP: xorp/contrib/win32/xorprtm/bsdroute.h,v 1.7 2008/10/02 21:56:40 bms Exp $ + */ + +/*- + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)route.h 8.4 (Berkeley) 1/9/95 + * $FreeBSD: src/sys/net/route.h,v 1.63.2.1 2006/04/04 20:07:23 andre Exp $ + */ + +#ifndef _BSDROUTE_H_ +#define _BSDROUTE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define XORPRTM4_PIPENAME "\\\\.\\pipe\\XorpRtm4" +#define XORPRTM4_LOGNAME "XORPRTM4" + +#define XORPRTM6_PIPENAME "\\\\.\\pipe\\XorpRtm6" +#define XORPRTM6_LOGNAME "XORPRTM6" + +#ifdef IPV6_DLL +#define XORPRTM_PIPENAME XORPRTM6_PIPENAME +#define XORPRTM_LOGNAME XORPRTM6_LOGNAME +#define XORPRTM_TRACENAME XORPRTM6_LOGNAME +#else +#define XORPRTM_PIPENAME XORPRTM4_PIPENAME +#define XORPRTM_LOGNAME XORPRTM4_LOGNAME +#define XORPRTM_TRACENAME XORPRTM4_LOGNAME +#endif + +/* + * Router Manager V2 IDs for XORP + */ + +#define PROTO_IP_XORPRTM PROTO_IP_HELLO +#define XORPRTM_PROTOCOL_ID \ + PROTOCOL_ID(PROTO_TYPE_UCAST, PROTO_VENDOR_MS0, PROTO_IP_XORPRTM) + +#define XORPRTM_GLOBAL_CONFIG_ID 1 + +/* + * MS Router Manager info structures + */ + +typedef struct _XORPRTM_GLOBAL_CONFIG { + DWORD dummy; +} XORPRTM_GLOBAL_CONFIG, *PXORPRTM_GLOBAL_CONFIG; + +typedef struct _XORPRTM_MIB_SET_INPUT_DATA { + DWORD IMSID_TypeID; + DWORD IMSID_IfIndex; + DWORD IMSID_BufferSize; + BYTE IMSID_Buffer[0]; +} XORPRTM_MIB_SET_INPUT_DATA, *PXORPRTM_MIB_SET_INPUT_DATA; + +typedef struct _XORPRTM_MIB_GET_INPUT_DATA { + DWORD IMGID_TypeID; + DWORD IMGID_IfIndex; +} XORPRTM_MIB_GET_INPUT_DATA, *PXORPRTM_MIB_GET_INPUT_DATA; + +typedef struct _XORPRTM_MIB_GET_OUTPUT_DATA { + DWORD IMGOD_TypeID; + DWORD IMGOD_IfIndex; + BYTE IMGOD_Buffer[0]; +} XORPRTM_MIB_GET_OUTPUT_DATA, *PXORPRTM_MIB_GET_OUTPUT_DATA; + +/* + * BSD routing socket interface + */ + +#define RTF_UP 0x1 /* route usable */ +#define RTF_GATEWAY 0x2 /* destination is a gateway */ +#define RTF_HOST 0x4 /* host entry (net otherwise) */ +#define RTF_REJECT 0x8 /* host or net unreachable */ +#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */ +#define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */ +#define RTF_DONE 0x40 /* message confirmed */ +/* 0x80 unused, was RTF_DELCLONE */ +#define RTF_CLONING 0x100 /* generate new routes on use */ +#define RTF_XRESOLVE 0x200 /* external daemon resolves name */ +#define RTF_LLINFO 0x400 /* generated by link layer (e.g. ARP) */ +#define RTF_STATIC 0x800 /* manually added */ +#define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */ +#define RTF_PROTO2 0x4000 /* protocol specific routing flag */ +#define RTF_PROTO1 0x8000 /* protocol specific routing flag */ + +#define RTF_WASCLONED 0x20000 /* route generated through cloning */ +#define RTF_PROTO3 0x40000 /* protocol specific routing flag */ +/* 0x80000 unused */ +#define RTF_PINNED 0x100000 /* future use */ +#define RTF_LOCAL 0x200000 /* route represents a local address */ +#define RTF_BROADCAST 0x400000 /* route represents a bcast address */ +#define RTF_MULTICAST 0x800000 /* route represents a mcast address */ + /* 0x1000000 and up unassigned */ + +/* Mask of RTF flags that are allowed to be modified by RTM_CHANGE. */ +#define RTF_FMASK \ + (RTF_PROTO1 | RTF_PROTO2 | RTF_PROTO3 | RTF_BLACKHOLE | \ + RTF_REJECT | RTF_STATIC) + +struct rt_metrics { + DWORD rmx_filler[14]; /* Ignore field names but pad in same way */ +}; + +/* + * Structures for routing messages. + */ +struct rt_msghdr { + USHORT rtm_msglen; /* to skip over non-understood messages */ + BYTE rtm_version; /* future binary compatibility */ + BYTE rtm_type; /* message type */ + USHORT rtm_index; /* index for associated ifp */ + DWORD rtm_flags; /* flags, incl. kern & message, e.g. DONE */ + DWORD rtm_addrs; /* bitmask identifying sockaddrs in msg */ + LONG rtm_pid; /* identify sender */ + LONG rtm_seq; /* for sender to identify action */ + DWORD rtm_errno; /* why failed */ + DWORD rtm_fmask; /* bitmask used in RTM_CHANGE message */ +#define rtm_use rtm_fmask /* deprecated, use rtm_rmx->rmx_pksent */ + DWORD rtm_inits; /* which metrics we are initializing */ + struct rt_metrics rtm_rmx; /* metrics themselves */ +}; + +#define RTM_VERSION 66 /* Unique to XORP/Win32 */ + +/* + * Message types. + * Only those supported by the Windows subsystem are provided. + */ +#define RTM_ADD 0x1 /* Add Route */ +#define RTM_DELETE 0x2 /* Delete Route */ +#define RTM_CHANGE 0x3 /* Change Metrics or flags */ +#define RTM_NEWADDR 0xc /* address being added to iface */ +#define RTM_DELADDR 0xd /* address being removed from iface */ +#define RTM_IFINFO 0xe /* iface going up/down etc. */ +#define RTM_IFANNOUNCE 0x11 /* iface arrival/departure */ + +/* + * Bitmask values for rtm_addrs. + */ +#define RTA_DST 0x1 /* destination sockaddr present */ +#define RTA_GATEWAY 0x2 /* gateway sockaddr present */ +#define RTA_NETMASK 0x4 /* netmask sockaddr present */ +#define RTA_GENMASK 0x8 /* cloning mask sockaddr present */ +#define RTA_IFP 0x10 /* interface name sockaddr present */ +#define RTA_IFA 0x20 /* interface addr sockaddr present */ +#define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */ +#define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */ + +/* + * Index offsets for sockaddr array for alternate internal encoding. + */ +#define RTAX_DST 0 /* destination sockaddr present */ +#define RTAX_GATEWAY 1 /* gateway sockaddr present */ +#define RTAX_NETMASK 2 /* netmask sockaddr present */ +#define RTAX_GENMASK 3 /* cloning mask sockaddr present */ +#define RTAX_IFP 4 /* interface name sockaddr present */ +#define RTAX_IFA 5 /* interface addr sockaddr present */ +#define RTAX_AUTHOR 6 /* sockaddr for author of redirect */ +#define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest addr */ +#define RTAX_MAX 8 /* size of array to allocate */ + +/* + * XXX: The Winsock definition of struct sockaddr does not have + * a size value, therefore we use struct sockaddr_storage in its entirety. + */ +#define SA_SIZE(sa) sizeof(struct sockaddr_storage) + +/* + * XXX: The length of IFNAMSIZ must be consistent across the ABI. + * It's different from BSDs to allow for arbitrary FriendlyNames, + * up to a length of 256 bytes. + */ +#ifdef IFNAMSIZ +#undef IFNAMSIZ +#endif +#ifndef IFNAMSIZ +#define IFNAMSIZ 256 +#endif + +#define IFAN_ARRIVAL 0 /* interface arrival */ +#define IFAN_DEPARTURE 1 /* interface departure */ + +struct if_announcemsghdr { + USHORT ifan_msglen; + BYTE ifan_version; + BYTE ifan_type; + DWORD ifan_index; /* XXX: This is now 32-bits wide */ + BYTE ifan_name[IFNAMSIZ]; /* FriendlyName in ANSI text. */ + BYTE ifan_what; +}; + +/* + * Values for if_link_state. + */ +#define LINK_STATE_UNKNOWN 0 /* link invalid/unknown */ +#define LINK_STATE_DOWN 1 /* link is down */ +#define LINK_STATE_UP 2 /* link is up */ + +/* + * XXX: Most of the fields in the original BSD if_data + * structure can't be obtained on Windows from the + * RTMv2 interface status callback, therefore this + * structure is very minimal. + */ +struct if_data { + BYTE ifi_link_state; +}; + +struct if_msghdr { + USHORT ifm_msglen; + BYTE ifm_version; + BYTE ifm_type; + DWORD ifm_addrs; + DWORD ifm_flags; + DWORD ifm_index; + struct if_data ifm_data; +}; + +struct ifa_msghdr { + USHORT ifam_msglen; + BYTE ifam_version; + BYTE ifam_type; + DWORD ifam_addrs; + DWORD ifam_flags; + DWORD ifam_index; + DWORD ifam_metric; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _BSDROUTE_H_ */ diff --git a/xorp/contrib/xorprtm/xorprtm/defs.h b/xorp/contrib/xorprtm/xorprtm/defs.h new file mode 100644 index 0000000..9c44ecf --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/defs.h @@ -0,0 +1,93 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +/* + * $XORP: xorp/contrib/win32/xorprtm/defs.h,v 1.7 2008/10/02 21:56:40 bms Exp $ + */ + +/* + * This file is derived from code which is under the following copyright: + * + * Copyright (c) 1999 - 2000 Microsoft Corporation. + * + */ + +#ifndef _DEFS_H_ +#define _DEFS_H_ + +#define GLOBAL_HEAP g_ce.hGlobalHeap +#define TRACEID g_ce.dwTraceID + +#define ENTER_XORPRTM_API() EnterSubsystemAPI() +#define ENTER_XORPRTM_WORKER() EnterSubsystemWorker() +#define LEAVE_XORPRTM_API() LeaveSubsystemWorker() +#define LEAVE_XORPRTM_WORKER() LeaveSubsystemWorker() + +#define MALLOC(ppPointer, ulSize, pdwErr) \ +{ \ + if (*(ppPointer) = HeapAlloc(GLOBAL_HEAP, HEAP_ZERO_MEMORY, (ulSize))) \ + { \ + *(pdwErr) = NO_ERROR; \ + } \ + else \ + { \ + *(pdwErr) = ERROR_NOT_ENOUGH_MEMORY; \ + TRACE1(ANY, "Error allocating %u bytes", (ulSize)); \ + } \ +} +#define REALLOC(ptr, size) HeapReAlloc(GLOBAL_HEAP, 0, ptr, size) +#define FREE(ptr) \ +{ \ + HeapFree(GLOBAL_HEAP, 0, (ptr)); \ + (ptr) = NULL; \ +} + +#define XORPRTM_TRACE_ANY ((DWORD)0xFFFF0000 | TRACE_USE_MASK) +#define XORPRTM_TRACE_ENTER ((DWORD)0x00010000 | TRACE_USE_MASK) +#define XORPRTM_TRACE_LEAVE ((DWORD)0x00020000 | TRACE_USE_MASK) +#define XORPRTM_TRACE_DEBUG ((DWORD)0x00040000 | TRACE_USE_MASK) +#define XORPRTM_TRACE_CONFIGURATION ((DWORD)0x00100000 | TRACE_USE_MASK) +#define XORPRTM_TRACE_NETWORK ((DWORD)0x00200000 | TRACE_USE_MASK) +#define XORPRTM_TRACE_PACKET ((DWORD)0x00400000 | TRACE_USE_MASK) +#define XORPRTM_TRACE_TIMER ((DWORD)0x00800000 | TRACE_USE_MASK) +#define XORPRTM_TRACE_MIB ((DWORD)0x01000000 | TRACE_USE_MASK) + +#define TRACE0(l,a) \ + if (TRACEID != INVALID_TRACEID) \ + TracePrintfEx(TRACEID, XORPRTM_TRACE_ ## l, a) +#define TRACE1(l,a,b) \ + if (TRACEID != INVALID_TRACEID) \ + TracePrintfEx(TRACEID, XORPRTM_TRACE_ ## l, a, b) +#define TRACE2(l,a,b,c) \ + if (TRACEID != INVALID_TRACEID) \ + TracePrintfEx(TRACEID, XORPRTM_TRACE_ ## l, a, b, c) +#define TRACE3(l,a,b,c,d) \ + if (TRACEID != INVALID_TRACEID) \ + TracePrintfEx(TRACEID, XORPRTM_TRACE_ ## l, a, b, c, d) +#define TRACE4(l,a,b,c,d,e) \ + if (TRACEID != INVALID_TRACEID) \ + TracePrintfEx(TRACEID, XORPRTM_TRACE_ ## l, a, b, c, d, e) +#define TRACE5(l,a,b,c,d,e,f) \ + if (TRACEID != INVALID_TRACEID) \ + TracePrintfEx(TRACEID, XORPRTM_TRACE_ ## l, a, b, c, d, e, f) + +#endif /* _DEFS_H_ */ diff --git a/xorp/contrib/xorprtm/xorprtm/list.h b/xorp/contrib/xorprtm/xorprtm/list.h new file mode 100644 index 0000000..a1da37b --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/list.h @@ -0,0 +1,175 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +/* + * $XORP: xorp/contrib/win32/xorprtm/list.h,v 1.7 2008/10/02 21:56:40 bms Exp $ + */ + +/* + * This file is derived from code which is under the following copyright: + * + * Copyright (c) 1999 - 2000 Microsoft Corporation. + * + */ + +#ifndef _LIST_H_ +#define _LIST_H_ + +#define InitializeListHead(ListHead) \ + ((ListHead)->Flink = (ListHead)->Blink = (ListHead)) + +#define IsListEmpty(ListHead) \ + ((ListHead)->Flink == (ListHead)) + +#define RemoveHeadList(ListHead) \ + (ListHead)->Flink; \ + {RemoveEntryList((ListHead)->Flink)} + +#define RemoveTailList(ListHead) \ + (ListHead)->Blink; \ + {RemoveEntryList((ListHead)->Blink)} + +#define RemoveEntryList(Entry) \ +{ \ + PLIST_ENTRY _EX_Blink; \ + PLIST_ENTRY _EX_Flink; \ + _EX_Flink = (Entry)->Flink; \ + _EX_Blink = (Entry)->Blink; \ + _EX_Blink->Flink = _EX_Flink; \ + _EX_Flink->Blink = _EX_Blink; \ +} + +#define InsertTailList(ListHead,Entry) \ +{ \ + PLIST_ENTRY _EX_Blink; \ + PLIST_ENTRY _EX_ListHead; \ + _EX_ListHead = (ListHead); \ + _EX_Blink = _EX_ListHead->Blink; \ + (Entry)->Flink = _EX_ListHead; \ + (Entry)->Blink = _EX_Blink; \ + _EX_Blink->Flink = (Entry); \ + _EX_ListHead->Blink = (Entry); \ +} + +#define InsertHeadList(ListHead,Entry) \ +{ \ + PLIST_ENTRY _EX_Flink; \ + PLIST_ENTRY _EX_ListHead; \ + _EX_ListHead = (ListHead); \ + _EX_Flink = _EX_ListHead->Flink; \ + (Entry)->Flink = _EX_Flink; \ + (Entry)->Blink = _EX_ListHead; \ + _EX_Flink->Blink = (Entry); \ + _EX_ListHead->Flink = (Entry); \ +} + +#define InsertSortedList(ListHead, Entry, CompareFunction) \ +{ \ + PLIST_ENTRY _EX_Entry; \ + PLIST_ENTRY _EX_Blink; \ + for (_EX_Entry = (ListHead)->Flink; \ + _EX_Entry != (ListHead); \ + _EX_Entry = _EX_Entry->Flink) \ + if ((*(CompareFunction))((Entry), _EX_Entry) <= 0) \ + break; \ + _EX_Blink = _EX_Entry->Blink; \ + _EX_Blink->Flink = (Entry); \ + _EX_Entry->Blink = (Entry); \ + (Entry)->Flink = _EX_Entry; \ + (Entry)->Blink = _EX_Blink; \ +} + +#define FindList(ListHead, Key, Entry, CompareFunction) \ +{ \ + PLIST_ENTRY _EX_Entry; \ + *(Entry) = NULL; \ + for (_EX_Entry = (ListHead)->Flink; \ + _EX_Entry != (ListHead); \ + _EX_Entry = _EX_Entry->Flink) \ + if ((*(CompareFunction))((Key), _EX_Entry) == 0) \ + { \ + *(Entry) = _EX_Entry; \ + break; \ + } \ +} + +#define FindSortedList(ListHead, Key, Entry, CompareFunction) \ +{ \ + PLIST_ENTRY _EX_Entry; \ + *(Entry) = NULL; \ + for (_EX_Entry = (ListHead)->Flink; \ + _EX_Entry != (ListHead); \ + _EX_Entry = _EX_Entry->Flink) \ + if ((*(CompareFunction))((Key), _EX_Entry) <= 0) \ + { \ + *(Entry) = _EX_Entry; \ + break; \ + } \ +} + +#define MapCarList(ListHead, VoidFunction) \ +{ \ + PLIST_ENTRY _EX_Entry; \ + for (_EX_Entry = (ListHead)->Flink; \ + _EX_Entry != (ListHead); \ + _EX_Entry = _EX_Entry->Flink) \ + (*(VoidFunction))(_EX_Entry); \ +} + +#define FreeList(ListHead, FreeFunction) \ +{ \ + PLIST_ENTRY _EX_Head; \ + while (!IsListEmpty(ListHead)) \ + { \ + _EX_Head = RemoveHeadList(ListHead); \ + (*(FreeFunction))(_EX_Head); \ + } \ +} + +#define QUEUE_ENTRY LIST_ENTRY +#define PQUEUE_ENTRY PLIST_ENTRY + +#define InitializeQueueHead(QueueHead) InitializeListHead(QueueHead) +#define IsQueueEmpty(QueueHead) IsListEmpty(QueueHead) +#define Enqueue(QueueHead, Entry) InsertTailList(QueueHead, Entry) +#define Dequeue(QueueHead) RemoveHeadList(QueueHead) +#define FreeQueue(QueueHead, FreeFunction) \ + FreeList(QueueHead, FreeFunction) +#define MapCarQueue(QueueHead, VoidFunction) \ + MapCarList(QueueHead, VoidFunction) + +#define STACK_ENTRY LIST_ENTRY +#define PSTACK_ENTRY PLIST_ENTRY + +#define InitializeStackHead(StackHead) InitializeListHead(StackHead) +#define IsStackEmpty(StackHead) IsListEmpty(StackHead) +#define Push(StackHead, Entry) InsertHeadList(StackHead, Entry) +#define Pop(StackHead) RemoveHeadList(StackHead) +#define FreeStack(StackHead, FreeFunction) \ + FreeList(StackHead, FreeFunction) +#define MapCarStack(StackHead, VoidFunction) \ + MapCarList(StackHead, VoidFunction) + +#endif /* _LIST_H_ */ + + + diff --git a/xorp/contrib/xorprtm/xorprtm/loadprotocol.c b/xorp/contrib/xorprtm/xorprtm/loadprotocol.c new file mode 100644 index 0000000..8c35183 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/loadprotocol.c @@ -0,0 +1,365 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +#ident "$XORP: xorp/contrib/win32/xorprtm/loadprotocol.c,v 1.7 2008/10/02 21:56:40 bms Exp $" + +/* + * This file is derived from code which is under the following copyright: + * + * Copyright (c) 1999 - 2000 Microsoft Corporation. + * + */ + +/* + * Modified version of LoadProtocol for integration into XORP. + * Restarts RRAS service after making registry changes. + * Loads the DLL into RRAS using MPR API calls. + */ + +#define UNICODE +#include +#include +#include +#include +#include +#include + +#include "xorprtm.h" + +HRESULT +add_protocol_to_rras(int family) +{ + static const SHORT XORPRTM_BLOCK_SIZE = 0x0004; + HRESULT hr = S_OK; + DWORD dwErr = ERROR_SUCCESS; + DWORD dwErrT = ERROR_SUCCESS; + MPR_SERVER_HANDLE hMprServer = NULL; + HANDLE hMprConfig = NULL; + LPBYTE pByte = NULL; + LPVOID pHeader = NULL; + LPVOID pNewHeader = NULL; + DWORD dwSize = 0; + HANDLE hTransport = NULL; + LPCWSTR pswzServerName = NULL; + int pid; + XORPRTM_GLOBAL_CONFIG igc; + + memset(&igc, 0, sizeof(igc)); + +#ifdef IPV6_DLL + if (family == AF_INET) { + pid = PID_IP; + } else { + pid = PID_IPV6; + } +#else + pid = PID_IP; +#endif + + /* Connect to the server */ + /* ---------------------------------------------------------------- */ + dwErr = MprAdminServerConnect((LPWSTR) pswzServerName, &hMprServer); + if (dwErr == ERROR_SUCCESS) + { + /* Ok, get the infobase from the server */ + /* ------------------------------------------------------------ */ + dwErr = MprAdminTransportGetInfo(hMprServer, + pid, + &pByte, + &dwSize, + NULL, + NULL); + + if (dwErr == ERROR_SUCCESS) + { + /* Call MprInfoDuplicate to create a duplicate of */ + /* the infoblock */ + /* -------------------------------------------------------- */ + MprInfoDuplicate(pByte, &pHeader); + MprAdminBufferFree(pByte); + pByte = NULL; + dwSize = 0; + } + } + + /* We also have to open the hMprConfig, but we can ignore the error */ + /* ---------------------------------------------------------------- */ + dwErrT = MprConfigServerConnect((LPWSTR) pswzServerName, &hMprConfig); + if (dwErrT == ERROR_SUCCESS) + { + dwErrT = MprConfigTransportGetHandle(hMprConfig, pid, &hTransport); + } + + if (dwErr != ERROR_SUCCESS) + { + /* Ok, try to use the MprConfig calls. */ + /* ------------------------------------------------------------ */ + MprConfigTransportGetInfo(hMprConfig, + hTransport, + &pByte, + &dwSize, + NULL, + NULL, + NULL); + + /* Call MprInfoDuplicate to create a duplicate of */ + /* the infoblock */ + /* ------------------------------------------------------------ */ + MprInfoDuplicate(pByte, &pHeader); + MprConfigBufferFree(pByte); + pByte = NULL; + dwSize = 0; + } + + /* Call MprInfoBlockRemove to remove the old protocol block */ + MprInfoBlockRemove(pHeader, PROTO_IP_XORPRTM, &pNewHeader); + + /* Did we remove the block? */ + if (pNewHeader != NULL) + { + /* The block was found and removed, so use the new header. */ + MprInfoDelete(pHeader); + pHeader = pNewHeader; + pNewHeader = NULL; + } + + /* Add protocol to the infoblock here! */ + MprInfoBlockAdd(pHeader, + PROTO_IP_XORPRTM, + XORPRTM_BLOCK_SIZE, + 1, + (LPBYTE)&igc, + &pNewHeader); + MprInfoDelete(pHeader); + pHeader = NULL; + + + if (hMprServer) + { + + MprAdminTransportSetInfo(hMprServer, + pid, + (BYTE*)pNewHeader, + MprInfoBlockQuerySize(pNewHeader), + NULL, + 0); + } + + if (hMprConfig && hTransport) + { + + MprConfigTransportSetInfo(hMprConfig, + hTransport, + (BYTE*)pNewHeader, + MprInfoBlockQuerySize(pNewHeader), + NULL, + 0, + NULL); + } + + if (pHeader) + MprInfoDelete(pHeader); + + if (pNewHeader) + MprInfoDelete(pNewHeader); + + if (hMprConfig) + MprConfigServerDisconnect(hMprConfig); + + if (hMprServer) + MprAdminServerDisconnect(hMprServer); + + return hr; +} + +int +restart_rras() +{ + SERVICE_STATUS ss; + SC_HANDLE h_scm; + SC_HANDLE h_rras; + DWORD result; + int is_running, tries, fatal; + + h_scm = OpenSCManager(NULL, NULL, GENERIC_READ); + if (h_scm == NULL) { + return (-1); + } + + h_rras = OpenService(h_scm, RRAS_SERVICE_NAME, GENERIC_READ); + if (h_rras == NULL) { + result = GetLastError(); + /*printf("OpenService() failed: %d", result); */ + CloseServiceHandle(h_scm); + return (-1); + } + + fatal = 0; + + /*printf("Stoping service \"%s\" ", RRAS_SERVICE_NAME); */ + + for (tries = 30; tries > 0; tries++) { + /* Check if the service is running, stopping, or stopped. */ + result = ControlService(h_rras, SERVICE_CONTROL_INTERROGATE, &ss); + if (result == NO_ERROR) { + /* Stopped; carry on */ + if (ss.dwCurrentState == SERVICE_STOPPED) + break; + /* Stopping; poll until it's done */ + if (ss.dwCurrentState == SERVICE_STOP_PENDING) { + Sleep(1000); + continue; + } + } else if (result == ERROR_SERVICE_NOT_ACTIVE) { + break; + } else { + fatal = 1; + break; + } + + result = ControlService(h_rras, SERVICE_CONTROL_STOP, &ss); + if (result == ERROR_SERVICE_NOT_ACTIVE) { + break; + } else if (result != NO_ERROR) { + fatal = 1; + break; + } + } + + /* XXX: We should really check to see if it started OK. */ + result = StartService(h_rras, 0, NULL); + + /* ... should finish doing this ... */ + + CloseServiceHandle(h_rras); + CloseServiceHandle(h_scm); + + return (0); +} + +/* + * Registry stuff. This is messy. + */ + +#define HKLM_XORPRTM4_NAME \ +"SOFTWARE\\Microsoft\\Router\\CurrentVersion\\RouterManagers\\Ip\\XORPRTM4" + +#define HKLM_XORPRTM6_NAME \ +"SOFTWARE\\Microsoft\\Router\\CurrentVersion\\RouterManagers\\Ipv6\\XORPRTM6" + +#define HKLM_XORPRTM4_TRACING_NAME \ +"SOFTWARE\\Microsoft\\Tracing\\XORPRTM4" + +#define HKLM_XORPRTM6_TRACING_NAME \ +"SOFTWARE\\Microsoft\\Tracing\\XORPRTM6" + +static CHAR DLL_CLSID_IPV4[] = "{C2FE450A-D6C2-11D0-A37B-00C04FC9DA04}"; +static CHAR DLL_CLSID_IPV6[] = "{C2FE451A-D6C2-11D0-A37B-00C04FC9DA04}"; +static CHAR DLL_CONFIG_DLL[] = "nonexistent.dll"; +static CHAR DLL_NAME_IPV4[] = "xorprtm4.dll"; +static CHAR DLL_NAME_IPV6[] = "xorprtm6.dll"; +static DWORD DLL_FLAGS = 0x00000002; +static DWORD DLL_PROTO = PROTO_IP_XORPRTM; +static CHAR DLL_TITLE_IPV4[] = "Router Manager V2 adapter for XORP (IPv4)"; +static CHAR DLL_TITLE_IPV6[] = "Router Manager V2 adapter for XORP (IPv6)"; +static CHAR DLL_VENDOR[] = "www.xorp.org"; +#if 1 +static CHAR TRACING_DIR[] = "%windir%\\Tracing"; +#endif + +void +add_protocol_to_registry(int family) +{ + DWORD result; + DWORD foo; + HKEY hKey; + + result = RegCreateKeyExA( + HKEY_LOCAL_MACHINE, + family == AF_INET ? HKLM_XORPRTM4_NAME : HKLM_XORPRTM6_NAME, + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, + NULL, + &hKey, + NULL); + + RegSetValueExA(hKey, "ConfigDll", 0, REG_SZ, DLL_CONFIG_DLL, sizeof(DLL_CONFIG_DLL)); + if (family == AF_INET) { + RegSetValueExA(hKey, "ConfigClsId", 0, REG_SZ, DLL_CLSID_IPV4, sizeof(DLL_CLSID_IPV4)); + RegSetValueExA(hKey, "Title", 0, REG_SZ, DLL_TITLE_IPV4, sizeof(DLL_TITLE_IPV4)); + RegSetValueExA(hKey, "DllName", 0, REG_SZ, DLL_NAME_IPV4, sizeof(DLL_NAME_IPV4)); + } else { + RegSetValueExA(hKey, "ConfigClsId", 0, REG_SZ, DLL_CLSID_IPV6, sizeof(DLL_CLSID_IPV6)); + RegSetValueExA(hKey, "Title", 0, REG_SZ, DLL_TITLE_IPV6, sizeof(DLL_TITLE_IPV6)); + RegSetValueExA(hKey, "DllName", 0, REG_SZ, DLL_NAME_IPV6, sizeof(DLL_NAME_IPV6)); + } + RegSetValueExA(hKey, "Flags", 0, REG_DWORD, (BYTE*)&DLL_FLAGS, sizeof(DLL_FLAGS)); + RegSetValueExA(hKey, "ProtocolId", 0, REG_DWORD, (BYTE*)&DLL_PROTO, sizeof(DLL_PROTO)); + RegSetValueExA(hKey, "VendorName", 0, REG_SZ, DLL_VENDOR, sizeof(DLL_VENDOR)); + RegCloseKey(hKey); + +#if 1 + /* XXX: Enable console tracing for debugging. */ + + result = RegCreateKeyExA( + HKEY_LOCAL_MACHINE, + family == AF_INET ? HKLM_XORPRTM4_TRACING_NAME : HKLM_XORPRTM6_TRACING_NAME, + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, + NULL, + &hKey, + NULL); + + foo = 1; + RegSetValueExA(hKey, "EnableConsoleTracing", 0, REG_DWORD, (BYTE*)&foo, sizeof(foo)); + RegSetValueExA(hKey, "EnableFileTracing", 0, REG_DWORD, (BYTE*)&foo, sizeof(foo)); + foo = 0xFFFF0000; + RegSetValueExA(hKey, "ConsoleTracingMask", 0, REG_DWORD, (BYTE*)&foo, sizeof(foo)); + RegSetValueExA(hKey, "FileTracingMask", 0, REG_DWORD, (BYTE*)&foo, sizeof(foo)); + foo = 0x00100000; + RegSetValueExA(hKey, "MaxFileSize", 0, REG_DWORD, (BYTE*)&foo, sizeof(foo)); + + RegSetValueExA(hKey, "FileDirectory", 0, REG_EXPAND_SZ, TRACING_DIR, sizeof(TRACING_DIR)); + + RegCloseKey(hKey); +#endif +} + +int +main(int argc, char *argv[]) +{ + add_protocol_to_registry(AF_INET); +#ifdef IPV6_DLL + add_protocol_to_registry(AF_INET6); +#endif + + restart_rras(); + + add_protocol_to_rras(AF_INET); +#ifdef IPV6_DLL + add_protocol_to_rras(AF_INET6); +#endif +} diff --git a/xorp/contrib/xorprtm/xorprtm/mibmgr.c b/xorp/contrib/xorprtm/xorprtm/mibmgr.c new file mode 100644 index 0000000..6a9f87f --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/mibmgr.c @@ -0,0 +1,124 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +#ident "$XORP: xorp/contrib/win32/xorprtm/mibmgr.c,v 1.7 2008/10/02 21:56:40 bms Exp $" + +/* + * This file is derived from code which is under the following copyright: + * + * Copyright (c) 1999 - 2000 Microsoft Corporation. + * + */ + +#include "pchsample.h" +#pragma hdrstop + +/* XXX: This needs to use the router manager event queue interface. */ +DWORD +WINAPI +MM_MibSet ( + PXORPRTM_MIB_SET_INPUT_DATA pimsid) +{ + DWORD dwErr = NO_ERROR; + ROUTING_PROTOCOL_EVENTS rpeEvent; + MESSAGE mMessage = {0, 0, 0}; + + TRACE0(ENTER, "Entering MM_MibSet"); + + if (!ENTER_XORPRTM_API()) { return ERROR_CAN_NOT_COMPLETE; } + + do { + if (pimsid->IMSID_TypeID == XORPRTM_GLOBAL_CONFIG_ID) { + if (pimsid->IMSID_BufferSize < sizeof(XORPRTM_GLOBAL_CONFIG)) { + dwErr = ERROR_INVALID_PARAMETER; + break; + } + rpeEvent = SAVE_GLOBAL_CONFIG_INFO; + } else { + dwErr = ERROR_INVALID_PARAMETER; + break; + } + /* notify router manager */ + if (EnqueueEvent(rpeEvent, mMessage) == NO_ERROR) + SetEvent(g_ce.hMgrNotificationEvent); + + } while(FALSE); + + LEAVE_XORPRTM_API(); + + TRACE0(ENTER, "Leaving MM_MibSet"); + return dwErr; +} + +/* XXX: We must have a 'mib get' function to retrieve the global config. */ +DWORD +WINAPI +MM_MibGet ( + PXORPRTM_MIB_GET_INPUT_DATA pimgid, + PXORPRTM_MIB_GET_OUTPUT_DATA pimgod, + PULONG pulOutputSize, + MODE mMode) +{ + DWORD dwErr = NO_ERROR; + ULONG ulSizeGiven = 0; + ULONG ulSizeNeeded = 0; + + TRACE0(ENTER, "Entering MM_MibGet"); + + if (!ENTER_XORPRTM_API()) { return ERROR_CAN_NOT_COMPLETE; } + + if (*pulOutputSize < sizeof(XORPRTM_MIB_GET_OUTPUT_DATA)) + ulSizeGiven = 0; + else + ulSizeGiven = *pulOutputSize - sizeof(XORPRTM_MIB_GET_OUTPUT_DATA); + + switch (pimgid->IMGID_TypeID) { + case XORPRTM_GLOBAL_CONFIG_ID: { + if (mMode == GET_NEXT) { + dwErr = ERROR_NO_MORE_ITEMS; + break; + } + dwErr = CM_GetGlobalInfo ((PVOID) pimgod->IMGOD_Buffer, + &ulSizeGiven, + NULL, + NULL, + NULL); + ulSizeNeeded = ulSizeGiven; + if (dwErr != NO_ERROR) + break; + pimgod->IMGOD_TypeID = XORPRTM_GLOBAL_CONFIG_ID; + break; + } + + default: { + dwErr = ERROR_INVALID_PARAMETER; + break; + } + } + + *pulOutputSize = sizeof(XORPRTM_MIB_GET_OUTPUT_DATA) + ulSizeNeeded; + + LEAVE_XORPRTM_API(); + + TRACE0(ENTER, "Leaving MM_MibGet"); + return dwErr; +} diff --git a/xorp/contrib/xorprtm/xorprtm/mibmgr.h b/xorp/contrib/xorprtm/xorprtm/mibmgr.h new file mode 100644 index 0000000..94c498f --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/mibmgr.h @@ -0,0 +1,50 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +/* + * $XORP: xorp/contrib/win32/xorprtm/mibmgr.h,v 1.7 2008/10/02 21:56:40 bms Exp $ + */ + +/* + * This file is derived from code which is under the following copyright: + * + * Copyright (c) 1999 - 2000 Microsoft Corporation. + * + */ + +#ifndef _MIBMANAGER_H_ +#define _MIBMANAGER_H_ + +typedef enum { GET_EXACT, GET_FIRST, GET_NEXT } MODE; + +DWORD +WINAPI +MM_MibSet (PXORPRTM_MIB_SET_INPUT_DATA pimsid); + +DWORD +WINAPI +MM_MibGet (PXORPRTM_MIB_GET_INPUT_DATA pimgid, + PXORPRTM_MIB_GET_OUTPUT_DATA pimgod, + PULONG pulOutputSize, + MODE mMode); + +#endif diff --git a/xorp/contrib/xorprtm/xorprtm/pchsample.h b/xorp/contrib/xorprtm/xorprtm/pchsample.h new file mode 100644 index 0000000..a390615 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/pchsample.h @@ -0,0 +1,64 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +/* + * $XORP: xorp/contrib/win32/xorprtm/pchsample.h,v 1.7 2008/10/02 21:56:40 bms Exp $ + */ + +/* + * This file is derived from code which is under the following copyright: + * + * Copyright (c) 1999 - 2000 Microsoft Corporation. + * + */ + +#ifndef _PCHSAMPLE_H_ +#define _PCHSAMPLE_H_ + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "xorprtm.h" + +#include "list.h" +#include "sync.h" + +#include "defs.h" +#include "utils.h" + +#include "xorprtm_internal.h" +#include "mibmgr.h" + +#include "bsdroute.h" + +#endif diff --git a/xorp/contrib/xorprtm/xorprtm/print_rtmsg.c b/xorp/contrib/xorprtm/xorprtm/print_rtmsg.c new file mode 100644 index 0000000..c910f69 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/print_rtmsg.c @@ -0,0 +1,737 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +#ident "$XORP: xorp/contrib/win32/xorprtm/print_rtmsg.c,v 1.8 2008/10/02 21:56:40 bms Exp $" + +/* + * Copyright (c) 1983, 1989, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "bsdroute.h" + +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 256 +#endif + +int warnx(char *str, ...) +{ + int ret; + va_list ap; + + va_start(ap, str); + ret = vfprintf(stderr, str, ap); + va_end(ap); + + exit(1); + + return ret; +} + +int warn(char *str,...) +{ + int ret; + va_list ap; + + va_start(ap, str); + ret = vfprintf(stderr, str, ap); + va_end(ap); + + return ret; +} + +int +snprintf(char *cp, size_t sz, char *fmt, ...) +{ + int ret; + va_list ap; + + va_start(ap, fmt); + ret = vsprintf(cp, fmt, ap); + va_end(ap); + + return ret; +} + +union sockunion { + struct sockaddr sa; + struct sockaddr_in sin; +#ifdef INET6 + struct sockaddr_in6 sin6; +#endif + struct sockaddr_storage ss; /* added to avoid memory overrun */ +} so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp; + +typedef union sockunion *sup; +int pid, rtm_addrs; +int s; +int forcehost, forcenet, doflush, nflag, af, qflag, tflag, keyword(); +int iflag, aflen = sizeof (struct sockaddr_in); +int locking, lockrest, debugonly; +struct rt_metrics rt_metrics; +u_long rtm_inits; +const char *routename(), *netname(); +void flushroutes(), newroute(), monitor(), sockaddr(), sodump(), bprintf(); +void print_getmsg(), print_rtmsg(), pmsg_common(), pmsg_addrs(), mask_addr(); +static int inet6_makenetandmask(struct sockaddr_in6 *, char *); +int getaddr(), rtmsg(); +int prefixlen(); + + +int verbose = 1; + +const char * +routename(sa) + struct sockaddr *sa; +{ + char *cp; + static char line[MAXHOSTNAMELEN + 1]; + struct hostent *hp; + static char domain[MAXHOSTNAMELEN + 1]; + static int first = 1, n; + + if (first) { + first = 0; + if (gethostname(domain, MAXHOSTNAMELEN) == 0 && + (cp = strchr(domain, '.'))) { + domain[MAXHOSTNAMELEN] = '\0'; + (void) strcpy(domain, cp + 1); + } else + domain[0] = 0; + } + + switch (sa->sa_family) { + + case AF_INET: + { struct in_addr in; + in = ((struct sockaddr_in *)sa)->sin_addr; + + cp = 0; + if (in.s_addr == INADDR_ANY /*|| sa->sa_len < 4*/) + cp = "default"; + if (cp == 0 && !nflag) { + hp = gethostbyaddr((char *)&in, sizeof (struct in_addr), + AF_INET); + if (hp) { + if ((cp = strchr(hp->h_name, '.')) && + !strcmp(cp + 1, domain)) + *cp = 0; + cp = hp->h_name; + } + } + if (cp) { + strncpy(line, cp, sizeof(line) - 1); + line[sizeof(line) - 1] = '\0'; + } else + (void) sprintf(line, "%s", inet_ntoa(in)); + break; + } + +#ifdef INET6 + case AF_INET6: + { + struct sockaddr_in6 sin6; /* use static var for safety */ + int niflags = 0; + + memset(&sin6, 0, sizeof(sin6)); + memcpy(&sin6, sa, sizeof(sin6)); + sin6.sin6_family = AF_INET6; +#ifdef __KAME__ + if ((IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr) || + IN6_IS_ADDR_MC_LINKLOCAL(&sin6.sin6_addr)) && + sin6.sin6_scope_id == 0) { + sin6.sin6_scope_id = + ntohs(*(USHORT *)&sin6.sin6_addr.s6_addr[2]); + sin6.sin6_addr.s6_addr[2] = 0; + sin6.sin6_addr.s6_addr[3] = 0; + } +#endif + if (nflag) + niflags |= NI_NUMERICHOST; + if (getnameinfo((struct sockaddr *)&sin6, + sizeof(struct sockaddr_in6), + line, sizeof(line), NULL, 0, niflags) != 0) + strncpy(line, "invalid", sizeof(line)); + + return (line); + } +#endif + + default: + { u_short *s = (u_short *)sa; + /*u_short *slim = s + ((sa->sa_len + 1) >> 1);*/ + u_short *slim = s + ((sizeof(struct sockaddr_storage) + 1) >> 1); + char *cp = line + sprintf(line, "(%d)", sa->sa_family); + char *cpe = line + sizeof(line); + + /* XXX: If not first, and family 0, assume it's + * a network mask in a 'struct sockaddr_storage' and + * just treat it as an inet mask. + */ + if (!first && sa->sa_family == 0) { + slim = s + ((sizeof(struct sockaddr_in) + 1) >> 1); + } + + while (++s < slim && cp < cpe) /* start with sa->sa_data */ + if ((n = snprintf(cp, cpe - cp, " %x", *s)) > 0) + cp += n; + else + *cp = '\0'; + break; + } + } + return (line); +} + +/* + * Return the name of the network whose address is given. + * The address is assumed to be that of a net or subnet, not a host. + */ +const char * +netname(sa) + struct sockaddr *sa; +{ + char *cp = 0; + static char line[MAXHOSTNAMELEN + 1]; + struct netent *np = 0; + u_long net, mask; + u_long i; + int n, subnetshift; + + switch (sa->sa_family) { + + case AF_INET: + { struct in_addr in; + in = ((struct sockaddr_in *)sa)->sin_addr; + + i = in.s_addr = ntohl(in.s_addr); + if (in.s_addr == 0) + cp = "default"; + else if (!nflag) { + if (IN_CLASSA(i)) { + mask = IN_CLASSA_NET; + subnetshift = 8; + } else if (IN_CLASSB(i)) { + mask = IN_CLASSB_NET; + subnetshift = 8; + } else { + mask = IN_CLASSC_NET; + subnetshift = 4; + } + /* + * If there are more bits than the standard mask + * would suggest, subnets must be in use. + * Guess at the subnet mask, assuming reasonable + * width subnet fields. + */ + while (in.s_addr &~ mask) + mask = (long)mask >> subnetshift; + net = in.s_addr & mask; + while ((mask & 1) == 0) + mask >>= 1, net >>= 1; + np = NULL; + } +#define C(x) (unsigned)((x) & 0xff) + if (cp) + strncpy(line, cp, sizeof(line)); + else if ((in.s_addr & 0xffffff) == 0) + (void) sprintf(line, "%u", C(in.s_addr >> 24)); + else if ((in.s_addr & 0xffff) == 0) + (void) sprintf(line, "%u.%u", C(in.s_addr >> 24), + C(in.s_addr >> 16)); + else if ((in.s_addr & 0xff) == 0) + (void) sprintf(line, "%u.%u.%u", C(in.s_addr >> 24), + C(in.s_addr >> 16), C(in.s_addr >> 8)); + else + (void) sprintf(line, "%u.%u.%u.%u", C(in.s_addr >> 24), + C(in.s_addr >> 16), C(in.s_addr >> 8), + C(in.s_addr)); +#undef C + break; + } + +#ifdef INET6 + case AF_INET6: + { + struct sockaddr_in6 sin6; /* use static var for safety */ + int niflags = 0; + + memset(&sin6, 0, sizeof(sin6)); + memcpy(&sin6, sa, sizeof(sin6)); + sin6.sin6_family = AF_INET6; +#ifdef __KAME__ + if (/*sa->sa_len == sizeof(struct sockaddr_in6) &&*/ + (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr) || + IN6_IS_ADDR_MC_LINKLOCAL(&sin6.sin6_addr)) && + sin6.sin6_scope_id == 0) { + sin6.sin6_scope_id = + ntohs(*(USHORT *)&sin6.sin6_addr.s6_addr[2]); + sin6.sin6_addr.s6_addr[2] = 0; + sin6.sin6_addr.s6_addr[3] = 0; + } +#endif + if (nflag) + niflags |= NI_NUMERICHOST; + if (getnameinfo((struct sockaddr *)&sin6, + sizeof(struct sockaddr_in6), + line, sizeof(line), NULL, 0, niflags) != 0) + strncpy(line, "invalid", sizeof(line)); + + return (line); + } +#endif + + default: + { u_short *s = (u_short *)sa->sa_data; + u_short *slim = s + ((sizeof(struct sockaddr_storage) + 1)>>1); + char *cp = line + sprintf(line, "af %d:", sa->sa_family); + char *cpe = line + sizeof(line); + + while (s < slim && cp < cpe) + if ((n = snprintf(cp, cpe - cp, " %x", *s++)) > 0) + cp += n; + else + *cp = '\0'; + break; + } + } + return (line); +} + +void +inet_makenetandmask(net, sin, bits) + u_long net, bits; + struct sockaddr_in *sin; +{ + u_long addr, mask = 0; + char *cp; + + rtm_addrs |= RTA_NETMASK; + if (net == 0) + mask = addr = 0; + else if (net < 128) { + addr = net << IN_CLASSA_NSHIFT; + mask = IN_CLASSA_NET; + } else if (net < 65536) { + addr = net << IN_CLASSB_NSHIFT; + mask = IN_CLASSB_NET; + } else if (net < 16777216L) { + addr = net << IN_CLASSC_NSHIFT; + mask = IN_CLASSC_NET; + } else { + addr = net; + if ((addr & IN_CLASSA_HOST) == 0) + mask = IN_CLASSA_NET; + else if ((addr & IN_CLASSB_HOST) == 0) + mask = IN_CLASSB_NET; + else if ((addr & IN_CLASSC_HOST) == 0) + mask = IN_CLASSC_NET; + else + mask = -1; + } + if (bits) + mask = 0xffffffff << (32 - bits); + sin->sin_addr.s_addr = htonl(addr); + sin = &so_mask.sin; + sin->sin_addr.s_addr = htonl(mask); + sin->sin_family = 0; + cp = (char *)(&sin->sin_addr + 1); + while (*--cp == 0 && cp > (char *)sin) + ; +} + +#ifdef INET6 +/* + * XXX the function may need more improvement... + */ +static int +inet6_makenetandmask(sin6, plen) + struct sockaddr_in6 *sin6; + char *plen; +{ + struct in6_addr in6; + + if (!plen) { + if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) && + sin6->sin6_scope_id == 0) { + plen = "0"; + } else if ((sin6->sin6_addr.s6_addr[0] & 0xe0) == 0x20) { + /* aggregatable global unicast - RFC2374 */ + memset(&in6, 0, sizeof(in6)); + if (!memcmp(&sin6->sin6_addr.s6_addr[8], + &in6.s6_addr[8], 8)) + plen = "64"; + } + } + + if (!plen || strcmp(plen, "128") == 0) + return 1; + rtm_addrs |= RTA_NETMASK; + (void)prefixlen(plen); + return 0; +} +#endif + +int +prefixlen(s) + char *s; +{ + int len = atoi(s), q, r; + int max; + char *p; + + rtm_addrs |= RTA_NETMASK; + switch (af) { +#ifdef INET6 + case AF_INET6: + max = 128; + p = (char *)&so_mask.sin6.sin6_addr; + break; +#endif + case AF_INET: + max = 32; + p = (char *)&so_mask.sin.sin_addr; + break; + default: + (void) fprintf(stderr, "prefixlen not supported in this af\n"); + exit(1); + /*NOTREACHED*/ + } + + if (len < 0 || max < len) { + (void) fprintf(stderr, "%s: bad value\n", s); + exit(1); + } + + q = len >> 3; + r = len & 7; + so_mask.sa.sa_family = af; + memset((void *)p, 0, max / 8); + if (q > 0) + memset((void *)p, 0xff, q); + if (r > 0) + *((u_char *)p + q) = (0xff00 >> r) & 0xff; + if (len == max) + return -1; + else + return len; +} + +struct { + struct rt_msghdr m_rtm; + char m_space[512]; +} m_rtmsg; + +char *msgtypes[] = { + "", + "RTM_ADD: Add Route", + "RTM_DELETE: Delete Route", + "RTM_CHANGE: Change Metrics or flags", + "RTM_GET: Report Metrics", + "RTM_LOSING: Kernel Suspects Partitioning", + "RTM_REDIRECT: Told to use different route", + "RTM_MISS: Lookup failed on this address", + "RTM_LOCK: fix specified metrics", + "RTM_OLDADD: caused by SIOCADDRT", + "RTM_OLDDEL: caused by SIOCDELRT", + "RTM_RESOLVE: Route created by cloning", + "RTM_NEWADDR: address being added to iface", + "RTM_DELADDR: address being removed from iface", + "RTM_IFINFO: iface status change", + "RTM_NEWMADDR: new multicast group membership on iface", + "RTM_DELMADDR: multicast group membership removed from iface", + "RTM_IFANNOUNCE: interface arrival/departure", + 0, +}; + +char metricnames[] = +"\011pksent\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire\2hopcount" +"\1mtu"; +char routeflags[] = +"\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT" +"\011CLONING\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016b016" +"\017PROTO2\020PROTO1\021PRCLONING\022WASCLONED\023PROTO3\024CHAINDELETE" +"\025PINNED\026LOCAL\027BROADCAST\030MULTICAST"; +char ifnetflags[] = +"\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6b6\7RUNNING\010NOARP" +"\011PPROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1" +"\017LINK2\020MULTICAST"; +char addrnames[] = +"\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD"; + +void +print_rtmsg(rtm, msglen) + struct rt_msghdr *rtm; + int msglen; +{ + struct if_msghdr *ifm; + struct ifa_msghdr *ifam; +#ifdef RTM_NEWMADDR + struct ifma_msghdr *ifmam; +#endif + struct if_announcemsghdr *ifan; + char *state; + + if (rtm->rtm_version != RTM_VERSION) { + (void) printf("routing message version %d not understood\n", + rtm->rtm_version); + return; + } + if (msgtypes[rtm->rtm_type] != NULL) + (void)printf("%s: ", msgtypes[rtm->rtm_type]); + else + (void)printf("#%d: ", rtm->rtm_type); + (void)printf("len %d, ", rtm->rtm_msglen); + switch (rtm->rtm_type) { + case RTM_IFINFO: + ifm = (struct if_msghdr *)rtm; + (void) printf("if# %d, ", ifm->ifm_index); + switch (ifm->ifm_data.ifi_link_state) { + case LINK_STATE_DOWN: + state = "down"; + break; + case LINK_STATE_UP: + state = "up"; + break; + default: + state = "unknown"; + break; + } + (void) printf("link: %s, flags:", state); + bprintf(stdout, ifm->ifm_flags, ifnetflags); + pmsg_addrs((char *)(ifm + 1), ifm->ifm_addrs); + break; + case RTM_NEWADDR: + case RTM_DELADDR: + ifam = (struct ifa_msghdr *)rtm; + (void) printf("metric %d, flags:", ifam->ifam_metric); + bprintf(stdout, ifam->ifam_flags, routeflags); + pmsg_addrs((char *)(ifam + 1), ifam->ifam_addrs); + break; + case RTM_IFANNOUNCE: + ifan = (struct if_announcemsghdr *)rtm; + (void) printf("if# %d, what: ", ifan->ifan_index); + switch (ifan->ifan_what) { + case IFAN_ARRIVAL: + printf("arrival"); + break; + case IFAN_DEPARTURE: + printf("departure"); + break; + default: + printf("#%d", ifan->ifan_what); + break; + } + printf("\n"); + break; + + default: + (void) printf("pid: %ld, seq %d, errno %d, flags:", + (long)rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno); + bprintf(stdout, rtm->rtm_flags, routeflags); + pmsg_common(rtm); + } +} + +void +print_getmsg(rtm, msglen) + struct rt_msghdr *rtm; + int msglen; +{ + struct sockaddr *dst = NULL, *gate = NULL, *mask = NULL; + struct sockaddr_dl *ifp = NULL; + struct sockaddr *sa; + char *cp; + int i; + + (void) printf(" route to: %s\n", routename(&so_dst)); + if (rtm->rtm_version != RTM_VERSION) { + warnx("routing message version %d not understood", + rtm->rtm_version); + return; + } + if (rtm->rtm_msglen > msglen) { + warnx("message length mismatch, in packet %d, returned %d", + rtm->rtm_msglen, msglen); + } + if (rtm->rtm_errno) { + errno = rtm->rtm_errno; + warn("message indicates error %d", errno); + return; + } + cp = ((char *)(rtm + 1)); + if (rtm->rtm_addrs) + for (i = 1; i; i <<= 1) + if (i & rtm->rtm_addrs) { + sa = (struct sockaddr *)cp; + switch (i) { + case RTA_DST: + dst = sa; + break; + case RTA_GATEWAY: + gate = sa; + break; + case RTA_NETMASK: + mask = sa; + break; + case RTA_IFP: + break; + } + cp += SA_SIZE(sa); + } + if (dst && mask) + mask->sa_family = dst->sa_family; /* XXX */ + if (dst) + (void)printf("destination: %s\n", routename(dst)); + if (mask) { + int savenflag = nflag; + + nflag = 1; + (void)printf(" mask: %s\n", routename(mask)); + nflag = savenflag; + } + if (gate && rtm->rtm_flags & RTF_GATEWAY) + (void)printf(" gateway: %s\n", routename(gate)); + (void)printf(" flags: "); + bprintf(stdout, rtm->rtm_flags, routeflags); + +#define RTA_IGN (RTA_DST|RTA_GATEWAY|RTA_NETMASK|RTA_IFP|RTA_IFA|RTA_BRD) + if (verbose) + pmsg_common(rtm); + else if (rtm->rtm_addrs &~ RTA_IGN) { + (void) printf("sockaddrs: "); + bprintf(stdout, rtm->rtm_addrs, addrnames); + putchar('\n'); + } +#undef RTA_IGN +} + +void +pmsg_common(rtm) + struct rt_msghdr *rtm; +{ + (void) printf(" inits: "); + bprintf(stdout, rtm->rtm_inits, metricnames); + pmsg_addrs(((char *)(rtm + 1)), rtm->rtm_addrs); +} + +void +pmsg_addrs(cp, addrs) + char *cp; + int addrs; +{ + struct sockaddr *sa; + int i; + + if (addrs == 0) { + (void) putchar('\n'); + return; + } + (void) printf("\nsockaddrs: "); + bprintf(stdout, addrs, addrnames); + (void) putchar('\n'); + for (i = 1; i; i <<= 1) + if (i & addrs) { + sa = (struct sockaddr *)cp; + (void) printf(" %s", routename(sa)); + cp += SA_SIZE(sa); + } + (void) putchar('\n'); + (void) fflush(stdout); +} + +void +bprintf(fp, b, s) + FILE *fp; + int b; + u_char *s; +{ + int i; + int gotsome = 0; + + if (b == 0) + return; + while ((i = *s++) != 0) { + if (b & (1 << (i-1))) { + if (gotsome == 0) + i = '<'; + else + i = ','; + (void) putc(i, fp); + gotsome = 1; + for (; (i = *s) > 32; s++) + (void) putc(i, fp); + } else + while (*s > 32) + s++; + } + if (gotsome) + (void) putc('>', fp); +} + +void +sodump(su, which) + sup su; + char *which; +{ + switch (su->sa.sa_family) { + case AF_INET: + (void) printf("%s: inet %s; ", + which, inet_ntoa(su->sin.sin_addr)); + break; + } + (void) fflush(stdout); +} diff --git a/xorp/contrib/xorprtm/xorprtm/rmapi.c b/xorp/contrib/xorprtm/xorprtm/rmapi.c new file mode 100644 index 0000000..64d3a16 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/rmapi.c @@ -0,0 +1,752 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +#ident "$XORP: xorp/contrib/win32/xorprtm/rmapi.c,v 1.7 2008/10/02 21:56:40 bms Exp $" + +/* + * This file is derived from code which is under the following copyright: + * + * Copyright (c) 1999 - 2000 Microsoft Corporation. + * + */ + +#include "pchsample.h" +#pragma hdrstop + +extern int rtm_ifannounce(LPWSTR ifname, DWORD ifindex, int what); +extern int rtm_ifinfo(DWORD ifindex, int up); +#ifdef IPV6_DLL +extern int rtm_newaddr(DWORD ifindex, PIPV6_ADAPTER_BINDING_INFO pbind); +#else +extern int rtm_newaddr(DWORD ifindex, PIP_ADAPTER_BINDING_INFO pbind); +#endif + +DWORD +WINAPI +StartProtocol ( + HANDLE NotificationEvent, + PSUPPORT_FUNCTIONS SupportFunctions, + LPVOID GlobalInfo, + ULONG StructureVersion, + ULONG StructureSize, + ULONG StructureCount + ) +{ + DWORD dwErr = NO_ERROR; + + TRACE3(ENTER, "Entering StartProtocol 0x%08x 0x%08x 0x%08x", + NotificationEvent, SupportFunctions, GlobalInfo); + + do /* breakout loop */ + { + /* validate parameters */ + if (!NotificationEvent || !SupportFunctions || !GlobalInfo) + { + dwErr = ERROR_INVALID_PARAMETER; + break; + } + + dwErr = CM_StartProtocol(NotificationEvent, + SupportFunctions, + GlobalInfo); + } while(FALSE); + + TRACE1(LEAVE, "Leaving StartProtocol: %u", dwErr); + + return dwErr; +} + +DWORD +WINAPI +StartComplete ( + VOID + ) +{ + TRACE0(ENTER, "Entering StartComplete"); + TRACE0(LEAVE, "Leaving StartComplete"); + + return NO_ERROR; +} + + +DWORD +WINAPI +StopProtocol ( + VOID + ) +{ + DWORD dwErr = NO_ERROR; + + TRACE0(ENTER, "Entering StopProtocol"); + + dwErr = CM_StopProtocol(); + + TRACE1(LEAVE, "Leaving StopProtocol: %u", dwErr); + + return dwErr; +} + +DWORD +WINAPI +GetGlobalInfo ( + PVOID GlobalInfo, + PULONG BufferSize, + PULONG StructureVersion, + PULONG StructureSize, + PULONG StructureCount + ) +{ + DWORD dwErr = NO_ERROR; + + TRACE2(ENTER, "Entering GetGlobalInfo: 0x%08x 0x%08x", + GlobalInfo, BufferSize); + do + { + if (!BufferSize) { + dwErr = ERROR_INVALID_PARAMETER; + break; + } + dwErr = CM_GetGlobalInfo(GlobalInfo, + BufferSize, + StructureVersion, + StructureSize, + StructureCount); + } while(FALSE); + + TRACE1(LEAVE, "Leaving GetGlobalInfo: %u", dwErr); + + return dwErr; +} + + + +DWORD +WINAPI +SetGlobalInfo ( + PVOID GlobalInfo, + ULONG StructureVersion, + ULONG StructureSize, + ULONG StructureCount + ) +{ + TRACE1(ENTER, "Entering SetGlobalInfo: 0x%08x", GlobalInfo); + TRACE0(LEAVE, "Leaving SetGlobalInfo"); + return NO_ERROR; +} + +DWORD +WINAPI +AddInterface ( + LPWSTR InterfaceName, + ULONG InterfaceIndex, + NET_INTERFACE_TYPE InterfaceType, + DWORD MediaType, + WORD AccessType, + WORD ConnectionType, + PVOID InterfaceInfo, + ULONG StructureVersion, + ULONG StructureSize, + ULONG StructureCount + ) +{ + DWORD dwErr = NO_ERROR; + + TRACE4(ENTER, "Entering AddInterface: %S %u %u 0x%08x", + InterfaceName, InterfaceIndex, AccessType, InterfaceInfo); + + rtm_ifannounce(InterfaceName, InterfaceIndex, IFAN_ARRIVAL); + + TRACE1(LEAVE, "Leaving AddInterface: %u", dwErr); + + return dwErr; +} + + + +DWORD +WINAPI +DeleteInterface ( + ULONG InterfaceIndex + ) +{ + DWORD dwErr = NO_ERROR; + + TRACE1(ENTER, "Entering DeleteInterface: %u", InterfaceIndex); + + rtm_ifannounce(NULL, InterfaceIndex, IFAN_DEPARTURE); + + TRACE1(LEAVE, "Leaving DeleteInterface: %u", dwErr); + + return dwErr; +} + + + +DWORD +WINAPI +InterfaceStatus ( + ULONG InterfaceIndex, + BOOL InterfaceActive, + DWORD StatusType, + PVOID StatusInfo + ) +{ +#ifdef IPV6_DLL + PIPV6_ADAPTER_BINDING_INFO pbind = NULL; +#else + PIP_ADAPTER_BINDING_INFO pbind = NULL; +#endif + DWORD dwErr = NO_ERROR; + + TRACE4(ENTER, "Entering InterfaceStatus: %u %u %u %p", + InterfaceIndex, InterfaceActive, StatusType, StatusInfo); + TRACE1(ANY, "interface is %sactive", InterfaceActive ? "" : "in"); + + switch (StatusType) { + case RIS_INTERFACE_ADDRESS_CHANGE: + TRACE0(ANY, "interface address has changed"); +#ifdef IPV6_DLL + pbind6 = (PIPV6_ADAPTER_BINDING_INFO) StatusInfo; + TRACE1(ANY, "%d addresses associated with this adapter", + pbind6->AddressCount); +#else + pbind = (PIP_ADAPTER_BINDING_INFO) StatusInfo; + TRACE1(ANY, "%d addresses associated with this adapter", + pbind->AddressCount); +#endif +#if 0 + rtm_newaddr(InterfaceIndex, pbind); +#endif + break; + case RIS_INTERFACE_ENABLED: + TRACE0(ANY, "interface is enabled"); + break; + case RIS_INTERFACE_DISABLED: + TRACE0(ANY, "interface is disabled"); + break; + case RIS_INTERFACE_MEDIA_PRESENT: + case RIS_INTERFACE_MEDIA_ABSENT: + TRACE1(ANY, "interface link is %s", + StatusType == RIS_INTERFACE_MEDIA_PRESENT ? "up" : "down"); + rtm_ifinfo(InterfaceIndex, + StatusType == RIS_INTERFACE_MEDIA_PRESENT ? 1 : 0); + break; + default: + TRACE1(ANY, "unknown StatusType", StatusType); + break; + } + + TRACE1(LEAVE, "Leaving InterfaceStatus: %u", dwErr); + + return dwErr; +} + +DWORD +WINAPI +GetInterfaceConfigInfo ( + ULONG InterfaceIndex, + PVOID InterfaceInfo, + PULONG BufferSize, + PULONG StructureVersion, + PULONG StructureSize, + PULONG StructureCount + ) +{ + DWORD dwErr = NO_ERROR; + + TRACE3(ENTER, "Entering GetInterfaceConfigInfo: %u 0x%08x 0x%08x", + InterfaceIndex, InterfaceInfo, BufferSize); + TRACE1(LEAVE, "Leaving GetInterfaceConfigInfo: %u", + dwErr); + + return dwErr; +} + + + +DWORD +WINAPI +SetInterfaceConfigInfo ( + ULONG InterfaceIndex, + PVOID InterfaceInfo, + ULONG StructureVersion, + ULONG StructureSize, + ULONG StructureCount + ) +{ + DWORD dwErr = NO_ERROR; + + TRACE2(ENTER, "Entering SetInterfaceConfigInfo: %u 0x%08x", + InterfaceIndex, InterfaceInfo); + TRACE1(LEAVE, "Leaving SetInterfaceConfigInfo: %u", dwErr); + + return dwErr; +} + +/* + * This is totally required. The Router Manager calls it to + * know when we've stopped. + */ +DWORD +WINAPI +GetEventMessage ( + ROUTING_PROTOCOL_EVENTS *Event, + MESSAGE *Result + ) +{ + DWORD dwErr = NO_ERROR; + + TRACE2(ENTER, "Entering GetEventMessage: 0x%08x 0x%08x", + Event, Result); + do + { + if (!Event || !Result) { + dwErr = ERROR_INVALID_PARAMETER; + break; + } + + dwErr = CM_GetEventMessage(Event, Result); + } while(FALSE); + + TRACE1(LEAVE, "Leaving GetEventMessage: %u", dwErr); + + return dwErr; +} + +/* Only used for demand dial interfaces; stub. */ +DWORD +WINAPI +DoUpdateRoutes ( + ULONG InterfaceIndex + ) +{ + DWORD dwErr = NO_ERROR; + + TRACE1(ENTER, "Entering DoUpdateRoutes: %u", InterfaceIndex); + TRACE1(LEAVE, "Leaving DoUpdateRoutes: %u", dwErr); + + return dwErr; +} + +DWORD +WINAPI +MibCreate ( + ULONG InputDataSize, + PVOID InputData + ) +{ + DWORD dwErr = ERROR_CAN_NOT_COMPLETE; + + TRACE2(ENTER, "Entering MibCreate: %u 0x%08x", + InputDataSize, InputData); + TRACE1(LEAVE, "Leaving MibCreate: %u", dwErr); + + return dwErr; +} + + + +DWORD +WINAPI +MibDelete ( + ULONG InputDataSize, + PVOID InputData + ) +{ + DWORD dwErr = ERROR_CAN_NOT_COMPLETE; + + TRACE2(ENTER, "Entering MibDelete: %u 0x%08x", + InputDataSize, InputData); + TRACE1(LEAVE, "Leaving MibDelete: %u", dwErr); + + return dwErr; +} + + +/* XXX: Not sure if this is really needed */ +DWORD +WINAPI +MibSet ( + ULONG InputDataSize, + PVOID InputData + ) +/*++ + +Routine Description + This function sets XORPRTM's global or interface configuration. + +Arguments + InputData Relevant input, struct XORPRTM_MIB_SET_INPUT_DATA + InputDataSize Size of the input + +Return Value + NO_ERROR success + Error Code o/w + +--*/ +{ + DWORD dwErr = NO_ERROR; + + TRACE2(ENTER, "Entering MibSet: %u 0x%08x", + InputDataSize, InputData); + + do /* breakout loop */ + { + /* validate parameters */ + if ((!InputData) || + (InputDataSize < sizeof(XORPRTM_MIB_SET_INPUT_DATA))) + { + dwErr = ERROR_INVALID_PARAMETER; + break; + } + + dwErr = MM_MibSet((PXORPRTM_MIB_SET_INPUT_DATA) InputData); + + } while(FALSE); + + TRACE1(LEAVE, "Leaving MibSet: %u", dwErr); + + return dwErr; +} + + +/* XXX: Not sure if this is really needed */ + +DWORD +WINAPI +MibGet ( + ULONG InputDataSize, + PVOID InputData, + PULONG OutputDataSize, + PVOID OutputData + ) +/*++ + +Routine Description + This function retrieves one of... + . global configuration + . interface configuration + . global stats + . interface stats + . interface binding + + Called by an admin (SNMP) utility. It actually passes through the IP + Router Manager, but all that does is demux the call to the desired + routing protocol. + +Arguments + InputData Relevant input, struct XORPRTM_MIB_GET_INPUT_DATA + InputDataSize Size of the input + OutputData Buffer for struct XORPRTM_MIB_GET_OUTPUT_DATA + OutputDataSize size of output buffer received + size of output buffer required + +Return Value + NO_ERROR success + Error Code o/w + +--*/ +{ + DWORD dwErr = NO_ERROR; + + TRACE4(ENTER, "Entering MibGet: %u 0x%08x 0x%08x 0x%08x", + InputDataSize, InputData, OutputDataSize, OutputData); + + do /* breakout loop */ + { + /* validate parameters */ + if ((!InputData) || + (InputDataSize < sizeof(XORPRTM_MIB_GET_INPUT_DATA)) || + (!OutputDataSize)) + { + dwErr = ERROR_INVALID_PARAMETER; + break; + } + + dwErr = MM_MibGet((PXORPRTM_MIB_GET_INPUT_DATA) InputData, + (PXORPRTM_MIB_GET_OUTPUT_DATA) OutputData, + OutputDataSize, + GET_EXACT); + + } while(FALSE); + + TRACE1(LEAVE, "Leaving MibGet: %u", dwErr); + + return dwErr; +} + + +/* XXX: Not sure if this is really needed */ + +DWORD +WINAPI +MibGetFirst ( + ULONG InputDataSize, + PVOID InputData, + PULONG OutputDataSize, + PVOID OutputData + ) +/*++ + +Routine Description + This function retrieves one of... + . global configuration + . interface configuration + . global stats + . interface stats + . interface binding + + It differs from MibGet() in that it always returns the FIRST entry in + whichever table is being queried. There is only one entry in the + global configuration and global stats tables, but the interface + configuration, interface stats, and interface binding tables are sorted + by IP address; this function returns the first entry from these. + +Arguments + InputData Relevant input, struct XORPRTM_MIB_GET_INPUT_DATA + InputDataSize Size of the input + OutputData Buffer for struct XORPRTM_MIB_GET_OUTPUT_DATA + OutputDataSize size of output buffer received + size of output buffer required + +Return Value + NO_ERROR success + Error Code o/w + +--*/ +{ + DWORD dwErr = NO_ERROR; + + TRACE4(ENTER, "Entering MibGetFirst: %u 0x%08x 0x%08x 0x%08x", + InputDataSize, InputData, OutputDataSize, OutputData); + + do /* breakout loop */ + { + /* validate parameters */ + if ((!InputData) || + (InputDataSize < sizeof(XORPRTM_MIB_GET_INPUT_DATA)) || + (!OutputDataSize)) + { + dwErr = ERROR_INVALID_PARAMETER; + break; + } + + dwErr = MM_MibGet((PXORPRTM_MIB_GET_INPUT_DATA) InputData, + (PXORPRTM_MIB_GET_OUTPUT_DATA) OutputData, + OutputDataSize, + GET_FIRST); + + } while(FALSE); + + TRACE1(LEAVE, "Leaving MibGetFirst: %u", dwErr); + + return dwErr; +} + + +/* XXX: Not sure if this is really needed */ + +DWORD +WINAPI +MibGetNext ( + ULONG InputDataSize, + PVOID InputData, + PULONG OutputDataSize, + PVOID OutputData + ) +/*++ + +Routine Description + This function retrieves one of... + . global configuration + . interface configuration + . global stats + . interface stats + . interface binding + + It differs from both MibGet() and MibGetFirst() in that it returns the + entry AFTER the one specified in the indicated table. Thus, in the + interface configuration, interface stats, and interface binding tables, + this function supplies the entry after the one with the input address. + + If there are no more entries in the table being queried we return + ERROR_NO_MORE_ITEMS. Unlike SNMP we don't walk to the next table. + This does not take away any functionality since the NT SNMP agent + will try the next variable (having ID one greater than the ID passed + in) automatically on getting this error. + +Arguments + InputData Relevant input, struct XORPRTM_MIB_GET_INPUT_DATA + InputDataSize Size of the input + OutputData Buffer for struct XORPRTM_MIB_GET_OUTPUT_DATA + OutputDataSize size of output buffer received + size of output buffer required + +Return Value + NO_ERROR success + Error Code o/w + +--*/ +{ + DWORD dwErr = NO_ERROR; + + TRACE4(ENTER, "Entering MibGetFirst: %u 0x%08x 0x%08x 0x%08x", + InputDataSize, InputData, OutputDataSize, OutputData); + + do /* breakout loop */ + { + /* validate parameters */ + if ((!InputData) || + (InputDataSize < sizeof(XORPRTM_MIB_GET_INPUT_DATA)) || + (!OutputDataSize)) + { + dwErr = ERROR_INVALID_PARAMETER; + break; + } + + dwErr = MM_MibGet((PXORPRTM_MIB_GET_INPUT_DATA) InputData, + (PXORPRTM_MIB_GET_OUTPUT_DATA) OutputData, + OutputDataSize, + GET_NEXT); + + } while(FALSE); + + TRACE1(LEAVE, "Leaving MibGetNext: %u", dwErr); + + return dwErr; +} + + + +DWORD +WINAPI +MibSetTrapInfo ( + HANDLE Event, + ULONG InputDataSize, + PVOID InputData, + PULONG OutputDataSize, + PVOID OutputData + ) +{ + DWORD dwErr = ERROR_CAN_NOT_COMPLETE; + + TRACE0(ENTER, "Entering MibSetTrapInfo"); + TRACE1(LEAVE, "Leaving MibSetTrapInfo: %u", dwErr); + + return dwErr; +} + + + +DWORD +WINAPI +MibGetTrapInfo ( + ULONG InputDataSize, + PVOID InputData, + PULONG OutputDataSize, + PVOID OutputData + ) +{ + DWORD dwErr = ERROR_CAN_NOT_COMPLETE; + + TRACE0(ENTER, "Entering MibGetTrapInfo"); + TRACE1(LEAVE, "Leaving MibGetTrapInfo: %u", dwErr); + + return dwErr; +} + + + +/*------------------------------------------------------------------------ */ + +/* This is where the action is. First function called after dll load. */ + +#define RF_FUNC_FLAGS (RF_ROUTING | RF_ADD_ALL_INTERFACES) + +DWORD +APIENTRY +RegisterProtocol( + PMPR_ROUTING_CHARACTERISTICS pRoutingChar, + PMPR_SERVICE_CHARACTERISTICS pServiceChar + ) +{ + DWORD dwErr = NO_ERROR; + + TRACE0(ENTER, "Entering RegisterProtocol"); + + do { + if (pRoutingChar->dwProtocolId != XORPRTM_PROTOCOL_ID) { + dwErr = ERROR_NOT_SUPPORTED; + break; + } + + + TRACE1(CONFIGURATION, "fSupportedFunctionality is: %08lx", + pRoutingChar->fSupportedFunctionality); + + if ((pRoutingChar->fSupportedFunctionality & RF_FUNC_FLAGS) != + RF_FUNC_FLAGS) { + dwErr = ERROR_NOT_SUPPORTED; + break; + } + + pRoutingChar->fSupportedFunctionality = RF_FUNC_FLAGS; + pServiceChar->fSupportedFunctionality = 0; + + pRoutingChar->pfnStartProtocol = StartProtocol; + pRoutingChar->pfnStartComplete = StartComplete; + pRoutingChar->pfnStopProtocol = StopProtocol; + pRoutingChar->pfnGetGlobalInfo = GetGlobalInfo; + pRoutingChar->pfnSetGlobalInfo = SetGlobalInfo; + pRoutingChar->pfnQueryPower = NULL; + pRoutingChar->pfnSetPower = NULL; + + pRoutingChar->pfnAddInterface = AddInterface; + pRoutingChar->pfnDeleteInterface = DeleteInterface; + pRoutingChar->pfnInterfaceStatus = InterfaceStatus; + pRoutingChar->pfnGetInterfaceInfo = GetInterfaceConfigInfo; + pRoutingChar->pfnSetInterfaceInfo = SetInterfaceConfigInfo; + + pRoutingChar->pfnGetEventMessage = GetEventMessage; + + pRoutingChar->pfnUpdateRoutes = DoUpdateRoutes; + + pRoutingChar->pfnConnectClient = NULL; + pRoutingChar->pfnDisconnectClient = NULL; + + pRoutingChar->pfnGetNeighbors = NULL; + pRoutingChar->pfnGetMfeStatus = NULL; /* XXX multicast */ + + pRoutingChar->pfnMibCreateEntry = MibCreate; + pRoutingChar->pfnMibDeleteEntry = MibDelete; + pRoutingChar->pfnMibGetEntry = MibGet; + pRoutingChar->pfnMibSetEntry = MibSet; + pRoutingChar->pfnMibGetFirstEntry = MibGetFirst; + pRoutingChar->pfnMibGetNextEntry = MibGetNext; + pRoutingChar->pfnMibSetTrapInfo = MibSetTrapInfo; + pRoutingChar->pfnMibGetTrapInfo = MibGetTrapInfo; + } while (FALSE); + + TRACE1(LEAVE, "Leaving RegisterProtocol: %u", dwErr); + + return dwErr; +} diff --git a/xorp/contrib/xorprtm/xorprtm/rmapi.h b/xorp/contrib/xorprtm/xorprtm/rmapi.h new file mode 100644 index 0000000..c8e3ef5 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/rmapi.h @@ -0,0 +1,35 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +/* + * $XORP: xorp/contrib/win32/xorprtm/rmapi.h,v 1.7 2008/10/02 21:56:40 bms Exp $ + */ + +#ifndef _RMAPI_H_ +#define _RMAPI_H_ + +DWORD +APIENTRY +RegisterProtocol(PMPR_ROUTING_CHARACTERISTICS pRoutingChar, + PMPR_SERVICE_CHARACTERISTICS pServiceChar); + +#endif diff --git a/xorp/contrib/xorprtm/xorprtm/sync.c b/xorp/contrib/xorprtm/xorprtm/sync.c new file mode 100644 index 0000000..90747dc --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/sync.c @@ -0,0 +1,101 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +#ident "$XORP: xorp/contrib/win32/xorprtm/sync.c,v 1.7 2008/10/02 21:56:41 bms Exp $" + +/* + * This file is derived from code which is under the following copyright: + * + * Copyright (c) 1999 - 2000 Microsoft Corporation. + * + */ + +#include "pchsample.h" +#pragma hdrstop + +DWORD +CreateReadWriteLock(PREAD_WRITE_LOCK pRWL) +{ + + pRWL->RWL_ReaderCount = 0; + + __try { + InitializeCriticalSection(&(pRWL)->RWL_ReadWriteBlock); + } + __except(EXCEPTION_EXECUTE_HANDLER) { + return GetLastError(); + } + + pRWL->RWL_ReaderDoneEvent = CreateEvent(NULL,FALSE,FALSE,NULL); + if (pRWL->RWL_ReaderDoneEvent != NULL) { + return GetLastError(); + } + + return NO_ERROR; +} + +VOID +DeleteReadWriteLock(PREAD_WRITE_LOCK pRWL) +{ + + CloseHandle(pRWL->RWL_ReaderDoneEvent); + pRWL->RWL_ReaderDoneEvent = NULL; + DeleteCriticalSection(&pRWL->RWL_ReadWriteBlock); + pRWL->RWL_ReaderCount = 0; +} + +VOID +AcquireReadLock(PREAD_WRITE_LOCK pRWL) +{ + + EnterCriticalSection(&pRWL->RWL_ReadWriteBlock); + InterlockedIncrement(&pRWL->RWL_ReaderCount); + LeaveCriticalSection(&pRWL->RWL_ReadWriteBlock); +} + +VOID +ReleaseReadLock(PREAD_WRITE_LOCK pRWL) +{ + + if (InterlockedDecrement(&pRWL->RWL_ReaderCount) < 0) { + SetEvent(pRWL->RWL_ReaderDoneEvent); + } +} + +VOID +AcquireWriteLock(PREAD_WRITE_LOCK pRWL) +{ + + EnterCriticalSection(&pRWL->RWL_ReadWriteBlock); + if (InterlockedDecrement(&pRWL->RWL_ReaderCount) >= 0) { + WaitForSingleObject(pRWL->RWL_ReaderDoneEvent, INFINITE); + } +} + +VOID +ReleaseWriteLock(PREAD_WRITE_LOCK pRWL) +{ + + InterlockedIncrement(&pRWL->RWL_ReaderCount); + LeaveCriticalSection(&(pRWL)->RWL_ReadWriteBlock); +} + diff --git a/xorp/contrib/xorprtm/xorprtm/sync.h b/xorp/contrib/xorprtm/xorprtm/sync.h new file mode 100644 index 0000000..706e333 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/sync.h @@ -0,0 +1,145 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +/* + * $XORP: xorp/contrib/win32/xorprtm/sync.h,v 1.7 2008/10/02 21:56:41 bms Exp $ + */ + +/* + * This file is derived from code which is under the following copyright: + * + * Copyright (c) 1999 - 2000 Microsoft Corporation. + * + */ + +#ifndef _SYNC_H_ +#define _SYNC_H_ + +typedef struct _READ_WRITE_LOCK { + CRITICAL_SECTION RWL_ReadWriteBlock; + LONG RWL_ReaderCount; + HANDLE RWL_ReaderDoneEvent; +} READ_WRITE_LOCK, *PREAD_WRITE_LOCK; + +DWORD +CreateReadWriteLock( + PREAD_WRITE_LOCK pRWL); + +VOID +DeleteReadWriteLock( + PREAD_WRITE_LOCK pRWL); + +VOID +AcquireReadLock( + PREAD_WRITE_LOCK pRWL); + +VOID +ReleaseReadLock( + PREAD_WRITE_LOCK pRWL); + +VOID +AcquireWriteLock( + PREAD_WRITE_LOCK pRWL); + +VOID +ReleaseWriteLock( + PREAD_WRITE_LOCK pRWL); + +#define CREATE_READ_WRITE_LOCK(pRWL) \ + CreateReadWriteLock(pRWL) +#define DELETE_READ_WRITE_LOCK(pRWL) \ + DeleteReadWriteLock(pRWL) +#define READ_WRITE_LOCK_CREATED(pRWL) \ + ((pRWL)->RWL_ReaderDoneEvent != NULL) + +#define ACQUIRE_READ_LOCK(pRWL) \ + AcquireReadLock(pRWL) +#define RELEASE_READ_LOCK(pRWL) \ + ReleaseReadLock(pRWL) +#define ACQUIRE_WRITE_LOCK(pRWL) \ + AcquireWriteLock(pRWL) +#define RELEASE_WRITE_LOCK(pRWL) \ + ReleaseWriteLock(pRWL) + +#define WRITE_LOCK_TO_READ_LOCK(pRWL) \ +{ \ + ACQUIRE_READ_LOCK(pRWL); \ + RELEASE_WRITE_LOCK(pRWL); \ +} + + +typedef struct _LOCKED_LIST { + CRITICAL_SECTION lock; + LIST_ENTRY head; + DWORD created; +} LOCKED_LIST, *PLOCKED_LIST; + +#define INITIALIZE_LOCKED_LIST(pLL) \ +{ \ + do \ + { \ + __try { \ + InitializeCriticalSection(&((pLL)->lock)); \ + } \ + __except (EXCEPTION_EXECUTE_HANDLER) { \ + break; \ + } \ + InitializeListHead(&((pLL)->head)); \ + (pLL)->created = 0x12345678; \ + } while (FALSE); \ +} + +#define LOCKED_LIST_INITIALIZED(pLL) \ + ((pLL)->created == 0x12345678) + +#define DELETE_LOCKED_LIST(pLL, FreeFunction) \ +{ \ + (pLL)->created = 0; \ + FreeList(&((pLL)->head), FreeFunction); \ + DeleteCriticalSection(&(pLL)->lock); \ +} + +#define ACQUIRE_LIST_LOCK(pLL) \ + EnterCriticalSection(&(pLL)->lock) + +#define RELEASE_LIST_LOCK(pLL) \ + LeaveCriticalSection(&(pLL)->lock) + + + +#define LOCKED_QUEUE LOCKED_LIST +#define PLOCKED_QUEUE PLOCKED_LIST + + +#define INITIALIZE_LOCKED_QUEUE(pLQ) \ + INITIALIZE_LOCKED_LIST(pLQ) +#define LOCKED_QUEUE_INITIALIZED(pLQ) \ + LOCKED_LIST_INITIALIZED(pLQ) +#define DELETE_LOCKED_QUEUE(pLQ, FreeFunction) \ + DELETE_LOCKED_LIST(pLQ, FreeFunction) +#define ACQUIRE_QUEUE_LOCK(pLQ) \ + ACQUIRE_LIST_LOCK(pLQ) +#define RELEASE_QUEUE_LOCK(pLQ) \ + RELEASE_LIST_LOCK(pLQ) + + +#endif diff --git a/xorp/contrib/xorprtm/xorprtm/test_monitor.c b/xorp/contrib/xorprtm/xorprtm/test_monitor.c new file mode 100644 index 0000000..3d100f4 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/test_monitor.c @@ -0,0 +1,98 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +#ident "$XORP: xorp/contrib/win32/xorprtm/test_monitor.c,v 1.7 2008/10/02 21:56:41 bms Exp $" + +/* + * test pipe client program + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "bsdroute.h" /* XXX */ + +#include "xorprtm.h" + +extern void print_rtmsg(struct rt_msghdr *, int); /* XXX client_rtmsg.c */ + +void +monitor(void) +{ + int n; + int result; + int wsize; + time_t now; + HANDLE hPipe; + char msg[2048]; + DWORD dwErr; + + if (!WaitNamedPipeA(XORPRTM_PIPENAME, NMPWAIT_USE_DEFAULT_WAIT)) { + fprintf(stderr, "No named pipe instances available.\n"); + return; + } + + hPipe = CreateFileA(XORPRTM_PIPENAME, + GENERIC_READ | GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, 0, NULL); + if (hPipe == INVALID_HANDLE_VALUE) { + result = GetLastError(); + fprintf(stderr, "error opening pipe: %d\n", result); + return; + } + + fprintf(stderr, "connected\n"); + /* + * Block the thread and read a message at a time, just + * like the monitor option of BSD's route(8) command. + */ + for (;;) { + dwErr = ReadFile(hPipe, msg, sizeof(msg), &n, NULL); + if (dwErr == 0) { + fprintf(stderr, "error %d reading from pipe\n", + GetLastError()); + break; + } + now = time(NULL); + (void) fprintf(stderr, "\ngot message of size %d on %s", n, + ctime(&now)); + print_rtmsg((struct rt_msghdr *) msg, n); + fflush(stdout); + } + + fprintf(stderr, "done\n"); + CloseHandle(hPipe); +} + +int +main(int argc, char *argv[]) +{ + monitor(); + exit(0); +} diff --git a/xorp/contrib/xorprtm/xorprtm/test_routeadd.c b/xorp/contrib/xorprtm/xorprtm/test_routeadd.c new file mode 100644 index 0000000..29ee842 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/test_routeadd.c @@ -0,0 +1,126 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +#ident "$XORP: xorp/contrib/win32/xorprtm/test_routeadd.c,v 1.7 2008/10/02 21:56:41 bms Exp $" + +/* + * test pipe client program + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "bsdroute.h" /* XXX */ + +#include "xorprtm.h" + +void +try_add_route(void) +{ + DWORD result; + HANDLE h_pipe; + struct rt_msghdr *msg; + struct sockaddr_storage *pss; + struct sockaddr_in *psin; + int msgsize; + int nbytes; + int i; + + if (!WaitNamedPipeA(XORPRTM_PIPENAME, NMPWAIT_USE_DEFAULT_WAIT)) { + fprintf(stderr, "No named pipe instances available.\n"); + return; + } + + h_pipe = CreateFileA(XORPRTM_PIPENAME, GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_EXISTING, 0, NULL); + if (h_pipe == INVALID_HANDLE_VALUE) { + result = GetLastError(); + fprintf(stderr, "error opening pipe: %d\n", result); + return; + } + + fprintf(stderr, "connected\n"); + + msgsize = sizeof(*msg) + (sizeof(struct sockaddr_storage) * 3); + msg = malloc(msgsize); + if (msg == NULL) { + fprintf(stderr, "cannot allocate routing socket message\n"); + CloseHandle(h_pipe); + return; + } + + ZeroMemory(msg, msgsize); + + /* Fill out routing message header */ + msg->rtm_type = RTM_ADD; + msg->rtm_msglen = msgsize; + msg->rtm_version = RTM_VERSION; + msg->rtm_addrs |= RTA_DST | RTA_NETMASK | RTA_GATEWAY; + + pss = (struct sockaddr_storage *)(msg + 1); + + /* Fill out destination XXX 192.0.2.0 in little endian */ + psin = (struct sockaddr_in *)pss; + psin->sin_family = AF_INET; + psin->sin_addr.s_addr = 0x000200C0; + + /* Fill out next-hop XXX 192.168.123.6 in little endian */ + psin = (struct sockaddr_in *)++pss; + psin->sin_family = AF_INET; + psin->sin_addr.s_addr = 0x067BA8C0; + + /* Fill out netmask XXX 255.255.255.0 in little endian */ + psin = (struct sockaddr_in *)++pss; + psin->sin_family = AF_INET; + psin->sin_addr.s_addr = 0x00FFFFFF; + + /* Try to add a route 3 times to test callbacks */ + for (i = 0; i < 3; i++) { + fprintf(stderr, "attempting to add a route\n", GetLastError()); + result = WriteFile(h_pipe, msg, msgsize, &nbytes, NULL); + if (result == 0) { + fprintf(stderr, "error %d writing to pipe\n", GetLastError()); + } else { + fprintf(stderr, "sent message %d\n", i); + } + + /* XXX: TODO: Wait for the 'kernel''s reply. */ + } + fprintf(stderr, "done\n"); + + CloseHandle(h_pipe); + free(msg); +} + +int +main(int argc, char *argv[]) +{ + try_add_route(); + exit(0); +} diff --git a/xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c b/xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c new file mode 100644 index 0000000..c030a9c --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c @@ -0,0 +1,199 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +#ident "$XORP: xorp/contrib/win32/xorprtm/test_routeadddelete.c,v 1.7 2008/10/02 21:56:41 bms Exp $" + +/* + * test pipe client program + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "bsdroute.h" /* XXX */ + +#include "xorprtm.h" + +extern void print_rtmsg(struct rt_msghdr *, int); /* XXX client_rtmsg.c */ + +void +try_add_route_with_wait_and_delete(void) +{ + DWORD result; + HANDLE h_pipe; + struct rt_msghdr *msg; + struct rt_msghdr *dmsg; + struct sockaddr_storage *pss; + struct sockaddr_in *psin; + int msgsize; + int nbytes; + int i; + + if (!WaitNamedPipeA(XORPRTM_PIPENAME, NMPWAIT_USE_DEFAULT_WAIT)) { + fprintf(stderr, "No named pipe instances available.\n"); + return; + } + + h_pipe = CreateFileA(XORPRTM_PIPENAME, GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_EXISTING, 0, NULL); + if (h_pipe == INVALID_HANDLE_VALUE) { + result = GetLastError(); + fprintf(stderr, "error opening pipe: %d\n", result); + return; + } + + fprintf(stderr, "connected\n"); + + msgsize = sizeof(*msg) + (sizeof(struct sockaddr_storage) * 3); + msg = malloc(msgsize); + if (msg == NULL) { + fprintf(stderr, "cannot allocate routing socket message\n"); + CloseHandle(h_pipe); + return; + } + + dmsg = malloc(msgsize); + if (dmsg == NULL) { + fprintf(stderr, "cannot allocate routing socket message\n"); + free(msg); + CloseHandle(h_pipe); + return; + } + + ZeroMemory(msg, msgsize); + + /* Fill out routing message header */ + msg->rtm_type = RTM_ADD; + msg->rtm_msglen = msgsize; + msg->rtm_version = RTM_VERSION; + msg->rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK; + msg->rtm_pid = GetCurrentProcessId(); + msg->rtm_seq = 100; + + pss = (struct sockaddr_storage *)(msg + 1); + + /* Fill out destination XXX 192.0.2.0 in little endian */ + psin = (struct sockaddr_in *)pss; + psin->sin_family = AF_INET; + psin->sin_addr.s_addr = 0x000200C0; + + /* Fill out next-hop XXX 192.168.123.6 in little endian */ + psin = (struct sockaddr_in *)++pss; + psin->sin_family = AF_INET; + psin->sin_addr.s_addr = 0x067BA8C0; + + /* Fill out netmask XXX 255.255.255.0 in little endian */ + psin = (struct sockaddr_in *)++pss; + psin->sin_family = AF_INET; + psin->sin_addr.s_addr = 0x00FFFFFF; + + /* Fill out deletion message header -- a copy with tweaks. */ + ZeroMemory(dmsg, msgsize); + dmsg->rtm_type = RTM_DELETE; + dmsg->rtm_msglen = msgsize - sizeof(struct sockaddr_storage); + dmsg->rtm_version = RTM_VERSION; + dmsg->rtm_addrs = RTA_DST | RTA_NETMASK; + dmsg->rtm_pid = GetCurrentProcessId(); + dmsg->rtm_seq = 100; + + pss = (struct sockaddr_storage *)(dmsg + 1); + /* Fill out destination XXX 192.0.2.0 in little endian */ + psin = (struct sockaddr_in *)pss; + psin->sin_family = AF_INET; + psin->sin_addr.s_addr = 0x000200C0; + /* Fill out netmask XXX 255.255.255.0 in little endian */ + psin = (struct sockaddr_in *)++pss; + psin->sin_family = AF_INET; + psin->sin_addr.s_addr = 0x00FFFFFF; + + /* Try to add a route 3 times to test callbacks */ + i = 0; + do { + fprintf(stderr, "attempting to add a route\n", GetLastError()); + result = WriteFile(h_pipe, msg, msgsize, &nbytes, NULL); + if (result == 0) { + fprintf(stderr, "error %d writing to pipe\n", GetLastError()); + break; + } else { + fprintf(stderr, "sent request %d\n", i); + print_rtmsg(msg, nbytes); + } + + ZeroMemory(msg, msgsize); + + /* Block and read a single reply. */ + /* XXX 'msg' is reused twice for reading replies to both + * RTM_ADD and RTM_DELTE commands. */ + result = ReadFile(h_pipe, msg, msgsize, &nbytes, NULL); + if (result == 0) { + fprintf(stderr, "error %d reading from pipe\n", GetLastError()); + break; + } else { + fprintf(stderr, "got reply %d, printing\n", i); + print_rtmsg(msg, nbytes); + } + + fprintf(stderr, "sleeping 4 seconds.\n"); + Sleep(4000); + + fprintf(stderr, "attempting to delete a route\n", GetLastError()); + result = WriteFile(h_pipe, dmsg, dmsg->rtm_msglen, &nbytes, NULL); + if (result == 0) { + fprintf(stderr, "error %d writing to pipe\n", GetLastError()); + break; + } else { + fprintf(stderr, "sent request %d\n", i); + print_rtmsg(dmsg, nbytes); + } + + ZeroMemory(dmsg, msgsize); + + /* Block and read a single reply. */ + result = ReadFile(h_pipe, dmsg, msgsize, &nbytes, NULL); + if (result == 0) { + fprintf(stderr, "error %d reading from pipe\n", GetLastError()); + break; + } else { + fprintf(stderr, "got reply %d, printing\n", i); + print_rtmsg(dmsg, nbytes); + } + + } while (0); + fprintf(stderr, "done\n"); + + CloseHandle(h_pipe); + free(msg); +} + +int +main(int argc, char *argv[]) +{ + try_add_route_with_wait_and_delete(); + exit(0); +} diff --git a/xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c b/xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c new file mode 100644 index 0000000..c90ba29 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c @@ -0,0 +1,138 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +#ident "$XORP: xorp/contrib/win32/xorprtm/test_routeaddwait.c,v 1.7 2008/10/02 21:56:41 bms Exp $" + +/* + * test pipe client program + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "bsdroute.h" /* XXX */ + +#include "xorprtm.h" + +extern void print_rtmsg(struct rt_msghdr *, int); /* XXX client_rtmsg.c */ + +void +try_add_route_with_wait(void) +{ + DWORD result; + HANDLE h_pipe; + struct rt_msghdr *msg; + struct sockaddr_storage *pss; + struct sockaddr_in *psin; + int msgsize; + int nbytes; + int i; + + if (!WaitNamedPipeA(XORPRTM_PIPENAME, NMPWAIT_USE_DEFAULT_WAIT)) { + fprintf(stderr, "No named pipe instances available.\n"); + return; + } + + h_pipe = CreateFileA(XORPRTM_PIPENAME, GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_EXISTING, 0, NULL); + if (h_pipe == INVALID_HANDLE_VALUE) { + result = GetLastError(); + fprintf(stderr, "error opening pipe: %d\n", result); + return; + } + + fprintf(stderr, "connected\n"); + + msgsize = sizeof(*msg) + (sizeof(struct sockaddr_storage) * 3); + msg = malloc(msgsize); + if (msg == NULL) { + fprintf(stderr, "cannot allocate routing socket message\n"); + CloseHandle(h_pipe); + return; + } + + ZeroMemory(msg, msgsize); + + /* Fill out routing message header */ + msg->rtm_type = RTM_ADD; + msg->rtm_msglen = msgsize; + msg->rtm_version = RTM_VERSION; + msg->rtm_addrs |= RTA_DST | RTA_NETMASK | RTA_GATEWAY; + + msg->rtm_pid = GetCurrentProcessId(); + + pss = (struct sockaddr_storage *)(msg + 1); + + /* Fill out destination XXX 192.0.2.0 in little endian */ + psin = (struct sockaddr_in *)pss; + psin->sin_family = AF_INET; + psin->sin_addr.s_addr = 0x000200C0; + + /* Fill out next-hop XXX 192.168.123.6 in little endian */ + psin = (struct sockaddr_in *)++pss; + psin->sin_family = AF_INET; + psin->sin_addr.s_addr = 0x067BA8C0; + + /* Fill out netmask XXX 255.255.255.0 in little endian */ + psin = (struct sockaddr_in *)++pss; + psin->sin_family = AF_INET; + psin->sin_addr.s_addr = 0x00FFFFFF; + + /* Try to add a route 3 times to test callbacks */ + for (i = 0; i < 3; i++) { + fprintf(stderr, "attempting to add a route\n", GetLastError()); + result = WriteFile(h_pipe, msg, msgsize, &nbytes, NULL); + if (result == 0) { + fprintf(stderr, "error %d writing to pipe\n", GetLastError()); + } else { + fprintf(stderr, "sent request %d\n", i); + print_rtmsg(msg, msgsize); + } + + /* Block and read a single reply. */ + result = ReadFile(h_pipe, msg, msgsize, &nbytes, NULL); + if (result == 0) { + fprintf(stderr, "error %d reading from pipe\n", GetLastError()); + } else { + fprintf(stderr, "got reply %d, printing\n", i); + print_rtmsg(msg, msgsize); + } + } + fprintf(stderr, "done\n"); + + CloseHandle(h_pipe); + free(msg); +} + +int +main(int argc, char *argv[]) +{ + try_add_route_with_wait(); + exit(0); +} diff --git a/xorp/contrib/xorprtm/xorprtm/utils.c b/xorp/contrib/xorprtm/xorprtm/utils.c new file mode 100644 index 0000000..027a3cb --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/utils.c @@ -0,0 +1,93 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +#ident "$XORP: xorp/contrib/win32/xorprtm/utils.c,v 1.7 2008/10/02 21:56:41 bms Exp $" + +/* + * This file is derived from code which is under the following copyright: + * + * Copyright (c) 1999 - 2000 Microsoft Corporation. + * + */ + +#include "pchsample.h" +#pragma hdrstop + +BOOL +EnterSubsystemAPI() +{ + BOOL bEntered = FALSE; + + ACQUIRE_WRITE_LOCK(&(g_ce.rwlLock)); + + if (g_ce.iscStatus == XORPRTM_STATUS_RUNNING) { + /* subsystem is running, so continue */ + g_ce.ulActivityCount++; + bEntered = TRUE; + } + + RELEASE_WRITE_LOCK(&(g_ce.rwlLock)); + + return bEntered; +} + +BOOL +EnterSubsystemWorker() +{ + BOOL bEntered = FALSE; + + ACQUIRE_WRITE_LOCK(&(g_ce.rwlLock)); + + do { + /* subsystem is running, so the function may continue */ + if (g_ce.iscStatus == XORPRTM_STATUS_RUNNING) { + bEntered = TRUE; + break; + } + + /* subsystem is not running, but it was, so the function must stop */ + if (g_ce.iscStatus == XORPRTM_STATUS_STOPPING) { + g_ce.ulActivityCount--; + ReleaseSemaphore(g_ce.hActivitySemaphore, 1, NULL); + break; + } + + /* subsystem probably never started. quit. */ + } while (FALSE); + + RELEASE_WRITE_LOCK(&(g_ce.rwlLock)); + + return bEntered; +} + +VOID +LeaveSubsystemWorker() +{ + ACQUIRE_WRITE_LOCK(&(g_ce.rwlLock)); + + g_ce.ulActivityCount--; + if (g_ce.iscStatus == XORPRTM_STATUS_STOPPING) { + ReleaseSemaphore(g_ce.hActivitySemaphore, 1, NULL); + } + + RELEASE_WRITE_LOCK(&(g_ce.rwlLock)); +} diff --git a/xorp/contrib/xorprtm/xorprtm/utils.h b/xorp/contrib/xorprtm/xorprtm/utils.h new file mode 100644 index 0000000..d3a7f9e --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/utils.h @@ -0,0 +1,41 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +/* + * $XORP: xorp/contrib/win32/xorprtm/utils.h,v 1.7 2008/10/02 21:56:41 bms Exp $ + */ + +/* + * This file is derived from code which is under the following copyright: + * + * Copyright (c) 1999 - 2000 Microsoft Corporation. + * + */ + +#ifndef _UTILS_H_ +#define _UTILS_H_ + +BOOL EnterSubsystemAPI(); +BOOL EnterSubsystemWorker(); +VOID LeaveSubsystemWorker(); + +#endif diff --git a/xorp/contrib/xorprtm/xorprtm/xorprtm.c b/xorp/contrib/xorprtm/xorprtm/xorprtm.c new file mode 100644 index 0000000..40112e0 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/xorprtm.c @@ -0,0 +1,1905 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +#ident "$XORP: xorp/contrib/win32/xorprtm/xorprtm.c,v 1.7 2008/10/02 21:56:41 bms Exp $" + +/* XXX: SORT FUNCTIONS IN THIS FILE */ + +/* XXX: RATIONALIZE INCLUDES */ + +#include "pchsample.h" +#include +#pragma hdrstop + +/* XXX: move to headers */ +typedef union _sockunion_t { + struct sockaddr sa; + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + struct sockaddr_storage ss; +} sockunion_t; + +/* XXX: move to headers */ +#define XORPRTM_PIPETIMEOUT 2000 /* 2 seconds */ +#define XORPRTM_RI_PREF 1 +#define XORPRTM_RI_METRIC 20 + +/* XXX: run cproto */ +/* XXX: move to headers */ +pipe_instance_t *pipe_new(void); +void pipe_destroy(pipe_instance_t *pp); +int pipe_listen(pipe_instance_t *pp); +void pipe_disconnect(pipe_instance_t *pp); +void CALLBACK pipe_connect_cb(PVOID lpParameter, BOOLEAN TimerOrWaitFired); +void CALLBACK pipe_read_cb(PVOID lpParameter, BOOLEAN TimerOrWaitFired); +void WINAPI pipe_reread_cb(void *ctx); +void WINAPI pipe_relisten_cb(void *ctx); +DWORD APIENTRY RTM_CallbackEvent (RTM_ENTITY_HANDLE hRtmHandle, RTM_EVENT_TYPE retEvent, PVOID pvContext1, PVOID pvContext2); +int rtm_add_route(struct rt_msghdr *rtm, int msgsize); +void broadcast_pipe_message(void *msg, int msgsize); + +/* + * XXX: The only global variable. + */ +/* XXX: move to headers */ +CONFIGURATION_ENTRY g_ce; + +/* + * Issue a routing socket message for a single changed destination. + */ +DWORD +rtm_send_dest_change(RTM_ENTITY_HANDLE reh, PRTM_DEST_INFO prdi) +{ +#ifdef IPV6_DLL + struct in6_addr dst; + struct in6_addr ip; + struct in6_addr nhip; +#else + struct in_addr dst; + struct in_addr ip; + struct in_addr nhip; +#endif + int i; + int dstprefix; + int nhprefix; + int type; + DWORD result; + + if (!prdi) + return NO_ERROR; + + TRACE1(NETWORK, "RtmDestInfo Destination %p", prdi); + +#ifdef IPV6_DLL + RTM_IPV6_GET_ADDR_AND_LEN(dst.s6_addr, dstprefix, &prdi->DestAddress); +#else + RTM_IPV4_GET_ADDR_AND_LEN(dst.s_addr, dstprefix, &prdi->DestAddress); +#endif + + /* + * Determine the nature of the change; whether a route has + * been added, changed or deleted for the given situation. + * We look only at the unicast routing view. + */ + for (i = 0; i < prdi->NumberOfViews; i++) { + if (prdi->ViewInfo[i].ViewId == RTM_VIEW_ID_UCAST) { +#ifdef IPV6_DLL + /* + * XXX: Don't filter IPv6 routes [yet]. + */ +#else /* IPv4 */ + /* + * Ignore routes to the all-ones broadcast destination. + */ + if ((dst.s_addr == INADDR_BROADCAST && dstprefix == 32)) { + TRACE0(NETWORK, "ignoring all-ones broadcast"); + break; + } +#ifdef notyet + /* + * XXX: Ignore multicast routes (for now). + */ + if (IN4_IS_ADDR_MULTICAST(dst.s_addr)) { + TRACE0(NETWORK, "ignoring multicast route"); + break; + } +#endif /* notyet */ +#endif /* IPV6_DLL */ + if (prdi->ViewInfo[i].NumRoutes == 0) { + TRACE0(NETWORK, "route deleted"); + type = RTM_DELETE; + } else if (prdi->ViewInfo[i].NumRoutes == 1) { + TRACE0(NETWORK, "route added"); + type = RTM_ADD; + } else { + /* + * XXX: The route has multiple next-hops. We do not know + * which next-hop we should send to the FEA, so do not + * process such changes for now. + */ + TRACE1(NETWORK, "route change, dest %d nexthops, no msg", + prdi->ViewInfo[i].NumRoutes); + type = 0; + } + break; /* stop when unicast route view is dealt with. */ + } + } + /* + * Craft a routing socket message based on the changes. + * We only allocate memory here if we require it. + */ + if (type != 0) { + sockunion_t *sa; + struct rt_msghdr *rtm; +#ifdef IPV6_DLL + struct in6_addr nh; +#else + struct in_addr nh; +#endif + int maxmsgsize; + + maxmsgsize = sizeof(struct rt_msghdr) + (sizeof(sockunion_t) * 3); + rtm = malloc(maxmsgsize); + ZeroMemory(rtm, maxmsgsize); + + sa = (sockunion_t *)(rtm + 1); + + rtm->rtm_msglen = maxmsgsize - sizeof(*sa); + rtm->rtm_version = RTM_VERSION; + rtm->rtm_type = type; + rtm->rtm_addrs = RTA_DST | RTA_NETMASK; + + /* Destination */ +#ifdef IPV6_DLL + sa->sin6.sin6_family = AF_INET6; + sa->sin6.sin6_addr = dst; +#else + sa->sin.sin_family = AF_INET; + sa->sin.sin_addr = dst; +#endif + + /* + * Route additions require that we also report the next-hop. + * Perform the necessary RTMv2 incantations to look up the + * next-hop from the destination reported as changed. + * XXX: Better error checking here considered desirable. + */ + if (type == RTM_ADD) { + PRTM_ROUTE_INFO prri; + RTM_NEXTHOP_INFO nhi; + + rtm->rtm_msglen += sizeof(*sa); + rtm->rtm_addrs |= RTA_GATEWAY; + + /* XXX weird heap malloc. */ + MALLOC(&prri, +RTM_SIZE_OF_ROUTE_INFO(g_ce.rrpRtmProfile.MaxNextHopsInRoute), &result); + + result = RtmGetRouteInfo(reh, prdi->ViewInfo[i].Route, prri, NULL); + if (result != NO_ERROR) { + TRACE1(NETWORK, "RtmGetRouteInfo() returns %d", result); + } + + result = RtmGetNextHopInfo(reh, prri->NextHopsList.NextHops[0], + &nhi); + if (result != NO_ERROR) { + TRACE1(ANY, "Error %u getting next hop", result); + } + + /* Gateway */ +#ifdef IPV6_DLL + RTM_IPV6_GET_ADDR_AND_LEN(nhip.s6_addr, nhprefix, + &nhi.NextHopAddress); + ++sa; + sa->sin6.sin6_family = AF_INET6; + sa->sin6.sin6_addr = nhip; +#else + RTM_IPV4_GET_ADDR_AND_LEN(nhip.s_addr, nhprefix, + &nhi.NextHopAddress); + ++sa; + sa->sin.sin_family = AF_INET; + sa->sin.sin_addr = nhip; +#endif /* IPV6_DLL */ + + /* + * Free the next-hop info structures. + */ + (void)RtmReleaseNextHopInfo(reh, &nhi); + (void)RtmReleaseRouteInfo(reh, prri); + FREE(prri); + } + + /* Netmask; comes after gateway in the RTM_ADD case. */ + ++sa; +#ifdef IPV6_DLL + /* XXX: may not be right */ + sa->sin6.sin6_family = AF_INET; + sa->sin6.sin6_addr.s6_addr = RTM_IPV6_MASK_FROM_LEN(dstprefix); +#else + sa->sin.sin_family = AF_INET; + sa->sin.sin_addr.s_addr = RTM_IPV4_MASK_FROM_LEN(dstprefix); +#endif + + broadcast_pipe_message(rtm, rtm->rtm_msglen); + free(rtm); + } + + return NO_ERROR; +} + +/* + * Send a message to all connected listeners. + * + * XXX: The write blocks the current thread. Because RRAS threads + * never enter alertable wait state, we can't use WriteFileEx(). + * We must either block or do the additional accounting for overlapped + * WriteFile(). + * This has a very important consequence: our thread blocks until the + * client thread reads its data or the pipe is disconnected. + */ +void +broadcast_pipe_message(void *msg, int msgsize) +{ + pipe_instance_t *pp; + int i; + int result; + int nbytes; + + for (i = 0; i < PIPE_INSTANCES; i++) { + pp = g_ce.pipes[i]; + if (pp != NULL && pp->state == PIPE_STATE_CONNECTED) { + result = WriteFile(pp->pipe, msg, msgsize, &nbytes, NULL); + if (result == 0) { + result = GetLastError(); + TRACE1(NETWORK, "broadcast: write error %d", result); + if (result == ERROR_PIPE_NOT_CONNECTED || + result == ERROR_NO_DATA || + result == ERROR_BROKEN_PIPE) { + TRACE1(NETWORK, +"broadcast: pipe %p disconnected; reconnecting.", pp->pipe); + /* + * We may be called by a reader thread. To avoid + * introducing loops, we schedule the listen + * operation on another thread. + */ + ResetEvent(pp->revent); + QueueUserWorkItem( +(LPTHREAD_START_ROUTINE)pipe_relisten_cb, (PVOID)pp, WT_EXECUTEINIOTHREAD); + } + } + } + } +} + + +DWORD +ProcessRouteChange (VOID) +{ + DWORD dwErr = NO_ERROR; + RTM_DEST_INFO rdiDestination; /* 1 view registered for change */ + BOOL bDone = FALSE; + UINT uiNumDests; + + if (!ENTER_XORPRTM_API()) { return ERROR_CAN_NOT_COMPLETE; } + + /* loop dequeueing messages until RTM says there are no more left */ + while (!bDone) + { + /* retrieve route changes */ + uiNumDests = 1; + dwErr = RtmGetChangedDests( + g_ce.hRtmHandle, /* my RTMv2 handle */ + g_ce.hRtmNotificationHandle, /* my notification handle */ + &uiNumDests, /* # dest info's required */ + /* g # dest info's supplied */ + &rdiDestination); /* g buffer for dest info's */ + + switch (dwErr) + { + case ERROR_NO_MORE_ITEMS: + bDone = TRUE; + dwErr = NO_ERROR; + if (uiNumDests < 1) + break; + /* else continue below to process the last destination */ + +/* XXX: Does not specify what the change(s) are, just that they */ +/* occurred, on *this destination*. maybe we should figure */ +/* this out? */ + + case NO_ERROR: + rtm_send_dest_change(g_ce.hRtmHandle, &rdiDestination); + + /* release the destination info */ + if (RtmReleaseChangedDests( + g_ce.hRtmHandle, /* my RTMv2 handle */ + g_ce.hRtmNotificationHandle,/* my notif handle */ + uiNumDests, /* 1 */ + &rdiDestination /* released dest info */ + ) != NO_ERROR) + TRACE0(NETWORK, "Error releasing changed dests"); + + break; + + default: + bDone = TRUE; + TRACE1(NETWORK, "Error %u RtmGetChangedDests", dwErr); + break; + } + } /* while */ + + LEAVE_XORPRTM_API(); + + return dwErr; +} + + +/* + * Where we get called by RTMv2 when things happen to the routing table. + */ +DWORD +APIENTRY +RTM_CallbackEvent ( + RTM_ENTITY_HANDLE hRtmHandle, /* registration handle */ + RTM_EVENT_TYPE retEvent, + PVOID pvContext1, + PVOID pvContext2) +{ + DWORD dwErr = NO_ERROR; + + TRACE1(ENTER, "Entering RTM_CallbackEvent: %u", retEvent); + + do /* breakout loop */ + { + UNREFERENCED_PARAMETER(hRtmHandle); + UNREFERENCED_PARAMETER(pvContext1); + UNREFERENCED_PARAMETER(pvContext2); + + /* only route change notifications are processed */ + if (retEvent != RTM_CHANGE_NOTIFICATION) + { + dwErr = ERROR_NOT_SUPPORTED; + break; + } + + dwErr = ProcessRouteChange(); + } while (FALSE); + + TRACE0(LEAVE, "Leaving RTM_CallbackEvent"); + + return dwErr; +} + + +/* + * Create a new instance of a pipe and return a pointer to + * its instance structure. + */ +pipe_instance_t * +pipe_new(void) +{ + pipe_instance_t *npp; + int failed; + DWORD result; + + TRACE0(ENTER, "Entering pipe_new"); + + npp = malloc(sizeof(*npp)); + if (npp == NULL) + return NULL; + ZeroMemory(npp, sizeof(*npp)); + + failed = 1; + + /* XXX buffer management */ + npp->rsize = PIPE_READBUF_SIZE; + npp->state = PIPE_STATE_INIT; + + InitializeCriticalSection(&npp->rcs); + + /* + * Create the event object used to signal connection completion. + */ + npp->cevent = CreateEvent(NULL, FALSE, FALSE, NULL); + if (npp->cevent == NULL) { + result = GetLastError(); + TRACE1(CONFIGURATION, "Error %u creating event", result); + goto fail; + } + npp->cov.hEvent = npp->cevent; + + /* + * Create the event object used to signal read completion. + */ + npp->revent = CreateEvent(NULL, FALSE, FALSE, NULL); + if (npp->revent == NULL) { + result = GetLastError(); + TRACE1(CONFIGURATION, "Error %u creating event", result); + goto fail; + } + npp->rov.hEvent = npp->revent; + + /* + * Create the instance of the named pipe itself. + */ + npp->pipe = CreateNamedPipeA(XORPRTM_PIPENAME, + PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, + PIPE_TYPE_MESSAGE, PIPE_INSTANCES, 0, 0, + XORPRTM_PIPETIMEOUT, NULL); + if (npp->pipe == NULL) { + result = GetLastError(); + TRACE1(CONFIGURATION, "Error %u creating named pipe", result); + goto fail; + } + + failed = 0; +fail: + if (failed) { + pipe_destroy(npp); + npp = NULL; + } + TRACE1(ENTER, "Leaving pipe_new %p", npp); + return (npp); +} + +/* + * XXX: This must be called from primary thread, or lock held if not! + */ +int +pipe_listen(pipe_instance_t *pp) +{ + int retval; + DWORD result; + + retval = -1; + + TRACE1(ENTER, "Entering pipe_listen %p", pp); + + if (pp == NULL || pp->state != PIPE_STATE_INIT) + return (retval); + + /* + * Register a pool thread to wait for pipe connection. + * Clear event state to avoid spurious signals. + */ + ResetEvent(pp->cevent); + result = RegisterWaitForSingleObject(&(pp->cwait), pp->cevent, + pipe_connect_cb, pp, INFINITE, + WT_EXECUTEINIOTHREAD | + WT_EXECUTEONLYONCE); + if (result == 0) { + result = GetLastError(); + TRACE1(CONFIGURATION, "Error %u RegisterWaitForSingleObject()", result); + goto fail; + } + + /* + * Register a pool thread to wait for data to be received on the pipe. + * We don't cause this to be activated until we post a read request + * from within the connection callback. + * XXX: We want the read callback to be called whenever the + * object is signalled, not just once. + */ + ResetEvent(pp->revent); + result = RegisterWaitForSingleObject(&(pp->rwait), pp->revent, + pipe_read_cb, pp, INFINITE, + WT_EXECUTEINIOTHREAD | + WT_EXECUTEONLYONCE); + if (result == 0) { + result = GetLastError(); + TRACE1(CONFIGURATION, "Error %u RegisterWaitForSingleObject()", result); + goto fail; + } + + /* + * Post the connection request. If it returns non-zero, then the + * connection attempt is pending and the thread will be signalled + * when complete. If it returns zero, then there's a problem. + * ERROR_NO_DATA means the client disconnected, but we didn't + * call DisconnectNamedPipe(). + * ConnectNamedPipe() does not reset the event object associated + * with the OVERLAPPED parameter. + */ + result = ConnectNamedPipe(pp->pipe, &pp->cov); + if (result == 0) { + result = GetLastError(); + if (result == ERROR_PIPE_LISTENING) { + TRACE0(NETWORK, "Error: listening; Reconnecting named pipe"); + result = ConnectNamedPipe(pp->pipe, &pp->cov); + } + if (result == ERROR_PIPE_CONNECTED) { + TRACE0(NETWORK, "Error: named pipe already connected"); + goto fail; + } + if (result == ERROR_NO_DATA) { + TRACE0(NETWORK, "Error: previous session not cleaned up"); + goto fail; + } + } + + pp->state = PIPE_STATE_LISTEN; + + retval = 0; +fail: + if (retval == -1) { + if (pp->cwait != NULL) { + UnregisterWaitEx(pp->cwait, pp->cevent); + ResetEvent(pp->cevent); + pp->cwait = NULL; + } + if (pp->rwait != NULL) { + UnregisterWaitEx(pp->rwait, pp->revent); + ResetEvent(pp->revent); + pp->rwait = NULL; + } + } + TRACE1(ENTER, "Leaving pipe_listen", pp); + return (retval); +} + +/* + * Disconnect, but do not close, a pipe handle; and deregister + * any pending waiter threads from its event handles. + * + * XXX: This must be called from primary thread, or lock held if not! + */ +void +pipe_disconnect(pipe_instance_t *pp) +{ + + TRACE0(ENTER, "Entering pipe_disconnect"); + + if (pp == NULL) + return; + /* + * Cancel pending I/O before deregistering the callback, + * and disconnect the pipe, to avoid race conditions. + * We also reset the event(s) to avoid being signalled for + * things which haven't actually happened yet. + * + * XXX: To avoid races during shutdown, we may have to + * NULL out the second argument to UnregisterWaitEx(). + * We can't, however, do that from a service thread. + */ + if (pp->cwait != NULL) { + UnregisterWaitEx(pp->cwait, pp->cevent); + ResetEvent(pp->cevent); + pp->cwait = NULL; + } + if (pp->rwait != NULL) { + UnregisterWaitEx(pp->rwait, pp->revent); + ResetEvent(pp->revent); + pp->rwait = NULL; + } + + if (pp->pipe != NULL) { + CancelIo(pp->pipe); + if (pp->state == PIPE_STATE_CONNECTED || + pp->state == PIPE_STATE_LISTEN) { + DisconnectNamedPipe(pp->pipe); + } + } + + pp->state = PIPE_STATE_INIT; + + TRACE0(ENTER, "Leaving pipe_disconnect"); +} + +void +pipe_destroy(pipe_instance_t *pp) +{ + + TRACE0(ENTER, "Leaving pipe_destroy"); + + if (pp == NULL) + return; + + pipe_disconnect(pp); + + if (pp->revent != NULL) { + CloseHandle(pp->revent); + pp->rov.hEvent = pp->revent = NULL; + } + if (pp->cevent != NULL) { + CloseHandle(pp->cevent); + pp->cov.hEvent = pp->cevent = NULL; + } + if (pp->pipe != NULL) { + CloseHandle(pp->pipe); + pp->pipe = NULL; + } + + DeleteCriticalSection(&pp->rcs); + + free(pp); + + TRACE0(ENTER, "Leaving pipe_destroy"); +} + +void CALLBACK +pipe_connect_cb(PVOID lpParameter, BOOLEAN TimerOrWaitFired) +{ + pipe_instance_t *pp; + DWORD result; + DWORD nbytes; + + pp = (pipe_instance_t *)lpParameter; + EnterCriticalSection(&pp->rcs); + TRACE1(ENTER, "Entering pipe_connect_cb %p", lpParameter); + + /* XXX CHECK STATE */ + + if (pp->state != PIPE_STATE_LISTEN) { + TRACE0(NETWORK, "WARNING: pipe state is not LISTEN"); + } + + /* + * If you forgot to reset the event object, the following call + * will block until the connection is actually made. We wish to + * run as lockless as possible, so do not block the service thread. + */ + /* + result = GetOverlappedResult(pp->pipe, &pp->cov, &nbytes, TRUE); + */ + + pp->state = PIPE_STATE_CONNECTED; + + /* + * Post an overlapped read request to capture a message from + * the client. + */ + result = ReadFile(pp->pipe, pp->rbuf, pp->rsize, NULL, &pp->rov); + if (result == 0) { + result = GetLastError(); + if (result != ERROR_IO_PENDING) { + TRACE1(ANY, "WARNING: pipe_connect_cb read returned %d", result); + } + } + + /* XXX: We need to be able to deal with errors immediately to + * avoid races. */ + TRACE0(ENTER, "Leaving pipe_connect_cb"); + LeaveCriticalSection(&pp->rcs); +} + +/* + * Callback which invokes pipe_listen(). + * + * When we are in pipe_read_cb(), we may try to call pipe_listen() + * (after tearing down an old connection). This can cause an infinite + * loop as they execute in the same helper thread, and pipe_listen() + * will try to reschedule pipe_read_cb(). + * Therefore, use QueueUserWorkItem() to make sure that pipe_listen() + * is invoked after a context switch. + */ +void WINAPI +pipe_relisten_cb(void *ctx) +{ + pipe_instance_t *pp; + + pp = (pipe_instance_t *)ctx; + EnterCriticalSection(&pp->rcs); + TRACE1(ENTER, "Entering pipe_relisten_cb %p", ctx); + + pipe_disconnect(pp); + pipe_listen(pp); + + TRACE0(ENTER, "Leaving pipe_relisten_cb"); + LeaveCriticalSection(&pp->rcs); +} + +void WINAPI +pipe_reread_cb(void *ctx) +{ + pipe_instance_t *pp; + DWORD result; + int failed; + + pp = (pipe_instance_t *)ctx; + EnterCriticalSection(&pp->rcs); + TRACE1(ENTER, "Entering pipe_reread_cb %p", ctx); + + failed = 0; + + if (pp->state != PIPE_STATE_CONNECTED) { + TRACE0(NETWORK, "WARNING: not PIPE_STATE_CONNECTED"); + } + + /* + * Tear down and wire up read thread callback again. + * This is probably inefficient. + */ + UnregisterWaitEx(pp->rwait, pp->revent); + ResetEvent(pp->revent); /* XXX ReadFile() should do this for us? */ + pp->rwait = NULL; + /* + * Post a new read request. Deal with fatal errors. + */ + result = ReadFile(pp->pipe, pp->rbuf, pp->rsize, NULL, &pp->rov); + if (result == 0) { + result = GetLastError(); + if (result != ERROR_IO_PENDING) { + TRACE1(ANY, "WARNING: pipe_reread_cb read returned %d", result); + } + if (result == ERROR_BROKEN_PIPE) { + failed = 1; + goto fail; + } + } + /* + * Now, and only now, do we kick off the read thread, in order + * to avoid being preempted if the client disconnects. + */ + result = RegisterWaitForSingleObject(&(pp->rwait), pp->revent, + pipe_read_cb, pp, INFINITE, + WT_EXECUTEINIOTHREAD | + WT_EXECUTEONLYONCE); + if (result == 0) { + result = GetLastError(); + TRACE1(CONFIGURATION, "Error %u RegisterWaitForSingleObject()", result); + failed = 1; + } + +fail: + /* + * If a fatal error occurred, disconnect the pipe client, and + * listen for a new connection on this instance. + */ + if (failed) { + ResetEvent(pp->revent); + QueueUserWorkItem( +(LPTHREAD_START_ROUTINE)pipe_relisten_cb, (PVOID)pp, WT_EXECUTEINIOTHREAD); + } +out: + TRACE0(ENTER, "Leaving pipe_reread_cb"); + LeaveCriticalSection(&pp->rcs); +} + +void CALLBACK +pipe_read_cb(PVOID lpParameter, BOOLEAN TimerOrWaitFired) +{ + struct rt_msghdr *rtm; + pipe_instance_t *pp; + DWORD result; + DWORD nbytes; + + pp = (pipe_instance_t *)lpParameter; + EnterCriticalSection(&pp->rcs); + TRACE1(ENTER, "Entering pipe_read_cb %p", lpParameter); + + if (pp->state != PIPE_STATE_CONNECTED) { + TRACE0(NETWORK, "WARNING: not PIPE_STATE_CONNECTED, bailing."); + /* + * XXX: Is something racy, or is it just me? + * Try to avoid deadlocking by returning if we + * got called when we weren't connected. + */ + goto out; + } + + result = GetOverlappedResult(pp->pipe, &pp->rov, &nbytes, TRUE); + if (result == 0) { + result = GetLastError(); + TRACE1(NETWORK, "WARNING: pipe_read_cb read returned %d", result); + if (result == ERROR_BROKEN_PIPE) { + /* + * We must queue the new listen on a separate thread to + * avoid infinite recursion. + */ + TRACE0(NETWORK, "Posting listen again."); + ResetEvent(pp->revent); + QueueUserWorkItem( +(LPTHREAD_START_ROUTINE)pipe_relisten_cb, (PVOID)pp, WT_EXECUTEINIOTHREAD); + goto out; + } + } + + TRACE1(NETWORK, "Read %d bytes from named pipe.", nbytes); + + /* + * Perform sanity checks on input message. + * XXX: We should use a more appropriate errno value. + * We use -1 as ENOBUFS, etc are not part of the namespace. + */ + rtm = (struct rt_msghdr *)&pp->rbuf[0]; + if (rtm->rtm_version != RTM_VERSION) { + TRACE1(NETWORK, "Invalid rtm_version %d, dropping.", rtm->rtm_version); + goto drop; + } + /* + * Sanity check size. + */ + if (rtm->rtm_msglen > nbytes || + nbytes < sizeof(struct rt_msghdr)) { + TRACE1(NETWORK, "Invalid rtm_msglen %d, dropping.", rtm->rtm_msglen); + rtm->rtm_errno = -1; + goto drop; + } + if (rtm->rtm_pid == 0) { + TRACE1(NETWORK, "Invalid rtm_pid %d, dropping.", rtm->rtm_pid); + rtm->rtm_errno = -1; + goto bounce; + } + + switch (rtm->rtm_type) { + case RTM_ADD: + result = rtm_add_route(rtm, nbytes); + if (result == 0) { + TRACE0(NETWORK, "route added successfully"); + } else { + TRACE0(NETWORK, "failed to add route"); + } + rtm->rtm_errno = result; + break; + + case RTM_DELETE: + result = rtm_delete_route(rtm, nbytes); + if (result == 0) { + TRACE0(NETWORK, "route deleted successfully"); + } else { + TRACE0(NETWORK, "failed to delete route"); + } + rtm->rtm_errno = result; + break; + + default: + TRACE1(NETWORK, "Invalid rtm_type %d, dropping.", rtm->rtm_type); + rtm->rtm_errno = -1; + break; + } + +bounce: + /* + * There is currently no analogue of the BSD SO_LOOPBACK option. + * XXX: Normally processes will hear their own messages echoed across + * the routing socket emulation pipe. Because the broadcast technique + * uses blocking NT I/O, processes must read back their own message + * after issuing it. + */ + broadcast_pipe_message(pp->rbuf, nbytes); +drop: + TRACE0(NETWORK, "Posting read again."); + ResetEvent(pp->revent); + QueueUserWorkItem( +(LPTHREAD_START_ROUTINE)pipe_reread_cb, (PVOID)pp, WT_EXECUTEINIOTHREAD); + +out: + TRACE0(ENTER, "Leaving pipe_read_cb"); + LeaveCriticalSection(&pp->rcs); +} + + +static +VOID +FreeEventEntry ( + PQUEUE_ENTRY pqeEntry) +{ + EE_Destroy(CONTAINING_RECORD(pqeEntry, EVENT_ENTRY, qeEventQueueLink)); +} + + + +DWORD +EE_Create ( + ROUTING_PROTOCOL_EVENTS rpeEvent, + MESSAGE mMessage, + PEVENT_ENTRY *ppeeEventEntry) +{ + DWORD dwErr = NO_ERROR; + PEVENT_ENTRY peeEntry; /* scratch */ + + /* validate parameters */ + if (!ppeeEventEntry) + return ERROR_INVALID_PARAMETER; + + *ppeeEventEntry = NULL; + + /* allocate the interface entry structure */ + MALLOC(&peeEntry, sizeof(EVENT_ENTRY), &dwErr); + if (dwErr != NO_ERROR) + return dwErr; + + /* initialize various fields */ + InitializeQueueHead(&(peeEntry->qeEventQueueLink)); + + peeEntry->rpeEvent = rpeEvent; + peeEntry->mMessage = mMessage; + + *ppeeEventEntry = peeEntry; + return dwErr; +} + + + +DWORD +EE_Destroy ( + PEVENT_ENTRY peeEventEntry) +{ + if (!peeEventEntry) + return NO_ERROR; + + FREE(peeEventEntry); + + return NO_ERROR; +} + + +DWORD +EnqueueEvent( + ROUTING_PROTOCOL_EVENTS rpeEvent, + MESSAGE mMessage) +{ + DWORD dwErr = NO_ERROR; + PEVENT_ENTRY peeEntry = NULL; + + dwErr = EE_Create(rpeEvent, mMessage, &peeEntry); + /* destroyed in EE_DequeueEvent */ + + if (dwErr == NO_ERROR) + { + ACQUIRE_QUEUE_LOCK(&(g_ce.lqEventQueue)); + + Enqueue(&(g_ce.lqEventQueue.head), &(peeEntry->qeEventQueueLink)); + + RELEASE_QUEUE_LOCK(&(g_ce.lqEventQueue)); + } + + return dwErr; +} + +DWORD +DequeueEvent( + ROUTING_PROTOCOL_EVENTS *prpeEvent, + MESSAGE *pmMessage) +{ + DWORD dwErr = NO_ERROR; + PQUEUE_ENTRY pqe = NULL; + PEVENT_ENTRY pee = NULL; + + ACQUIRE_QUEUE_LOCK(&(g_ce.lqEventQueue)); + + do { + if (IsQueueEmpty(&(g_ce.lqEventQueue.head))) { + dwErr = ERROR_NO_MORE_ITEMS; + TRACE0(CONFIGURATION, "No events in the queue."); + break; + } + + pqe = Dequeue(&(g_ce.lqEventQueue.head)); + pee = CONTAINING_RECORD(pqe, EVENT_ENTRY, qeEventQueueLink); + *(prpeEvent) = pee->rpeEvent; + *(pmMessage) = pee->mMessage; + + /* created in EE_EnqueueEvent */ + EE_Destroy(pee); + pee = NULL; + } while (FALSE); + + RELEASE_QUEUE_LOCK(&(g_ce.lqEventQueue)); + + return dwErr; +} + +DWORD +CE_Create ( + PCONFIGURATION_ENTRY pce) +{ + DWORD dwErr = NO_ERROR; + + /* initialize to default values */ + ZeroMemory(pce, sizeof(CONFIGURATION_ENTRY)); + pce->dwTraceID = INVALID_TRACEID; + + do { + /* initialize the read-write lock */ + CREATE_READ_WRITE_LOCK(&(pce->rwlLock)); + if (!READ_WRITE_LOCK_CREATED(&(pce->rwlLock))) { + dwErr = GetLastError(); + + TRACE1(CONFIGURATION, "Error %u creating read-write-lock", dwErr); + + break; + } + + /* initialize the global heap */ + pce->hGlobalHeap = HeapCreate(0, 0, 0); + if (pce->hGlobalHeap == NULL) { + dwErr = GetLastError(); + TRACE1(CONFIGURATION, "Error %u creating global heap", dwErr); + + break; + } + + /* + * Initialize the count of threads that are active in subsystem. + * Create the semaphore released by each thread when it is done; + * required for clean stop to the protocol. + */ + pce->ulActivityCount = 0; + pce->hActivitySemaphore = CreateSemaphore(NULL, 0, 0xfffffff, NULL); + if (pce->hActivitySemaphore == NULL) { + dwErr = GetLastError(); + TRACE1(CONFIGURATION, "Error %u creating semaphore", dwErr); + break; + } + + /* Logging & Tracing Information */ + pce->dwTraceID = TraceRegister(XORPRTM_TRACENAME); + + /* Event Queue */ + INITIALIZE_LOCKED_QUEUE(&(pce->lqEventQueue)); + if (!LOCKED_QUEUE_INITIALIZED(&(pce->lqEventQueue))) { + dwErr = GetLastError(); + TRACE1(CONFIGURATION, "Error %u initializing locked queue", dwErr); + break; + } + + /* Protocol State */ + pce->iscStatus = XORPRTM_STATUS_STOPPED; + + } while (FALSE); + + if (dwErr != NO_ERROR) { + /* something went wrong, so cleanup. */ + TRACE0(CONFIGURATION, "Failed to create configuration entry"); + CE_Destroy(pce); + } + + return dwErr; +} + +DWORD +CE_Destroy ( + PCONFIGURATION_ENTRY pce) +{ + /* Event Queue */ + if (LOCKED_QUEUE_INITIALIZED(&(pce->lqEventQueue))) + DELETE_LOCKED_QUEUE((&(pce->lqEventQueue)), FreeEventEntry); + + /* Logging & Tracing Information */ + if (pce->dwTraceID != INVALID_TRACEID) { + TraceDeregister(pce->dwTraceID); + pce->dwTraceID = INVALID_TRACEID; + } + + /* destroy the semaphore released by each thread when it is done */ + if (pce->hActivitySemaphore != NULL) { + CloseHandle(pce->hActivitySemaphore); + pce->hActivitySemaphore = NULL; + } + + if (pce->hGlobalHeap != NULL) { + HeapDestroy(pce->hGlobalHeap); + pce->hGlobalHeap = NULL; + } + + /* delete the read-write lock */ + if (READ_WRITE_LOCK_CREATED(&(pce->rwlLock))) + DELETE_READ_WRITE_LOCK(&(pce->rwlLock)); + + return NO_ERROR; +} + +DWORD +CE_Initialize ( + PCONFIGURATION_ENTRY pce, + HANDLE hMgrNotificationEvent, + PSUPPORT_FUNCTIONS psfSupportFunctions, + PXORPRTM_GLOBAL_CONFIG pigc) +{ + DWORD dwErr = NO_ERROR; + pipe_instance_t *pp; + int i, pipefail; + + do { + pce->ulActivityCount = 0; + + pce->hMprConfig = NULL; + dwErr = MprConfigServerConnect(NULL, &pce->hMprConfig); + if (dwErr != NO_ERROR) { + TRACE0(CONFIGURATION, "could not obtain mpr config handle"); + } + + /* Router Manager Information */ + pce->hMgrNotificationEvent = hMgrNotificationEvent; + if (psfSupportFunctions) + pce->sfSupportFunctions = *psfSupportFunctions; + + pipefail = 0; + for (i = 0; i < PIPE_INSTANCES; i++) { + pp = pipe_new(); + if (pp == NULL) { + pipefail = 1; + break; + } else { + pipe_listen(pp); + pce->pipes[i] = pp; + } + } + + if (pipefail) { + TRACE0(CONFIGURATION, "failed to allocate all pipes"); + break; + } + TRACE0(ANY, "Listening on pipes ok."); + + pce->reiRtmEntity.RtmInstanceId = 0; +#ifdef IPV6_DLL + pce->reiRtmEntity.AddressFamily = AF_INET6; +#else + pce->reiRtmEntity.AddressFamily = AF_INET; +#endif + pce->reiRtmEntity.EntityId.EntityProtocolId = PROTO_IP_XORPRTM; + pce->reiRtmEntity.EntityId.EntityInstanceId = 0; + + dwErr = RtmRegisterEntity( + &pce->reiRtmEntity, + NULL, + RTM_CallbackEvent, + TRUE, + &pce->rrpRtmProfile, + &pce->hRtmHandle); + if (dwErr != NO_ERROR) { + TRACE1(CONFIGURATION, "Error %u registering with RTM", dwErr); + break; + } + TRACE0(ANY, "registered entity ok."); + + dwErr = RtmRegisterForChangeNotification( + pce->hRtmHandle, + RTM_VIEW_MASK_UCAST, + RTM_CHANGE_TYPE_ALL, + NULL, + &pce->hRtmNotificationHandle); + if (dwErr != NO_ERROR) { + TRACE1(CONFIGURATION, + "Error %u registering for change with RTM", dwErr); + break; + } + TRACE0(ANY, "registered rtm changes ok."); + + pce->iscStatus = XORPRTM_STATUS_RUNNING; + } while (FALSE); + + if (dwErr != NO_ERROR) { + TRACE0(ANY, "init failed, cleaning up."); + CE_Cleanup(pce); + } else { + TRACE0(ANY, "Leaving init ok "); + } + + return dwErr; +} + +DWORD +CE_Cleanup(PCONFIGURATION_ENTRY pce) +{ + DWORD dwErr = NO_ERROR; + int i; + + if (pce->hRtmNotificationHandle) { + dwErr = RtmDeregisterFromChangeNotification( + pce->hRtmHandle, + pce->hRtmNotificationHandle); + if (dwErr != NO_ERROR) + TRACE1(CONFIGURATION, + "Error %u deregistering for change from RTM", dwErr); + } + pce->hRtmNotificationHandle = NULL; + + if (pce->hRtmHandle) { + dwErr = RtmDeregisterEntity(pce->hRtmHandle); + + if (dwErr != NO_ERROR) + TRACE1(CONFIGURATION, + "Error %u deregistering from RTM", dwErr); + } + pce->hRtmHandle = NULL; + + for (i = 0; i < PIPE_INSTANCES; i++) { + if (pce->pipes[i]) { + pipe_destroy(pce->pipes[i]); + pce->pipes[i] = NULL; + } + } + + if (pce->hMprConfig != NULL) { + MprConfigServerDisconnect(pce->hMprConfig); + } + pce->hMprConfig = NULL; + + pce->iscStatus = XORPRTM_STATUS_STOPPED; + + return NO_ERROR; +} + +VOID +CM_WorkerFinishStopProtocol ( + PVOID pvContext) +{ + DWORD dwErr = NO_ERROR; + MESSAGE mMessage; + + ULONG ulThreadCount = 0; + + ulThreadCount = (ULONG)pvContext; + + TRACE1(ENTER, "Entering WorkerFinishStopProtocol: active threads %u", + ulThreadCount); + + /* NOTE: since this is called while the router is stopping, there is no */ + /* need for it to use ENTER_XORPRTM_WORKER()/LEAVE_XORPRTM_WORKER() */ + + /* waits for all threads to stop */ + while (ulThreadCount-- > 0) + WaitForSingleObject(g_ce.hActivitySemaphore, INFINITE); + + + /* acquire the lock and release it, just to be sure that all threads */ + /* have quit their calls to LeaveSampleWorker() */ + + ACQUIRE_WRITE_LOCK(&(g_ce.rwlLock)); + RELEASE_WRITE_LOCK(&(g_ce.rwlLock)); + + /* NOTE: there is no need to acquire g_ce.rwlLock for the call to */ + /* CE_Cleanup since there are no threads competing for access to the */ + /* fields being cleaned up. new competing threads aren't created till */ + /* CE_Cleanup sets the protocol state to XORPRTM_STATUS_STOPPED, which */ + /* is the last thing it does. */ + + CE_Cleanup(&g_ce); + + /* inform router manager that we are done */ + ZeroMemory(&mMessage, sizeof(MESSAGE)); + if (EnqueueEvent(ROUTER_STOPPED, mMessage) == NO_ERROR) + SetEvent(g_ce.hMgrNotificationEvent); + + TRACE0(LEAVE, "Leaving WorkerFinishStopProtocol"); +} + +/* APIFUNCTIONS */ + +DWORD +CM_StartProtocol ( + HANDLE hMgrNotificationEvent, + PSUPPORT_FUNCTIONS psfSupportFunctions, + PVOID pvGlobalInfo) +{ + DWORD dwErr = NO_ERROR; + + /* + * NOTE: since this is called when the protocol is stopped, there + * is no need for it to use ENTER_XORPRTM_API()/LEAVE_XORPRTM_API(). + */ + ACQUIRE_WRITE_LOCK(&(g_ce.rwlLock)); + + do { + if (g_ce.iscStatus != XORPRTM_STATUS_STOPPED) { + TRACE1(CONFIGURATION, "Error: %s already installed", + XORPRTM_LOGNAME); + dwErr = ERROR_CAN_NOT_COMPLETE; + + break; + } + dwErr = CE_Initialize(&g_ce, + hMgrNotificationEvent, + psfSupportFunctions, + (PXORPRTM_GLOBAL_CONFIG) pvGlobalInfo); + } while (FALSE); + + RELEASE_WRITE_LOCK(&(g_ce.rwlLock)); + + if (dwErr == NO_ERROR) { + TRACE1(CONFIGURATION, "%s has successfully started", XORPRTM_LOGNAME); + } else { + TRACE2(CONFIGURATION, "Error: %s failed to start (%d)", + XORPRTM_LOGNAME, dwErr); + } + + return dwErr; +} + + +DWORD +CM_StopProtocol () +{ + DWORD dwErr = NO_ERROR; + BOOL bSuccess = FALSE; + ULONG ulThreadCount = 0; + + /* XXX: no need to use ENTER_XORPRTM_API()/LEAVE_XORPRTM_API() */ + + ACQUIRE_WRITE_LOCK(&(g_ce.rwlLock)); + + do { + /* cannot stop if already stopped */ + if (g_ce.iscStatus != XORPRTM_STATUS_RUNNING) + { + TRACE0(CONFIGURATION, "Error ip sample already stopped"); + dwErr = ERROR_CAN_NOT_COMPLETE; + + break; + } + + /* + * Set XORPRTM's status to STOPPING; this prevents any more work + * items from being queued, and it prevents the ones already + * queued from executing. + */ + g_ce.iscStatus = XORPRTM_STATUS_STOPPING; + + /* + * find out how many threads are either queued or active in XORPRTM; + * we will have to wait for this many threads to exit before we + * clean up XORPRTM's resources. + */ + ulThreadCount = g_ce.ulActivityCount; + TRACE2(CONFIGURATION, "%u threads are active in %s", ulThreadCount, + XORPRTM_LOGNAME); + } while (FALSE); + + RELEASE_WRITE_LOCK(&(g_ce.rwlLock)); + + if (dwErr == NO_ERROR) { + bSuccess = QueueUserWorkItem( + (LPTHREAD_START_ROUTINE)CM_WorkerFinishStopProtocol, + (PVOID) ulThreadCount, + 0); /* no flags */ + dwErr = (bSuccess) ? ERROR_PROTOCOL_STOP_PENDING : GetLastError(); + } + + return dwErr; +} + +DWORD +CM_GetGlobalInfo ( + PVOID pvGlobalInfo, + PULONG pulBufferSize, + PULONG pulStructureVersion, + PULONG pulStructureSize, + PULONG pulStructureCount) +{ + DWORD dwErr = NO_ERROR; + PXORPRTM_GLOBAL_CONFIG pigc; + ULONG ulSize = sizeof(XORPRTM_GLOBAL_CONFIG); + + do + { + if((*pulBufferSize < ulSize) || (pvGlobalInfo == NULL)) + { + dwErr = ERROR_INSUFFICIENT_BUFFER; + TRACE1(CONFIGURATION, + "CM_GetGlobalInfo: *ulBufferSize %u", + *pulBufferSize); + + *pulBufferSize = ulSize; + + break; + } + + *pulBufferSize = ulSize; + + if (pulStructureVersion) *pulStructureVersion = 1; + if (pulStructureSize) *pulStructureSize = ulSize; + if (pulStructureCount) *pulStructureCount = 1; + + pigc = (PXORPRTM_GLOBAL_CONFIG) pvGlobalInfo; + + } while (FALSE); + + return dwErr; +} + +/* + * Called when the Router Manager tells us there's an event + * in our event queue. + * NOTE: this can be called after the protocol is stopped, as in when + * the ip router manager is retrieving the ROUTER_STOPPED message, so + * we do not call ENTER_XORPRTM_API()/LEAVE_XORPRTM_API(). + */ +DWORD +CM_GetEventMessage ( + ROUTING_PROTOCOL_EVENTS *prpeEvent, + MESSAGE *pmMessage) +{ + DWORD dwErr = NO_ERROR; + + dwErr = DequeueEvent(prpeEvent, pmMessage); + + return dwErr; +} + +BOOL WINAPI +DllMain(HINSTANCE hInstance, DWORD dwReason, PVOID pvImpLoad) +{ + BOOL bError = TRUE; + + switch (dwReason) { + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(hInstance); + bError = (CE_Create(&g_ce) == NO_ERROR) ? TRUE : FALSE; + break; + + case DLL_PROCESS_DETACH: + CE_Destroy(&g_ce); + break; + + default: + break; + } + + return bError; +} + +/* + * Add a route to RTMv2 based on a routing socket message. + * XXX: We should report errors in more detail, e.g. if the + * route could not be added because it already existed, etc. + */ +int +rtm_add_route(struct rt_msghdr *rtm, int msgsize) +{ + static const proper_msgsize = (sizeof(struct rt_msghdr) + + (sizeof(sockunion_t) * 3)); + sockunion_t *sa; +#ifdef IPV6_DLL + struct in6_addr in6_dest; + struct in6_addr in6_mask; + struct in6_addr in6_nexthop; +#else + struct in_addr in_dest; + struct in_addr in_mask; + struct in_addr in_nexthop; + MIB_IPFORWARDROW ro; +#endif + int retval; + int prefix; + DWORD result; + RTM_NET_ADDRESS dest; + RTM_NET_ADDRESS nexthop; + RTM_NEXTHOP_HANDLE nhh; + RTM_NEXTHOP_INFO nhi; + RTM_ROUTE_HANDLE nrh; + RTM_ROUTE_INFO ri; + RTM_ROUTE_CHANGE_FLAGS changeFlags; + + /* + * Sanity check message size, fields etc. + */ + if (!rtm) + return -1; + if (msgsize < proper_msgsize || (rtm->rtm_msglen < proper_msgsize)) + return -1; + if (rtm->rtm_type != RTM_ADD) + return -1; + if ((rtm->rtm_addrs & (RTA_DST|RTA_GATEWAY|RTA_NETMASK)) != + (RTA_DST|RTA_GATEWAY|RTA_NETMASK)) + return -1; + + nhh = NULL; + nrh = NULL; + + /* + * Extract destination, netmask and next-hop from routing + * socket message. + */ +#ifdef IPV6_DLL + sa = (sockunion_t *)(rtm + 1); + in6_dest = sa->sin6.sin6_addr; + if (sa->sa.sa_family != AF_INET6) + return -1; + ++sa; + in6_nexthop = sa->sin6.sin6_addr; + if (sa->sa.sa_family != AF_INET6) + return -1; + ++sa; + in6_mask = sa->sin6.sin6_addr; + if (sa->sa.sa_family != AF_INET6) + return -1; +#else + sa = (sockunion_t *)(rtm + 1); + if (sa->sa.sa_family != AF_INET) + return -1; + in_dest = sa->sin.sin_addr; + ++sa; + if (sa->sa.sa_family != AF_INET) + return -1; + in_nexthop = sa->sin.sin_addr; + ++sa; + if (sa->sa.sa_family != AF_INET) + return -1; + in_mask = sa->sin.sin_addr; +#endif + +#ifndef IPV6_DLL + /* + * Look up the next-hop in the system routing table via + * IP Helper. If there is no directly connected route we + * can use to reach the next-hop, then we reject this attempt + * to add a route, as we need to know the interface index + * of this route in order to add the new route. + * XXX This is not good for multihop. + * XXX IPv6! + */ + result = GetBestRoute(in_nexthop.s_addr, INADDR_ANY, &ro); + if (result != NO_ERROR) { + TRACE1(NETWORK, "error: GetBestRoute() returned %d", result); + return -1; + } +#endif + + /* + * Convert netmask to a prefix length. + * Convert destination to an RTM_NET_ADDRESS. + * Convert next-hop to an RTM_NET_ADDRESS. + * XXX: IPv6 path needs 'get length from mask' macro. + * XXX: IPv6 path needs interface index. + */ +#ifdef IPV6_DLL + RTM_IPV6_LEN_FROM_MASK(prefix, in6_mask.s_addr); + RTM_IPV6_MAKE_NET_ADDRESS(&dest, in6_dest.s_addr, prefix); + RTM_IPV6_MAKE_NET_ADDRESS(&nexthop, in6_nexthop.s_addr, 128); +#else + RTM_IPV4_LEN_FROM_MASK(prefix, in_mask.s_addr); + RTM_IPV4_MAKE_NET_ADDRESS(&dest, in_dest.s_addr, prefix); + RTM_IPV4_MAKE_NET_ADDRESS(&nexthop, in_nexthop.s_addr, 32); + /* + * Fill out the next-hop info structure. + * Create the next-hop in the RTMv2 table. + */ + ZeroMemory(&nhi, sizeof(nhi)); + nhi.InterfaceIndex = ro.dwForwardIfIndex; + nhi.NextHopAddress = nexthop; +#endif /* IPV6_DLL */ + + result = RtmAddNextHop(g_ce.hRtmHandle, &nhi, &nhh, &changeFlags); + if (result != NO_ERROR) { + TRACE1(NETWORK, "error %u adding nexthop", result); + retval = -1; + goto out; + } + + /* + * Fill out the RTM_ROUTE_INFO structure. + * Attempt to add the route. + */ + ZeroMemory(&ri, sizeof(ri)); + ri.PrefInfo.Metric = XORPRTM_RI_METRIC; + ri.PrefInfo.Preference = XORPRTM_RI_PREF; + ri.BelongsToViews = RTM_VIEW_MASK_UCAST; + ri.NextHopsList.NumNextHops = 1; + ri.NextHopsList.NextHops[0] = nhh; + changeFlags = 0; + + result = RtmAddRouteToDest(g_ce.hRtmHandle, &nrh, &dest, &ri, INFINITE, + NULL, 0, NULL, &changeFlags); + if (result != NO_ERROR) { + TRACE1(NETWORK, "error %u adding route", result); + retval = -1; + goto out; + } + + retval = 0; + +out: + if (nrh != NULL) + RtmReleaseRoutes(g_ce.hRtmHandle, 1, &nrh); + if (nhh != NULL) + RtmReleaseNextHops(g_ce.hRtmHandle, 1, &nhh); + + return (retval); +} + +/* + * Delete a route from RTMv2 based on a routing socket message. + * XXX: We should report errors in more detail, e.g. if the + * route could not be added because it already existed, etc. + */ +int +rtm_delete_route(struct rt_msghdr *rtm, int msgsize) +{ + static const min_msgsize = (sizeof(struct rt_msghdr) + + (sizeof(sockunion_t) * 2)); + sockunion_t *sa; + struct in_addr in_dest; + struct in_addr in_mask; + int found; + int i; + int prefix; + int retval; + DWORD result; + RTM_DEST_INFO di; + RTM_NET_ADDRESS dest; + RTM_ROUTE_CHANGE_FLAGS changeflags; + + /* + * Sanity check message size, fields etc. + */ + if (!rtm) + return -1; + if (msgsize < min_msgsize || (rtm->rtm_msglen < min_msgsize)) + return -1; + if (rtm->rtm_type != RTM_DELETE) + return -1; + if ((rtm->rtm_addrs & (RTA_DST|RTA_NETMASK)) != (RTA_DST|RTA_NETMASK)) + return -1; + /* + * Extract destination, netmask and next-hop from routing + * socket message. + * XXX: bsd's delete order is: + * XXX: we don't check to see if gateway is present and + * if so we do not handle it correctly. + */ + sa = (sockunion_t *)(rtm + 1); + in_dest = sa->sin.sin_addr; + ++sa; + in_mask = sa->sin.sin_addr; + + /* + * Convert netmask to a prefix length. + * Convert destination to an RTM_NET_ADDRESS. + */ + RTM_IPV4_LEN_FROM_MASK(prefix, in_mask.s_addr); + RTM_IPV4_MAKE_NET_ADDRESS(&dest, in_dest.s_addr, prefix); + + /* + * Look up the route to be deleted in RTMv2, from those + * which belong to our protocol, in the unicast view. + */ + ZeroMemory(&di, sizeof(di)); + di.DestAddress = dest; + result = RtmGetExactMatchDestination(g_ce.hRtmHandle, &dest, + RTM_THIS_PROTOCOL, + RTM_VIEW_MASK_UCAST, &di); + if (result != NO_ERROR) { + TRACE1(NETWORK, "error %u looking up route to delete", result); + retval = -1; + goto out; + } + i = 0; + found = 0; + for (i = 0; i < di.NumberOfViews; i++) { + if (di.ViewInfo[i].ViewId == RTM_VIEW_ID_UCAST) { + /* + * Return a match only if the unicast view for our protocol + * contains a single next-hop route to the destination. + */ + if (di.ViewInfo[i].NumRoutes == 1) + found = 1; + break; + } + } + if (!found) { + TRACE0(NETWORK, "route not found in table"); + retval = -1; + goto out; + } + + result = RtmDeleteRouteToDest(g_ce.hRtmHandle, di.ViewInfo[i].Route, + &changeflags); + if (result != NO_ERROR) { + TRACE1(NETWORK, "error %u deleting route", result); + retval = -1; + goto out; + } + + retval = 0; + +out: + return (retval); +} + +int +rtm_ifannounce(LPWSTR ifname, DWORD ifindex, int what) +{ + WCHAR fnameW[IFNAMSIZ]; + struct if_announcemsghdr *ifa; + int result; + int retval; + + TRACE3(ENTER, "Entering rtm_ifannounce %S %d %d", ifname, ifindex, what); + + ifa = NULL; + retval = -1; + + if ((what != IFAN_ARRIVAL) && (what != IFAN_DEPARTURE)) { + goto out; + } + + ifa = malloc(sizeof(*ifa)); + if (ifa == NULL) { + goto out; + } + ifa->ifan_name[0] = '\0'; + + /* + * If this is a new interface, then look up the FriendlyName from + * the unicode GUID name; convert Unicode to ASCII afterwards. + * If the caller didn't supply this, the error is fatal to this function. + * If we can't find it, the error is non-fatal to this function. + * + * XXX: The very fact that we don't provide the interface name here + * is a limitation to do with how the notifications work in the + * Microsoft stack. It only tells us the interface index when + * the interface goes away. XORP currently depends on both for + * interface deletion. We could look it up from the transport, + * but it's more work to deliver redundant information. + */ + if (what == IFAN_ARRIVAL) { + if (ifname == NULL) + goto out; + + result = MprConfigGetFriendlyName(g_ce.hMprConfig, ifname, fnameW, + sizeof(fnameW)); + if (result != NO_ERROR) { + TRACE1(NETWORK, "can't find friendlyname for ifname %S", ifname); + } else { + wcstombs(ifa->ifan_name, fnameW, IFNAMSIZ); + } + } + + /* + * Fill our the rest of the interface announcement and send it to + * all connected clients. + */ + ifa->ifan_msglen = sizeof(*ifa); + ifa->ifan_version = RTM_VERSION; /* XXX should set to 0 or ignore */ + ifa->ifan_type = RTM_IFANNOUNCE; + ifa->ifan_index = ifindex; + ifa->ifan_what = what; + + broadcast_pipe_message(ifa, sizeof(*ifa)); + + retval = 0; + +out: + if (ifa != NULL) + free(ifa); + + TRACE0(ENTER, "Leaving rtm_ifannounce"); + + return (retval); +} + +int +rtm_ifinfo(DWORD ifindex, int up) +{ + struct if_msghdr *ifm; + int result; + int retval; + + TRACE2(ENTER, "Entering rtm_ifinfo %d %d", ifindex, up); + + ifm = NULL; + retval = -1; + + ifm = malloc(sizeof(*ifm)); + if (ifm == NULL) { + goto out; + } + + /* + * Fill our the rest of the interface announcement and send it to + * all connected clients. + */ + ifm->ifm_msglen = sizeof(*ifm); + ifm->ifm_version = RTM_VERSION; + ifm->ifm_type = RTM_IFANNOUNCE; + ifm->ifm_addrs = 0; + ifm->ifm_flags = 0; + ifm->ifm_index = ifindex; + ifm->ifm_data.ifi_link_state = (up ? LINK_STATE_UP : LINK_STATE_DOWN); + + broadcast_pipe_message(ifm, sizeof(*ifm)); + + retval = 0; + +out: + if (ifm != NULL) + free(ifm); + + TRACE0(ENTER, "Leaving rtm_ifinfo"); + + return (retval); +} + +/* + * Send one RTM_NEWADDR message for each IPv4 address we've found + * in the binding message. We ignore pbind->RemoteAddress for now. + * + * XXX: This does not work like BSD's notifications; again, if we + * wish to send changes, like routes, we need to maintain state, + * as the RTMv2 APIs send the entire state of the interface's + * address list each time. + * + * For this reason it's probably better to use IP Helper as + * the means of interface information discovery (with + * GetAdaptersAddresses()). + */ +int +rtm_newaddr(DWORD ifindex, +#ifdef IPV6_DLL + PIPV6_ADAPTER_BINDING_INFO pbind +#else + PIP_ADAPTER_BINDING_INFO pbind +#endif +) +{ + static const msgsize = +sizeof(struct ifa_msghdr) + (sizeof(sockunion_t) * 2); + struct ifa_msghdr *ifam; + sockunion_t *sa; + sockunion_t *sa2; + int i; + int result; + int retval; + + TRACE2(ENTER, "Entering rtm_newaddr %d %p", ifindex, pbind); + + retval = -1; + ifam = NULL; + + if (pbind == NULL) + goto out; + if (pbind->AddressCount == 0) + goto out; + + ifam = malloc(sizeof(*ifam)); + if (ifam == NULL) + goto out; + + sa = (sockunion_t *)(ifam + 1); + sa2 = (sa + 1); + + for (i = 0; i < pbind->AddressCount; i++) { + ifam->ifam_msglen = msgsize; + ifam->ifam_version = RTM_VERSION; + ifam->ifam_type = RTM_NEWADDR; + ifam->ifam_addrs = RTA_DST | RTA_NETMASK; + ifam->ifam_flags = 0; + ifam->ifam_index = ifindex; + ifam->ifam_metric = 0; +#ifdef IPV6_DLL + sa->sin6.sin6_family = AF_INET6; + sa->sin6.sin6_addr.s_addr = pbind->Address[i].Address; + sa2->sin6.sin6_family = AF_INET6; + sa2->sin6.sin6_addr.s_addr = pbind->Address[i].Mask; +#else + sa->sin.sin_family = AF_INET; + sa->sin.sin_addr.s_addr = pbind->Address[i].Address; + sa2->sin.sin_family = AF_INET; + sa2->sin.sin_addr.s_addr = pbind->Address[i].Mask; +#endif + + broadcast_pipe_message(ifam, msgsize); + } + + retval = 0; + +out: + if (ifam != NULL) + free(ifam); + + TRACE0(ENTER, "Leaving rtm_newaddr"); + + return (retval); +} diff --git a/xorp/contrib/xorprtm/xorprtm/xorprtm.h b/xorp/contrib/xorprtm/xorprtm/xorprtm.h new file mode 100644 index 0000000..fbf6400 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/xorprtm.h @@ -0,0 +1,32 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +/* + * $XORP: xorp/contrib/win32/xorprtm/xorprtm.h,v 1.7 2008/10/02 21:56:41 bms Exp $ + */ + +#ifndef _XORPRTM_H_ +#define _XORPRTM_H_ + +/* Nothing */ + +#endif /* _XORPRTM_H_ */ diff --git a/xorp/contrib/xorprtm/xorprtm/xorprtm_internal.h b/xorp/contrib/xorprtm/xorprtm/xorprtm_internal.h new file mode 100644 index 0000000..4534a48 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm/xorprtm_internal.h @@ -0,0 +1,175 @@ +/* -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- */ +/* vim:set sts=4 ts=8: */ + +/* + * Copyright (c) 2001-2009 XORP, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, Version 2, June + * 1991 as published by the Free Software Foundation. Redistribution + * and/or modification of this program under the terms of any other + * version of the GNU General Public License is not permitted. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, + * see the GNU General Public License, Version 2, a copy of which can be + * found in the XORP LICENSE.gpl file. + * + * XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; + * http://xorp.net + */ + +/* + * $XORP: xorp/contrib/win32/xorprtm/xorprtm_internal.h,v 1.7 2008/10/02 21:56:41 bms Exp $ + */ + +#ifndef _CONFIGURATIONENTRY_H_ +#define _CONFIGURATIONENTRY_H_ + +typedef struct _EVENT_ENTRY { + QUEUE_ENTRY qeEventQueueLink; + ROUTING_PROTOCOL_EVENTS rpeEvent; + MESSAGE mMessage; +} EVENT_ENTRY, *PEVENT_ENTRY; + +DWORD +EE_Create ( + ROUTING_PROTOCOL_EVENTS rpeEvent, + MESSAGE mMessage, + PEVENT_ENTRY *ppeeEventEntry); + +DWORD +EE_Destroy (PEVENT_ENTRY peeEventEntry); + +#ifdef DEBUG +DWORD +EE_Display ( + PEVENT_ENTRY peeEventEntry); +#else +#define EE_Display(peeEventEntry) +#endif /* DEBUG */ + +DWORD +EnqueueEvent( + ROUTING_PROTOCOL_EVENTS rpeEvent, + MESSAGE mMessage); + +DWORD +DequeueEvent( + ROUTING_PROTOCOL_EVENTS *prpeEvent, + MESSAGE *pmMessage); + +/* various codes describing states of XORPRTM. */ +typedef enum _XORPRTM_STATUS_CODE +{ + XORPRTM_STATUS_RUNNING = 101, + XORPRTM_STATUS_STOPPING = 102, + XORPRTM_STATUS_STOPPED = 103 +} XORPRTM_STATUS_CODE, *PXORPRTM_STATUS_CODE; + +#define PIPE_INSTANCES 12 +#define PIPE_READBUF_SIZE 2048 + +typedef enum _pipe_state_t { + PIPE_STATE_INIT, + PIPE_STATE_LISTEN, + PIPE_STATE_CONNECTED +} pipe_state_t; + +typedef struct pipe_instance { + HANDLE pipe; + pipe_state_t state; + + HANDLE cevent; + HANDLE cwait; + OVERLAPPED cov; + + HANDLE revent; + HANDLE rwait; + OVERLAPPED rov; + + CRITICAL_SECTION rcs; + + size_t rsize; + char rbuf[PIPE_READBUF_SIZE]; /* XXX */ + +} pipe_instance_t; + +typedef struct _CONFIGURATION_ENTRY { + /* Following are PERSISTENT, across Start and Stop Protocol */ + + READ_WRITE_LOCK rwlLock; + HANDLE hGlobalHeap; + ULONG ulActivityCount; + HANDLE hActivitySemaphore; + DWORD dwTraceID; + LOCKED_QUEUE lqEventQueue; + XORPRTM_STATUS_CODE iscStatus; + + /* Router Manager Information */ + HANDLE hMgrNotificationEvent; + SUPPORT_FUNCTIONS sfSupportFunctions; + + /* RTMv2 Information */ + RTM_ENTITY_INFO reiRtmEntity; + RTM_REGN_PROFILE rrpRtmProfile; + HANDLE hRtmHandle; + HANDLE hRtmNotificationHandle; + + HANDLE hMprConfig; + + pipe_instance_t *pipes[PIPE_INSTANCES]; + +} CONFIGURATION_ENTRY, *PCONFIGURATION_ENTRY; + + + +/* create all fields on DLL_PROCESS_ATTACH */ +DWORD +CE_Create (PCONFIGURATION_ENTRY pce); + +/* destroy all fields on DLL_PROCESS_DEATTACH */ +DWORD +CE_Destroy (PCONFIGURATION_ENTRY pce); + +/* initialize non persistent fields on StartProtocol */ +DWORD +CE_Initialize ( + PCONFIGURATION_ENTRY pce, + HANDLE hMgrNotificationEvent, + PSUPPORT_FUNCTIONS psfSupportFunctions, + PXORPRTM_GLOBAL_CONFIG pigc); + +/* cleanup non persistent fields on StopProtocol */ +DWORD +CE_Cleanup (PCONFIGURATION_ENTRY pce); + +extern CONFIGURATION_ENTRY g_ce; + +DWORD +CM_StartProtocol ( + HANDLE hMgrNotificationEvent, + PSUPPORT_FUNCTIONS psfSupportFunctions, + PVOID pvGlobalInfo); + +DWORD +CM_StopProtocol (); + +DWORD +CM_GetGlobalInfo ( + PVOID pvGlobalInfo, + PULONG pulBufferSize, + PULONG pulStructureVersion, + PULONG pulStructureSize, + PULONG pulStructureCount); + +DWORD +CM_SetGlobalInfo (PVOID pvGlobalInfo); + +DWORD +CM_GetEventMessage ( + ROUTING_PROTOCOL_EVENTS *prpeEvent, + MESSAGE *pmMessage); + +#endif /* _CONFIGURATIONENTRY_H_ */ diff --git a/xorp/contrib/xorprtm/xorprtm4/xorprtm4.def b/xorp/contrib/xorprtm/xorprtm4/xorprtm4.def new file mode 100644 index 0000000..49cc495 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm4/xorprtm4.def @@ -0,0 +1,4 @@ +LIBRARY XORPRTM4 + +EXPORTS + RegisterProtocol diff --git a/xorp/contrib/xorprtm/xorprtm6/xorprtm6.def b/xorp/contrib/xorprtm/xorprtm6/xorprtm6.def new file mode 100644 index 0000000..8767494 --- /dev/null +++ b/xorp/contrib/xorprtm/xorprtm6/xorprtm6.def @@ -0,0 +1,4 @@ +LIBRARY XORPRTM6 + +EXPORTS + RegisterProtocol -- 1.7.9.msysgit.0 From vvm at tut.by Wed Mar 14 07:41:21 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 14 Mar 2012 17:41:21 +0300 Subject: [Xorp-hackers] [PATCH] contrib/win32/xorprtm (c) 2001-2012 XORP, Inc and Others Message-ID: <2C8BF29373924F93A6E557BEC741B54F@local.st.by> From: Victor Miasnikov contrib/win32/xorprtm (c) 2001-2012 XORP, Inc and Others Signed-off-by: Victor Miasnikov --- xorp/contrib/xorprtm/xorprtm/bsdroute.h | 2 +- xorp/contrib/xorprtm/xorprtm/defs.h | 2 +- xorp/contrib/xorprtm/xorprtm/list.h | 2 +- xorp/contrib/xorprtm/xorprtm/loadprotocol.c | 2 +- xorp/contrib/xorprtm/xorprtm/mibmgr.c | 2 +- xorp/contrib/xorprtm/xorprtm/mibmgr.h | 2 +- xorp/contrib/xorprtm/xorprtm/pchsample.h | 2 +- xorp/contrib/xorprtm/xorprtm/print_rtmsg.c | 2 +- xorp/contrib/xorprtm/xorprtm/rmapi.c | 2 +- xorp/contrib/xorprtm/xorprtm/rmapi.h | 2 +- xorp/contrib/xorprtm/xorprtm/sync.c | 2 +- xorp/contrib/xorprtm/xorprtm/sync.h | 2 +- xorp/contrib/xorprtm/xorprtm/test_monitor.c | 2 +- xorp/contrib/xorprtm/xorprtm/test_routeadd.c | 2 +- xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c | 2 +- xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c | 2 +- xorp/contrib/xorprtm/xorprtm/utils.c | 2 +- xorp/contrib/xorprtm/xorprtm/utils.h | 2 +- xorp/contrib/xorprtm/xorprtm/xorprtm.c | 2 +- xorp/contrib/xorprtm/xorprtm/xorprtm.h | 2 +- xorp/contrib/xorprtm/xorprtm/xorprtm_internal.h | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/xorp/contrib/xorprtm/xorprtm/bsdroute.h b/xorp/contrib/xorprtm/xorprtm/bsdroute.h index 87e6972..c76ec43 100644 --- a/xorp/contrib/xorprtm/xorprtm/bsdroute.h +++ b/xorp/contrib/xorprtm/xorprtm/bsdroute.h @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/defs.h b/xorp/contrib/xorprtm/xorprtm/defs.h index 9c44ecf..ac9cdd0 100644 --- a/xorp/contrib/xorprtm/xorprtm/defs.h +++ b/xorp/contrib/xorprtm/xorprtm/defs.h @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/list.h b/xorp/contrib/xorprtm/xorprtm/list.h index a1da37b..294ff96 100644 --- a/xorp/contrib/xorprtm/xorprtm/list.h +++ b/xorp/contrib/xorprtm/xorprtm/list.h @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/loadprotocol.c b/xorp/contrib/xorprtm/xorprtm/loadprotocol.c index 8c35183..b9e9ac5 100644 --- a/xorp/contrib/xorprtm/xorprtm/loadprotocol.c +++ b/xorp/contrib/xorprtm/xorprtm/loadprotocol.c @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/mibmgr.c b/xorp/contrib/xorprtm/xorprtm/mibmgr.c index 6a9f87f..cd1951e 100644 --- a/xorp/contrib/xorprtm/xorprtm/mibmgr.c +++ b/xorp/contrib/xorprtm/xorprtm/mibmgr.c @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/mibmgr.h b/xorp/contrib/xorprtm/xorprtm/mibmgr.h index 94c498f..7f36737 100644 --- a/xorp/contrib/xorprtm/xorprtm/mibmgr.h +++ b/xorp/contrib/xorprtm/xorprtm/mibmgr.h @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/pchsample.h b/xorp/contrib/xorprtm/xorprtm/pchsample.h index a390615..a6afa8e 100644 --- a/xorp/contrib/xorprtm/xorprtm/pchsample.h +++ b/xorp/contrib/xorprtm/xorprtm/pchsample.h @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/print_rtmsg.c b/xorp/contrib/xorprtm/xorprtm/print_rtmsg.c index c910f69..16622e3 100644 --- a/xorp/contrib/xorprtm/xorprtm/print_rtmsg.c +++ b/xorp/contrib/xorprtm/xorprtm/print_rtmsg.c @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/rmapi.c b/xorp/contrib/xorprtm/xorprtm/rmapi.c index 64d3a16..324981a 100644 --- a/xorp/contrib/xorprtm/xorprtm/rmapi.c +++ b/xorp/contrib/xorprtm/xorprtm/rmapi.c @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/rmapi.h b/xorp/contrib/xorprtm/xorprtm/rmapi.h index c8e3ef5..70b5fc2 100644 --- a/xorp/contrib/xorprtm/xorprtm/rmapi.h +++ b/xorp/contrib/xorprtm/xorprtm/rmapi.h @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/sync.c b/xorp/contrib/xorprtm/xorprtm/sync.c index 90747dc..146ab4e 100644 --- a/xorp/contrib/xorprtm/xorprtm/sync.c +++ b/xorp/contrib/xorprtm/xorprtm/sync.c @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/sync.h b/xorp/contrib/xorprtm/xorprtm/sync.h index 706e333..d021961 100644 --- a/xorp/contrib/xorprtm/xorprtm/sync.h +++ b/xorp/contrib/xorprtm/xorprtm/sync.h @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/test_monitor.c b/xorp/contrib/xorprtm/xorprtm/test_monitor.c index 3d100f4..6447753 100644 --- a/xorp/contrib/xorprtm/xorprtm/test_monitor.c +++ b/xorp/contrib/xorprtm/xorprtm/test_monitor.c @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/test_routeadd.c b/xorp/contrib/xorprtm/xorprtm/test_routeadd.c index 29ee842..178db1b 100644 --- a/xorp/contrib/xorprtm/xorprtm/test_routeadd.c +++ b/xorp/contrib/xorprtm/xorprtm/test_routeadd.c @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c b/xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c index c030a9c..79db77b 100644 --- a/xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c +++ b/xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c b/xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c index c90ba29..03bf71b 100644 --- a/xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c +++ b/xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/utils.c b/xorp/contrib/xorprtm/xorprtm/utils.c index 027a3cb..81dffb8 100644 --- a/xorp/contrib/xorprtm/xorprtm/utils.c +++ b/xorp/contrib/xorprtm/xorprtm/utils.c @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/utils.h b/xorp/contrib/xorprtm/xorprtm/utils.h index d3a7f9e..9a9fa55 100644 --- a/xorp/contrib/xorprtm/xorprtm/utils.h +++ b/xorp/contrib/xorprtm/xorprtm/utils.h @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/xorprtm.c b/xorp/contrib/xorprtm/xorprtm/xorprtm.c index 40112e0..35ff695 100644 --- a/xorp/contrib/xorprtm/xorprtm/xorprtm.c +++ b/xorp/contrib/xorprtm/xorprtm/xorprtm.c @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/xorprtm.h b/xorp/contrib/xorprtm/xorprtm/xorprtm.h index fbf6400..cf485ae 100644 --- a/xorp/contrib/xorprtm/xorprtm/xorprtm.h +++ b/xorp/contrib/xorprtm/xorprtm/xorprtm.h @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June diff --git a/xorp/contrib/xorprtm/xorprtm/xorprtm_internal.h b/xorp/contrib/xorprtm/xorprtm/xorprtm_internal.h index 4534a48..2d0d09f 100644 --- a/xorp/contrib/xorprtm/xorprtm/xorprtm_internal.h +++ b/xorp/contrib/xorprtm/xorprtm/xorprtm_internal.h @@ -2,7 +2,7 @@ /* vim:set sts=4 ts=8: */ /* - * Copyright (c) 2001-2009 XORP, Inc. + * Copyright (c) 2001-2012 XORP, Inc and Others * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, June -- 1.7.9.msysgit.0 From vvm at tut.by Wed Mar 14 08:06:39 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 14 Mar 2012 18:06:39 +0300 Subject: [Xorp-hackers] [PATCH] contrib/win32/xorprtm Skip #ident pragma Message-ID: <231D6040598F44618C4F0E586B78927F@local.st.by> From: Victor Miasnikov contrib/win32/xorprtm Skip #ident pragma Skip #ident pragma by add comment ( "//" ) for prevent warninigs: == xorprtm.c(23) : warning C4274: #ident ignored; see documentation for #pragma comment(exestr, 'string') == Pragma "#ident" is Ok only for GCC v3.X , but not supported GCC v4.X and MS Visual C Signed-off-by: Victor Miasnikov --- xorp/contrib/xorprtm/xorprtm/loadprotocol.c | 2 +- xorp/contrib/xorprtm/xorprtm/mibmgr.c | 2 +- xorp/contrib/xorprtm/xorprtm/print_rtmsg.c | 2 +- xorp/contrib/xorprtm/xorprtm/rmapi.c | 2 +- xorp/contrib/xorprtm/xorprtm/sync.c | 2 +- xorp/contrib/xorprtm/xorprtm/test_monitor.c | 2 +- xorp/contrib/xorprtm/xorprtm/test_routeadd.c | 2 +- xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c | 2 +- xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c | 2 +- xorp/contrib/xorprtm/xorprtm/utils.c | 2 +- xorp/contrib/xorprtm/xorprtm/xorprtm.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/xorp/contrib/xorprtm/xorprtm/loadprotocol.c b/xorp/contrib/xorprtm/xorprtm/loadprotocol.c index b9e9ac5..8c43064 100644 --- a/xorp/contrib/xorprtm/xorprtm/loadprotocol.c +++ b/xorp/contrib/xorprtm/xorprtm/loadprotocol.c @@ -20,7 +20,7 @@ * http://xorp.net */ -#ident "$XORP: xorp/contrib/win32/xorprtm/loadprotocol.c,v 1.7 2008/10/02 21:56:40 bms Exp $" +// #ident "$XORP: xorp/contrib/win32/xorprtm/loadprotocol.c,v 1.7 2008/10/02 21:56:40 bms Exp $" /* * This file is derived from code which is under the following copyright: diff --git a/xorp/contrib/xorprtm/xorprtm/mibmgr.c b/xorp/contrib/xorprtm/xorprtm/mibmgr.c index cd1951e..c81100d 100644 --- a/xorp/contrib/xorprtm/xorprtm/mibmgr.c +++ b/xorp/contrib/xorprtm/xorprtm/mibmgr.c @@ -20,7 +20,7 @@ * http://xorp.net */ -#ident "$XORP: xorp/contrib/win32/xorprtm/mibmgr.c,v 1.7 2008/10/02 21:56:40 bms Exp $" +// #ident "$XORP: xorp/contrib/win32/xorprtm/mibmgr.c,v 1.7 2008/10/02 21:56:40 bms Exp $" /* * This file is derived from code which is under the following copyright: diff --git a/xorp/contrib/xorprtm/xorprtm/print_rtmsg.c b/xorp/contrib/xorprtm/xorprtm/print_rtmsg.c index 16622e3..104079e 100644 --- a/xorp/contrib/xorprtm/xorprtm/print_rtmsg.c +++ b/xorp/contrib/xorprtm/xorprtm/print_rtmsg.c @@ -20,7 +20,7 @@ * http://xorp.net */ -#ident "$XORP: xorp/contrib/win32/xorprtm/print_rtmsg.c,v 1.8 2008/10/02 21:56:40 bms Exp $" +// #ident "$XORP: xorp/contrib/win32/xorprtm/print_rtmsg.c,v 1.8 2008/10/02 21:56:40 bms Exp $" /* * Copyright (c) 1983, 1989, 1991, 1993 diff --git a/xorp/contrib/xorprtm/xorprtm/rmapi.c b/xorp/contrib/xorprtm/xorprtm/rmapi.c index 324981a..ee84d44 100644 --- a/xorp/contrib/xorprtm/xorprtm/rmapi.c +++ b/xorp/contrib/xorprtm/xorprtm/rmapi.c @@ -20,7 +20,7 @@ * http://xorp.net */ -#ident "$XORP: xorp/contrib/win32/xorprtm/rmapi.c,v 1.7 2008/10/02 21:56:40 bms Exp $" +// #ident "$XORP: xorp/contrib/win32/xorprtm/rmapi.c,v 1.7 2008/10/02 21:56:40 bms Exp $" /* * This file is derived from code which is under the following copyright: diff --git a/xorp/contrib/xorprtm/xorprtm/sync.c b/xorp/contrib/xorprtm/xorprtm/sync.c index 146ab4e..47f6e63 100644 --- a/xorp/contrib/xorprtm/xorprtm/sync.c +++ b/xorp/contrib/xorprtm/xorprtm/sync.c @@ -20,7 +20,7 @@ * http://xorp.net */ -#ident "$XORP: xorp/contrib/win32/xorprtm/sync.c,v 1.7 2008/10/02 21:56:41 bms Exp $" +// #ident "$XORP: xorp/contrib/win32/xorprtm/sync.c,v 1.7 2008/10/02 21:56:41 bms Exp $" /* * This file is derived from code which is under the following copyright: diff --git a/xorp/contrib/xorprtm/xorprtm/test_monitor.c b/xorp/contrib/xorprtm/xorprtm/test_monitor.c index 6447753..1c1024d 100644 --- a/xorp/contrib/xorprtm/xorprtm/test_monitor.c +++ b/xorp/contrib/xorprtm/xorprtm/test_monitor.c @@ -20,7 +20,7 @@ * http://xorp.net */ -#ident "$XORP: xorp/contrib/win32/xorprtm/test_monitor.c,v 1.7 2008/10/02 21:56:41 bms Exp $" +// #ident "$XORP: xorp/contrib/win32/xorprtm/test_monitor.c,v 1.7 2008/10/02 21:56:41 bms Exp $" /* * test pipe client program diff --git a/xorp/contrib/xorprtm/xorprtm/test_routeadd.c b/xorp/contrib/xorprtm/xorprtm/test_routeadd.c index 178db1b..d1f41fe 100644 --- a/xorp/contrib/xorprtm/xorprtm/test_routeadd.c +++ b/xorp/contrib/xorprtm/xorprtm/test_routeadd.c @@ -20,7 +20,7 @@ * http://xorp.net */ -#ident "$XORP: xorp/contrib/win32/xorprtm/test_routeadd.c,v 1.7 2008/10/02 21:56:41 bms Exp $" +// #ident "$XORP: xorp/contrib/win32/xorprtm/test_routeadd.c,v 1.7 2008/10/02 21:56:41 bms Exp $" /* * test pipe client program diff --git a/xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c b/xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c index 79db77b..4a55a2d 100644 --- a/xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c +++ b/xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c @@ -20,7 +20,7 @@ * http://xorp.net */ -#ident "$XORP: xorp/contrib/win32/xorprtm/test_routeadddelete.c,v 1.7 2008/10/02 21:56:41 bms Exp $" +// #ident "$XORP: xorp/contrib/win32/xorprtm/test_routeadddelete.c,v 1.7 2008/10/02 21:56:41 bms Exp $" /* * test pipe client program diff --git a/xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c b/xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c index 03bf71b..bebccb2 100644 --- a/xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c +++ b/xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c @@ -20,7 +20,7 @@ * http://xorp.net */ -#ident "$XORP: xorp/contrib/win32/xorprtm/test_routeaddwait.c,v 1.7 2008/10/02 21:56:41 bms Exp $" +// #ident "$XORP: xorp/contrib/win32/xorprtm/test_routeaddwait.c,v 1.7 2008/10/02 21:56:41 bms Exp $" /* * test pipe client program diff --git a/xorp/contrib/xorprtm/xorprtm/utils.c b/xorp/contrib/xorprtm/xorprtm/utils.c index 81dffb8..7a631e0 100644 --- a/xorp/contrib/xorprtm/xorprtm/utils.c +++ b/xorp/contrib/xorprtm/xorprtm/utils.c @@ -20,7 +20,7 @@ * http://xorp.net */ -#ident "$XORP: xorp/contrib/win32/xorprtm/utils.c,v 1.7 2008/10/02 21:56:41 bms Exp $" +// #ident "$XORP: xorp/contrib/win32/xorprtm/utils.c,v 1.7 2008/10/02 21:56:41 bms Exp $" /* * This file is derived from code which is under the following copyright: diff --git a/xorp/contrib/xorprtm/xorprtm/xorprtm.c b/xorp/contrib/xorprtm/xorprtm/xorprtm.c index 35ff695..12b990a 100644 --- a/xorp/contrib/xorprtm/xorprtm/xorprtm.c +++ b/xorp/contrib/xorprtm/xorprtm/xorprtm.c @@ -20,7 +20,7 @@ * http://xorp.net */ -#ident "$XORP: xorp/contrib/win32/xorprtm/xorprtm.c,v 1.7 2008/10/02 21:56:41 bms Exp $" +// #ident "$XORP: xorp/contrib/win32/xorprtm/xorprtm.c,v 1.7 2008/10/02 21:56:41 bms Exp $" /* XXX: SORT FUNCTIONS IN THIS FILE */ -- 1.7.9.msysgit.0 From vvm at tut.by Wed Mar 14 08:51:09 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 14 Mar 2012 18:51:09 +0300 Subject: [Xorp-hackers] [PATCH] contrib/win32/xorprtm Fixes related "bsdroute.h" Message-ID: From: Victor Miasnikov contrib/win32/xorprtm Fixes related "bsdroute.h" 1) Add Or move source code line #include "bsdroute.h" 2) xorptm4/Jamfile ( from "SVN Rev 11384" ) 2b) xorptm6/Jamfile ( see "SharedLibrary xorprtm6 :") 3) build script Jam-Run.cmd == set JAM_TOOLSET=VISUALC jam.exe == Signed-off-by: Victor Miasnikov --- xorp/contrib/xorprtm/Jam-Run.cmd | Bin 0 -> 777 bytes xorp/contrib/xorprtm/xorprtm/loadprotocol.c | 2 + xorp/contrib/xorprtm/xorprtm/pchsample.h | 4 +- xorp/contrib/xorprtm/xorprtm4/Jamfile | 39 +++++++++++++++++++++++++++ xorp/contrib/xorprtm/xorprtm6/Jamfile | 39 +++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 xorp/contrib/xorprtm/Jam-Run.cmd create mode 100644 xorp/contrib/xorprtm/xorprtm4/Jamfile create mode 100644 xorp/contrib/xorprtm/xorprtm6/Jamfile diff --git a/xorp/contrib/xorprtm/Jam-Run.cmd b/xorp/contrib/xorprtm/Jam-Run.cmd new file mode 100644 index 0000000000000000000000000000000000000000..2f7532374c3888bf6326213e49cd2ce2e41d0e59 GIT binary patch literal 777 xcmXR;Em81t^o References: <2C8BF29373924F93A6E557BEC741B54F@local.st.by> Message-ID: <4F60C3E5.1000001@candelatech.com> On 03/14/2012 07:41 AM, Victor Miasnikov wrote: > From: Victor Miasnikov > > contrib/win32/xorprtm (c) 2001-2012 XORP, Inc and Others > > Signed-off-by: Victor Miasnikov > --- > diff --git a/xorp/contrib/xorprtm/xorprtm/bsdroute.h b/xorp/contrib/xorprtm/xorprtm/bsdroute.h > index 87e6972..c76ec43 100644 > --- a/xorp/contrib/xorprtm/xorprtm/bsdroute.h > +++ b/xorp/contrib/xorprtm/xorprtm/bsdroute.h > @@ -2,7 +2,7 @@ > /* vim:set sts=4 ts=8: */ > > /* > - * Copyright (c) 2001-2009 XORP, Inc. > + * Copyright (c) 2001-2012 XORP, Inc and Others > * > * This program is free software; you can redistribute it and/or modify > * it under the terms of the GNU General Public License, Version 2, June To date, we have only updated the copyright on a file when it has been changed, and I have a script that will take care of this near release time. Did you write this xorprtm code originally, or work on submit changes while not employed by XORP, Inc? Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From greearb at candelatech.com Wed Mar 14 09:35:50 2012 From: greearb at candelatech.com (Ben Greear) Date: Wed, 14 Mar 2012 09:35:50 -0700 Subject: [Xorp-hackers] [PATCH] xorp: rtrmgr: Fix compiling of lex and yacc on BSD OSs In-Reply-To: <1331719300-9653-2-git-send-email-igorm@etf.rs> References: <1331719300-9653-1-git-send-email-igorm@etf.rs> <1331719300-9653-2-git-send-email-igorm@etf.rs> Message-ID: <4F60C8E6.6020601@candelatech.com> On 03/14/2012 03:01 AM, igorm at etf.rs wrote: > From: Igor Maravic > > On BSD bison generates header files with .h suffix. > On other OSs it generates header files with .hh suffix. > > Check which OS we use and include appropriate files. This still does not work. On my BSD box, the .h file is: y.tplt_tab.cc.h But, I fixed that. Now it complains because it doesn't know about some variable: scons: `obj/i386-unknown-freebsd8.1/rib/tools/rib_show_routes' is up to date. scons: `obj/i386-unknown-freebsd8.1/rib/xorp_rib' is up to date. flex -Ptplt -t rtrmgr/template.ll > obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.cc g++ -o obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 -I. -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.cc rtrmgr/template.ll: In function 'int tpltlex()': rtrmgr/template.ll:269: error: 'tpltlval' was not declared in this scope rtrmgr/template.ll:274: error: 'tpltlval' was not declared in this scope rtrmgr/template.ll:279: error: 'tpltlval' was not declared in this scope Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Wed Mar 14 10:04:41 2012 From: noreply at github.com (GitHub) Date: Wed, 14 Mar 2012 10:04:41 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] ecf035: xorp: rtrmgr: Fix compiling of lex and yacc on BSD... Message-ID: <4f60cfa9af6e4_30341591af41295e4@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: ecf035e957524765099b8f8051fb8acb5f2c1c70 https://github.com/greearb/xorp.ct/commit/ecf035e957524765099b8f8051fb8acb5f2c1c70 Author: Igor Maravic Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/SConstruct M xorp/rtrmgr/SConscript M xorp/rtrmgr/boot.ll M xorp/rtrmgr/op_commands.ll M xorp/rtrmgr/template.ll Log Message: ----------- xorp: rtrmgr: Fix compiling of lex and yacc on BSD OSs On BSD bison generates header files with .h suffix. On other OSs it generates header files with .hh suffix. Check which OS we use and include appropriate files. Signed-off-by: Igor Maravic Commit: fe27f9e242245c25c1653ec44e55c2e92e048eae https://github.com/greearb/xorp.ct/commit/fe27f9e242245c25c1653ec44e55c2e92e048eae Author: Ben Greear Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/rtrmgr/boot.ll M xorp/rtrmgr/op_commands.cc M xorp/rtrmgr/op_commands.ll M xorp/rtrmgr/template.ll Log Message: ----------- freebsd: Fix compile related to lex/yacc issues. This makes it compile again, but not idea if it actually functions properly at this point. Signed-off-by: Ben Greear Compare: https://github.com/greearb/xorp.ct/compare/8a06fc4...fe27f9e From greearb at candelatech.com Wed Mar 14 10:05:21 2012 From: greearb at candelatech.com (Ben Greear) Date: Wed, 14 Mar 2012 10:05:21 -0700 Subject: [Xorp-hackers] [PATCH] xorp: rtrmgr: Fix compiling of lex and yacc on BSD OSs In-Reply-To: <4F60C8E6.6020601@candelatech.com> References: <1331719300-9653-1-git-send-email-igorm@etf.rs> <1331719300-9653-2-git-send-email-igorm@etf.rs> <4F60C8E6.6020601@candelatech.com> Message-ID: <4F60CFD1.8060900@candelatech.com> On 03/14/2012 09:35 AM, Ben Greear wrote: > On 03/14/2012 03:01 AM, igorm at etf.rs wrote: >> From: Igor Maravic >> >> On BSD bison generates header files with .h suffix. >> On other OSs it generates header files with .hh suffix. >> >> Check which OS we use and include appropriate files. > > This still does not work. On my BSD box, the .h file is: > > y.tplt_tab.cc.h > > But, I fixed that. > > Now it complains because it doesn't know about some variable: > > scons: `obj/i386-unknown-freebsd8.1/rib/tools/rib_show_routes' is up to date. > scons: `obj/i386-unknown-freebsd8.1/rib/xorp_rib' is up to date. > flex -Ptplt -t rtrmgr/template.ll> obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.cc > g++ -o obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.o -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align -Woverloaded-virtual > -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i386-unknown-freebsd8.1 -I. -Iobj/i386-unknown-freebsd8.1/rtrmgr -Irtrmgr -I. > obj/i386-unknown-freebsd8.1/rtrmgr/lex.tplt.cc > rtrmgr/template.ll: In function 'int tpltlex()': > rtrmgr/template.ll:269: error: 'tpltlval' was not declared in this scope > rtrmgr/template.ll:274: error: 'tpltlval' was not declared in this scope > rtrmgr/template.ll:279: error: 'tpltlval' was not declared in this scope I committed a patch that lets it compile on my freeBSD system. Please take a look and see if it looks sane to you. Thanks, Ben > > Thanks, > Ben > -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Wed Mar 14 10:17:48 2012 From: noreply at github.com (GitHub) Date: Wed, 14 Mar 2012 10:17:48 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] cf6056: xorp/contrib/win32/xorprtm SVN Rev 11384 Message-ID: <4f60d2bc34ea_70c112caf41839d7@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: cf60560f102f90c43c380758d8d9da5661bd583e https://github.com/greearb/xorp.ct/commit/cf60560f102f90c43c380758d8d9da5661bd583e Author: Victor Miasnikov Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: A xorp/contrib/xorprtm/BUGS A xorp/contrib/xorprtm/BUILD_NOTES A xorp/contrib/xorprtm/README A xorp/contrib/xorprtm/TODO A xorp/contrib/xorprtm/xorprtm/bsdroute.h A xorp/contrib/xorprtm/xorprtm/defs.h A xorp/contrib/xorprtm/xorprtm/list.h A xorp/contrib/xorprtm/xorprtm/loadprotocol.c A xorp/contrib/xorprtm/xorprtm/mibmgr.c A xorp/contrib/xorprtm/xorprtm/mibmgr.h A xorp/contrib/xorprtm/xorprtm/pchsample.h A xorp/contrib/xorprtm/xorprtm/print_rtmsg.c A xorp/contrib/xorprtm/xorprtm/rmapi.c A xorp/contrib/xorprtm/xorprtm/rmapi.h A xorp/contrib/xorprtm/xorprtm/sync.c A xorp/contrib/xorprtm/xorprtm/sync.h A xorp/contrib/xorprtm/xorprtm/test_monitor.c A xorp/contrib/xorprtm/xorprtm/test_routeadd.c A xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c A xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c A xorp/contrib/xorprtm/xorprtm/utils.c A xorp/contrib/xorprtm/xorprtm/utils.h A xorp/contrib/xorprtm/xorprtm/xorprtm.c A xorp/contrib/xorprtm/xorprtm/xorprtm.h A xorp/contrib/xorprtm/xorprtm/xorprtm_internal.h A xorp/contrib/xorprtm/xorprtm4/xorprtm4.def A xorp/contrib/xorprtm/xorprtm6/xorprtm6.def Log Message: ----------- xorp/contrib/win32/xorprtm SVN Rev 11384 xorp/contrib/win32/xorprtm SVN Rev 11384 Signed-off-by: Victor Miasnikov From noreply at github.com Wed Mar 14 10:19:33 2012 From: noreply at github.com (GitHub) Date: Wed, 14 Mar 2012 10:19:33 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] b7a5d6: contrib/win32/xorprtm Fixes related "bsdroute.h" Message-ID: <4f60d3251ec8d_3b53fb2465b02ec229623@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: b7a5d6abb962814227dedd49fd9961350106e928 https://github.com/greearb/xorp.ct/commit/b7a5d6abb962814227dedd49fd9961350106e928 Author: Victor Miasnikov Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: A xorp/contrib/xorprtm/Jam-Run.cmd M xorp/contrib/xorprtm/xorprtm/loadprotocol.c M xorp/contrib/xorprtm/xorprtm/pchsample.h A xorp/contrib/xorprtm/xorprtm4/Jamfile A xorp/contrib/xorprtm/xorprtm6/Jamfile Log Message: ----------- contrib/win32/xorprtm Fixes related "bsdroute.h" contrib/win32/xorprtm Fixes related "bsdroute.h" 1) Add Or move source code line #include "bsdroute.h" 2) xorptm4/Jamfile ( from "SVN Rev 11384" ) 2b) xorptm6/Jamfile ( see "SharedLibrary xorprtm6 :") 3) build script Jam-Run.cmd == set JAM_TOOLSET=VISUALC jam.exe == Signed-off-by: Victor Miasnikov From noreply at github.com Wed Mar 14 10:20:19 2012 From: noreply at github.com (GitHub) Date: Wed, 14 Mar 2012 10:20:19 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] f7d84e: trivial: ws fixes Message-ID: <4f60d353a2a85_46c11cfeae4113132@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: f7d84ee473502375d70dbf6dd5b1682f7929b593 https://github.com/greearb/xorp.ct/commit/f7d84ee473502375d70dbf6dd5b1682f7929b593 Author: Igor Maravic Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/libxorp/range.hh M xorp/rtrmgr/conf_tree.cc M xorp/rtrmgr/template_tree.cc M xorp/rtrmgr/template_tree_node.cc M xorp/rtrmgr/template_tree_node.hh Log Message: ----------- trivial: ws fixes Automaticaly fixed trailing ws with Eclipse From noreply at github.com Wed Mar 14 10:33:12 2012 From: noreply at github.com (GitHub) Date: Wed, 14 Mar 2012 10:33:12 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 0b7c87: xorp: Added support for uint64 type Message-ID: <4f60d658a9d88_3d6e3fd2d9a6eaf0145236@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 0b7c874cd929dfa297653d15f6e49c31717ea26b https://github.com/greearb/xorp.ct/commit/0b7c874cd929dfa297653d15f6e49c31717ea26b Author: Igor Maravic Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/libxorp/range.hh M xorp/rtrmgr/conf_tree.cc M xorp/rtrmgr/template.ll M xorp/rtrmgr/template.yy M xorp/rtrmgr/template_tree.cc M xorp/rtrmgr/template_tree_node.cc M xorp/rtrmgr/template_tree_node.hh Log Message: ----------- xorp: Added support for uint64 type In template.yy and template.ll files added support for uint64 and uin64range types. Their nodes are called NODE_ULONG and NODE_ULONGRANGE respectively. In range.hh added U64Range class. Does everything as U32Range, but with uint64_t instead of uint32_t variables. In template_tree_node.cc and template_tree_node.hh added ULongTemplate and ULongRangeTemplate to handle new types. Unfortunately Eclipse striped whitespaces from changed files, so they are meshed up with the changed code. Signed-off-by: Igor Maravic Commit: 135900a417be7a89f0607f71679f9634b4b060f3 https://github.com/greearb/xorp.ct/commit/135900a417be7a89f0607f71679f9634b4b060f3 Author: Igor Maravic Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/rtrmgr/boot.ll M xorp/rtrmgr/boot.yy Log Message: ----------- xorp: rtrmgr: Add option to read negative int values In boot.ll and boot.yy added option to read negative int values. Positive int values are read as uint values. Signed-off-by: Igor Maravic Commit: f8c934d8c548aa78f8fb6d450c3074531c8bb479 https://github.com/greearb/xorp.ct/commit/f8c934d8c548aa78f8fb6d450c3074531c8bb479 Author: Igor Maravic Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/rtrmgr/conf_tree.cc Log Message: ----------- xorp: rtrmgr: Enable reading of positive integers Positive integers are read as uint. Change type from NODE_UINT to NODE_INT so they could be read. Signed-off-by: Igor Maravic Commit: 690f3fac70f593a164a34ce3be8a00f490ebabae https://github.com/greearb/xorp.ct/commit/690f3fac70f593a164a34ce3be8a00f490ebabae Author: Igor Maravic Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/rtrmgr/template_tree.cc Log Message: ----------- xorp: rtrmgr: Enable i32 and u64 multi value nodes to boot up Positive int and u64 values are read as uint. If our node is of type NODE_ULONG or NODE_INT and read type is of type NODE_UINT, than we have a match. Signed-off-by: Igor Maravic Compare: https://github.com/greearb/xorp.ct/compare/f7d84ee...690f3fa From greearb at candelatech.com Wed Mar 14 10:38:26 2012 From: greearb at candelatech.com (Ben Greear) Date: Wed, 14 Mar 2012 10:38:26 -0700 Subject: [Xorp-hackers] Recent Xorp patches. Message-ID: <4F60D792.1020506@candelatech.com> First, thanks for all of the recent patches! I just committed a bunch of patches. I probably missed a few that were recently submitted, so if you notice a patch I skipped, please re-send it to the list. For anyone able to test out XORP, please pull down the latest code and see if it works for you. In particular, I would not be surprised if Open or NetBSD has issues compiling related to the lex/yacc changes. Send logs if you see failures and we'll try to fix them. I have no idea if the Windows changes work properly or not, so please test those as well if you are using that platform. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From greearb at candelatech.com Wed Mar 14 10:47:36 2012 From: greearb at candelatech.com (Ben Greear) Date: Wed, 14 Mar 2012 10:47:36 -0700 Subject: [Xorp-hackers] Xorp indentation Message-ID: <4F60D9B8.70709@candelatech.com> It seems that the indentation in use in xorp is: Indentation is 4 spaces. Tabs are 8 spaces. A block of 8 spaces is replaced with a tab. There is some config at the top of each file that makes emacs do this properly: // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- I'm unsure of other editors, but if someone can document how to do this in eclipse and other editors, please do so. Regardless of personal preferences, I think we should leave the basic indentation rules as they are and follow them so that the code remains consistent and we are not constantly doing trivial white-space changes that obscure the 'git blame' and similar functionality. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Wed Mar 14 12:05:26 2012 From: noreply at github.com (GitHub) Date: Wed, 14 Mar 2012 12:05:26 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 7d5ab6: ulongtemplate: Fix build on 32-bit systems. Message-ID: <4f60ebf63819c_32793fb0ee4612f0191180@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 7d5ab6d874c420f0f4d2c8861591ad60e8c0c016 https://github.com/greearb/xorp.ct/commit/7d5ab6d874c420f0f4d2c8861591ad60e8c0c016 Author: Ben Greear Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/rtrmgr/template_tree_node.cc Log Message: ----------- ulongtemplate: Fix build on 32-bit systems. Use ostringstream instead of sprintf...sprintf has compiler warnings based on %lu and uint64_t not matching properly. Signed-off-by: Ben Greear From noreply at github.com Wed Mar 14 12:33:22 2012 From: noreply at github.com (GitHub) Date: Wed, 14 Mar 2012 12:33:22 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 3b5804: bsd: Another attempt at fixing the flex/yacc issu... Message-ID: <4f60f282af3af_5a7ae03ae4266e7@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 3b5804d2a3f31e74e9b10376baa81e7a2a5a2104 https://github.com/greearb/xorp.ct/commit/3b5804d2a3f31e74e9b10376baa81e7a2a5a2104 Author: Ben Greear Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/rtrmgr/SConscript Log Message: ----------- bsd: Another attempt at fixing the flex/yacc issues. Guess I forgot to fully clean before declaring my previous fix a fix. Signed-off-by: Ben Greear From noreply at github.com Wed Mar 14 14:43:54 2012 From: noreply at github.com (GitHub) Date: Wed, 14 Mar 2012 14:43:54 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 5d24b7: bool: Don't redefine 'bool' type if stdbool.h exis... Message-ID: <4f61111a7a9ed_38a3f86a40122f413014b@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 5d24b726961aceff322e7734c9a54248a2f36b43 https://github.com/greearb/xorp.ct/commit/5d24b726961aceff322e7734c9a54248a2f36b43 Author: Ben Greear Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/libxorp/xorp.h M xorp/site_scons/config/allconfig.py Log Message: ----------- bool: Don't redefine 'bool' type if stdbool.h exists. Helps fix some problems seen on BSD system. Signed-off-by: Ben Greear Commit: c7521b5979e72edec3b6a4004ec6cd10ce0b2fb8 https://github.com/greearb/xorp.ct/commit/c7521b5979e72edec3b6a4004ec6cd10ce0b2fb8 Author: Ben Greear Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/fea/data_plane/io/io_link_pcap.hh Log Message: ----------- netbsd: Work around pcap header file bugs. This fixes this error: g++ -o obj/x86_64-unknown-netbsd6.0./fea/data_plane/io/io_link_pcap.os -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -fPIC -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/x86_64-unknown-netbsd6.0. -I. -I. fea/data_plane/io/io_link_pcap.cc In file included from fea/data_plane/io/io_link_pcap.hh:36:0, from fea/data_plane/io/io_link_pcap.cc:45: /usr/include/pcap/bpf.h:382:8: error: previous declaration of 'u_int bpf_filter(const bpf_insn*, const u_char*, u_int, u_int)' with 'C++' linkage /usr/include/pcap.h:354:71: error: conflicts with new declaration with 'C' linkage /usr/include/pcap/bpf.h:381:6: error: previous declaration of 'int bpf_validate(const bpf_insn*, int)' with 'C++' linkage /usr/include/pcap.h:355:51: error: conflicts with new declaration with 'C' linkage scons: *** [obj/x86_64-unknown-netbsd6.0./fea/data_plane/io/io_link_pcap.os] Error 1 scons: building terminated because of errors. Signed-off-by: Ben Greear Commit: 5f48b66c0dad8708d399529d13288228f5657c1e https://github.com/greearb/xorp.ct/commit/5f48b66c0dad8708d399529d13288228f5657c1e Author: Ben Greear Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/SConstruct M xorp/rtrmgr/boot.ll M xorp/rtrmgr/op_commands.cc M xorp/rtrmgr/op_commands.ll M xorp/rtrmgr/template.ll Log Message: ----------- bsd/lex: Newer BSD doesn't need lex hack, so make user enable it explicitly. This fixes compile on newer BSD..will see if it works elsewhere! Signed-off-by: Ben Greear Compare: https://github.com/greearb/xorp.ct/compare/3b5804d...5f48b66 From noreply at github.com Wed Mar 14 16:18:26 2012 From: noreply at github.com (GitHub) Date: Wed, 14 Mar 2012 16:18:26 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] da8e4b: Update BUILD_NOTES. Message-ID: <4f61274223bca_31941b4eaf02319c@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: da8e4ba3014105a3ce7e677a2a14a08038231710 https://github.com/greearb/xorp.ct/commit/da8e4ba3014105a3ce7e677a2a14a08038231710 Author: Ben Greear Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M xorp/BUILD_NOTES Log Message: ----------- Update BUILD_NOTES. Still lots of cruft..but a bit less now, and add a note that might help older BSD systems compile (enable_lex_hack=true). Signed-off-by: Ben Greear Commit: 3e1eb42e6fcbc988a0035fadec282fd4feff708d https://github.com/greearb/xorp.ct/commit/3e1eb42e6fcbc988a0035fadec282fd4feff708d Author: Ben Greear Date: 2012-03-14 (Wed, 14 Mar 2012) Changed paths: M README M xorp/Makefile.deb M xorp/VERSION M xorp/package_files/xorp.ct.spec Log Message: ----------- Update to version 1.8.6-WIP. Should have done this right after releasing 1.8.5. Will remove the WIP (work-in-progress) as release time approaches. Signed-off-by: Ben Greear Compare: https://github.com/greearb/xorp.ct/compare/5f48b66...3e1eb42 From igorm at etf.rs Thu Mar 15 02:03:27 2012 From: igorm at etf.rs (=?ISO-8859-2?Q?Igor_Maravi=E6?=) Date: Thu, 15 Mar 2012 10:03:27 +0100 Subject: [Xorp-hackers] Xorp indentation In-Reply-To: <4F60D9B8.70709@candelatech.com> References: <4F60D9B8.70709@candelatech.com> Message-ID: Hi, I can do that in Eclipse :) I'm sending the xml file for Eclipse. It can be imported via Window->Preferences->C/C++->Code Style->Import BR Igor 2012/3/14 Ben Greear : > It seems that the indentation in use in xorp is: > > Indentation is 4 spaces. > Tabs are 8 spaces. > A block of 8 spaces is replaced with a tab. > > There is some config at the top of each file that makes emacs > do this properly: > > // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- > > I'm unsure of other editors, but if someone can document how to > do this in eclipse and other editors, please do so. ?Regardless > of personal preferences, I think we should leave the basic > indentation rules as they are and follow them so that the > code remains consistent and we are not constantly doing > trivial white-space changes that obscure the 'git blame' > and similar functionality. > > Thanks, > Ben > > -- > Ben Greear > Candela Technologies Inc ?http://www.candelatech.com > > _______________________________________________ > Xorp-hackers mailing list > Xorp-hackers at icir.org > http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers -------------- next part -------------- A non-text attachment was scrubbed... Name: xorpEclipse.xml Type: text/xml Size: 17506 bytes Desc: not available Url : http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120315/bbba0f8c/attachment-0001.xml From vvm at tut.by Thu Mar 15 04:07:56 2012 From: vvm at tut.by (Victor Miasnikov) Date: Thu, 15 Mar 2012 14:07:56 +0300 Subject: [Xorp-hackers] [PATCH] contrib/win32/xorprtm (c) 2001-2012 XORP, Inc and Others References: <2C8BF29373924F93A6E557BEC741B54F@local.st.by> <4F60C3E5.1000001@candelatech.com> Message-ID: Hi! > On 03/14/2012 07:41 AM, Victor Miasnikov wrote: >> From: Victor Miasnikov > Did you write this xorprtm code originally, or work on submit > changes while not employed by XORP, Inc? My code changes: See screenshot: == C:\src\xorprtm_Var_xorprtm v1.6_.7z_And_xorprtm6___\xorprtm6>diff -u Jamfile-00 Jamfile --- Jamfile-00 Thu Jun 29 14:06:51 2006 +++ Jamfile Thu Jun 29 14:08:51 2006 @@ -22,7 +22,7 @@ # XXX: We have a problem; we can't currently build both protocol versions # of the DLL without rearranging the directory structure. # -SharedLibrary xorprtm4 : xorprtm.c mibmgr.c rmapi.c sync.c utils.c ; +SharedLibrary xorprtm6 : xorprtm.c mibmgr.c rmapi.c sync.c utils.c ; # Protocol shim activation program. C:\src\xorprtm_Var_xorprtm v1.6_.7z_And_xorprtm6___\xorprtm4>diff -u loadprotocol.c-0 loadprotocol.c --- loadprotocol.c-0 Mon Jan 05 20:30:48 2009 +++ loadprotocol.c Fri Aug 14 13:17:20 2009 @@ -45,6 +45,11 @@ #include "xorprtm.h" +/* [ VVM*/ +#include "bsdroute.h" +/* ] VVM*/ + + HRESULT add_protocol_to_rras(int family) { C:\src\xorprtm_Var_xorprtm_v1.6_.7z___>diff -u pchsample.h-0 pchsample.h --- pchsample.h-0 Mon Jan 05 20:30:48 2009 +++ pchsample.h Fri Aug 14 13:12:56 2009 @@ -56,9 +56,19 @@ #include "defs.h" #include "utils.h" +/* [ VVM */ +#include "bsdroute.h" +/* ] VVM */ + + #include "xorprtm_internal.h" #include "mibmgr.h" +/* [ VVM */ +/* #include "bsdroute.h" +*/ +/* ] VVM */ + #endif === Who write other code -- need be look on SVN . . . >> contrib/win32/xorprtm (c) 2001-2012 XORP, Inc and Others >> - * Copyright (c) 2001-2009 XORP, Inc. >> + * Copyright (c) 2001-2012 XORP, Inc and Others > To date, we have only updated the copyright on a file > when it has been changed, Ok, I'm can make+send [PATCH] only for changed files > and I have a script that will take care of this near release time. Or not need send new [PATCH] ? For me _personaly_ (c) -- not important . . . Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ ----- Original Message ----- From: "Ben Greear" To: "Victor Miasnikov" Cc: xorp-hackers Sent: Wednesday, March 14, 2012 7:14 PM Subject: Re: [PATCH] contrib/win32/xorprtm (c) 2001-2012 XORP, Inc and Others On 03/14/2012 07:41 AM, Victor Miasnikov wrote: > From: Victor Miasnikov > > contrib/win32/xorprtm (c) 2001-2012 XORP, Inc and Others > > Signed-off-by: Victor Miasnikov > --- > diff --git a/xorp/contrib/xorprtm/xorprtm/bsdroute.h b/xorp/contrib/xorprtm/xorprtm/bsdroute.h > index 87e6972..c76ec43 100644 > --- a/xorp/contrib/xorprtm/xorprtm/bsdroute.h > +++ b/xorp/contrib/xorprtm/xorprtm/bsdroute.h . . . > /* > - * Copyright (c) 2001-2009 XORP, Inc. > + * Copyright (c) 2001-2012 XORP, Inc and Others > * . . . To date, we have only updated the copyright on a file when it has been changed, and I have a script that will take care of this near release time. Did you write this xorprtm code originally, or work on submit changes while not employed by XORP, Inc? Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From igorm at etf.rs Thu Mar 15 05:39:57 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Thu, 15 Mar 2012 13:39:57 +0100 Subject: [Xorp-hackers] [PATCH 1/2] trivial: ws fixes In-Reply-To: References: Message-ID: <1331815198-24512-1-git-send-email-igorm@etf.rs> From: Igor Maravic Eclipse automaticaly striped trailing ws. Signed-off-by: Igor Maravic --- xorp/rtrmgr/conf_tree_node.cc | 78 +++++++++++++++++----------------- xorp/rtrmgr/conf_tree_node.hh | 26 ++++++------ xorp/rtrmgr/master_conf_tree.cc | 12 +++--- xorp/rtrmgr/template_base_command.cc | 16 ++++---- xorp/rtrmgr/template_commands.cc | 26 ++++++------ 5 files changed, 79 insertions(+), 79 deletions(-) diff --git a/xorp/rtrmgr/conf_tree_node.cc b/xorp/rtrmgr/conf_tree_node.cc index 03c609d..12adc59 100644 --- a/xorp/rtrmgr/conf_tree_node.cc +++ b/xorp/rtrmgr/conf_tree_node.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -103,7 +103,7 @@ ConfigTreeNode::ConfigTreeNode(bool verbose) } ConfigTreeNode::ConfigTreeNode(const string& nodename, - const string& path, + const string& path, const TemplateTreeNode* ttn, ConfigTreeNode* parent, const ConfigNodeId& node_id, @@ -275,7 +275,7 @@ ConfigTreeNode::add_default_children() string name = ttn->segname(); string path = _path + " " + name; ConfigTreeNode *new_node = create_node(name, path, ttn, - this, + this, ConfigNodeId::ZERO(), _user_id, _clientid, @@ -313,7 +313,7 @@ ConfigTreeNode::check_allowed_value(string& error_msg) const return (check_allowed_value(_value, error_msg)); } -bool +bool ConfigTreeNode::check_allowed_value(const string& value, string& error_msg) const { @@ -323,7 +323,7 @@ ConfigTreeNode::check_allowed_value(const string& value, return (_template_tree_node->check_allowed_value(value, error_msg)); } -bool +bool ConfigTreeNode::check_allowed_operator(const string& value, string& error_msg) const { @@ -393,7 +393,7 @@ ConfigTreeNode::set_operator_without_verification(ConfigOperator op, bool ConfigTreeNode::merge_deltas(uid_t user_id, - const ConfigTreeNode& delta_node, + const ConfigTreeNode& delta_node, bool provisional_change, bool preserve_node_id, string& error_msg) @@ -404,7 +404,7 @@ ConfigTreeNode::merge_deltas(uid_t user_id, XLOG_ASSERT(type() == delta_node.type()); if (delta_node.is_leaf_value()) { - if (_value != delta_node.value() + if (_value != delta_node.value() || _operator != delta_node.get_operator()) { _has_value = true; if (provisional_change) { @@ -456,7 +456,7 @@ XXXXXXX to be copied to MasterConfigTreeNode iter != delta_node.const_children().end(); ++iter) { ConfigTreeNode *delta_child = *iter; - + bool delta_child_done = false; list::iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -498,7 +498,7 @@ XXXXXXX to be copied to MasterConfigTreeNode bool ConfigTreeNode::merge_deletions(uid_t user_id, - const ConfigTreeNode& deletion_node, + const ConfigTreeNode& deletion_node, bool provisional_change, string& error_msg) { @@ -522,7 +522,7 @@ ConfigTreeNode::merge_deletions(uid_t user_id, return true; } } - + list::const_iterator iter; for (iter = deletion_node.const_children().begin(); iter != deletion_node.const_children().end(); @@ -535,7 +535,7 @@ ConfigTreeNode::merge_deletions(uid_t user_id, ConfigTreeNode *my_child = *ci; if (my_child->segname() == deletion_child->segname()) { deletion_child_done = true; - bool success = my_child->merge_deletions(user_id, + bool success = my_child->merge_deletions(user_id, *deletion_child, provisional_change, error_msg); @@ -695,7 +695,7 @@ ConfigTreeNode::discard_changes(int depth, int last_depth) if (_template_tree_node != NULL) { if (_existence_committed == false) { bool show_top = (depth > 0); - result = show_subtree(show_top, depth, /* XXX */ depth * 2, true, + result = show_subtree(show_top, depth, /* XXX */ depth * 2, true, /* numbered */ false, false, false); delete_subtree_silently(); return result; @@ -709,12 +709,12 @@ ConfigTreeNode::discard_changes(int depth, int last_depth) _user_id = _committed_user_id; _modification_time = _committed_modification_time; result = node_str(); - if (is_leaf_value()) + if (is_leaf_value()) result += "\n"; else result += " {\n"; changes_made = true; - } + } } list::iterator iter, prev_iter; @@ -909,7 +909,7 @@ ConfigTreeNode::show_subtree(bool show_top, int depth, int indent, if (_template_tree_node != NULL) is_a_tag = is_tag(); - for (int i = 0; i < indent; i++) + for (int i = 0; i < indent; i++) my_in += " "; if (is_a_tag && show_top) { @@ -943,9 +943,9 @@ ConfigTreeNode::show_subtree(bool show_top, int depth, int indent, break; } while (false); } - s += my_in + show_node_id(numbered, child_ctn->node_id()) + s += my_in + show_node_id(numbered, child_ctn->node_id()) + _segname + " " + - child_ctn->show_subtree(show_top, depth, indent, false, + child_ctn->show_subtree(show_top, depth, indent, false, numbered, annotate, suppress_default_values); } @@ -982,7 +982,7 @@ ConfigTreeNode::show_subtree(bool show_top, int depth, int indent, if ((type() == NODE_TEXT) && is_quotable_string(_segname)) { s += quoted_value(_segname); } else { - s += _segname; + s += _segname; } } if ((type() != NODE_VOID) && (_has_value)) { @@ -1017,7 +1017,7 @@ ConfigTreeNode::show_subtree(bool show_top, int depth, int indent, s += " {\n"; list::const_iterator iter; for (iter = _children.begin(); iter != _children.end(); ++iter) { - s += (*iter)->show_subtree(true, depth + 1, new_indent, true, + s += (*iter)->show_subtree(true, depth + 1, new_indent, true, numbered, annotate, suppress_default_values); } @@ -1026,7 +1026,7 @@ ConfigTreeNode::show_subtree(bool show_top, int depth, int indent, new_indent = indent; list::const_iterator iter; for (iter = _children.begin(); iter != _children.end(); ++iter) { - s += (*iter)->show_subtree(true, depth + 1, new_indent, true, + s += (*iter)->show_subtree(true, depth + 1, new_indent, true, numbered, annotate, suppress_default_values); } @@ -1163,7 +1163,7 @@ ConfigTreeNode::node_str() const // // TODO: this method is not used. What is the difference between // str() and node_str() ?? -// +// string ConfigTreeNode::str() const { @@ -1641,7 +1641,7 @@ ConfigTreeNode::find_varname_node(const string& varname, VarType& type) } ConfigTreeNode* -ConfigTreeNode::find_parent_varname_node(const list& var_parts, +ConfigTreeNode::find_parent_varname_node(const list& var_parts, VarType& type) { debug_msg("find parent at node %s\n", _segname.c_str()); @@ -1668,7 +1668,7 @@ ConfigTreeNode::find_parent_varname_node(const list& var_parts, } ConfigTreeNode* -ConfigTreeNode::find_child_varname_node(const list& var_parts, +ConfigTreeNode::find_child_varname_node(const list& var_parts, VarType& type) { string s; @@ -1708,9 +1708,9 @@ ConfigTreeNode::find_child_varname_node(const list& var_parts, } if ((var_parts.front() != "@") - && (var_parts.front() != _segname) - && (var_parts.front() != "<>") - && (var_parts.front() != "#") + && (var_parts.front() != _segname) + && (var_parts.front() != "<>") + && (var_parts.front() != "#") && ((!_has_value) || (var_parts.front() != _value))) { // varname doesn't match us. type = NONE; @@ -1771,7 +1771,7 @@ ConfigTreeNode::find_child_varname_node(const list& var_parts, } bool -ConfigTreeNode::split_up_varname(const string& varname, +ConfigTreeNode::split_up_varname(const string& varname, list& var_parts) const { debug_msg("split up varname >%s<\n", varname.c_str()); @@ -1854,7 +1854,7 @@ ConfigTreeNode::expand_varname_to_matchlist(const vector& parts, XLOG_ASSERT(parts[part] == "*"); matches.push_back(_segname); return; - } + } // // Search the children. If no more children, return the result so far @@ -1888,7 +1888,7 @@ ConfigTreeNode::set_variable(const string& varname, const string& value) // This can't happen XLOG_UNREACHABLE(); break; - case NODE_VALUE: + case NODE_VALUE: if (node->is_read_only()) { string reason = node->read_only_reason(); errmsg = c_format("Attempt to set node \"%s\" " @@ -1906,13 +1906,13 @@ ConfigTreeNode::set_variable(const string& varname, const string& value) return false; } return true; - case NODE_OPERATOR: + case NODE_OPERATOR: errmsg = c_format("Attempt to set variable operator \"%s\" " "which is the name of a configuration node", varname.c_str()); XLOG_ERROR("%s", errmsg.c_str()); return false; - case NODE_ID: + case NODE_ID: errmsg = c_format("Attempt to set variable node ID \"%s\" " "which is not user-settable", varname.c_str()); @@ -1928,7 +1928,7 @@ ConfigTreeNode::set_variable(const string& varname, const string& value) node->set_named_value(var_parts.back(), value); return true; } - case TEMPLATE_DEFAULT: + case TEMPLATE_DEFAULT: // XXX: Ignore, and attempt to set a named variable below. break; } @@ -2043,10 +2043,10 @@ ConfigTreeNode::sort_by_template(list& children) const #else children.sort(CTN_Compare()); #endif -} +} string -ConfigTreeNode::show_node_id(bool numbered, const ConfigNodeId& node_id) const +ConfigTreeNode::show_node_id(bool numbered, const ConfigNodeId& node_id) const { string s; if (numbered) { @@ -2056,7 +2056,7 @@ ConfigTreeNode::show_node_id(bool numbered, const ConfigNodeId& node_id) const } void -ConfigTreeNode::allocate_unique_node_id() +ConfigTreeNode::allocate_unique_node_id() { ConfigTreeNode *prev = NULL, *next = NULL; ConfigTreeNode *effective_parent = _parent; @@ -2077,7 +2077,7 @@ ConfigTreeNode::allocate_unique_node_id() sort_by_template(sorted_children); bool found_this = false; list::iterator iter; - for (iter = sorted_children.begin(); + for (iter = sorted_children.begin(); iter != sorted_children.end(); ++iter) { if ((*iter) == this) { @@ -2114,7 +2114,7 @@ ConfigTreeNode::allocate_unique_node_id() debug_msg("finding order (phase 2)...\n"); list sorted_children = effective_parent->children(); sort_by_template(sorted_children); - for (iter = sorted_children.begin(); + for (iter = sorted_children.begin(); iter != sorted_children.end(); ++iter) { if ((*iter) == _parent) { @@ -2208,7 +2208,7 @@ ConfigTreeNode::update_node_id_position() XLOG_ASSERT(effective_parent != NULL); sorted_children = effective_parent->children(); sort_by_template(sorted_children); - for (iter = sorted_children.begin(); + for (iter = sorted_children.begin(); iter != sorted_children.end(); ++iter) { ConfigTreeNode* ctn = *iter; diff --git a/xorp/rtrmgr/conf_tree_node.hh b/xorp/rtrmgr/conf_tree_node.hh index a0d4358..0101a00 100644 --- a/xorp/rtrmgr/conf_tree_node.hh +++ b/xorp/rtrmgr/conf_tree_node.hh @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -54,7 +54,7 @@ class ConfigTreeNode { public: ConfigTreeNode(bool verbose); ConfigTreeNode(const ConfigTreeNode& ctn); - ConfigTreeNode(const string& node_name, const string& path, + ConfigTreeNode(const string& node_name, const string& path, const TemplateTreeNode* ttn, ConfigTreeNode* parent, const ConfigNodeId& node_id, uid_t user_id, uint32_t clientid, bool verbose); @@ -62,14 +62,14 @@ public: bool operator==(const ConfigTreeNode& them) const; bool is_same(const ConfigTreeNode& them, bool ignore_node_id) const; - - virtual ConfigTreeNode* create_node(const string& segment, + + virtual ConfigTreeNode* create_node(const string& segment, const string& path, - const TemplateTreeNode* ttn, - ConfigTreeNode* parent_node, + const TemplateTreeNode* ttn, + ConfigTreeNode* parent_node, const ConfigNodeId& node_id, - uid_t user_id, - uint32_t clientid, + uid_t user_id, + uint32_t clientid, bool verbose) = 0; virtual ConfigTreeNode* create_node(const ConfigTreeNode& ctn) = 0; @@ -93,7 +93,7 @@ public: bool preserve_node_id, string& error_msg); - bool merge_deletions(uid_t user_id, const ConfigTreeNode& deletion_node, + bool merge_deletions(uid_t user_id, const ConfigTreeNode& deletion_node, bool provisional_change, string& error_msg); ConfigTreeNode* find_config_module(const string& module_name); @@ -147,7 +147,7 @@ public: void mark_subtree_for_deletion(uid_t user_id); void delete_subtree_silently(); void clone_subtree(const ConfigTreeNode& orig_node); - bool retain_different_nodes(const ConfigTreeNode& them, + bool retain_different_nodes(const ConfigTreeNode& them, bool retain_changed_values); bool retain_deletion_nodes(const ConfigTreeNode& them, bool retain_value_changed); @@ -178,10 +178,10 @@ protected: bool split_up_varname(const string& varname, list& var_parts) const; string join_up_varname(const list& var_parts) const; - enum VarType { NONE, NODE_VALUE, NODE_OPERATOR, NODE_ID, + enum VarType { NONE, NODE_VALUE, NODE_OPERATOR, NODE_ID, NAMED, TEMPLATE_DEFAULT }; ConfigTreeNode* find_varname_node(const string& varname, VarType& type); - const ConfigTreeNode* find_const_varname_node(const string& varname, + const ConfigTreeNode* find_const_varname_node(const string& varname, VarType& type) const; ConfigTreeNode* find_parent_varname_node(const list& var_parts, VarType& type); diff --git a/xorp/rtrmgr/master_conf_tree.cc b/xorp/rtrmgr/master_conf_tree.cc index b4ee578..b6b8dc0 100644 --- a/xorp/rtrmgr/master_conf_tree.cc +++ b/xorp/rtrmgr/master_conf_tree.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -115,7 +115,7 @@ MasterConfigTree::MasterConfigTree(const string& config_file, string error_msg; _current_node = &_root_node; - _task_manager = new TaskManager(*this, mmgr, xclient, + _task_manager = new TaskManager(*this, mmgr, xclient, global_do_exec, verbose); #ifdef HAVE_GRP_H @@ -294,8 +294,8 @@ MasterConfigTree::config_done(bool success, string error_msg) ConfigTreeNode* MasterConfigTree::create_node(const string& segment, const string& path, - const TemplateTreeNode* ttn, - ConfigTreeNode* parent_node, + const TemplateTreeNode* ttn, + ConfigTreeNode* parent_node, const ConfigNodeId& node_id, uid_t user_id, bool verbose) { @@ -1169,7 +1169,7 @@ MasterConfigTree::apply_config_commit_changes_cb(bool success, _config_tree_copy->diff_configs(*this, delta_tree, deletion_tree); deltas = delta_tree.show_unannotated_tree(/*numbered*/ true); deletions = deletion_tree.show_unannotated_tree(/*numbered*/ true); - + cb->dispatch(success, error_msg, deltas, deletions); } diff --git a/xorp/rtrmgr/template_base_command.cc b/xorp/rtrmgr/template_base_command.cc index dbcb8e9..62de9b6 100644 --- a/xorp/rtrmgr/template_base_command.cc +++ b/xorp/rtrmgr/template_base_command.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -37,7 +37,7 @@ #include "util.hh" #include "config_operators.hh" -BaseCommand::BaseCommand(TemplateTreeNode& template_tree_node, +BaseCommand::BaseCommand(TemplateTreeNode& template_tree_node, const string& cmd_name) : _template_tree_node(template_tree_node) { @@ -56,7 +56,7 @@ BaseCommand::str() const return tmp; } - + // ---------------------------------------------------------------------------- // AllowCommand implementation @@ -66,7 +66,7 @@ AllowCommand::AllowCommand(TemplateTreeNode& template_tree_node, { } - + // ---------------------------------------------------------------------------- // AllowOptionsCommand implementation @@ -268,7 +268,7 @@ AllowOptionsCommand::str() const return tmp; } - + // ---------------------------------------------------------------------------- // AllowOperatorsCommand implementation @@ -322,7 +322,7 @@ AllowOperatorsCommand::add_action(const list& action) } catch (const ParseError& e) { error_msg = c_format("%%allow-operator command with invalid " "operator: %s", op_str.c_str()); - xorp_throw(ParseError, error_msg); + xorp_throw(ParseError, error_msg); } if (find(_allowed_operators.begin(), _allowed_operators.end(), op) == _allowed_operators.end()) { @@ -429,7 +429,7 @@ AllowOperatorsCommand::str() const tmp += "\n"; return tmp; } - + // ---------------------------------------------------------------------------- // AllowRangeCommand implementation diff --git a/xorp/rtrmgr/template_commands.cc b/xorp/rtrmgr/template_commands.cc index 0072b6b..8164d72 100644 --- a/xorp/rtrmgr/template_commands.cc +++ b/xorp/rtrmgr/template_commands.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -448,7 +448,7 @@ XrlAction::check_xrl_is_valid(const list& action, cleaned_xrl += xrl_str[i]; break; } - if ((xrl_str.size() > i) + if ((xrl_str.size() > i) && (xrl_str[i] == '-') && (xrl_str[i+1] == '>')) { /* it's the start of the return spec */ cleaned_xrl += xrl_str[i]; @@ -633,7 +633,7 @@ XrlAction::expand_xrl_variables(const TreeNode& tn, } command = cmd_parts.back(); cmd_parts.pop_back(); - + // put the target name back together again string target; while (!cmd_parts.empty()) { @@ -647,7 +647,7 @@ XrlAction::expand_xrl_variables(const TreeNode& tn, // now process the args. XrlArgs xrl_args; - + list::const_iterator iter; for (iter = args.begin(); iter != args.end(); ++iter) { @@ -670,7 +670,7 @@ XrlAction::expand_xrl_variables(const TreeNode& tn, } // check that this is a legal XrlAtom type - // it really shouldn't be possible for this to fail given + // it really shouldn't be possible for this to fail given // earlier checks XrlAtomType arg_type = XrlAtom::lookup_type(type.c_str()); if (arg_type == xrlatom_no_type) { @@ -679,18 +679,18 @@ XrlAction::expand_xrl_variables(const TreeNode& tn, _request.c_str(), tn.path().c_str()); return NULL; } - + string expanded_value; if (!expand_vars(tn, value, expanded_value)) { error_msg = expanded_value; return NULL; } - // At this point we've expanded all the variables. + // At this point we've expanded all the variables. // Now it's time to build an XrlAtom try { debug_msg("Atom: %s\n", expanded_value.c_str()); - XrlAtom atom(name, arg_type, + XrlAtom atom(name, arg_type, xrlatom_encode_value(expanded_value.c_str(), expanded_value.size())); xrl_args.add(atom); @@ -701,7 +701,7 @@ XrlAction::expand_xrl_variables(const TreeNode& tn, return NULL; } } - + // Now we've got a arg list. Time to build an Xrl Xrl* xrl = new Xrl(target, command, xrl_args); debug_msg("Xrl expanded to %s\n", xrl->str().c_str()); @@ -1266,7 +1266,7 @@ ProgramAction::affected_module() const /***********************************************************************/ Command::Command(TemplateTreeNode& template_tree_node, const string& cmd_name) - : BaseCommand(template_tree_node, cmd_name) + : BaseCommand(template_tree_node, cmd_name) { debug_msg("Command constructor: %s\n", cmd_name.c_str()); } @@ -1305,7 +1305,7 @@ Command::add_action(const list& action, const XRLdb* xrldb) error_msg = c_format("Unknown action \"%s\". Expected actions: " "\"%s\", \"%s\".", action_type.c_str(), "xrl", "program"); - xorp_throw(ParseError, error_msg); + xorp_throw(ParseError, error_msg); } int @@ -1552,7 +1552,7 @@ template bool XrlAction::expand_vars( template bool XrlAction::expand_vars( const TemplateTreeNode& ctn, const string& value, string& result) const; - + template int ProgramAction::expand_program_variables( const MasterConfigTreeNode& ctn, -- 1.7.5.4 From igorm at etf.rs Thu Mar 15 05:39:58 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Thu, 15 Mar 2012 13:39:58 +0100 Subject: [Xorp-hackers] [PATCH 2/2] trivial: ws fixes In-Reply-To: <1331815198-24512-1-git-send-email-igorm@etf.rs> References: <1331815198-24512-1-git-send-email-igorm@etf.rs> Message-ID: <1331815198-24512-2-git-send-email-igorm@etf.rs> From: Igor Maravic Eclipse automaticaly striped trailing ws Signed-off-by: Igor Maravic --- xorp/libxipc/xrl_atom.cc | 8 ++++---- xorp/libxipc/xrl_atom.hh | 4 ++-- xorp/rtrmgr/unexpanded_xrl.cc | 8 ++++---- xorp/rtrmgr/xorp_client.cc | 18 +++++++++--------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/xorp/libxipc/xrl_atom.cc b/xorp/libxipc/xrl_atom.cc index 5106e4a..a31d54a 100644 --- a/xorp/libxipc/xrl_atom.cc +++ b/xorp/libxipc/xrl_atom.cc @@ -9,13 +9,13 @@ // Redistribution and/or modification of this program under the terms of // any other version of the GNU Lesser General Public License is not // permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU Lesser General Public License, Version 2.1, a copy of // which can be found in the XORP LICENSE.lgpl file. -// +// // XORP, Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -945,7 +945,7 @@ size_t XrlAtom::unpack_ipv6(const uint8_t* buffer) { uint32_t a[4]; - + if (_type == xrlatom_no_type) { memcpy(a, buffer, sizeof(a)); _ipv6 = new IPv6(a); @@ -1168,7 +1168,7 @@ XrlAtom::unpack_binary(const uint8_t* buffer, size_t buffer_bytes) _binary = 0; return 0; } - + if (_type != xrlatom_no_type) delete _binary; diff --git a/xorp/libxipc/xrl_atom.hh b/xorp/libxipc/xrl_atom.hh index 3a4f73f..ba996d6 100644 --- a/xorp/libxipc/xrl_atom.hh +++ b/xorp/libxipc/xrl_atom.hh @@ -9,13 +9,13 @@ // Redistribution and/or modification of this program under the terms of // any other version of the GNU Lesser General Public License is not // permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU Lesser General Public License, Version 2.1, a copy of // which can be found in the XORP LICENSE.lgpl file. -// +// // XORP, Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net diff --git a/xorp/rtrmgr/unexpanded_xrl.cc b/xorp/rtrmgr/unexpanded_xrl.cc index 6f48291..fa07b6c 100644 --- a/xorp/rtrmgr/unexpanded_xrl.cc +++ b/xorp/rtrmgr/unexpanded_xrl.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -32,7 +32,7 @@ UnexpandedXrl::UnexpandedXrl(const MasterConfigTreeNode& node, - const XrlAction& action) + const XrlAction& action) : _node(node), _action(action), _xrl(NULL) @@ -47,7 +47,7 @@ UnexpandedXrl::~UnexpandedXrl() /** * Expand expands the variables in the unexpanded XRL, and creates an - * XRL that we can actually send. + * XRL that we can actually send. */ Xrl* UnexpandedXrl::expand(string& errmsg) const diff --git a/xorp/rtrmgr/xorp_client.cc b/xorp/rtrmgr/xorp_client.cc index 1bbd81e..a1df523 100644 --- a/xorp/rtrmgr/xorp_client.cc +++ b/xorp/rtrmgr/xorp_client.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -38,7 +38,7 @@ /* XorpClient */ /***********************************************************************/ -XorpClient::XorpClient(EventLoop& eventloop, XrlRouter& xrl_router) +XorpClient::XorpClient(EventLoop& eventloop, XrlRouter& xrl_router) : _eventloop(eventloop), _xrl_router(xrl_router) { @@ -49,8 +49,8 @@ XorpClient::~XorpClient() { } void -XorpClient::send_now(const Xrl& xrl, XrlRouter::XrlCallback cb, - const string& xrl_return_spec, bool do_exec) +XorpClient::send_now(const Xrl& xrl, XrlRouter::XrlCallback cb, + const string& xrl_return_spec, bool do_exec) { if (do_exec) { debug_msg("send_sync before sending\n"); @@ -61,7 +61,7 @@ XorpClient::send_now(const Xrl& xrl, XrlRouter::XrlCallback cb, debug_msg("DUMMY SEND: immediate callback dispatch\n"); if (!cb.is_empty()) { _delay_timer = _eventloop.new_oneoff_after_ms(0, - callback(this, &XorpClient::fake_send_done, + callback(this, &XorpClient::fake_send_done, xrl_return_spec, cb)); } debug_msg("send_sync after sending\n"); @@ -71,10 +71,10 @@ XorpClient::send_now(const Xrl& xrl, XrlRouter::XrlCallback cb, /** * fake_send_done decouples the XRL response callback for debug_mode calls * to send_now, so that the callback doesn't happen until after - * send_now has returned. + * send_now has returned. */ void XorpClient::fake_send_done(string xrl_return_spec, - XrlRouter::XrlCallback cb) + XrlRouter::XrlCallback cb) { XrlArgs args = fake_return_args(xrl_return_spec); cb->dispatch(XrlError::OKAY(), &args); @@ -84,7 +84,7 @@ void XorpClient::fake_send_done(string xrl_return_spec, * fake_return_args is purely needed for testing, so that XRLs that * should return a value don't completely fail */ -XrlArgs +XrlArgs XorpClient::fake_return_args(const string& xrl_return_spec) { list args; -- 1.7.5.4 From igorm at etf.rs Thu Mar 15 05:42:10 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Thu, 15 Mar 2012 13:42:10 +0100 Subject: [Xorp-hackers] [PATCH] xorp: rtrmgr: Fix command completion with %allow-range option on multi-value nodes In-Reply-To: References: Message-ID: <1331815330-25121-1-git-send-email-igorm@etf.rs> From: Igor Maravic Fixed problem of command completion for multi-value nodes with allow-range option. Without this fix, if we would enter number within the allowed range, and then we would enter " " + "\t" we wouldn't get any command propositions. Signed-off-by: Igor Maravic --- xorp/rtrmgr/template_tree.cc | 34 +++++++++++++++++++++++++++++++++- xorp/rtrmgr/template_tree_node.cc | 6 +++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/xorp/rtrmgr/template_tree.cc b/xorp/rtrmgr/template_tree.cc index fa04132..6134a30 100644 --- a/xorp/rtrmgr/template_tree.cc +++ b/xorp/rtrmgr/template_tree.cc @@ -38,6 +38,17 @@ #include "template_tree.hh" #include "template_tree_node.hh" +#ifdef HAVE_REGEX_H +# include +#else // ! HAVE_REGEX_H +# ifdef HAVE_PCRE_H +# include +# endif +# ifdef HAVE_PCREPOSIX_H +# include +# endif +#endif // ! HAVE_REGEX_H + #ifdef HOST_OS_WINDOWS #define stat _stat @@ -425,12 +436,33 @@ TemplateTree::find_node(const list& path_segments) const TemplateTreeNode* t = *ti; if (t->type() == NODE_VOID) continue; - if ((t->parent() == NULL) || (! t->parent()->is_tag())) + if ((t->parent() == NULL) || (!t->parent()->is_tag())) continue; if (t->encoded_typestr() == segname) { matches.push_back(t); continue; } + + /** + * Check if this segname represents some kind of range. + * If it does, it will match regexp below, and we + * are expecting t->encoded_typestr to be "" or "" or "" + */ + regex_t range_reg; + if (regcomp(&range_reg, "[\[][-]{0,1}[0-9]+[.][.][-]{0,1}[0-9]+]", + REG_EXTENDED)) + XLOG_UNREACHABLE(); + + bool is_range = !regexec(&range_reg, segname.c_str(), 0, 0, 0); + regfree(&range_reg); + if (is_range + && (t->encoded_typestr() == "" + || t->encoded_typestr() == "" + || t->encoded_typestr() == "")) { + matches.push_back(t); + continue; + } + string s; if (t->type_match(segname, s)) matches.push_back(t); diff --git a/xorp/rtrmgr/template_tree_node.cc b/xorp/rtrmgr/template_tree_node.cc index 7ae9698..4c858e8 100644 --- a/xorp/rtrmgr/template_tree_node.cc +++ b/xorp/rtrmgr/template_tree_node.cc @@ -1471,7 +1471,7 @@ UIntTemplate::type_match(const string& orig, string& error_msg) const return false; } } - return true; + return check_allowed_value(orig, error_msg); } string @@ -1585,7 +1585,7 @@ ULongTemplate::type_match(const string& orig, string& error_msg) const return false; } } - return true; + return check_allowed_value(orig, error_msg); } string @@ -1703,7 +1703,7 @@ IntTemplate::type_match(const string& orig, string& error_msg) const } return false; } - return true; + return check_allowed_value(orig, error_msg); } string -- 1.7.5.4 From igorm at etf.rs Thu Mar 15 05:57:38 2012 From: igorm at etf.rs (=?ISO-8859-2?Q?Igor_Maravi=E6?=) Date: Thu, 15 Mar 2012 13:57:38 +0100 Subject: [Xorp-hackers] [PATCH] xorp: rtrmgr: Fix command completion with %allow-range option on multi-value nodes In-Reply-To: <4F5F8731.6010304@candelatech.com> References: <1331636150-4816-1-git-send-email-igorm@etf.rs> <1331636150-4816-2-git-send-email-igorm@etf.rs> <4F5F8393.5070605@candelatech.com> <4F5F8731.6010304@candelatech.com> Message-ID: Fixed indentation and resubmitted. BR Igor > Actually, xorp is using tabs for indentation. ?Maybe your patch > will look better outside of email. ?Let me double-check > that before you spend more time re-writing it. > From greearb at candelatech.com Thu Mar 15 06:08:10 2012 From: greearb at candelatech.com (Ben Greear) Date: Thu, 15 Mar 2012 06:08:10 -0700 Subject: [Xorp-hackers] [PATCH] contrib/win32/xorprtm (c) 2001-2012 XORP, Inc and Others In-Reply-To: References: <2C8BF29373924F93A6E557BEC741B54F@local.st.by> <4F60C3E5.1000001@candelatech.com> Message-ID: <4F61E9BA.9020601@candelatech.com> On 03/15/2012 04:07 AM, Victor Miasnikov wrote: > > Hi! > >> On 03/14/2012 07:41 AM, Victor Miasnikov wrote: >>> From: Victor Miasnikov > >> Did you write this xorprtm code originally, or work on submit >> changes while not employed by XORP, Inc? > > My code changes: My script will update the copyright anyway since it's new files, so I'm going to ignore your patch that changes copyright. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From vvm at tut.by Thu Mar 15 06:35:15 2012 From: vvm at tut.by (Victor Miasnikov) Date: Thu, 15 Mar 2012 16:35:15 +0300 Subject: [Xorp-hackers] MS RRAS ( see "RTMv2" ) "xorprtm v1.8.6-WIP .EXE _ and xorprtm4.dll and xorprtm6.dll .7z" Fw: b7a5d6: contrib/win32/xorprtm Re: Recent Xorp patches. References: <4F60D792.1020506@candelatech.com> Message-ID: Hi! > I have no idea if the Windows changes work properly or not, This > Commit: b7a5d6abb962814227dedd49fd9961350106e928 > contrib/win32/xorprtm Fixes related "bsdroute.h" not related build XORP*.exe this is source code for build by MS VC xorprtm4.dll and xorprtm6.dll i.e. ?modules? for MS RRAS ( see "RTMv2" ) > so please test those as well if you are using that platform. We ( I , Andrey V. Semenov and friends) start testing: At this moment tested ( very well result ( worked OSPFv2 + static ) on Windows 8 Server "Cosumer Preview" i.e. latest "Windows 8 Alpha" ): 1) "XORP v1.8.5ct _ 2012-03-14--SRC And RRAS HotFix Or greearb-xorp.ct-lf-5.2.3-25-g8a06fc4.zip-- And RRAS HotFix Or xorp_win32.zip" SHA1: 7ad1f5239728e685ee9b81388576d53554c82969 2) "xorp 15.03.2012 with RRAS Fix xorp_win32.zip Based XORP v1.8.6-WIP _ 2012-03-15 _ Or greearb-xorp.ct-lf-5.2.3-41-g3e1eb42.zip _and RRAS Fix _.zip" SHA1: 581101a3c7f3df0cfa39bb9e378ab3b6bd9ee6b2 ( about RRAS Fix see P.P.S. ) Pure "XORP v1.8.6-WIP _ 2012-03-15 _ Or greearb-xorp.ct-lf-5.2.3-41-g3e1eb42.zip -- xorp_win32.zip" is difficult for test -- need uninstall RRAS component . . . Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ P.S. see "xorprtm v1.8.6-WIP .EXE _ and xorprtm4.dll and xorprtm6.dll .7z" in atachment of e-mail -- I'm don't known how exactly public binary files related XORP ----- Original Message ----- From: "Victor Miasnikov" vvm To: "Ben Greear" greearb Sent: Thursday, March 15, 2012 3:35 PM Subject: MS RRAS ( see "RTMv2" ) "xorprtm v1.8.6-WIP .EXE _ and xorprtm4.dll and xorprtm6.dll .7z" + Source Code Re: [Xorp-hackers] [greearb/xorp.ct] Fixes related "bsdroute.h" Hi! Output binary: xorprtm4.dll and xorprtm6.dll This is ?modules? for MS RRAS ( see "RTMv2" ) <= { > Commit: b7a5d6abb962814227dedd49fd9961350106e928 > https://github.com/greearb/xorp.ct/commit/b7a5d6abb962814227dedd49fd9961350106e928 > Author: Victor Miasnikov > Date: 2012-03-14 (Wed, 14 Mar 2012) > contrib/win32/xorprtm Fixes related "bsdroute.h" > > 1) Add Or move source code line #include "bsdroute.h" > > 2) xorptm4/Jamfile ( from "SVN Rev 11384" ) > 2b) xorptm6/Jamfile ( see "SharedLibrary xorprtm6 :") > > 3) build script Jam-Run.cmd > == > set JAM_TOOLSET=VISUALC > jam.exe > == } Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ -- P.P.S. ----- Original Message ----- From: "Victor Miasnikov" vvm To: "Ben Greear" greearb Sent: Wednesday, March 07, 2012 6:24 PM Subject: . . . 2) xorprtm4.dll . . . -- Ok ? 2b) Or may be [temporary] disable xorprtm4.dll ? Or VVM 2012-03-07 Temporary turn off windows_rras_support feature Hi! . . . 2) I'm compile xorprtm4.dll . . . it can work with XORP v1.8.5/v1.8.6-WIP ? 2b) Or may be [temporary] disable [all related] xorprtm4.dll ? == C:\...03-07\greearb-xorp.ct-df3ca57 And VVM\xorp\fea\data_plane\control_socket>diff -u windows_rras_support.cc.Orig windows_rras_support.cc --- windows_rras_support.cc.Orig Wed Feb 29 09:11:46 2012 +++ windows_rras_support.cc Wed Mar 07 12:59:08 2012 @@ -44,11 +44,14 @@ // Helper method to determine if the Routing and Remote Access Service // is installed and running. // +// See later /* VVM 2012-03-07 Temporary turn off windows_rras_support feature */ bool WinSupport::is_rras_running() { bool is_installed = false; bool is_running = false; + + //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ; /* VVM 2012-03-07 Temporary turn off windows_rras_support feature */ + // VVM 2012-03-15 first // -- need skipped, ZZZZZZ -- is very trivial "copy & paste", but at this moment xorprtm4.dll may be solved problem by traditial way, if not success -- i'm public [PATCH] SC_HANDLE h_scm = OpenSCManager(NULL, NULL, GENERIC_READ); if (h_scm != NULL) { == Best regards, Victor Miasnikov -- From vvm at tut.by Thu Mar 15 06:37:36 2012 From: vvm at tut.by (Victor Miasnikov) Date: Thu, 15 Mar 2012 16:37:36 +0300 Subject: [Xorp-hackers] [PATCH] contrib/win32/xorprtm (c) 2001-2012 XORP, Inc and Others References: <2C8BF29373924F93A6E557BEC741B54F@local.st.by> <4F60C3E5.1000001@candelatech.com> <4F61E9BA.9020601@candelatech.com> Message-ID: <13945245B270496EA2DF2FAEABB86ACF@local.st.by> Hi! > My script will update the copyright anyway since it's new files, so > I'm going to ignore your patch that changes copyright. Ok > Thanks, No problem ;-) Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ ----- Original Message ----- From: "Ben Greear" To: "Victor Miasnikov" Cc: Sent: Thursday, March 15, 2012 4:08 PM Subject: Re: [PATCH] contrib/win32/xorprtm (c) 2001-2012 XORP, Inc and Others > On 03/15/2012 04:07 AM, Victor Miasnikov wrote: >> >>> On 03/14/2012 07:41 AM, Victor Miasnikov wrote: >>>> From: Victor Miasnikov >> >>> Did you write this xorprtm code originally, or work on submit >>> changes while not employed by XORP, Inc? >> >> My code changes: > > My script will update the copyright anyway since it's new files, so > I'm going to ignore your patch that changes copyright. > > Thanks, > Ben From igorm at etf.rs Thu Mar 15 06:39:34 2012 From: igorm at etf.rs (=?ISO-8859-2?Q?Igor_Maravi=E6?=) Date: Thu, 15 Mar 2012 14:39:34 +0100 Subject: [Xorp-hackers] Recent Xorp patches. In-Reply-To: <4F60D792.1020506@candelatech.com> References: <4F60D792.1020506@candelatech.com> Message-ID: Hi, Looks good on Ubuntu 11.10. Maybe you could make testing branch, so there wouldn't be any "blackouts" for users which want to use stable Xorp. BR Igor 2012/3/14 Ben Greear : > > First, thanks for all of the recent patches! > > I just committed a bunch of patches. ?I probably missed a few > that were recently submitted, so if you notice a patch I skipped, > please re-send it to the list. > > For anyone able to test out XORP, please pull down the > latest code and see if it works for you. ?In particular, I would > not be surprised if Open or NetBSD has issues compiling related to the > lex/yacc changes. ?Send logs if you see failures and we'll > try to fix them. > > I have no idea if the Windows changes work properly or not, so > please test those as well if you are using that platform. > > Thanks, > Ben > > -- > Ben Greear > Candela Technologies Inc ?http://www.candelatech.com > > _______________________________________________ > Xorp-hackers mailing list > Xorp-hackers at icir.org > http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers From greearb at candelatech.com Thu Mar 15 08:07:48 2012 From: greearb at candelatech.com (Ben Greear) Date: Thu, 15 Mar 2012 08:07:48 -0700 Subject: [Xorp-hackers] Recent Xorp patches. In-Reply-To: References: <4F60D792.1020506@candelatech.com> Message-ID: <4F6205C4.8010708@candelatech.com> On 03/15/2012 06:39 AM, Igor Maravi? wrote: > Hi, > Looks good on Ubuntu 11.10. > > Maybe you could make testing branch, so there wouldn't be any > "blackouts" for users which want to use stable Xorp. > BR > Igor Well, I really don't have the time to deal with that, and truth is, we need testers to try the latest stuff even if it occassionaly breaks. Much better than noticing the breaks after we do a release. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From vvm at tut.by Thu Mar 15 08:46:34 2012 From: vvm at tut.by (Victor Miasnikov) Date: Thu, 15 Mar 2012 18:46:34 +0300 Subject: [Xorp-hackers] MS RRAS ( see "RTMv2" ) "xorprtm v1.8.6-WIP .EXE _and xorprtm4.dll and xorprtm6.dll .7z" Fw: b7a5d6:contrib/win32/xorprtm Re: Recent Xorp patches. Message-ID: <7E169BAC6EBB4ACBA3F5C5D75C647127@local.st.by> Hi! ----- Original Message ----- From: "Victor Miasnikov" vvm To: "Ben Greear" greearb Sent: Thursday, March 15, 2012 6:39 PM Subject: . . . ? Re: xorprtm dll 00) == +// See later /* VVM 2012-03-07 Temporary turn off windows_rras_support feature */ bool WinSupport::is_rras_running() { bool is_installed = false; bool is_running = false; + + //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ; /* VVM 2012-03-07 Temporary turn off windows_rras_support feature */ + // VVM 2012-03-15 first // -- need skipped, ZZZZZZ -- is very trivial "copy & paste", but at this moment xorprtm4.dll may be solved problem by traditial way, if not success -- i'm public [PATCH] == May be turn off windows_rras_support by default? Who can compile xorprtm dll -- can be simply turn on feature by recompile XORP And not-developer can be work with XORP on windows comps with RRAS component ( RRAS very offten not configure as _router_ , usual it simply installed by other MS software ) Or may be best implement check ENV variable "usexorprtm4dll" If it set on , then use RTMv2 , if off or not defined -- work as usual . . . 2) [xorprtm4.dll and xorprtm6.dll can be] build with MS Platform SDK: == Microsoft Windows Software Development Kit Update for Windows Vista http://www.microsoft.com/downloads/details.aspx?familyid=FF6467E6-5BBA-4BF5-B562-9199BE864D29&displaylang=en . . . File Name: 6.1.6000.16384.10.WindowsSDK_Vista_Feb2007Update_rtm.DVD.Rel.iso Version: 6.0 Date Published: 3/22/2007 . . . SHA-1 hash: 0x5D28463DAAA755450D697C850DD622D1F8B580AE . . . System Requirements Supported Operating Systems: Windows Server 2003; Windows Server 2003 R2 (32-Bit x86); Windows Server 2003 R2 x64 editions; Windows Server 2003 Service Pack 1; Windows Vista; Windows XP == . . . -- Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ From greearb at candelatech.com Thu Mar 15 08:57:40 2012 From: greearb at candelatech.com (Ben Greear) Date: Thu, 15 Mar 2012 08:57:40 -0700 Subject: [Xorp-hackers] xorprtm dll. In-Reply-To: <7E169BAC6EBB4ACBA3F5C5D75C647127@local.st.by> References: <7E169BAC6EBB4ACBA3F5C5D75C647127@local.st.by> Message-ID: <4F621174.7020703@candelatech.com> On 03/15/2012 08:46 AM, Victor Miasnikov wrote: > > Hi! > > > ----- Original Message ----- From: "Victor Miasnikov" vvm > To: "Ben Greear" greearb > Sent: Thursday, March 15, 2012 6:39 PM > Subject: . . . ? Re: xorprtm dll > > 00) > == > +// See later /* VVM 2012-03-07 Temporary turn off windows_rras_support feature */ > bool > WinSupport::is_rras_running() > { > bool is_installed = false; > bool is_running = false; > + > + //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ; /* VVM 2012-03-07 Temporary turn off windows_rras_support > feature */ > + // VVM 2012-03-15 first // -- need skipped, ZZZZZZ -- is very trivial "copy & paste", but at this moment > xorprtm4.dll may be solved problem by traditial way, if not success -- i'm public [PATCH] > == > > May be turn off windows_rras_support by default? > > Who can compile xorprtm dll -- can be simply turn on feature by recompile XORP > > And not-developer can be work with XORP on windows comps with RRAS component > ( RRAS very offten not configure as _router_ , usual it simply installed by other MS software ) Do you think you could get it to compile using the mingw cross-compiler so that it's automatically compiled? That would be the best way to support the dll I think, and then we can just package it up with the xorp executables. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From vvm at tut.by Thu Mar 15 09:34:23 2012 From: vvm at tut.by (Victor Miasnikov) Date: Thu, 15 Mar 2012 19:34:23 +0300 Subject: [Xorp-hackers] De-facto xorprtm dll / "RTMv2" -- is [IMHO] very _experimenal_ feature Re: xorprtm dll. References: <7E169BAC6EBB4ACBA3F5C5D75C647127@local.st.by> <4F621174.7020703@candelatech.com> Message-ID: <1C6087CCFA584735A786C3BCAE187AA7@local.st.by> Hi! > Do you think you I'm think what .dll / module(!) for MS Software ( RRAS) need be compile with MS VC , and _best_ with version what corresponded Windows IMHO, need personal .dll for NT52 / NT60 / NT61 / NT62 and may be for even(!) SP / HotFix > could get it to compile using the mingw cross-compiler > so that it's automatically compiled? In any case for build xorprtm dll need *..h and *.lib from MS Platform SDK . . . http://mailman.icsi.berkeley.edu/pipermail/xorp-users/2009-May/003172.html === ... From this point I decided to go back to Routing and Remote Access, and had it running doing OSPF 2012-03-15 VVM: In Windows 2008 RRAS not contain(!) OSPF ( in Win 2003 -- RRAS can work with OSPF) while I tried to convince Xorp to just do the multicast stuff. Sadly all 3 versions complained about not having an RTMv2 pipe available. I found the source code for the relevant dll in contrib/win32/xorprtm, convinced it to compile (using the suggested Visual C++ Toolkit 2003, and the Windows Server 2003 R2 Platform SDK, after having to add some #include lines to bsdroute.h), and put that in, at which point I was able to get Xorp running again. It's at this point I hit what seems to be my final roadblock, and sadly it wasn't in the release notes (though I've since found it in the build notes): Multicast routing is not supported on Windows. ... So at the moment, I'm stuck. I'm wondering if it's possible to just get Xorp to handle the PIM stuff on it's own, though to be honest, I don't know enough about multicast to know if that would be sufficient. Does anyone have any ideas about a solution to this mess? Aside from using a different operating system, of course, as I'm stuck with Windows on this one. . . . === > That would be the best way to support the dll Yes . . . But . . . > I think, and then we can just package it up with > the xorp executables. De-facto xorprtm dll / "RTMv2" -- is [IMHO] very _experimenal_ feature For example: BUGS == - Routes appear in the RTM routing table but do not propagate to the FIB. This can be verified by comparing the output of 'route print' with that of 'netsh routing ip show rtmroutes'. == I.e. xorprtm dll itself work as need ( if run ( in OS shell ) 'netsh routing ip show rtmroutes' -- all Ok ), but 'route print' not show new routes! :-( [IMHO] xorprtm dll / "RTMv2" need some [big] improvements / see TODO : == Tasks depending on Microsoft feedback: Fix route adds so they are pushed to the FIB. Blocked awaiting feedback. Refine and test IPv6 support. Blocked on missing defines in SDK. Blocked awaiting feedback. == + BUGS == . . . * XXX: The following identifiers seem to be missing from the Windows SDK build 5284 headers: IPV6_ADDRESS_LEN_IN_BYTES ConvertAddressAndLengthToNetAddress() ConvertNetAddressToAddressAndLength() referenced by: RTM_IPV6_SET_ADDR_AND_LEN() RTM_IPV6_GET_ADDR_AND_LEN() There also seems to be no RTM_IPV6_MASK_FROM_LEN() function, which we'd need for converting our IPv6 prefix lengths to socket address structures for the modified BSD message format we currently use. == IMHO at this time need be do: >> May be turn off windows_rras_support by default? >> >> Who can compile xorprtm dll -- can be simply turn on feature by recompile XORP >> >> And not-developer can be work with XORP on windows comps with RRAS component >> ( RRAS very offten not configure as _router_ , usual it simply installed by other MS software ) and in [near] future -- start work with upgrade "xorprtm dll" . . . Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ ----- Original Message ----- From: "Ben Greear" greearb To: "Victor Miasnikov" vvm Cc: xorp-hackers Sent: Thursday, March 15, 2012 6:57 PM Subject: xorprtm dll. > On 03/15/2012 08:46 AM, Victor Miasnikov wrote: . . . >> + // VVM 2012-03-15 first // -- need skipped, ZZZZZZ -- is very trivial "copy & paste", but at this moment >> xorprtm4.dll may be solved problem by traditial way, if not success -- i'm public [PATCH] >> == >> >> May be turn off windows_rras_support by default? >> >> Who can compile xorprtm dll -- can be simply turn on feature by recompile XORP >> >> And not-developer can be work with XORP on windows comps with RRAS component >> ( RRAS very offten not configure as _router_ , usual it simply installed by other MS software ) > > > Do you think you could get it to compile using the mingw cross-compiler > so that it's automatically compiled? That would be the best way to > support the dll I think, and then we can just package it up with > the xorp executables. > > Thanks, > Ben From greearb at candelatech.com Thu Mar 15 09:55:47 2012 From: greearb at candelatech.com (Ben Greear) Date: Thu, 15 Mar 2012 09:55:47 -0700 Subject: [Xorp-hackers] De-facto xorprtm dll / "RTMv2" -- is [IMHO] very _experimenal_ feature Re: xorprtm dll. In-Reply-To: <1C6087CCFA584735A786C3BCAE187AA7@local.st.by> References: <7E169BAC6EBB4ACBA3F5C5D75C647127@local.st.by> <4F621174.7020703@candelatech.com> <1C6087CCFA584735A786C3BCAE187AA7@local.st.by> Message-ID: <4F621F13.4000307@candelatech.com> On 03/15/2012 09:34 AM, Victor Miasnikov wrote: > > Hi! > >> Do you think you > > I'm think what .dll / module(!) for MS Software ( RRAS) need be compile with MS VC , and _best_ with version what corresponded Windows > > IMHO, need personal .dll for NT52 / NT60 / NT61 / NT62 and may be for even(!) SP / HotFix > > >> could get it to compile using the mingw cross-compiler >> so that it's automatically compiled? > > In any case for build xorprtm dll need *..h and *.lib from MS Platform SDK . . . Well, we can compile the rest of xorp for windows using mingw, so hopefully the xorprtm part can be made to compile there as well. It might be a while before I try to do this, but if someone else gets it working, please send patches. In the meantime, if you would like to send a patch to optionally enable the feature in xorp, and document how to compile the module using MS VC that would be welcome. Anyone that wants to experiment or try to fix some of the bugs in that code will have an easier time that way. I'm not going to add pre-compiled dlls to the git tree nor to package them in the standard xorp packages, but perhaps they could be added to the downloads directory on our web page under 'contributions' or similar. > IMHO at this time need be do: > >>> May be turn off windows_rras_support by default? >>> >>> Who can compile xorprtm dll -- can be simply turn on feature by recompile XORP >>> >>> And not-developer can be work with XORP on windows comps with RRAS component >>> ( RRAS very offten not configure as _router_ , usual it simply installed by other MS software ) > > > > and in [near] future -- start work with upgrade "xorprtm dll" . . . Sure, that sounds good to me. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Thu Mar 15 09:56:04 2012 From: noreply at github.com (GitHub) Date: Thu, 15 Mar 2012 09:56:04 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 416aa2: eclipse: Add xml file to make eclipse do proper x... Message-ID: <4f621f24530c2_44291c23ae8792fd@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 416aa2ce8a10be0a9f53f9ca385eb0b87ca60a78 https://github.com/greearb/xorp.ct/commit/416aa2ce8a10be0a9f53f9ca385eb0b87ca60a78 Author: Ben Greear Date: 2012-03-15 (Thu, 15 Mar 2012) Changed paths: A xorp/devnotes/xorpEclipse.xml Log Message: ----------- eclipse: Add xml file to make eclipse do proper xorp formatting. It can be imported via Window->Preferences->C/C++->Code Style->Import Contributed by: Igor Maravic Signed-off-by: Ben Greear Commit: 9710e898af9c83d969f41f8a083942f25df68a88 https://github.com/greearb/xorp.ct/commit/9710e898af9c83d969f41f8a083942f25df68a88 Author: Ben Greear Date: 2012-03-15 (Thu, 15 Mar 2012) Changed paths: M xorp/devnotes/coding-style.txt M xorp/devnotes/template_gpl.c M xorp/devnotes/template_gpl.cc M xorp/devnotes/template_gpl.h M xorp/devnotes/template_gpl.hh M xorp/devnotes/template_gpl.py M xorp/devnotes/template_gpl.sh M xorp/devnotes/template_lgpl.c M xorp/devnotes/template_lgpl.cc M xorp/devnotes/template_lgpl.h M xorp/devnotes/template_lgpl.hh M xorp/devnotes/template_lgpl.sh Log Message: ----------- Update coding style guide. Signed off by: Ben Greear Commit: 0da358759f08952062911da0ae6fe7b1cb82defe https://github.com/greearb/xorp.ct/commit/0da358759f08952062911da0ae6fe7b1cb82defe Author: Igor Maravic Date: 2012-03-15 (Thu, 15 Mar 2012) Changed paths: M xorp/rtrmgr/conf_tree_node.cc M xorp/rtrmgr/conf_tree_node.hh M xorp/rtrmgr/master_conf_tree.cc M xorp/rtrmgr/template_base_command.cc M xorp/rtrmgr/template_commands.cc Log Message: ----------- trivial: ws fixes Eclipse automaticaly striped trailing ws. Signed-off-by: Igor Maravic Commit: 535e29457de35a567027bc5e25a5d7f2742f647d https://github.com/greearb/xorp.ct/commit/535e29457de35a567027bc5e25a5d7f2742f647d Author: Igor Maravic Date: 2012-03-15 (Thu, 15 Mar 2012) Changed paths: M xorp/libxipc/xrl_atom.cc M xorp/libxipc/xrl_atom.hh M xorp/rtrmgr/unexpanded_xrl.cc M xorp/rtrmgr/xorp_client.cc Log Message: ----------- trivial: ws fixes Eclipse automaticaly striped trailing ws Signed-off-by: Igor Maravic Commit: ad8f55446d511a3688aaf15dbd8c6be95b2bfa74 https://github.com/greearb/xorp.ct/commit/ad8f55446d511a3688aaf15dbd8c6be95b2bfa74 Author: Igor Maravic Date: 2012-03-15 (Thu, 15 Mar 2012) Changed paths: M xorp/rtrmgr/template_tree.cc M xorp/rtrmgr/template_tree_node.cc Log Message: ----------- xorp: rtrmgr: Fix command completion with %allow-range option on multi-value nodes Fixed problem of command completion for multi-value nodes with allow-range option. Without this fix, if we would enter number within the allowed range, and then we would enter " " + "\t" we wouldn't get any command propositions. Signed-off-by: Igor Maravic Compare: https://github.com/greearb/xorp.ct/compare/3e1eb42...ad8f554 From vvm at tut.by Fri Mar 16 02:49:07 2012 From: vvm at tut.by (Victor Miasnikov) Date: Fri, 16 Mar 2012 12:49:07 +0300 Subject: [Xorp-hackers] De-facto xorprtm dll / "RTMv2" -- is [IMHO] very _experimenal_ feature Re: xorprtm dll. References: <7E169BAC6EBB4ACBA3F5C5D75C647127@local.st.by> <4F621174.7020703@candelatech.com> <1C6087CCFA584735A786C3BCAE187AA7@local.st.by> <4F621F13.4000307@candelatech.com> Message-ID: <563BC3A064A74706A537001E6EF3C4BE@local.st.by> Hi! > On 03/15/2012 09:34 AM, Victor Miasnikov wrote: VVM>>>> May be turn off windows_rras_support by default? VVM>>>> Who can compile xorprtm dll -- can be simply turn on feature by recompile XORP VVM>>>> And not-developer can be work with XORP on windows comps with RRAS component VVM>>>> ( RRAS very offten not configure as _router_ , usual it simply installed by other MS software ) VVM>> VVM>> and in [near] future -- start work with upgrade "xorprtm dll" . . . > > Sure, that sounds good to me. Well: i'm start do it, i.e. make/send patches, write documentation, etc. In this order: == 1) create patch to optionally enable the feature 2) "document how to compile the module using MS VC" == > that would be welcome: > In the meantime, if you would like to send a patch to optionally enable the feature in xorp Ok, I'm start do it >, and document how to compile the module using MS VC I'm start write it > Anyone that wants to experiment or try to fix some of the bugs in that code will have an easier time that way. Yes, yes: this is main goal of "reincarnation" feature "xorprtm dll" / "RTMv2" > I'm not going to add pre-compiled dlls to the git tree nor to package > them in the standard xorp packages, but perhaps they could be added to the downloads directory on our web page under > 'contributions' or similar. Yes: last variant [IMHO] is optimal >>> could get it to compile using the mingw cross-compiler >>> so that it's automatically compiled? >> >> In any case for build xorprtm dll need *..h and *.lib from MS Platform SDK . . . > Well, we can compile the rest of xorp for windows using mingw, so hopefully > the xorprtm part can be made to compile there as well. I'm try do it, but _may be_ and in _any case_ after 1) create patch to optionally enable the feature 2) "document how to compile the module using MS VC" i.e. not in near future :-( > It might be a while before I try to do this, but if someone else > gets it working, please send patches. Yes: that "would be welcome" / "very well" >>> Do you think you could get it to compile using the mingw cross-compiler so that it's automatically compiled? >> I'm think what .dll / module(!) for MS Software ( RRAS) need be compile with MS VC , and _best_ with version what >> corresponded Windows >> IMHO, need personal .dll for NT52 / NT60 / NT61 / NT62 and may be for even(!) SP / HotFix Problem N2 : build x64 editions of "xorprtm dll" itself and on x86 build computers Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ ----- Original Message ----- From: "Ben Greear" To: "Victor Miasnikov" Cc: Sent: Thursday, March 15, 2012 7:55 PM Subject: Re: De-facto xorprtm dll / "RTMv2" -- is [IMHO] very _experimenal_ feature Re: xorprtm dll. On 03/15/2012 09:34 AM, Victor Miasnikov wrote: > > Hi! > >> Do you think you > > I'm think what .dll / module(!) for MS Software ( RRAS) need be compile with MS VC , and _best_ with version what > corresponded Windows > > IMHO, need personal .dll for NT52 / NT60 / NT61 / NT62 and may be for even(!) SP / HotFix > > >> could get it to compile using the mingw cross-compiler >> so that it's automatically compiled? > > In any case for build xorprtm dll need *..h and *.lib from MS Platform SDK . . . Well, we can compile the rest of xorp for windows using mingw, so hopefully the xorprtm part can be made to compile there as well. It might be a while before I try to do this, but if someone else gets it working, please send patches. In the meantime, if you would like to send a patch to optionally enable the feature in xorp, and document how to compile the module using MS VC that would be welcome. Anyone that wants to experiment or try to fix some of the bugs in that code will have an easier time that way. I'm not going to add pre-compiled dlls to the git tree nor to package them in the standard xorp packages, but perhaps they could be added to the downloads directory on our web page under 'contributions' or similar. > IMHO at this time need be do: > >>> May be turn off windows_rras_support by default? >>> >>> Who can compile xorprtm dll -- can be simply turn on feature by recompile XORP >>> >>> And not-developer can be work with XORP on windows comps with RRAS component >>> ( RRAS very offten not configure as _router_ , usual it simply installed by other MS software ) > > > > and in [near] future -- start work with upgrade "xorprtm dll" . . . + Sure, that sounds good to me. Thanks, Ben -- From markus.xorp at gmail.com Fri Mar 16 06:36:05 2012 From: markus.xorp at gmail.com (Markus Zehnder) Date: Fri, 16 Mar 2012 14:36:05 +0100 Subject: [Xorp-hackers] xrl calls from xorp_ospf to xorp_fea start failing when generating lots of calls. In-Reply-To: <4F5F8565.7040708@candelatech.com> References: <4F5F8565.7040708@candelatech.com> Message-ID: Hi Ben, Debugging: >> - ospf is trying to send LSA Updates, one packet for each route and >> interface. The packets are passed to xorp_fea as >> mentioned at the top with the transmit() method. ..but that fails after >> 120..140 packets. >> >> Can anybody give me some hint how that intented to work ? Is there some >> queue overflowing in the xorp_fea? should >> xorp_fea run with higher priority then the xorp_ospf. >> > > Probably whatever is sending needs to queue and retry sends > that fail (and preserve ordering, most likely..so after first failure, > start queueing or otherwise stop sending pkts, set a short timer, and try > again soon). XRL is tricky code to deal with, so it's usually easier > to hack around it's deficiencies than try to fix the core code to be > more flexible. But, I'd welcome patches that make the core more > robust! > > > i found out that the transport mechanism for the XRL between xorp_ospf and xorp_fea allows a maximum of 100 unacknowledged requests. ( xrlipc/xrl_pf_stcp.cc:61) In my setup i have two neighbours, so each configured LSA doubles into two packet requests in direction to xorp_fea. So i see the following options: - implement the queuing which you described - slow down the generator (xorp_rtrmgr) - make ospf more efficient in collecting the LSA's. Not send one packet per LSA but collect them and only send a packet when it has no more room in the packet..or no new LSA arrived for a short time. regards Markus -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120316/37d9f7a4/attachment.html From vvm at tut.by Fri Mar 16 09:04:04 2012 From: vvm at tut.by (Victor Miasnikov) Date: Fri, 16 Mar 2012 19:04:04 +0300 Subject: [Xorp-hackers] [PATCH] use RRAS only if environment variable XORP_USE_RRAS is set Message-ID: <2B1AD82EE8FC4A26B96C524796A8B726@local.st.by> From: Victor Miasnikov use RRAS only if environment variable XORP_USE_RRAS is set I.e. not-developers can be work with XORP on Windows comps with RRAS component ( RRAS very often not configure as _router_ , usual it simply installed by other MS software ) Who want use feature "xorprtm dll" / "RTMv2" -- simply set XORP_USE_RRAS=y Signed-off-by: Victor Miasnikov --- .../control_socket/windows_rras_support.cc | 22 ++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/xorp/fea/data_plane/control_socket/windows_rras_support.cc b/xorp/fea/data_plane/control_socket/windows_rras_support.cc index 23332d5..cfdd92f 100644 --- a/xorp/fea/data_plane/control_socket/windows_rras_support.cc +++ b/xorp/fea/data_plane/control_socket/windows_rras_support.cc @@ -50,6 +50,28 @@ WinSupport::is_rras_running() bool is_installed = false; bool is_running = false; + // + // If environment variable XORP_USE_RRAS is not set , + // then disable feature "xorprtm dll" / "RTMv2" + // + // I.e. not-developers can be work with XORP on Windows comps with RRAS component + // ( RRAS very often not configure as _router_ , usual it simply installed by other MS software ) + // + // Who want use feature "xorprtm dll" / "RTMv2" -- simply set XORP_USE_RRAS=y + // + // See: + // + // http://mailman.icsi.berkeley.edu/pipermail/xorp-hackers/2012-March/003315.html + // http://mailman.icsi.berkeley.edu/pipermail/xorp-hackers/2012-March/003317.html + // + // + // TODO: XXX: do feature "xorprtm dll" / "RTMv2" worked stable + // + const char* pf = getenv("XORP_USE_RRAS"); + if (pf == NULL) { + return (is_running && is_installed); + } + SC_HANDLE h_scm = OpenSCManager(NULL, NULL, GENERIC_READ); if (h_scm != NULL) { SC_HANDLE h_rras = OpenService(h_scm, RRAS_SERVICE_NAME, GENERIC_READ); -- 1.7.9.msysgit.0 From vvm at tut.by Fri Mar 16 09:11:56 2012 From: vvm at tut.by (Victor Miasnikov) Date: Fri, 16 Mar 2012 19:11:56 +0300 Subject: [Xorp-hackers] [PATCH] use RRAS only if environment variable XORP_USE_RRAS is set Message-ID: <61D5E467F1454ADEB10B186550611881@local.st.by> Hi! >env variable XORP_USE_RRAS and have it only try to use RRAS if that env var is set? Done, compiled, tested: all work as need: { == C:\xorp\sbin>set XORP_USE_RRAS=y C:\xorp\sbin>xorp_rtrmgr.exe -c config.boot -t ..\share\xorp\templates -m ..\lib\xorp\sbin 2>>xorp_errors.log . . . == == . . . [ 2012/3/16 15:53:59.879000 WARNING ..\lib\xorp\sbin\xorp_fea.exe:960 FEA fea/data_plane/fibconfig/fibconfig_table_set_iphelper.cc:53 FibConfigTableSetIPHelper ] Windows Routing and Remote Access Service is running. Some change operations through IP Helper may not work. . . . == } without "set XORP_USE_RRAS" -- work as on comp without RRAS Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ ----- Original Message ----- From: "Victor Miasnikov" To: "Ben Greear" Cc: Sent: Friday, March 16, 2012 7:04 PM Subject: [PATCH] use RRAS only if environment variable XORP_USE_RRAS is set > From: Victor Miasnikov > > use RRAS only if environment variable XORP_USE_RRAS is set > > I.e. not-developers can be work with XORP on Windows comps with RRAS component > ( RRAS very often not configure as _router_ , > usual it simply installed by other MS software ) > > Who want use feature "xorprtm dll" / "RTMv2" > -- simply set XORP_USE_RRAS=y > > Signed-off-by: Victor Miasnikov > --- From vvm at tut.by Fri Mar 16 09:32:35 2012 From: vvm at tut.by (Victor Miasnikov) Date: Fri, 16 Mar 2012 19:32:35 +0300 Subject: [Xorp-hackers] Fw: [PATCH] xorp/contrib/xorprtm FIXed tab and again disable #ident Message-ID: <383D24F793CE4829A70FF4D2DD84BD17@local.st.by> Hi! > [PATCH] xorp/contrib/xorprtm FIXed tab and again disable #ident For prevent copy&paste trouble with tabs in source code / <-tab-> -- of course, for visualization: == . . . -IPV6_ADDRESS_LEN_IN_BYTES -ConvertAddressAndLengthToNetAddress() -ConvertNetAddressToAddressAndLength() +<-tab->IPV6_ADDRESS_LEN_IN_BYTES +<-tab->ConvertAddressAndLengthToNetAddress() +<-tab->ConvertNetAddressToAddressAndLength() referenced by: -RTM_IPV6_SET_ADDR_AND_LEN() -RTM_IPV6_GET_ADDR_AND_LEN() +<-tab->RTM_IPV6_SET_ADDR_AND_LEN() +<-tab->RTM_IPV6_GET_ADDR_AND_LEN() . . . == send in "March 16, 2012 7:24 PM" as attachment Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ ----- Original Message ----- From: "Victor Miasnikov" vvm To: "Ben Greear" greearb Sent: Friday, March 16, 2012 7:24 PM Subject: [PATCH] xorp/contrib/xorprtm FIXed tab and again disable #ident > Hi! > > [PATCH] xorp/contrib/xorprtm FIXed tab and again disable #ident > > see in attachment > > Best regards, Victor Miasnikov From vvm at tut.by Mon Mar 19 04:11:32 2012 From: vvm at tut.by (Victor Miasnikov) Date: Mon, 19 Mar 2012 14:11:32 +0300 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); Message-ID: From: Victor Miasnikov FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); No XLOG_ASSERT when "delete route for iface" , but XLOG_WARNING a-la fibconfig_entry_set_iphelper.cc for prevent: == [ 2012/3/19 6:48:11.708000 FATAL ..\lib\xorp\sbin\xorp_fea.exe:304 FEA fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc:347 delete_entry ] vifp != NULL Assertion failed: 0, file fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc, line 347 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. == Signed-off-by: Victor Miasnikov --- .../fibconfig/fibconfig_entry_set_rtmv2.cc | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/xorp/fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc b/xorp/fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc index f24e8a4..432a8fe 100644 --- a/xorp/fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc +++ b/xorp/fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc @@ -344,6 +344,13 @@ FibConfigEntrySetRtmV2::delete_entry(const FteX& fte) // Copy the interface index. const IfTree& iftree = fibconfig().merged_config_iftree(); const IfTreeVif* vifp = iftree.find_vif(fte.ifname(), fte.vifname()); + if (!vifp) { + // Maybe VIF is already deleted or we are not configured to use it. + XLOG_WARNING("Trying to delete route for iface: %s on tree: %s, but cannot find iface. Will continue.\n", + fte.ifname().c_str(), iftree.getName().c_str()); + return XORP_OK; + } + XLOG_ASSERT(vifp != NULL); rtm->rtm_index = vifp->pif_index(); -- 1.7.9.msysgit.0 From greearb at candelatech.com Mon Mar 19 09:03:55 2012 From: greearb at candelatech.com (Ben Greear) Date: Mon, 19 Mar 2012 09:03:55 -0700 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); In-Reply-To: References: Message-ID: <4F6758EB.1000601@candelatech.com> On 03/19/2012 04:11 AM, Victor Miasnikov wrote: > From: Victor Miasnikov > > FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); > > No XLOG_ASSERT when "delete route for iface" , but XLOG_WARNING a-la fibconfig_entry_set_iphelper.cc > for prevent: > == > [ 2012/3/19 6:48:11.708000 FATAL ..\lib\xorp\sbin\xorp_fea.exe:304 FEA fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc:347 delete_entry ] vifp != NULL > Assertion failed: 0, file fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc, line 347 > > This application has requested the Runtime to terminate it in an unusual way. > Please contact the application's support team for more information. > == > > Signed-off-by: Victor Miasnikov > --- > .../fibconfig/fibconfig_entry_set_rtmv2.cc | 7 +++++++ > 1 files changed, 7 insertions(+), 0 deletions(-) > > diff --git a/xorp/fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc b/xorp/fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc > index f24e8a4..432a8fe 100644 > --- a/xorp/fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc > +++ b/xorp/fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc > @@ -344,6 +344,13 @@ FibConfigEntrySetRtmV2::delete_entry(const FteX& fte) > // Copy the interface index. > const IfTree& iftree = fibconfig().merged_config_iftree(); > const IfTreeVif* vifp = iftree.find_vif(fte.ifname(), fte.vifname()); > + if (!vifp) { > + // Maybe VIF is already deleted or we are not configured to use it. > + XLOG_WARNING("Trying to delete route for iface: %s on tree: %s, but cannot find iface. Will continue.\n", > + fte.ifname().c_str(), iftree.getName().c_str()); > + return XORP_OK; > + } > + > XLOG_ASSERT(vifp != NULL); > rtm->rtm_index = vifp->pif_index(); The formatting looks bad in this patch. Please make sure code blocks are indented by 4 characters. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From vvm at tut.by Mon Mar 19 09:29:36 2012 From: vvm at tut.by (Victor Miasnikov) Date: Mon, 19 Mar 2012 19:29:36 +0300 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); x References: <4F6758EB.1000601@candelatech.com> Message-ID: -------------- next part -------------- A non-text attachment was scrubbed... Name: 0002-FEA-fibconfig_entry_set_rtmv2.cc-delete_entry-XLOG_W.patch Type: application/octet-stream Size: 1697 bytes Desc: not available Url : http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120319/b421bf03/attachment.obj From vvm at tut.by Mon Mar 19 09:33:42 2012 From: vvm at tut.by (Victor Miasnikov) Date: Mon, 19 Mar 2012 19:33:42 +0300 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); References: <4F6758EB.1000601@candelatech.com> Message-ID: <2338F2D70E0845FDA0179B88A3899B43@local.st.by> Hi! > The formatting looks bad in this patch. Please make sure code blocks > are indented by 4 characters. Sorry :-( -- may be my e-mail client replace tab to 1 space :-/ Resend as attach Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ From greearb at candelatech.com Mon Mar 19 11:57:23 2012 From: greearb at candelatech.com (Ben Greear) Date: Mon, 19 Mar 2012 11:57:23 -0700 Subject: [Xorp-hackers] [PATCH] use RRAS only if environment variable XORP_USE_RRAS is set In-Reply-To: <2B1AD82EE8FC4A26B96C524796A8B726@local.st.by> References: <2B1AD82EE8FC4A26B96C524796A8B726@local.st.by> Message-ID: <4F678193.9070006@candelatech.com> On 03/16/2012 09:04 AM, Victor Miasnikov wrote: > From: Victor Miasnikov > > use RRAS only if environment variable XORP_USE_RRAS is set > > I.e. not-developers can be work with XORP on Windows comps with RRAS component > ( RRAS very often not configure as _router_ , > usual it simply installed by other MS software ) I just applied this patch. Please update the wiki to document this new environment variable: http://xorp.run.montefiore.ulg.ac.be/latex2wiki/user_manual/environment_variables You may have to create an account on the wiki... Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From vvm at tut.by Mon Mar 19 12:02:46 2012 From: vvm at tut.by (Victor M.) Date: Mon, 19 Mar 2012 22:02:46 +0300 Subject: [Xorp-hackers] [PATCH] use RRAS only if environment variable XORP_USE_RRAS is set In-Reply-To: <4F678193.9070006@candelatech.com> References: <2B1AD82EE8FC4A26B96C524796A8B726@local.st.by> <4F678193.9070006@candelatech.com> Message-ID: Hi! 2012/3/19, Ben Greear : > On 03/16/2012 09:04 AM, Victor Miasnikov wrote: >> From: Victor Miasnikov >> >> use RRAS only if environment variable XORP_USE_RRAS is set >> I.e. not-developers can be work with XORP on Windows comps with RRAS > I just applied this patch. Big thanks! > Please update the wiki to document this new environment > variable: > http://xorp.run.montefiore.ulg.ac.be/latex2wiki/user_manual/environment_variables > You may have to create an account on the wiki... Ok But not today ;-) : 22:00 > Thanks, No problem ;-) V.M. P.S. How about documentation in .pdf ? From noreply at github.com Mon Mar 19 12:06:41 2012 From: noreply at github.com (GitHub) Date: Mon, 19 Mar 2012 12:06:41 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] d4b1ef: use RRAS only if environment variable XORP_USE_RRA... Message-ID: <4f6783c1b3963_e273fbacaf13af07344a@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: d4b1ef1d90fa2a5046098e21000eb33703121bee https://github.com/greearb/xorp.ct/commit/d4b1ef1d90fa2a5046098e21000eb33703121bee Author: Victor Miasnikov Date: 2012-03-19 (Mon, 19 Mar 2012) Changed paths: M xorp/fea/data_plane/control_socket/windows_rras_support.cc Log Message: ----------- use RRAS only if environment variable XORP_USE_RRAS is set use RRAS only if environment variable XORP_USE_RRAS is set I.e. not-developers can be work with XORP on Windows comps with RRAS component ( RRAS very often not configure as _router_ , usual it simply installed by other MS software ) Who want use feature "xorprtm dll" / "RTMv2" -- simply set XORP_USE_RRAS=y Signed-off-by: Victor Miasnikov From greearb at candelatech.com Mon Mar 19 12:08:07 2012 From: greearb at candelatech.com (Ben Greear) Date: Mon, 19 Mar 2012 12:08:07 -0700 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); x In-Reply-To: References: <4F6758EB.1000601@candelatech.com> Message-ID: <4F678417.7080406@candelatech.com> On 03/19/2012 09:29 AM, Victor Miasnikov wrote: Your patch looks better as an attachment, but please send me patches created by 'git format-patch' so that I can apply them with 'git am'. Preferably, you can just send them with 'git send-email' instead of using your emailer..that will ensure white-space is handled properly. Or, if 'git send-email' isn't convenient, then you can attach the 'git format-patch' created patches to your email and send it as normal. Please review the patches before sending to make sure the comments and subject are well formatted and that the title is no more than around 80 characters. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From vvm at tut.by Tue Mar 20 01:36:49 2012 From: vvm at tut.by (Victor Miasnikov) Date: Tue, 20 Mar 2012 11:36:49 +0300 Subject: [Xorp-hackers] FIXed Fw: win32api IP_LOCAL_BINDING defined wrong in routeprot.h Or . . . include/routprot.h:51: error 'IP_LOCAL_BINDING' does not name a type Message-ID: <6AA9C901DDDA4583A2AF431264DA24FB@local.st.by> Hi! Big thanks to Ben Greear for source code and Chris Sutcliffe for commit to CVS! Error described in BUILD_NOTES == . . . 3.7 Microsoft Windows ===================== * This describes steps to cross-compile Xorp.ct on Linux, using mingw toolchain to produce windows binaries. . . . If you see errors such as: In file included from fea/data_plane/fibconfig/fibconfig_entry_get_iphelper.cc:34: /usr/i686-pc-mingw32/sys-root/mingw/include/routprot.h:51: error: 'IP_LOCAL_BINDING' does not name a type scons: *** [obj/i386-pc-mingw32/fea/data_plane/fibconfig/fibconfig_entry_get_iphelper.o] Error 1 scons: building terminated because of errors. Then you should patch the routprot.h file: diff --git a/routprot.h.orig b/routprot.h . . . == fixed in Rev v1.3 of routprot.h http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/?cvsroot=src == . . . routprot.h 1.3 6 hours ironhead 2012-03-19 Ben Greear * include/routprot.h ... . . . == http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/routprot.h?cvsroot=src == CVS log for src/winsup/w32api/include/routprot.h . . . -------------------------------------------------------------------------------- Revision 1.3 / (download) - annotate - [select for diffs], Tue Mar 20 00:28:53 2012 UTC (6 hours, 36 minutes ago) by ironhead Changes since 1.2: +4 -4 lines Diff to previous 1.2(colored) 2012-03-19 Ben Greear * include/routprot.h (IP_LOCAL_BINDING): Move above IP_ADAPTER_BINDING_INFO to correct warning about IP_LOCAL_BINDING being undefined. . . . == http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/routprot.h.diff?r1=1.2&r2=1.3&cvsroot=src == =================================================================== RCS file: /cvs/src/src/winsup/w32api/include/routprot.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- src/winsup/w32api/include/routprot.h 2006/05/11 15:57:11 1.2 +++ src/winsup/w32api/include/routprot.h 2012/03/20 00:28:53 1.3 @@ -43,6 +43,10 @@ #define IPX_PROTOCOL_NLSP 0x00020002 /*--- Router Management Reference - Router Management Structures */ #if (_WIN32_WINNT >= 0x0500) +typedef struct IP_LOCAL_BINDING { + DWORD Address; + DWORD Mask; +} IP_LOCAL_BINDING,*PIP_LOCAL_BINDING; typedef struct IP_ADAPTER_BINDING_INFO { ULONG AddressCount; DWORD RemoteAddress; @@ -50,10 +54,6 @@ ULONGLONG Speed; IP_LOCAL_BINDING Address[]; } IP_ADAPTER_BINDING_INFO,*PIP_ADAPTER_BINDING_INFO; -typedef struct IP_LOCAL_BINDING { - DWORD Address; - DWORD Mask; -} IP_LOCAL_BINDING,*PIP_LOCAL_BINDING; typedef struct IPX_ADAPTER_BINDING_INFO { ULONG AdapterIndex; UCHAR Network[4]; == Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ P.S. Of course, we need wait fixed mingw32-w32api . . . From vvm at tut.by Tue Mar 20 05:08:34 2012 From: vvm at tut.by (Victor Miasnikov) Date: Tue, 20 Mar 2012 15:08:34 +0300 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); x Message-ID: <78B89B0CFAA341C9A69049ED80AD0985@local.st.by> Hi! > Your patch looks better as an attachment, but please send > me patches created by 'git format-patch' Attached file has good format? It can be applyed itself? Or need renew? Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ -------------- next part -------------- A non-text attachment was scrubbed... Name: 0002-FEA-fibconfig_entry_set_rtmv2.cc-delete_entry-XLOG_W.patch Type: application/octet-stream Size: 1863 bytes Desc: not available Url : http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120320/a076a028/attachment.obj From greearb at candelatech.com Tue Mar 20 09:09:30 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 20 Mar 2012 09:09:30 -0700 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); x In-Reply-To: <78B89B0CFAA341C9A69049ED80AD0985@local.st.by> References: <78B89B0CFAA341C9A69049ED80AD0985@local.st.by> Message-ID: <4F68ABBA.9040607@candelatech.com> On 03/20/2012 05:08 AM, Victor Miasnikov wrote: > > Hi! > >> Your patch looks better as an attachment, but please send >> me patches created by 'git format-patch' > > Attached file has good format? > It can be applyed itself? Or need renew? > > Best regards, Victor Miasnikov > Blog: http://vvm.blog.tut.by/ It does not apply (I saved it as /tmp/fea-fib.patch) [greearb at ben-dt xorp.ct.github]$ git am /tmp/fea-fib.patch Patch format detection failed. [greearb at ben-dt xorp.ct.github]$ Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From igorm at etf.rs Tue Mar 20 10:02:40 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 20 Mar 2012 18:02:40 +0100 Subject: [Xorp-hackers] [PATCH 1/8] xorp: rtrmgr: Insert missing XrlAtoms for sending fake args In-Reply-To: <1332262967-28742-1-git-send-email-igorm@etf.rs> References: <1332262967-28742-1-git-send-email-igorm@etf.rs> Message-ID: <1332262967-28742-2-git-send-email-igorm@etf.rs> From: Igor Maravic Added missing XrlAtoms for sending fake args. Signed-off-by: Igor Maravic --- xorp/rtrmgr/xorp_client.cc | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/xorp/rtrmgr/xorp_client.cc b/xorp/rtrmgr/xorp_client.cc index a1df523..437fcb6 100644 --- a/xorp/rtrmgr/xorp_client.cc +++ b/xorp/rtrmgr/xorp_client.cc @@ -109,6 +109,7 @@ XorpClient::fake_return_args(const string& xrl_return_spec) list::const_iterator iter; for (iter = args.begin(); iter != args.end(); ++iter) { string::size_type eq = iter->find("="); + uint8_t data[] = {0}; //Needed for xrlatom_binary XrlAtom atom; debug_msg("ARG: %s\n", iter->c_str()); @@ -140,15 +141,31 @@ XorpClient::fake_return_args(const string& xrl_return_spec) xargs.add(XrlAtom(atom.name().c_str(), string("")) ); break; case xrlatom_ipv6: + xargs.add(XrlAtom(atom.name().c_str(), IPv6("::")) ); + break; case xrlatom_ipv6net: + xargs.add(XrlAtom(atom.name().c_str(), IPv6Net("::/0")) ); + break; case xrlatom_mac: + xargs.add(XrlAtom(atom.name().c_str(), Mac("00:00:00:00:00:00")) ); + break; case xrlatom_list: + xargs.add(XrlAtom(atom.name().c_str(), XrlAtomList()) ); + break; case xrlatom_boolean: + xargs.add(XrlAtom(atom.name().c_str(), false) ); + break; case xrlatom_binary: + xargs.add(XrlAtom(atom.name().c_str(), data, sizeof(data)) ); + break; case xrlatom_uint64: + xargs.add(XrlAtom(atom.name().c_str(), (uint64_t)0) ); + break; case xrlatom_int64: + xargs.add(XrlAtom(atom.name().c_str(), (int64_t)0) ); + break; case xrlatom_fp64: - XLOG_UNFINISHED(); + xargs.add(XrlAtom(atom.name().c_str(), (fp64_t)0) ); break; } } -- 1.7.5.4 From igorm at etf.rs Tue Mar 20 10:02:42 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 20 Mar 2012 18:02:42 +0100 Subject: [Xorp-hackers] [PATCH 3/8] xorp: rtrmgr: When adding child node, remove named variable with same name In-Reply-To: <1332262967-28742-1-git-send-email-igorm@etf.rs> References: <1332262967-28742-1-git-send-email-igorm@etf.rs> Message-ID: <1332262967-28742-4-git-send-email-igorm@etf.rs> From: Igor Maravic When adding child node, remove named variable with same name. If we wouldn't do that, we couldn't set value for child node, in function ConfigTreeNode::set_variable(), because we would always find named variable first. Signed-off-by: Igor Maravic --- xorp/rtrmgr/conf_tree_node.cc | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/xorp/rtrmgr/conf_tree_node.cc b/xorp/rtrmgr/conf_tree_node.cc index bb8fd25..c26d2a9 100644 --- a/xorp/rtrmgr/conf_tree_node.cc +++ b/xorp/rtrmgr/conf_tree_node.cc @@ -222,6 +222,15 @@ ConfigTreeNode::is_same(const ConfigTreeNode& them, bool ignore_node_id) const void ConfigTreeNode::add_child(ConfigTreeNode* child) { + map::iterator iter; + + iter = _variables.find(child->segname()); + if (iter != _variables.end()) { + debug_msg("Remove conflicting named variable %s on %s", + iter->first.c_str(), _segname.c_str()); + _variables.erase(iter); + } + _children.push_back(child); list sorted_children = _children; sort_by_template(sorted_children); -- 1.7.5.4 From igorm at etf.rs Tue Mar 20 10:02:41 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 20 Mar 2012 18:02:41 +0100 Subject: [Xorp-hackers] [PATCH 2/8] xorp: rtrmgr: Fix using of return varibles in xrl In-Reply-To: <1332262967-28742-1-git-send-email-igorm@etf.rs> References: <1332262967-28742-1-git-send-email-igorm@etf.rs> Message-ID: <1332262967-28742-3-git-send-email-igorm@etf.rs> From: Igor Maravic Without this patch, when we read and write from/to same xrl variable, value that should be committed to variable is overwritten with fake value. For example: ... parent @: uint { %create: xrl "$(prot.targetname)/prot/0.1/create?node:u32=$(@)"; %activate: xrl "$(prot.targetname)/prot/0.1/activate?node:u32=$(@)->child_ret:u32=$(@.child)"; %update: xrl "$(prot.targetname)/prot/0.1/update?node:u32=$(@)->child_ret:u32=$(@.child)"; child { %set: xrl "$(prot.targetname)/prot/0.1/set?node:u32=$(parent.@)&child:u32=$(@)"; } } ... In this case in function set we would get bogus value for variable child, because we are writing to it from update functions. This patch fixes that. Case when we are calling %create + %set + %activate is working without this patch. Signed-off-by: Igor Maravic --- xorp/libxipc/xrl_atom.cc | 11 +++- xorp/libxipc/xrl_atom.hh | 108 ++++++++++++++++++++------------------ xorp/rtrmgr/conf_tree_node.cc | 10 ++++ xorp/rtrmgr/conf_tree_node.hh | 9 +++ xorp/rtrmgr/template_commands.cc | 5 ++ xorp/rtrmgr/xorp_client.cc | 28 +++++----- 6 files changed, 102 insertions(+), 69 deletions(-) diff --git a/xorp/libxipc/xrl_atom.cc b/xorp/libxipc/xrl_atom.cc index a31d54a..e8a892b 100644 --- a/xorp/libxipc/xrl_atom.cc +++ b/xorp/libxipc/xrl_atom.cc @@ -385,6 +385,7 @@ XrlAtom::copy(const XrlAtom& xa) _type = xa._type; _have_data = xa._have_data; + _has_fake_args = xa._has_fake_args; _own = true; if (_have_data) { @@ -483,6 +484,7 @@ XrlAtom::discard_dynamic() // ... Your type should free allocated memory here ... } _have_data = false; + _has_fake_args = false; } } @@ -505,7 +507,8 @@ XrlAtom::str() const XrlAtom::XrlAtom(const char* serialized) throw (InvalidString, BadName) : _type(xrlatom_no_type), _have_data(false), - _own(true) + _own(true), + _has_fake_args(false) { const char *start, *sep; @@ -547,7 +550,8 @@ XrlAtom::XrlAtom(const string& name, XrlAtomType t, const string& serialized_data) throw (InvalidString) : _type(t), _have_data(false), - _own(true) + _own(true), + _has_fake_args(false) { set_name(name); ssize_t bad_pos = data_from_c_str(serialized_data.c_str()); @@ -559,7 +563,8 @@ XrlAtom::XrlAtom(const char* name, XrlAtomType t, const string& serialized_data) throw (InvalidString) : _type(t), _have_data(false), - _own(true) + _own(true), + _has_fake_args(false) { set_name(name); ssize_t bad_pos = data_from_c_str(serialized_data.c_str()); diff --git a/xorp/libxipc/xrl_atom.hh b/xorp/libxipc/xrl_atom.hh index ba996d6..7dc7a80 100644 --- a/xorp/libxipc/xrl_atom.hh +++ b/xorp/libxipc/xrl_atom.hh @@ -119,20 +119,20 @@ public: string _name; }; - XrlAtom() : _type(xrlatom_no_type), _have_data(false), _own(true) {} + XrlAtom() : _type(xrlatom_no_type), _have_data(false), _own(true), _has_fake_args(false) {} ~XrlAtom(); // type but no data constructors XrlAtom(XrlAtomType t) - : _type(t), _have_data(false), _own(true) {} + : _type(t), _have_data(false), _own(true), _has_fake_args(false) {} XrlAtom(const string& name, XrlAtomType t) throw (BadName) - : _type(t), _have_data(false), _own(true) { + : _type(t), _have_data(false), _own(true), _has_fake_args(false) { set_name(name); } XrlAtom(const char* name, XrlAtomType t) throw (BadName) - : _type(t), _have_data(false), _own(true) { + : _type(t), _have_data(false), _own(true), _has_fake_args(false) { set_name(name); } @@ -153,81 +153,81 @@ public: // int32 constructors explicit XrlAtom(const int32_t& value) - : _type(xrlatom_int32), _have_data(true), _own(true), _i32val(value) {} + : _type(xrlatom_int32), _have_data(true), _own(true), _has_fake_args(false), _i32val(value) {} - XrlAtom(const char* name, int32_t value) throw (BadName) - : _type(xrlatom_int32), _have_data(true), _own(true) ,_i32val(value) { + XrlAtom(const char* name, int32_t value, bool fake_args = false) throw (BadName) + : _type(xrlatom_int32), _have_data(true), _own(true), _has_fake_args(fake_args),_i32val(value) { set_name(name); } // bool constructors explicit XrlAtom(const bool& value) : _type(xrlatom_boolean), _have_data(true), - _own(true), _boolean(value) {} + _own(true), _has_fake_args(false), _boolean(value) {} - XrlAtom(const char* name, bool value) throw (BadName) + XrlAtom(const char* name, bool value, bool fake_args = false) throw (BadName) : _type(xrlatom_boolean), _have_data(true), - _own(true), _boolean(value) { + _own(true), _has_fake_args(fake_args), _boolean(value) { set_name(name); } // uint32 constructors explicit XrlAtom(const uint32_t& value) - : _type(xrlatom_uint32), _have_data(true), _own(true), _u32val(value) {} + : _type(xrlatom_uint32), _have_data(true), _own(true), _has_fake_args(false), _u32val(value) {} - XrlAtom(const char* name, uint32_t value) throw (BadName) - : _type(xrlatom_uint32), _have_data(true), _own(true), _u32val(value) { + XrlAtom(const char* name, uint32_t value, bool fake_args = false) throw (BadName) + : _type(xrlatom_uint32), _have_data(true), _own(true), _has_fake_args(fake_args), _u32val(value) { set_name(name); } // ipv4 constructors explicit XrlAtom(const IPv4& addr) - : _type(xrlatom_ipv4), _have_data(true), _own(true), + : _type(xrlatom_ipv4), _have_data(true), _own(true), _has_fake_args(false), _ipv4(addr) {} - XrlAtom(const char* name, const IPv4& addr) throw (BadName) - : _type(xrlatom_ipv4), _have_data(true), _own(true), + XrlAtom(const char* name, const IPv4& addr, bool fake_args = false) throw (BadName) + : _type(xrlatom_ipv4), _have_data(true), _own(true), _has_fake_args(fake_args), _ipv4(addr) { set_name(name); } // ipv4net constructors explicit XrlAtom(const IPv4Net& subnet) - : _type(xrlatom_ipv4net), _have_data(true), _own(true), + : _type(xrlatom_ipv4net), _have_data(true), _own(true), _has_fake_args(false), _ipv4net(subnet) {} - XrlAtom(const char* name, const IPv4Net& subnet) throw (BadName) - : _type(xrlatom_ipv4net), _have_data(true), _own(true), + XrlAtom(const char* name, const IPv4Net& subnet, bool fake_args = false) throw (BadName) + : _type(xrlatom_ipv4net), _have_data(true), _own(true), _has_fake_args(fake_args), _ipv4net(subnet) { set_name(name); } // ipv6 constructors explicit XrlAtom(const IPv6& addr) - : _type(xrlatom_ipv6), _have_data(true), _own(true), + : _type(xrlatom_ipv6), _have_data(true), _own(true), _has_fake_args(false), _ipv6(new IPv6(addr)) {} XrlAtom(const char* name, const IPv6& addr) throw (BadName) - : _type(xrlatom_ipv6), _have_data(true), _own(true), + : _type(xrlatom_ipv6), _have_data(true), _own(true), _has_fake_args(false), _ipv6(new IPv6(addr)) { set_name(name); } // ipv6 net constructors explicit XrlAtom(const IPv6Net& subnet) - : _type(xrlatom_ipv6net), _have_data(true), _own(true), + : _type(xrlatom_ipv6net), _have_data(true), _own(true), _has_fake_args(false), _ipv6net(new IPv6Net(subnet)) {} - XrlAtom(const char* name, const IPv6Net& subnet) throw (BadName) - : _type(xrlatom_ipv6net), _have_data(true), _own(true), + XrlAtom(const char* name, const IPv6Net& subnet, bool fake_args = false) throw (BadName) + : _type(xrlatom_ipv6net), _have_data(true), _own(true), _has_fake_args(fake_args), _ipv6net(new IPv6Net(subnet)) { set_name(name); } // IPvX constructors - there is no underlying IPvX type // data is cast to IPv4 or IPv6. - XrlAtom(const char* name, const IPvX& ipvx) throw (BadName) - : _have_data(true), _own(true) + XrlAtom(const char* name, const IPvX& ipvx, bool fake_args = false) throw (BadName) + : _have_data(true), _own(true), _has_fake_args(fake_args) { set_name(name); if (ipvx.is_ipv4()) { @@ -243,8 +243,8 @@ public: // IPvXNet constructors - there is no underlying IPvXNet type // data is cast to IPv4Net or IPv6Net. - XrlAtom(const char* name, const IPvXNet& ipvxnet) throw (BadName) - : _have_data(true), _own(true) + XrlAtom(const char* name, const IPvXNet& ipvxnet, bool fake_args = false) throw (BadName) + : _have_data(true), _own(true), _has_fake_args(fake_args) { set_name(name); if (ipvxnet.is_ipv4()) { @@ -260,83 +260,83 @@ public: // mac constructors explicit XrlAtom(const Mac& mac) - : _type(xrlatom_mac), _have_data(true), _own(true), + : _type(xrlatom_mac), _have_data(true), _own(true), _has_fake_args(false), _mac(new Mac(mac)) {} - XrlAtom(const char* name, const Mac& mac) throw (BadName) - : _type(xrlatom_mac), _have_data(true), _own(true), + XrlAtom(const char* name, const Mac& mac, bool fake_args = false) throw (BadName) + : _type(xrlatom_mac), _have_data(true), _own(true), _has_fake_args(fake_args), _mac(new Mac(mac)) { set_name(name); } // text constructors explicit XrlAtom(const string& txt) - : _type(xrlatom_text), _have_data(true), _own(true), + : _type(xrlatom_text), _have_data(true), _own(true), _has_fake_args(false), _text(new string(txt)) {} - XrlAtom(const char* name, const string& txt) throw (BadName) - : _type(xrlatom_text), _have_data(true), _own(true), + XrlAtom(const char* name, const string& txt, bool fake_args = false) throw (BadName) + : _type(xrlatom_text), _have_data(true), _own(true), _has_fake_args(fake_args), _text(new string(txt)) { set_name(name); } // list constructors explicit XrlAtom(const XrlAtomList& l) - : _type(xrlatom_list), _have_data(true), _own(true), + : _type(xrlatom_list), _have_data(true), _own(true), _has_fake_args(false), _list(new XrlAtomList(l)) {} - XrlAtom(const char* name, const XrlAtomList& l) throw (BadName) - : _type(xrlatom_list), _have_data(true), _own(true), + XrlAtom(const char* name, const XrlAtomList& l, bool fake_args = false) throw (BadName) + : _type(xrlatom_list), _have_data(true), _own(true), _has_fake_args(fake_args), _list(new XrlAtomList(l)) { set_name(name); } // binary XrlAtom(const char* name, const vector& data) - : _type(xrlatom_binary), _have_data(true), _own(true), + : _type(xrlatom_binary), _have_data(true), _own(true), _has_fake_args(false), _binary(new vector(data)) { set_name(name); } - XrlAtom(const char* name, const uint8_t* data, size_t data_bytes) - : _type(xrlatom_binary), _have_data(true), _own(true), + XrlAtom(const char* name, const uint8_t* data, size_t data_bytes, bool fake_args = false) + : _type(xrlatom_binary), _have_data(true), _own(true), _has_fake_args(fake_args), _binary(new vector(data, data + data_bytes)) { set_name(name); } XrlAtom(const vector& data) - : _type(xrlatom_binary), _have_data(true), _own(true), + : _type(xrlatom_binary), _have_data(true), _own(true), _has_fake_args(false), _binary(new vector(data)) {} XrlAtom(const uint8_t* data, size_t data_bytes) - : _type(xrlatom_binary), _have_data(true), _own(true), + : _type(xrlatom_binary), _have_data(true), _own(true), _has_fake_args(false), _binary(new vector(data, data + data_bytes)) {} // int64 constructors explicit XrlAtom(const int64_t& value) - : _type(xrlatom_int64), _have_data(true), _own(true), _i64val(value) {} + : _type(xrlatom_int64), _have_data(true), _own(true), _has_fake_args(false), _i64val(value) {} - XrlAtom(const char* name, int64_t value) throw (BadName) - : _type(xrlatom_int64), _have_data(true), _own(true), _i64val(value) { + XrlAtom(const char* name, int64_t value, bool fake_args = false) throw (BadName) + : _type(xrlatom_int64), _have_data(true), _own(true), _has_fake_args(fake_args), _i64val(value) { set_name(name); } // uint64 constructors explicit XrlAtom(const uint64_t& value) - : _type(xrlatom_uint64), _have_data(true), _own(true), _u64val(value) {} + : _type(xrlatom_uint64), _have_data(true), _own(true), _has_fake_args(false), _u64val(value) {} - XrlAtom(const char* name, uint64_t value) throw (BadName) - : _type(xrlatom_uint64), _have_data(true), _own(true), _u64val(value) { + XrlAtom(const char* name, uint64_t value, bool fake_args = false) throw (BadName) + : _type(xrlatom_uint64), _have_data(true), _own(true), _has_fake_args(fake_args), _u64val(value) { set_name(name); } // fp64 constructors explicit XrlAtom(const fp64_t& value) - : _type(xrlatom_fp64), _have_data(true), _own(true), _fp64val(value) {} + : _type(xrlatom_fp64), _have_data(true), _own(true), _has_fake_args(false), _fp64val(value) {} - XrlAtom(const char* name, fp64_t value) throw (BadName) - : _type(xrlatom_fp64), _have_data(true), _own(true), _fp64val(value) { + XrlAtom(const char* name, fp64_t value, bool fake_args = false) throw (BadName) + : _type(xrlatom_fp64), _have_data(true), _own(true), _has_fake_args(fake_args), _fp64val(value) { set_name(name); } @@ -345,7 +345,7 @@ public: // Copy operations XrlAtom(const XrlAtom& x) - : _type(xrlatom_no_type), _have_data(false), _own(true) { + : _type(xrlatom_no_type), _have_data(false), _own(true), _has_fake_args(false) { copy(x); } XrlAtom& operator=(const XrlAtom& x) { @@ -362,8 +362,11 @@ public: const string value() const; const bool& has_data() const { return _have_data; } + const bool& has_fake_args() const { return _has_fake_args; } const XrlAtomType& type() const { return _type; } + void using_real_args() { _has_fake_args = false; } + // The following accessors may throw accessor exceptions... const bool& boolean() const throw (NoData, WrongType); const int32_t& int32() const throw (NoData, WrongType); @@ -482,6 +485,7 @@ private: bool _have_data; string _atom_name; bool _own; + bool _has_fake_args; union { bool _boolean; diff --git a/xorp/rtrmgr/conf_tree_node.cc b/xorp/rtrmgr/conf_tree_node.cc index 12adc59..bb8fd25 100644 --- a/xorp/rtrmgr/conf_tree_node.cc +++ b/xorp/rtrmgr/conf_tree_node.cc @@ -1866,6 +1866,16 @@ ConfigTreeNode::expand_varname_to_matchlist(const vector& parts, } } +void +ConfigTreeNode::value_to_node_existing_value(const string& varname, string& value) +{ + VarType type; + ConfigTreeNode* node = find_varname_node(varname, type); + if (node && node->has_value()) + value = node->value(); +} + + bool ConfigTreeNode::set_variable(const string& varname, const string& value) { diff --git a/xorp/rtrmgr/conf_tree_node.hh b/xorp/rtrmgr/conf_tree_node.hh index 0101a00..4bff458 100644 --- a/xorp/rtrmgr/conf_tree_node.hh +++ b/xorp/rtrmgr/conf_tree_node.hh @@ -174,6 +174,15 @@ public: bool has_undeleted_children() const; virtual void update_node_id_position(); + /** + * This function sets variable value, from it's arguments, + * to existing value of node. + * + * If there is no node defined with varname or node + * doesn't have value, variable value stays unchanged. + */ + void value_to_node_existing_value(const string& varname, string& value); + protected: bool split_up_varname(const string& varname, list& var_parts) const; diff --git a/xorp/rtrmgr/template_commands.cc b/xorp/rtrmgr/template_commands.cc index 8164d72..00422bd 100644 --- a/xorp/rtrmgr/template_commands.cc +++ b/xorp/rtrmgr/template_commands.cc @@ -1419,6 +1419,11 @@ Command::process_xrl_action_return_arguments(XrlArgs* xrl_args, string value = returned_atom.value(); debug_msg("found atom = %s\n", returned_atom.str().c_str()); debug_msg("found value = %s\n", value.c_str()); + + if (returned_atom.has_fake_args()) { + ctn->value_to_node_existing_value(varname, value); + returned_atom.using_real_args(); + } ctn->set_variable(varname, value); } diff --git a/xorp/rtrmgr/xorp_client.cc b/xorp/rtrmgr/xorp_client.cc index 437fcb6..f88b3de 100644 --- a/xorp/rtrmgr/xorp_client.cc +++ b/xorp/rtrmgr/xorp_client.cc @@ -126,46 +126,46 @@ XorpClient::fake_return_args(const string& xrl_return_spec) case xrlatom_no_type: XLOG_UNREACHABLE(); case xrlatom_int32: - xargs.add(XrlAtom(atom.name().c_str(), (int32_t)0) ); + xargs.add(XrlAtom(atom.name().c_str(), (int32_t)0, true) ); break; case xrlatom_uint32: - xargs.add(XrlAtom(atom.name().c_str(), (uint32_t)0) ); + xargs.add(XrlAtom(atom.name().c_str(), (uint32_t)0, true) ); break; case xrlatom_ipv4: - xargs.add(XrlAtom(atom.name().c_str(), IPv4("0.0.0.0")) ); + xargs.add(XrlAtom(atom.name().c_str(), IPv4("0.0.0.0"), true) ); break; case xrlatom_ipv4net: - xargs.add(XrlAtom(atom.name().c_str(), IPv4Net("0.0.0.0/0")) ); + xargs.add(XrlAtom(atom.name().c_str(), IPv4Net("0.0.0.0/0"), true) ); break; case xrlatom_text: - xargs.add(XrlAtom(atom.name().c_str(), string("")) ); + xargs.add(XrlAtom(atom.name().c_str(), string(""), true) ); break; case xrlatom_ipv6: - xargs.add(XrlAtom(atom.name().c_str(), IPv6("::")) ); + xargs.add(XrlAtom(atom.name().c_str(), IPv6("::"), true) ); break; case xrlatom_ipv6net: - xargs.add(XrlAtom(atom.name().c_str(), IPv6Net("::/0")) ); + xargs.add(XrlAtom(atom.name().c_str(), IPv6Net("::/0"), true) ); break; case xrlatom_mac: - xargs.add(XrlAtom(atom.name().c_str(), Mac("00:00:00:00:00:00")) ); + xargs.add(XrlAtom(atom.name().c_str(), Mac("00:00:00:00:00:00"), true) ); break; case xrlatom_list: - xargs.add(XrlAtom(atom.name().c_str(), XrlAtomList()) ); + xargs.add(XrlAtom(atom.name().c_str(), XrlAtomList(), true) ); break; case xrlatom_boolean: - xargs.add(XrlAtom(atom.name().c_str(), false) ); + xargs.add(XrlAtom(atom.name().c_str(), false, true) ); break; case xrlatom_binary: - xargs.add(XrlAtom(atom.name().c_str(), data, sizeof(data)) ); + xargs.add(XrlAtom(atom.name().c_str(), data, sizeof(data), true) ); break; case xrlatom_uint64: - xargs.add(XrlAtom(atom.name().c_str(), (uint64_t)0) ); + xargs.add(XrlAtom(atom.name().c_str(), (uint64_t)0, true) ); break; case xrlatom_int64: - xargs.add(XrlAtom(atom.name().c_str(), (int64_t)0) ); + xargs.add(XrlAtom(atom.name().c_str(), (int64_t)0, true) ); break; case xrlatom_fp64: - xargs.add(XrlAtom(atom.name().c_str(), (fp64_t)0) ); + xargs.add(XrlAtom(atom.name().c_str(), (fp64_t)0, true) ); break; } } -- 1.7.5.4 From igorm at etf.rs Tue Mar 20 10:02:45 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 20 Mar 2012 18:02:45 +0100 Subject: [Xorp-hackers] [PATCH 6/8] xorp:etc:templates: add missing returning args to %get functions In-Reply-To: <1332262967-28742-1-git-send-email-igorm@etf.rs> References: <1332262967-28742-1-git-send-email-igorm@etf.rs> Message-ID: <1332262967-28742-7-git-send-email-igorm@etf.rs> From: Igor Maravic Signed-off-by: Igor Maravic --- xorp/etc/templates/interfaces.tp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xorp/etc/templates/interfaces.tp b/xorp/etc/templates/interfaces.tp index ecfdc28..8665df1 100644 --- a/xorp/etc/templates/interfaces.tp +++ b/xorp/etc/templates/interfaces.tp @@ -192,7 +192,7 @@ interfaces { %help: short "Assign the network prefix length"; %allow-range: $(@) "1" "32" %help: "The network prefix length"; %set: xrl "$(interfaces.targetname)/ifmgr/0.1/set_prefix4?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)&prefix_len:u32=$(@)"; - %get: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_prefix4?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)->prefix_len:u32"; + %get: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_prefix4?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)->prefix_len:u32=$(@)"; } broadcast { @@ -246,7 +246,7 @@ interfaces { %help: short "Assign the network prefix length"; %allow-range: $(@) "1" "128" %help: "The network prefix length"; %set: xrl "$(interfaces.targetname)/ifmgr/0.1/set_prefix6?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)&prefix_len:u32=$(@)"; - %get: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_prefix6?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)->prefix_len:u32"; + %get: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_prefix6?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)->prefix_len:u32=$(@)"; } destination { -- 1.7.5.4 From igorm at etf.rs Tue Mar 20 10:02:46 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 20 Mar 2012 18:02:46 +0100 Subject: [Xorp-hackers] [PATCH 7/8] xorp: etc: templates: Don't read vif parameters one by one In-Reply-To: <1332262967-28742-1-git-send-email-igorm@etf.rs> References: <1332262967-28742-1-git-send-email-igorm@etf.rs> Message-ID: <1332262967-28742-8-git-send-email-igorm@etf.rs> From: Igor Maravic Delete %get functions for vif address parameters and put single %get function in address node that handle all parameters. All parameters that should be read from system are false by default. They are synchronized as soon as vif address is created. If parent if of created vif doesn't exist on system, those parameters aren't important. Signed-off-by: Igor Maravic --- xorp/etc/templates/interfaces.tp | 38 ++++++++++++++++++++------------------ 1 files changed, 20 insertions(+), 18 deletions(-) diff --git a/xorp/etc/templates/interfaces.tp b/xorp/etc/templates/interfaces.tp index 8665df1..135b539 100644 --- a/xorp/etc/templates/interfaces.tp +++ b/xorp/etc/templates/interfaces.tp @@ -26,9 +26,10 @@ interfaces { prefix-length: u32; broadcast: ipv4; destination: ipv4; - multicast-capable: bool; - point-to-point: bool; - loopback: bool; + multicast-capable: toggle = false; + point-to-point: toggle = false; + loopback: toggle = false; + broadcast-capable: toggle = false; disable: toggle = false; enabled: bool; /* %deprecated */ } @@ -36,9 +37,9 @@ interfaces { address @: ipv6 { prefix-length: u32; destination: ipv6; - multicast-capable: bool; - point-to-point: bool; - loopback: bool; + multicast-capable: toggle = false; + point-to-point: toggle = false; + loopback: toggle = false; disable: toggle = false; enabled: bool; /* %deprecated */ } @@ -147,6 +148,7 @@ interfaces { %help: short "Interface-type: VLAN."; %set: xrl "$(interfaces.targetname)/ifmgr/0.1/set_iface_type?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&iface_type:txt=$(@)"; } + vid { %help: short "Virtual Interface Identifier: VLAN-ID for VLANs."; %set: xrl "$(interfaces.targetname)/ifmgr/0.1/set_vid?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vid:txt=$(@)"; @@ -174,6 +176,7 @@ interfaces { %mandatory: $(@.prefix-length); %create: xrl "$(interfaces.targetname)/ifmgr/0.1/create_address4?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(@)"; + %get: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags4?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(@)->enabled:bool&broadcast:bool=$(@.broadcast-capable)&loopback:bool=$(@.loopback)&point_to_point:bool=$(@.point-to-point)&multicast:bool=$(@.multicast-capable)"; %delete: xrl "$(interfaces.targetname)/ifmgr/0.1/delete_address4?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(@)"; %list: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_vif_addresses4?ifname:txt=$(interface.@)&vif:txt->addresses:list"; @@ -208,18 +211,19 @@ interfaces { } multicast-capable { - %help: short "Show if the address is multicast capable"; - %get: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags4?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)->enabled:bool&broadcast:bool&loopback:bool&point_to_point:bool&multicast:bool=$(@)"; + %help: short "Show if this is multicast capable vif"; } point-to-point { - %help: short "Show if the address is point-to-point"; - %get: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags4?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)->enabled:bool&broadcast:bool&loopback:bool&point_to_point:bool=$(@)&multicast:bool"; + %help: short "Show if this is point-to-point vif"; } loopback { - %help: short "Show if this is a loopback address"; - %get: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags4?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)->enabled:bool&broadcast:bool&loopback:bool=$(@)&point_to_point:bool&multicast:bool"; + %help: short "Show if this is a loopback vif"; + } + + broadcast-capable { + %help: short "Show if this is a broadcast capable vif"; } } @@ -228,6 +232,7 @@ interfaces { %mandatory: $(@.prefix-length); %create: xrl "$(interfaces.targetname)/ifmgr/0.1/create_address6?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(@)"; + %get: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags6?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)->enabled:bool&loopback:bool=$(@.loopback)&point_to_point:bool=$(@.point-to-point)&multicast:bool=$(@.multicast-capable)"; %delete: xrl "$(interfaces.targetname)/ifmgr/0.1/delete_address6?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(@)"; %list: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_vif_addresses6?ifname:txt=$(interface.@)&vif:txt->addresses:list"; @@ -256,18 +261,15 @@ interfaces { } multicast-capable { - %help: short "Show if the address is multicast capable"; - %get: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags6?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)->enabled:bool&loopback:bool&point_to_point:bool&multicast:bool=$(@)"; + %help: short "Show if this is multicast capable vif"; } point-to-point { - %help: short "Show if the address is point-to-point"; - %get: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags6?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)->enabled:bool&loopback:bool&point_to_point:bool=$(@)&multicast:bool"; + %help: short "Show if this is point-to-point vif"; } loopback { - %help: short "Show if this is a loopback address"; - %get: xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags6?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)->enabled:bool&loopback:bool=$(@)&point_to_point:bool&multicast:bool"; + %help: short "Show if this is a loopback vif"; } } } -- 1.7.5.4 From igorm at etf.rs Tue Mar 20 10:02:43 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 20 Mar 2012 18:02:43 +0100 Subject: [Xorp-hackers] [PATCH 4/8] trivial: automated ws fixes In-Reply-To: <1332262967-28742-1-git-send-email-igorm@etf.rs> References: <1332262967-28742-1-git-send-email-igorm@etf.rs> Message-ID: <1332262967-28742-5-git-send-email-igorm@etf.rs> From: Igor Maravic Signed-off-by: Igor Maravic --- xorp/fea/data_plane/ifconfig/ifconfig_set.cc | 6 ++-- xorp/rtrmgr/cli.cc | 42 +++++++++++++------------- xorp/rtrmgr/master_conf_tree_node.cc | 38 +++++++++++----------- xorp/rtrmgr/master_conf_tree_node.hh | 14 ++++---- xorp/rtrmgr/module_command.cc | 4 +- 5 files changed, 52 insertions(+), 52 deletions(-) diff --git a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc index 9dc37a9..6965c41 100644 --- a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc +++ b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -333,7 +333,7 @@ IfConfigSet::push_config(const IfTree& iftree) if (error_reporter.error_count() != 0) return (XORP_ERROR); - + return (XORP_OK); } diff --git a/xorp/rtrmgr/cli.cc b/xorp/rtrmgr/cli.cc index 7f42bec..edb5a95 100644 --- a/xorp/rtrmgr/cli.cc +++ b/xorp/rtrmgr/cli.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -183,7 +183,7 @@ RouterCLI::RouterCLI(XorpShellBase& xorpsh, CliNode& cli_node, // internationalization. // _help_o["configure"] = "Switch to configuration mode"; - _help_o["configure exclusive"] + _help_o["configure exclusive"] = "Switch to configuration mode, locking out other users"; _help_o["exit"] = "Exit this command session"; _help_o["help"] = "Provide help with commands"; @@ -195,7 +195,7 @@ RouterCLI::RouterCLI(XorpShellBase& xorpsh, CliNode& cli_node, _help_c["edit"] = "Edit a sub-element"; _help_c["exit"] = "Exit from this configuration level"; _help_c["exit configuration-mode"] = "Exit from configuration mode"; - _help_c["exit discard"] + _help_c["exit discard"] = "Exit from configuration mode, discarding changes"; _help_c["help"] = "Provide help with commands"; _help_c["load"] = "Load configuration from a file"; @@ -582,7 +582,7 @@ RouterCLI::done() const return (true); } -string +string RouterCLI::get_help_o(const string& s) const { map::const_iterator i = _help_o.find(s); @@ -593,7 +593,7 @@ RouterCLI::get_help_o(const string& s) const return i->second; } -string +string RouterCLI::get_help_c(const string& s) const { map::const_iterator i = _help_c.find(s); @@ -728,7 +728,7 @@ RouterCLI::add_op_mode_commands(CliCommand* com0, string& error_msg) return (XORP_OK); } -map +map RouterCLI::op_mode_help(const vector& command_global_name) const { string command_name; @@ -1171,7 +1171,7 @@ RouterCLI::config_changed_by_other_user() { if (! is_config_mode()) { // XXX: we care about the changes only if we are in config mode - return; + return; } // @@ -1748,7 +1748,7 @@ RouterCLI::new_config_user(uid_t user_id) string user_name = get_user_name(user_id); if (user_name.empty()) user_name = c_format("UID:%u", XORP_UINT_CAST(user_id)); - + string alert = c_format("User %s entered configuration mode\n", user_name.c_str()); notify_user(alert, false /* not urgent */); @@ -1815,7 +1815,7 @@ RouterCLI::op_help_func(const string& , if (i != _help_long_o.end()) { cli_client()->cli_print("\n" + i->second + "\n\n"); return (XORP_OK); - } + } // // There was no long help description available. If there's a @@ -1862,7 +1862,7 @@ RouterCLI::conf_help_func(const string& , if (i != _help_long_c.end()) { cli_client()->cli_print("\n" + i->second + "\n\n"); return (XORP_OK); - } + } // // There was no long help description available. If there's a @@ -2311,7 +2311,7 @@ RouterCLI::text_entry_func(const string& , for (cti = ctn->children().begin(); cti != ctn->children().end(); ++cti) { if ((*cti)->segname() == new_path_segments.front()) { - XLOG_TRACE(_verbose, "Found pre-existing node: %s\n", + XLOG_TRACE(_verbose, "Found pre-existing node: %s\n", (*cti)->segname().c_str()); ConfigTreeNode *existing_ctn = (*cti); ctn = (SlaveConfigTreeNode*)(existing_ctn); @@ -2326,7 +2326,7 @@ RouterCLI::text_entry_func(const string& , } if (value_expected) { // We're expecting a value here - if (new_path_segments.front() == "{" + if (new_path_segments.front() == "{" || new_path_segments.front() == "}" ) { error_msg = c_format("ERROR: a value for \"%s\" " "is required.\n", @@ -2388,13 +2388,13 @@ RouterCLI::text_entry_func(const string& , error_msg += c_format(" Allowed type(s): %s.", cand_types.c_str()); } - error_msg += "\n"; + error_msg += "\n"; cli_client()->cli_print(error_msg); goto cleanup; } path_segments.push_back(value); XLOG_TRACE(_verbose, "creating node %s\n", value.c_str()); - ctn = new SlaveConfigTreeNode(value, + ctn = new SlaveConfigTreeNode(value, makepath(path_segments), data_ttn, ctn, ConfigNodeId::ZERO(), @@ -2492,7 +2492,7 @@ RouterCLI::text_entry_func(const string& , cli_client()->cli_print("ERROR: mismatched \"}\".\n"); goto cleanup; } - XLOG_TRACE(_verbose, "braces: %u ctn depth: %u ctn: %s\n", + XLOG_TRACE(_verbose, "braces: %u ctn depth: %u ctn: %s\n", XORP_UINT_CAST(_braces.back()), ctn->depth(), ctn->segname().c_str()); while (ctn->depth() > _braces.back()) { @@ -2501,7 +2501,7 @@ RouterCLI::text_entry_func(const string& , //appropriately before we can handle this correctly. ctn = ctn->parent(); XLOG_TRACE(_verbose, "jumping out one level\n"); - XLOG_TRACE(_verbose, "braces: %u ctn depth: %u ctn: %s\n", + XLOG_TRACE(_verbose, "braces: %u ctn depth: %u ctn: %s\n", XORP_UINT_CAST(_braces.back()), ctn->depth(), ctn->segname().c_str()); } @@ -2566,7 +2566,7 @@ RouterCLI::text_entry_func(const string& , } XLOG_TRACE(_verbose, "creating node %s\n", ttn->segname().c_str()); - ctn = new SlaveConfigTreeNode(ttn->segname(), + ctn = new SlaveConfigTreeNode(ttn->segname(), makepath(path_segments), ttn, ctn, ConfigNodeId::ZERO(), @@ -2654,7 +2654,7 @@ RouterCLI::text_entry_func(const string& , return (XORP_ERROR); } -map +map RouterCLI::text_entry_children_func(const vector& vector_path) const { string command_name; @@ -2712,7 +2712,7 @@ RouterCLI::text_entry_children_func(const vector& vector_path) const ttn = template_tree()->find_node(path_segments); if (ttn != NULL && (! ttn->is_deprecated()) && (! ttn->is_user_hidden())) { list::const_iterator tti; - for (tti = ttn->children().begin(); tti != ttn->children().end(); + for (tti = ttn->children().begin(); tti != ttn->children().end(); ++tti) { const TemplateTreeNode* ttn_child = *tti; // XXX: ignore deprecated subtrees @@ -2766,7 +2766,7 @@ RouterCLI::text_entry_children_func(const vector& vector_path) const ccm.set_is_argument_expected(true); children.insert(make_pair(command_name, ccm)); } - + if (ttn->is_leaf_value() && (! ttn->is_tag()) && ttn->allowed_values().empty() && ttn->allowed_ranges().empty()) { diff --git a/xorp/rtrmgr/master_conf_tree_node.cc b/xorp/rtrmgr/master_conf_tree_node.cc index 1b350ce..170b5f2 100644 --- a/xorp/rtrmgr/master_conf_tree_node.cc +++ b/xorp/rtrmgr/master_conf_tree_node.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -44,13 +44,13 @@ MasterConfigTreeNode::MasterConfigTreeNode(bool verbose) } MasterConfigTreeNode::MasterConfigTreeNode(const string& nodename, - const string& path, + const string& path, const TemplateTreeNode* ttn, MasterConfigTreeNode* parent, const ConfigNodeId& node_id, uid_t user_id, bool verbose) - : ConfigTreeNode(nodename, path, ttn, parent, node_id, user_id, + : ConfigTreeNode(nodename, path, ttn, parent, node_id, user_id, /* clientid */ 0, verbose), _actions_pending(0), _actions_succeeded(true), @@ -68,8 +68,8 @@ MasterConfigTreeNode::MasterConfigTreeNode(const MasterConfigTreeNode& ctn) ConfigTreeNode* MasterConfigTreeNode::create_node(const string& segment, const string& path, - const TemplateTreeNode* ttn, - ConfigTreeNode* parent_node, + const TemplateTreeNode* ttn, + ConfigTreeNode* parent_node, const ConfigNodeId& node_id, uid_t user_id, uint32_t clientid, @@ -83,7 +83,7 @@ MasterConfigTreeNode::create_node(const string& segment, const string& path, if (parent_node != NULL) XLOG_ASSERT(parent != NULL); - new_node = new MasterConfigTreeNode(segment, path, ttn, parent, + new_node = new MasterConfigTreeNode(segment, path, ttn, parent, node_id, user_id, verbose); return reinterpret_cast(new_node); } @@ -316,7 +316,7 @@ MasterConfigTreeNode::find_all_modules(set& all_modules) const } } -void +void MasterConfigTreeNode::initialize_commit() { _actions_pending = 0; @@ -394,7 +394,7 @@ MasterConfigTreeNode::commit_changes(TaskManager& task_manager, if (_template_tree_node != NULL) { // Do we have to start any modules to implement this functionality base_cmd = _template_tree_node->const_command("%modinfo"); - const ModuleCommand* modcmd + const ModuleCommand* modcmd = dynamic_cast(base_cmd); if (modcmd != NULL) { if (modcmd->start_transaction(*this, task_manager) != XORP_OK) { @@ -420,7 +420,7 @@ MasterConfigTreeNode::commit_changes(TaskManager& task_manager, // (_value_committed == false) // XLOG_ASSERT(_existence_committed); - XLOG_ASSERT(!_value_committed); + XLOG_ASSERT(!_value_committed); base_cmd = _template_tree_node->const_command("%delete"); if (base_cmd != NULL) { cmd = reinterpret_cast(base_cmd); @@ -446,7 +446,7 @@ MasterConfigTreeNode::commit_changes(TaskManager& task_manager, base_cmd = _template_tree_node->const_command("%allow"); if (base_cmd == NULL) { // Try allow-range - base_cmd + base_cmd = _template_tree_node->const_command("%allow-range"); } if (base_cmd != NULL) { @@ -473,7 +473,7 @@ MasterConfigTreeNode::commit_changes(TaskManager& task_manager, } } // Check that the operator is OK - base_cmd = + base_cmd = _template_tree_node->const_command("%allow-operator"); if (base_cmd == NULL) { /* no explicit command, so only ":" is allowed */ @@ -481,7 +481,7 @@ MasterConfigTreeNode::commit_changes(TaskManager& task_manager, error_msg = c_format("Bad operator for \"%s\": " "operator %s was specified, " "only ':' is allowed\n", - path().c_str(), + path().c_str(), operator_to_str(_operator).c_str()); error_msg += "No changes have been committed. "; error_msg += "Correct this error and try again."; @@ -551,7 +551,7 @@ MasterConfigTreeNode::commit_changes(TaskManager& task_manager, string child_error_msg; MasterConfigTreeNode *child = (MasterConfigTreeNode*)(*prev_iter); success = child->commit_changes(task_manager, do_commit, - depth + 1, last_depth, + depth + 1, last_depth, child_error_msg, needs_activate, needs_update); @@ -646,7 +646,7 @@ MasterConfigTreeNode::commit_changes(TaskManager& task_manager, return success; } -bool +bool MasterConfigTreeNode::check_commit_status(string& error_msg) const { debug_msg("ConfigTreeNode::check_commit_status %s\n", @@ -664,7 +664,7 @@ MasterConfigTreeNode::check_commit_status(string& error_msg) const return false; } if (_deleted) { - const BaseCommand* cmd + const BaseCommand* cmd = _template_tree_node->const_command("%delete"); if (cmd != NULL) { // @@ -689,7 +689,7 @@ MasterConfigTreeNode::check_commit_status(string& error_msg) const return result; } -void +void MasterConfigTreeNode::finalize_commit() { debug_msg("MasterConfigTreeNode::finalize_commit %s\n", @@ -705,7 +705,7 @@ MasterConfigTreeNode::finalize_commit() // previously committed (_value_committed == false) // XLOG_ASSERT(_existence_committed); - XLOG_ASSERT(!_value_committed); + XLOG_ASSERT(!_value_committed); delete_subtree_silently(); // No point in going further return; @@ -729,7 +729,7 @@ MasterConfigTreeNode::finalize_commit() // careful the iterator stays valid. // list::iterator iter, prev_iter; - iter = _children.begin(); + iter = _children.begin(); while (iter != _children.end()) { prev_iter = iter; ++iter; diff --git a/xorp/rtrmgr/master_conf_tree_node.hh b/xorp/rtrmgr/master_conf_tree_node.hh index b600fa5..0d37dc3 100644 --- a/xorp/rtrmgr/master_conf_tree_node.hh +++ b/xorp/rtrmgr/master_conf_tree_node.hh @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -37,16 +37,16 @@ class MasterConfigTreeNode : public ConfigTreeNode { public: MasterConfigTreeNode(bool verbose); MasterConfigTreeNode(const MasterConfigTreeNode& ctn); - MasterConfigTreeNode(const string& node_name, const string& path, - const TemplateTreeNode* ttn, + MasterConfigTreeNode(const string& node_name, const string& path, + const TemplateTreeNode* ttn, MasterConfigTreeNode* parent, const ConfigNodeId& node_id, uid_t user_id, bool verbose); - virtual ConfigTreeNode* create_node(const string& segment, + virtual ConfigTreeNode* create_node(const string& segment, const string& path, - const TemplateTreeNode* ttn, - ConfigTreeNode* parent_node, + const TemplateTreeNode* ttn, + ConfigTreeNode* parent_node, const ConfigNodeId& node_id, uid_t user_id, uint32_t clientid, diff --git a/xorp/rtrmgr/module_command.cc b/xorp/rtrmgr/module_command.cc index ef0bfd3..85eb2c7 100644 --- a/xorp/rtrmgr/module_command.cc +++ b/xorp/rtrmgr/module_command.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net -- 1.7.5.4 From igorm at etf.rs Tue Mar 20 10:02:39 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 20 Mar 2012 18:02:39 +0100 Subject: [Xorp-hackers] [PATCH 0/8] Enable sync of Xorp and kernel In-Reply-To: References: Message-ID: <1332262967-28742-1-git-send-email-igorm@etf.rs> From: Igor Maravic Hi, In this patch series I fixed returning of variable values and enabled sync of Xorp and kernel. BR Igor Maravic Igor Maravic (8): xorp: rtrmgr: Insert missing XrlAtoms for sending fake args xorp: rtrmgr: Fix using of return varibles in xrl xorp: rtrmgr: When adding child node, remove named variable with same name trivial: automated ws fixes xorp: rtrmgr: Enable usage of %get functions xorp:etc:templates: add missing returning args to %get functions xorp: etc: templates: Don't read vif parameters one by one xorp: fea: data_plane: ifconfig: Check if we can set destination(broadcast) address for vif xorp/etc/templates/interfaces.tp | 42 +++++---- xorp/fea/data_plane/ifconfig/ifconfig_set.cc | 21 ++++- xorp/libxipc/xrl_atom.cc | 11 ++- xorp/libxipc/xrl_atom.hh | 108 +++++++++++---------- xorp/rtrmgr/cli.cc | 43 +++++---- xorp/rtrmgr/conf_tree_node.cc | 36 +++++++ xorp/rtrmgr/conf_tree_node.hh | 10 ++ xorp/rtrmgr/master_conf_tree_node.cc | 132 ++++++++++++++++++++++---- xorp/rtrmgr/master_conf_tree_node.hh | 24 ++++-- xorp/rtrmgr/module_command.cc | 4 +- xorp/rtrmgr/template_commands.cc | 5 + xorp/rtrmgr/xorp_client.cc | 29 +++++- 12 files changed, 332 insertions(+), 133 deletions(-) -- 1.7.5.4 From igorm at etf.rs Tue Mar 20 10:02:47 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 20 Mar 2012 18:02:47 +0100 Subject: [Xorp-hackers] [PATCH 8/8] xorp: fea: data_plane: ifconfig: Check if we can set destination(broadcast) address for vif In-Reply-To: <1332262967-28742-1-git-send-email-igorm@etf.rs> References: <1332262967-28742-1-git-send-email-igorm@etf.rs> Message-ID: <1332262967-28742-9-git-send-email-igorm@etf.rs> From: Igor Maravic If our vif on system isn't broadcast-capable(point-to-point) link we can't set appropriate broadcast(destination) address. Commit will fail in that case. Signed-off-by: Igor Maravic --- xorp/fea/data_plane/ifconfig/ifconfig_set.cc | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc index 6965c41..046ab3e 100644 --- a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc +++ b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc @@ -595,6 +595,21 @@ IfConfigSet::push_vif_address(const IfTreeInterface* system_ifp, is_add = false; } + if (system_vifp != NULL) { + if (system_vifp->point_to_point() != config_addr.point_to_point()) { + error_msg = c_format("Can't set destination address for if: %s vif: %s" + "because it isn't point-to-point interface\n", + system_ifp->ifname().c_str(), system_vifp->vifname().c_str()); + goto done; + } + if (system_vifp->broadcast() != config_addr.broadcast()) { + error_msg = c_format("Can't set broadcast address for if: %s vif: %s" + "because it isn't broadcast capable\n", + system_ifp->ifname().c_str(), system_vifp->vifname().c_str()); + goto done; + } + } + // // XXX: If the broadcast address was omitted, recompute and set it here. // Note that we recompute it only if the underlying vif is -- 1.7.5.4 From igorm at etf.rs Tue Mar 20 10:02:44 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 20 Mar 2012 18:02:44 +0100 Subject: [Xorp-hackers] [PATCH 5/8] xorp: rtrmgr: Enable usage of %get functions In-Reply-To: <1332262967-28742-1-git-send-email-igorm@etf.rs> References: <1332262967-28742-1-git-send-email-igorm@etf.rs> Message-ID: <1332262967-28742-6-git-send-email-igorm@etf.rs> From: Igor Maravic %get functions are very important, so our CLI DB would be synchronized with kernel DB. So, in this patch I am looking for existing %get functions of affected modules. They are stashed in map for latter calling. After we finish all changes in our module, that means after end_commit function is called, all stashed %get functions are called. Signed-off-by: Igor Maravic --- xorp/rtrmgr/cli.cc | 1 + xorp/rtrmgr/conf_tree_node.cc | 17 ++++++ xorp/rtrmgr/conf_tree_node.hh | 1 + xorp/rtrmgr/master_conf_tree_node.cc | 94 ++++++++++++++++++++++++++++++++++ xorp/rtrmgr/master_conf_tree_node.hh | 10 ++++ 5 files changed, 123 insertions(+), 0 deletions(-) diff --git a/xorp/rtrmgr/cli.cc b/xorp/rtrmgr/cli.cc index edb5a95..adcb019 100644 --- a/xorp/rtrmgr/cli.cc +++ b/xorp/rtrmgr/cli.cc @@ -1476,6 +1476,7 @@ RouterCLI::add_delete_subtree() cmds.push_back("%create"); cmds.push_back("%activate"); cmds.push_back("%update"); + cmds.push_back("%get"); cmds.push_back("%set"); cmds.push_back("%delete"); SlaveConfigTreeNode *current_config_node = config_tree()->find_node(_path); diff --git a/xorp/rtrmgr/conf_tree_node.cc b/xorp/rtrmgr/conf_tree_node.cc index c26d2a9..7050ffa 100644 --- a/xorp/rtrmgr/conf_tree_node.cc +++ b/xorp/rtrmgr/conf_tree_node.cc @@ -893,6 +893,23 @@ ConfigTreeNode::undelete_subtree() } } +ConfigTreeNode* +ConfigTreeNode::module_root_node() +{ + /** + * Module root node is the node that have modinfo commands defined + * + * If we are not the module root node, + * we recursively check our parent node. + */ + if (_template_tree_node->const_command("%modinfo")) + return this; + + XLOG_ASSERT(_parent); + + return _parent->module_root_node(); +} + string ConfigTreeNode::show_subtree(bool show_top, int depth, int indent, bool do_indent, bool numbered, bool annotate, diff --git a/xorp/rtrmgr/conf_tree_node.hh b/xorp/rtrmgr/conf_tree_node.hh index 4bff458..ebd8fe9 100644 --- a/xorp/rtrmgr/conf_tree_node.hh +++ b/xorp/rtrmgr/conf_tree_node.hh @@ -139,6 +139,7 @@ public: void set_parent(ConfigTreeNode* parent) { _parent = parent; } ConfigTreeNode* parent() { return _parent; } const ConfigTreeNode* const_parent() const { return _parent; } + ConfigTreeNode* module_root_node(); list& children() { return _children; } const list& const_children() const { return _children; } string show_subtree(bool show_top, int depth, int indent, bool do_indent, diff --git a/xorp/rtrmgr/master_conf_tree_node.cc b/xorp/rtrmgr/master_conf_tree_node.cc index 170b5f2..4251177 100644 --- a/xorp/rtrmgr/master_conf_tree_node.cc +++ b/xorp/rtrmgr/master_conf_tree_node.cc @@ -174,6 +174,15 @@ MasterConfigTreeNode::find_changed_modules(set& changed_modules) const for (iter = modules.begin(); iter != modules.end(); ++iter) changed_modules.insert(*iter); } + + base_cmd = _template_tree_node->const_command("%get"); + if (base_cmd != NULL) { + cmd = reinterpret_cast(base_cmd); + modules = cmd->affected_modules(); + for (iter = modules.begin(); iter != modules.end(); ++iter) + changed_modules.insert(*iter); + } + base_cmd = _template_tree_node->const_command("%update"); if (base_cmd != NULL) { cmd = reinterpret_cast(base_cmd); @@ -246,6 +255,14 @@ MasterConfigTreeNode::find_active_modules(set& active_modules) const for (iter = modules.begin(); iter != modules.end(); ++iter) active_modules.insert(*iter); } + + base_cmd = _template_tree_node->const_command("%get"); + if (base_cmd != NULL) { + cmd = reinterpret_cast(base_cmd); + modules = cmd->affected_modules(); + for (iter = modules.begin(); iter != modules.end(); ++iter) + active_modules.insert(*iter); + } } // @@ -301,6 +318,15 @@ MasterConfigTreeNode::find_all_modules(set& all_modules) const for (iter = modules.begin(); iter != modules.end(); ++iter) all_modules.insert(*iter); } + + base_cmd = _template_tree_node->const_command("%get"); + if (base_cmd != NULL) { + cmd = reinterpret_cast(base_cmd); + modules = cmd->affected_modules(); + for (iter = modules.begin(); iter != modules.end(); ++iter) + all_modules.insert(*iter); + } + base_cmd = _template_tree_node->const_command("%set"); if (base_cmd != NULL) { cmd = reinterpret_cast(base_cmd); @@ -322,6 +348,7 @@ MasterConfigTreeNode::initialize_commit() _actions_pending = 0; _actions_succeeded = true; _cmd_that_failed = NULL; + _sync_cmds.clear(); list::iterator iter; for (iter = _children.begin(); iter != _children.end(); ++iter) { @@ -570,6 +597,18 @@ MasterConfigTreeNode::commit_changes(TaskManager& task_manager, if (_template_tree_node == NULL) break; + // The %get command + if (_value_committed == false) { + base_cmd = _template_tree_node->const_command("%get"); + if (base_cmd) { + debug_msg("found commands: %s. Adding it to sync map\n", cmd->str().c_str()); + MasterConfigTreeNode* module_root = dynamic_cast(this->module_root_node()); + XLOG_ASSERT(module_root); + + module_root->add_sync_cmd(this, reinterpret_cast(base_cmd)); + } + } + // The %activate command if (needs_activate || (_existence_committed == false)) { base_cmd = _template_tree_node->const_command("%activate"); @@ -633,6 +672,14 @@ MasterConfigTreeNode::commit_changes(TaskManager& task_manager, return false; } } + + /** + * Sync CLI DB, with module parameters + */ + bool result = this->sync(task_manager); + + if (!result) + return false; } } @@ -715,6 +762,7 @@ MasterConfigTreeNode::finalize_commit() XLOG_ASSERT(_actions_pending == 0); XLOG_ASSERT(_actions_succeeded); + XLOG_ASSERT(_sync_cmds.empty()); _existence_committed = true; _value_committed = true; _deleted = false; @@ -738,4 +786,50 @@ MasterConfigTreeNode::finalize_commit() } } +void +MasterConfigTreeNode::increment_actions_pending(const int increment = 1) +{ + XLOG_ASSERT(increment >= 0); + _actions_pending += increment; +} + + +void +MasterConfigTreeNode::add_sync_cmd(MasterConfigTreeNode* node, const Command* cmd) +{ + /** + * Synchronization should be done ONLY from module root node + */ + XLOG_ASSERT(this == module_root_node()); + + if (_sync_cmds.find(this) != _sync_cmds.end()) + XLOG_UNREACHABLE(); + + _sync_cmds[node] = cmd; +} + +bool +MasterConfigTreeNode::sync(TaskManager& task_manager) +{ + XLOG_ASSERT(this == module_root_node()); + map::iterator iter; + + for (iter = _sync_cmds.begin(); iter != _sync_cmds.end(); ++iter) { + int ret = iter->second->execute(*(iter->first), task_manager); + if (ret < 0) { + string error_msg; + error_msg = c_format("Parameter error for \"%s\"\n", + iter->first->path().c_str()); + error_msg += "Correct this error and try again.\n"; + XLOG_WARNING("%s\n", error_msg.c_str()); + _sync_cmds.clear(); + return false; + } + iter->first->increment_actions_pending(ret); + } + + _sync_cmds.clear(); + return true; +} + diff --git a/xorp/rtrmgr/master_conf_tree_node.hh b/xorp/rtrmgr/master_conf_tree_node.hh index 0d37dc3..5c2bfad 100644 --- a/xorp/rtrmgr/master_conf_tree_node.hh +++ b/xorp/rtrmgr/master_conf_tree_node.hh @@ -58,6 +58,9 @@ public: void find_active_modules(set& active_modules) const; void find_all_modules(set& all_modules) const; + void add_sync_cmd(MasterConfigTreeNode* node, const Command* cmd); + bool sync(TaskManager& task_manager); + void initialize_commit(); bool children_changed(); bool commit_changes(TaskManager& task_manager, bool do_commit, @@ -66,6 +69,8 @@ public: bool check_commit_status(string& error_msg) const; void finalize_commit(); + void increment_actions_pending(const int increment); + protected: @@ -74,6 +79,11 @@ protected: bool _actions_succeeded; // Did any action fail during the commit? const Command* _cmd_that_failed; + map _sync_cmds; //In this map we store MasterConfigTreeNodes + //that have been changed, and that have %get + //functions which we use for synchronization. + //This map should have elements only for module root node + private: }; -- 1.7.5.4 From noreply at github.com Tue Mar 20 10:21:03 2012 From: noreply at github.com (GitHub) Date: Tue, 20 Mar 2012 10:21:03 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 82e2cf: xorprtm: bsdroute.h whitespace fixes. Message-ID: <4f68bc7fef4e4_1a6f11edaec3598f@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 82e2cf9c1eb2b88c0aa6a609bd7cf80cb1202ddd https://github.com/greearb/xorp.ct/commit/82e2cf9c1eb2b88c0aa6a609bd7cf80cb1202ddd Author: Ben Greear Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/contrib/xorprtm/xorprtm/bsdroute.h Log Message: ----------- xorprtm: bsdroute.h whitespace fixes. Signed-off-by: Ben Greear Commit: 86aaeb1c94d17c4763eb554fb2e2eacd6dc53328 https://github.com/greearb/xorp.ct/commit/86aaeb1c94d17c4763eb554fb2e2eacd6dc53328 Author: Ben Greear Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/contrib/xorprtm/xorprtm/defs.h M xorp/contrib/xorprtm/xorprtm/list.h M xorp/contrib/xorprtm/xorprtm/loadprotocol.c Log Message: ----------- xorprtm: More whitespace fixes. Signed-off-by: Ben Greear Commit: 2299da93855413534eaf30cb8f9bbc22cbdfd2c0 https://github.com/greearb/xorp.ct/commit/2299da93855413534eaf30cb8f9bbc22cbdfd2c0 Author: Ben Greear Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/contrib/xorprtm/xorprtm/mibmgr.c M xorp/contrib/xorprtm/xorprtm/mibmgr.h M xorp/contrib/xorprtm/xorprtm/pchsample.h M xorp/contrib/xorprtm/xorprtm/print_rtmsg.c Log Message: ----------- xorprtm: Whitespace fixes. Commit: d5cee044894aa6e91453410f86444f733271907d https://github.com/greearb/xorp.ct/commit/d5cee044894aa6e91453410f86444f733271907d Author: Ben Greear Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/contrib/xorprtm/xorprtm/rmapi.c M xorp/contrib/xorprtm/xorprtm/rmapi.h M xorp/contrib/xorprtm/xorprtm/sync.c M xorp/contrib/xorprtm/xorprtm/sync.h M xorp/contrib/xorprtm/xorprtm/test_monitor.c M xorp/contrib/xorprtm/xorprtm/test_routeadd.c M xorp/contrib/xorprtm/xorprtm/test_routeadddelete.c M xorp/contrib/xorprtm/xorprtm/test_routeaddwait.c M xorp/contrib/xorprtm/xorprtm/utils.h Log Message: ----------- xorprtm: More whitespace fixes. Commit: e232c069b72dc64838deacd2a7707646d926f84a https://github.com/greearb/xorp.ct/commit/e232c069b72dc64838deacd2a7707646d926f84a Author: Ben Greear Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/contrib/xorprtm/xorprtm/utils.c M xorp/contrib/xorprtm/xorprtm/xorprtm.c M xorp/contrib/xorprtm/xorprtm/xorprtm.h M xorp/contrib/xorprtm/xorprtm/xorprtm_internal.h Log Message: ----------- xorprtm: Finish up white-space fixes. I'm sure more remains..but this gets the bulk of it fixed in the xorp/contrib/xorprtm directory. Signed-off-by: Ben Greear Compare: https://github.com/greearb/xorp.ct/compare/d4b1ef1...e232c06 From greearb at candelatech.com Tue Mar 20 10:30:30 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 20 Mar 2012 10:30:30 -0700 Subject: [Xorp-hackers] [PATCH 0/8] Enable sync of Xorp and kernel In-Reply-To: <1332262967-28742-1-git-send-email-igorm@etf.rs> References: <1332262967-28742-1-git-send-email-igorm@etf.rs> Message-ID: <4F68BEB6.3010105@candelatech.com> On 03/20/2012 10:02 AM, igorm at etf.rs wrote: > From: Igor Maravic > > Hi, > In this patch series I fixed returning of variable values and enabled sync of > Xorp and kernel. The patches look fine at first glance. Just out of curiosity, can you describe in a bit more detail how you are using these features? Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Tue Mar 20 10:31:19 2012 From: noreply at github.com (GitHub) Date: Tue, 20 Mar 2012 10:31:19 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 5a6506: xorp: rtrmgr: Insert missing XrlAtoms for sending ... Message-ID: <4f68bee71138c_6e691b47ae8166730@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 5a65069284ccb8a0a9a6a24adf00e31356261247 https://github.com/greearb/xorp.ct/commit/5a65069284ccb8a0a9a6a24adf00e31356261247 Author: Igor Maravic Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/rtrmgr/xorp_client.cc Log Message: ----------- xorp: rtrmgr: Insert missing XrlAtoms for sending fake args Added missing XrlAtoms for sending fake args. Signed-off-by: Igor Maravic Commit: 6e77828d2cf8cbcfa335db907784d34a5ca653aa https://github.com/greearb/xorp.ct/commit/6e77828d2cf8cbcfa335db907784d34a5ca653aa Author: Igor Maravic Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/libxipc/xrl_atom.cc M xorp/libxipc/xrl_atom.hh M xorp/rtrmgr/conf_tree_node.cc M xorp/rtrmgr/conf_tree_node.hh M xorp/rtrmgr/template_commands.cc M xorp/rtrmgr/xorp_client.cc Log Message: ----------- xorp: rtrmgr: Fix using of return varibles in xrl Without this patch, when we read and write from/to same xrl variable, value that should be committed to variable is overwritten with fake value. For example: ... parent @: uint { %create: xrl "$(prot.targetname)/prot/0.1/create?node:u32=$(@)"; %activate: xrl "$(prot.targetname)/prot/0.1/activate?node:u32=$(@)->child_ret:u32=$(@.child)"; %update: xrl "$(prot.targetname)/prot/0.1/update?node:u32=$(@)->child_ret:u32=$(@.child)"; child { %set: xrl "$(prot.targetname)/prot/0.1/set?node:u32=$(parent.@)&child:u32=$(@)"; } } ... In this case in function set we would get bogus value for variable child, because we are writing to it from update functions. This patch fixes that. Case when we are calling %create + %set + %activate is working without this patch. Signed-off-by: Igor Maravic Commit: 2466c8a1d1272dc0f23e92c2e03adde5d2546945 https://github.com/greearb/xorp.ct/commit/2466c8a1d1272dc0f23e92c2e03adde5d2546945 Author: Igor Maravic Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/rtrmgr/conf_tree_node.cc Log Message: ----------- xorp: rtrmgr: When adding child node, remove named variable with same name When adding child node, remove named variable with same name. If we wouldn't do that, we couldn't set value for child node, in function ConfigTreeNode::set_variable(), because we would always find named variable first. Signed-off-by: Igor Maravic Commit: 38087a8c4fc23d14a0eff13d03d434396dc85aa9 https://github.com/greearb/xorp.ct/commit/38087a8c4fc23d14a0eff13d03d434396dc85aa9 Author: Igor Maravic Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/fea/data_plane/ifconfig/ifconfig_set.cc M xorp/rtrmgr/cli.cc M xorp/rtrmgr/master_conf_tree_node.cc M xorp/rtrmgr/master_conf_tree_node.hh M xorp/rtrmgr/module_command.cc Log Message: ----------- trivial: automated ws fixes Signed-off-by: Igor Maravic Commit: edbfa3fd26949cc0f1b40fc68bf627bf8e1a215d https://github.com/greearb/xorp.ct/commit/edbfa3fd26949cc0f1b40fc68bf627bf8e1a215d Author: Igor Maravic Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/rtrmgr/cli.cc M xorp/rtrmgr/conf_tree_node.cc M xorp/rtrmgr/conf_tree_node.hh M xorp/rtrmgr/master_conf_tree_node.cc M xorp/rtrmgr/master_conf_tree_node.hh Log Message: ----------- xorp: rtrmgr: Enable usage of %get functions %get functions are very important, so our CLI DB would be synchronized with kernel DB. So, in this patch I am looking for existing %get functions of affected modules. They are stashed in map for latter calling. After we finish all changes in our module, that means after end_commit function is called, all stashed %get functions are called. Signed-off-by: Igor Maravic Commit: d8fbd89c04daba50d9673f4425da9fec9ec87c20 https://github.com/greearb/xorp.ct/commit/d8fbd89c04daba50d9673f4425da9fec9ec87c20 Author: Igor Maravic Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/etc/templates/interfaces.tp Log Message: ----------- xorp:etc:templates: add missing returning args to %get functions Signed-off-by: Igor Maravic Commit: c266ad467a31d289a2770a1b97f53d66a984a935 https://github.com/greearb/xorp.ct/commit/c266ad467a31d289a2770a1b97f53d66a984a935 Author: Igor Maravic Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/etc/templates/interfaces.tp Log Message: ----------- xorp: etc: templates: Don't read vif parameters one by one Delete %get functions for vif address parameters and put single %get function in address node that handle all parameters. All parameters that should be read from system are false by default. They are synchronized as soon as vif address is created. If parent if of created vif doesn't exist on system, those parameters aren't important. Signed-off-by: Igor Maravic Commit: 24373f852352e864d28490cfb5f0d55b86537ac6 https://github.com/greearb/xorp.ct/commit/24373f852352e864d28490cfb5f0d55b86537ac6 Author: Igor Maravic Date: 2012-03-20 (Tue, 20 Mar 2012) Changed paths: M xorp/fea/data_plane/ifconfig/ifconfig_set.cc Log Message: ----------- xorp: fea: data_plane: ifconfig: Check if we can set destination(broadcast) address for vif If our vif on system isn't broadcast-capable(point-to-point) link we can't set appropriate broadcast(destination) address. Commit will fail in that case. Signed-off-by: Igor Maravic Compare: https://github.com/greearb/xorp.ct/compare/e232c06...24373f8 From igorm at etf.rs Wed Mar 21 02:17:02 2012 From: igorm at etf.rs (=?ISO-8859-2?Q?Igor_Maravi=E6?=) Date: Wed, 21 Mar 2012 10:17:02 +0100 Subject: [Xorp-hackers] [PATCH 0/8] Enable sync of Xorp and kernel In-Reply-To: <4F68BEB6.3010105@candelatech.com> References: <1332262967-28742-1-git-send-email-igorm@etf.rs> <4F68BEB6.3010105@candelatech.com> Message-ID: Well, it's quite simple really :) We're writing new protocols for XORP (RSVP-TE and MPLS for now). We need XORP to be operational as much as possible so I'm fixing all XORP problems that I find along the way :) It bothered me that %get functions aren't called and I fixed that. BR Igor ????? 20. ???? 2012. 18.30, Ben Greear ?? ???????/??: > On 03/20/2012 10:02 AM, igorm at etf.rs wrote: >> >> From: Igor Maravic >> >> Hi, >> In this patch series I fixed returning of variable values and enabled sync >> of >> Xorp and kernel. > > > The patches look fine at first glance. ?Just out of curiosity, can > you describe in a bit more detail how you are using these > features? > > Thanks, > Ben > > -- > Ben Greear > Candela Technologies Inc ?http://www.candelatech.com > From vvm at tut.by Wed Mar 21 05:37:11 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 21 Mar 2012 15:37:11 +0300 Subject: [Xorp-hackers] [PATCH] use RRAS only if environment variable XORP_USE_RRAS is set References: <2B1AD82EE8FC4A26B96C524796A8B726@local.st.by><4F678193.9070006@candelatech.com> Message-ID: <70F3084EEB60432090F93A0A12E4598B@local.st.by> Hi! VVM>>> use RRAS only if environment variable XORP_USE_RRAS is set VVM>>> I.e. not-developers can be work with XORP on Windows comps with RRAS Ben Greear>> Please update the wiki to document this new environment variable: Ben Greear>> http://xorp.run.montefiore.ulg.ac.be/latex2wiki/user_manual/environment_variables Done: ^ XORP_USE_RRAS | Specific for Windows. Set only, if You planning use XORP feature "xorprtm dll" / "RTMv2" on computer with RRAS and installed and configured "xorprtm4.dll" and( or) "xorprtm6.dll". See more info in source code directory "xorp/contrib/xorprtm". | Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ From vvm at tut.by Wed Mar 21 06:03:15 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 21 Mar 2012 16:03:15 +0300 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); References: <78B89B0CFAA341C9A69049ED80AD0985@local.st.by> <4F68ABBA.9040607@candelatech.com> Message-ID: <1007791AB328425481E145F4CA026A9B@local.st.by> -------------- next part -------------- A non-text attachment was scrubbed... Name: VarC-0002-FEA-fibconfig_entry_set_rtmv2.cc-delete_entry-XLOG_W.patch Type: application/octet-stream Size: 1744 bytes Desc: not available Url : http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120321/be18ed4e/attachment.obj From greearb at candelatech.com Wed Mar 21 08:07:03 2012 From: greearb at candelatech.com (Ben Greear) Date: Wed, 21 Mar 2012 08:07:03 -0700 Subject: [Xorp-hackers] [PATCH 0/8] Enable sync of Xorp and kernel In-Reply-To: References: <1332262967-28742-1-git-send-email-igorm@etf.rs> <4F68BEB6.3010105@candelatech.com> Message-ID: <4F69EE97.6010605@candelatech.com> On 03/21/2012 02:17 AM, Igor Maravi? wrote: > Well, it's quite simple really :) > We're writing new protocols for XORP (RSVP-TE and MPLS for now). > We need XORP to be operational as much as possible so I'm fixing all > XORP problems that I find along the way :) > It bothered me that %get functions aren't called and I fixed that. Ok, I appreciate the effort! When you get the new protocols somewhat functional, please send patches for those as well! Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From vvm at tut.by Wed Mar 21 09:04:38 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 21 Mar 2012 19:04:38 +0300 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); Message-ID: <4DD2D77E9B324DB1A79D332E79792648@local.st.by> -------------- next part -------------- A non-text attachment was scrubbed... Name: Var_D_0002-FEA-fibconfig_entry_set_rtmv2.cc-delete_entry-XLOG_W.patch Type: application/octet-stream Size: 1329 bytes Desc: not available Url : http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120321/eb48d0aa/attachment.obj From greearb at candelatech.com Wed Mar 21 09:14:59 2012 From: greearb at candelatech.com (Ben Greear) Date: Wed, 21 Mar 2012 09:14:59 -0700 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); In-Reply-To: <4DD2D77E9B324DB1A79D332E79792648@local.st.by> References: <4DD2D77E9B324DB1A79D332E79792648@local.st.by> Message-ID: <4F69FE83.4040103@candelatech.com> It still did not apply with 'git am'. I had to edit it to remove the character in front of 'From' at the beginning of the patch. I also fixed up the title and comments. See the attached patch as an example of what I consider good title and comment section for a patch. The fixed-up patch has been applied and will be pushed shortly. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com -------------- next part -------------- A non-text attachment was scrubbed... Name: xorp-fib.patch Type: text/x-patch Size: 1382 bytes Desc: not available Url : http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120321/0461e5b5/attachment.bin From greearb at candelatech.com Wed Mar 21 09:18:35 2012 From: greearb at candelatech.com (Ben Greear) Date: Wed, 21 Mar 2012 09:18:35 -0700 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); In-Reply-To: <4F69FE83.4040103@candelatech.com> References: <4DD2D77E9B324DB1A79D332E79792648@local.st.by> <4F69FE83.4040103@candelatech.com> Message-ID: <4F69FF5B.5040609@candelatech.com> On 03/21/2012 09:14 AM, Ben Greear wrote: > > It still did not apply with 'git am'. I had to edit it to remove the > character in front of 'From' at the beginning of the patch. > > I also fixed up the title and comments. > > See the attached patch as an example of what I consider good > title and comment section for a patch. > > The fixed-up patch has been applied and will be pushed shortly. Well fun..looks like my email client (firefox) screws up the attachment as well, by prepending a > in front of 'From'. Please see if you can get 'git send-email' working..that will solve a lot of issues. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Wed Mar 21 09:20:39 2012 From: noreply at github.com (GitHub) Date: Wed, 21 Mar 2012 09:20:39 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 1ac240: FEA/rtmv2: Fix XLOG_ASSERT if vifp is not found. Message-ID: <4f69ffd7e3c8_3c603fb07c3132f83794f@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 1ac240caefa877932eaebbad5a2f7b157b0bc92d https://github.com/greearb/xorp.ct/commit/1ac240caefa877932eaebbad5a2f7b157b0bc92d Author: Victor Miasnikov Date: 2012-03-21 (Wed, 21 Mar 2012) Changed paths: M xorp/fea/data_plane/fibconfig/fibconfig_entry_set_rtmv2.cc Log Message: ----------- FEA/rtmv2: Fix XLOG_ASSERT if vifp is not found. There is no need to assert if we try to remove something that is already gone. Signed-off-by: Victor Miasnikov From vvm at tut.by Wed Mar 21 09:35:00 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 21 Mar 2012 19:35:00 +0300 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); References: <4DD2D77E9B324DB1A79D332E79792648@local.st.by> <4F69FE83.4040103@candelatech.com> Message-ID: <15F5505BE04F4A4496722FC55FA0D960@local.st.by> Hi! > The fixed-up patch has been applied and will be pushed shortly. > I also fixed up the title and comments. Thank You! > Thanks, No problem :-) > It [Var_D] still did not apply with 'git am'. - {-- XLOG_ASSERT ^^^ may be "--" in Subj ( see "diff of patches" later) go to strange work "git am" { > I had to edit it to remove the character in front of 'From' at the beginning of the patch. see "diff of patches" later : "character in front of 'From'" simply not exit ;-0 == Well fun..looks like my email client (firefox) screws up the attachment as well, by prepending a > in front of 'From'. == Ok -- not only my e-mail client work strange :-) } > See the attached patch as an example of what I consider good > title and comment section for a patch. Ok "diff of patches": == --- Var_D_0002-FEA-fibconfig_entry_set_rtmv2.cc-delete_entry-XLOG_W.patch Wed Mar 21 18:56:03 2012 +++ xorp-fib.patch Wed Mar 21 19:19:30 2012 @@ -1,8 +1,10 @@ From fad792992b2edc3896808250835445d7a124160a Mon Sep 17 00:00:00 2001 From: Victor Miasnikov Date: Wed, 21 Mar 2012 18:53:41 +0300 -Subject: [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING - {-- XLOG_ASSERT +Subject: [PATCH] FEA/rtmv2: Fix XLOG_ASSERT if vifp is not found. + +There is no need to assert if we try to remove something that +is already gone. Signed-off-by: Victor Miasnikov --- == Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ ----- Original Message ----- From: "Ben Greear" To: "Victor Miasnikov" Cc: Sent: Wednesday, March 21, 2012 7:14 PM Subject: Re: [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); > > It still did not apply with 'git am'. I had to edit it to remove the > character in front of 'From' at the beginning of the patch. > > I also fixed up the title and comments. > > See the attached patch as an example of what I consider good > title and comment section for a patch. > > The fixed-up patch has been applied and will be pushed shortly. > > Thanks, > Ben > > -- > Ben Greear > Candela Technologies Inc http://www.candelatech.com From vvm at tut.by Wed Mar 21 09:47:39 2012 From: vvm at tut.by (Victor Miasnikov) Date: Wed, 21 Mar 2012 19:47:39 +0300 Subject: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); References: <4DD2D77E9B324DB1A79D332E79792648@local.st.by> <4F69FE83.4040103@candelatech.com> <4F69FF5B.5040609@candelatech.com> Message-ID: <04A7378795D24D03A6BAE8FD1683C3B2@local.st.by> Hi! > Please see if you can get 'git send-email' working.. It working But if To: xorp-hackers at xorp.org e-mail blocked by anti-spam ( or vise versa ) on MX of xorp.org : == Error: Received invalid response : 504 5.5.2 : Helo command rejected: need fully-qualified hostname == > that will solve a lot of issues. Yes . . . Best regards, Victor Miasnikov Blog: http://vvm.blog.tut.by/ ----- Original Message ----- From: "Ben Greear" To: "Victor Miasnikov" Cc: Sent: Wednesday, March 21, 2012 7:18 PM Subject: Re: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); > On 03/21/2012 09:14 AM, Ben Greear wrote: . . . > Please see if you can get 'git send-email' working..that will solve > a lot of issues. > > Thanks, Ben From greearb at candelatech.com Wed Mar 21 09:53:24 2012 From: greearb at candelatech.com (Ben Greear) Date: Wed, 21 Mar 2012 09:53:24 -0700 Subject: [Xorp-hackers] xorp lists and git send-email. In-Reply-To: <04A7378795D24D03A6BAE8FD1683C3B2@local.st.by> References: <4DD2D77E9B324DB1A79D332E79792648@local.st.by> <4F69FE83.4040103@candelatech.com> <4F69FF5B.5040609@candelatech.com> <04A7378795D24D03A6BAE8FD1683C3B2@local.st.by> Message-ID: <4F6A0784.1050007@candelatech.com> On 03/21/2012 09:47 AM, Victor Miasnikov wrote: > > Hi! > > >> Please see if you can get 'git send-email' working.. > > It working > > But if To: > xorp-hackers at xorp.org > > e-mail blocked by anti-spam ( or vise versa ) on MX of xorp.org : > == > Error: Received invalid response : 504 5.5.2 : Helo command rejected: need fully-qualified hostname > == For my own email-ing of patches (to linux mailing lists..not xorp), I added some git configuration to my .git/config file. I'm not sure if any of this would help you or not, and at the least you'd have to change it for your own email configuration: [sendemail] from = greearb at candelatech.com to = netdev at vger.kernel.org smtpencryption = ssl smtpserver = mail.candelatech.com chainreplyto = false Please send me the full bounce message and maybe I can figure out what is weird about your email. Also, please try sending one directly to me with 'git send-email'. Thanks, Ben > > >> that will solve a lot of issues. > > Yes . . . > > Best regards, Victor Miasnikov > Blog: http://vvm.blog.tut.by/ > > > ----- Original Message ----- From: "Ben Greear" > To: "Victor Miasnikov" > Cc: > Sent: Wednesday, March 21, 2012 7:18 PM > Subject: Re: [Xorp-hackers] [PATCH] FEA fibconfig_entry_set_rtmv2.cc delete_entry XLOG_WARNING {-- XLOG_ASSERT(vifp != NULL); > > >> On 03/21/2012 09:14 AM, Ben Greear wrote: > > . . . > >> Please see if you can get 'git send-email' working..that will solve >> a lot of issues. >> >> Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From vvm at tut.by Thu Mar 22 09:19:00 2012 From: vvm at tut.by (Victor Miasnikov) Date: Thu, 22 MAR 12 19:19:0 +0300 Subject: [Xorp-hackers] [PATCH] xorprtm: xorprtm6\Jamfile whitespace fixes Message-ID: >From 7dd5e205671318fc1afa46c9549ae286b53937a2 Mon Sep 17 00:00:00 2001 From: Victor Miasnikov Date: Thu, 22 Mar 2012 19:15:51 +0300 Subject: [PATCH] xorprtm: xorprtm6\Jamfile whitespace fixes Signed-off-by: Victor Miasnikov --- xorp/contrib/xorprtm/xorprtm6/Jamfile | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xorp/contrib/xorprtm/xorprtm6/Jamfile b/xorp/contrib/xorprtm/xorprtm6/Jamfile index 111f5d1..e03161b 100644 --- a/xorp/contrib/xorprtm/xorprtm6/Jamfile +++ b/xorp/contrib/xorprtm/xorprtm6/Jamfile @@ -9,13 +9,13 @@ SubDir TOP ; #QueueUserWorkItem() CCFLAGS = - #-DIPV6_DLL - -DINET6 -D__KAME__ - -DTEST - -DNT -DMPR50 - -DDEBUG=999 - -D_CRT_SECURE_NO_DEPRECATE - /Gz ; + #-DIPV6_DLL + -DINET6 -D__KAME__ + -DTEST + -DNT -DMPR50 + -DDEBUG=999 + -D_CRT_SECURE_NO_DEPRECATE + /Gz ; LINKLIBS = rtm.lib rtutils.lib mprapi.lib ws2_32.lib advapi32.lib iphlpapi.lib ; # -- 1.7.9.msysgit.0 From ddavidson72 at gmx.com Wed Mar 21 15:44:21 2012 From: ddavidson72 at gmx.com (David Davidson) Date: Wed, 21 Mar 2012 18:44:21 -0400 Subject: [Xorp-hackers] Unable to compile on Gentoo stage3 x86 virtual machine Message-ID: <20120321224421.4300@gmx.com> Hi, Thank you so much for your work and dedication to the XORP project! I am so pleased with this work and I wanted to say that I think it's the best routing software one can get in the free world, and it rivals commercial routing in a big way, hands-down. My hat is off to those developers and maintainers that are supporting this project and again, many kind thanks for working on this exciting project. I am hoping that somebody will be able to give me some help or point me in the right direction to get a problem fixed that I am seeing. I am trying to get XORP v.1.8.5 compiled on a recent Gentoo GNU/Linux virtual machine instance but I am unable to get it compiled. I am running the following command from the root of the source release: scons prefix=/usr sysconfdir=/etc/xorp localstatedir=/var/lib/xorp I am getting the following error message and then compilation terminates: ################################################ g++ -o obj/i686-pc-linux-gnu/policy/backend/lex.yy_policy_backend_parser.os -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -fPIC -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i686-pc-linux-gnu -I. -I. policy/backend/lex.yy_policy_backend_parser.cc cc1plus: warnings being treated as errors backend.l: In function 'int yy_policy_backend_parserlex()': backend.l:96:5: error: ignoring return value of 'size_t fwrite(const void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result scons: *** [obj/i686-pc-linux-gnu/policy/backend/lex.yy_policy_backend_parser.os] Error 1 scons: building terminated because of errors. ################################################ Please notice that this seems to be a warning and because the compiler is set to treat warnings as errors, the compile fails. If I manually hack the SConstruct and remove the -Werror flags manually, then the compilation succeeds. I have done some extensive looking for resolving the "fwrite" warnings / errors but I have not been able to come up with a solution and I am hoping somebody could help point me in the right direction or maybe give me some kind of patch that I could keep for myself that would allow this to succeed. I have also tried this with the GIT clone and I end up with the same result. So here are a few more notes: 1. This is Gentoo GNU/Linux installed from the x86 stage3 tarball from 3/13/2012. The file is: stage3-i686-20120313.tar.bz2 2. This is a deblobed kernel! I have set the "deblob" use flag which applies the deblob scripting against the kernel tree. This removes non-free firmware from the kernel tree. 3. This is kernel version "kernel-3.2.1-gentoo-r2-libre" and where libre is appended because of the deblob. 4. The uname is as follows: Linux XORP9000 3.2.1-gentoo-r2-libre #1 SMP Tue Mar 20 23:59:55 Local time zone must be set--see zic i686 Pentium(R) Dual-Core CPU E6700 @ 3.20GHz GenuineIntel GNU/Linux 5. The GCC version is: gcc (Gentoo 4.5.3-r2 p1.1, pie-0.4.7) 4.5.3 6. Last but not least, I should mention that this is an x86 fully virtualized virtual machine running under Xen hvmloader emulation (this is NOT paravirtualized). When I compiled this kernel, I also receive a warning concerning the value of "fwrite" and the attribute "warn_unused_result" but the kernel compile succeeds without any problems because this is only treated as a warning. The output of the kernel warning is as follows; this is seen after running "make menuconfig" on this source tree: ################################################ HOSTCC scripts/kconfig/lxdialog/menubox.o HOSTCC scripts/kconfig/lxdialog/textbox.o HOSTCC scripts/kconfig/lxdialog/util.o HOSTCC scripts/kconfig/lxdialog/yesno.o HOSTCC scripts/kconfig/mconf.o HOSTCC scripts/kconfig/zconf.tab.o scripts/kconfig/zconf.tab.c: In function 'header_print_comment': scripts/kconfig/confdata.c:540:10: warning: ignoring return value of 'fwrite', declared with attribute warn_unused_result scripts/kconfig/zconf.tab.c: In function 'kconfig_print_comment': scripts/kconfig/confdata.c:467:10: warning: ignoring return value of 'fwrite', declared with attribute warn_unused_result HOSTLD scripts/kconfig/mconf scripts/kconfig/mconf Kconfig # # configuration written to .config # ################################################ Here again, despite the warning, the kernel compile succeeds and this kernel seems to work great. Even if I decide not to use the deblobing, I still see this fwrite warning, but again, the kernel compile succeeds without any problems. Some googling on this turns up that this might be a compiler flag problem, but others turn up patches for various different softwares. I am not certain which way to go about fixing it, and I am certainly not a developer, nor am I a compiler expert, so I am hoping that somebody with a little more expertise can point me in the right direction and help me to know what I should do to go about getting this to succeed without hacking up the SConstruct and disabling the warnings being treated as errors. I worry that there might be something else that I would be missing by not stopping on perhaps other warnings. Other websites suggest that this is a dependencies problem for other different softwares, but I think that I have everything I need to get XORP running. In the end, I plan on using this image on a GNS3 QEMU guest for networking labs. I know that there might already be images out there that will do this, but I want my own home-grown one for me, and then I want to run it under Gentoo GNU/Linux. Using the GIT tree, [git clone git://github.com/greearb/xorp.ct.git], I still get the same error message. I have attached the build log from the command: scons prefix=/usr sysconfdir=/etc/xorp localstatedir=/var/lib/xorp 2>&1 | tee build.log Please let me know your thoughts on this. I really appreciate your help and thoughts about this. Thank you again for working on and developing XORP! I really love this project and wanted to say thank you again for this exciting work. This is really a breath of fresh air, a wonderful blessing and a much better alternative and choice instead of using commercial routing platforms. I have been using XORP for a few years and I am really pleased with it and want to thank you again for your work and commitment with this software. Many kind thanks again! Best Regards, David -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120321/523094f8/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: gentoo_compile_problem_build.log Type: application/octet-stream Size: 240496 bytes Desc: Attachment: gentoo_compile_problem_build.log Url : http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120321/523094f8/attachment-0001.obj From vvm at tut.by Thu Mar 22 09:47:48 2012 From: vvm at tut.by (Victor Miasnikov) Date: Thu, 22 MAR 12 19:47:48 +0300 Subject: [Xorp-hackers] [PATCH] xorprtm: xorprtm6\Jamfile "#define IPV6_DLL" Message-ID: >From b655fc6d670cf4907c4e0bbec433cb0d0014ba1b Mon Sep 17 00:00:00 2001 From: Victor Miasnikov Date: Thu, 22 Mar 2012 19:46:23 +0300 Subject: [PATCH] xorprtm: xorprtm6\Jamfile "#define IPV6_DLL" Signed-off-by: Victor Miasnikov --- xorp/contrib/xorprtm/xorprtm6/Jamfile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/xorp/contrib/xorprtm/xorprtm6/Jamfile b/xorp/contrib/xorprtm/xorprtm6/Jamfile index e03161b..7efd2f0 100644 --- a/xorp/contrib/xorprtm/xorprtm6/Jamfile +++ b/xorp/contrib/xorprtm/xorprtm6/Jamfile @@ -9,7 +9,7 @@ SubDir TOP ; #QueueUserWorkItem() CCFLAGS = - #-DIPV6_DLL + -DIPV6_DLL -DINET6 -D__KAME__ -DTEST -DNT -DMPR50 -- 1.7.9.msysgit.0 From greearb at candelatech.com Thu Mar 22 09:59:43 2012 From: greearb at candelatech.com (Ben Greear) Date: Thu, 22 Mar 2012 09:59:43 -0700 Subject: [Xorp-hackers] Unable to compile on Gentoo stage3 x86 virtual machine In-Reply-To: <20120321224421.4300@gmx.com> References: <20120321224421.4300@gmx.com> Message-ID: <4F6B5A7F.3070204@candelatech.com> On 03/21/2012 03:44 PM, David Davidson wrote: > Hi, > > Thank you so much for your work and dedication to the XORP project! I am so pleased with this work and I wanted to say that I think it's the best routing > software one can get in the free world, and it rivals commercial routing in a big way, hands-down. My hat is off to those developers and maintainers that are > supporting this project and again, many kind thanks for working on this exciting project. > > I am hoping that somebody will be able to give me some help or point me in the right direction to get a problem fixed that I am seeing. I am trying to get XORP > v.1.8.5 compiled on a recent Gentoo GNU/Linux virtual machine instance but I am unable to get it compiled. I am running the following command from the root of > the source release: > > > scons prefix=/usr sysconfdir=/etc/xorp localstatedir=/var/lib/xorp > > > I am getting the following error message and then compilation terminates: > > ################################################ > g++ -o obj/i686-pc-linux-gnu/policy/backend/lex.yy_policy_backend_parser.os -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align > -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -fPIC -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i686-pc-linux-gnu -I. -I. > policy/backend/lex.yy_policy_backend_parser.cc > cc1plus: warnings being treated as errors > backend.l: In function 'int yy_policy_backend_parserlex()': > backend.l:96:5: error: ignoring return value of 'size_t fwrite(const void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result > scons: *** [obj/i686-pc-linux-gnu/policy/backend/lex.yy_policy_backend_parser.os] Error 1 > scons: building terminated because of errors. > ################################################ We probably just need to find everywhere that calls fwrite and check it's return value. In the git tree, there is an option: scons disable_werror=true that should let it compile, but we should fix the root cause as well. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From noreply at github.com Thu Mar 22 13:21:03 2012 From: noreply at github.com (GitHub) Date: Thu, 22 Mar 2012 13:21:03 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] f2ad0c: xorprtm: xorprtm6\Jamfile whitespace fixes Message-ID: <4f6b89af5c20b_74863ff7695fdafc1034f0@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: f2ad0cb0d1642a0f5e1aee3b07584a9bff7b828e https://github.com/greearb/xorp.ct/commit/f2ad0cb0d1642a0f5e1aee3b07584a9bff7b828e Author: Victor Miasnikov Date: 2012-03-22 (Thu, 22 Mar 2012) Changed paths: M xorp/contrib/xorprtm/xorprtm6/Jamfile Log Message: ----------- xorprtm: xorprtm6\Jamfile whitespace fixes >From 7dd5e205671318fc1afa46c9549ae286b53937a2 Mon Sep 17 00:00:00 2001 From: Victor Miasnikov Date: Thu, 22 Mar 2012 19:15:51 +0300 Subject: [PATCH] xorprtm: xorprtm6\Jamfile whitespace fixes Signed-off-by: Victor Miasnikov Commit: dae20bf36c93e55c39f3f0c30f9973e32b1bdbcd https://github.com/greearb/xorp.ct/commit/dae20bf36c93e55c39f3f0c30f9973e32b1bdbcd Author: Victor Miasnikov Date: 2012-03-22 (Thu, 22 Mar 2012) Changed paths: M xorp/contrib/xorprtm/xorprtm6/Jamfile Log Message: ----------- xorprtm: xorprtm6\Jamfile "#define IPV6_DLL" Signed-off-by: Victor Miasnikov Compare: https://github.com/greearb/xorp.ct/compare/1ac240c...dae20bf From igorm at etf.rs Fri Mar 23 00:26:16 2012 From: igorm at etf.rs (=?ISO-8859-2?Q?Igor_Maravi=E6?=) Date: Fri, 23 Mar 2012 08:26:16 +0100 Subject: [Xorp-hackers] Unable to compile on Gentoo stage3 x86 virtual machine In-Reply-To: <4F6B5A7F.3070204@candelatech.com> References: <20120321224421.4300@gmx.com> <4F6B5A7F.3070204@candelatech.com> Message-ID: I think that the good solution would be to automatically generate lex and yacc files here as well. BR Igor ????? 22. ???? 2012. 17.59, Ben Greear ?? ???????/??: > On 03/21/2012 03:44 PM, David Davidson wrote: >> Hi, >> >> Thank you so much for your work and dedication to the XORP project! I am so pleased with this work and I wanted to say that I think it's the best routing >> software one can get in the free world, and it rivals commercial routing in a big way, hands-down. My hat is off to those developers and maintainers that are >> supporting this project and again, many kind thanks for working on this exciting project. >> >> I am hoping that somebody will be able to give me some help or point me in the right direction to get a problem fixed that I am seeing. I am trying to get XORP >> v.1.8.5 compiled on a recent Gentoo GNU/Linux virtual machine instance but I am unable to get it compiled. I am running the following command from the root of >> the source release: >> >> >> scons prefix=/usr sysconfdir=/etc/xorp localstatedir=/var/lib/xorp >> >> >> I am getting the following error message and then compilation terminates: >> >> ################################################ >> g++ -o obj/i686-pc-linux-gnu/policy/backend/lex.yy_policy_backend_parser.os -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align >> -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -fPIC -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i686-pc-linux-gnu -I. -I. >> policy/backend/lex.yy_policy_backend_parser.cc >> cc1plus: warnings being treated as errors >> backend.l: In function 'int yy_policy_backend_parserlex()': >> backend.l:96:5: error: ignoring return value of 'size_t fwrite(const void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result >> scons: *** [obj/i686-pc-linux-gnu/policy/backend/lex.yy_policy_backend_parser.os] Error 1 >> scons: building terminated because of errors. >> ################################################ > > We probably just need to find everywhere that calls fwrite and check it's > return value. > > In the git tree, there is an option: ?scons disable_werror=true > > that should let it compile, but we should fix the root cause as well. > > Thanks, > Ben > > -- > Ben Greear > Candela Technologies Inc ?http://www.candelatech.com > > _______________________________________________ > Xorp-hackers mailing list > Xorp-hackers at icir.org > http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers From igorm at etf.rs Fri Mar 23 09:03:39 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Fri, 23 Mar 2012 17:03:39 +0100 Subject: [Xorp-hackers] [PATCH 1/2] xorp: fea: data_plane: ifconfig: Check if we can set destination address for vif(IPv6) In-Reply-To: References: Message-ID: <1332518620-18507-1-git-send-email-igorm@etf.rs> From: Igor Maravic If our vif on system isn't point-to-point link we can't set appropriate destination address. Commit will fail in that case. Signed-off-by: Igor Maravic --- xorp/fea/data_plane/ifconfig/ifconfig_set.cc | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc index 046ab3e..75013da 100644 --- a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc +++ b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc @@ -706,6 +706,15 @@ IfConfigSet::push_vif_address(const IfTreeInterface* system_ifp, is_add = false; } + if (system_vifp != NULL) { + if (system_vifp->point_to_point() != config_addr.point_to_point()) { + error_msg = c_format("Can't set destination address for if: %s vif: %s" + "because it isn't point-to-point interface\n", + system_ifp->ifname().c_str(), system_vifp->vifname().c_str()); + goto done; + } + } + // // XXX: For whatever reason a prefix length of zero does not cut it, so // initialize prefix to 64. This is exactly what ifconfig(8) does. -- 1.7.5.4 From igorm at etf.rs Fri Mar 23 09:03:40 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Fri, 23 Mar 2012 17:03:40 +0100 Subject: [Xorp-hackers] [PATCH 2/2] xorp: fea: data_plane: ifconfig: Fix checking if interface can have broadcast(destination) address In-Reply-To: <1332518620-18507-1-git-send-email-igorm@etf.rs> References: <1332518620-18507-1-git-send-email-igorm@etf.rs> Message-ID: <1332518620-18507-2-git-send-email-igorm@etf.rs> From: Igor Maravic Signed-off-by: Igor Maravic --- xorp/fea/data_plane/ifconfig/ifconfig_set.cc | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc index 75013da..98fc505 100644 --- a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc +++ b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc @@ -596,14 +596,14 @@ IfConfigSet::push_vif_address(const IfTreeInterface* system_ifp, } if (system_vifp != NULL) { - if (system_vifp->point_to_point() != config_addr.point_to_point()) { - error_msg = c_format("Can't set destination address for if: %s vif: %s" + if (!system_vifp->point_to_point() && config_addr.point_to_point()) { + error_msg = c_format("Can't set destination address for if: %s vif: %s\n" "because it isn't point-to-point interface\n", system_ifp->ifname().c_str(), system_vifp->vifname().c_str()); goto done; } - if (system_vifp->broadcast() != config_addr.broadcast()) { - error_msg = c_format("Can't set broadcast address for if: %s vif: %s" + if (!system_vifp->broadcast() && config_addr.broadcast()) { + error_msg = c_format("Can't set broadcast address for if: %s vif: %s\n" "because it isn't broadcast capable\n", system_ifp->ifname().c_str(), system_vifp->vifname().c_str()); goto done; @@ -707,8 +707,8 @@ IfConfigSet::push_vif_address(const IfTreeInterface* system_ifp, } if (system_vifp != NULL) { - if (system_vifp->point_to_point() != config_addr.point_to_point()) { - error_msg = c_format("Can't set destination address for if: %s vif: %s" + if (!system_vifp->point_to_point() && config_addr.point_to_point()) { + error_msg = c_format("Can't set destination address for if: %s vif: %s\n" "because it isn't point-to-point interface\n", system_ifp->ifname().c_str(), system_vifp->vifname().c_str()); goto done; -- 1.7.5.4 From greearb at candelatech.com Fri Mar 23 09:19:04 2012 From: greearb at candelatech.com (Ben Greear) Date: Fri, 23 Mar 2012 09:19:04 -0700 Subject: [Xorp-hackers] [PATCH 1/2] xorp: fea: data_plane: ifconfig: Check if we can set destination address for vif(IPv6) In-Reply-To: <1332518620-18507-1-git-send-email-igorm@etf.rs> References: <1332518620-18507-1-git-send-email-igorm@etf.rs> Message-ID: <4F6CA278.60700@candelatech.com> On 03/23/2012 09:03 AM, igorm at etf.rs wrote: > From: Igor Maravic > > If our vif on system isn't point-to-point link > we can't set appropriate destination address. Commit will fail in that case. > > Signed-off-by: Igor Maravic > --- > xorp/fea/data_plane/ifconfig/ifconfig_set.cc | 9 +++++++++ > 1 files changed, 9 insertions(+), 0 deletions(-) > > diff --git a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc > index 046ab3e..75013da 100644 > --- a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc > +++ b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc > @@ -706,6 +706,15 @@ IfConfigSet::push_vif_address(const IfTreeInterface* system_ifp, > is_add = false; > } > > + if (system_vifp != NULL) { > + if (system_vifp->point_to_point() != config_addr.point_to_point()) { Should this check be something more like: if (config_addr.point_to_point() && !system_vifp->point_to_point()) { ? Looks like you changed this exact code in the next patch? Thanks, Ben > + error_msg = c_format("Can't set destination address for if: %s vif: %s" > + "because it isn't point-to-point interface\n", > + system_ifp->ifname().c_str(), system_vifp->vifname().c_str()); > + goto done; > + } > + } > + > // > // XXX: For whatever reason a prefix length of zero does not cut it, so > // initialize prefix to 64. This is exactly what ifconfig(8) does. -- Ben Greear Candela Technologies Inc http://www.candelatech.com From igorm at etf.rs Fri Mar 23 11:48:09 2012 From: igorm at etf.rs (=?ISO-8859-2?Q?Igor_Maravi=E6?=) Date: Fri, 23 Mar 2012 19:48:09 +0100 Subject: [Xorp-hackers] [PATCH 1/2] xorp: fea: data_plane: ifconfig: Check if we can set destination address for vif(IPv6) In-Reply-To: <4F6CA278.60700@candelatech.com> References: <1332518620-18507-1-git-send-email-igorm@etf.rs> <4F6CA278.60700@candelatech.com> Message-ID: It should, but I wanted to be in two different patches. I can squash them together, in Monday if you like. BR Igor ????? 23. ???? 2012. 17.19, Ben Greear ?? ???????/??: > On 03/23/2012 09:03 AM, igorm at etf.rs wrote: >> >> From: Igor Maravic >> >> If our vif on system isn't point-to-point link >> we can't set appropriate destination address. Commit will fail in that >> case. >> >> Signed-off-by: Igor Maravic >> --- >> ?xorp/fea/data_plane/ifconfig/ifconfig_set.cc | ? ?9 +++++++++ >> ?1 files changed, 9 insertions(+), 0 deletions(-) >> >> diff --git a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc >> b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc >> index 046ab3e..75013da 100644 >> --- a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc >> +++ b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc >> @@ -706,6 +706,15 @@ IfConfigSet::push_vif_address(const IfTreeInterface* >> ? ? ? system_ifp, >> ? ? ? ?is_add = false; >> ? ? ?} >> >> + ? ?if (system_vifp != NULL) { >> + ? ? ? if (system_vifp->point_to_point() != config_addr.point_to_point()) >> { > > > Should this check be something more like: > > if (config_addr.point_to_point() && !system_vifp->point_to_point()) { > > ? > > Looks like you changed this exact code in the next patch? > > Thanks, > Ben > >> + ? ? ? ? ? error_msg = c_format("Can't set destination address for if: %s >> vif: %s" >> + ? ? ? ? ? ? ? ? ? "because it isn't point-to-point interface\n", >> + ? ? ? ? ? ? ? ? ? system_ifp->ifname().c_str(), >> system_vifp->vifname().c_str()); >> + ? ? ? ? ? goto done; >> + ? ? ? } >> + ? ?} >> + >> ? ? ?// >> ? ? ?// XXX: For whatever reason a prefix length of zero does not cut it, >> so >> ? ? ?// initialize prefix to 64. This is exactly what ifconfig(8) does. > > > > -- > Ben Greear > Candela Technologies Inc ?http://www.candelatech.com > From greearb at candelatech.com Fri Mar 23 11:53:14 2012 From: greearb at candelatech.com (Ben Greear) Date: Fri, 23 Mar 2012 11:53:14 -0700 Subject: [Xorp-hackers] [PATCH 1/2] xorp: fea: data_plane: ifconfig: Check if we can set destination address for vif(IPv6) In-Reply-To: References: <1332518620-18507-1-git-send-email-igorm@etf.rs> <4F6CA278.60700@candelatech.com> Message-ID: <4F6CC69A.5050503@candelatech.com> On 03/23/2012 11:48 AM, Igor Maravi? wrote: > It should, but I wanted to be in two different patches. I can squash > them together, in Monday if you like. Ok, 2 patches is fine..but... With regard to the second patch, it effectively removes the warning check if system is point-to-point but config is not. Do we need to handle that error case as well? Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From igorm at etf.rs Sat Mar 24 00:27:15 2012 From: igorm at etf.rs (=?ISO-8859-2?Q?Igor_Maravi=E6?=) Date: Sat, 24 Mar 2012 08:27:15 +0100 Subject: [Xorp-hackers] [PATCH 1/2] xorp: fea: data_plane: ifconfig: Check if we can set destination address for vif(IPv6) In-Reply-To: <4F6CC69A.5050503@candelatech.com> References: <1332518620-18507-1-git-send-email-igorm@etf.rs> <4F6CA278.60700@candelatech.com> <4F6CC69A.5050503@candelatech.com> Message-ID: I think that we don't need to handle the other case. Problem that I experienced with my first patch was when I deleted address for some vif. After I deleted it, system still was broadcast, but config was not. Because of that it reported error. With my second patch I bypassed that case and in some consecutive function, config was set to be of the system_vifp->broadcast() value. I think that should be the case for point-to-point links, but I don't have necessary equipment to test that. BR Igor ????? 23. ???? 2012. 19.53, Ben Greear ?? ???????/??: > On 03/23/2012 11:48 AM, Igor Maravi? wrote: >> >> It should, but I wanted to be in two different patches. I can squash >> them together, in Monday if you like. > > > Ok, 2 patches is fine..but... > > With regard to the second patch, it effectively removes > the warning check if system is point-to-point but config > is not. ?Do we need to handle that error case as well? > > Thanks, > Ben > > > -- > Ben Greear > Candela Technologies Inc ?http://www.candelatech.com > From igorm at etf.rs Mon Mar 26 22:17:33 2012 From: igorm at etf.rs (=?ISO-8859-2?Q?Igor_Maravi=E6?=) Date: Tue, 27 Mar 2012 07:17:33 +0200 Subject: [Xorp-hackers] [PATCH 1/2] xorp: fea: data_plane: ifconfig: Check if we can set destination address for vif(IPv6) In-Reply-To: References: <1332518620-18507-1-git-send-email-igorm@etf.rs> <4F6CA278.60700@candelatech.com> <4F6CC69A.5050503@candelatech.com> Message-ID: Ben, do you want to resend this patches? Do they need to be modified in some way? BR Igor ????? 24. ???? 2012. 08.27, Igor Maravi? ?? ???????/??: > I think that we don't need to handle the other case. > Problem that I experienced with my first patch was when I deleted > address for some vif. After I deleted it, system still was broadcast, > but config was not. Because of that it reported error. > With my second patch I bypassed that case and in some consecutive > function, config was set to be of the system_vifp->broadcast() value. > I think that should be the case for point-to-point links, but I don't > have necessary equipment to test that. > BR > Igor > > ????? 23. ???? 2012. 19.53, Ben Greear ?? ???????/??: >> On 03/23/2012 11:48 AM, Igor Maravi? wrote: >>> >>> It should, but I wanted to be in two different patches. I can squash >>> them together, in Monday if you like. >> >> >> Ok, 2 patches is fine..but... >> >> With regard to the second patch, it effectively removes >> the warning check if system is point-to-point but config >> is not. ?Do we need to handle that error case as well? >> >> Thanks, >> Ben >> >> >> -- >> Ben Greear >> Candela Technologies Inc ?http://www.candelatech.com >> From greearb at candelatech.com Mon Mar 26 22:35:07 2012 From: greearb at candelatech.com (Ben Greear) Date: Mon, 26 Mar 2012 22:35:07 -0700 Subject: [Xorp-hackers] [PATCH 1/2] xorp: fea: data_plane: ifconfig: Check if we can set destination address for vif(IPv6) In-Reply-To: References: <1332518620-18507-1-git-send-email-igorm@etf.rs> <4F6CA278.60700@candelatech.com> <4F6CC69A.5050503@candelatech.com> Message-ID: <4F71518B.8020802@candelatech.com> On 03/26/2012 10:17 PM, Igor Maravi? wrote: > Ben, > do you want to resend this patches? Do they need to be modified in some way? I spent all day chasing a nasty kernel bug, and probably will do so much of tomorrow as well. Hopefully I can find time to review your code in details soon. I am not sure I'm going to apply these though..from your description it sounds like you may be hiding real bugs. Can you provide an exact set of xorpsh (I assume) commands & config file(s) to make this bug happen? Thanks, Ben > BR > Igor > > ????? 24. ???? 2012. 08.27, Igor Maravi? ?? ???????/??: >> I think that we don't need to handle the other case. >> Problem that I experienced with my first patch was when I deleted >> address for some vif. After I deleted it, system still was broadcast, >> but config was not. Because of that it reported error. >> With my second patch I bypassed that case and in some consecutive >> function, config was set to be of the system_vifp->broadcast() value. >> I think that should be the case for point-to-point links, but I don't >> have necessary equipment to test that. >> BR >> Igor >> >> ????? 23. ???? 2012. 19.53, Ben Greear ?? ???????/??: >>> On 03/23/2012 11:48 AM, Igor Maravi? wrote: >>>> >>>> It should, but I wanted to be in two different patches. I can squash >>>> them together, in Monday if you like. >>> >>> >>> Ok, 2 patches is fine..but... >>> >>> With regard to the second patch, it effectively removes >>> the warning check if system is point-to-point but config >>> is not. Do we need to handle that error case as well? >>> >>> Thanks, >>> Ben >>> >>> >>> -- >>> Ben Greear >>> Candela Technologies Inc http://www.candelatech.com >>> -- Ben Greear Candela Technologies Inc http://www.candelatech.com From igorm at etf.rs Tue Mar 27 03:39:53 2012 From: igorm at etf.rs (=?utf-8?B?Iklnb3IgTWFyYXZpxIci?=) Date: Tue, 27 Mar 2012 12:39:53 +0200 Subject: [Xorp-hackers] [PATCH 1/2] xorp: fea: data_plane: ifconfig: Check if we can set destination address for vif(IPv6) In-Reply-To: <4F71518B.8020802@candelatech.com> References: <1332518620-18507-1-git-send-email-igorm@etf.rs> <4F6CA278.60700@candelatech.com> <4F6CC69A.5050503@candelatech.com> <4F71518B.8020802@candelatech.com> Message-ID: Ben, this is the config that I use: --- /* XORP configuration file * * Configuration format: 1.1 * XORP version: 1.8.5 * Date: 2012/02/28 10:17:12.863958 * Host: igor * User: root */ fea { unicast-forwarding4 { disable: false } } interfaces { restore-original-config-on-shutdown: false interface eth0 { description: "" disable: false discard: false unreachable: false management: false parent-ifname: "" iface-type: "" vid: "" vif eth0 { disable: false address 10.10.10.10 { prefix-length: 24 broadcast: 10.10.10.255 disable: false } } } } --- It sets vif's address without any problems. When I want to add new vif address this is what I get: --- root at igor# set interfaces interface eth0 vif eth0 address 10.10.1.2 prefix-length 24 [edit] root at igor# commit Commit Failed 102 Command failed push_config failed: Interface/Vif/Address error on eth0/eth0/10.10.1.2: Can't set broadcast address for if: eth0 vif: eth0because it isn't broadcast capable --- I looked code a bit and there is another solution. I can leave a strict check. I only moved the check if config and system configuration are different, bellow the code where we are changing config->broadcast flag to be equal to system-broadcast flag. I'm sending this patch. Unfortunately I don't have ppp interface to test this. BR Igor From igorm at etf.rs Tue Mar 27 03:42:07 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 27 Mar 2012 12:42:07 +0200 Subject: [Xorp-hackers] [PATCH] xorp: fea: data_plane: ifconfig: Fix checking if interface can have broadcast address Message-ID: <1332844927-14127-1-git-send-email-igorm@etf.rs> From: Igor Maravic Signed-off-by: Igor Maravic --- xorp/fea/data_plane/ifconfig/ifconfig_set.cc | 30 +++++++++++++------------- 1 files changed, 15 insertions(+), 15 deletions(-) diff --git a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc index 75013da..108b612 100644 --- a/xorp/fea/data_plane/ifconfig/ifconfig_set.cc +++ b/xorp/fea/data_plane/ifconfig/ifconfig_set.cc @@ -595,21 +595,6 @@ IfConfigSet::push_vif_address(const IfTreeInterface* system_ifp, is_add = false; } - if (system_vifp != NULL) { - if (system_vifp->point_to_point() != config_addr.point_to_point()) { - error_msg = c_format("Can't set destination address for if: %s vif: %s" - "because it isn't point-to-point interface\n", - system_ifp->ifname().c_str(), system_vifp->vifname().c_str()); - goto done; - } - if (system_vifp->broadcast() != config_addr.broadcast()) { - error_msg = c_format("Can't set broadcast address for if: %s vif: %s" - "because it isn't broadcast capable\n", - system_ifp->ifname().c_str(), system_vifp->vifname().c_str()); - goto done; - } - } - // // XXX: If the broadcast address was omitted, recompute and set it here. // Note that we recompute it only if the underlying vif is @@ -625,6 +610,21 @@ IfConfigSet::push_vif_address(const IfTreeInterface* system_ifp, config_addr.set_broadcast(true); } + if (system_vifp != NULL) { + if (system_vifp->point_to_point() != config_addr.point_to_point()) { + error_msg = c_format("Can't set destination address for if: %s vif: %s" + "because it isn't point-to-point interface\n", + system_ifp->ifname().c_str(), system_vifp->vifname().c_str()); + goto done; + } + if (system_vifp->broadcast() != config_addr.broadcast()) { + error_msg = c_format("Can't set broadcast address for if: %s vif: %s" + "because it isn't broadcast capable\n", + system_ifp->ifname().c_str(), system_vifp->vifname().c_str()); + goto done; + } + } + // // Push the address configuration: either add/update or delete it. // -- 1.7.5.4 From noreply at github.com Tue Mar 27 09:40:05 2012 From: noreply at github.com (GitHub) Date: Tue, 27 Mar 2012 09:40:05 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 135772: xorp: fea: data_plane: ifconfig: Fix checking if i... Message-ID: <4f71ed659bea6_369119b9af01165d3@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 135772b8d444436e70d2c6b6b1d683274aad4789 https://github.com/greearb/xorp.ct/commit/135772b8d444436e70d2c6b6b1d683274aad4789 Author: Igor Maravic Date: 2012-03-27 (Tue, 27 Mar 2012) Changed paths: M xorp/fea/data_plane/ifconfig/ifconfig_set.cc Log Message: ----------- xorp: fea: data_plane: ifconfig: Fix checking if interface can have broadcast address Signed-off-by: Igor Maravic