Print this page
3882 remove xmod & friends


   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #pragma ident   "%Z%%M% %I%     %E% SMI"
  27 
  28 /* EXPORT DELETE START */
  29 #include <sys/types.h>
  30 #include <sys/param.h>
  31 #include <sys/salib.h>
  32 #include <sys/promif.h>
  33 #include <sys/wanboot_impl.h>
  34 #include <netinet/in.h>
  35 #include <parseURL.h>
  36 #include <bootlog.h>
  37 #include <sys/socket.h>
  38 #include <netinet/inetutil.h>
  39 #include <netinet/dhcp.h>
  40 #include <dhcp_impl.h>
  41 #include <lib/inet/mac.h>
  42 #include <lib/inet/ipv4.h>
  43 #include <lib/inet/dhcpv4.h>
  44 #include <lib/sock/sock_test.h>
  45 #include <sys/sunos_dhcp_class.h>
  46 #include <aes.h>
  47 #include <des3.h>
  48 #include <hmac_sha1.h>
  49 #include <netdb.h>
  50 #include <wanboot_conf.h>
  51 #include <bootinfo.h>
  52 /* EXPORT DELETE END */
  53 
  54 #include "wbcli.h"
  55 
  56 /* EXPORT DELETE START */
  57 
  58 #define skipspace(p)    while (isspace(*(p))) ++p
  59 
  60 #define skiptext(p)     while (*(p) != '\0' && !isspace(*(p)) && \
  61                             *(p) != '=' && *(p) != ',') ++p
  62 
  63 #define PROMPT          "boot> "
  64 #define TEST_PROMPT     "boot-test> "
  65 
  66 #define CLI_SET         0
  67 #define CLI_FAIL        (-1)
  68 #define CLI_EXIT        (-2)
  69 #define CLI_CONT        (-3)
  70 
  71 #define CLF_CMD         0x00000001      /* builtin command */
  72 #define CLF_ARG         0x00000002      /* boot argument directive */
  73 
  74 #define CLF_IF          0x00000100      /* interface parameter */
  75 #define CLF_BM          0x00000200      /* bootmisc parameter */
  76 
  77 #define CLF_VALSET      0x00010000      /* value set, may be null */


1288         if (bootinfo_get(BI_SUBNET_MASK, str, &len, NULL) == BI_E_SUCCESS &&
1289             (in_addr.s_addr = inet_addr(str)) != (in_addr_t)-1) {
1290                 in_addr.s_addr = htonl(in_addr.s_addr);
1291                 ipv4_setnetmask(&in_addr);
1292         }
1293 
1294         len = sizeof (str);
1295         if (bootinfo_get(BI_ROUTER_IP, str, &len, NULL) == BI_E_SUCCESS &&
1296             (in_addr.s_addr = inet_addr(str)) != (in_addr_t)-1) {
1297                 in_addr.s_addr = htonl(in_addr.s_addr);
1298                 ipv4_setdefaultrouter(&in_addr);
1299                 (void) ipv4_route(IPV4_ADD_ROUTE, RT_DEFAULT, NULL, &in_addr);
1300         }
1301 
1302         len = sizeof (str);
1303         if (bootinfo_get(BI_HOSTNAME, str, &len, NULL) == BI_E_SUCCESS) {
1304                 (void) sethostname(str, len);
1305         }
1306 }
1307 
1308 /* EXPORT DELETE END */
1309 boolean_t
1310 wanboot_init_interface(char *boot_arguments)
1311 {
1312 /* EXPORT DELETE START */
1313         boolean_t       interactive;
1314         int             which;
1315 
1316 #if     defined(__sparcv9)
1317         /*
1318          * Get the keys from PROM before we allow the user
1319          * to override them from the CLI.
1320          */
1321         get_prom_encr_keys();
1322         get_prom_hash_keys();
1323 #endif  /* defined(__sparcv9) */
1324 
1325         /*
1326          * If there is already a bootp-response property under
1327          * /chosen then the PROM must have done DHCP for us;
1328          * invoke dhcp() to 'bind' the interface.
1329          */
1330         if (bootinfo_get(BI_BOOTP_RESPONSE, NULL, NULL, NULL) ==
1331             BI_E_BUF2SMALL) {
1332                 (void) cldhcp(NULL, NULL, 0);


1388                             "interface incorrectly configured");
1389                         return (B_FALSE);
1390                 }
1391         }
1392 
1393         /*
1394          * If a wanboot-enabled PROM hasn't processed client-id in
1395          * network-boot-arguments, or no value for client-id has been
1396          * specified to the boot interpreter, then provide a default
1397          * client-id based on our MAC address.
1398          */
1399         generate_default_clientid();
1400 
1401         /*
1402          * If net-config-strategy == "manual" then we must setup
1403          * the interface now; if "dhcp" then it will already have
1404          * been setup.
1405          */
1406         if (strcmp(net_config_strategy(), "manual") == 0)
1407                 setup_interface();
1408 /* EXPORT DELETE END */
1409         return (B_TRUE);
1410 }
1411 
1412 boolean_t
1413 wanboot_verify_config(void)
1414 {
1415 /* EXPORT DELETE START */
1416         /*
1417          * Check that the wanboot.conf file defines a valid root_server
1418          * URL, and check that, if given, the boot_logger URL is valid.
1419          */
1420         if (config_incomplete(0, B_FALSE)) {
1421                 bootlog("wanboot", BOOTLOG_CRIT,
1422                     "incomplete boot configuration");
1423                 return (B_FALSE);
1424         }
1425 /* EXPORT DELETE END */
1426         return (B_TRUE);
1427 }


   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #pragma ident   "%Z%%M% %I%     %E% SMI"
  27 

  28 #include <sys/types.h>
  29 #include <sys/param.h>
  30 #include <sys/salib.h>
  31 #include <sys/promif.h>
  32 #include <sys/wanboot_impl.h>
  33 #include <netinet/in.h>
  34 #include <parseURL.h>
  35 #include <bootlog.h>
  36 #include <sys/socket.h>
  37 #include <netinet/inetutil.h>
  38 #include <netinet/dhcp.h>
  39 #include <dhcp_impl.h>
  40 #include <lib/inet/mac.h>
  41 #include <lib/inet/ipv4.h>
  42 #include <lib/inet/dhcpv4.h>
  43 #include <lib/sock/sock_test.h>
  44 #include <sys/sunos_dhcp_class.h>
  45 #include <aes.h>
  46 #include <des3.h>
  47 #include <hmac_sha1.h>
  48 #include <netdb.h>
  49 #include <wanboot_conf.h>
  50 #include <bootinfo.h>

  51 
  52 #include "wbcli.h"
  53 


  54 #define skipspace(p)    while (isspace(*(p))) ++p
  55 
  56 #define skiptext(p)     while (*(p) != '\0' && !isspace(*(p)) && \
  57                             *(p) != '=' && *(p) != ',') ++p
  58 
  59 #define PROMPT          "boot> "
  60 #define TEST_PROMPT     "boot-test> "
  61 
  62 #define CLI_SET         0
  63 #define CLI_FAIL        (-1)
  64 #define CLI_EXIT        (-2)
  65 #define CLI_CONT        (-3)
  66 
  67 #define CLF_CMD         0x00000001      /* builtin command */
  68 #define CLF_ARG         0x00000002      /* boot argument directive */
  69 
  70 #define CLF_IF          0x00000100      /* interface parameter */
  71 #define CLF_BM          0x00000200      /* bootmisc parameter */
  72 
  73 #define CLF_VALSET      0x00010000      /* value set, may be null */


