diff options
Diffstat (limited to 'c/src/exec/libnetworking/nfs')
-rw-r--r-- | c/src/exec/libnetworking/nfs/.cvsignore | 2 | ||||
-rw-r--r-- | c/src/exec/libnetworking/nfs/Makefile.am | 47 | ||||
-rw-r--r-- | c/src/exec/libnetworking/nfs/bootp_subr.c | 1144 | ||||
-rw-r--r-- | c/src/exec/libnetworking/nfs/krpc.h | 26 | ||||
-rw-r--r-- | c/src/exec/libnetworking/nfs/nfs.h | 620 | ||||
-rw-r--r-- | c/src/exec/libnetworking/nfs/nfsdiskless.h | 100 | ||||
-rw-r--r-- | c/src/exec/libnetworking/nfs/nfsproto.h | 441 | ||||
-rw-r--r-- | c/src/exec/libnetworking/nfs/rpcv2.h | 142 | ||||
-rw-r--r-- | c/src/exec/libnetworking/nfs/xdr_subs.h | 90 |
9 files changed, 0 insertions, 2612 deletions
diff --git a/c/src/exec/libnetworking/nfs/.cvsignore b/c/src/exec/libnetworking/nfs/.cvsignore deleted file mode 100644 index 282522db03..0000000000 --- a/c/src/exec/libnetworking/nfs/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/c/src/exec/libnetworking/nfs/Makefile.am b/c/src/exec/libnetworking/nfs/Makefile.am deleted file mode 100644 index 8d213b78fc..0000000000 --- a/c/src/exec/libnetworking/nfs/Makefile.am +++ /dev/null @@ -1,47 +0,0 @@ -## -## $Id$ -## - - -include_nfsdir = $(includedir)/nfs - -LIBNAME = lib.a -LIB = $(ARCH)/$(LIBNAME) - -C_FILES = bootp_subr.c -C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) - -OBJS = $(C_O_FILES) - -include $(top_srcdir)/../automake/multilib.am -include $(top_srcdir)/../automake/compile.am -include $(top_srcdir)/../automake/lib.am - -# -# Add local stuff here using += -# - -AM_CPPFLAGS += -D_COMPILING_BSD_KERNEL_ -DKERNEL -DINET -DNFS -DDIAGNOSTIC \ - -DBOOTP_COMPAT - -$(LIB): $(OBJS) - $(make-library) - -all-local: $(PREINSTALL_FILES) $(ARCH) $(OBJS) $(LIB) - -.PRECIOUS: $(LIB) - -EXTRA_DIST = bootp_subr.c - -include_nfs_HEADERS = krpc.h nfs.h nfsdiskless.h nfsproto.h rpcv2.h xdr_subs.h - -PREINSTALL_FILES = $(PROJECT_INCLUDE)/nfs \ - $(include_nfs_HEADERS:%=$(PROJECT_INCLUDE)/nfs/%) - -$(PROJECT_INCLUDE)/nfs: - @$(mkinstalldirs) $@ - -$(PROJECT_INCLUDE)/nfs/%.h: %.h - $(INSTALL_DATA) $< $@ - -include $(top_srcdir)/../automake/local.am diff --git a/c/src/exec/libnetworking/nfs/bootp_subr.c b/c/src/exec/libnetworking/nfs/bootp_subr.c deleted file mode 100644 index ceb471dad0..0000000000 --- a/c/src/exec/libnetworking/nfs/bootp_subr.c +++ /dev/null @@ -1,1144 +0,0 @@ -/* $Id$ */ - -/* - * Copyright (c) 1995 Gordon Ross, Adam Glass - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * based on: - * nfs/krpc_subr.c - * $NetBSD: krpc_subr.c,v 1.10 1995/08/08 20:43:43 gwr Exp $ - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/conf.h> -#include <sys/sockio.h> -#include <sys/proc.h> -#include <sys/mount.h> -#include <sys/mbuf.h> -#include <sys/reboot.h> -#include <sys/socket.h> -#include <sys/socketvar.h> - -#include <net/if.h> -#include <net/route.h> - -#include <netinet/in.h> -#include <net/if_types.h> -#include <net/if_dl.h> -#include <netinet/if_ether.h> - -#include <nfs/rpcv2.h> -#include <nfs/nfsproto.h> -#include <nfs/nfs.h> -#include <nfs/nfsdiskless.h> -#include <nfs/krpc.h> -#include <nfs/xdr_subs.h> - -#include <sys/stat.h> -#include <sys/types.h> -#include <fcntl.h> -#include <rtems/mkrootfs.h> - -#define BOOTP_MIN_LEN 300 /* Minimum size of bootp udp packet */ - -/* - * What is the longest we will wait before re-sending a request? - * Note this is also the frequency of "RPC timeout" messages. - * The re-send loop count sup linearly to this maximum, so the - * first complaint will happen after (1+2+3+4+5)=15 seconds. - */ -#define MAX_RESEND_DELAY 5 /* seconds */ - -/* Definitions from RFC951 */ -struct bootp_packet { - u_int8_t op; - u_int8_t htype; - u_int8_t hlen; - u_int8_t hops; - u_int32_t xid; - u_int16_t secs; - u_int16_t flags; - struct in_addr ciaddr; - struct in_addr yiaddr; - struct in_addr siaddr; - struct in_addr giaddr; - unsigned char chaddr[16]; - char sname[64]; - char file[128]; - unsigned char vend[256]; -}; - -#define IPPORT_BOOTPC 68 -#define IPPORT_BOOTPS 67 - -extern int nfs_diskless_valid; -extern struct nfsv3_diskless nfsv3_diskless; - -/* mountd RPC */ -#if !defined(__rtems__) -static int md_mount __P((struct sockaddr_in *mdsin, char *path, - u_char *fhp, int *fhsizep, struct nfs_args *args,struct proc *procp)); -static int md_lookup_swap __P((struct sockaddr_in *mdsin,char *path, - u_char *fhp, int *fhsizep, - struct nfs_args *args, - struct proc *procp)); -static int setfs __P((struct sockaddr_in *addr, char *path, char *p)); -static int getdec __P((char **ptr)); -#endif -static char *substr __P((char *a,char *b)); -#if !defined(__rtems__) -static void mountopts __P((struct nfs_args *args, char *p)); -static int xdr_opaque_decode __P((struct mbuf **ptr,u_char *buf, - int len)); -static int xdr_int_decode __P((struct mbuf **ptr,int *iptr)); -#endif -static void printip __P((char *prefix,struct in_addr addr)); - -#ifdef BOOTP_DEBUG -void bootpboot_p_sa(struct sockaddr *sa,struct sockaddr *ma); -void bootpboot_p_ma(struct sockaddr *ma); -void bootpboot_p_rtentry(struct rtentry *rt); -void bootpboot_p_tree(struct radix_node *rn); -void bootpboot_p_rtlist(void); -void bootpboot_p_iflist(void); -#endif - -int bootpc_call(struct bootp_packet *call, - struct bootp_packet *reply, - struct proc *procp); - -int bootpc_fakeup_interface(struct ifreq *ireq,struct socket *so, - struct proc *procp); - -int -bootpc_adjust_interface(struct ifreq *ireq,struct socket *so, - struct sockaddr_in *myaddr, - struct sockaddr_in *netmask, - struct sockaddr_in *gw, - struct proc *procp); - -void bootpc_init(int update_files); - -#ifdef BOOTP_DEBUG -void bootpboot_p_sa(sa,ma) - struct sockaddr *sa; - struct sockaddr *ma; -{ - if (!sa) { - printf("(sockaddr *) <null>"); - return; - } - switch (sa->sa_family) { - case AF_INET: - { - struct sockaddr_in *sin = (struct sockaddr_in *) sa; - printf("inet %x",ntohl(sin->sin_addr.s_addr)); - if (ma) { - struct sockaddr_in *sin = (struct sockaddr_in *) ma; - printf(" mask %x",ntohl(sin->sin_addr.s_addr)); - } - } - break; - case AF_LINK: - { - struct sockaddr_dl *sli = (struct sockaddr_dl *) sa; - int i; - printf("link %.*s ",sli->sdl_nlen,sli->sdl_data); - for (i=0;i<sli->sdl_alen;i++) { - if (i>0) - printf(":"); - printf("%x",(unsigned char) sli->sdl_data[i+sli->sdl_nlen]); - } - } - break; - default: - printf("af%d",sa->sa_family); - } -} - -void bootpboot_p_ma(ma) - struct sockaddr *ma; -{ - if (!ma) { - printf("<null>"); - return; - } - printf("%x",*(int*)ma); -} - -void bootpboot_p_rtentry(rt) - struct rtentry *rt; -{ - bootpboot_p_sa(rt_key(rt),rt_mask(rt)); - printf(" "); - bootpboot_p_ma(rt->rt_genmask); - printf(" "); - bootpboot_p_sa(rt->rt_gateway,NULL); - printf(" "); - printf("flags %x",(unsigned short) rt->rt_flags); - printf(" %d",rt->rt_rmx.rmx_expire); - printf(" %s%d\n",rt->rt_ifp->if_name,rt->rt_ifp->if_unit); -} -void bootpboot_p_tree(rn) - struct radix_node *rn; -{ - while (rn) { - if (rn->rn_b < 0) { - if (rn->rn_flags & RNF_ROOT) { - } else { - bootpboot_p_rtentry((struct rtentry *) rn); - } - rn = rn->rn_dupedkey; - } else { - bootpboot_p_tree(rn->rn_l); - bootpboot_p_tree(rn->rn_r); - return; - } - - } -} - -void bootpboot_p_rtlist(void) -{ - printf("Routing table:\n"); - bootpboot_p_tree(rt_tables[AF_INET]->rnh_treetop); -} - -void bootpboot_p_iflist(void) -{ - struct ifnet *ifp; - struct ifaddr *ifa; - printf("Interface list:\n"); - for (ifp = TAILQ_FIRST(&ifnet); ifp != 0; ifp = TAILQ_NEXT(ifp,if_link)) - { - for (ifa = TAILQ_FIRST(&ifp->if_addrhead) ;ifa; - ifa=TAILQ_NEXT(ifa,ifa_link)) - if (ifa->ifa_addr->sa_family == AF_INET ) { - printf("%s%d flags %x, addr %x, bcast %x, net %x\n", - ifp->if_name,ifp->if_unit, - (unsigned short) ifp->if_flags, - ntohl(((struct sockaddr_in *) ifa->ifa_addr)->sin_addr.s_addr), - ntohl(((struct sockaddr_in *) ifa->ifa_dstaddr)->sin_addr.s_addr), - ntohl(((struct sockaddr_in *) ifa->ifa_netmask)->sin_addr.s_addr) - ); - } - } -} -#endif - -/* - * - determine space needed to store src string - * - allocate or reallocate dst, so that string fits in - * - copy string from src to dest - */ -void *bootp_strdup_realloc(char *dst,const char *src) -{ - size_t len; - void *realloc(void * __r, size_t __size); - - if (dst == NULL) { - /* first allocation, simply use strdup */ - dst = strdup(src); - } - else { - /* already allocated, so use realloc/strcpy */ - len = strlen(src) + 1; - dst = realloc(dst,len); - if (dst != NULL) { - strcpy(dst,src); - } - } - return dst; -} - -int -bootpc_call(call,reply,procp) - struct bootp_packet *call; - struct bootp_packet *reply; /* output */ - struct proc *procp; -{ - struct socket *so; - struct sockaddr_in *sin; - struct mbuf *m, *nam; - struct uio auio; - struct iovec aio; - int error, rcvflg, timo, secs, len; - - /* Free at end if not null. */ - nam = NULL; - - /* - * Create socket and set its recieve timeout. - */ - if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0,procp))) - goto out; - - m = m_get(M_WAIT, MT_SOOPTS); - if (m == NULL) { - error = ENOBUFS; - goto out; - } else { - struct timeval *tv; - tv = mtod(m, struct timeval *); - m->m_len = sizeof(*tv); - tv->tv_sec = 1; - tv->tv_usec = 0; - if ((error = sosetopt(so, SOL_SOCKET, SO_RCVTIMEO, m))) - goto out; - } - - /* - * Enable broadcast. - */ - { - int *on; - m = m_get(M_WAIT, MT_SOOPTS); - if (m == NULL) { - error = ENOBUFS; - goto out; - } - on = mtod(m, int *); - m->m_len = sizeof(*on); - *on = 1; - if ((error = sosetopt(so, SOL_SOCKET, SO_BROADCAST, m))) - goto out; - } - - /* - * Bind the local endpoint to a bootp client port. - */ - m = m_getclr(M_WAIT, MT_SONAME); - sin = mtod(m, struct sockaddr_in *); - sin->sin_len = m->m_len = sizeof(*sin); - sin->sin_family = AF_INET; - sin->sin_addr.s_addr = INADDR_ANY; - sin->sin_port = htons(IPPORT_BOOTPC); - error = sobind(so, m); - m_freem(m); - if (error) { - printf("bind failed\n"); - goto out; - } - - /* - * Setup socket address for the server. - */ - nam = m_get(M_WAIT, MT_SONAME); - if (nam == NULL) { - error = ENOBUFS; - goto out; - } - sin = mtod(nam, struct sockaddr_in *); - sin-> sin_len = sizeof(*sin); - sin-> sin_family = AF_INET; - sin->sin_addr.s_addr = INADDR_BROADCAST; - sin->sin_port = htons(IPPORT_BOOTPS); - - nam->m_len = sizeof(*sin); - - /* - * Send it, repeatedly, until a reply is received, - * but delay each re-send by an increasing amount. - * If the delay hits the maximum, start complaining. - */ - timo = 0; - for (;;) { - /* Send BOOTP request (or re-send). */ - - aio.iov_base = (caddr_t) call; - aio.iov_len = sizeof(*call); - - auio.uio_iov = &aio; - auio.uio_iovcnt = 1; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_rw = UIO_WRITE; - auio.uio_offset = 0; - auio.uio_resid = sizeof(*call); - auio.uio_procp = procp; - - error = sosend(so, nam, &auio, NULL, NULL, 0); - if (error) { - printf("bootpc_call: sosend: %d\n", error); - goto out; - } - - /* Determine new timeout. */ - if (timo < MAX_RESEND_DELAY) - timo++; - else - printf("BOOTP timeout for server 0x%x\n", - (int)ntohl(sin->sin_addr.s_addr)); - - /* - * Wait for up to timo seconds for a reply. - * The socket receive timeout was set to 1 second. - */ - secs = timo; - while (secs > 0) { - aio.iov_base = (caddr_t) reply; - aio.iov_len = sizeof(*reply); - - auio.uio_iov = &aio; - auio.uio_iovcnt = 1; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_rw = UIO_READ; - auio.uio_offset = 0; - auio.uio_resid = sizeof(*reply); - auio.uio_procp = procp; - - rcvflg = 0; - error = soreceive(so, NULL, &auio, NULL, NULL, &rcvflg); - if (error == EWOULDBLOCK) { - secs--; - call->secs=htons(ntohs(call->secs)+1); - continue; - } - if (error) - goto out; - len = sizeof(*reply) - auio.uio_resid; - - /* Do we have the required number of bytes ? */ - if (len < BOOTP_MIN_LEN) - continue; - - /* Is it the right reply? */ - if (reply->op != 2) - continue; - - if (reply->xid != call->xid) - continue; - - if (reply->hlen != call->hlen) - continue; - - if (bcmp(reply->chaddr,call->chaddr,call->hlen)) - continue; - - goto gotreply; /* break two levels */ - - } /* while secs */ - } /* forever send/receive */ - - error = ETIMEDOUT; - goto out; - - gotreply: - out: - if (nam) m_freem(nam); - soclose(so); - return error; -} - -int -bootpc_fakeup_interface(struct ifreq *ireq,struct socket *so, - struct proc *procp) -{ - struct sockaddr_in *sin; - int error; - struct sockaddr_in dst; - struct sockaddr_in gw; - struct sockaddr_in mask; - - /* - * Bring up the interface. - * - * Get the old interface flags and or IFF_UP into them; if - * IFF_UP set blindly, interface selection can be clobbered. - */ - error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)ireq, procp); - if (error) - panic("bootpc_fakeup_interface: GIFFLAGS, error=%d", error); - ireq->ifr_flags |= IFF_UP; - error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)ireq, procp); - if (error) - panic("bootpc_fakeup_interface: SIFFLAGS, error=%d", error); - - /* - * Do enough of ifconfig(8) so that the chosen interface - * can talk to the servers. (just set the address) - */ - - /* addr is 0.0.0.0 */ - - sin = (struct sockaddr_in *)&ireq->ifr_addr; - bzero((caddr_t)sin, sizeof(*sin)); - sin->sin_len = sizeof(*sin); - sin->sin_family = AF_INET; - sin->sin_addr.s_addr = INADDR_ANY; - error = ifioctl(so, SIOCSIFADDR, (caddr_t)ireq, procp); - if (error) - panic("bootpc_fakeup_interface: set if addr, error=%d", error); - - /* netmask is 0.0.0.0 */ - - sin = (struct sockaddr_in *)&ireq->ifr_addr; - bzero((caddr_t)sin, sizeof(*sin)); - sin->sin_len = sizeof(*sin); - sin->sin_family = AF_INET; - sin->sin_addr.s_addr = INADDR_ANY; - error = ifioctl(so, SIOCSIFNETMASK, (caddr_t)ireq, procp); - if (error) - panic("bootpc_fakeup_interface: set if net addr, error=%d", error); - - /* Broadcast is 255.255.255.255 */ - - sin = (struct sockaddr_in *)&ireq->ifr_addr; - bzero((caddr_t)sin, sizeof(*sin)); - sin->sin_len = sizeof(*sin); - sin->sin_family = AF_INET; - sin->sin_addr.s_addr = INADDR_BROADCAST; - error = ifioctl(so, SIOCSIFBRDADDR, (caddr_t)ireq, procp); - if (error) - panic("bootpc_fakeup_interface: set if broadcast addr, error=%d", error); - - /* Add default route to 0.0.0.0 so we can send data */ - - bzero((caddr_t) &dst, sizeof(dst)); - dst.sin_len=sizeof(dst); - dst.sin_family=AF_INET; - dst.sin_addr.s_addr = htonl(0); - - bzero((caddr_t) &gw, sizeof(gw)); - gw.sin_len=sizeof(gw); - gw.sin_family=AF_INET; - gw.sin_addr.s_addr = htonl(0x0); - - bzero((caddr_t) &mask, sizeof(mask)); - mask.sin_len=sizeof(mask); - mask.sin_family=AF_INET; - mask.sin_addr.s_addr = htonl(0); - - error = rtrequest(RTM_ADD, - (struct sockaddr *) &dst, - (struct sockaddr *) &gw, - (struct sockaddr *) &mask, - RTF_UP | RTF_STATIC - , NULL); - if (error) - printf("bootpc_fakeup_interface: add default route, error=%d\n", error); - return error; -} - -int -bootpc_adjust_interface(struct ifreq *ireq,struct socket *so, - struct sockaddr_in *myaddr, - struct sockaddr_in *netmask, - struct sockaddr_in *gw, - struct proc *procp) -{ - int error; - struct sockaddr_in oldgw; - struct sockaddr_in olddst; - struct sockaddr_in oldmask; - struct sockaddr_in *sin; - - /* Remove old default route to 0.0.0.0 */ - - bzero((caddr_t) &olddst, sizeof(olddst)); - olddst.sin_len=sizeof(olddst); - olddst.sin_family=AF_INET; - olddst.sin_addr.s_addr = INADDR_ANY; - - bzero((caddr_t) &oldgw, sizeof(oldgw)); - oldgw.sin_len=sizeof(oldgw); - oldgw.sin_family=AF_INET; - oldgw.sin_addr.s_addr = INADDR_ANY; - - bzero((caddr_t) &oldmask, sizeof(oldmask)); - oldmask.sin_len=sizeof(oldmask); - oldmask.sin_family=AF_INET; - oldmask.sin_addr.s_addr = INADDR_ANY; - - error = rtrequest(RTM_DELETE, - (struct sockaddr *) &olddst, - (struct sockaddr *) &oldgw, - (struct sockaddr *) &oldmask, - (RTF_UP | RTF_STATIC), NULL); - if (error) { - printf("nfs_boot: del default route, error=%d\n", error); - return error; - } - - /* - * Do enough of ifconfig(8) so that the chosen interface - * can talk to the servers. (just set the address) - */ - bcopy(netmask,&ireq->ifr_addr,sizeof(*netmask)); - error = ifioctl(so, SIOCSIFNETMASK, (caddr_t)ireq, procp); - if (error) - panic("nfs_boot: set if netmask, error=%d", error); - - /* Broadcast is with host part of IP address all 1's */ - - sin = (struct sockaddr_in *)&ireq->ifr_addr; - bzero((caddr_t)sin, sizeof(*sin)); - sin->sin_len = sizeof(*sin); - sin->sin_family = AF_INET; - sin->sin_addr.s_addr = myaddr->sin_addr.s_addr | ~ netmask->sin_addr.s_addr; - error = ifioctl(so, SIOCSIFBRDADDR, (caddr_t)ireq, procp); - if (error) - panic("bootpc_call: set if broadcast addr, error=%d", error); - - bcopy(myaddr,&ireq->ifr_addr,sizeof(*myaddr)); - error = ifioctl(so, SIOCSIFADDR, (caddr_t)ireq, procp); - if (error) - panic("nfs_boot: set if addr, error=%d", error); - - /* Add new default route */ - - error = rtrequest(RTM_ADD, - (struct sockaddr *) &olddst, - (struct sockaddr *) gw, - (struct sockaddr *) &oldmask, - (RTF_UP | RTF_GATEWAY | RTF_STATIC), NULL); - if (error) { - printf("nfs_boot: add net route, error=%d\n", error); - return error; - } - - return 0; -} - -#if !defined(__rtems__) -static int setfs(addr, path, p) - struct sockaddr_in *addr; - char *path; - char *p; -{ - unsigned ip = 0; - int val; - - if (((val = getdec(&p)) < 0) || (val > 255)) return(0); - ip = val << 24; - if (*p != '.') return(0); - p++; - if (((val = getdec(&p)) < 0) || (val > 255)) return(0); - ip |= (val << 16); - if (*p != '.') return(0); - p++; - if (((val = getdec(&p)) < 0) || (val > 255)) return(0); - ip |= (val << 8); - if (*p != '.') return(0); - p++; - if (((val = getdec(&p)) < 0) || (val > 255)) return(0); - ip |= val; - if (*p != ':') return(0); - p++; - - addr->sin_addr.s_addr = htonl(ip); - addr->sin_len = sizeof(struct sockaddr_in); - addr->sin_family = AF_INET; - - strncpy(path,p,MNAMELEN-1); - return(1); -} -#endif - -static int getdec(ptr) - char **ptr; -{ - char *p = *ptr; - int ret=0; - if ((*p < '0') || (*p > '9')) return(-1); - while ((*p >= '0') && (*p <= '9')) { - ret = ret*10 + (*p - '0'); - p++; - } - *ptr = p; - return(ret); -} - -static char *substr(a,b) - char *a,*b; -{ - char *loc1; - char *loc2; - - while (*a != '\0') { - loc1 = a; - loc2 = b; - while (*loc1 == *loc2++) { - if (*loc1 == '\0') return (0); - loc1++; - if (*loc2 == '\0') return (loc1); - } - a++; - } - return (0); -} - -static void printip(char *prefix,struct in_addr addr) -{ - unsigned int ip; - - ip = ntohl(addr.s_addr); - - printf("%s is %d.%d.%d.%d\n",prefix, - ip >> 24, (ip >> 16) & 255 ,(ip >> 8) & 255 ,ip & 255 ); -} - -static int dhcpOptionOverload = 0; -static char dhcp_gotgw = 0; -static char dhcp_gotnetmask = 0; -static char dhcp_gotserver = 0; -static char dhcp_gotlogserver = 0; -static struct sockaddr_in dhcp_netmask; -static struct sockaddr_in dhcp_gw; -static char *dhcp_hostname = NULL; - -static void -processOptions (unsigned char *optbuf, int optbufSize) -{ - int j = 0; - int len; - int code, ncode; - char *p; - - ncode = optbuf[0]; - while (j < optbufSize) { - code = optbuf[j] = ncode; - if (code == 255) - return; - if (code == 0) { - j++; - continue; - } - len = optbuf[j+1]; - j += 2; - if ((len + j) >= optbufSize) { - printf ("Truncated field for code %d", code); - return; - } - ncode = optbuf[j+len]; - optbuf[j+len] = '\0'; - p = &optbuf[j]; - j += len; - - /* - * Process the option - */ - switch (code) { - case 1: - /* Subnet mask */ - if (len!=4) - panic("bootpc: subnet mask len is %d",len); - bcopy (p, &dhcp_netmask.sin_addr, 4); - dhcp_gotnetmask = 1; - break; - - case 2: - /* Time offset */ - if (len!=4) - panic("bootpc: time offset len is %d",len); - bcopy (p, &rtems_bsdnet_timeoffset, 4); - rtems_bsdnet_timeoffset = ntohl (rtems_bsdnet_timeoffset); - break; - - case 3: - /* Routers */ - if (len % 4) - panic ("bootpc: Router Len is %d", len); - if (len > 0) { - bcopy(p, &dhcp_gw.sin_addr, 4); - dhcp_gotgw = 1; - } - break; - - case 42: - /* NTP servers */ - if (len % 4) - panic ("bootpc: time server Len is %d", len); - { - int tlen = 0; - while ((tlen < len) && - (rtems_bsdnet_ntpserver_count < sizeof rtems_bsdnet_config.ntp_server / - sizeof rtems_bsdnet_config.ntp_server[0])) { - bcopy (p+tlen, - &rtems_bsdnet_ntpserver[rtems_bsdnet_ntpserver_count], - 4); - printip("Time Server", - rtems_bsdnet_ntpserver[rtems_bsdnet_ntpserver_count]); - rtems_bsdnet_ntpserver_count++; - tlen += 4; - } - } - break; - - case 6: - /* Domain Name servers */ - if (len % 4) - panic ("bootpc: DNS Len is %d", len); - { - int dlen = 0; - while ((dlen < len) && - (rtems_bsdnet_nameserver_count < sizeof rtems_bsdnet_config.name_server / - sizeof rtems_bsdnet_config.name_server[0])) { - bcopy (p+dlen, - &rtems_bsdnet_nameserver[rtems_bsdnet_nameserver_count], - 4); - printip("Domain Name Server", - rtems_bsdnet_nameserver[rtems_bsdnet_nameserver_count]); - rtems_bsdnet_nameserver_count++; - dlen += 4; - } - } - break; - - case 12: - /* Host name */ - if (len>=MAXHOSTNAMELEN) - panic ("bootpc: hostname >=%d bytes", MAXHOSTNAMELEN); - if (sethostname (p, len) < 0) - panic("Can't set host name"); - printf("Hostname is %s\n", p); - dhcp_hostname = bootp_strdup_realloc(dhcp_hostname,p); - break; - - case 7: - /* Log servers */ - if (len % 4) - panic ("bootpc: Log server Len is %d", len); - if (len > 0) { - bcopy(p, &rtems_bsdnet_log_host_address, 4); - dhcp_gotlogserver = 1; - } - break; - - case 15: - /* Domain name */ - if (p[0]) { - rtems_bsdnet_domain_name = - bootp_strdup_realloc(rtems_bsdnet_domain_name,p); - printf("Domain name is %s\n", rtems_bsdnet_domain_name); - } - break; - - case 16: /* Swap server IP address. unused */ - break; - - case 52: - /* DHCP option override */ - if (len != 1) - panic ("bootpc: DHCP option overload len is %d", len); - dhcpOptionOverload = p[0]; - break; - - case 128: /* Site-specific option for DHCP servers that - * a) don't supply tag 54 - * and - * b) don't supply the server address in siaddr - * For example, on Solaris 2.6 in.dhcpd, include in the dhcptab: - * Bootsrv s Site,128,IP,1,1 - * and use that symbol in the macro that defines the client: - * Bootsrv=<tftp-server-ip-address> - */ - case 54: - /* DHCP server */ - if (len != 4) - panic ("bootpc: DHCP server len is %d", len); - bcopy(p, &rtems_bsdnet_bootp_server_address, 4); - dhcp_gotserver = 1; - break; - - case 66: - /* DHCP server name option */ - if (p[0]) - rtems_bsdnet_bootp_server_name = - bootp_strdup_realloc(rtems_bsdnet_bootp_server_name,p); - break; - - case 67: - /* DHCP bootfile option */ - if (p[0]) - rtems_bsdnet_bootp_boot_file_name = - bootp_strdup_realloc(rtems_bsdnet_bootp_boot_file_name,p); - break; - - default: - printf ("Ignoring BOOTP/DHCP option code %d\n", code); - break; - } - } -} - -#define EALEN 6 - -void -bootpc_init(int update_files) -{ - struct bootp_packet call; - struct bootp_packet reply; - static u_int32_t xid = ~0xFF; - - struct ifreq ireq; - struct ifnet *ifp; - struct socket *so; - int j; - int error; - struct sockaddr_in myaddr; - struct ifaddr *ifa; - struct sockaddr_dl *sdl = NULL; - char *delim; - struct proc *procp = NULL; - - /* - * If already filled in, don't touch it here - */ - if (nfs_diskless_valid) - return; - - /* - * If we are to update the files create the root - * file structure. - */ - if (update_files) - if (rtems_create_root_fs () < 0) { - printf("Error creating the root filesystem.\nFile not created.\n"); - update_files = 0; - } - - dhcp_hostname = NULL; - - /* - * Find a network interface. - */ - for (ifp = ifnet; ifp != 0; ifp = ifp->if_next) - if ((ifp->if_flags & - (IFF_LOOPBACK|IFF_POINTOPOINT)) == 0) - break; - if (ifp == NULL) - panic("bootpc_init: no suitable interface"); - bzero(&ireq,sizeof(ireq)); - sprintf(ireq.ifr_name, "%s%d", ifp->if_name,ifp->if_unit); - printf("bootpc_init: using network interface '%s'\n", - ireq.ifr_name); - - if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0,procp)) != 0) - panic("nfs_boot: socreate, error=%d", error); - - bootpc_fakeup_interface(&ireq,so,procp); - - printf("Bootpc testing starting\n"); - - /* Get HW address */ - - for (ifa = ifp->if_addrlist;ifa; ifa = ifa->ifa_next) - if (ifa->ifa_addr->sa_family == AF_LINK && - (sdl = ((struct sockaddr_dl *) ifa->ifa_addr)) && - sdl->sdl_type == IFT_ETHER) - break; - - if (!sdl) - panic("bootpc: Unable to find HW address"); - if (sdl->sdl_alen != EALEN ) - panic("bootpc: HW address len is %d, expected value is %d", - sdl->sdl_alen,EALEN); - - printf("bootpc hw address is "); - delim=""; - for (j=0;j<sdl->sdl_alen;j++) { - printf("%s%x",delim,((unsigned char *)LLADDR(sdl))[j]); - delim=":"; - } - printf("\n"); - -#if 0 - bootpboot_p_iflist(); - bootpboot_p_rtlist(); -#endif - - bzero((caddr_t) &call, sizeof(call)); - - /* bootpc part */ - call.op = 1; /* BOOTREQUEST */ - call.htype= 1; /* 10mb ethernet */ - call.hlen=sdl->sdl_alen; /* Hardware address length */ - call.hops=0; - xid++; - call.xid = txdr_unsigned(xid); - bcopy(LLADDR(sdl),&call.chaddr,sdl->sdl_alen); - - call.vend[0]=99; - call.vend[1]=130; - call.vend[2]=83; - call.vend[3]=99; - call.vend[4]=255; - - call.secs = 0; - call.flags = htons(0x8000); /* We need an broadcast answer */ - - error = bootpc_call(&call,&reply,procp); - - if (error) - panic("BOOTP call failed -- error %d", error); - - /* - * Initialize network address structures - */ - bzero(&myaddr,sizeof(myaddr)); - bzero(&dhcp_netmask,sizeof(dhcp_netmask)); - bzero(&dhcp_gw,sizeof(dhcp_gw)); - myaddr.sin_len = sizeof(myaddr); - myaddr.sin_family = AF_INET; - dhcp_netmask.sin_len = sizeof(dhcp_netmask); - dhcp_netmask.sin_family = AF_INET; - dhcp_gw.sin_len = sizeof(dhcp_gw); - dhcp_gw.sin_family= AF_INET; - - /* - * Set our address - */ - myaddr.sin_addr = reply.yiaddr; - printip("My ip address",myaddr.sin_addr); - - /* - * Process BOOTP/DHCP options - */ - if (reply.vend[0]==99 && reply.vend[1]==130 && - reply.vend[2]==83 && reply.vend[3]==99) { - processOptions (&reply.vend[4], sizeof(reply.vend) - 4); - } - if (dhcpOptionOverload & 1) { - processOptions (reply.file, sizeof reply.file); - } - else { - if (reply.file[0]) - rtems_bsdnet_bootp_boot_file_name = - bootp_strdup_realloc(rtems_bsdnet_bootp_boot_file_name,reply.file); - } - if (dhcpOptionOverload & 2) { - processOptions (reply.sname, sizeof reply.sname); - } - else { - if (reply.sname[0]) - rtems_bsdnet_bootp_server_name = - bootp_strdup_realloc(rtems_bsdnet_bootp_server_name,reply.sname); - } - if (rtems_bsdnet_bootp_server_name) - printf ("Server name is %s\n", rtems_bsdnet_bootp_server_name); - if (rtems_bsdnet_bootp_boot_file_name) - printf ("Boot file is %s\n", rtems_bsdnet_bootp_boot_file_name); - - /* - * Use defaults if values were not supplied by BOOTP/DHCP options - */ - if (!dhcp_gotnetmask) { - if (IN_CLASSA(ntohl(myaddr.sin_addr.s_addr))) - dhcp_netmask.sin_addr.s_addr = htonl(IN_CLASSA_NET); - else if (IN_CLASSB(ntohl(myaddr.sin_addr.s_addr))) - dhcp_netmask.sin_addr.s_addr = htonl(IN_CLASSB_NET); - else - dhcp_netmask.sin_addr.s_addr = htonl(IN_CLASSC_NET); - } - printip ("Subnet mask", dhcp_netmask.sin_addr); - if (!dhcp_gotserver) - rtems_bsdnet_bootp_server_address = reply.siaddr; - printip ("Server ip address" ,rtems_bsdnet_bootp_server_address); - if (!dhcp_gotgw) - dhcp_gw.sin_addr = reply.giaddr; - printip ("Gateway ip address", dhcp_gw.sin_addr); - if (!dhcp_gotlogserver) - rtems_bsdnet_log_host_address = rtems_bsdnet_bootp_server_address; - printip ("Log server ip address", rtems_bsdnet_log_host_address); - - /* - * Update the files if we are asked too. - */ - if (update_files) { - char *dn = rtems_bsdnet_domain_name; - char *hn = dhcp_hostname; - if (!dn) - dn = "mydomain"; - if (!hn) - hn = "me"; - rtems_rootfs_append_host_rec(*((unsigned long*) &myaddr.sin_addr), hn, dn); - - /* - * Should the given domainname be used here ? - */ - if (dhcp_gotserver) { - if (rtems_bsdnet_bootp_server_name) - hn = rtems_bsdnet_bootp_server_name; - else - hn = "bootps"; - rtems_rootfs_append_host_rec(*((unsigned long *) &rtems_bsdnet_bootp_server_address), - hn, dn); - } - - if (dhcp_gotlogserver) { - rtems_rootfs_append_host_rec(*((unsigned long *) &rtems_bsdnet_log_host_address), - "logs", dn); - } - - /* - * Setup the DNS configuration file /etc/resolv.conf. - */ - if (rtems_bsdnet_nameserver_count) { - int i; - char buf[64]; - const char *bufl[1]; - - bufl[0] = buf; - -#define MKFILE_MODE (S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IROTH) - - if (rtems_bsdnet_domain_name && - (strlen(rtems_bsdnet_domain_name) < (sizeof(buf) - 1))) { - strcpy(buf, "search "); - strcat(buf, rtems_bsdnet_domain_name); - strcat(buf, "\n"); - rtems_rootfs_file_append ("/etc/resolv.conf", MKFILE_MODE, 1, bufl); - } - - for (i = 0; i < rtems_bsdnet_nameserver_count; i++) { - strcpy(buf, "nameserver "); - strcat(buf, inet_ntoa(rtems_bsdnet_ntpserver[i])); - strcat(buf, "\n"); - if (rtems_rootfs_file_append ("/etc/resolv.conf", MKFILE_MODE, 1, bufl)) - break; - } - } - } - - /* - * Configure the interface with the new settings - */ - error = bootpc_adjust_interface(&ireq,so, - &myaddr,&dhcp_netmask,&dhcp_gw,procp); - soclose(so); -} diff --git a/c/src/exec/libnetworking/nfs/krpc.h b/c/src/exec/libnetworking/nfs/krpc.h deleted file mode 100644 index 8a21392657..0000000000 --- a/c/src/exec/libnetworking/nfs/krpc.h +++ /dev/null @@ -1,26 +0,0 @@ -/* $NetBSD: krpc.h,v 1.4 1995/12/19 23:07:11 cgd Exp $ */ -/* $Id$ */ - -#include <sys/cdefs.h> - -int krpc_call __P((struct sockaddr_in *sin, - u_int prog, u_int vers, u_int func, - struct mbuf **data, struct mbuf **from, struct proc *procp)); - -int krpc_portmap __P((struct sockaddr_in *sin, - u_int prog, u_int vers, u_int16_t *portp, struct proc *procp)); - -struct mbuf *xdr_string_encode __P((char *str, int len)); - -/* - * RPC definitions for the portmapper - */ -#define PMAPPORT 111 -#define PMAPPROG 100000 -#define PMAPVERS 2 -#define PMAPPROC_NULL 0 -#define PMAPPROC_SET 1 -#define PMAPPROC_UNSET 2 -#define PMAPPROC_GETPORT 3 -#define PMAPPROC_DUMP 4 -#define PMAPPROC_CALLIT 5 diff --git a/c/src/exec/libnetworking/nfs/nfs.h b/c/src/exec/libnetworking/nfs/nfs.h deleted file mode 100644 index 68f206e213..0000000000 --- a/c/src/exec/libnetworking/nfs/nfs.h +++ /dev/null @@ -1,620 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Rick Macklem at The University of Guelph. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)nfs.h 8.1 (Berkeley) 6/10/93 - * $Id$ - */ - -#ifndef _NFS_NFS_H_ -#define _NFS_NFS_H_ - -#include <nfs/rpcv2.h> - -/* - * Tunable constants for nfs - */ - -#define NFS_MAXIOVEC 34 -#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ -#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ -#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ -#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ -#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ -#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ -#define NFS_MAXREXMIT 100 /* Stop counting after this many */ -#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ -#define NFS_RETRANS 10 /* Num of retrans for soft mounts */ -#define NFS_MAXGRPS 16 /* Max. size of groups list */ -#ifndef NFS_MINATTRTIMO -#define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ -#endif -#ifndef NFS_MAXATTRTIMO -#define NFS_MAXATTRTIMO 60 -#endif -#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ -#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ -#define NFS_READDIRSIZE 8192 /* Def. readdir size */ -#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ -#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ -#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ -#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */ -#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */ -#ifndef NFS_GATHERDELAY -#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */ -#endif -#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */ - -/* - * Oddballs - */ -#define NMOD(a) ((a) % nfs_asyncdaemons) -#define NFS_CMPFH(n, f, s) \ - ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s))) -#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3) -#define NFS_SRVMAXDATA(n) \ - (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \ - NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA) - -/* - * XXX - * sys/buf.h should be edited to change B_APPENDWRITE --> B_NEEDCOMMIT, but - * until then... - * Same goes for sys/malloc.h, which needs M_NFSDIROFF, - * M_NFSRVDESC and M_NFSBIGFH added. - * The VA_EXCLUSIVE flag should be added for va_vaflags and set for an - * exclusive create. - * The B_INVAFTERWRITE flag should be set to whatever is required by the - * buffer cache code to say "Invalidate the block after it is written back". - */ -#ifndef B_NEEDCOMMIT -#define B_NEEDCOMMIT B_APPENDWRITE -#endif -#ifndef M_NFSRVDESC -#define M_NFSRVDESC M_TEMP -#endif -#ifndef M_NFSDIROFF -#define M_NFSDIROFF M_TEMP -#endif -#ifndef M_NFSBIGFH -#define M_NFSBIGFH M_TEMP -#endif -#ifndef VA_EXCLUSIVE -#define VA_EXCLUSIVE 0 -#endif -#ifdef __FreeBSD__ -#define B_INVAFTERWRITE B_NOCACHE -#else -#define B_INVAFTERWRITE B_INVAL -#endif - -/* - * These ifdefs try to handle the differences between the various 4.4BSD-Lite - * based vfs interfaces. - * btw: NetBSD-current does have a VOP_LEASDE(), but I don't know how to - * differentiate between NetBSD-1.0 and NetBSD-current, so.. - * I also don't know about BSDi's 2.0 release. - */ -#if !defined(HAS_VOPLEASE) && !defined(__FreeBSD__) && !defined(__NetBSD__) -#define HAS_VOPLEASE 1 -#endif -#if !defined(HAS_VOPREVOKE) && !defined(__FreeBSD__) && !defined(__NetBSD__) -#define HAS_VOPREVOKE 1 -#endif - -/* - * The IO_METASYNC flag should be implemented for local file systems. - * (Until then, it is nothin at all.) - */ -#ifndef IO_METASYNC -#define IO_METASYNC 0 -#endif - -/* - * Set the attribute timeout based on how recently the file has been modified. - */ -#define NFS_ATTRTIMEO(np) \ - ((((np)->n_flag & NMODIFIED) || \ - (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \ - ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \ - (time.tv_sec - (np)->n_mtime) / 10)) - -/* - * Expected allocation sizes for major data structures. If the actual size - * of the structure exceeds these sizes, then malloc() will be allocating - * almost twice the memory required. This is used in nfs_init() to warn - * the sysadmin that the size of a structure should be reduced. - * (These sizes are always a power of 2. If the kernel malloc() changes - * to one that does not allocate space in powers of 2 size, then this all - * becomes bunk!) - */ -#define NFS_NODEALLOC 256 -#define NFS_MNTALLOC 512 -#define NFS_SVCALLOC 256 -#define NFS_UIDALLOC 128 - -/* - * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs - * should ever try and use it. - */ -struct nfsd_args { - int sock; /* Socket to serve */ - caddr_t name; /* Client address for connection based sockets */ - int namelen; /* Length of name */ -}; - -struct nfsd_srvargs { - struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ - uid_t nsd_uid; /* Effective uid mapped to cred */ - u_long nsd_haddr; /* Ip address of client */ - struct ucred nsd_cr; /* Cred. uid maps to */ - int nsd_authlen; /* Length of auth string (ret) */ - u_char *nsd_authstr; /* Auth string (ret) */ - int nsd_verflen; /* and the verfier */ - u_char *nsd_verfstr; - struct timeval nsd_timestamp; /* timestamp from verifier */ - u_long nsd_ttl; /* credential ttl (sec) */ - NFSKERBKEY_T nsd_key; /* Session key */ -}; - -struct nfsd_cargs { - char *ncd_dirp; /* Mount dir path */ - uid_t ncd_authuid; /* Effective uid */ - int ncd_authtype; /* Type of authenticator */ - int ncd_authlen; /* Length of authenticator string */ - u_char *ncd_authstr; /* Authenticator string */ - int ncd_verflen; /* and the verifier */ - u_char *ncd_verfstr; - NFSKERBKEY_T ncd_key; /* Session key */ -}; - -/* - * Stats structure - */ -struct nfsstats { - int attrcache_hits; - int attrcache_misses; - int lookupcache_hits; - int lookupcache_misses; - int direofcache_hits; - int direofcache_misses; - int biocache_reads; - int read_bios; - int read_physios; - int biocache_writes; - int write_bios; - int write_physios; - int biocache_readlinks; - int readlink_bios; - int biocache_readdirs; - int readdir_bios; - int rpccnt[NFS_NPROCS]; - int rpcretries; - int srvrpccnt[NFS_NPROCS]; - int srvrpc_errs; - int srv_errs; - int rpcrequests; - int rpctimeouts; - int rpcunexpected; - int rpcinvalid; - int srvcache_inproghits; - int srvcache_idemdonehits; - int srvcache_nonidemdonehits; - int srvcache_misses; - int srvnqnfs_leases; - int srvnqnfs_maxleases; - int srvnqnfs_getleases; - int srvvop_writes; -}; - -/* - * Flags for nfssvc() system call. - */ -#define NFSSVC_BIOD 0x002 -#define NFSSVC_NFSD 0x004 -#define NFSSVC_ADDSOCK 0x008 -#define NFSSVC_AUTHIN 0x010 -#define NFSSVC_GOTAUTH 0x040 -#define NFSSVC_AUTHINFAIL 0x080 -#define NFSSVC_MNTD 0x100 - -/* - * fs.nfs sysctl(3) identifiers - */ -#define NFS_NFSSTATS 1 /* struct: struct nfsstats */ -#define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */ - -#define FS_NFS_NAMES { \ - { 0, 0 }, \ - { "nfsstats", CTLTYPE_STRUCT }, \ - { "nfsprivport", CTLTYPE_INT }, \ -} - -/* - * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. - * What should be in this set is open to debate, but I believe that since - * I/O system calls on ufs are never interrupted by signals the set should - * be minimal. My reasoning is that many current programs that use signals - * such as SIGALRM will not expect file I/O system calls to be interrupted - * by them and break. - */ -#if defined(KERNEL) || defined(_KERNEL) - -struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ - -#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ - sigmask(SIGHUP)|sigmask(SIGQUIT)) - -/* - * Socket errors ignored for connectionless sockets?? - * For now, ignore them all - */ -#define NFSIGNORE_SOERROR(s, e) \ - ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ - ((s) & PR_CONNREQUIRED) == 0) - -/* - * Nfs outstanding request list element - */ -struct nfsreq { - TAILQ_ENTRY(nfsreq) r_chain; - struct mbuf *r_mreq; - struct mbuf *r_mrep; - struct mbuf *r_md; - caddr_t r_dpos; - struct nfsmount *r_nmp; - struct vnode *r_vp; - u_long r_xid; - int r_flags; /* flags on request, see below */ - int r_retry; /* max retransmission count */ - int r_rexmit; /* current retrans count */ - int r_timer; /* tick counter on reply */ - int r_procnum; /* NFS procedure number */ - int r_rtt; /* RTT for rpc */ - struct proc *r_procp; /* Proc that did I/O system call */ -}; - -/* - * Queue head for nfsreq's - */ -extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq; - -/* Flag values for r_flags */ -#define R_TIMING 0x01 /* timing request (in mntp) */ -#define R_SENT 0x02 /* request has been sent */ -#define R_SOFTTERM 0x04 /* soft mnt, too many retries */ -#define R_INTR 0x08 /* intr mnt, signal pending */ -#define R_SOCKERR 0x10 /* Fatal error on socket */ -#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ -#define R_MUSTRESEND 0x40 /* Must resend request */ -#define R_GETONEREP 0x80 /* Probe for one reply only */ - -/* - * A list of nfssvc_sock structures is maintained with all the sockets - * that require service by the nfsd. - * The nfsuid structs hang off of the nfssvc_sock structs in both lru - * and uid hash lists. - */ -#ifndef NFS_UIDHASHSIZ -#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */ -#endif -#define NUIDHASH(sock, uid) \ - (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ]) -#ifndef NFS_WDELAYHASHSIZ -#define NFS_WDELAYHASHSIZ 16 /* and with this */ -#endif -#define NWDELAYHASH(sock, f) \ - (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ]) -#ifndef NFS_MUIDHASHSIZ -#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */ -#endif -#define NMUIDHASH(nmp, uid) \ - (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) -#define NFSNOHASH(fhsum) \ - (&nfsnodehashtbl[(fhsum) & nfsnodehash]) - -/* - * Network address hash list element - */ -union nethostaddr { - u_long had_inetaddr; - struct mbuf *had_nam; -}; - -struct nfsuid { - TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ - LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ - int nu_flag; /* Flags */ - union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ - struct ucred nu_cr; /* Cred uid mapped to */ - int nu_expire; /* Expiry time (sec) */ - struct timeval nu_timestamp; /* Kerb. timestamp */ - u_long nu_nickname; /* Nickname on server */ - NFSKERBKEY_T nu_key; /* and session key */ -}; - -#define nu_inetaddr nu_haddr.had_inetaddr -#define nu_nam nu_haddr.had_nam -/* Bits for nu_flag */ -#define NU_INETADDR 0x1 -#define NU_NAM 0x2 -#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO) - -struct nfssvc_sock { - TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ - TAILQ_HEAD(, nfsuid) ns_uidlruhead; - struct file *ns_fp; - struct socket *ns_so; - struct mbuf *ns_nam; - struct mbuf *ns_raw; - struct mbuf *ns_rawend; - struct mbuf *ns_rec; - struct mbuf *ns_recend; - struct mbuf *ns_frag; - int ns_flag; - int ns_solock; - int ns_cc; - int ns_reclen; - int ns_numuids; - u_long ns_sref; - LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ - LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; - LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; -}; - -/* Bits for "ns_flag" */ -#define SLP_VALID 0x01 -#define SLP_DOREC 0x02 -#define SLP_NEEDQ 0x04 -#define SLP_DISCONN 0x08 -#define SLP_GETSTREAM 0x10 -#define SLP_LASTFRAG 0x20 -#define SLP_ALLFLAGS 0xff - -extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead; -extern int nfssvc_sockhead_flag; -#define SLP_INIT 0x01 -#define SLP_WANTINIT 0x02 - -/* - * One of these structures is allocated for each nfsd. - */ -struct nfsd { - TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ - int nfsd_flag; /* NFSD_ flags */ - struct nfssvc_sock *nfsd_slp; /* Current socket */ - int nfsd_authlen; /* Authenticator len */ - u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ - int nfsd_verflen; /* and the Verifier */ - u_char nfsd_verfstr[RPCVERF_MAXSIZ]; - struct proc *nfsd_procp; /* Proc ptr */ - struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ -}; - -/* Bits for "nfsd_flag" */ -#define NFSD_WAITING 0x01 -#define NFSD_REQINPROG 0x02 -#define NFSD_NEEDAUTH 0x04 -#define NFSD_AUTHFAIL 0x08 - -/* - * This structure is used by the server for describing each request. - * Some fields are used only when write request gathering is performed. - */ -struct nfsrv_descript { - u_quad_t nd_time; /* Write deadline (usec) */ - off_t nd_off; /* Start byte offset */ - off_t nd_eoff; /* and end byte offset */ - LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ - LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ - LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ - struct mbuf *nd_mrep; /* Request mbuf list */ - struct mbuf *nd_md; /* Current dissect mbuf */ - struct mbuf *nd_mreq; /* Reply mbuf list */ - struct mbuf *nd_nam; /* and socket addr */ - struct mbuf *nd_nam2; /* return socket addr */ - caddr_t nd_dpos; /* Current dissect pos */ - int nd_procnum; /* RPC # */ - int nd_stable; /* storage type */ - int nd_flag; /* nd_flag */ - int nd_len; /* Length of this write */ - int nd_repstat; /* Reply status */ - u_long nd_retxid; /* Reply xid */ - u_long nd_duration; /* Lease duration */ - struct timeval nd_starttime; /* Time RPC initiated */ - fhandle_t nd_fh; /* File handle */ - struct ucred nd_cr; /* Credentials */ -}; - -/* Bits for "nd_flag" */ -#define ND_READ LEASE_READ -#define ND_WRITE LEASE_WRITE -#define ND_CHECK 0x04 -#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) -#define ND_NFSV3 0x08 -#define ND_NQNFS 0x10 -#define ND_KERBNICK 0x20 -#define ND_KERBFULL 0x40 -#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) - -extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head; -extern int nfsd_head_flag; -#define NFSD_CHECKSLP 0x01 - -/* - * These macros compare nfsrv_descript structures. - */ -#define NFSW_CONTIG(o, n) \ - ((o)->nd_eoff >= (n)->nd_off && \ - !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH)) - -#define NFSW_SAMECRED(o, n) \ - (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ - !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ - sizeof (struct ucred))) - -int nfs_reply __P((struct nfsreq *)); -int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); -int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *)); -int nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *)); -int nfs_sndlock __P((int *,struct nfsreq *)); -void nfs_sndunlock __P((int *flagp)); -int nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); -int nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int)); -int nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *)); -int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *)); -int nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *)); -int nfs_asyncio __P((struct buf *,struct ucred *)); -int nfs_doio __P((struct buf *,struct ucred *,struct proc *)); -int nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *)); -int nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *)); -int nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *)); -int nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); -void nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *)); -void nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **)); -void nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **)); -int netaddr_match __P((int,union nethostaddr *,struct mbuf *)); -int nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *)); -int nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *)); -int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int)); -void nfsm_adj __P((struct mbuf *,int,int)); -int nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *)); -void nfsrv_initcache __P((void)); -int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T)); -int nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int)); -int nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *)); -int nfs_adv __P((struct mbuf **,caddr_t *,int,int)); -void nfs_nhinit __P((void)); -void nfs_timer __P((void*)); -u_long nfs_hash __P((nfsfh_t *,int)); -void nfsrv_slpderef __P((struct nfssvc_sock *slp)); -int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **)); -void nfsrv_cleancache __P((void)); -int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **)); -int nfs_init __P((void)); -void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *)); -int nfs_connect __P((struct nfsmount *,struct nfsreq *)); -void nfs_disconnect __P((struct nfsmount *nmp)); -int nfs_getattrcache __P((struct vnode *,struct vattr *)); -int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long)); -int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *, int getpages)); -int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *)); -void nfsrv_init __P((int)); -void nfs_clearcommit __P((struct mount *)); -int nfsrv_errmap __P((struct nfsrv_descript *, int)); -void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag)); -void nfsrvw_sort __P((gid_t [],int)); -void nfsrv_setcred __P((struct ucred *,struct ucred *)); -int nfs_writebp __P((struct buf *,int)); -int nfsrv_object_create __P(( struct vnode * )); -void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); -int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, - struct proc *, struct mbuf **)); -int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, - struct proc *p)); - -int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **, - struct ucred *,struct nfssvc_sock *,struct mbuf *, - int *,int)); -int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, - struct mbuf **mrq)); -int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, - struct mbuf **mrq)); -int nfsrv_readlink __P((struct nfsrv_descript *nfsd, - struct nfssvc_sock *slp, struct proc *procp, - struct mbuf **mrq)); -int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); -int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, - struct proc *procp, struct mbuf **mrq)); - -#ifdef NFS_DEBUG - -extern int nfs_debug; -#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */ -#define NFS_DEBUG_WG 2 /* server write gathering */ -#define NFS_DEBUG_RC 4 /* server request caching */ - -#define NFS_DPF(cat, args) \ - do { \ - if (nfs_debug & NFS_DEBUG_##cat) printf args; \ - } while (0) - -#else - -#define NFS_DPF(cat, args) - -#endif - -#endif /* KERNEL */ - -#endif diff --git a/c/src/exec/libnetworking/nfs/nfsdiskless.h b/c/src/exec/libnetworking/nfs/nfsdiskless.h deleted file mode 100644 index 0ed5c8f6f7..0000000000 --- a/c/src/exec/libnetworking/nfs/nfsdiskless.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Rick Macklem at The University of Guelph. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)nfsdiskless.h 8.1 (Berkeley) 6/10/93 - * $Id$ - */ - -#ifndef _NFS_NFSDISKLESS_H_ -#define _NFS_NFSDISKLESS_H_ - -/* - * Structure that must be initialized for a diskless nfs client. - * This structure is used by nfs_mountroot() to set up the root and swap - * vnodes plus do a partial ifconfig(8) and route(8) so that the critical net - * interface can communicate with the server. - * The primary bootstrap is expected to fill in the appropriate fields before - * starting the kernel. Whether or not the swap area is nfs mounted is determined - * by the value in swdevt[0]. (equal to NODEV --> swap over nfs) - * Currently only works for AF_INET protocols. - * NB: All fields are stored in net byte order to avoid hassles with - * client/server byte ordering differences. - */ - -/* - * I have defined a new structure that can handle an NFS Version 3 file handle - * but the kernel still expects the old Version 2 one to be provided. The - * changes required in nfs_vfsops.c for using the new are documented there in - * comments. (I felt that breaking network booting code by changing this - * structure would not be prudent at this time, since almost all servers are - * still Version 2 anyhow.) - */ -struct nfsv3_diskless { - struct ifaliasreq myif; /* Default interface */ - struct sockaddr_in mygateway; /* Default gateway */ - struct nfs_args swap_args; /* Mount args for swap file */ - int swap_fhsize; /* Size of file handle */ - u_char swap_fh[NFSX_V3FHMAX]; /* Swap file's file handle */ - struct sockaddr_in swap_saddr; /* Address of swap server */ - char swap_hostnam[MNAMELEN]; /* Host name for mount pt */ - int swap_nblks; /* Size of server swap file */ - struct ucred swap_ucred; /* Swap credentials */ - struct nfs_args root_args; /* Mount args for root fs */ - int root_fhsize; /* Size of root file handle */ - u_char root_fh[NFSX_V3FHMAX]; /* File handle of root dir */ - struct sockaddr_in root_saddr; /* Address of root server */ - char root_hostnam[MNAMELEN]; /* Host name for mount pt */ - long root_time; /* Timestamp of root fs */ - char my_hostnam[MAXHOSTNAMELEN]; /* Client host name */ -}; - -struct nfs_diskless { - struct ifaliasreq myif; /* Default interface */ - struct sockaddr_in mygateway; /* Default gateway */ - struct nfs_args swap_args; /* Mount args for swap file */ - u_char swap_fh[NFSX_V2FH]; /* Swap file's file handle */ - struct sockaddr_in swap_saddr; /* Address of swap server */ - char swap_hostnam[MNAMELEN]; /* Host name for mount pt */ - int swap_nblks; /* Size of server swap file */ - struct ucred swap_ucred; /* Swap credentials */ - struct nfs_args root_args; /* Mount args for root fs */ - u_char root_fh[NFSX_V2FH]; /* File handle of root dir */ - struct sockaddr_in root_saddr; /* Address of root server */ - char root_hostnam[MNAMELEN]; /* Host name for mount pt */ - long root_time; /* Timestamp of root fs */ - char my_hostnam[MAXHOSTNAMELEN]; /* Client host name */ -}; - -#endif diff --git a/c/src/exec/libnetworking/nfs/nfsproto.h b/c/src/exec/libnetworking/nfs/nfsproto.h deleted file mode 100644 index 6ce7c5b960..0000000000 --- a/c/src/exec/libnetworking/nfs/nfsproto.h +++ /dev/null @@ -1,441 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Rick Macklem at The University of Guelph. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)nfsproto.h 8.1 (Berkeley) 6/10/93 - * $Id$ - */ - -#ifndef _NFS_NFSPROTO_H_ -#define _NFS_NFSPROTO_H_ - -/* - * nfs definitions as per the Version 2 and 3 specs - */ - -/* - * Constants as defined in the Sun NFS Version 2 and 3 specs. - * "NFS: Network File System Protocol Specification" RFC1094 - * and in the "NFS: Network File System Version 3 Protocol - * Specification" - */ - -#define NFS_PORT 2049 -#define NFS_PROG 100003 -#define NFS_VER2 2 -#define NFS_VER3 3 -#define NFS_V2MAXDATA 8192 -#define NFS_MAXDGRAMDATA 16384 -#define NFS_MAXDATA 32768 -#define NFS_MAXPATHLEN 1024 -#define NFS_MAXNAMLEN 255 -#define NFS_MAXPKTHDR 404 -#define NFS_MAXPACKET (NFS_MAXPKTHDR + NFS_MAXDATA) -#define NFS_MINPACKET 20 -#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */ - -/* Stat numbers for rpc returns (version 2 and 3) */ -#define NFS_OK 0 -#define NFSERR_PERM 1 -#define NFSERR_NOENT 2 -#define NFSERR_IO 5 -#define NFSERR_NXIO 6 -#define NFSERR_ACCES 13 -#define NFSERR_EXIST 17 -#define NFSERR_XDEV 18 /* Version 3 only */ -#define NFSERR_NODEV 19 -#define NFSERR_NOTDIR 20 -#define NFSERR_ISDIR 21 -#define NFSERR_INVAL 22 /* Version 3 only */ -#define NFSERR_FBIG 27 -#define NFSERR_NOSPC 28 -#define NFSERR_ROFS 30 -#define NFSERR_MLINK 31 /* Version 3 only */ -#define NFSERR_NAMETOL 63 -#define NFSERR_NOTEMPTY 66 -#define NFSERR_DQUOT 69 -#define NFSERR_STALE 70 -#define NFSERR_REMOTE 71 /* Version 3 only */ -#define NFSERR_WFLUSH 99 /* Version 2 only */ -#define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */ -#define NFSERR_NOT_SYNC 10002 -#define NFSERR_BAD_COOKIE 10003 -#define NFSERR_NOTSUPP 10004 -#define NFSERR_TOOSMALL 10005 -#define NFSERR_SERVERFAULT 10006 -#define NFSERR_BADTYPE 10007 -#define NFSERR_JUKEBOX 10008 -#define NFSERR_TRYLATER NFSERR_JUKEBOX -#define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */ - -#define NFSERR_RETVOID 0x20000000 /* Return void, not error */ -#define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */ -#define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */ - -/* Sizes in bytes of various nfs rpc components */ -#define NFSX_UNSIGNED 4 - -/* specific to NFS Version 2 */ -#define NFSX_V2FH 32 -#define NFSX_V2FATTR 68 -#define NFSX_V2SATTR 32 -#define NFSX_V2COOKIE 4 -#define NFSX_V2STATFS 20 - -/* specific to NFS Version 3 */ -#define NFSX_V3FH (sizeof (fhandle_t)) /* size this server uses */ -#define NFSX_V3FHMAX 64 /* max. allowed by protocol */ -#define NFSX_V3FATTR 84 -#define NFSX_V3SATTR 60 /* max. all fields filled in */ -#define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr)) -#define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED) -#define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED) -#define NFSX_V3COOKIEVERF 8 -#define NFSX_V3WRITEVERF 8 -#define NFSX_V3CREATEVERF 8 -#define NFSX_V3STATFS 52 -#define NFSX_V3FSINFO 48 -#define NFSX_V3PATHCONF 24 - -/* variants for both versions */ -#define NFSX_FH(v3) ((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \ - NFSX_V2FH) -#define NFSX_SRVFH(v3) ((v3) ? NFSX_V3FH : NFSX_V2FH) -#define NFSX_FATTR(v3) ((v3) ? NFSX_V3FATTR : NFSX_V2FATTR) -#define NFSX_PREOPATTR(v3) ((v3) ? (7 * NFSX_UNSIGNED) : 0) -#define NFSX_POSTOPATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0) -#define NFSX_POSTOPORFATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \ - NFSX_V2FATTR) -#define NFSX_WCCDATA(v3) ((v3) ? NFSX_V3WCCDATA : 0) -#define NFSX_WCCORFATTR(v3) ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR) -#define NFSX_SATTR(v3) ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR) -#define NFSX_COOKIEVERF(v3) ((v3) ? NFSX_V3COOKIEVERF : 0) -#define NFSX_WRITEVERF(v3) ((v3) ? NFSX_V3WRITEVERF : 0) -#define NFSX_READDIR(v3) ((v3) ? (5 * NFSX_UNSIGNED) : \ - (2 * NFSX_UNSIGNED)) -#define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS) - -/* nfs rpc procedure numbers (before version mapping) */ -#define NFSPROC_NULL 0 -#define NFSPROC_GETATTR 1 -#define NFSPROC_SETATTR 2 -#define NFSPROC_LOOKUP 3 -#define NFSPROC_ACCESS 4 -#define NFSPROC_READLINK 5 -#define NFSPROC_READ 6 -#define NFSPROC_WRITE 7 -#define NFSPROC_CREATE 8 -#define NFSPROC_MKDIR 9 -#define NFSPROC_SYMLINK 10 -#define NFSPROC_MKNOD 11 -#define NFSPROC_REMOVE 12 -#define NFSPROC_RMDIR 13 -#define NFSPROC_RENAME 14 -#define NFSPROC_LINK 15 -#define NFSPROC_READDIR 16 -#define NFSPROC_READDIRPLUS 17 -#define NFSPROC_FSSTAT 18 -#define NFSPROC_FSINFO 19 -#define NFSPROC_PATHCONF 20 -#define NFSPROC_COMMIT 21 - -/* And leasing (nqnfs) procedure numbers (must be last) */ -#define NQNFSPROC_GETLEASE 22 -#define NQNFSPROC_VACATED 23 -#define NQNFSPROC_EVICTED 24 - -#define NFSPROC_NOOP 25 -#define NFS_NPROCS 26 - -/* Actual Version 2 procedure numbers */ -#define NFSV2PROC_NULL 0 -#define NFSV2PROC_GETATTR 1 -#define NFSV2PROC_SETATTR 2 -#define NFSV2PROC_NOOP 3 -#define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */ -#define NFSV2PROC_LOOKUP 4 -#define NFSV2PROC_READLINK 5 -#define NFSV2PROC_READ 6 -#define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */ -#define NFSV2PROC_WRITE 8 -#define NFSV2PROC_CREATE 9 -#define NFSV2PROC_REMOVE 10 -#define NFSV2PROC_RENAME 11 -#define NFSV2PROC_LINK 12 -#define NFSV2PROC_SYMLINK 13 -#define NFSV2PROC_MKDIR 14 -#define NFSV2PROC_RMDIR 15 -#define NFSV2PROC_READDIR 16 -#define NFSV2PROC_STATFS 17 - -/* - * Constants used by the Version 3 protocol for various RPCs - */ -#define NFSV3SATTRTIME_DONTCHANGE 0 -#define NFSV3SATTRTIME_TOSERVER 1 -#define NFSV3SATTRTIME_TOCLIENT 2 - -#define NFSV3ACCESS_READ 0x01 -#define NFSV3ACCESS_LOOKUP 0x02 -#define NFSV3ACCESS_MODIFY 0x04 -#define NFSV3ACCESS_EXTEND 0x08 -#define NFSV3ACCESS_DELETE 0x10 -#define NFSV3ACCESS_EXECUTE 0x20 - -#define NFSV3WRITE_UNSTABLE 0 -#define NFSV3WRITE_DATASYNC 1 -#define NFSV3WRITE_FILESYNC 2 - -#define NFSV3CREATE_UNCHECKED 0 -#define NFSV3CREATE_GUARDED 1 -#define NFSV3CREATE_EXCLUSIVE 2 - -#define NFSV3FSINFO_LINK 0x01 -#define NFSV3FSINFO_SYMLINK 0x02 -#define NFSV3FSINFO_HOMOGENEOUS 0x08 -#define NFSV3FSINFO_CANSETTIME 0x10 - -/* Conversion macros */ -#define vtonfsv2_mode(t,m) \ - txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \ - MAKEIMODE((t), (m))) -#define vtonfsv3_mode(m) txdr_unsigned((m) & 07777) -#define nfstov_mode(a) (fxdr_unsigned(u_short, (a))&07777) -#define vtonfsv2_type(a) txdr_unsigned(nfsv2_type[((long)(a))]) -#define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((long)(a))]) -#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_long,(a))&0x7] -#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(u_long,(a))&0x7] - -/* File types */ -typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5, - NFSOCK=6, NFFIFO=7 } nfstype; - -/* Structs for common parts of the rpc's */ -/* - * File Handle (32 bytes for version 2), variable up to 64 for version 3. - * File Handles of up to NFS_SMALLFH in size are stored directly in the - * nfs node, whereas larger ones are malloc'd. (This never happens when - * NFS_SMALLFH is set to 64.) - * NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4. - */ -#ifndef NFS_SMALLFH -#define NFS_SMALLFH 64 -#endif -union nfsfh { - fhandle_t fh_generic; - u_char fh_bytes[NFS_SMALLFH]; -}; -typedef union nfsfh nfsfh_t; - -struct nfsv2_time { - u_long nfsv2_sec; - u_long nfsv2_usec; -}; -typedef struct nfsv2_time nfstime2; - -struct nfsv3_time { - u_long nfsv3_sec; - u_long nfsv3_nsec; -}; -typedef struct nfsv3_time nfstime3; - -/* - * Quads are defined as arrays of 2 longs to ensure dense packing for the - * protocol and to facilitate xdr conversion. - */ -struct nfs_uquad { - u_long nfsuquad[2]; -}; -typedef struct nfs_uquad nfsuint64; - -/* - * Used to convert between two u_longs and a u_quad_t. - */ -union nfs_quadconvert { - u_long lval[2]; - u_quad_t qval; -}; -typedef union nfs_quadconvert nfsquad_t; - -/* - * NFS Version 3 special file number. - */ -struct nfsv3_spec { - u_long specdata1; - u_long specdata2; -}; -typedef struct nfsv3_spec nfsv3spec; - -/* - * File attributes and setable attributes. These structures cover both - * NFS version 2 and the version 3 protocol. Note that the union is only - * used so that one pointer can refer to both variants. These structures - * go out on the wire and must be densely packed, so no quad data types - * are used. (all fields are longs or u_longs or structures of same) - * NB: You can't do sizeof(struct nfs_fattr), you must use the - * NFSX_FATTR(v3) macro. - */ -struct nfs_fattr { - u_long fa_type; - u_long fa_mode; - u_long fa_nlink; - u_long fa_uid; - u_long fa_gid; - union { - struct { - u_long nfsv2fa_size; - u_long nfsv2fa_blocksize; - u_long nfsv2fa_rdev; - u_long nfsv2fa_blocks; - u_long nfsv2fa_fsid; - u_long nfsv2fa_fileid; - nfstime2 nfsv2fa_atime; - nfstime2 nfsv2fa_mtime; - nfstime2 nfsv2fa_ctime; - } fa_nfsv2; - struct { - nfsuint64 nfsv3fa_size; - nfsuint64 nfsv3fa_used; - nfsv3spec nfsv3fa_rdev; - nfsuint64 nfsv3fa_fsid; - nfsuint64 nfsv3fa_fileid; - nfstime3 nfsv3fa_atime; - nfstime3 nfsv3fa_mtime; - nfstime3 nfsv3fa_ctime; - } fa_nfsv3; - } fa_un; -}; - -/* and some ugly defines for accessing union components */ -#define fa2_size fa_un.fa_nfsv2.nfsv2fa_size -#define fa2_blocksize fa_un.fa_nfsv2.nfsv2fa_blocksize -#define fa2_rdev fa_un.fa_nfsv2.nfsv2fa_rdev -#define fa2_blocks fa_un.fa_nfsv2.nfsv2fa_blocks -#define fa2_fsid fa_un.fa_nfsv2.nfsv2fa_fsid -#define fa2_fileid fa_un.fa_nfsv2.nfsv2fa_fileid -#define fa2_atime fa_un.fa_nfsv2.nfsv2fa_atime -#define fa2_mtime fa_un.fa_nfsv2.nfsv2fa_mtime -#define fa2_ctime fa_un.fa_nfsv2.nfsv2fa_ctime -#define fa3_size fa_un.fa_nfsv3.nfsv3fa_size -#define fa3_used fa_un.fa_nfsv3.nfsv3fa_used -#define fa3_rdev fa_un.fa_nfsv3.nfsv3fa_rdev -#define fa3_fsid fa_un.fa_nfsv3.nfsv3fa_fsid -#define fa3_fileid fa_un.fa_nfsv3.nfsv3fa_fileid -#define fa3_atime fa_un.fa_nfsv3.nfsv3fa_atime -#define fa3_mtime fa_un.fa_nfsv3.nfsv3fa_mtime -#define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime - -struct nfsv2_sattr { - u_long sa_mode; - u_long sa_uid; - u_long sa_gid; - u_long sa_size; - nfstime2 sa_atime; - nfstime2 sa_mtime; -}; - -/* - * NFS Version 3 sattr structure for the new node creation case. - */ -struct nfsv3_sattr { - u_long sa_modetrue; - u_long sa_mode; - u_long sa_uidtrue; - u_long sa_uid; - u_long sa_gidtrue; - u_long sa_gid; - u_long sa_sizefalse; - u_long sa_atimetype; - nfstime3 sa_atime; - u_long sa_mtimetype; - nfstime3 sa_mtime; -}; - -struct nfs_statfs { - union { - struct { - u_long nfsv2sf_tsize; - u_long nfsv2sf_bsize; - u_long nfsv2sf_blocks; - u_long nfsv2sf_bfree; - u_long nfsv2sf_bavail; - } sf_nfsv2; - struct { - nfsuint64 nfsv3sf_tbytes; - nfsuint64 nfsv3sf_fbytes; - nfsuint64 nfsv3sf_abytes; - nfsuint64 nfsv3sf_tfiles; - nfsuint64 nfsv3sf_ffiles; - nfsuint64 nfsv3sf_afiles; - u_long nfsv3sf_invarsec; - } sf_nfsv3; - } sf_un; -}; - -#define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize -#define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize -#define sf_blocks sf_un.sf_nfsv2.nfsv2sf_blocks -#define sf_bfree sf_un.sf_nfsv2.nfsv2sf_bfree -#define sf_bavail sf_un.sf_nfsv2.nfsv2sf_bavail -#define sf_tbytes sf_un.sf_nfsv3.nfsv3sf_tbytes -#define sf_fbytes sf_un.sf_nfsv3.nfsv3sf_fbytes -#define sf_abytes sf_un.sf_nfsv3.nfsv3sf_abytes -#define sf_tfiles sf_un.sf_nfsv3.nfsv3sf_tfiles -#define sf_ffiles sf_un.sf_nfsv3.nfsv3sf_ffiles -#define sf_afiles sf_un.sf_nfsv3.nfsv3sf_afiles -#define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec - -struct nfsv3_fsinfo { - u_long fs_rtmax; - u_long fs_rtpref; - u_long fs_rtmult; - u_long fs_wtmax; - u_long fs_wtpref; - u_long fs_wtmult; - u_long fs_dtpref; - nfsuint64 fs_maxfilesize; - nfstime3 fs_timedelta; - u_long fs_properties; -}; - -struct nfsv3_pathconf { - u_long pc_linkmax; - u_long pc_namemax; - u_long pc_notrunc; - u_long pc_chownrestricted; - u_long pc_caseinsensitive; - u_long pc_casepreserving; -}; - -#endif diff --git a/c/src/exec/libnetworking/nfs/rpcv2.h b/c/src/exec/libnetworking/nfs/rpcv2.h deleted file mode 100644 index 5fd6e7febf..0000000000 --- a/c/src/exec/libnetworking/nfs/rpcv2.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Rick Macklem at The University of Guelph. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)rpcv2.h 8.1 (Berkeley) 6/10/93 - * $Id$ - */ - -#ifndef _NFS_RPCV2_H_ -#define _NFS_RPCV2_H_ - -/* - * Definitions for Sun RPC Version 2, from - * "RPC: Remote Procedure Call Protocol Specification" RFC1057 - */ - -/* Version # */ -#define RPC_VER2 2 - -/* Authentication */ -#define RPCAUTH_NULL 0 -#define RPCAUTH_UNIX 1 -#define RPCAUTH_SHORT 2 -#define RPCAUTH_KERB4 4 -#define RPCAUTH_NQNFS 300000 -#define RPCAUTH_MAXSIZ 400 -#define RPCVERF_MAXSIZ 12 /* For Kerb, can actually be 400 */ -#define RPCAUTH_UNIXGIDS 16 - -/* - * Constants associated with authentication flavours. - */ -#define RPCAKN_FULLNAME 0 -#define RPCAKN_NICKNAME 1 - -/* Rpc Constants */ -#define RPC_CALL 0 -#define RPC_REPLY 1 -#define RPC_MSGACCEPTED 0 -#define RPC_MSGDENIED 1 -#define RPC_PROGUNAVAIL 1 -#define RPC_PROGMISMATCH 2 -#define RPC_PROCUNAVAIL 3 -#define RPC_GARBAGE 4 /* I like this one */ -#define RPC_MISMATCH 0 -#define RPC_AUTHERR 1 - -/* Authentication failures */ -#define AUTH_BADCRED 1 -#define AUTH_REJECTCRED 2 -#define AUTH_BADVERF 3 -#define AUTH_REJECTVERF 4 -#define AUTH_TOOWEAK 5 /* Give em wheaties */ - -/* Sizes of rpc header parts */ -#define RPC_SIZ 24 -#define RPC_REPLYSIZ 28 - -/* RPC Prog definitions */ -#define RPCPROG_MNT 100005 -#define RPCMNT_VER1 1 -#define RPCMNT_VER3 3 -#define RPCMNT_MOUNT 1 -#define RPCMNT_DUMP 2 -#define RPCMNT_UMOUNT 3 -#define RPCMNT_UMNTALL 4 -#define RPCMNT_EXPORT 5 -#define RPCMNT_NAMELEN 255 -#define RPCMNT_PATHLEN 1024 -#define RPCPROG_NFS 100003 - -/* - * Structures used for RPCAUTH_KERB4. - */ -struct nfsrpc_fullverf { - u_long t1; - u_long t2; - u_long w2; -}; - -struct nfsrpc_fullblock { - u_long t1; - u_long t2; - u_long w1; - u_long w2; -}; - -struct nfsrpc_nickverf { - u_long kind; - struct nfsrpc_fullverf verf; -}; - -/* - * and their sizes in bytes.. If sizeof (struct nfsrpc_xx) != these - * constants, well then things will break in mount_nfs and nfsd. - */ -#define RPCX_FULLVERF 12 -#define RPCX_FULLBLOCK 16 -#define RPCX_NICKVERF 16 - -#ifdef NFSKERB -XXX -#else -typedef u_char NFSKERBKEY_T[2]; -typedef u_char NFSKERBKEYSCHED_T[2]; -#endif -#define NFS_KERBSRV "rcmd" /* Kerberos Service for NFS */ -#define NFS_KERBTTL (30 * 60) /* Credential ttl (sec) */ -#define NFS_KERBCLOCKSKEW (5 * 60) /* Clock skew (sec) */ -#define NFS_KERBW1(t) (*((u_long *)(&((t).dat[((t).length + 3) & ~0x3])))) -#endif diff --git a/c/src/exec/libnetworking/nfs/xdr_subs.h b/c/src/exec/libnetworking/nfs/xdr_subs.h deleted file mode 100644 index 874730378f..0000000000 --- a/c/src/exec/libnetworking/nfs/xdr_subs.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Rick Macklem at The University of Guelph. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)xdr_subs.h 8.1 (Berkeley) 6/10/93 - * $Id$ - */ - -#ifndef _NFS_XDR_SUBS_H_ -#define _NFS_XDR_SUBS_H_ - -/* - * Macros used for conversion to/from xdr representation by nfs... - * These use the MACHINE DEPENDENT routines ntohl, htonl - * As defined by "XDR: External Data Representation Standard" RFC1014 - * - * To simplify the implementation, we use ntohl/htonl even on big-endian - * machines, and count on them being `#define'd away. Some of these - * might be slightly more efficient as quad_t copies on a big-endian, - * but we cannot count on their alignment anyway. - */ - -#define fxdr_unsigned(t, v) ((t)ntohl((long)(v))) -#define txdr_unsigned(v) (htonl((long)(v))) - -#define fxdr_nfsv2time(f, t) { \ - (t)->tv_sec = ntohl(((struct nfsv2_time *)(f))->nfsv2_sec); \ - if (((struct nfsv2_time *)(f))->nfsv2_usec != 0xffffffff) \ - (t)->tv_nsec = 1000 * ntohl(((struct nfsv2_time *)(f))->nfsv2_usec); \ - else \ - (t)->tv_nsec = 0; \ -} -#define txdr_nfsv2time(f, t) { \ - ((struct nfsv2_time *)(t))->nfsv2_sec = htonl((f)->tv_sec); \ - if ((f)->tv_nsec != -1) \ - ((struct nfsv2_time *)(t))->nfsv2_usec = htonl((f)->tv_nsec / 1000); \ - else \ - ((struct nfsv2_time *)(t))->nfsv2_usec = 0xffffffff; \ -} - -#define fxdr_nfsv3time(f, t) { \ - (t)->tv_sec = ntohl(((struct nfsv3_time *)(f))->nfsv3_sec); \ - (t)->tv_nsec = ntohl(((struct nfsv3_time *)(f))->nfsv3_nsec); \ -} -#define txdr_nfsv3time(f, t) { \ - ((struct nfsv3_time *)(t))->nfsv3_sec = htonl((f)->tv_sec); \ - ((struct nfsv3_time *)(t))->nfsv3_nsec = htonl((f)->tv_nsec); \ -} - -#define fxdr_hyper(f, t) { \ - ((long *)(t))[_QUAD_HIGHWORD] = ntohl(((long *)(f))[0]); \ - ((long *)(t))[_QUAD_LOWWORD] = ntohl(((long *)(f))[1]); \ -} -#define txdr_hyper(f, t) { \ - ((long *)(t))[0] = htonl(((long *)(f))[_QUAD_HIGHWORD]); \ - ((long *)(t))[1] = htonl(((long *)(f))[_QUAD_LOWWORD]); \ -} - -#endif |