summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--freebsd/bin/hostname/hostname.c31
-rw-r--r--libbsd.txt9
2 files changed, 38 insertions, 2 deletions
diff --git a/freebsd/bin/hostname/hostname.c b/freebsd/bin/hostname/hostname.c
index c3342b85..bd22ce8f 100644
--- a/freebsd/bin/hostname/hostname.c
+++ b/freebsd/bin/hostname/hostname.c
@@ -46,6 +46,7 @@ static char sccsid[] = "@(#)hostname.c 8.1 (Berkeley) 5/31/93";
#include <rtems/netcmds-config.h>
#include <machine/rtems-bsd-program.h>
#include <machine/rtems-bsd-commands.h>
+#include <rtems/mdns.h>
#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -78,7 +79,7 @@ static int hostname_command(int argc, char *argv[])
rtems_shell_cmd_t rtems_shell_HOSTNAME_Command = {
.name = "hostname",
- .usage = "hostname [-fs] [name-of-host]",
+ .usage = "hostname [-fms] [name-of-host]",
.topic = "net",
.command = hostname_command
};
@@ -93,10 +94,15 @@ main(int argc, char *argv[])
memset(&getopt_data, 0, sizeof(getopt_data));
#define optind getopt_data.optind
#define getopt(argc, argv, opt) getopt_r(argc, argv, "+" opt, &getopt_data)
+ int mflag = 0;
#endif /* __rtems__ */
sflag = 0;
+#ifndef __rtems__
while ((ch = getopt(argc, argv, "fs")) != -1)
+#else /* __rtems__ */
+ while ((ch = getopt(argc, argv, "fms")) != -1)
+#endif /* __rtems__ */
switch (ch) {
case 'f':
/*
@@ -108,6 +114,11 @@ main(int argc, char *argv[])
case 's':
sflag = 1;
break;
+#ifdef __rtems__
+ case 'm':
+ mflag = 1;
+ break;
+#endif /* __rtems__ */
case '?':
default:
usage();
@@ -119,8 +130,24 @@ main(int argc, char *argv[])
usage();
if (*argv) {
+#ifdef __rtems__
+ if (mflag) {
+ if (rtems_mdns_sethostname(*argv)) {
+ err(1, "rtems_mdns_sethostname");
+ }
+ } else {
+#endif /* __rtems__ */
if (sethostname(*argv, (int)strlen(*argv)))
err(1, "sethostname");
+#ifdef __rtems__
+ }
+ } else if (mflag) {
+ if (rtems_mdns_gethostname(hostname, sizeof(hostname))) {
+ err(1, "rtems_mdns_gethostname");
+ }
+
+ (void)printf("%s\n", hostname);
+#endif /* __rtems__ */
} else {
if (gethostname(hostname, (int)sizeof(hostname)))
err(1, "gethostname");
@@ -138,6 +165,6 @@ static void
usage(void)
{
- (void)fprintf(stderr, "usage: hostname [-fs] [name-of-host]\n");
+ (void)fprintf(stderr, "usage: hostname [-fms] [name-of-host]\n");
exit(1);
}
diff --git a/libbsd.txt b/libbsd.txt
index 96173e88..c60bd2a0 100644
--- a/libbsd.txt
+++ b/libbsd.txt
@@ -285,6 +285,15 @@ Make sure that the interface flag IFF_UP and the interface driver flag
IFF_DRV_RUNNING is set in case the link is up, otherwise ether_output() will
return the error status ENETDOWN.
+== Shell Commands
+
+=== HOSTNAME(1)
+
+In addition to the standard options the RTEMS version of the HOSTNAME(1)
+command supports the -m flag to set/get the multicast hostname of the
+mDNS resolver instance. See also rtems_mdns_sethostname() and
+rtems_mdns_gethostname().
+
== Issues and TODO
* Per-CPU data should be enabled once the new stack is ready for SMP.