summaryrefslogtreecommitdiffstats
path: root/freebsd/sbin/ping6/ping6.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-10-31 11:31:56 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-10-31 13:20:14 +0100
commit5c3f0b76d840d178e4e80881f7d81f186149117e (patch)
tree5b36103168fc445f660cb8a6214e3d0bddc5aa6d /freebsd/sbin/ping6/ping6.c
parentPING6(8): Delete unused variable (diff)
downloadrtems-libbsd-5c3f0b76d840d178e4e80881f7d81f186149117e.tar.bz2
PING6(8): Add RTEMS support
Diffstat (limited to 'freebsd/sbin/ping6/ping6.c')
-rw-r--r--freebsd/sbin/ping6/ping6.c58
1 files changed, 47 insertions, 11 deletions
diff --git a/freebsd/sbin/ping6/ping6.c b/freebsd/sbin/ping6/ping6.c
index abb95268..7bfa96e9 100644
--- a/freebsd/sbin/ping6/ping6.c
+++ b/freebsd/sbin/ping6/ping6.c
@@ -107,6 +107,8 @@ static const char rcsid[] =
#ifdef __rtems__
#define __need_getopt_newlib
#include <getopt.h>
+#include <machine/rtems-bsd-program.h>
+#include <machine/rtems-bsd-commands.h>
#define USE_RFC2292BIS
#endif /* __rtems__ */
@@ -220,7 +222,7 @@ static struct addrinfo *res;
static struct sockaddr_in6 dst; /* who to ping6 */
static struct sockaddr_in6 src; /* src addr of this packet */
static socklen_t srclen;
-static int datalen = DEFDATALEN;
+static int datalen;
static int s; /* socket file descriptor */
static u_char outpack[MAXPACKETLEN];
static const char BSPACE = '\b'; /* characters written for flood */
@@ -229,7 +231,7 @@ static const char DOT = '.';
static char *hostname;
static int ident; /* process id to identify our packets */
static u_int8_t nonce[8]; /* nonce field for node information */
-static int hoplimit = -1; /* hoplimit */
+static int hoplimit; /* hoplimit */
/* counters */
static long nmissedmax; /* max value of ntransmitted - nreceived - 1 */
@@ -237,14 +239,14 @@ static long npackets; /* max packets to transmit */
static long nreceived; /* # of packets we got back */
static long nrepeats; /* number of duplicates */
static long ntransmitted; /* sequence # for outbound packets = #sent */
-static struct timeval interval = {1, 0}; /* interval between packets */
+static struct timeval interval; /* interval between packets */
/* timing */
static int timing; /* flag to do timing */
-static double tmin = 999999999.0; /* minimum round trip time */
-static double tmax = 0.0; /* maximum round trip time */
-static double tsum = 0.0; /* sum of all times, for doing average */
-static double tsumsq = 0.0; /* sum of all times squared, for std. dev. */
+static double tmin; /* minimum round trip time */
+static double tmax; /* maximum round trip time */
+static double tsum; /* sum of all times, for doing average */
+static double tsumsq; /* sum of all times squared, for std. dev. */
/* for node addresses */
static u_short naflags;
@@ -295,13 +297,47 @@ static int setpolicy(int, char *);
static char *nigroup(char *);
static void usage(void);
+#ifdef __rtems__
+int rtems_bsd_command_ping6(int argc, char **argv)
+{
+ int exit_code;
+
+ rtems_bsd_program_lock();
+
+ memset(&rcvd_tbl[0], 0, sizeof(rcvd_tbl));
+ srclen = 0;
+ datalen = DEFDATALEN;
+ memset(&outpack[0], 0, sizeof(outpack));
+ hoplimit = -1;
+ nmissedmax = 0;
+ npackets = 0;
+ nreceived = 0;
+ nrepeats = 0;
+ ntransmitted = 0;
+ interval.tv_sec = 1;
+ interval.tv_usec = 0;
+ timing = 0;
+ tmin = 999999999.0;
+ tmax = 0.0;
+ tsum = 0.0;
+ tsumsq = 0.0;
+ naflags = 0;
+ scmsg = NULL;
+ seenalrm = 0;
+ seenint = 0;
+#ifdef SIGINFO
+ seeninfo = 0;
+#endif
+
+ exit_code = rtems_bsd_program_call_main("ping6", main, argc, argv);
+ rtems_bsd_program_unlock();
+
+ return exit_code;
+}
+#endif /* __rtems__ */
int
-#ifdef __rtems__
-main_ping6(argc, argv)
-#else
main(argc, argv)
-#endif
int argc;
char *argv[];
{