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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libnwam/common/libnwam_ncp.c
          +++ new/usr/src/lib/libnwam/common/libnwam_ncp.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
       25 + * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
  25   26   */
  26   27  
  27   28  #include <assert.h>
  28   29  #include <ctype.h>
  29   30  #include <libgen.h>
  30   31  #include <netdb.h>
  31   32  #include <sys/param.h>
  32   33  #include <sys/types.h>
  33   34  #include <sys/stat.h>
  34   35  #include <sys/socket.h>
  35   36  #include <netinet/in.h>
  36   37  #include <arpa/inet.h>
  37   38  #include <stdio.h>
  38   39  #include <stdlib.h>
  39   40  #include <strings.h>
  40   41  #include <unistd.h>
  41   42  #include <libdladm.h>
       43 +#include <libipadm.h>
  42   44  
  43   45  #include "libnwam_impl.h"
  44   46  #include <libnwam_priv.h>
  45   47  #include <libnwam.h>
  46   48  
  47   49  /*
  48   50   * Functions to support creating, modifying, destroying, querying the
  49   51   * state of and changing the state of NCP (Network Configuration Profiles)
  50   52   * and the NCUs (Network Configuration Units) that are contained in those
  51   53   * NCP objects.  An NCP is simply a container for a set of NCUs which represent
↓ open down ↓ 14 lines elided ↑ open up ↑
  66   68  static nwam_error_t valid_type(nwam_value_t);
  67   69  static nwam_error_t valid_class(nwam_value_t);
  68   70  static nwam_error_t valid_ncp(nwam_value_t);
  69   71  static nwam_error_t valid_priority_mode(nwam_value_t);
  70   72  static nwam_error_t valid_ncu_activation_mode(nwam_value_t);
  71   73  static nwam_error_t valid_link_autopush(nwam_value_t);
  72   74  static nwam_error_t valid_link_mtu(nwam_value_t);
  73   75  static nwam_error_t valid_ip_version(nwam_value_t);
  74   76  static nwam_error_t valid_addrsrc_v4(nwam_value_t);
  75   77  static nwam_error_t valid_addrsrc_v6(nwam_value_t);
       78 +static nwam_error_t valid_reqhost(nwam_value_t);
  76   79  
  77   80  struct nwam_prop_table_entry ncu_prop_table_entries[] = {
  78   81          {NWAM_NCU_PROP_TYPE, NWAM_VALUE_TYPE_UINT64, B_FALSE, 1, 1, valid_type,
  79   82              "specifies the NCU type - valid values are \'datalink\' and \'ip\'",
  80   83              NWAM_FLAG_NCU_TYPE_ALL, NWAM_FLAG_NCU_CLASS_ALL},
  81   84          {NWAM_NCU_PROP_CLASS, NWAM_VALUE_TYPE_UINT64, B_FALSE, 1, 1,
  82   85              valid_class,
  83   86              "specifies the NCU class - valid values are "
  84   87              "\'phys\' and \'ip\'",
  85   88              NWAM_FLAG_NCU_TYPE_ALL, NWAM_FLAG_NCU_CLASS_ALL},
↓ open down ↓ 56 lines elided ↑ open up ↑
 142  145              "\'dhcp\', \'autoconf\' and \'static\'.\n"
 143  146              "\'dhcp\' and \'autoconf\' are mandatory values.",
 144  147              NWAM_FLAG_NCU_TYPE_INTERFACE, NWAM_FLAG_NCU_CLASS_ALL_INTERFACE},
 145  148          {NWAM_NCU_PROP_IPV6_ADDR, NWAM_VALUE_TYPE_STRING, B_FALSE, 0,
 146  149              NWAM_MAX_NUM_VALUES, nwam_valid_host_v6,
 147  150              "specifies static IPv6 host address(es)",
 148  151              NWAM_FLAG_NCU_TYPE_INTERFACE, NWAM_FLAG_NCU_CLASS_ALL_INTERFACE},
 149  152          {NWAM_NCU_PROP_IPV6_DEFAULT_ROUTE, NWAM_VALUE_TYPE_STRING, B_FALSE, 0,
 150  153              1, nwam_valid_route_v6,
 151  154              "specifies per-interface default IPv6 route",
 152      -            NWAM_FLAG_NCU_TYPE_INTERFACE, NWAM_FLAG_NCU_CLASS_ALL_INTERFACE}
      155 +            NWAM_FLAG_NCU_TYPE_INTERFACE, NWAM_FLAG_NCU_CLASS_ALL_INTERFACE},
      156 +        {NWAM_NCU_PROP_IP_PRIMARY, NWAM_VALUE_TYPE_BOOLEAN, B_FALSE, 0,
      157 +            1, nwam_valid_boolean,
      158 +            "specifies the status of an interface as primary for the delivery"
      159 +            " of client-wide configuration data",
      160 +            NWAM_FLAG_NCU_TYPE_INTERFACE, NWAM_FLAG_NCU_CLASS_ALL_INTERFACE},
      161 +        {NWAM_NCU_PROP_IP_REQHOST, NWAM_VALUE_TYPE_STRING, B_FALSE, 0,
      162 +            1, valid_reqhost,
      163 +            "specifies a requested hostname for the interface",
      164 +            NWAM_FLAG_NCU_TYPE_INTERFACE, NWAM_FLAG_NCU_CLASS_ALL_INTERFACE},
 153  165  };
 154  166  
 155  167  #define NWAM_NUM_NCU_PROPS      (sizeof (ncu_prop_table_entries) / \
 156  168                                  sizeof (*ncu_prop_table_entries))
 157  169  
 158  170  struct nwam_prop_table ncu_prop_table =
 159  171          { NWAM_NUM_NCU_PROPS, ncu_prop_table_entries };
 160  172  
 161  173  nwam_error_t
 162  174  nwam_ncp_get_name(nwam_ncp_handle_t ncph, char **namep)
↓ open down ↓ 1478 lines elided ↑ open up ↑
1641 1653          /*
1642 1654           * DHCP and AUTOCONF need to be specified as v6 address sources
1643 1655           * since there is no way to switch them off in NWAM at present.
1644 1656           */
1645 1657          if (dhcp_found && autoconf_found)
1646 1658                  return (NWAM_SUCCESS);
1647 1659          else
1648 1660                  return (NWAM_ENTITY_INVALID_VALUE);
1649 1661  }
1650 1662  
     1663 +static nwam_error_t
     1664 +valid_reqhost(nwam_value_t value)
     1665 +{
     1666 +        char *hostname;
     1667 +
     1668 +        if (nwam_value_get_string(value, &hostname) != NWAM_SUCCESS)
     1669 +                return (NWAM_ENTITY_INVALID_VALUE);
     1670 +        return (ipadm_is_valid_hostname(hostname) ? NWAM_SUCCESS
     1671 +            : NWAM_ENTITY_INVALID_VALUE);
     1672 +}
     1673 +
1651 1674  /* ARGSUSED0 */
1652 1675  static nwam_error_t
1653 1676  valid_link_mtu(nwam_value_t value)
1654 1677  {
1655 1678          return (NWAM_SUCCESS);
1656 1679  }
1657 1680  
1658 1681  nwam_error_t
1659 1682  nwam_ncu_validate(nwam_ncu_handle_t ncuh, const char **errpropp)
1660 1683  {
↓ open down ↓ 59 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX