/* begincopyright Copyright (c) 1988, 1991 Xerox Corporation. All rights reserved. Use and copying of this software and preparation of derivative works based upon this software are permitted. Any distribution of this software or derivative works must comply with all applicable United States export control laws. This software is made available AS IS, and Xerox Corporation makes no warranty about the software, its performance or its conformity to any specification. Any person obtaining a copy of this software is requested to send their name and post office or electronic mail address to: PCR Coordinator Xerox PARC 3333 Coyote Hill Rd. Palo Alto, CA 94304 endcopyright */ /* * XNSRouterGlue.c * * XR interface to Mentat XNS Router using ND variables * * Demers, November 27, 1989 3:08:45 pm PST * Plass, February 18, 1992 10:44:24 am PST */ #include <xr/Errno.h> #include <xr/Threads.h> #include <xr/UIO.h> #include <sys/file.h> #include <stropts.h> #ifndef ←COURMUX← # include <courmux.h> #endif #ifndef COURIERVERSION # include <courier/courier.h> #endif #define XR←GetEnv(x) getenv(x) /* * The folowing comes from <nd.h> * (which won't compile without including a whole bunch of other junk, so ...) */ #define XNS←ROUTER←NAME←DEF "/dev/xr" #define ND←BASE ('N' << 8) /** base */ #define ND←GET (ND←BASE + 0) /** Get a value */ #define ND←SET (ND←BASE + 1) /** Set a value */ /* (end of includes from <nd.h> */ /* * Create Handle */ typedef XR←Fildes XR←XNSRouterDescriptor; XR←XNSRouterDescriptor XR←CreateXNSRouterHandle () { XR←XNSRouterDescriptor d; char *name; name = (char *)XR←GetEnv("XNS←ROUTER←NAME"); if( name == NIL ) { name = XNS←ROUTER←NAME←DEF; } d = XR←OpenStream(name, O←RDWR, 0); if( d < 0 ) d = -(XR←GetErrno()); return d; } /* * Destroy Handle */ void XR←DestroyXNSRouterHandle (d) XR←XNSRouterDescriptor d; { (void)XR←Close(d); } /* * Get or Set Parameter */ static int XR←GetOrSetXNSRouterParameter(d, cmd, buf, nBytes) XR←XNSRouterDescriptor d; int cmd; char *buf; unsigned nBytes; { struct strioctl ibuf; int ans; ibuf.ic←cmd = cmd; ibuf.ic←timout = 0; /* -1 ??? */ ibuf.ic←dp = buf; ibuf.ic←len = nBytes; ans = XR←IOCtl(d, I←STR, &ibuf); if( ans == -1 ) ans = -(XR←GetErrno()); return ans; } int XR←GetXNSRouterParameter(d, buf, nBytes) XR←XNSRouterDescriptor d; char *buf; unsigned nBytes; { return( XR←GetOrSetXNSRouterParameter(d, ND←GET, buf, nBytes) ); } int XR←SetXNSRouterParameter(d, buf, nBytes) XR←XNSRouterDescriptor d; char *buf; unsigned nBytes; { return( XR←GetOrSetXNSRouterParameter(d, ND←SET, buf, nBytes) ); }