Print this page
7388 Support DHCP Client FQDN. Allow IAID/DUID for all v4.

*** 19,28 **** --- 19,29 ---- * CDDL HEADER END */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2012 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2016, Chris Fraire <cfraire@me.com>. */ #include <arpa/inet.h> #include <errno.h> #include <getopt.h> #include <inet/ip.h>
*** 86,96 **** /* address management related sub-commands */ { "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 addrconf [-i interface-id]\n" "\t\t\t[-p {stateful|stateless}={yes|no}] <addrobj>" }, { "down-addr", do_down_addr, "\tdown-addr\t[-t] <addrobj>" }, { "up-addr", do_up_addr, "\tup-addr\t\t[-t] <addrobj>" }, { "disable-addr", do_disable_addr, "\tdisable-addr\t-t <addrobj>" }, --- 87,98 ---- /* address management related sub-commands */ { "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]\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>" }, { "up-addr", do_up_addr, "\tup-addr\t\t[-t] <addrobj>" }, { "disable-addr", do_disable_addr, "\tdisable-addr\t-t <addrobj>" },
*** 159,169 **** --- 161,173 ---- 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' }, { 0, 0, 0, 0 } };
*** 630,641 **** return (_B_TRUE); } /* * 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 * information */ static void show_properties(void *arg, int prop_class) { --- 634,645 ---- return (_B_TRUE); } /* * Properties to be displayed is in `statep->sps_proplist'. If it is NULL, ! * for all the properties for the specified object, display relevant ! * information. Otherwise, for the selected property set, display relevant * information */ static void show_properties(void *arg, int prop_class) {
*** 1256,1273 **** char *atype = NULL; char *static_arg = NULL; char *addrconf_arg = NULL; char *interface_id = NULL; char *wait = 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 */ opterr = 0; ! while ((option = getopt_long(argc, argv, ":T:a:di:p:w:t", addr_longopts, NULL)) != -1) { switch (option) { case 'T': atype = optarg; break; case 'a': static_arg = optarg; --- 1260,1282 ---- char *atype = NULL; char *static_arg = NULL; 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, ":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; case 'a': static_arg = optarg;
*** 1275,1284 **** --- 1284,1296 ---- break; case 'd': flags &= ~IPADM_OPT_UP; s_opt = _B_TRUE; break; + case 'h': + reqhost = optarg; + break; case 'i': interface_id = optarg; auto_opt = _B_TRUE; break; case 'p':
*** 1306,1316 **** /* * Allocate and initialize the addrobj based on the address type. */ if (strcmp(atype, "static") == 0) { ! if (static_arg == NULL || auto_opt || dhcp_opt) { die("Invalid arguments for type %s\nusage: %s", atype, use); } process_static_addrargs(use, static_arg, argv[optind]); } else if (strcmp(atype, "dhcp") == 0) { --- 1318,1329 ---- /* * Allocate and initialize the addrobj based on the address type. */ if (strcmp(atype, "static") == 0) { ! if (static_arg == NULL || auto_opt || dhcp_opt ! || reqhost != NULL || primary_opt) { die("Invalid arguments for type %s\nusage: %s", atype, use); } process_static_addrargs(use, static_arg, argv[optind]); } else if (strcmp(atype, "dhcp") == 0) {
*** 1343,1359 **** if (status != IPADM_SUCCESS) { die("Error in setting wait time: %s", ipadm_status2str(status)); } } } else if (strcmp(atype, "addrconf") == 0) { ! if (dhcp_opt || s_opt) { die("Invalid arguments for type %s\nusage: %s", atype, use); } ! /* Initialize the addrobj for dhcp addresses. */ status = ipadm_create_addrobj(IPADM_ADDR_IPV6_ADDRCONF, argv[optind], &ipaddr); if (status != IPADM_SUCCESS) { die("Error in creating address object: %s", ipadm_status2str(status)); --- 1356,1386 ---- if (status != IPADM_SUCCESS) { die("Error in setting wait time: %s", 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 || reqhost != NULL || primary_opt) { die("Invalid arguments for type %s\nusage: %s", atype, use); } ! /* Initialize the addrobj for ipv6-addrconf addresses. */ status = ipadm_create_addrobj(IPADM_ADDR_IPV6_ADDRCONF, argv[optind], &ipaddr); if (status != IPADM_SUCCESS) { die("Error in creating address object: %s", ipadm_status2str(status));