1 /* $NetBSD: nfsdiskless.h,v 1.33 2024/12/07 02:05:55 riastradh Exp $ */ 2 3 /*- 4 * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Adam Glass and Gordon W. Ross. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 * @(#)nfsdiskless.h 8.1 (Berkeley) 6/10/93 32 */ 33 34 #ifndef _NFS_NFSDISKLESS_H_ 35 #define _NFS_NFSDISKLESS_H_ 36 37 #include <sys/types.h> 38 39 #include <sys/mount.h> 40 #include <sys/socket.h> 41 42 #include <netinet/in.h> 43 44 #include <nfs/nfsmount.h> 45 #include <nfs/nfsproto.h> 46 47 struct ifnet; 48 49 /* 50 * Structure holds parameters needed by nfs_mountroot(), 51 * which are filled in by nfs_boot_init() using either 52 * BOOTP (RFC951, RFC1048) or Sun RPC/bootparams. These 53 * parameters are INET specific because nfs_boot_init() 54 * currently supports only AF_INET protocols. 55 * 56 * NB: All fields are stored in net byte order to avoid hassles 57 * with client/server byte ordering differences. 58 */ 59 struct nfs_dlmount { 60 struct nfs_args ndm_args; 61 struct sockaddr ndm_saddr; /* Address of file server */ 62 char ndm_host[MNAMELEN]; /* server:pathname */ 63 u_char ndm_fh[NFSX_V3FHMAX]; /* The file's file handle */ 64 }; 65 struct nfs_diskless { 66 /* the interface used */ 67 struct ifnet *nd_ifp; 68 /* A collection of IP addresses, for convenience. */ 69 struct in_addr nd_myip; /* My IP address */ 70 struct in_addr nd_mask; /* My netmask */ 71 struct in_addr nd_gwip; /* My gateway */ 72 int nd_mtu; /* Interface MTU */ 73 /* Information for each mount point we need. */ 74 struct nfs_dlmount nd_root; /* Mount info for root */ 75 #ifdef TFTPROOT 76 char nd_bootfile[MNAMELEN]; /* Boot file */ 77 int nd_nomount; 78 #endif 79 }; 80 81 #ifdef _KERNEL 82 struct lwp; 83 84 int nfs_boot_init(struct nfs_diskless *, struct lwp *); 85 void nfs_boot_cleanup(struct nfs_diskless *, struct lwp *); 86 int nfs_boot_ifupdown(struct ifnet *, struct lwp *, int); 87 int nfs_boot_setaddress(struct ifnet *, struct lwp *, 88 uint32_t, uint32_t, uint32_t); 89 void nfs_boot_setmtu (struct ifnet *, int, struct lwp *); 90 int nfs_boot_deladdress(struct ifnet *, struct lwp *, uint32_t); 91 void nfs_boot_flushrt(struct ifnet *); 92 int nfs_boot_setrecvtimo(struct socket *); 93 int nfs_boot_enbroadcast(struct socket *); 94 int nfs_boot_sobind_ipport(struct socket *, uint16_t, struct lwp *); 95 int nfs_boot_sendrecv(struct socket *, struct sockaddr_in *, 96 int (*)(struct mbuf *, void*, int), struct mbuf *, 97 int (*)(struct mbuf **, void*), struct mbuf **, 98 struct mbuf **, void*, struct lwp *); 99 100 int nfs_bootdhcp(struct nfs_diskless *, struct lwp *, int *); 101 int nfs_bootparam(struct nfs_diskless *, struct lwp *, int *); 102 int nfs_bootstatic(struct nfs_diskless *, struct lwp *, int *); 103 104 extern int (*nfs_bootstatic_callback)(struct nfs_diskless *); 105 106 #define NFS_BOOT_HAS_MYIP 0x01 107 #define NFS_BOOT_HAS_GWIP 0x02 108 #define NFS_BOOT_HAS_MASK 0x04 109 #define NFS_BOOT_HAS_SERVADDR 0x08 110 #define NFS_BOOT_HAS_SERVER 0x10 111 #define NFS_BOOT_NOSTATIC 0x20 112 #define NFS_BOOT_HAS_ROOTPATH 0x40 113 114 #define NFS_BOOT_ALLINFO \ 115 (NFS_BOOT_HAS_MYIP|NFS_BOOT_HAS_GWIP|NFS_BOOT_HAS_MASK| \ 116 NFS_BOOT_HAS_SERVADDR|NFS_BOOT_HAS_SERVER|NFS_BOOT_HAS_ROOTPATH) 117 118 #endif /* _KERNEL */ 119 120 #endif /* _NFS_NFSDISKLESS_H_ */ 121