If compiled for the system installation program, prompt for myip, gateip,

netmask, serverip, and path rather than using rarp/bootparam.

Catch up with libsa changes.
This commit is contained in:
thorpej 1995-09-23 17:31:10 +00:00
parent d429f2e11f
commit a35f639de0
1 changed files with 76 additions and 12 deletions

View File

@ -1,6 +1,7 @@
/* $NetBSD: netio.c,v 1.1 1995/09/02 05:04:21 thorpej Exp $ */
/* $NetBSD: netio.c,v 1.2 1995/09/23 17:31:10 thorpej Exp $ */
/*
* Copyright (c) 1995 Jason R. Thorpe
* Copyright (c) 1995 Gordon W. Ross
* All rights reserved.
*
@ -59,15 +60,21 @@
#include "net.h"
#include "netif.h"
#include "bootparam.h"
#include "nfs.h"
extern int nfs_root_node[]; /* XXX - get from nfs_mount() */
u_int32_t myip, rootip, gateip, mask;
struct in_addr myip, rootip, gateip;
n_long netmask;
char rootpath[FNAME_SIZE];
int netdev_sock = -1;
static int open_count;
#ifdef SYS_INST
static char input_line[100];
#endif
/* Why be any different? */
#define SUN_BOOTPARAMS
@ -124,11 +131,64 @@ netmountroot(f, devname)
char *devname; /* Device part of file name (or NULL). */
{
int error;
#ifdef SYS_INST
struct iodesc *d;
#endif
#ifdef DEBUG
printf("netmountroot: %s\n", devname);
#endif
#ifdef SYS_INST
get_my_ip:
printf("My IP address? ");
bzero(input_line, sizeof(input_line));
gets(input_line);
if ((myip.s_addr = inet_addr(input_line)) == htonl(INADDR_NONE)) {
printf("invalid IP address: %s\n", input_line);
goto get_my_ip;
}
get_my_netmask:
printf("My netmask? ");
bzero(input_line, sizeof(input_line));
gets(input_line);
if ((netmask = inet_addr(input_line)) == htonl(INADDR_NONE)) {
printf("invalid netmask: %s\n", input_line);
goto get_my_netmask;
}
get_my_gateway:
printf("My gateway? ");
bzero(input_line, sizeof(input_line));
gets(input_line);
if ((gateip.s_addr = inet_addr(input_line)) == htonl(INADDR_NONE)) {
printf("invalid IP address: %s\n", input_line);
goto get_my_gateway;
}
get_server_ip:
printf("Server IP address? ");
bzero(input_line, sizeof(input_line));
gets(input_line);
if ((rootip.s_addr = inet_addr(input_line)) == htonl(INADDR_NONE)) {
printf("invalid IP address: %s\n", input_line);
goto get_server_ip;
}
get_server_path:
printf("Server path? ");
bzero(rootpath, sizeof(rootpath));
gets(rootpath);
if (rootpath[0] == '\0' || rootpath[0] == '\n')
goto get_server_path;
if ((d = socktodesc(netdev_sock)) == NULL)
return (EMFILE);
d->myip = myip;
#else /* SYS_INST */
/*
* Get info for NFS boot: our IP address, our hostname,
* server IP address, and our root path on the server.
@ -140,36 +200,40 @@ netmountroot(f, devname)
/* Get boot info using RARP and Sun bootparams. */
/* Get our IP address. (rarp.c) */
if ((myip = rarp_getipaddress(netdev_sock)) == 0)
return (EIO);
printf("boot: client IP address: %s\n", intoa(myip));
if (rarp_getipaddress(netdev_sock) == -1)
return (errno);
printf("boot: client IP address: %s\n", inet_ntoa(myip));
/* Get our hostname, server IP address. */
if (bp_whoami(netdev_sock))
return (EIO);
return (errno);
printf("boot: client name: %s\n", hostname);
/* Get the root pathname. */
if (bp_getfile(netdev_sock, "root", &rootip, rootpath))
return (EIO);
return (errno);
#else
/* Get boot info using BOOTP way. (RFC951, RFC1048) */
bootp(netdev_sock);
printf("Using IP address: %s\n", intoa(myip));
printf("Using IP address: %s\n", inet_ntoa(myip));
printf("myip: %s (%s)", hostname, intoa(myip));
printf("myip: %s (%s)", hostname, inet_ntoa(myip));
if (gateip)
printf(", gateip: %s", intoa(gateip));
printf(", gateip: %s", inet_ntoa(gateip));
if (mask)
printf(", mask: %s", intoa(mask));
printf(", mask: %s", intoa(netmask));
printf("\n");
#endif /* SUN_BOOTPARAMS */
printf("root addr=%s path=%s\n", intoa(rootip), rootpath);
printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath);
#endif /* SYS_INST */
/* Get the NFS file handle (mount). */
error = nfs_mount(netdev_sock, rootip, rootpath);