/* 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 #include #include #include #include #ifndef _COURMUX_ # include #endif #ifndef COURIERVERSION # include #endif #define XR_GetEnv(x) getenv(x) /* * The folowing comes from * (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 */ /* * 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) ); }