diff --git a/Makefile b/Makefile index c2534a96..79ad109e 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,7 @@ LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-pci_cfgreg.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-program.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-rwlock.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-shell.c +LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-shell-netcmds.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-signal.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-smp.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-subr_param.c diff --git a/freebsd-to-rtems.py b/freebsd-to-rtems.py index 1fadb58b..0d0669fa 100755 --- a/freebsd-to-rtems.py +++ b/freebsd-to-rtems.py @@ -630,6 +630,7 @@ rtems.addRTEMSSourceFiles( 'rtems/rtems-bsd-program.c', 'rtems/rtems-bsd-rwlock.c', 'rtems/rtems-bsd-shell.c', + 'rtems/rtems-bsd-shell-netcmds.c', 'rtems/rtems-bsd-signal.c', 'rtems/rtems-bsd-smp.c', 'rtems/rtems-bsd-subr_param.c', diff --git a/freebsd/sbin/ifconfig/ifconfig.c b/freebsd/sbin/ifconfig/ifconfig.c index d983862d..078eae98 100644 --- a/freebsd/sbin/ifconfig/ifconfig.c +++ b/freebsd/sbin/ifconfig/ifconfig.c @@ -164,10 +164,11 @@ usage(void) #ifdef __rtems__ #include +#include static int main(int argc, char *argv[]); -static int rtems_shell_main_ifconfig(int argc, char *argv[]) +int rtems_bsd_command_ifconfig(int argc, char *argv[]) { descr = NULL; descrlen = 64; @@ -1220,16 +1221,3 @@ ifconfig_ctor(void) cmd_register(&basic_cmds[i]); #undef N } - -#ifdef __rtems__ - #include - - rtems_shell_cmd_t rtems_shell_IFCONFIG_Command = { - "ifconfig", /* name */ - "ifconfig [args]", /* usage */ - "net", /* topic */ - rtems_shell_main_ifconfig, /* command */ - NULL, /* alias */ - NULL /* next */ - }; -#endif diff --git a/freebsd/sbin/ping/ping.c b/freebsd/sbin/ping/ping.c index f1b4b912..4a2554c0 100644 --- a/freebsd/sbin/ping/ping.c +++ b/freebsd/sbin/ping/ping.c @@ -219,10 +219,11 @@ static void usage(void) __dead2; #ifdef __rtems__ #include +#include static int main(int argc, char **argv); -static int rtems_shell_main_ping(int argc, char *argv[]) +int rtems_bsd_command_ping(int argc, char *argv[]) { BBELL = '\a'; BSPACE = '\b'; @@ -1769,16 +1770,3 @@ usage() " [-z tos] mcast-group"); exit(EX_USAGE); } - -#ifdef __rtems__ - #include - - rtems_shell_cmd_t rtems_shell_PING_Command = { - "ping", /* name */ - "ping [args]", /* usage */ - "net", /* topic */ - rtems_shell_main_ping, /* command */ - NULL, /* alias */ - NULL /* next */ - }; -#endif diff --git a/freebsd/sbin/route/route.c b/freebsd/sbin/route/route.c index 964188ff..1442e095 100644 --- a/freebsd/sbin/route/route.c +++ b/freebsd/sbin/route/route.c @@ -130,10 +130,11 @@ usage(cp) #ifdef __rtems__ #include +#include static int main(int argc, char **argv); -static int rtems_shell_main_route(int argc, char *argv[]) +int rtems_bsd_command_route(int argc, char *argv[]) { return rtems_bsd_program_call_main("route", main, argc, argv); } @@ -1694,16 +1695,3 @@ atalk_ntoa(struct at_addr at) (void) snprintf(buf, sizeof(buf), "%u.%u", ntohs(at.s_net), at.s_node); return(buf); } - -#ifdef __rtems__ - #include - - rtems_shell_cmd_t rtems_shell_ROUTE_Command = { - "route", /* name */ - "route [args]", /* usage */ - "net", /* topic */ - rtems_shell_main_route, /* command */ - NULL, /* alias */ - NULL /* next */ - }; -#endif diff --git a/freebsd/usr.bin/netstat/main.c b/freebsd/usr.bin/netstat/main.c index dc413942..4e531bb4 100644 --- a/freebsd/usr.bin/netstat/main.c +++ b/freebsd/usr.bin/netstat/main.c @@ -363,10 +363,11 @@ int live; /* true if we are examining a live system */ #ifdef __rtems__ #include +#include static int main(int argc, char *argv[]); -static int rtems_shell_main_netstat(int argc, char *argv[]) +int rtems_bsd_command_netstat(int argc, char *argv[]) { int i; @@ -1198,16 +1199,3 @@ usage(void) " netstat -gs [-s] [-f address_family] [-M core] [-N system]"); exit(1); } - -#ifdef __rtems__ - #include - - rtems_shell_cmd_t rtems_shell_NETSTAT_Command = { - "netstat", /* name */ - "netstat [args]", /* usage */ - "net", /* topic */ - rtems_shell_main_netstat, /* command */ - NULL, /* alias */ - NULL /* next */ - }; -#endif diff --git a/rtemsbsd/include/machine/rtems-bsd-commands.h b/rtemsbsd/include/machine/rtems-bsd-commands.h new file mode 100644 index 00000000..2b4c617d --- /dev/null +++ b/rtemsbsd/include/machine/rtems-bsd-commands.h @@ -0,0 +1,59 @@ +/** + * @file + * + * @ingroup rtems_bsd_machine + * + * @brief TODO. + */ + +/* + * Copyright (c) 2013 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + */ + +#ifndef _RTEMS_BSD_MACHINE_RTEMS_BSD_COMMANDS_H_ +#define _RTEMS_BSD_MACHINE_RTEMS_BSD_COMMANDS_H_ + +#include + +__BEGIN_DECLS + +int rtems_bsd_command_ifconfig(int argc, char **argv); + +int rtems_bsd_command_netstat(int argc, char **argv); + +int rtems_bsd_command_ping(int argc, char **argv); + +int rtems_bsd_command_ping6(int argc, char **argv); + +int rtems_bsd_command_route(int argc, char **argv); + +__END_DECLS + +#endif /* _RTEMS_BSD_MACHINE_RTEMS_BSD_COMMANDS_H_ */ diff --git a/rtemsbsd/rtems/rtems-bsd-shell-netcmds.c b/rtemsbsd/rtems/rtems-bsd-shell-netcmds.c new file mode 100644 index 00000000..b34cab95 --- /dev/null +++ b/rtemsbsd/rtems/rtems-bsd-shell-netcmds.c @@ -0,0 +1,47 @@ +/* + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include +#include + +rtems_shell_cmd_t rtems_shell_IFCONFIG_Command = { + "ifconfig", /* name */ + "ifconfig [args]", /* usage */ + "net", /* topic */ + rtems_bsd_command_ifconfig, /* command */ + NULL, /* alias */ + NULL /* next */ +}; + +rtems_shell_cmd_t rtems_shell_NETSTAT_Command = { + "netstat", /* name */ + "netstat [args]", /* usage */ + "net", /* topic */ + rtems_bsd_command_netstat, /* command */ + NULL, /* alias */ + NULL /* next */ +}; + +rtems_shell_cmd_t rtems_shell_PING_Command = { + "ping", /* name */ + "ping [args]", /* usage */ + "net", /* topic */ + rtems_bsd_command_ping, /* command */ + NULL, /* alias */ + NULL /* next */ +}; + +rtems_shell_cmd_t rtems_shell_ROUTE_Command = { + "route", /* name */ + "route [args]", /* usage */ + "net", /* topic */ + rtems_bsd_command_route, /* command */ + NULL, /* alias */ + NULL /* next */ +};