1284         if (bootinfo_get(BI_SUBNET_MASK, str, &len, NULL) == BI_E_SUCCESS &&
1285             (in_addr.s_addr = inet_addr(str)) != (in_addr_t)-1) {
1286                 in_addr.s_addr = htonl(in_addr.s_addr);
1287                 ipv4_setnetmask(&in_addr);
1288         }
1289 
1290         len = sizeof (str);
1291         if (bootinfo_get(BI_ROUTER_IP, str, &len, NULL) == BI_E_SUCCESS &&
1292             (in_addr.s_addr = inet_addr(str)) != (in_addr_t)-1) {
1293                 in_addr.s_addr = htonl(in_addr.s_addr);
1294                 ipv4_setdefaultrouter(&in_addr);
1295                 (void) ipv4_route(IPV4_ADD_ROUTE, RT_DEFAULT, NULL, &in_addr);
1296         }
1297 
1298         len = sizeof (str);
1299         if (bootinfo_get(BI_HOSTNAME, str, &len, NULL) == BI_E_SUCCESS) {
1300                 (void) sethostname(str, len);
1301         }
1302 }
1303 

1304 boolean_t
1305 wanboot_init_interface(char *boot_arguments)
1306 {

1307         boolean_t       interactive;
1308         int             which;
1309 
1310 #if     defined(__sparcv9)
1311         /*
1312          * Get the keys from PROM before we allow the user
1313          * to override them from the CLI.
1314          */
1315         get_prom_encr_keys();
1316         get_prom_hash_keys();
1317 #endif  /* defined(__sparcv9) */
1318 
1319         /*
1320          * If there is already a bootp-response property under
1321          * /chosen then the PROM must have done DHCP for us;
1322          * invoke dhcp() to 'bind' the interface.
1323          */
1324         if (bootinfo_get(BI_BOOTP_RESPONSE, NULL, NULL, NULL) ==
1325             BI_E_BUF2SMALL) {
1326                 (void) cldhcp(NULL, NULL, 0);


1382                             "interface incorrectly configured");
1383                         return (B_FALSE);
1384                 }
1385         }
1386 
1387         /*
1388          * If a wanboot-enabled PROM hasn't processed client-id in
1389          * network-boot-arguments, or no value for client-id has been
1390          * specified to the boot interpreter, then provide a default
1391          * client-id based on our MAC address.
1392          */
1393         generate_default_clientid();
1394 
1395         /*
1396          * If net-config-strategy == "manual" then we must setup
1397          * the interface now; if "dhcp" then it will already have
1398          * been setup.
1399          */
1400         if (strcmp(net_config_strategy(), "manual") == 0)
1401                 setup_interface();

1402         return (B_TRUE);
1403 }
1404 
1405 boolean_t
1406 wanboot_verify_config(void)
1407 {

1408         /*
1409          * Check that the wanboot.conf file defines a valid root_server
1410          * URL, and check that, if given, the boot_logger URL is valid.
1411          */
1412         if (config_incomplete(0, B_FALSE)) {
1413                 bootlog("wanboot", BOOTLOG_CRIT,
1414                     "incomplete boot configuration");
1415                 return (B_FALSE);
1416         }

1417         return (B_TRUE);
1418 }