summaryrefslogtreecommitdiff
path: root/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c')
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c b/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c
index 4e32ac67e0..14f8a70c72 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c
@@ -23,6 +23,7 @@
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2017 Nexenta Systems, Inc.
* Copyright 2017 Gary Mills
+ * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
*/
#include <arpa/inet.h>
@@ -91,7 +92,8 @@ static cmd_t cmds[] = {
{ "create-addr", do_create_addr,
"\tcreate-addr\t[-t] -T static [-d] "
"-a{local|remote}=addr[/prefixlen]\n\t\t\t<addrobj>\n"
- "\tcreate-addr\t[-t] -T dhcp [-w <seconds> | forever] <addrobj>\n"
+ "\tcreate-addr\t[-t] -T dhcp [-w <seconds> | forever]\n"
+ "\t\t\t[-1] [-h <hostname>] <addrobj>\n"
"\tcreate-addr\t[-t] -T addrconf [-i interface-id]\n"
"\t\t\t[-p {stateful|stateless}={yes|no}] <addrobj>" },
{ "down-addr", do_down_addr, "\tdown-addr\t[-t] <addrobj>" },
@@ -164,7 +166,9 @@ static const struct option addr_longopts[] = {
{"address", required_argument, 0, 'a' },
{"down", no_argument, 0, 'd' },
{"interface-id", required_argument, 0, 'i' },
+ {"primary", no_argument, 0, '1' },
{"prop", required_argument, 0, 'p' },
+ {"reqhost", required_argument, 0, 'h' },
{"temporary", no_argument, 0, 't' },
{"type", required_argument, 0, 'T' },
{"wait", required_argument, 0, 'w' },
@@ -615,8 +619,8 @@ show_property(void *arg, const char *pname, uint_t proto)
/*
* Properties to be displayed is in `statep->sps_proplist'. If it is NULL,
- * for all the properties for the specified object, relavant information, will
- * be displayed. Otherwise, for the selected property set, display relevant
+ * for all the properties for the specified object, display relevant
+ * information. Otherwise, for the selected property set, display relevant
* information
*/
static void
@@ -1241,14 +1245,19 @@ do_create_addr(int argc, char *argv[], const char *use)
char *addrconf_arg = NULL;
char *interface_id = NULL;
char *wait = NULL;
+ char *reqhost = NULL;
boolean_t s_opt = _B_FALSE; /* static addr options */
boolean_t auto_opt = _B_FALSE; /* Addrconf options */
boolean_t dhcp_opt = _B_FALSE; /* dhcp options */
+ boolean_t primary_opt = _B_FALSE; /* dhcp primary option */
opterr = 0;
- while ((option = getopt_long(argc, argv, ":T:a:di:p:w:t",
+ while ((option = getopt_long(argc, argv, ":1T:a:dh:i:p:w:t",
addr_longopts, NULL)) != -1) {
switch (option) {
+ case '1':
+ primary_opt = _B_TRUE;
+ break;
case 'T':
atype = optarg;
break;
@@ -1260,6 +1269,9 @@ do_create_addr(int argc, char *argv[], const char *use)
flags &= ~IPADM_OPT_UP;
s_opt = _B_TRUE;
break;
+ case 'h':
+ reqhost = optarg;
+ break;
case 'i':
interface_id = optarg;
auto_opt = _B_TRUE;
@@ -1291,7 +1303,8 @@ do_create_addr(int argc, char *argv[], const char *use)
* Allocate and initialize the addrobj based on the address type.
*/
if (strcmp(atype, "static") == 0) {
- if (static_arg == NULL || auto_opt || dhcp_opt) {
+ if (static_arg == NULL || auto_opt || dhcp_opt ||
+ reqhost != NULL || primary_opt) {
die("Invalid arguments for type %s\nusage: %s",
atype, use);
}
@@ -1328,13 +1341,27 @@ do_create_addr(int argc, char *argv[], const char *use)
ipadm_status2str(status));
}
}
+ if (primary_opt) {
+ status = ipadm_set_primary(ipaddr, _B_TRUE);
+ if (status != IPADM_SUCCESS) {
+ die("Error in setting primary flag: %s",
+ ipadm_status2str(status));
+ }
+ }
+ if (reqhost != NULL) {
+ status = ipadm_set_reqhost(ipaddr, reqhost);
+ if (status != IPADM_SUCCESS) {
+ die("Error in setting reqhost: %s",
+ ipadm_status2str(status));
+ }
+ }
} else if (strcmp(atype, "addrconf") == 0) {
- if (dhcp_opt || s_opt) {
+ if (dhcp_opt || s_opt || reqhost != NULL || primary_opt) {
die("Invalid arguments for type %s\nusage: %s",
atype, use);
}
- /* Initialize the addrobj for dhcp addresses. */
+ /* Initialize the addrobj for ipv6-addrconf addresses. */
status = ipadm_create_addrobj(IPADM_ADDR_IPV6_ADDRCONF,
argv[optind], &ipaddr);
if (status != IPADM_SUCCESS) {