mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-31 20:23:56 +08:00
HOSTNAME(1): Add -m flag
This commit is contained in:
parent
026abfb7ae
commit
e6405ea0cb
@ -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);
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user