diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-01-10 08:04:58 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-01-10 11:03:32 +0100 |
commit | 64c663c0d1341d208891e68a7e2c857485754f99 (patch) | |
tree | 80a4ff217d4f19245c58d1d419ca8f4387d58e4b /freebsd/usr.sbin | |
parent | ARP(8): Import from FreeBSD (diff) | |
download | rtems-libbsd-64c663c0d1341d208891e68a7e2c857485754f99.tar.bz2 |
ARP(8): Port to RTEMS
Diffstat (limited to 'freebsd/usr.sbin')
-rw-r--r-- | freebsd/usr.sbin/arp/arp.c | 57 | ||||
-rw-r--r-- | freebsd/usr.sbin/arp/rtems-bsd-arp-arp-data.h | 14 | ||||
-rw-r--r-- | freebsd/usr.sbin/arp/rtems-bsd-arp-data.h | 3 | ||||
-rw-r--r-- | freebsd/usr.sbin/arp/rtems-bsd-arp-namespace.h | 2 |
4 files changed, 75 insertions, 1 deletions
diff --git a/freebsd/usr.sbin/arp/arp.c b/freebsd/usr.sbin/arp/arp.c index 951d6f5c..5a85f252 100644 --- a/freebsd/usr.sbin/arp/arp.c +++ b/freebsd/usr.sbin/arp/arp.c @@ -1,5 +1,9 @@ #include <machine/rtems-bsd-user-space.h> +#ifdef __rtems__ +#include "rtems-bsd-arp-namespace.h" +#endif /* __rtems__ */ + /* * Copyright (c) 1984, 1993 * The Regents of the University of California. All rights reserved. @@ -51,6 +55,12 @@ __FBSDID("$FreeBSD$"); */ +#ifdef __rtems__ +#define __need_getopt_newlib +#include <getopt.h> +#include <machine/rtems-bsd-program.h> +#include <machine/rtems-bsd-commands.h> +#endif /* __rtems__ */ #include <rtems/bsd/sys/param.h> #include <sys/file.h> #include <sys/socket.h> @@ -81,6 +91,13 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <strings.h> #include <unistd.h> +#ifdef __rtems__ +#include "rtems-bsd-arp-arp-data.h" +static struct timespec tp; +static int seq; +static int s = -1; +static pid_t pid; +#endif /* __rtems__ */ typedef void (action_fn)(struct sockaddr_dl *sdl, struct sockaddr_in *s_in, struct rt_msghdr *rtm); @@ -106,7 +123,7 @@ static char *rifname; static time_t expire_time; static int flags, doing_proxy; -struct if_nameindex *ifnameindex; +static struct if_nameindex *ifnameindex; /* which function we're supposed to do */ #define F_GET 1 @@ -117,12 +134,44 @@ struct if_nameindex *ifnameindex; #define SETFUNC(f) { if (func) usage(); func = (f); } +#ifdef __rtems__ +static int main(int argc, char *argv[]); + +RTEMS_LINKER_RWSET(bsd_prog_arp, char); + +int +rtems_bsd_command_arp(int argc, char *argv[]) +{ + int exit_code; + void *data_begin; + size_t data_size; + + data_begin = RTEMS_LINKER_SET_BEGIN(bsd_prog_arp); + data_size = RTEMS_LINKER_SET_SIZE(bsd_prog_arp); + + rtems_bsd_program_lock(); + exit_code = rtems_bsd_program_call_main_with_data_restore("arp", + main, argc, argv, data_begin, data_size); + rtems_bsd_program_unlock(); + + return exit_code; +} +#endif /* __rtems__ */ int main(int argc, char *argv[]) { int ch, func = 0; int rtn = 0; int aflag = 0; /* do it for all entries */ +#ifdef __rtems__ + struct getopt_data getopt_data; + memset(&getopt_data, 0, sizeof(getopt_data)); +#define optind getopt_data.optind +#define optarg getopt_data.optarg +#define opterr getopt_data.opterr +#define optopt getopt_data.optopt +#define getopt(argc, argv, opt) getopt_r(argc, argv, "+" opt, &getopt_data) +#endif /* __rtems__ */ while ((ch = getopt(argc, argv, "andfsSi:")) != -1) switch(ch) { @@ -619,7 +668,9 @@ print_entry(struct sockaddr_dl *sdl, if (rtm->rtm_rmx.rmx_expire == 0) printf(" permanent"); else { +#ifndef __rtems__ static struct timespec tp; +#endif /* __rtems__ */ if (tp.tv_sec == 0) clock_gettime(CLOCK_MONOTONIC, &tp); if ((expire_time = rtm->rtm_rmx.rmx_expire - tp.tv_sec) > 0) @@ -703,12 +754,16 @@ usage(void) static struct rt_msghdr * rtmsg(int cmd, struct sockaddr_in *dst, struct sockaddr_dl *sdl) { +#ifndef __rtems__ static int seq; +#endif /* __rtems__ */ int rlen; int l; struct sockaddr_in so_mask, *som = &so_mask; +#ifndef __rtems__ static int s = -1; static pid_t pid; +#endif /* __rtems__ */ static struct { struct rt_msghdr m_rtm; diff --git a/freebsd/usr.sbin/arp/rtems-bsd-arp-arp-data.h b/freebsd/usr.sbin/arp/rtems-bsd-arp-arp-data.h new file mode 100644 index 00000000..b50ea220 --- /dev/null +++ b/freebsd/usr.sbin/arp/rtems-bsd-arp-arp-data.h @@ -0,0 +1,14 @@ +/* generated by userspace-header-gen.py */ +#include <rtems/linkersets.h> +#include "rtems-bsd-arp-data.h" +/* arp.c */ +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_arp, static int nflag); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_arp, static char *rifname); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_arp, static time_t expire_time); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_arp, static int flags); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_arp, static int doing_proxy); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_arp, static struct if_nameindex *ifnameindex); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_arp, static struct timespec tp); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_arp, static int seq); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_arp, static int s); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_arp, static pid_t pid); diff --git a/freebsd/usr.sbin/arp/rtems-bsd-arp-data.h b/freebsd/usr.sbin/arp/rtems-bsd-arp-data.h new file mode 100644 index 00000000..cd210b1d --- /dev/null +++ b/freebsd/usr.sbin/arp/rtems-bsd-arp-data.h @@ -0,0 +1,3 @@ +/* generated by userspace-header-gen.py */ +#include <rtems/linkersets.h> +/* arp.c */ diff --git a/freebsd/usr.sbin/arp/rtems-bsd-arp-namespace.h b/freebsd/usr.sbin/arp/rtems-bsd-arp-namespace.h new file mode 100644 index 00000000..71a22796 --- /dev/null +++ b/freebsd/usr.sbin/arp/rtems-bsd-arp-namespace.h @@ -0,0 +1,2 @@ +/* generated by userspace-header-gen.py */ +/* arp.c */ |