NETLIB_SRC.BCKa)pNETLIB_SRC.BCKBACKUP DESCRIP.MMS,COMPATIBILITY.C,CONNECT.C,DNS.C,DNS_MXLOOK.C,DNS_QUERY.C,LINEMODE.C,MEM.C,MISC.C,NAMEADDR.C,NETLIB_SRI.C,NETLIB_SRI_SUPPORT.C,NETLIB_UCX.C,NETLIB_CMU.C,NETLIB_VECTOR.MAR,NETLIB_SHRXFR.MAR,NETLIB_SRI.H,NETLIB_MULTINET.H,NETLIB_TCPWARE.H,NETLIB_PATHWAY.H,NETLIB_UCX.H,NETLIB_CMU.H,NETLIB.H,NETLIBDEF.H,NETLIBDEF.R32,NETLIB.OPT,NETLIB.ALPHA_OPT,NETLIB_DOC.SDML,NETLIB_INST.SDML,NETLIB020.SDML MG_KIT:[NETLIB]NETLIB_SRC.BCK/SAVE/INTERCHANGE/BLOCK=8192/NOCRC/GROU=0 MADISON  @erʘT6.2 _HQ::  _HQ$DKA500: V6.2 t*[NETLIB]DESCRIP.MMS;34+,s*./ @ 4Tn-n?0123KPWO56^bWʘ73Wʘ889G @HJ !++! DESCRIP.MMS!3! MMS (MMK) description file for building NETLIB.!8! N.B.: If you are on an AXP system and using DEC/MMS,:! use the command MMS/MACRO=(__AXP__=1) to build MMK,:! so you get the right linker options file. This may:! or may not work; some versions of MMS may not be6! able to handle some of the syntax in this file.!4! 21-SEP-1994 V1.0 Madison Initial commenting.7! 31-OCT-1994 V2.0 Madison Rewrite for NETLIB V2.!--.IFDEF __MADGOAT_BUILD__MG_FACILITY = NETLIBMG_VMSVER = V53.INCLUDE MG_TOOLS:HEADER.MMS .IFDEF LIS2MFLAGS = $(MFLAGS)/LIST=MG_ETC:$(MMS$TARGET_FNAME)2CFLAGS = $(CFLAGS)/LIST=MG_ETC:$(MMS$TARGET_FNAME)BLINKFLAGS = $(LINKFLAGS)/MAP=MG_ETC:$(MMS$TARGET_FNAME)/CROSS/FULL.ENDIF.ELSEETCDIR =KITDIR =SRCDIR = SYS$DISK:[]BINDIR =.ENDIF.IFDEF __MMK_V32__.IFDEF __AXP__ ARCH = AXP#OPTFILE = $(SRCDIR)NETLIB.ALPHA_OPT*XFROPTF = $(SRCDIR)NETLIB_SHRXFR.ALPHA_OPT.ELSE ARCH = VAXOPTFILE = $(SRCDIR)NETLIB.OPT$XFROPTF = $(SRCDIR)NETLIB_SHRXFR.OPT.ENDIF.IFDEF __MADGOAT_BUILD__.ELSEBINDIR = [.BIN-$(ARCH)].FIRSTJ @ IF F$PARSE("[.BIN-$(ARCH)]") .EQS. "" THEN CREATE/DIR [.BIN-$(ARCH)], @ DEFINE BIN_DIR SYS$DISK:[.BIN-$(ARCH)]{}.B32{[.BIN-$(ARCH)]}.OBJ :{}.MAR{[.BIN-$(ARCH)]}.OBJ :.ENDIF.ELSE ! MMK pre-V3.2, or MMS.IFDEF __AXP__OPT = .ALPHA_OPT.ELSE OPT = .OPT.ENDIFOPTFILE = NETLIB$(OPT)XFROPTF = NETLIB_SHRXFR$(OPT).ENDIF.IFDEF __AXP__VEC =CMUSHR =.ELSE%CMUSHR = ,$(BINDIR)NETLIB_CMU_SHR.EXE!vec = ,$(BINDIR)NETLIB_VECTOR.OBJ.ENDIF .IFDEF DBGCFLAGS = $(CFLAGS)$(DBG)/NOOPTLINKFLAGS = $(LINKFLAGS)$(DBG)MFLAGS = $(MFLAGS)$(DBG).ELSE LINKFLAGS = $(LINKFLAGS)/NOTRACE.ENDIF;MULTINET_MODULES = NETLIB_SRI, NETLIB_MULTINET, NAMEADDR:TCPWARE_MODULES = NETLIB_SRI, NETLIB_TCPWARE, NAMEADDR:PATHWAY_MODULES = NETLIB_SRI, NETLIB_PATHWAY, NAMEADDRUCX_MODULES = NETLIB_UCX'CMU_MODULES = NETLIB_CMU, NAMEADDRCCOMMON_MODULES = MEM, LINEMODE, MISC, CONNECT, COMPATIBILITY, -* DNS, DNS_QUERY, DNS_MXLOOK:ALL : NETLIBDEF$(L32), $(BINDIR)NETLIB_SHRXFR.EXE, -L $(BINDIR)NETLIB_MULTINET_SHR.EXE, $(BINDIR)NETLIB_UCX_SHR.EXE, -- $(BINDIR)NETLIB_TCPWARE_SHR.EXE,-5 $(BINDIR)NETLIB_PATHWAY_SHR.EXE $(CMUSHR) @ !$(BINDIR)NETLIB_SHRXFR.EXE -9 : $(BINDIR)NETLIB_SHRXFR.OBJ $(VEC), $(XFROPTF)H $(LINK)$(LINKFLAGS)/SHARE $(BINDIR)NET LIB_SHRXFR.OBJ, $(XFROPTF)/OPT"$(BINDIR)NETLIB_MULTINET_SHR.EXE -? : $(BINDIR)NETLIB_MULTINET.OLB($(MULTINET_MODULES)),-L $(BINDIR)NETLIB_COMMON.OLB($(COMMON_MODULES)) $(VEC), $(OPTFILE)O $(LINK) $(LINKFLAGS)/SHARE $(OPTFILE)/OPT, $(BINDIR)NETLIB_MULTINET.OLB/LIB$(BINDIR)NETLIB_UCX_SHR.EXE -5 : $(BINDIR)NETLIB_UCX.OLB($(UCX_MODULES)),-L $(BINDIR)NETLIB_COMMON.OLB($(COMMON_MODULES)) $(VEC), $(OPTFILE)J $(LINK) $(LINKFLAGS)/SHARE $(OPTFILE)/OPT, $(BINDIR)NETLIB_UCX.OLB/LIB!$(BINDIR)NETLIB_TCPWARE_SHR.EXE -= : $(BINDIR)NETLIB_TCPWARE.OLB($(TCPWARE_MODULES)),-L $(BINDIR)NETLIB_COMMON.OLB($(COMMON_MODULES)) $(VEC), $(OPTFILE)N $(LINK) $(LINKFLAGS)/SHARE $(OPTFILE)/OPT, $(BINDIR)NETLIB_TCPWARE.OLB/LIB!$(BINDIR)NETLIB_PATHWAY_SHR.EXE -= : $(BINDIR)NETLIB_PATHWAY.OLB($(PATHWAY_MODULES)),-L $(BINDIR)NETLIB_COMMON.OLB($(COMMON_MODULES)) $(VEC), $(OPTFILE)N $(LINK) $(LINKFLAGS)/SHARE $(OPTFILE)/OPT, $(BINDIR)NETLIB_PATHWAY.OLB/LIB$(BINDIR)NETLIB_CMU_SHR.EXE -5 : $(BINDIR)NETLIB_CMU.OLB($(CMU_MODULES)),-L $(BINDIR)NETLIB_COMMON.OLB($(COMMON_MODULES)) $(VEC), $(OPTFILE)J $(LINK) $(LINKFLAGS)/SHARE $(OPTFILE)/OPT, $(BINDIR)NETLIB_CMU.OLB/LIBB$(BINDIR)NETLIB_UCX.OBJ : NETLIB.H, NETLIBDEF.H, NETLIB_UCX.HB$(BINDIR)NETLIB_SRI.OBJ : NETLIB.H, NETLIBDEF.H, NETLIB_SRI.HB$(BINDIR)NETLIB_CMU.OBJ : NETLIB.H, NETLIBDEF.H, NETLIB_CMU.HM$(BINDIR)NETLIB_MULTINET.OBJ : NETLIB_SRI_SUPPORT.C, NETLIB.H, NETLIBDEF.H, -/ NETLIB_SRI.H, NETLIB_MULTINET.HN $(CC)$(CFLAGS)/DEFINE=(MULTINET,MODULE_NAME=NETLIB_MULTINET) $(MMS$SOURCE)M$(BINDIR)NETLIB_TCPWARE.OBJ : NETLIB_SRI_SUPPORT.C, NETLIB.H, NETLIBDEF.H, -. NETLIB_SRI.H, NETLIB_TCPWARE.HL $(CC)$(CFLAGS)/DEFINE=(TCPWARE,MODULE_NAME=NETLIB_TCPWARE) $(MMS$SOURCE)M$(BINDIR)NETLIB_PATHWAY.OBJ : NETLIB_SRI_SUPPORT.C, NETLIB.H, NETLIBDEF.H, -. NETLIB_SRI.H, NETLIB_PATHWAY.HL $(CC)$(CFLAGS)/DEFINE=(PATHWAY,MODULE_NAME=NETLIB_PATHWAY) $(MMS$SOURCE)$(BINDIR)MEM.OBJ, -$(BINDIR)LINEMODE.OBJ, -$(BINDIR)MISC.OBJ, -$(BINDIR)DNS.OBJ, -$(BINDIR)DNS_QUERY.OBJ, -$(BINDIR)DNS_MXLOOK.OBJ, -$(BINDIR)CONNECT.OBJ, -2$(BINDIR)NAMEADDR.OBJ : NETLIB.H, NETLIBDEF.H*$(BINDIR)COMPATIBILITY.OBJ : NETLIBDEF.H!++?! End of dependencies for binaries. Kit dependencies follow.!---$(KITDIR)NETLIB_DOC.PS : NETLIB_DOC.SDML9 DOCUMENT/OUTPU T=$(MMS$TARGET)/DEVICE=BLANK/CONTENTS -( $(MMS$SOURCE) SOFTWARE.REFERENCE PS.$(KITDIR)NETLIB_DOC.TXT : NETLIB_DOC.SDML, DOCUMENT/OUTPUT=$(MMS$TARGET)/CONTENTS -* $(MMS$SOURCE) SOFTWARE.REFERENCE MAIL/$(KITDIR)NETLIB_DOC.DECW$BOOK : NETLIB_DOC.SDML, DOCUMENT/OUTPUT=$(MMS$TARGET)/CONTENTS -- $(MMS$SOURCE) SOFTWARE.ONLINE BOOKREADER/$(KITDIR)NETLIB_INST.PS : NETLIB_INST.SDML9 DOCUMENT/OUTPUT=$(MMS$TARGET)/DEVICE=BLANK/CONTENTS -( $(MMS$SOURCE) SOFTWARE.REFERENCE PS0$(KITDIR)NETLIB_INST.TXT : NETLIB_INST.SDML, DOCUMENT/OUTPUT=$(MMS$TARGET)/CONTENTS -* $(MMS$SOURCE) SOFTWARE.REFERENCE MAIL1$(KITDIR)NETLIB_INST.DECW$BOOK : NETLIB_INST.SDML, DOCUMENT/OUTPUT=$(MMS$TARGET)/CONTENTS -- $(MMS$SOURCE) SOFTWARE.ONLINE BOOKREADER5DOCS : $(KITDIR)NETLIB_DOC.DECW$BOOK,-. $(KITDIR)NETLIB_DOC.PS,-/ $(KITDIR)NETLIB_DOC.TXT,-6 $(KITDIR)NETLIB_INST.DECW$BOOK,-/ $(KITDIR)NETLIB_INST.PS,-. $(KITDIR)NETLIB_INST.TXT @ !,KIT : $(KITDIR)NETLIB020.ZIP @ !-$(KITDIR)NETLIB020.ZIP : AAAREADME.DOC,-C $(KITDIR)NETLIB020.A, $(KITDIR)NETLIB020.B, -B $(KITDIR)NETLIB020.C, $(KITDIR)NETLIB020.D,-- $(KITDIR)NETLIB_SRC.BCKE IF F$SEARCH("$(MMS$TARGET)") .NES. "" THEN DELETE $(MMS$TARGET);*6 PKZIP "-V" $(MMS$TARGET) $(MMS$SOURCE_LI@ NETLIB_SRC.BCKs*n?[NETLIB]DESCRIP.MMS;34T ST_SPACES)"$(KITDIR)NETLIB020.RELEASE_NOTES -$ : NETLIB020.SDML4 DOCUMENT/OUTPUT=$(MMS$TARGET)/NOPRINT/CONTENTS -+ $(MMS$SOURCE) SOFTWARE.REFERENCE MAIL+$(KITDIR)NETLIB020.A : KITINSTAL.COM,-* NETLIB_INSTALL.COM,-/ NETLIB_USER_INSTALL.COM,-6 $(KITDIR)NETLIB020.RELEASE_NOTES" PURGE/NOLOG $(MMS$SOURCE_LIST)T BACKUP $(MMS$SOURCE_LIST) $(MMS$TARGET)/SAVE/INTERCHANGE/BLOCK=8192/NOCRC/GROU=0)$(KITDIR)NETLIB020.B : NETLIB.OPT, -) NETLIB_SHRXFR.OPT,-2 $(BINVAX)NETLIB_SHRXFR.OBJ,-2 $(BINVAX)NETLIB_VECTOR.OBJ,-2 $(BINVAX)NETLIB_COMMON.OLB,-/ $(BINVAX)NETLIB_CMU.OLB,-/ $(BINVAX)NETLIB_UCX.OLB,-4 $(BINVAX)NETLIB_MULTINET.OLB,-3 $(BINVAX)NETLIB_TCPWARE.OLB,-3 $(BINVAX)NETLIB_PATHWAY.OLB,-0 $(BINVAX)NETLIB_SHRXFR.OBJ" PURGE/NOLOG $(MMS$SOURCE_LIST)T BACKUP $(MMS$SOURCE_LIST) $(MMS$TARGET)/SAVE/INTERCHANGE/BLOCK=8192/NOCRC/GROU=0/$(KITDIR)NETLIB020.C : NETLIB.ALPHA_OPT, -/ NETLIB_SHRXFR.ALPHA_OPT,-2 $(BINAXP)NETLIB_SHRXFR.OBJ,-2 $(BINAXP)NETLIB_COMMON.OLB,-/ $(BINAXP)NETLIB_UCX.OLB,-4 $(BINAXP)NETLIB_MULTINET.OLB,-3 $(BINAXP)NETLIB_TCPWARE.OLB,-3 $(BINAXP)NETLIB_PATHWAY.OLB,-0 $(BINAXP)NETLIB_SHRXFR.OBJ" PURGE/NOLOG $(MMS$SOURCE_LIST)T BACKUP $(MMS$SOURCE_LIST) $(MMS$TARGET)/SAVE/INTERCHANGE/BLOCK=8192/NOCRC/GROU=08$(KITDIR)NETLIB020.D : NETLIBDEF.H, NETLIBDEF.R32,-6 NETLIBDEF.L32, NETLIBDEF.L32E, -. LIBRARY.DECW$BOOKSHELF,-- NETLIB.DECW$BOOKSHELF,-2 ECHOCLIENT.C, ECHOSERVER.C,-/ ECHOSERVER_STANDALONE.C,-5 $(KITDIR)NETLIB_DOC.DECW$BOOK,-. $(KITDIR)NETLIB_DOC.PS,-/ $(KITDIR)NETLIB_DOC.TXT,-6 $(KITDIR)NETLIB_INST.DECW$BOOK,-/ $(KITDIR)NETLIB_INST.PS,-. $(KITDIR)NETLIB_INST.TXT" PURGE/NOLOG $(MMS$SOURCE_LIST)T BACKUP $(MMS$SOURCE_LIST) $(MMS$TARGET)/SAVE/INTERCHANGE/BLOCK=8192/NOCRC/GROU=0,$(KITDIR)NETLIB_SRC.BCK : DESCRIP.MMS,-: COMPATIBILITY.C, CONNECT.C, DNS.C, -> DNS_MXLOOK.C, DNS_QUERY.C, LINEMODE.C, -2 MEM.C, MISC.C, NAMEADDR.C, -; NETLIB_SRI.C, NETLIB_SRI_SUPPORT.C, -3 NETLIB_UCX.C, NETLIB_CMU.C, -= NETLIB_VECTOR.MAR, NETLIB_SHRXFR.MAR, -8 NETLIB_SRI.H, NETLIB_MULTINET.H, -; NETLIB_TCPWARE.H, NETLIB_PATHWAY.H, -3 NETLIB_UCX.H, NETLIB_CMU.H, -= NETLIB.H, NETLIBDEF.H, NETLIBDEF.R32, -5 NETLIB.OPT, NETLIB.ALPHA_OPT, -9 NETLIB_DOC.SDML, NETLIB_INST.SDML,-$ NETLIB020.SDML" PURGE/NOLOG $(MMS$SOURCE_LIST)T BACKUP $(MMS$SOURCE_LIST) $(MMS$TARGET)/SAVE/INTERCHANGE/BLOCK=8192/NOCRC/GROU=0 NETLIB_SRC.BCKSn?[NETLIB]COMPATIBILITY.C;29Z<? *[NETLIB]COMPATIBILITY.C;29+,S.</ @ 4Z<8-n?0123KPWO=56_L7d890/9V$ǘG @HJ/***++** FACILITY: NETLIB**,** ABSTRACT: Pre-V2 compatibility routines.**** MODULE DESCRIPTION:**G** This module contains wrapper routines for NETLIB V2 that implementO** the V1 programming interface, for compatibility with V1-based applications.**J** N.B.: This compatibility may be removed in a future release of NETLIB.F** Existing applications should migrate to the V2 API, and all new/** applications should use only the V2 API.**** AUTHOR: M. MadisonM** COPYRIGHT 1994, 1995 MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** CREATION DATE: 25-OCT-1994**** MODIFICATION HISTORY:**1** 25-OCT-1994 V1.0 Madison Initial coding.F** 13-NOV-1994 V1.1 Madison Another V1 compatibility hack -- for%** udp_receive.@** 17-NOV-1994 V1.1-1 Madison A shutdown call on disconnect.B** 11-JAN-1995 V1.1-2 Madison Fix shutdown call on disconnect;0** add default timeout.F** 11-JAN-1995 V1.1-3 Madison Fixed invocation of default timeout.D** 17-FEB-1995 V1.1-4 Madison Allow SS$_LINKDISCON as success on,** tcp_disconnect.**--*/#include "netlibdef.h"#include #include #include #include #include #include #include /*0** A few handy macros and structure definitions*/$#define OK(x) $VMS_STATUS_SUCCESS(x)F#define VERIFY_CONTEXT(p,c) {if (p == 0) return SS$_BADPARAM; c = *p;}"#define SETARGCOUNT(x) va_count(x)#ifdef __ALPHA#pragma member_alignment save#pragma nomember_alignment#endif2 typedef struct {unsigned int low, high;} TIME;#ifdef __ALPHA #pragma member_alignment restore#endif/*:** These constants are from the V1 programming interface.*/#define NET_K_TCP 1#define NET_K_UDP 2#define NET_M_PUSH 1#define NET_M_NOTRM 2/*:** Context structure for tracking a V1-style "connection"*/ struct COMPATCTX { struct NETLIBIOSBDEF iosb; void *ctx; unsigned int proto; unsigned int rcvsinlen; void (*astadr)(); void *astprm; unsigned short *retlenp; struct INADDRDEF *retaddr; unsigned short *retport;% struct NETLIBIOSBDEF *user_iosb; struct SINDEF rcvsin; };/*** Forward declarations*/5 unsigned int net_assign(struct COMPATCTX **xctx);F unsigned int net_bind(struct COMPATCTX **xctx, unsigned int proto,8 unsigned short port, unsigned int threads,$ unsigned int notpass);9 unsigned int net_get_address(struct COMPATCTX **xctx,? struct dsc$descriptor *host, unsigned int alsize,> struct INADDRDEF *alist, unsigned int *alcount);: unsigned int net_addr_to_name(struct COMPATCTX **xctx,B struct INADDRDEF addr, struct dsc$descriptor *name);7 unsigned int net_deassign(struct COMPATCTX **xctx);6 unsigned int net_get_info(struct COMPATCTX **xctx,> struct INADDRDEF *remadr, unsigned int *remport,? struct INADDRDEF *lcladr, unsigned int *lclport);R unsigned int net_get_hostname(struct dsc$descriptor *name, unsigned int *len);5 unsigned int tcp_connect(struct COMPATCTX **xctx,> struct dsc$descriptor *node, unsigned int port);: unsigned int tcp_connect_addr(struct COMPATCTX **xctx,9 struct INADDRDEF *addr, unsigned int port);4 unsigned int tcp_accept(struct COMPATCTX **xctx,D struct COMPATCTX **newctx, struct NETLIBIOSBDEF *iosb,. void (*astadr)(), void *astprm);9 unsigned int tcp_disconnect(struct COMPATCTX **xctx);N unsigned int tcp_send(struct COMPATCTX **xctx, struct dsc$descriptor *str,= unsigned int flags, struct NETLIBIOSBDEF *iosb,. void (*astadr)(), void *astprm);Q unsigned int tcp_receive(struct COMPATCTX **xctx, struct dsc$descriptor *str,I struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm, TIME *timeout);R unsigned int tcp_get_line(struct COMPATCTX **xctx, struct dsc$descriptor *str,I struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm, TIME *timeout);I unsigned int udp_send(struct COMPATCTX **xctx, struct INADDRDEF addr,E unsigned short port, void *buf, unsigned short buflen);C unsigned int udp_receive(struct COMPATCTX **xctx, void *bufptr,= unsigned short bufsize, unsigned short *buflen,? struct INADDRDEF *srcaddr, unsigned int *srcport,8 TIME *timeout, struct NETLIBIOSBDEF *iosb,. void (*astadr)(), void *astprm);; static void udp_read_completion(struct COMPATCTX *ctx);B unsigned int net_set_trace_routine(unsigned int (*routine)());L unsigned int dns_mxlook(struct dsc$descriptor *name, unsigned int *size,? unsigned int *count, struct MXRRDEF *mxrr);/*** OWN storage*/; static unsigned int ctxsize = sizeof(struct COMPATCTX);8 static unsigned int sinsize = sizeof(struct SINDEF);; static unsigned int inasize = sizeof(struct INADDRDEF);U static unsigned int which[2] = {NETLIB_K_LOOKUP_DNS, NETLIB_K_LOOKUP_HOST_TABLE};N static unsigned int type[2] = {NETLIB_K_TYPE_STREAM, NETLIB_K_TYPE_DGRAM}; /***++** ROUTINE: net_assign**** FUNCTIONAL DESCRIPTION:**>** Creates a V1 API network context. Under V1, this routineB** would also assign a channel to the network device. While this;** no longer happens, applications should not be affected.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** NET_ASSIGN ctxptr**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**9** COMPLETION CODES: SS$_NORMAL, or any from LIB$GET_VM.**** SIDE EFFECTS: None.****--*/3unsigned int net_assign (struct COMPATCTX **xctx) { unsigned int status; struct COMPATCTX *ctx;( status = lib$get_vm(&ctxsize, &ctx);# if (!OK(status)) return status; memset(ctx, 0, ctxsize); *xctx = ctx; return SS$_NORMAL;} /* net_assign */ /***++** ROUTINE: net_bind**** FUNCTIONAL DESCRIPTION:**?** Binds a network context to a particular port. For passive<** connections, also establishes the context as a listener.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**C** NETLIB_BIND ctxptr, protocol [,port] [,backlog] [,notpassive]**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/Cunsigned int net_bind (struct COMPATCTX **xctx, unsigned int proto,8 unsigned short port, unsigned int threads,% unsigned int notpass) { struct COMPATCTX *ctx; struct SINDEF sin; struct NETLIBIOSBDEF iosb; unsigned int status; int argc, passive;/*%** Make sure we have a valid context*/ NETLIB_SRC.BCKSn?[NETLIB]COMPATIBILITY.C;29Z< VERIFY_CONTEXT(xctx, ctx);/*&** Make sure we have enough arguments*/ SETARGCOUNT(argc);% if (argc < 2) return SS$_INSFARG;/*1** Use TCP if they specified an invalid protocol*/* if (proto < 1 || proto > 2) proto = 1;/*** Create a V2 socket*/6 status = netlib_socket(&ctx->ctx, &type[proto-1]);# if (!OK(status)) return status;/*** Passive mode?*/H passive = (argc > 4) ? !notpass : ((argc > 2 && port != 0) ? 1 : 0);/*** Bind the V2 socket*/! memset(&sin, 0, sizeof(sin));( sin.sin_w_family = NETLIB_K_AF_INET;= sin.sin_w_port = (argc > 2) ? netlib_word_swap(port) : 0;; status = netlib_bind(&ctx->ctx, &sin, &sinsize, &iosb);0 if (OK(status)) status = iosb.iosb_w_status; if (!OK(status)) { netlib_close(&ctx->ctx); ctx->ctx = 0; return status; }/*2** For a passive open, establish the listener now*/ if (passive) {I status = netlib_listen(&ctx->ctx, (argc > 3) ? &threads : 0, &iosb);1 if (OK(status)) status = iosb.iosb_w_status; if (!OK(status)) {! netlib_close(&ctx->ctx); ctx->ctx = 0; } } return status; } /* net_bind */ /***++** ROUTINE: net_get_address**** FUNCTIONAL DESCRIPTION:**3** Looks up a host name, returning an IP address.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**A** NET_GET_ADDRESS ctxptr, hostname, listsize, alist [,acount]**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/6unsigned int net_get_address (struct COMPATCTX **xctx,? struct dsc$descriptor *host, unsigned int alsize,? struct INADDRDEF *alist, unsigned int *alcount) { struct COMPATCTX *ctx; unsigned int status; int argc, i, temp; VERIFY_CONTEXT(xctx, ctx); SETARGCOUNT(argc);% if (argc < 4) return SS$_INSFARG;5 if (host == 0 || alist == 0) return SS$_BADPARAM; if (ctx->ctx == 0) {' status = netlib_socket(&ctx->ctx);$ if (!OK(status)) return status; temp = 1; } else temp = 0; for (i = 0; i < 2; i++) {: status = netlib_name_to_address(&ctx->ctx, &which[i],? host, alist, &alsize, (argc > 4) ? alcount : 0); if (OK(status)) break; } if (temp) { netlib_close(&ctx->ctx); ctx->ctx = 0; } return status;} /* net_get_address */ /***++** ROUTINE: net_addr_to_name**** FUNCTIONAL DESCRIPTION:**3** Looks up an IP address, returning a host name.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**3** NET_ADDR_TO_NAME ctxptr, ip-address, hostname**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/7unsigned int net_addr_to_name (struct COMPATCTX **xctx,C struct INADDRDEF addr, struct dsc$descriptor *name) { struct COMPATCTX *ctx; unsigned int status; int argc, i, temp; VERIFY_CONTEXT(xctx, ctx); SETARGCOUNT(argc);% if (argc < 3) return SS$_INSFARG;' if (name == 0) return SS$_BADPARAM; if (ctx->ctx == 0) {' status = netlib_socket(&ctx->ctx);$ if (!OK(status)) return status; temp = 1; } else temp = 0; for (i = 0; i < 2; i++) {K status = netlib_address_to_name(&ctx->ctx, &which[i], &addr, &inasize,% name); if (OK(status)) break; } if (temp) { netlib_close(&ctx->ctx); ctx->ctx = 0; } return status;} /* net_addr_to_name */ /***++** ROUTINE: net_deassign**** FUNCTIONAL DESCRIPTION:**&** Closes down a V1 network context.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** NET_DEASSIGN ctxptr**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**1** COMPLETION CODES: SS$_NORMAL always returned.**** SIDE EFFECTS: None.****--*/5unsigned int net_deassign (struct COMPATCTX **xctx) { struct COMPATCTX *ctx; VERIFY_CONTEXT(xctx, ctx); if (ctx->ctx != 0) { netlib_close(&ctx->ctx); ctx->ctx = 0; } lib$free_vm(&ctxsize, &ctx); *xctx = 0; return SS$_NORMAL;} /* net_deassign */ /***++** ROUTINE: net_get_info**** FUNCTIONAL DESCRIPTION:**G** Gets the local and/or remote socket information (address and port)** for a connection.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**C** NET_GET_INFO ctxptr, [remadr] [,remport] [,lcladr] [,lclport]**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/3unsigned int net_get_info (struct COMPATCTX **xctx,> struct INADDRDEF *remadr, unsigned int *remport,@ struct INADDRDEF *lcladr, unsigned int *lclport) { struct COMPATCTX *ctx; struct SINDEF sin; unsigned int status; unsigned int retlen; int argc; VERIFY_CONTEXT(xctx, ctx); SETARGCOUNT(argc);% if (argc < 2) return SS$_INSFARG;* if (ctx->ctx == 0) return SS$_NOLINKS;/*4** Get the remote information, if they asked for it*/4 if (remadr != 0 || (argc > 2 && remport != 0)) {E status = netlib_getpeername(&ctx->ctx, &sin, &sinsize, &retlen);$ if (!OK(status)) return status;= if (argc > 2 && remport != 0) *remport = sin.sin_w_port;/ if (remadr != 0) *remadr = sin.sin_x_addr; }/*7** Now get the local information, if they asked for it*/ if (argc > 3) {E status = netlib_getsockname(&ctx->ctx, &sin, &sinsize, &retlen); if (OK(status)) {3 if (lcladr != 0) *lcladr = sin.sin_x_addr;A if (argc > 4 && lclport != 0) *lclport = sin.sin_w_port; } } return status;} /* net_get_info */ /***++** ROUTINE: net_get_hostname**** FUNCTIONAL DESCRIPTION:**$** Returns the local IP host name.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**)** NET_GET_HOSTNAME hostname [,retlen]**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/Punsigned int net_get_hostname (struct dsc$descriptor *name, unsigned int *len) { unsigned int status; unsigned short retlen; int argc; SETARGCOUNT(argc);0 status = netlib_get_hostname(name, &retlen);: if (OK(status) && argc > 1 && len != 0) *len = retlen; return status;} /* net_get_hostname */ /***++** ROUTINE: tcp_connect**** FUNCTIONAL DESCRIPTION:**=** Performs an active open to establish a TCP connection to** a remote system (by name).**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**(** TCP_CONNECT ctxptr, hostname, port**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/2unsigned int tcp_connect (struct COMPATCTX **xctx,? struct dsc$descriptor *node, unsigned int port) { struct COMPATCTX *ctx; unsigned short p; unsigned int status; VERIFY_CONTEXT(xctx, ctx); if (ctx->c NETLIB_SRC.BCKSn?[NETLIB]COMPATIBILITY.C;29Z<ttx == 0) {< status = netlib_socket(&ctx->ctx, &type[ctx->proto-1]);$ if (!OK(status)) return status; } p = port;7 return netlib_connect_by_name(&ctx->ctx, node, &p);} /* tcp_connect */ /***++** ROUTINE: tcp_connect_addr**** FUNCTIONAL DESCRIPTION:**9** Performs an active open to establish a connection to** a remote system by address.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**,** TCP_CONNECT_ADDR ctxptr, addrptr, port**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/7unsigned int tcp_connect_addr (struct COMPATCTX **xctx,: struct INADDRDEF *addr, unsigned int port) { struct COMPATCTX *ctx; struct SINDEF sin; unsigned int status; VERIFY_CONTEXT(xctx, ctx); if (ctx->ctx == 0) {< status = netlib_socket(&ctx->ctx, &type[ctx->proto-1]);$ if (!OK(status)) return status; }! memset(&sin, 0, sizeof(sin));( sin.sin_w_family = NETLIB_K_AF_INET;, sin.sin_w_port = netlib_word_swap(port); sin.sin_x_addr = *addr;5 return netlib_connect(&ctx->ctx, &sin, &sinsize);} /* tcp_connect */ /***++** ROUTINE: tcp_accept**** FUNCTIONAL DESCRIPTION:**B** Accepts an incoming TCP connection (passive open completion).**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**>** TCP_ACCEPT ctxptr, newctxptr [,iosb] [,astadr] [,astprm]**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.i**** COMPLETION CODES: See code.r**** SIDE EFFECTS: None.****--*/1unsigned int tcp_accept (struct COMPATCTX **xctx,lB struct COMPATCTX **xnew, struct NETLIBIOSBDEF *iosb,/ void (*astadr)(), void *astprm) {o struct COMPATCTX *ctx, *new; int argc;  SETARGCOUNT(argc);% if (argc < 2) return SS$_INSFARG;M VERIFY_CONTEXT(xctx, ctx); VERIFY_CONTEXT(xnew, new);7 return netlib_accept(&ctx->ctx, &new->ctx, 0, 0, 0,99 (argc > 2) ? iosb : 0, (argc > 3) ? astadr : 0,.# (argc > 4) ? astprm : 0);1} /* tcp_accept */ n/***++** ROUTINE: tcp_disconnect**** FUNCTIONAL DESCRIPTION:i**"** Closes down a TCP connection.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** TCP_DISCONNECT ctxptr **** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.n**** COMPLETION CODES: See code.-**** SIDE EFFECTS: None.****--*/7unsigned int tcp_disconnect (struct COMPATCTX **xctx) {c struct COMPATCTX *ctx; unsigned int status;< static unsigned int shuttype = NETLIB_K_SHUTDOWN_SENDER; VERIFY_CONTEXT(xctx, ctx);) if (ctx->ctx == 0) return SS$_NORMAL;3 status = netlib_shutdown(&ctx->ctx, &shuttype);? if (!OK(status) && status != SS$_LINKDISCON) return status;p% status = netlib_close(&ctx->ctx); ! if (OK(status)) ctx->ctx = 0;n return status;} /* tcp_disconnect */ v/***++** ROUTINE: tcp_sende**** FUNCTIONAL DESCRIPTION:d**9** Sends data on a TCP connection, possibly followed byt** a CR/LF sequence.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**B** TCP_SEND ctxptr, strdsc [,flags] [,iosb] [,astadr] [,astprm]**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.E**** SIDE EFFECTS: None.****--*/Kunsigned int tcp_send (struct COMPATCTX **xctx, struct dsc$descriptor *str,v> unsigned int flags, struct NETLIBIOSBDEF *iosb,0 void (*astadr)(), void *astprm) { struct COMPATCTX *ctx; unsigned int f;I int argc;  VERIFY_CONTEXT(xctx, ctx); SETARGCOUNT(argc);% if (argc < 2) return SS$_INSFARG; & if (str == 0) return SS$_BADPARAM;* if (ctx->ctx == 0) return SS$_NOLINKS; f = (argc > 2) ? flags : 0;e if (f & NET_M_NOTRM) {E return netlib_write(&ctx->ctx, str, 0, 0, (argc > 3) ? iosb : 0,@ (argc > 4) ? astadr : 0, (argc > 5) ? astprm : 0); } else {C return netlib_writeline(&ctx->ctx, str, (argc > 3) ? iosb : 0,n@ (argc > 4) ? astadr : 0, (argc > 5) ? astprm : 0); }a} /* tcp_send */ t/***++** ROUTINE: tcp_receive**** FUNCTIONAL DESCRIPTION:**%** Reads data off a TCP connection.C**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**G** TCP_RECEIVE ctxptr, bufdsc [,iosb] [,astadr] [,astprm] [,timeout]s**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.n**** COMPLETION CODES: See code.***** SIDE EFFECTS: None.****--*/Nunsigned int tcp_receive (struct COMPATCTX **xctx, struct dsc$descriptor *str,I struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm,n TIME *timeout) { struct COMPATCTX *ctx; struct dsc$descriptor dsc; unsigned int status; int argc;a VERIFY_CONTEXT(xctx, ctx); SETARGCOUNT(argc);% if (argc < 2) return SS$_INSFARG;i& if (str == 0) return SS$_BADPARAM;* if (ctx->ctx == 0) return SS$_NOLINKS;/*J** HACK to support broken MGFTP code, which passes us a static descriptor,** which is set up as a dynamic descriptor!*/K status = lib$analyze_sdesc(str, &dsc.dsc$w_length, &dsc.dsc$a_pointer);D$ dsc.dsc$b_dtype = DSC$K_DTYPE_T;$ dsc.dsc$b_class = DSC$K_CLASS_S;J return netlib_read(&ctx->ctx, &dsc, 0, 0, 0, (argc > 5) ? timeout : 0,> (argc > 2) ? iosb : 0, (argc > 3) ? astadr : 0,( (argc > 4) ? astprm : 0);} /* tcp_receive */t p/***++** ROUTINE: tcp_get_line **** FUNCTIONAL DESCRIPTION:n**G** Reads a "line" of data (a string of characters which is terminatedr3** with a CR/LF sequence) from the TCP connection. **B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**I** TCP_GET_LINE ctxptr, bufdsc [,iosb] [,astadr] [,astprm], [,timeout]E**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.t**** COMPLETION CODES: See code.M**** SIDE EFFECTS: None.****--*/Ounsigned int tcp_get_line (struct COMPATCTX **xctx, struct dsc$descriptor *str,rI struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm,s TIME *timeout) { struct COMPATCTX *ctx;2 static unsigned int flags = NETLIB_M_ALLOW_LF;( static TIME default_timeout = {1,0}; static int did_timeout = 0;e< static $DESCRIPTOR(default_timeoutdsc, "0 00:10:00.00"); int argc;= VERIFY_CONTEXT(xctx, ctx); SETARGCOUNT(argc);% if (argc < 2) return SS$_INSFARG;Y& if (str == 0) return SS$_BADPARAM;* if (ctx->ctx == 0) return SS$_NOLINKS;Z if (!did_timeout) did_timeout = OK(sys$bintim(&default_timeoutdsc, &default_timeout));5 return netlib_readline(&ctx->ctx, str, 0, &flags,lG (argc > 5 && timeout != 0) ? timeout : &default_timeout,> (argc > 2) ? iosb : 0, (argc > 3) ? astadr : 0,( (argc > 4) ? astprm : 0);} /* tcp_get_line */ T/***++** ROUTINE: udp_sendO**** FUNCTIONAL DESCRIPTION:N**** Sends a UDP datagram.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**4** UDP_SEND ctxptr, address, port, bufptr, buflen**** IMPLICIT INPUTS: None.**** IMPLIC NETLIB_SRC.BCKSn?[NETLIB]COMPATIBILITY.C;29Z<s-IT OUTPUTS: None. **** COMPLETION CODES: See code. **** SIDE EFFECTS: None.****--*/Funsigned int udp_send (struct COMPATCTX **xctx, struct INADDRDEF addr,B unsigned short port, void *buf, unsigned short buflen) { struct COMPATCTX *ctx; struct SINDEF sin; struct dsc$descriptor dsc; VERIFY_CONTEXT(xctx, ctx);* if (ctx->ctx == 0) return SS$_NOLINKS;$ dsc.dsc$b_dtype = DSC$K_DTYPE_T;$ dsc.dsc$b_class = DSC$K_CLASS_S; dsc.dsc$w_length = buflen; dsc.dsc$a_pointer = buf;! memset(&sin, 0, sizeof(sin));e( sin.sin_w_family = NETLIB_K_AF_INET; sin.sin_x_addr = addr;, sin.sin_w_port = netlib_word_swap(port);9 return netlib_write(&ctx->ctx, &dsc, &sin, &sinsize);n} /* udp_send */ /***++** ROUTINE: udp_receive**** FUNCTIONAL DESCRIPTION:M**** Receives a UDP datagram.;**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**>** UDP_RECEIVE ctxptr, bufptr, bufsize [,retlen] [,srcaddr]@** [,srcport] [,timeout] [,iosb] [,astadr] [,astprm]**D** N.B.: for synchronous calls, srcport should be the address of aC** longword. For asynchronous calls, it should be the address2** of a word.**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES: See code.)**** SIDE EFFECTS: None.****--*/@unsigned int udp_receive (struct COMPATCTX **xctx, void *bufptr,= unsigned short bufsize, unsigned short *buflen,i? struct INADDRDEF *srcaddr, unsigned int *srcport,i8 TIME *timeout, struct NETLIBIOSBDEF *iosb,/ void (*astadr)(), void *astprm) {  struct COMPATCTX *ctx; struct SINDEF sin; struct dsc$descriptor dsc; unsigned int status; int argc;t VERIFY_CONTEXT(xctx, ctx); SETARGCOUNT(argc);% if (argc < 3) return SS$_INSFARG;) if (bufptr == 0) return SS$_BADPARAM;s* if (ctx->ctx == 0) return SS$_NOLINKS;$ dsc.dsc$b_dtype = DSC$K_DTYPE_T;$ dsc.dsc$b_class = DSC$K_CLASS_S; dsc.dsc$a_pointer = bufptr;x dsc.dsc$w_length = bufsize;" if (argc > 8 && astadr != 0) {" ctx->retaddr = srcaddr; / ctx->retport = (unsigned short *) srcport;D ctx->retlenp = buflen;u ctx->user_iosb = iosb;P ctx->astadr = astadr;+ ctx->astprm = (argc > 9) ? astprm : 0; @ return netlib_read(&ctx->ctx, &dsc, &ctx->rcvsin, &sinsize,8 &ctx->rcvsinlen, timeout, &ctx->iosb,- udp_read_completion, ctx);* }EA status = netlib_read(&ctx->ctx, &dsc, &ctx->rcvsin, &sinsize,A &ctx->rcvsinlen, (argc > 6) ? timeout : 0, &ctx->iosb);  if (OK(status)) {hC if (argc > 3 && buflen != 0) *buflen = ctx->iosb.iosb_w_count;sE if (argc > 4 && srcaddr != 0) *srcaddr = ctx->rcvsin.sin_x_addr;s" if (argc > 5 && srcport != 0)= *srcport = netlib_word_swap(ctx->rcvsin.sin_w_port);( }4K if (argc > 7 && iosb != 0) memcpy(iosb, &ctx->iosb, sizeof(ctx->iosb)); return status;} /* udp_receive */e b/***++ ** ROUTINE: udp_read_completion**** FUNCTIONAL DESCRIPTION: **G** AST completion routine for asynchronous UDP_READ calls. Does somem<** pre-processing before invoking the caller's AST routine.**** RETURNS: void **** PROTOTYPE:**** UDP_READ_COMPLETION ctx**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES: None.**** SIDE EFFECTS: None.****--*/9static void udp_read_completion (struct COMPATCTX *ctx) {/*E** Stash the originating address and port, if the caller wanted themc*/& if (OK(ctx->iosb.iosb_w_status)) {E if (ctx->retaddr != 0) *(ctx->retaddr) = ctx->rcvsin.sin_x_addr;r if (ctx->retport != 0)CD *(ctx->retport) = netlib_word_swap(ctx->rcvsin.sin_w_port);E if (ctx->retlenp != 0) *(ctx->retlenp) = ctx->iosb.iosb_w_count;n }n/*$** Stash the IOSB, if it was wanted*/S if (ctx->user_iosb != 0) memcpy(ctx->user_iosb, &ctx->iosb, sizeof(ctx->iosb));X/*#** Invoke the caller's AST routiner*/ (*ctx->astadr)(ctx->astprm);} /* udp_read_completion */; /***++"** ROUTINE: net_set_trace_routine**** FUNCTIONAL DESCRIPTION:**C** This routine was used in the V1 interface for tracing activity ;** of the MX lookup routine. It no longer has any effect.e**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**"** NET_SET_TRACE_ROUTINE rtnptr**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **1** COMPLETION CODES: SS$_NORMAL always returned.**** SIDE EFFECTS: None.****--*/@unsigned int net_set_trace_routine (unsigned int (*routine)()) { return SS$_NORMAL;} /* net_set_trace_routine */o a/***++** ROUTINE: dns_mxlookN**** FUNCTIONAL DESCRIPTION:)**A** Looks up MX RR's in the DNS for a domain name. Returns themtE** in an array of special structures (the same structure is used for*'** the V2 equivalent of this routine). **B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**5** DNS_MXLOOK name, mxrrsize [,mxrrcount], mxrrptrE**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None._**** COMPLETION CODES: See code.;**** SIDE EFFECTS: None.****--*/Hunsigned int dns_mxlook(struct dsc$descriptor *name, unsigned int *size,? unsigned int *count, struct MXRRDEF *mxrr) {N void *ctx; unsigned int status;! status = netlib_socket(&ctx);# if (!OK(status)) return status;NA status = netlib_dns_mx_lookup(&ctx, name, mxrr, size, count);R netlib_close(&ctx);T return status;} /* dns_mxlook */,lclport]**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/3unsigned int net_get_info (struct COMPATCTX **xctx,> st NETLIB_SRC.BCK&/n?[NETLIB]CONNECT.C;9O *[NETLIB]CONNECT.C;9+,&/./ @ 4O-n?0123KPWO56¢m7m8Bi/9V$ǘG @HJ/***++** FACILITY: NETLIB**** ABSTRACT: Connect by name.**** MODULE DESCRIPTION:**=** This module contains the NETLIB_CONNECT_BY_NAME routine,E** which does establishes an active TCP connect to a remote host and&** port by name, rather than address.**** AUTHOR: M. MadisonM** COPYRIGHT 1994, 1995 MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** CREATION DATE: 25-OCT-1994**** MODIFICATION HISTORY:**1** 25-OCT-1994 V1.0 Madison Initial coding.E** 17-NOV-1994 V1.0-1 Madison Don't use _both_ DNS & host tables!E** 19-JAN-1994 V1.0-2 Madison Fix connect() call completion args.**--*/#include "netlib.h"/*0** Context structure used to track our progress*/ struct Connect_Context { struct NETLIBIOSBDEF iosb; struct dsc$descriptor dsc; unsigned int ctxsize; char *name; struct CTX *ctx; int state;- unsigned int adrcnt, htadrcnt, nsadrcnt; int curadr; void (*astadr)(); void *astprm;% struct NETLIBIOSBDEF *user_iosb; struct SINDEF sin; struct INADDRDEF *adrlst;/ struct INADDRDEF htadrlst[8], nsadrlst[8]; };/*** Forward declarations*/: unsigned int netlib_connect_by_name(struct CTX **xctx,? struct dsc$descriptor *dsc, unsigned short *port,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);@ static unsigned int do_connect(struct Connect_Context *con);/*** OWN storage*/5 static unsigned int usedns = NETLIB_K_LOOKUP_DNS;< static unsigned int useht = NETLIB_K_LOOKUP_HOST_TABLE;8 static unsigned int sinsize = sizeof(struct SINDEF);/*** External references*/F unsigned int netlib_name_to_address(struct CTX **, unsigned int *,: struct dsc$descriptor *, struct INADDRDEF *,# unsigned int *, ...);? unsigned int netlib_connect(struct CTX **, struct SINDEF *,# unsigned int *, ...);O unsigned int netlib_strtoaddr(struct dsc$descriptor *, struct INADDRDEF *); /***++#** ROUTINE: netlib_connect_by_name**** FUNCTIONAL DESCRIPTION:**D** Connects to a remote host/port by name. The name is looked up,D** then a connection is tried to each address until a connection is,** established, or we run out of addresses.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**M** NETLIB_CONNECT_BY_NAME ctxptr, namdsc, port [,iosb] [,astadr] [,astprm]**I** ctxptr: NETLIB context, longword (unsigned), read only, by referenceD** namdsc: char_string, character string, read only, by descriptorD** port: word_unsigned, word (unsigned), read only, by referenceK** iosb: io_status_block, quadword (unsigned), write only, by reference?** astadr: ast_procedure, procedure value, call, by reference?** astprm: user_arg, longword (unsigned), read only, by value**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:2** SS$_NORMAL: normal successful completion*** SS$_INSFARG: not enough arguments'** SS$_BADPARAM: invalid argument2** Codes from LIB$GET_VM, LIB$ANALYZE_SDESC, and'** other NETLIB network status codes.**** SIDE EFFECTS: None.****--*/7unsigned int netlib_connect_by_name (struct CTX **xctx,? struct dsc$descriptor *dsc, unsigned short *port,K struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm) { struct Connect_Context *con; struct CTX *ctx; struct INADDRDEF addr; unsigned int status, size; unsigned short namlen; char *namp; int argc;/*** Verify the arguments*/ VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 3) return SS$_INSFARG;3 if (dsc == 0 || port == 0) return SS$_BADPARAM;/*/** Allocate and fill in the connection context*/4 status = lib$analyze_sdesc(dsc, &namlen, &namp);# if (!OK(status)) return status;3 size = namlen + sizeof(struct Connect_Context);% status = lib$get_vm(&size, &con);# if (!OK(status)) return status; memset(con, 0, size);# con->name = (char *) (con + 1);$ memcpy(con->name, namp, namlen);, INIT_SDESC(con->dsc, namlen, con->name); con->ctx = ctx;- con->sin.sin_w_family = NETLIB_K_AF_INET;2 con->sin.sin_w_port = netlib_word_swap(*port); con->ctxsize = size;: size = sizeof(con->htadrlst)/sizeof(con->htadrlst[0]);5 if (argc > 3 && iosb != 0) con->user_iosb = iosb;" if (argc > 4 && astadr != 0) { con->astadr = astadr;( if (argc > 5) con->astprm = astprm; }/*>** If they provided us with a dotted-decimal IP address, fake@** out do_connect to make it look like we looked up the address ** via DNS.*/1 if (OK(netlib_strtoaddr(&con->dsc, &addr))) {* con->iosb.iosb_w_status = SS$_NORMAL; con->nsadrcnt = 1; con->nsadrlst[0] = addr;A if (con->astadr != 0) return sys$dclast(do_connect, con, 0); return do_connect(con); }/*B** Make lookup via host table synchronous and in main-line thread<** because we can't call it from AST level for all packages*/A status = netlib_name_to_address(&con->ctx, &useht, &con->dsc,@ con->htadrlst, &size, &con->htadrcnt, &con->iosb);' if (!OK(status)) con->htadrcnt = 0;: size = sizeof(con->nsadrlst)/sizeof(con->nsadrlst[0]);/*E** For an asynch call, do the DNS lookup and have DO_CONNECT invoked** as the AST routine*/" if (argc > 4 && astadr != 0) {C status = netlib_name_to_address(&con->ctx, &usedns, &con->dsc,? con->nsadrlst, &size, &con->nsadrcnt, &con->iosb, do_connect, con);7 if (!OK(status)) lib$free_vm(&con->ctxsize, &con); return status; }/**** Synchronous call: do the DNS lookup...*/B status = netlib_name_to_address(&con->ctx, &usedns, &con->dsc,@ con->nsadrlst, &size, &con->nsadrcnt, &con->iosb);/*D** ... if it failed, fall back on the host table lookup info we got*/ if (!OK(status)) {- con->iosb.iosb_w_status = SS$_ENDOFFILE; con->nsadrcnt = 0; }/*0** Just call DO_CONNECT to complete this for us*/ return do_connect(con);} /* netlib_connect_by_name */ /***++** ROUTINE: do_connect**** FUNCTIONAL DESCRIPTION:**;** Completion routine for NETLIB_CONNECT_BY_NAME. Can be@** invoked as a regular main-line routine or an AST completion.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**#** DO_CONNECT connection-context**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**5** COMPLETION CODES: Any NETLIB network status code.**** SIDE EFFECTS: None.****--*/>static unsigned int do_connect (struct Connect_Context *con) { unsigned int status; int done;/*;** We implement our FSM as a loop for the synchronous case*/ done = 0; while (!done) {& status  NETLIB_SRC.BCK&/n?[NETLIB]CONNECT.C;9O= con->iosb.iosb_w_status; switch (con->state) {/*F** Initial state -- if the DNS lookup failed, fall back on host table4** entry. Otherwise, start trying the connections.*/ case 0:# if (con->nsadrcnt == 0) {' if (con->htadrcnt == 0) {7 con->iosb.iosb_w_status = SS$_ENDOFFILE; done = 1; break; }* con->adrlst = con->htadrlst;* con->adrcnt = con->htadrcnt; } else {* con->adrlst = con->nsadrlst;* con->adrcnt = con->nsadrcnt; } con->state = 1; /* and fall through *//*!** State 1: Attempt a connection*/ case 1:; con->sin.sin_x_addr = con->adrlst[con->curadr++]; con->state = 2;A status = netlib_connect(&con->ctx, &con->sin, &sinsize,C &con->iosb, (con->astadr == 0) ? 0 : do_connect,7 (con->astadr == 0) ? 0 : con);$ if (!OK(status)) done = 1;, else if (con->astadr != 0) return; break;/*D** State 2: connect() completion status check. If we're successfulB** or we've run out of addresses, we're done. Otherwise, we loop** back up and try again.*/ case 2:A if (OK(status) || con->curadr >= con->adrcnt) done = 1; con->state = 1; break; } }/*B** We're done, one way or another. Fill in the caller's IOSB and(** call back the AST, if there was one.*/ if (con->user_iosb != 0); memcpy(con->user_iosb, &con->iosb, sizeof(con->iosb));6 if (con->astadr != 0) (*con->astadr)(con->astprm);/*+** We're done with this context -- free it*/% lib$free_vm(&con->ctxsize, &con);/*'** Synchronous completion occurs here.*/ return status;} /* do_connect */  NETLIB_SRC.BCKn?[NETLIB]DNS.C;16R5*[NETLIB]DNS.C;16+,./ @ 4R-n?0123KPWO56e7 !8no89V$ǘG @HJ/***++** FACILITY: NETLIB**#** ABSTRACT: DNS resolver support.**** MODULE DESCRIPTION:**D** This module contains support routines for implementing NETLIB's!** Domain Name Service resolver.**** AUTHOR: M. MadisonG** COPYRIGHT 1994, MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** CREATION DATE: 22-OCT-1994**** MODIFICATION HISTORY:**1** 22-OCT-1994 V1.0 Madison Initial coding.B** 17-NOV-1994 V1.1 Madison Removed socket from DNS context.2** 18-NOV-1994 V1.2 Madison Add retry count.**--*/#include "netlib.h"#include /*** Forward declarations*/4 unsigned int netlib___dns_init(struct CTX *ctx);4 void netlib___free_dns_context(struct CTX *ctx);I int netlib_dns_skipname(unsigned char *bufp, unsigned short *buflen);R unsigned int netlib_dns_expandname(unsigned char *buf, unsigned short *buflen,A unsigned char *bufp, struct dsc$descriptor *namdsc,? unsigned short *retlen, unsigned short *bufchrs);/*** OWN storage*/6 static $DESCRIPTOR(default_timeout, "0 00:00:05");/*** External references*/- int netlib___get_nameservers(QUEUE *nsq);F int netlib___get_domain(char *, unsigned short, unsigned short *); /***++** ROUTINE: netlib___dns_init**** FUNCTIONAL DESCRIPTION:**2** Initializes an internal DNS resolver context.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**'** netlib___dns_init(struct CTX *ctx)**1** ctx: NETLIB context, modify, by reference.**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/2unsigned int netlib___dns_init (struct CTX *ctx) { struct DOMAIN *dom; unsigned int status; ITMLST lnmlst[3]; int i, maxidx; unsigned int size; unsigned short buflen; char buf[256];7 static unsigned int socktype = NETLIB_K_TYPE_DGRAM;8 static unsigned int ctxsize = sizeof(struct DNSCTX);/ static $DESCRIPTOR(tabnam, "LNM$FILE_DEV");7 static $DESCRIPTOR(lognam, "NETLIB_SEARCH_DOMAIN");/*%** Allocate the DNS resolver context*/0 status = lib$get_vm(&ctxsize, &ctx->dnsctx);# if (!OK(status)) return status;! INIT_QUEUE(ctx->dnsctx->nsq);" INIT_QUEUE(ctx->dnsctx->domq);/*:** Get the list of name servers we're supposed to contact*/; if (netlib___get_nameservers(&ctx->dnsctx->nsq) == 0) {) lib$free_vm(&ctxsize, &ctx->dnsctx); ctx->dnsctx = 0; ctx->flags |= CTX_M_NO_DNS; return SS$_UNSUPPORTED; }/*B** Get the list of NETLIB search domains, or the package-specific ** ones.*/G ITMLST_INIT(lnmlst[0], LNM$_MAX_INDEX, sizeof(maxidx), &maxidx, 0);' ITMLST_INIT(lnmlst[1], 0, 0, 0, 0);9 if (OK(sys$trnlnm(0, &tabnam, &lognam, 0, lnmlst))) {: ITMLST_INIT(lnmlst[0], LNM$_INDEX, sizeof(i), &i, 0);D ITMLST_INIT(lnmlst[1], LNM$_STRING, sizeof(buf), buf, &buflen);( ITMLST_INIT(lnmlst[2], 0, 0, 0, 0);$ for (i = 0; i <= maxidx; i++) {M if (OK(sys$trnlnm(0, &tabnam, &lognam, 0, lnmlst)) && buflen != 0) {0 size = buflen + sizeof(struct DOMAIN);, if (OK(lib$get_vm(&size, &dom))) {# dom->length = buflen;- memcpy(dom->name, buf, buflen);' dom->name[buflen] = '\0';8 queue_insert(dom, ctx->dnsctx->domq.tail); } } }@ } else if (netlib___get_domain(buf, sizeof(buf), &buflen)) { char *cp, *cp1; int remain; cp = buf; remain = buflen;/*I** A search domain must have at least two parts, to avoid the ".com.edu"I** problem, which is why we check to make sure that the remaining domain ** string has at least one dot.*/ while (remain > 0) {' cp1 = memchr(cp, '.', remain); if (cp1 == 0) break;/ size = remain + sizeof(struct DOMAIN);+ if (OK(lib$get_vm(&size, &dom))) { dom->length = remain;( memcpy(dom->name, cp, remain);# dom->name[remain] = '\0';4 queue_insert(dom, ctx->dnsctx->domq.tail); } cp = cp1 + 1;" remain -= (cp1 - cp) + 1; } }8 sys$bintim(&default_timeout, &ctx->dnsctx->timeout);! ctx->dnsctx->retry_count = 4; return SS$_NORMAL;} /* netlib___dns_init */  /***++&** ROUTINE: netlib___free_dns_context**** FUNCTIONAL DESCRIPTION:**&** Deallocates the resolver context.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**/** netlib___free_dns_context(struct CTX *ctx)**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/2void netlib___free_dns_context (struct CTX *ctx) { struct NAMESERVER *ns; struct DOMAIN *d; unsigned int size;! if (ctx->dnsctx == 0) return;% size = sizeof(struct NAMESERVER);M while (queue_remove(ctx->dnsctx->nsq.head, &ns)) lib$free_vm(&size, &ns);6 while (queue_remove(ctx->dnsctx->domq.head, &d)) {. size = sizeof(struct DOMAIN) + d->length; lib$free_vm(&size, &d); }! size = sizeof(struct DNSCTX);% lib$free_vm(&size, &ctx->dnsctx); ctx->dnsctx = 0;!} /* netlib___free_dns_context */ /***++ ** ROUTINE: netlib_dns_skipname**** FUNCTIONAL DESCRIPTION:**@** Utility routine for skipping over a name in a DNS response.F** Handles the compressed form of domain string that DNS packets use.**** RETURNS: longword_signed**E** The number of bytes to be skipped in the DNS packet is returned.**** PROTOTYPE:**&** NETLIB_DNS_SKIPNAME bufp, buflen**B** bufp: char_string, character string, read only, by referenceC** buflen: word_unsigned, word (unsigned), read only, by reference**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: None.**** SIDE EFFECTS: None.****--*/Gint netlib_dns_skipname (unsigned char *bufp, unsigned short *buflen) { unsigned char *cp, *eom; cp = bufp; eom = cp + *buflen;" while (cp < eom && *cp != 0) { if (*cp >= 64) cp++; else cp += *cp + 1; } return (cp - bufp) + 1;} /* netlib_dns_skipname */ /***++"** ROUTINE: netlib_dns_expandname**** FUNCTIONAL DESCRIPTION:**C** Expands a domain string from a DNS reply packet into somethingE** human-readable. The string is returned, along with the number ofK** bytes in the DNS packet that composed the name (which won't necessarilyG** be the same as the string length because of the compression used in** DNS packets).**>** RETURNS: cond_value, condition value, write only, by value**** PROTOTYPE:**H** NETLIB_DNS_EXPANDNAME buf, buflen, bufp, namdsc [,retlen] [,count]**C** buf: char_string, character string, read only, by referenceD** buflen: word_unsigned, word (unsigned), read only, by reference?** bufp: pointer, longword (unsigned), modify, by referenceE** namdsc: char_string, character string, write only, by descriptorE** retlen: word_unsigned, word (unsigned), write only, by referenceE** count: word_unsigned, word (unsigned), write only, by reference**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/Ounsigned  NETLIB_SRC.BCKn?[NETLIB]DNS.C;16RY int netlib_dns_expandname (unsigned char *buf, unsigned short *buflen,= unsigned char *bufp, struct dsc$descriptor *namdsc,; unsigned short *retlen, unsigned short *countp) { int argc, indirect; struct dsc$descriptor dsc; char name[256], *namp;! unsigned short namlen, count; unsigned int status; SETARGCOUNT(argc); namp = name; indirect = 0; count = 0; while (*bufp != 0) { if (*bufp < 64) {+ if (!indirect) count += *bufp + 1;. if (namp-name+*bufp < sizeof(name)) {& memcpy(namp, bufp+1, *bufp); namp += *bufp; *namp++ = '.'; } bufp += *bufp + 1; } else {# if (!indirect) count += 2; indirect = 1;K bufp = buf + (netlib_word_swap(*(unsigned short *)bufp) - 0xc000);7 if (bufp - buf > *buflen) return SS$_BADPARAM; } }) INIT_SDESC(dsc, (namp-name)-1, name);* status = lib$scopy_dxdx(&dsc, namdsc);# if (!OK(status)) return status;; if (argc > 4 && retlen != 0) *retlen = namp - name - 1;1 if (argc > 5 && countp != 0) *countp = count; return SS$_NORMAL;} /* netlib_dns_expandname */  NETLIB_SRC.BCKn?[NETLIB]DNS_MXLOOK.C;8[!*[NETLIB]DNS_MXLOOK.C;8+,./ @ 4[-n?0123KPWO56yM7M8Ι<89V$ǘG @HJ/***++** FACILITY: NETLIB**'** ABSTRACT: DNS MX RR lookup routines**** MODULE DESCRIPTION:**?** This module contains routines for implementing MX resource6** record lookups in the DNS using NETLIB's resolver.**** AUTHOR: M. MadisonG** COPYRIGHT 1994, MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** CREATION DATE: 25-OCT-1994**** MODIFICATION HISTORY:**1** 25-OCT-1994 V1.0 Madison Initial coding.**--*/#include "netlib.h"/*** Forward declarations*/: unsigned int netlib___dns_mx_lookup(struct CTX **xctx,B struct dsc$descriptor *namdsc, struct MXRRDEF *mxrr,> unsigned int *mxrrsize, unsigned int *mxrrcount,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);A static unsigned int mxlook_completion(struct DNSREQ *dnsreq);/*** External references*/4 unsigned int netlib___dns_init(struct CTX *ctx);S unsigned int netlib_dns_query(struct CTX **xctx, struct dsc$descriptor *namdsc,6 unsigned int *class, unsigned int *type,: unsigned char *buf, unsigned short *bufsize,> unsigned int *flags, struct NETLIBIOSBDEF *iosb,. void (*astadr)(), void *astprm);I int netlib_dns_skipname(unsigned char *bufp, unsigned short *buflen);R unsigned int netlib_dns_expandname(unsigned char *buf, unsigned short *buflen,A unsigned char *bufp, struct dsc$descriptor *namdsc,? unsigned short *retlen, unsigned short *bufchrs); /***++#** ROUTINE: netlib___dns_mx_lookup**** FUNCTIONAL DESCRIPTION:**?** Performs an MX RR lookup, returning the information in the** special MXRRDEF structure.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**E** NETLIB___DNS_MX_LOOKUP ctx, namdsc, mxrr, mxrrsize [,mxrrcount]4** [,iosb] [,astadr] [,astprm]**Q** ctx: NETLIB context address, longword (unsigned), read only, by referenceD** namdsc: char_string, character string, read only, by descriptorM** mxrr: MXRRDEF structure, longword (unsigned), write only, by referenceM** mxrrsize: longword_unsigned, longword (unsigned), read only, by referenceO** mxrrcount: longword_unsigned, longword (unsigned), write only, by referenceL** iosb: I/O status block, quadword (unsigned), write only, by reference>** astadr: ast_procedure, procedure mask, call, by reference?** astprm: user_arg, longword (unsigned), read only, by value**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/6unsigned int netlib___dns_mx_lookup(struct CTX **xctx,B struct dsc$descriptor *namdsc, struct MXRRDEF *mxrr,> unsigned int *mxrrsize, unsigned int *mxrrcount,K struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm) { struct CTX *ctx; struct DNSREQ *dnsreq; struct IOR *ior; unsigned short bufsize; unsigned int status; int argc;6 static unsigned int class = NETLIB_K_DNS_CLASS_IN;5 static unsigned int type = NETLIB_K_DNS_TYPE_MX;< static unsigned int queryflags = NETLIB_M_DOMAIN_SEARCH; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);/*** Check arguments*/% if (argc < 4) return SS$_INSFARG;G if (namdsc == 0 || mxrr == 0 || mxrrsize == 0) return SS$_BADPARAM;/*C** If NETLIB___DNS_INIT couldn't initialize the resolver, we don't** do DNS stuff*/: if (ctx->flags & CTX_M_NO_DNS) return SS$_UNSUPPORTED;/*)** Initialize the resolver, if necessary*/ if (ctx->dnsctx == 0) {% status = netlib___dns_init(ctx);- if (!OK(status)) return SS$_UNSUPPORTED; }/*K** Allocate a DNS request block (also gets us a generic I/O request block)*/2 GET_DNSREQ(dnsreq, ctx, (argc > 5) ? iosb : 0,+ (argc > 6) ? astadr : 0,, (argc > 7) ? astprm : 0);/*+** Fill in the request and start the query*/ ior = dnsreq->ior; ior->arg[0].address = mxrr;% ior->arg[1].longword = *mxrrsize;5 ior->arg[2].address = (argc > 4) ? mxrrcount : 0;" bufsize = sizeof(dnsreq->buf);: status = netlib_dns_query(&ctx, namdsc, &class, &type,% dnsreq->buf, &bufsize, &queryflags, &ior->iosb,& (ior->astadr == 0) ? 0 = : (void (*)()) mxlook_completion, dnsreq);( if (ior->astadr != 0) return status; if (!OK(status)) { FREE_DNSREQ(dnsreq); return status; }/*>** We get to this point if the query completed synchronously.*/% return mxlook_completion(dnsreq);} /* netlib___dns_mx_lookup */ /***++** ROUTINE: mxlook_completion**** FUNCTIONAL DESCRIPTION:**>** Completion routine for NETLIB___DNS_MXLOOKUP. Can eitherA** be called as an AST routine or in the main-line thread if the&** DNS query completed synchronously.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**"** MXLOOK_COMPLETION dnsrequest**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/?static unsigned int mxlook_completion (struct DNSREQ *dnsreq) {" struct IOR *ior = dnsreq->ior;/ struct MXRRDEF *mxrr = ior->arg[0].address;. unsigned int *count = ior->arg[2].address;$ struct dsc$descriptor dsc, dsc2;" struct NETLIB_DNS_HEADER *hdr; unsigned char *cp; char name[256];0 unsigned short retlen, remain, buflen, skip;, int i, n, ancount, qdcount, type, class;/*&** Check the completion status first.*/' if (!OK(ior->iosb.iosb_w_status)) { if (ior->iosbp != 0) {= ior->iosbp->iosb_w_status = ior->iosb.iosb_w_status;' ior->iosbp->iosb_w_count = 0;' ior->iosbp->iosb_l_unused = 0; } if (count != 0) *count = 0;7 if (ior->astadr != 0) (*ior->astadr)(ior->astprm); FREE_DNSREQ(dnsreq);$ return ior->iosb.iosb_w_status; }/*7** Status was OK, so let's parse out the reply packet.*/3 hdr = (struct NETLIB_DNS_HEADER *) dnsreq->buf;3 ancount = netlib_word_swap(hdr->dns_w_ancount);3 qdcount = netlib_word_swap(hdr->dns_w_qdcount);/*N** We treat all failures as "end of file" (no such name or domain) responses.*/; if (hdr->dns_v_reply_code != NETLIB_K_DNS_RC_SUCCESS) {/ ior->iosbp->iosb_w_status = SS$_ENDOFFILE;" ior->iosbp->iosb_w_count = 0;# ior->iosbp->iosb_l_unused = 0; if (count != 0) *count = 0;7 if (ior->astadr != 0) (*ior->astadr)(ior->astprm); FREE_DNSREQ(dnsreq); return SS$_ENDOFFILE; }/*** Skip over the question*/$ buflen = ior->iosb.iosb_w_count;$ remain = buflen - sizeof(*hdr);$ cp = dnsreq->buf + sizeof(*hdr); while (qdcount-- > 0) {. i = netlib_dns_skipname(cp, &remain) + 4; c  NETLIB_SRC.BCKn?[NETLIB]DNS_MXLOOK.C;8[n-p += i; remain -= i; }/*6** Now parse out the answers, looking for the MX RRs.*/( INIT_SDESC(dsc, sizeof(name), name); n = 0;E while (ancount-- > 0 && remain > 0 && n < ior->arg[1].longword) {[ if (!OK(netlib_dns_expandname(dnsreq->buf, &buflen, cp, &dsc, &retlen, &skip))) break; cp += skip; remain -= skip;4 type = netlib_word_swap(*(unsigned short *)cp); cp += 2; remain -= 2;5 class = netlib_word_swap(*(unsigned short *)cp);3 cp += 6; remain -= 6; /* skip over TTL, too */1 i = netlib_word_swap(*(unsigned short *)cp); cp += 2; remain -= 2;( if (type == NETLIB_K_DNS_TYPE_MX) {M mxrr[n].mxrr_l_preference = netlib_word_swap(*(unsigned short *)cp);C INIT_SDESC(dsc2, NETLIB_S_MXRR_NAME, mxrr[n].mxrr_t_name);T netlib_dns_expandname(dnsreq->buf, &buflen, cp + 2, &dsc2, &retlen, &skip);( mxrr[n].mxrr_l_length = retlen; n++; } cp += i; remain -= i; }/*D** Fill in the status and RR count information and either call back)** (for an AST) or return to the caller.*/ if (count != 0) *count = n; if (ior->iosbp != 0) {, ior->iosbp->iosb_w_status = SS$_NORMAL;# ior->iosbp->iosb_w_count = n;# ior->iosbp->iosb_l_unused = 0; }1 if (ior->astadr) (*ior->astadr)(ior->astprm); FREE_DNSREQ(dnsreq); return SS$_NORMAL;} /* mxlook_completion */  NETLIB_SRC.BCKn?[NETLIB]DNS_QUERY.C;23Y(Y*[NETLIB]DNS_QUERY.C;23+,.(/ @ 4Y(%&-n?0123KPWO)567P8>89V$ǘG @HJ/***++** FACILITY: NETLIB**E** ABSTRACT: Formulates and sends DNS queries, preprocesses replies.**** MODULE DESCRIPTION:**6** This module is the core of NETLIB's DNS resolver.**** AUTHOR: M. MadisonG** COPYRIGHT 1994, MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** CREATION DATE: 24-OCT-1994**** MODIFICATION HISTORY:**1** 24-OCT-1994 V1.0 Madison Initial coding.8** 17-NOV-1994 V1.1 Madison Connect to nameserver.=** 18-NOV-1994 V1.2 Madison Restructure asynch queries.**--*/#include "netlib.h"/*** Forward routines*/S unsigned int netlib_dns_query(struct CTX **xctx, struct dsc$descriptor *namdsc,6 unsigned int *class, unsigned int *type,: unsigned char *buf, unsigned short *bufsize,> unsigned int *flags, struct NETLIBIOSBDEF *iosb,. void (*astadr)(), void *astprm);8 static unsigned int do_query(struct DNSREQ *dnsreq);@ static unsigned int query_nameserver(struct DNSREQ *dnsreq);8 static void query_completion(struct DNSREQ *dnsreq);0 static void do_write(struct DNSREQ *dnsreq);/ static void do_read(struct DNSREQ *dnsreq);/*** External references*/4 unsigned int netlib___dns_init(struct CTX *ctx);3 unsigned int netlib_socket(struct CTX **, ...);K unsigned int netlib_connect(struct CTX **, void *, unsigned int *,...);K unsigned int netlib_write(struct CTX **, struct dsc$descriptor *, ...);J unsigned int netlib_read(struct CTX **, struct dsc$descriptor *, ...);- unsigned int netlib_close(struct CTX **); /***++** ROUTINE: netlib_dns_query**** FUNCTIONAL DESCRIPTION:**B** Formulates a DNS query, sends it out, and obtains a reply (if** possible).**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**?** NETLIB_DNS_QUERY ctx, namdsc, [class], type, buf, bufsize8** [,flags] [,iosb] [,astadr] [,astprm]**O** ctx: NETLIB context address, longword_unsigned, read only, by referenceD** namdsc: char_string, character string, read only, by descriptorL** class: longword_unsigned, longword (unsigned), read only, by referenceL** type: longword_unsigned, longword (unsigned), read only, by referenceG** buf: varying_arg, longword (unsigned), write only, by referenceD** bufsize: word_unsigned, word (unsigned), read only, by referenceH** flags: mask_longword, longword (unsigned), read only, by referenceK** iosb: io_status_block, quadword (unsigned), write only, by reference?** astadr: ast_procedure, procedure value, call, by reference?** astprm: user_arg, longword (unsigned), read only, by value**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/Ounsigned int netlib_dns_query(struct CTX **xctx, struct dsc$descriptor *namdsc,7 unsigned int *xclass, unsigned int *type,: unsigned char *buf, unsigned short *bufsize,? unsigned int *xflags, struct NETLIBIOSBDEF *iosb,/ void (*astadr)(), void *astprm) { struct CTX *ctx; struct DNSREQ *dnsreq; struct IOR *ior;! struct NETLIB_DNS_HEADER *hp;& unsigned int class, flags, status; unsigned short namlen; char *name; int argc;/*"** Sanity-check the argument list*/ VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 6) return SS$_INSFARG;R if (namdsc == 0 || type == 0 || buf == 0 || bufsize == 0) return SS$_BADPARAM;/*B** Make sure we're doing DNS, and initialize the resolver context ** if needed*/: if (ctx->flags & CTX_M_NO_DNS) return SS$_UNSUPPORTED; if (ctx->dnsctx == 0) {% status = netlib___dns_init(ctx);- if (!OK(status)) return SS$_UNSUPPORTED; }/*** Process the input arguments*/7 status = lib$analyze_sdesc(namdsc, &namlen, &name);# if (!OK(status)) return status;3 if (xclass == 0) class = NETLIB_K_DNS_CLASS_IN; else class = *xclass;@ if (argc < 7 || xflags == 0) flags = NETLIB_M_DOMAIN_SEARCH; else flags = *xflags;/*%** Allocate DNS & I/O request blocks*/2 GET_DNSREQ(dnsreq, ctx, (argc > 7) ? iosb : 0,+ (argc > 8) ? astadr : 0,, (argc > 9) ? astprm : 0);/*&** Initialize the domain search stuff*/M if ((flags & NETLIB_M_DOMAIN_SEARCH) && memchr(name, '.', namlen) == 0) {- dnsreq->curdom = ctx->dnsctx->domq.head; } else { dnsreq->curdom = 0; }/*B** Fill in the DNS request block and call DO_QUERY to do the work*/ dnsreq->query_name = name;# dnsreq->query_namlen = namlen; dnsreq->query_flags = flags; dnsreq->query_rbuf = buf;& dnsreq->query_rbufsize = *bufsize; dnsreq->query_class = class; dnsreq->query_type = *type; dnsreq->ctx = ctx;3 dnsreq->retries = ctx->dnsctx->retry_count; return do_query(dnsreq);} /* netlib_dns_query */ /***++** ROUTINE: do_query**** FUNCTIONAL DESCRIPTION:**K** Does the actual work of formatting a query. Calls on QUERY_NAMESERVER,** to send the query out and get the reply.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** DO_QUERY dnsrequest**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/6static unsigned int do_query (struct DNSREQ *dnsreq) {" struct IOR *ior = dnsreq->ior;" struct CTX *ctx = dnsreq->ctx;$ struct DNSCTX *dc = ctx->dnsctx;! struct NETLIB_DNS_HEADER *hp; char *anchor, *cp; unsigned char *bp; int i, j; unsigned int status;/*G** This is set up as a loop for synchronous queries. For asynchronous>** queries, we return as soon as the query has been sent out.*/ while (1) {/*** Format the query header*/3 hp = (struct NETLIB_DNS_HEADER *) dnsreq->buf;5 memset(hp, 0, sizeof(struct NETLIB_DNS_HEADER));' hp->dns_w_queryid = ++dc->queryid;. hp->dns_v_opcode = NETLIB_K_DNS_OP_STDQ;Y hp->dns_v_recursion_desired = (dnsreq->query_flags & NETLIB_M_NO_RECURSION) ? 0 : 1;- hp->dns_w_qdcount = netlib_word_swap(1);/*/** Fill in the question -- the name part first*/9 bp = dnsreq->buf + sizeof(struct NETLIB_DNS_HEADER);! anchor = dnsreq->query_name; i = dnsreq->query_namlen; while (i > 0) {% cp = memchr(anchor, '.', i); if (cp == 0) { *bp++ = i;) memcpy(bp, anchor, i); bp += i; break; } else { j = cp - anchor; *bp++ = j; memcpy(bp, anchor, j); bp += j; i -= j + 1; } anchor = cp + 1; }/*9** And the search domain, if we're doing search domains.*/ if (dnsreq->curdom == 0) {J dnsreq->curdom = (dnsreq- NETLIB_SRC.BCKn?[NETLIB]DNS_QUERY.C;23Y(>query_flags & NETLIB_M_DOMAIN_SEARCH) ?? dc->domq.head : (struct DOMAIN *) &dc->domq; } else {' anchor = dnsreq->curdom->name;$ i = dnsreq->curdom->length;( if (i >= 1 && *anchor == '.') { anchor++; i--; } while (i > 0) {& cp = memchr(anchor, '.', i); if (cp == 0) { *bp++ = i;- memcpy(bp, anchor, i); bp += i; break; } else { j = cp - anchor; *bp++ = j;$ memcpy(bp, anchor, j); bp += j; i -= j + 1; } anchor = cp + 1; }0 dnsreq->curdom = dnsreq->curdom->flink; }/*1** Terminate the name, insert the type and class*/ *bp++ = '\0';L *(unsigned short *) bp = netlib_word_swap(dnsreq->query_type); bp += 2;M *(unsigned short *) bp = netlib_word_swap(dnsreq->query_class); bp += 2;' dnsreq->buflen = bp - dnsreq->buf;/*$** Start with the first name server*/" dnsreq->curns = dc->nsq.head;/*(** If ASTADR is 0, this is synchronous.*/ if (ior->astadr == 0) {/*G** Loop through all the nameservers until we get a successful response'** back, or we run out of nameservers.*/B while (dnsreq->curns != (struct NAMESERVER *) &dc->nsq) {, status = query_nameserver(dnsreq); if (OK(status)) break;/ dnsreq->curns = dnsreq->curns->flink; }/*D** Check status and verify the reply code from the server. If it'sG** not a successful reply, move on to the next search domain; if we'veF** run through all the search domains, return the ENDOFFILE error (no** such host or domain).*/ if (!OK(status)) {# status = SS$_UNREACHABLE;J } else if (dnsreq->replylen > sizeof(struct NETLIB_DNS_HEADER)) {? hp = (struct NETLIB_DNS_HEADER *) dnsreq->query_rbuf;@ if (hp->dns_v_reply_code == NETLIB_K_DNS_RC_SUCCESS) {" status = SS$_NORMAL; } else {B if (dnsreq->curdom != (struct DOMAIN *) &dc->domq) {< continue; /* back to top of while(1) loop */ }% status = SS$_ENDOFFILE; }& } else status = SS$_PROTOCOL;/*D** Return the results to the caller (still in synch I/O processing)*/ if (ior->iosbp != 0) {- ior->iosbp->iosb_w_status = status;6 ior->iosbp->iosb_w_count = dnsreq->replylen;( ior->iosbp->iosb_l_unused = 0; } FREE_DNSREQ(dnsreq); return status;/*D** For asynchronous calls, just fire off a query and do the rest of1** the processing in the AST completion routine.*/ } else {) return query_nameserver(dnsreq); } } /* while (1) */7 return SS$_DATACHECK; /* should never reach here */} /* do_query */ /***++** ROUTINE: query_nameserver**** FUNCTIONAL DESCRIPTION:**$** Sends a query to a name server.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**!** QUERY_NAMESERVER dnsrequest**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/>static unsigned int query_nameserver (struct DNSREQ *dnsreq) {" struct IOR *ior = dnsreq->ior;" struct CTX *ctx = dnsreq->ctx;, struct DNSCTX *dc = dnsreq->ctx->dnsctx;( struct NETLIB_DNS_HEADER *hp1, *hp2; struct dsc$descriptor dsc;! unsigned int status, sinsize;4 static unsigned int dgram = NETLIB_K_TYPE_DGRAM;/*** Set up the socket address*/1 memset(&dnsreq->sin, 0, sizeof(dnsreq->sin));0 dnsreq->sin.sin_w_family = NETLIB_K_AF_INET;2 dnsreq->sin.sin_w_port = netlib_word_swap(53);1 dnsreq->sin.sin_x_addr = dnsreq->curns->addr;/*A** Create the socket and "connect" it to the server. We do thisH** so we can find out right away whether or not the server is listeningE** on that UDP port, rather than waiting for the reply timeout if weJ** were to use sendto/recvfrom. It's also more efficient to do a connect(** in BSD-based TCP/IP implementations.*/H status = ior->iosb.iosb_w_status = netlib_socket(&ior->ctx, &dgram); if (OK(status)) {# sinsize = sizeof(dnsreq->sin); if (ior->astadr != 0) {C status = netlib_connect(&ior->ctx, &dnsreq->sin, &sinsize,6 &ior->iosb, do_write, dnsreq);' if (OK(status)) return status;* ior->iosb.iosb_w_status = status; } else {D status = netlib_connect(&ior->ctx, &dnsreq->sin, &sinsize); if (OK(status)) {7 INIT_SDESC(dsc, dnsreq->buflen, dnsreq->buf);C status = netlib_write(&ior->ctx, &dsc, 0, 0, &ior->iosb);; if (OK(status)) status = ior->iosb.iosb_w_status;0 else ior->iosb.iosb_w_status = status; } }. if (!OK(status)) netlib_close(&ior->ctx); } if (!OK(status)) { ior->ctx = 0;) if (ior->astadr == 0) return status; query_completion(dnsreq); return SS$_NORMAL; }/*G** OK, we've got ourselves connected and sent off the query. Now readL** the reply. This loop handles synchronous reads; asynch reply processing#** is handled in QUERY_COMPLETION.*/ while (1) {A INIT_SDESC(dsc, dnsreq->query_rbufsize, dnsreq->query_rbuf);N status = netlib_read(&ior->ctx, &dsc, 0, 0, 0, &dc->timeout, &ior->iosb);/*8** Make sure that the reply is to the query we sent out*/ if (OK(status)) {G if (ior->iosb.iosb_w_count < sizeof(struct NETLIB_DNS_HEADER)) continue;8 hp1 = (struct NETLIB_DNS_HEADER *) dnsreq->buf;? hp2 = (struct NETLIB_DNS_HEADER *) dnsreq->query_rbuf;8 if (hp1->dns_w_queryid == hp2->dns_w_queryid) {4 dnsreq->replylen = ior->iosb.iosb_w_count;" netlib_close(&ior->ctx); ior->ctx = 0; return SS$_NORMAL; }/*?** If the reply timed out, try again. This is UDP, after all.*/ } else {B if ((status == SS$_TIMEOUT) && (--dnsreq->retries > 0)) {7 INIT_SDESC(dsc, dnsreq->buflen, dnsreq->buf);C status = netlib_write(&ior->ctx, &dsc, 0, 0, &ior->iosb);# if (OK(status)) continue; }! netlib_close(&ior->ctx); ior->ctx = 0; return status; } }7 return SS$_DATACHECK; /* should never reach here */} /* query_nameserver */ /***++** ROUTINE: query_completion**** FUNCTIONAL DESCRIPTION:**2** Completion processing for a reply to a query.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**!** QUERY_COMPLETION dnsrequest**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: See code.**** SIDE EFFECTS: None.****--*/6static void query_completion (struct DNSREQ *dnsreq) {" struct IOR *ior = dnsreq->ior;" struct CTX *ctx = dnsreq->ctx;$ struct DNSCTX *dc = ctx->dnsctx;( struct NETLIB_DNS_HEADER *hp1, *hp2; struct dsc$descriptor dsc; unsigned int status;/*I** If completion status was OK, verify that the response is to the query5** we sent out. If it wasn't queue up another read.*/% status = ior->iosb.iosb_w_status;S if (OK(status) && ior->iosb.iosb_w_count >= sizeof(struct NETLIB_DNS_H NETLIB_SRC.BCKn?[NETLIB]DNS_QUERY.C;23Y(`EADER)) {4 hp1 = (struct NETLIB_DNS_HEADER *) dnsreq->buf;; hp2 = (struct NETLIB_DNS_HEADER *) dnsreq->query_rbuf;4 if (hp1->dns_w_queryid == hp2->dns_w_queryid) {4 if (ior->ctx != 0) netlib_close(&ior->ctx); ior->ctx = 0; if (ior->iosbp != 0)< memcpy(ior->iosbp, &ior->iosb, sizeof(ior->iosb));% (*ior->astadr)(ior->astprm); FREE_DNSREQ(dnsreq); return; } else {E INIT_SDESC(dsc, dnsreq->query_rbufsize, dnsreq->query_rbuf);E status = netlib_read(&ior->ctx, &dsc, 0, 0, 0, &dc->timeout,9 &ior->iosb, query_completion, dnsreq); if (OK(status)) return; } }/*'** If we timed out, re-send the query.*/= if ((status == SS$_TIMEOUT) && (--dnsreq->retries > 0)) {2 INIT_SDESC(dsc, dnsreq->buflen, dnsreq->buf);1 status = netlib_write(&ior->ctx, &dsc, 0, 0,1 &ior->iosb, do_read, dnsreq); if (OK(status)) return; }/*?** Done with this connection. Don't need the socket any more.*/ if (ior->ctx != 0) { netlib_close(&ior->ctx); ior->ctx = 0; }/*@** Set things up for moving on to next server; if we've run outC** of servers, move on to next search domain. If we've run out of9** those, we report the last error we got to the caller.*/) dnsreq->curns = dnsreq->curns->flink;: if (dnsreq->curns == (struct NAMESERVER *) &dc->nsq) {9 if (dnsreq->curdom == (struct DOMAIN *) &dc->domq) {I if (ior->iosbp != 0) < memcpy(ior->iosbp, &ior->iosb, sizeof(ior->iosb));% (*ior->astadr)(ior->astprm);  FREE_DNSREQ(dnsreq);D return; }/*** Next query*/ do_query(dnsreq); return; }E/*** Next nameserver**/ query_nameserver(dnsreq);} /* query_completion */ /***++** ROUTINE: do_writes**** FUNCTIONAL DESCRIPTION:-**B** Queue a write to the nameserver (for asynch queries). Called%** as completion AST on the connect.***B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** DO_WRITE dnsreqc**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.s**** COMPLETION CODES: See code.n**** SIDE EFFECTS: None.****--*/.static void do_write (struct DNSREQ *dnsreq) {" struct IOR *ior = dnsreq->ior; struct dsc$descriptor dsc; unsigned int status;% status = ior->iosb.iosb_w_status;n if (OK(status)) {c2 INIT_SDESC(dsc, dnsreq->buflen, dnsreq->buf);O status = netlib_write(&ior->ctx, &dsc, 0, 0, &ior->iosb, do_read, dnsreq);t }i if (OK(status)) return;)% ior->iosb.iosb_w_status = status;  query_completion(dnsreq);s} /* do_write */ n/***++** ROUTINE: do_read**** FUNCTIONAL DESCRIPTION:n**B** Queues a read to the nameserver (for asynch queries). Called"** as completion AST to DO_WRITE.**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** DO_READ dnsrequest**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None._**** COMPLETION CODES: See code.P**** SIDE EFFECTS: None.****--*/-static void do_read (struct DNSREQ *dnsreq) {." struct IOR *ior = dnsreq->ior;, struct DNSCTX *dc = dnsreq->ctx->dnsctx; struct dsc$descriptor dsc; unsigned int status;% status = ior->iosb.iosb_w_status;  if (OK(status)) {dA INIT_SDESC(dsc, dnsreq->query_rbufsize, dnsreq->query_rbuf);iA status = netlib_read(&ior->ctx, &dsc, 0, 0, 0, &dc->timeout, : &ior->iosb, query_completion, dnsreq); }o if (OK(status)) return;y% ior->iosb.iosb_w_status = status;d query_completion(dnsreq);y} /* do_read */ f: varying_arg, longword (unsigned), write only, by referenceD** bufsize: word_unsigned, word (unsigned), read only, by referenceH** flags: mask_longword, longword (unsigned), read only, by referenceK**  NETLIB_SRC.BCK/n?[NETLIB]LINEMODE.C;11S*[NETLIB]LINEMODE.C;11+,/./ @ 4S-n?0123KPWO56|7tg8tCi/9V$ǘG @HJ/***++** FACILITY: NETLIB**1** ABSTRACT: Line-mode send and receive routines**** MODULE DESCRIPTION:**@** Note that character strings are just allocated using malloc.**** AUTHOR: M. Madison1** COPYRIGHT 1994, MADGOAT SOFTWARE."** ALL RIGHTS RESERVED.**** CREATION DATE: 22-OCT-1994**** MODIFICATION HISTORY:**1** 22-OCT-1994 V1.0 Madison Initial coding.9** 09-JAN-1995 V1.0-1 Madison Read data in 1K chunks.D** 11-JAN-1995 V1.0-2 Madison Fix timeout reference in readline.M** 13-JAN-1995 V1.0-3 Madison Fix split CR/LF handling in parse_out_line.4** 25-JAN-1995 V1.0-4 Madison Fix ofr CR w/o LF.**--*/#include "netlib.h"/*** Forward declarations*/O unsigned int netlib_readline(struct CTX **xctx, struct dsc$descriptor *dsc,@ unsigned short *retlen, unsigned int *flagp,> TIME *timeout, struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm);3 static void readline_continue(struct IOR *ior);J static int parse_out_line(struct CTX *ctx, struct dsc$descriptor *dsc,, unsigned short *retlen);P unsigned int netlib_writeline(struct CTX **xctx, struct dsc$descriptor *dsc,1 struct NETLIBIOSBDEF *iosb,6 void (*astadr)(), void *astprm);4 static void writeline_continue(struct IOR *ior);2 static void writeline_finish(struct IOR *ior);/*** OWN storage*/% static $DESCRIPTOR(crlf, "\r\n");/*** External references*/= unsigned int netlib_read(struct CTX **xctx, void *, ...);> unsigned int netlib_write(struct CTX **xctx, void *, ...); /***++** ROUTINE: x**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Lunsigned int netlib_readline (struct CTX **xctx, struct dsc$descriptor *dsc,@ unsigned short *retlen, unsigned int *flagp,> TIME *timeout, struct NETLIBIOSBDEF *iosb,5 void (*astadr)(), void *astprm) { struct CTX *ctx; struct NETLIBIOSBDEF myiosb; struct dsc$descriptor sdsc; unsigned int status; unsigned short len; int argc; VERIFY_CTX(xctx, ctx) SETARGCOUNT(argc);% if (argc < 2) return SS$_INSFARG;D if (argc < 4 || flagp == 0) ctx->line_flags = NETLIB_M_ALLOW_LF;" else ctx->line_flags = *flagp; if (ctx->linebuf == 0) {. static unsigned int size = CTX_S_LINEBUF;/ status = lib$get_vm(&size, &ctx->linebuf);$ if (!OK(status)) return status; ctx->line_remain = 0;4 ctx->linebufp = ctx->lineanchor = ctx->linebuf; } len = 0; while (1) {* if (parse_out_line(ctx, dsc, &len)) {4 if (argc > 2 && retlen != 0) *retlen = len; status = SS$_NORMAL; break; }A INIT_SDESC(sdsc, CTX_S_LINEBUF-(ctx->linebufp-ctx->linebuf)," ctx->linebufp);< if (sdsc.dsc$w_length > 1024) sdsc.dsc$w_length = 1024;# if (argc > 6 && astadr != 0) { struct IOR *ior;B GET_IOR(ior, ctx, iosb, astadr, (argc > 7) ? astprm : 0);# ctx->line_retlen = retlen; ctx->line_dsc = dsc;$ ctx->line_tmo = timeout;? netlib_read(xctx, &sdsc, 0, 0, 0, timeout, &ior->iosb,, readline_continue, ior); return SS$_NORMAL; }S status = netlib_read(xctx, &sdsc, 0, 0, 0, (argc > 4) ? timeout : 0, &myiosb); if (!OK(status)) break;, ctx->line_remain = myiosb.iosb_w_count; } /* while *// if (argc > 2 && retlen != 0) *retlen = len; if (argc > 5 && iosb != 0) {" iosb->iosb_w_status = status; iosb->iosb_w_count = len; }" if (argc > 6 && astadr != 0) {4 sys$dclast(astadr, (argc > 7) ? astprm : 0, 0); return SS$_NORMAL; } return status;} /* netlib_readline */ /***++** ROUTINE: readline_continue**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/1static void readline_continue (struct IOR *ior) { struct CTX *ctx = ior->ctx; struct dsc$descriptor sdsc; unsigned int status; unsigned short len;' if (!OK(ior->iosb.iosb_w_status)) { if (ior->iosbp != 0) {$ ior->iosbp->iosb_w_status =" ior->iosb.iosb_w_status;& ior->iosbp->iosb_w_count = 0; }8 if (ctx->line_retlen != 0) *(ctx->line_retlen) = 0;7 if (ior->astadr != 0) (*ior->astadr)(ior->astprm); FREE_IOR(ior); return; }. ctx->line_remain = ior->iosb.iosb_w_count;3 if (parse_out_line(ctx, ctx->line_dsc, &len)) { if (ior->iosbp != 0) {0 ior->iosbp->iosb_w_status = SS$_NORMAL;( ior->iosbp->iosb_w_count = len; }: if (ctx->line_retlen != 0) *(ctx->line_retlen) = len;7 if (ior->astadr != 0) (*ior->astadr)(ior->astprm); FREE_IOR(ior); return; } P INIT_SDESC(sdsc, CTX_S_LINEBUF-(ctx->linebufp-ctx->linebuf), ctx->linebufp);; if (sdsc.dsc$w_length > 1024) sdsc.dsc$w_length = 1024;@ netlib_read(&ctx, &sdsc, 0, 0, 0, ctx->line_tmo, &ior->iosb,, readline_continue, ior); return;} /* readline_continue */ /***++** ROUTINE: parse_out_line**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Gstatic int parse_out_line (struct CTX *ctx, struct dsc$descriptor *dsc,- unsigned short *retlen) { unsigned short len; unsigned char *cp;" while (ctx->line_remain > 0) {, if (ctx->flags & CTX_M_LINE_FOUND_CR) {, ctx->flags &= ~CTX_M_LINE_FOUND_CR;& if (*ctx->linebufp == '\n') {6 len = (ctx->linebufp - ctx->lineanchor) - 1;1 str$copy_r(dsc, &len, ctx->lineanchor); *retlen = len; ctx->line_remain -= 1; ctx->linebufp += 1;* ctx->lineanchor = ctx->linebufp; return 1; } }8 cp = memchr(ctx->linebufp, '\r', ctx->line_remain); if (cp == 0) {3 if (ctx->line_flags & NETLIB_M_ALLOW_LF) {= cp = memchr(ctx->linebufp, '\n', ctx->line_remain); if (cp != 0) {) len = cp - ctx->lineanchor;5 str$copy_r(dsc, &len, ctx->lineanchor); *retlen = len;5 len -= (ctx->lin NETLIB_SRC.BCK/n?[NETLIB]LINEMODE.C;11S0Debufp-ctx->lineanchor);* ctx->line_remain -= len + 1;' ctx->linebufp += len + 1;. ctx->lineanchor = ctx->linebufp; return 1; } }+ ctx->linebufp += ctx->line_remain; ctx->line_remain = 0; } else {< if ((cp - ctx->linebufp) == (ctx->line_remain-1)) {, ctx->flags |= CTX_M_LINE_FOUND_CR;, ctx->linebufp += ctx->line_remain; ctx->line_remain = 0; } else {" if (*(cp + 1) == '\n') {) len = cp - ctx->lineanchor;5 str$copy_r(dsc, &len, ctx->lineanchor); *retlen = len;5 len -= (ctx->linebufp-ctx->lineanchor);* ctx->line_remain -= len + 2;' ctx->linebufp += len + 2;. ctx->lineanchor = ctx->linebufp; return 1; } else {; ctx->line_remain -= (cp - ctx->linebufp) + 1;% ctx->linebufp = cp + 1; } } } }= if (ctx->linebufp - ctx->lineanchor >= CTX_S_LINEBUF-2) {+ len = ctx->linebufp - ctx->lineanchor;, str$copy_r(dsc, &len, ctx->lineanchor); ctx->line_remain = 0;4 ctx->lineanchor = ctx->linebufp = ctx->linebuf; *retlen = len; return 1; } if (ctx->line_remain > 0 ||L (ctx->linebufp - ctx->linebuf == CTX_S_LINEBUF-ctx->line_remain)) {< len = ctx->line_remain + ctx->linebufp-ctx->lineanchor;1 memmove(ctx->linebuf, ctx->lineanchor, len);( ctx->linebufp = ctx->linebuf + len;$ ctx->lineanchor = ctx->linebuf; ctx->line_remain = 0; } return 0;} /* parse_out_line */ /***++** ROUTINE: netlib_writeline**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Munsigned int netlib_writeline (struct CTX **xctx, struct dsc$descriptor *dsc,1 struct NETLIBIOSBDEF *iosb,7 void (*astadr)(), void *astprm) { struct CTX *ctx; struct IOR *ior; struct NETLIBIOSBDEF myiosb; char *line; unsigned short len; unsigned int status, count; int argc; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 2) return SS$_INSFARG;& if (dsc == 0) return SS$_BADPARAM;" if (argc > 3 && astadr != 0) {> GET_IOR(ior, ctx, iosb, astadr, (argc > 4) ? astprm : 0);5 return netlib_write(xctx, dsc, 0, 0, &ior->iosb,' writeline_continue, ior); }4 status = netlib_write(xctx, dsc, 0, 0, &myiosb); count = myiosb.iosb_w_count; if (OK(status)) {7 status = netlib_write(xctx, &crlf, 0, 0, &myiosb);" count += myiosb.iosb_w_count; } if (argc > 2 && iosb != 0) {" iosb->iosb_w_status = status; iosb->iosb_w_count = count; iosb->iosb_l_unused = 0; } return status;} /* netlib_writeline */ /***++** ROUTINE: writeline_continue**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/2static void writeline_continue (struct IOR *ior) { struct CTX *ctx = ior->ctx; unsigned int status; if (ior->iosbp != 0)7 ior->iosbp->iosb_w_count = ior->iosb.iosb_w_count;% status = ior->iosb.iosb_w_status; ior->iorflags = 0; if (OK(status)) {9 status = netlib_write(&ctx, &crlf, 0, 0, &ior->iosb,& writeline_finish, ior); } if (!OK(status)) {= if (ior->iosbp != 0) ior->iosbp->iosb_w_status = status;7 if (ior->astadr != 0) (*ior->astadr)(ior->astprm); FREE_IOR(ior); }} /* writeline_continue */ /***++** ROUTINE: writeline_finish**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/0static void writeline_finish (struct IOR *ior) { if (ior->iosbp != 0) {9 ior->iosbp->iosb_w_status = ior->iosb.iosb_w_status;8 ior->iosbp->iosb_w_count += ior->iosb.iosb_w_count; }6 if (ior->astadr != 0) (*ior->astadr)(ior->astprm); FREE_IOR(ior);} /* writeline_finish */  NETLIB_SRC.BCK%n?[NETLIB]MEM.C;5Wl*[NETLIB]MEM.C;5+,%./ @ 4W-n?0123KPWO56Cz7Cz8g͗89V$ǘG @HJ/***++** FACILITY: NETLIB**(** ABSTRACT: Memory management routines**** MODULE DESCRIPTION:**@** Note that character strings are just allocated using malloc.**** AUTHOR: M. Madison1** COPYRIGHT 1994, MADGOAT SOFTWARE."** ALL RIGHTS RESERVED.**** CREATION DATE: 02-APR-1994**** MODIFICATION HISTORY:**1** 02-APR-1994 V1.0 Madison Initial coding.3** 09-NOV-1994 V1.1 Madison AAdd IOR, DNSREQ.**--*/#define __NETLIB_MODULE_MEM__#include "netlib.h"#include /*** Forward declarations*/A unsigned int netlib___alloc_ctx(struct CTX **, unsigned int);1 unsigned int netlib___free_ctx(struct CTX *);3 unsigned int netlib___alloc_ior(struct IOR **);1 unsigned int netlib___free_ior(struct IOR *);9 unsigned int netlib___alloc_dnsreq(struct DNSREQ **);7 unsigned int netlib___free_dnsreq(struct DNSREQ *);/*** OWN and GLOBAL storage*/$ static unsigned int ctxzone = 0;: static unsigned int CTX_S_CTXDEF = sizeof(struct CTX);$ static unsigned int iorzone = 0;: static unsigned int IOR_S_IORDEF = sizeof(struct IOR);' static unsigned int dnsreqzone = 0;C static unsigned int DNSREQ_S_DNSREQDEF = sizeof(struct DNSREQ);#pragma nostandard9 globaldef unsigned int netlib_synch_efn = 0xffffffff;: globaldef unsigned int netlib_asynch_efn = 0xffffffff;#pragma standard- static QUEUE iorque = {&iorque, &iorque};6 static QUEUE dnsreqque = {&dnsreqque, &dnsreqque};/*** External references*/1 void netlib___free_dns_context(struct CTX *); /***++** ROUTINE: netlib___alloc_ctx**** FUNCTIONAL DESCRIPTION:**** Allocates some memory.**** RETURNS: cond_value**** PROTOTYPE:**5** netlib___alloc_ctx(unsigned int size, void *ptr)**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: None.**** SIDE EFFECTS: None.****--*/Lunsigned int netlib___alloc_ctx (struct CTX **ctxp, unsigned int specsize) { struct CTX *ctx;+ unsigned int status, fullsize, aststat; aststat = sys$setast(0);) if (netlib_synch_efn == 0xffffffff) {, status = lib$get_ef(&netlib_synch_efn); if (!OK(status)) {2 if (aststat == SS$_WASSET) sys$setast(1); return status; } }* if (netlib_asynch_efn == 0xffffffff) {- status = lib$get_ef(&netlib_asynch_efn); if (!OK(status)) {2 if (aststat == SS$_WASSET) sys$setast(1); return status; } }' fullsize = specsize + CTX_S_CTXDEF; if (ctxzone == 0) {+ unsigned int algorithm=LIB$K_VM_FIXED;@ unsigned int flags=LIB$M_VM_GET_FILL0|LIB$M_VM_EXTEND_AREA;J status = lib$create_vm_zone(&ctxzone, &algorithm, &fullsize, &flags); if (!OK(status)) {2 if (aststat == SS$_WASSET) sys$setast(1); return status; } }- if (aststat == SS$_WASSET) sys$setast(1);3 status = lib$get_vm(&fullsize, &ctx, &ctxzone); if (OK(status)) { ctx->specctx = ctx + 1;" ctx->specctx_size = specsize;= if (!OK(status)) lib$free_vm(&fullsize, &ctx, &ctxzone); *ctxp = ctx; return SS$_NORMAL; } return status;} /* netlib___alloc_ctx */ /***++** ROUTINE: netlib___free_ctx**** FUNCTIONAL DESCRIPTION:**** Frees a block of memory.**** RETURNS: void**** PROTOTYPE:**%** netlib___free_ctx(struct CMD *c)**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: None.**** SIDE EFFECTS: None.****--*/2unsigned int netlib___free_ctx (struct CTX *ctx) { unsigned int fullsize; if (ctx->linebuf != 0) { fullsize = CTX_S_LINEBUF;+ lib$free_vm(&fullsize, &ctx->linebuf); }# netlib___free_dns_context(ctx);0 fullsize = ctx->specctx_size + CTX_S_CTXDEF;2 return lib$free_vm(&fullsize, &ctx, &ctxzone);} /* netlib___free_ctx */ /***++** ROUTINE: netlib___alloc_ior**** FUNCTIONAL DESCRIPTION:**** Allocates some memory.**** RETURNS: cond_value**** PROTOTYPE:**5** netlib___alloc_ior(unsigned int size, void *ptr)**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: None.**** SIDE EFFECTS: None.****--*/5unsigned int netlib___alloc_ior (struct IOR **iorp) { struct IOR *ior;" unsigned int status, fullsize; if (iorzone == 0) {+ unsigned int algorithm=LIB$K_VM_FIXED;@ unsigned int flags=LIB$M_VM_GET_FILL0|LIB$M_VM_EXTEND_AREA; int i;N status = lib$create_vm_zone(&iorzone, &algorithm, &IOR_S_IORDEF, &flags);$ if (!OK(status)) return status; for (i = 0; i < 8; i++) {9 if (!OK(lib$get_vm(&IOR_S_IORDEF, &ior))) break;( queue_insert(ior, iorque.tail); } }* if (queue_remove(iorque.head, &ior)) {" memset(ior, 0, IOR_S_IORDEF); *iorp = ior; return SS$_NORMAL; }7 status = lib$get_vm(&IOR_S_IORDEF, &ior, &iorzone); if (OK(status)) *iorp = ior; return status;} /* netlib___alloc_ior */ /***++** ROUTINE: netlib___free_ior**** FUNCTIONAL DESCRIPTION:**** Frees a block of memory.**** RETURNS: void**** PROTOTYPE:**%** netlib___free_ior(struct CMD *c)**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: None.**** SIDE EFFECTS: None.****--*/2unsigned int netlib___free_ior (struct IOR *ior) {# queue_insert(ior, iorque.tail); return SS$_NORMAL;} /* netlib___free_ior */ /***++"** ROUTINE: netlib___alloc_dnsreq**** FUNCTIONAL DESCRIPTION:**** Allocates some memory.**** RETURNS: cond_value**** PROTOTYPE:**8** netlib___alloc_dnsreq(unsigned int size, void *ptr)**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: None.**** SIDE EFFECTS: None.****--*/>unsigned int netlib___alloc_dnsreq (struct DNSREQ **dnsreqp) { struct DNSREQ *dnsreq;" unsigned int status, fullsize; if (dnsreqzone == 0) {+ unsigned int algorithm=LIB$K_VM_FIXED;@ unsigned int flags=LIB$M_VM_GET_FILL0|LIB$M_VM_EXTEND_AREA;W status = lib$create_vm_zone(&dnsreqzone, &algorithm, &DNSREQ_S_DNSREQDEF, &flags);$ if (!OK(status)) return status; }0 if (queue_remove(dnsreqque.head, &dnsreq)) {+ memset(dnsreq, 0, DNSREQ_S_DNSREQDEF); *dnsreqp = dnsreq; return SS$_NORMAL; }C status = lib$get_vm(&DNSREQ_S_DNSREQDEF, &dnsreq, &dnsreqzone);& if (OK(status)) *dnsreqp = dnsreq; return status;} /* netlib___alloc_dnsreq */ /***++!** ROUTINE: netlib___free_dnsreq**** FUNCTIONAL DESCRIPTION:**** Frees a block of memory.**** RETURNS: void**** PROTOTYPE:**(** netlib___free_dnsreq(struct CMD *c)**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES: None.**** SIDE EFFECTS: None.****--*/;unsigned int netlib___free_dnsreq (struct DNSREQ *dnsreq) {) queue_insert(dnsreq, dnsreqque.tail); return SS$_NORMAL;} /* netlib___free_dnsreq */ NETLIB_SRC.BCKp2n?[NETLIB]MISC.C;3UC!*[NETLIB]MISC.C;3+,p2./ @ 4U-n?0123KPWO56,ԭBo7LBo8s͗89V$ǘG @HJ/***++** FACILITY: NETLIB**%** ABSTRACT: Miscellaneous routines.**** MODULE DESCRIPTION:**** tbs**** AUTHOR: M. MadisonG** COPYRIGHT 1994, MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** CREATION DATE: 22-OCT-1994**** MODIFICATION HISTORY:**1** 22-OCT-1994 V1.0 Madison Initial coding.**--*/#include "netlib.h" #ifdef __DECC#pragma extern_model save%#pragma extern_model common_block shr#endifU char $$$Copyright[] = "Copyright 1994, MadGoat Software. All Rights Reserved."; #ifdef __DECC#pragma extern_model restore#endif/*** Forward declarations*/S unsigned int netlib_strtoaddr(struct dsc$descriptor *dsc, struct INADDRDEF *a);N unsigned int netlib_addrtostr(struct INADDRDEF *, struct dsc$descriptor *,* unsigned short *);P unsigned int netlib___find_symbol(char *imgnam, char *symnam, void *symptr);H static unsigned int find_image_symbol(struct dsc$descriptor *imgdsc,< struct dsc$descriptor *symdsc, void *symptr);2 unsigned int netlib_hton_long(unsigned int *);2 unsigned int netlib_ntoh_long(unsigned int *);6 unsigned short netlib_hton_word(unsigned short *);7 unsigned short netlib_ntoh_short(unsigned short *); /***++** ROUTINE: netlib_strtoaddr**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Qunsigned int netlib_strtoaddr (struct dsc$descriptor *dsc, struct INADDRDEF *a) { unsigned short len; char *cp, *anchor;' unsigned int status, parts[4], val; int i;/ status = lib$analyze_sdesc(dsc, &len, &cp);# if (!OK(status)) return status;( for (i = 0; len > 0 && i < 4; i++) { val = 0;$ while (*cp != '.' && len > 0) {. if (!isdigit(*cp)) return SS$_IVADDR;& val = val * 10 + (*cp - '0'); cp++; len--; } parts[i] = val; cp++; len--; } switch (i) { case 0: return SS$_IVADDR; case 1: val = parts[0]; break;< case 2: val = (parts[0] << 24) | (parts[1] & 0xffffff); break;A case 3: val = (parts[0] << 24) | ((parts[1] & 0xff) << 16) |' (parts[2] & 0xffff); break;A case 4: val = (parts[0] << 24) | ((parts[1] & 0xff) << 16) |= ((parts[2] & 0xff) << 8) | (parts[3] & 0xff); break; }- a->inaddr_l_addr = netlib_long_swap(val); return SS$_NORMAL;} /* netlib_strtoaddr */ /***++** ROUTINE: netlib_addrtostr**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/6unsigned int netlib_addrtostr (struct INADDRDEF *addr,F struct dsc$descriptor *dsc, unsigned short *len) { int argc;2 static $DESCRIPTOR(faodsc, "!UB.!UB.!UB.!UB"); SETARGCOUNT(argc);: return lib$sys_fao(&faodsc, (argc > 2) ? len : 0, dsc,1 (addr->inaddr_l_addr) & 0xff,1 (addr->inaddr_l_addr >> 8) & 0xff,1 (addr->inaddr_l_addr >> 16) & 0xff,2 (addr->inaddr_l_addr >> 24) & 0xff);} /* netlib_addrtostr */ /***++!** ROUTINE: netlib___find_symbol**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Nunsigned int netlib___find_symbol (char *imgnam, char *symnam, void *symptr) {) struct dsc$descriptor imgdsc, symdsc;" lib$establish(lib$sig_to_ret);/ INIT_SDESC(imgdsc, strlen(imgnam), imgnam);/ INIT_SDESC(symdsc, strlen(symnam), symnam);7 return find_image_symbol(&imgdsc, &symdsc, symptr);} /* netlib___find_symbol */ /***++** ROUTINE: find_image_symbol**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Estatic unsigned int find_image_symbol (struct dsc$descriptor *imgdsc,= struct dsc$descriptor *symdsc, void *symptr) {9 return lib$find_image_symbol(imgdsc, symdsc, symptr);} /* find_image_symbol */ /***++** ROUTINE: netlib_hton_long**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/5unsigned int netlib_hton_long (unsigned int *value) {$ return netlib_long_swap(*value);} /* netlib_hton_long */ /***++** ROUTINE: netlib_ntoh_long**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/5unsigned int netlib_ntoh_long (unsigned int *value) {$ return netlib_long_swap(*value);} /* netlib_ntoh_long */ /***++** ROUTINE: netlib_hton_word**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, wordword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/9unsigned short netlib_hton_word (unsigned short *value) {$ return netlib_word_swap(*value);} /* netlib_hton_word */ /***++** ROUTINE: netlib_ntoh_word**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, wordword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/9unsigned short netlib_ntoh_word (unsigned short *value) {$ return netlib_word_swap(*value);} /* netlib_ntoh_word */ NETLIB_SRC.BCKn?[NETLIB]NAMEADDR.C;16[*[NETLIB]NAMEADDR.C;16+,./ @ 4[-n?0123KPWO56y7^y8.F89V$ǘG @HJ/***++** FACILITY: NETLIB**?** ABSTRACT: DNS resolver routines - support for doing our own2** DNS gethostbyname/gethostbyaddr support.**** MODULE DESCRIPTION:**** tbs**** AUTHOR: M. MadisonG** COPYRIGHT 1994, MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** CREATION DATE: 22-OCT-1994**** MODIFICATION HISTORY:**1** 22-OCT-1994 V1.0 Madison Initial coding.F** 17-NOV-1994 V1.1 Madison Fixed handling of DNS lookup errors.**--*/#include "netlib.h"/*** Forward declarations*/; unsigned int netlib___dns_name_to_addr(struct CTX *ctx,H struct dsc$descriptor *namdsc, struct INADDRDEF *addrlist,9 unsigned int listsize, unsigned int *count,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);G static unsigned int name_to_addr_completion(struct DNSREQ *dnsreq);; unsigned int netlib___dns_addr_to_name(struct CTX *ctx,@ struct INADDRDEF *addrlist, unsigned int addrsize,D struct dsc$descriptor *namdsc, unsigned short *retlen,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);G static unsigned int addr_to_name_completion(struct DNSREQ *dnsreq);/*** External references*/S unsigned int netlib_dns_query(struct CTX **xctx, struct dsc$descriptor *namdsc,6 unsigned int *class, unsigned int *type,: unsigned char *buf, unsigned short *bufsize,> unsigned int *flags, struct NETLIBIOSBDEF *iosb,. void (*astadr)(), void *astprm);I int netlib_dns_skipname(unsigned char *bufp, unsigned short *buflen);R unsigned int netlib_dns_expandname(unsigned char *buf, unsigned short *buflen,A unsigned char *bufp, struct dsc$descriptor *namdsc,? unsigned short *retlen, unsigned short *bufchrs);4 unsigned int netlib___dns_init(struct CTX *ctx);  /***++&** ROUTINE: netlib___dns_name_to_addr**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/8unsigned int netlib___dns_name_to_addr (struct CTX *ctx,H struct dsc$descriptor *namdsc, struct INADDRDEF *addrlist,9 unsigned int listsize, unsigned int *count,K struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm) { unsigned short bufsize; unsigned int status; struct DNSREQ *dnsreq; struct IOR *ior;6 static unsigned int class = NETLIB_K_DNS_CLASS_IN;4 static unsigned int type = NETLIB_K_DNS_TYPE_A;< static unsigned int queryflags = NETLIB_M_DOMAIN_SEARCH;: if (ctx->flags & CTX_M_NO_DNS) return SS$_UNSUPPORTED; if (ctx->dnsctx == 0) {% status = netlib___dns_init(ctx);- if (!OK(status)) return SS$_UNSUPPORTED; }2 GET_DNSREQ(dnsreq, ctx, iosb, astadr, astprm); ior = dnsreq->ior;# ior->arg[0].address = addrlist;$ ior->arg[1].longword = listsize; ior->arg[2].address = count;" bufsize = sizeof(dnsreq->buf);: status = netlib_dns_query(&ctx, namdsc, &class, &type,% dnsreq->buf, &bufsize, &queryflags, &ior->iosb,! (astadr == 0) ? 0 C : (void (*)()) name_to_addr_completion, dnsreq);# if (astadr != 0) return status;+ return name_to_addr_completion(dnsreq);!} /* netlib___dns_name_to_addr */ /***++$** ROUTINE: name_to_addr_completion**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Estatic unsigned int name_to_addr_completion (struct DNSREQ *dnsreq) {" struct IOR *ior = dnsreq->ior; struct CTX *ctx = ior->ctx;2 struct INADDRDEF *alist = ior->arg[0].address;. unsigned int *count = ior->arg[2].address; struct dsc$descriptor dsc;" struct NETLIB_DNS_HEADER *hdr; unsigned char *cp; char name[256];0 unsigned short retlen, remain, buflen, skip;, int i, n, ancount, qdcount, type, class;' if (!OK(ior->iosb.iosb_w_status)) { unsigned int status; if (ior->iosbp != 0) {= ior->iosbp->iosb_w_status = ior->iosb.iosb_w_status;' ior->iosbp->iosb_w_count = 0;' ior->iosbp->iosb_l_unused = 0; } if (count != 0) *count = 0;7 if (ior->astadr != 0) (*ior->astadr)(ior->astprm);& status = ior->iosb.iosb_w_status; FREE_DNSREQ(dnsreq); return status; }3 hdr = (struct NETLIB_DNS_HEADER *) dnsreq->buf;3 ancount = netlib_word_swap(hdr->dns_w_ancount);3 qdcount = netlib_word_swap(hdr->dns_w_qdcount);; if (hdr->dns_v_reply_code != NETLIB_K_DNS_RC_SUCCESS) {/ ior->iosbp->iosb_w_status = SS$_ENDOFFILE;" ior->iosbp->iosb_w_count = 0;# ior->iosbp->iosb_l_unused = 0; if (count != 0) *count = 0;7 if (ior->astadr != 0) (*ior->astadr)(ior->astprm); FREE_DNSREQ(dnsreq); return SS$_ENDOFFILE; }$ buflen = ior->iosb.iosb_w_count;$ remain = buflen - sizeof(*hdr);$ cp = dnsreq->buf + sizeof(*hdr); while (qdcount-- > 0) {. i = netlib_dns_skipname(cp, &remain) + 4; cp += i; remain -= i; }( INIT_SDESC(dsc, sizeof(name), name); n = 0;E while (ancount-- > 0 && remain > 0 && n < ior->arg[1].longword) {[ if (!OK(netlib_dns_expandname(dnsreq->buf, &buflen, cp, &dsc, &retlen, &skip))) break; cp += skip; remain -= skip;4 type = netlib_word_swap(*(unsigned short *)cp); cp += 2; remain -= 2;5 class = netlib_word_swap(*(unsigned short *)cp);3 cp += 6; remain -= 6; /* skip over TTL, too */1 i = netlib_word_swap(*(unsigned short *)cp); cp += 2; remain -= 2;' if (type == NETLIB_K_DNS_TYPE_A) {9 alist[n++].inaddr_l_addr = *(unsigned long *)cp; } cp += i; remain -= i; }  if (count != 0) *count = n; if (ior->iosbp != 0) {, ior->iosbp->iosb_w_status = SS$_NORMAL;# ior->iosbp->iosb_w_count = n;# ior->iosbp->iosb_l_unused = 0; }1 if (ior->astadr) (*ior->astadr)(ior->astprm); FREE_DNSREQ(dnsreq); return SS$_NORMAL;} /* name_to_addr_completion */ /***++&** ROUTINE: netlib___dns_addr_to_name**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/8unsigned int netlib___dns_addr_to_name (struct CTX *ctx,= struct INADDRDEF *xaddr, unsigned int addr NETLIB_SRC.BCKn?[NETLIB]NAMEADDR.C;16[7psize,D struct dsc$descriptor *namdsc, unsigned short *retlen,K struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm) { struct dsc$descriptor dsc; struct IOR *ior; struct DNSREQ *dnsreq; char tmp[256]; unsigned short bufsize; unsigned int status; unsigned char *addr;6 static unsigned int class = NETLIB_K_DNS_CLASS_IN;6 static unsigned int type = NETLIB_K_DNS_TYPE_PTR;< static unsigned int queryflags = NETLIB_M_DOMAIN_SEARCH;: if (ctx->flags & CTX_M_NO_DNS) return SS$_UNSUPPORTED; if (ctx->dnsctx == 0) {% status = netlib___dns_init(ctx);- if (!OK(status)) return SS$_UNSUPPORTED; }2 GET_DNSREQ(dnsreq, ctx, iosb, astadr, astprm); ior = dnsreq->ior;! ior->arg[0].address = namdsc;! ior->arg[1].address = retlen;# addr = (unsigned char *) xaddr;= INIT_SDESC(dsc, sprintf(tmp, "%d.%d.%d.%d.in-addr.arpa.",9 addr[3], addr[2], addr[1], addr[0]), tmp);" bufsize = sizeof(dnsreq->buf);8 status = netlib_dns_query(&ctx, &dsc, &class, &type,% dnsreq->buf, &bufsize, &queryflags, &ior->iosb,! (astadr == 0) ? 0 C : (void (*)()) addr_to_name_completion, dnsreq);# if (astadr != 0) return status;+ return addr_to_name_completion(dnsreq);!} /* netlib___dns_addr_to_name */ /***++$** ROUTINE: addr_to_name_completion**** FUNCTIONAL DESCRIPTION:**)** tbs **B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Estatic unsigned int addr_to_name_completion (struct DNSREQ *dnsreq) {" struct IOR *ior = dnsreq->ior; struct CTX *ctx = ior->ctx;8 struct dsc$descriptor *namdsc = ior->arg[0].address;2 unsigned short *retlenp = ior->arg[1].address; struct dsc$descriptor dsc;" struct NETLIB_DNS_HEADER *hdr; unsigned char *cp;3 unsigned short retlen, remain, buflen, n, skip; char name[256];) int i, ancount, qdcount, type, class; unsigned int status;' if (!OK(ior->iosb.iosb_w_status)) { if (ior->iosbp != 0) {= ior->iosbp->iosb_w_status = ior->iosb.iosb_w_status;' ior->iosbp->iosb_w_count = 0;' ior->iosbp->iosb_l_unused = 0; }$ if (retlenp != 0) *retlenp = 0;7 if (ior->astadr != 0) (*ior->astadr)(ior->astprm);& status = ior->iosb.iosb_w_status; FREE_DNSREQ(dnsreq); return status; }3 hdr = (struct NETLIB_DNS_HEADER *) dnsreq->buf;3 ancount = netlib_word_swap(hdr->dns_w_ancount);3 qdcount = netlib_word_swap(hdr->dns_w_qdcount);; if (hdr->dns_v_reply_code != NETLIB_K_DNS_RC_SUCCESS) {/ ior->iosbp->iosb_w_status = SS$_ENDOFFILE;" ior->iosbp->iosb_w_count = 0;# ior->iosbp->iosb_l_unused = 0;$ if (retlenp != 0) *retlenp = 0;7 if (ior->astadr != 0) (*ior->astadr)(ior->astprm); FREE_DNSREQ(dnsreq); return SS$_ENDOFFILE; }$ buflen = ior->iosb.iosb_w_count;$ remain = buflen - sizeof(*hdr);$ cp = dnsreq->buf + sizeof(*hdr); while (qdcount-- > 0) {. i = netlib_dns_skipname(cp, &remain) + 4; cp += i; remain -= i; }( INIT_SDESC(dsc, sizeof(name), name); status = SS$_NORMAL;) while (ancount-- > 0 && remain > 0) {[ if (!OK(netlib_dns_expandname(dnsreq->buf, &buflen, cp, &dsc, &retlen, &skip))) break; cp += skip; remain -= skip;4 type = netlib_word_swap(*(unsigned short *)cp); cp += 2; remain -= 2;5 class = netlib_word_swap(*(unsigned short *)cp);3 cp += 6; remain -= 6; /* skip over TTL, too */1 i = netlib_word_swap(*(unsigned short *)cp); cp += 2; remain -= 2;) if (type == NETLIB_K_DNS_TYPE_PTR) {Q status = netlib_dns_expandname(dnsreq->buf, &buflen, cp, namdsc, &n, 0); break; } cp += i; remain -= i; } 1 if (OK(status) && retlenp != 0) *retlenp = n; if (ior->iosbp != 0) {( ior->iosbp->iosb_w_status = status;3 ior->iosbp->iosb_w_count = OK(status) ? n: 0;# ior->iosbp->iosb_l_unused = 0; }1 if (ior->astadr) (*ior->astadr)(ior->astprm); FREE_DNSREQ(dnsreq); return status;} /* addr_to_name_completion */  NETLIB_SRC.BCKwn?[NETLIB]NETLIB_SRI.C;34XP *[NETLIB]NETLIB_SRI.C;34+,w.P/ @ 4XPOT-n?0123KPWOQ56fڬ({7&lΔ({8.*69V$ǘG @HJ/***++** FACILITY: NETLIB**8** ABSTRACT: Routines specific to the SRI-QIO interface'** (MultiNet, TCPware, Pathway).**** MODULE DESCRIPTION:**** tbs**** AUTHOR: M. MadisonG** COPYRIGHT 1994, MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** CREATION DATE: 20-OCT-1994**** MODIFICATION HISTORY:**1** 20-OCT-1994 V1.0 Madison Initial coding.M** 17-NOV-1994 V1.0-1 Madison Wasn't mapping 0-length read to LINKDISCON.**--*/#include "netlib_sri.h"#include "netlib.h"/*** Forward declarations*/E unsigned int netlib_socket(struct CTX **xctx, unsigned int *type,* unsigned int *family);7 unsigned int netlib_server_setup(struct CTX **xctx,; struct SINDEF *sa, unsigned int *salen);B unsigned int netlib_bind(struct CTX **xctx, struct SINDEF *sa,C unsigned int *salen, struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);7 static unsigned int io_completion(struct IOR *ior);H unsigned int netlib_getsockname(struct CTX **ctx, struct SINDEF *sa,? unsigned int *sasize, unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,5 void (*astadr)(), void *astprm);H unsigned int netlib_getpeername(struct CTX **ctx, struct SINDEF *sa,? unsigned int *sasize, unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,5 void (*astadr)(), void *astprm);D unsigned int netlib_connect(struct CTX **ctx, struct SINDEF *sa,) unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,5 void (*astadr)(), void *astprm);K unsigned int netlib_write(struct CTX **ctx, struct dsc$descriptor *dsc,: struct SINDEF *sa, unsigned int *salen,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);J unsigned int netlib_read(struct CTX **ctx, struct dsc$descriptor *dsc,; struct SINDEF *sa, unsigned int *sasize,2 unsigned int *salen, TIME *tmo,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);4 static unsigned int io_timeout(struct IOR *ior);K unsigned int netlib_shutdown(struct CTX **xctx, unsigned int *shuttype,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);1 unsigned int netlib_close(struct CTX **xctx);H unsigned int netlib_listen(struct CTX **xctx, unsigned int *backlog,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);F unsigned int netlib_accept(struct CTX **ctx, struct CTX **xnewctx,; struct SINDEF *sa, unsigned int *sasize,C unsigned int *salen, struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);5 unsigned int netlib_setsockopt(struct CTX **xctx,= unsigned int *level, unsigned int *option,5 void *value, unsigned int *vallen,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);5 unsigned int netlib_getsockopt(struct CTX **xctx,= unsigned int *level, unsigned int *option,6 void *value, unsigned int *valsize,( unsigned int *vallen,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);P unsigned int netlib_name_to_address(struct CTX **xctx, unsigned int *whichp,1 struct dsc$descriptor *namdsc,. struct INADDRDEF *addrlist,? unsigned int *listsize, unsigned int *count,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);P unsigned int netlib_address_to_name(struct CTX **xctx, unsigned int *whichp,* struct INADDRDEF *addr,* unsigned int *addrsize,1 struct dsc$descriptor *namdsc,* unsigned short *retlen,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);H static unsigned int netlib___cvt_status(struct NETLIBIOSBDEF *iosb);X static void netlib___cvt_iosb(struct NETLIBIOSBDEF *dst, struct NETLIBIOSBDEF *src);8 unsigned int netlib_dns_mx_lookup(struct CTX **xctx,B struct dsc$descriptor *namdsc, struct MXRRDEF *mxrr,> unsigned int *mxrrsize, unsigned int *mxrrcount,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);/*** OWN storage*/. static $DESCRIPTOR(inetdevice, "_INET0:");( static unsigned short errorvec[] = {@ SS$_ABORT, SS$_ABORT, SS$_NOSUCHNODE, SS$_ABORT, SS$_ABORT,C SS$_NOSUCHNODE, SS$_ABORT, SS$_ABORT, SS$_BADPARAM, SS$_ABORT,? SS$_ABORT, SS$_INSFMEM, SS$_NOPRIV, SS$_ACCVIO, SS$_ABORT,? SS$_ABORT, SS$_FILALRACC, SS$_ABORT, SS$_ABORT, SS$_ABORT,> SS$_ABORT, SS$_BADPARAM, SS$_ABORT, SS$_ABORT, SS$_ABORT,; SS$_ABORT, SS$_ABORT, SS$_ABORT, SS$_ABORT, SS$_ABORT,M SS$_ABORT, SS$_LINKDISCON, SS$_BADPARAM, SS$_TOOMUCHDATA, SS$_SUSPENDED,J SS$_ABORT, SS$_ABORT, SS$_NOTNETDEV, SS$_NOSUCHNODE, SS$_TOOMUCHDATA,M SS$_PROTOCOL, SS$_PROTOCOL, SS$_PROTOCOL, SS$_PROTOCOL, SS$_ILLCNTRFUNC,J SS$_PROTOCOL, SS$_PROTOCOL, SS$_DUPLNAM, SS$_IVADDR, SS$_UNREACHABLE,L SS$_UNREACHABLE, SS$_RESET, SS$_LINKABORT, SS$_CONNECFAIL, SS$_INSFMEM,B SS$_FILALRACC, SS$_NOLINKS, SS$_SHUT, SS$_ABORT, SS$_TIMEOUT,B SS$_REJECT, SS$_ABORT, SS$_ABORT, SS$_SHUT, SS$_UNREACHABLE};/*** External references*/; unsigned int netlib___dns_name_to_addr(struct CTX *ctx,H struct dsc$descriptor *namdsc, struct INADDRDEF *addrlist,9 unsigned int listsize, unsigned int *count,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);: unsigned int netlib___ht_name_to_addr(struct CTX *ctx,H struct dsc$descriptor *namdsc, struct INADDRDEF *addrlist,9 unsigned int listsize, unsigned int *count,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);; unsigned int netlib___dns_addr_to_name(struct CTX *ctx,@ struct INADDRDEF *addrlist, unsigned int addrsize,D struct dsc$descriptor *namdsc, unsigned short *retlen,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);: unsigned int netlib___ht_addr_to_name(struct CTX *ctx,@ struct INADDRDEF *addrlist, unsigned int addrsize,D struct dsc$descriptor *namdsc, unsigned short *retlen,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);O unsigned int netlib_strtoaddr(struct dsc$descriptor *, struct INADDRDEF *);: unsigned int netlib___dns_mx_lookup(struct CTX **xctx,B struct dsc$descriptor *namdsc, struct MXRRDEF *mxrr,> un NETLIB_SRC.BCKwn?[NETLIB]NETLIB_SRI.C;34XP signed int *mxrrsize, unsigned int *mxrrcount,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm); /***++** ROUTINE: netlib_socket**** FUNCTIONAL DESCRIPTION:**** Create a "socket".**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Bunsigned int netlib_socket (struct CTX **xctx, unsigned int *type,+ unsigned int *family) { struct CTX *ctx; struct NETLIBIOSBDEF myiosb; unsigned int status, af, ty; int argc; SETARGCOUNT(argc);% if (argc < 1) return SS$_INSFARG;4 status = netlib___alloc_ctx(&ctx, SPECCTX_SIZE);# if (!OK(status)) return status;7 status = sys$assign(&inetdevice, &ctx->chan, 0, 0); if (!OK(status)) { netlib___free_ctx(ctx); return status; }A ty = (argc >= 2 && type != 0) ? *type : NETLIB_K_TYPE_STREAM;A af = (argc >= 3 && family != 0) ? *family : NETLIB_K_AF_INET;> status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SOCKET, &myiosb, 0, 0,# af, ty, 0, 0, 0, 0);: if (OK(status)) status = netlib___cvt_status(&myiosb); if (!OK(status)) { sys$dassgn(ctx->chan); netlib___free_ctx(ctx); return status; } *xctx = ctx; return SS$_NORMAL;} /* netlib_socket */ /***++ ** ROUTINE: netlib_server_setup**** FUNCTIONAL DESCRIPTION:**** Create a "server_setup".**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Gunsigned int netlib_server_setup (struct CTX **xctx, struct SINDEF *sa,. unsigned int *salen) { struct CTX *ctx; unsigned int status;, static $DESCRIPTOR(device, "SYS$INPUT");4 status = netlib___alloc_ctx(&ctx, SPECCTX_SIZE);# if (!OK(status)) return status;3 status = sys$assign(&device, &ctx->chan, 0, 0); if (!OK(status)) { netlib___free_ctx(ctx); return status; } *xctx = ctx; return SS$_NORMAL;} /* netlib_server_setup */ /***++** ROUTINE: netlib_bind**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/?unsigned int netlib_bind (struct CTX **xctx, struct SINDEF *sa,C unsigned int *salen, struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; struct NETLIBIOSBDEF myiosb; unsigned int status; int argc; static unsigned int one = 1; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);3 if (sa == 0 || salen == 0) return SS$_BADPARAM;< if (*salen < sizeof(struct SINDEF)) return SS$_BADPARAM;3 if (!(ctx->flags & CTX_M_USER_SET_REUSEADDR)) {C sys$qiow(netlib_synch_efn, ctx->chan, IO$_SETSOCKOPT, 0, 0, 0,? NETLIB_K_LEVEL_SOCKET, NETLIB_K_OPTION_REUSEADDR,' &one, sizeof(one), 0, 0); }" if (argc > 4 && astadr != 0) { struct IOR *ior;> GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);I status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_BIND, &ior->iosb,? io_completion, ior, sa, *salen, 0, 0, 0, 0); } else {F status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_BIND, &myiosb,1 0, 0, sa, *salen, 0, 0, 0, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);A if (argc > 3 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); } return status;} /* netlib_bind */ /***++** ROUTINE: io_completion**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/5static unsigned int io_completion (struct IOR *ior) { struct CTX *ctx; ctx = ior->ctx;( ior->iorflags |= IOR_M_IO_COMPLETED;; if (ior->iorflags & IOR_M_IO_TIMED) sys$cantim(ior, 0);. if (ior->iosb.iosb_w_status == SS$_CANCEL)+ ior->iosb.iosb_w_status = SS$_TIMEOUT;- if (ior->iorflags & IOR_M_CHECK_LENGTH &&D OK(ior->iosb.iosb_w_status) && ior->iosb.iosb_w_count == 0). ior->iosb.iosb_w_status = SS$_LINKDISCON;C if (ior->iosbp != 0) netlib___cvt_iosb(ior->iosbp, &ior->iosb);, if (ior->iorflags & IOR_M_COPY_LENGTH) {> if (OK(ior->iosb.iosb_w_status) && ior->spec_retlen != 0)@ *(unsigned int *) ior->spec_retlen = ior->spec_length;) ior->iorflags &= ~IOR_M_COPY_LENGTH; }* if (ior->iorflags & IOR_M_COPY_FROM) {B if (OK(ior->iosb.iosb_w_status) && ior->spec_userfrom != 0) { unsigned int len;( len = ior->specior.from.length;< if (len > ior->spec_length) len = ior->spec_length;E memcpy(ior->spec_userfrom, &ior->specior.from.address, len);L if (ior->spec_retlen != 0) *(unsigned int *)ior->spec_retlen = len; }' ior->iorflags &= ~IOR_M_COPY_FROM; }+ if (ior->iorflags & IOR_M_COPY_FROM2) {B if (OK(ior->iosb.iosb_w_status) && ior->spec_userfrom != 0) { unsigned int len;) len = ior->specior.from2.length;< if (len > ior->spec_length) len = ior->spec_length;F memcpy(ior->spec_userfrom, &ior->specior.from2.address, len);L if (ior->spec_retlen != 0) *(unsigned int *)ior->spec_retlen = len; }( ior->iorflags &= ~IOR_M_COPY_FROM2; }, if (ior->iorflags & IOR_M_NEW_CONTEXT) {' if (OK(ior->iosb.iosb_w_status)) {P *((struct CTX **) ior->spec_xnewctx) = (struct CTX *) ior->spec_newctx; } else {= sys$dassgn(((struct CTX *) ior->spec_newctx)->chan);< netlib___free_ctx((struct CTX *) ior->spec_newctx); }) ior->iorflags &= ~IOR_M_NEW_CONTEXT; }8 if (ior->astadr != 0) (*(ior->astadr))(ior->astprm); FREE_IOR(ior); return SS$_NORMAL;} /* io_completion */ /***++** ROUTINE: netlib_getsockname**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Funsigned int netlib_getsockname (struct CTX **xctx, struct SINDEF *sa,? unsigned int *sasize, unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,6 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; int argc; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);4 if (sa == 0 || sasize == 0) return SS$_BADPARAM;" if (argc > 5 && astadr != 0) { struct IOR *ior;> GET_IOR(ior, ctx, iosb, astadr, (argc > 6) ? astprm : 0); ior->spec_length = *sasize; ior->spec_retlen = salen;' ior->iorflags = IOR_M_COPY_LENGTH;P status = sys$qio(netlib_asynch_efn, ctx->chan,  NETLIB_SRC.BCKwn?[NETLIB]NETLIB_SRI.C;34XP<IO$_GETSOCKNAME, &ior->iosb,= io_completion, ior, sa, &ior->spec_length, 0, 0, 0, 0); } else {! struct NETLIBIOSBDEF myiosb; unsigned int length; length = *sasize;D status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_GETSOCKNAME, &myiosb,2 0, 0, sa, &length, 0, 0, 0, 0);1 if (argc > 3 && salen != 0) *salen = length;; if (OK(status)) status = netlib___cvt_status(&myiosb);A if (argc > 4 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); } return status;} /* netlib_getsockname */ /***++** ROUTINE: netlib_getpeername**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Funsigned int netlib_getpeername (struct CTX **xctx, struct SINDEF *sa,? unsigned int *sasize, unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,6 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; int argc; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);4 if (sa == 0 || sasize == 0) return SS$_BADPARAM;" if (argc > 5 && astadr != 0) { struct IOR *ior;> GET_IOR(ior, ctx, iosb, astadr, (argc > 6) ? astprm : 0); ior->spec_length = *sasize; ior->spec_retlen = salen;' ior->iorflags = IOR_M_COPY_LENGTH;OP status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_GETPEERNAME, &ior->iosb,= io_completion, ior, sa, &ior->spec_length,  0, 0, 0, 0);E } else {! struct NETLIBIOSBDEF myiosb;  unsigned int length;I length = *sasize;D status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_GETPEERNAME, &myiosb,02 0, 0, sa, &length, 0, 0, 0, 0);1 if (argc > 3 && salen != 0) *salen = length; ; if (OK(status)) status = netlib___cvt_status(&myiosb);*A if (argc > 4 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);y }  return status;} /* netlib_getpeername */ /***++** ROUTINE: netlib_connecti**** FUNCTIONAL DESCRIPTION:i**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.t**** COMPLETION CODES:o****** SIDE EFFECTS: None.****--*/Bunsigned int netlib_connect (struct CTX **xctx, struct SINDEF *sa,) unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,6 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; int argc;N VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);3 if (sa == 0 || salen == 0) return SS$_BADPARAM;B< if (*salen < sizeof(struct SINDEF)) return SS$_BADPARAM;" if (argc > 4 && astadr != 0) { struct IOR *ior;t> GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);L status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_CONNECT, &ior->iosb,2 io_completion, ior, sa, *salen, 0, 0, 0, 0);d } else {! struct NETLIBIOSBDEF myiosb;FI status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_CONNECT, &myiosb,1 0, 0, sa, *salen, 0, 0, 0, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);eA if (argc > 3 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);* } return status;} /* netlib_connect */ ,/***++** ROUTINE: netlib_writeB**** FUNCTIONAL DESCRIPTION:i**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.r**** COMPLETION CODES: ****** SIDE EFFECTS: None.****--*/Iunsigned int netlib_write (struct CTX **xctx, struct dsc$descriptor *dsc,i: struct SINDEF *sa, unsigned int *salen,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; void *bufptr;s unsigned int status; unsigned short buflen; int argc;i VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);6 status = lib$analyze_sdesc(dsc, &buflen, &bufptr);# if (!OK(status)) return status;d" if (argc > 5 && astadr != 0) { struct IOR *ior; > GET_IOR(ior, ctx, iosb, astadr, (argc > 6) ? astprm : 0);N status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_WRITEVBLK, &ior->iosb,= io_completion, ior, bufptr, buflen, 0, sa, - (salen == 0) ? 0 : *salen,x 0); } else {! struct NETLIBIOSBDEF myiosb; B status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_WRITEVBLK,4 &myiosb, 0, 0, bufptr, buflen, 0,' (argc > 2) ? sa : 0, = (argc > 3 && salen != 0) ? *salen : 0, 0);d; if (OK(status)) status = netlib___cvt_status(&myiosb); A if (argc > 4 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);D }a return status;} /* netlib_write */ z/***++** ROUTINE: netlib_read**** FUNCTIONAL DESCRIPTION:s**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:n****** SIDE EFFECTS: None.****--*/Hunsigned int netlib_read (struct CTX **xctx, struct dsc$descriptor *dsc,; struct SINDEF *sa, unsigned int *sasize,s6 unsigned int *salen, TIME *timeout,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; struct IOR *ior; int argc, do_from; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);E if (dsc->dsc$b_dtype != DSC$K_DTYPE_T && dsc->dsc$b_dtype != 0) { return SS$_BADPARAM;I }*E if (dsc->dsc$b_class != DSC$K_CLASS_S && dsc->dsc$b_class != 0) {t return SS$_BADPARAM;" }"C do_from = (argc > 3 && sa != 0 && sasize != 0 && *sasize != 0);," if (argc > 7 && astadr != 0) {> GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0); if (do_from) {OF ior->specior.from.length = sizeof(ior->specior.from.address);! ior->spec_userfrom = sa;S$ ior->spec_length = *sasize;" ior->spec_retlen = salen;) ior->iorflags = IOR_M_COPY_FROM;_ } else ior->iorflags = 0; if (timeout != 0) {( ior->iorflags = IOR_M_IO_TIMED;J status = sys$setimr(netlib_asynch_efn, timeout, io_timeout, ior);( if (!OK(status)) return status; } else ior->iorflags = 0;) ior->iorflags |= IOR_M_CHECK_LENGTH;PM status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_READVBLK, &ior->iosb,O: io_completion, ior, dsc->dsc$a_pointer,( dsc->dsc$w_length, 0,4 do_from ? &ior->specior.from : 0,? do_from ? sizeof(ior->specior.from) : 0, 0);n } else { struct {c unsigned short length;t struct SINDEF address;N } from;! struct NETLIBIOSBDEF myiosb;s( from.length = sizeof(from.address);$ if (argc > 5 && timeout != 0) {$ GET_IOR(ior, ctx, 0, 0, 0);(  NETLIB_SRC.BCKwn?[NETLIB]NETLIB_SRI.C;34XP- ior->iorflags = IOR_M_IO_TIMED;J status = sys$setimr(netlib_asynch_efn, timeout, io_timeout, ior); if (!OK(status)) {l FREE_IOR(ior); return status; } }A status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_READVBLK,d! &myiosb, 0, 0, < dsc->dsc$a_pointer, dsc->dsc$w_length, 0,' do_from ? &from : 0,,2 do_from ? sizeof(from) : 0, 0);$ if (argc > 5 && timeout != 0) { sys$cantim(ior, 0); FREE_IOR(ior);t } if (OK(status)) {/ status = netlib___cvt_status(&myiosb); 4 if (OK(status) && myiosb.iosb_w_count == 0)9 status = myiosb.iosb_w_status = SS$_LINKDISCON;d }A if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);d! if (OK(status) && do_from) { unsigned int len; len = from.length;,* if (len > *sasize) len = *sasize;( memcpy(sa, &from.address, len);2 if (argc > 4 && salen != 0) *salen = len; } }t return status;} /* netlib_read */* p/***++** ROUTINE: io_timeoutt**** FUNCTIONAL DESCRIPTION:S**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.***** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/2static unsigned int io_timeout (struct IOR *ior) {> if (ior->iorflags & IOR_M_IO_COMPLETED) return SS$_NORMAL;& return sys$cancel(ior->ctx->chan);} /* io_timeout */ I/***++** ROUTINE: netlib_shutdown**** FUNCTIONAL DESCRIPTION:E**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.d**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Hunsigned int netlib_shutdown (struct CTX **xctx, unsigned int *shuttype,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; int argc;  VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);" if (argc > 3 && astadr != 0) { struct IOR *ior;&> GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);M status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SHUTDOWN, &ior->iosb,;& io_completion, ior,C (shuttype == 0) ? 0 : *shuttype, 0, 0, 0, 0, 0);U } else {! struct NETLIBIOSBDEF myiosb;_J status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SHUTDOWN, &myiosb,E 0, 0, (argc > 1 && shuttype != 0) ? *shuttype : 0," 0, 0, 0, 0, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);A if (argc > 2 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);s }I return status;} /* netlib_shutdown */* e/***++** ROUTINE: netlib_closei**** FUNCTIONAL DESCRIPTION:E**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:t****** SIDE EFFECTS: None.****--*//unsigned int netlib_close (struct CTX **xctx) {  struct CTX *ctx; unsigned int status; VERIFY_CTX(xctx, ctx);# status = sys$dassgn(ctx->chan);# if (!OK(status)) return status;s netlib___free_ctx(ctx);* *xctx = 0; return SS$_NORMAL;} /* netlib_close */ /***++** ROUTINE: netlib_listen**** FUNCTIONAL DESCRIPTION:E**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:t****** SIDE EFFECTS: None.****--*/Eunsigned int netlib_listen (struct CTX **xctx, unsigned int *backlog,s. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; int argc;) VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);" if (argc > 3 && astadr != 0) { struct IOR *ior;-> GET_IOR(ior, ctx, iosb, astadr, (argc > 4) ? astprm : 0);K status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_LISTEN, &ior->iosb,& io_completion, ior,A (backlog == 0) ? 0 : *backlog, 0, 0, 0, 0, 0);( } else {! struct NETLIBIOSBDEF myiosb;eH status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_LISTEN, &myiosb,C 0, 0, (argc > 1 && backlog != 0) ? *backlog : 0, " 0, 0, 0, 0, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);0A if (argc > 2 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);i } return status;} /* netlib_listen */s o/***++** ROUTINE: netlib_accept**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.***** COMPLETION CODES:P****** SIDE EFFECTS: None.****--*/Dunsigned int netlib_accept (struct CTX **xctx, struct CTX **xnewctx,; struct SINDEF *sa, unsigned int *sasize,C unsigned int *salen, struct NETLIBIOSBDEF *iosb,I4 void (*astadr)(), void *astprm) { struct CTX *ctx, *newctx; unsigned int status; int argc;N VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 2) return SS$_INSFARG;H* if (xnewctx == 0) return SS$_BADPARAM;7 status = netlib___alloc_ctx(&newctx, SPECCTX_SIZE);t# if (!OK(status)) return status;i: status = sys$assign(&inetdevice, &newctx->chan, 0, 0); if (!OK(status)) { netlib___free_ctx(newctx);- return status;& }s" if (argc > 6 && astadr != 0) { struct IOR *ior;n> GET_IOR(ior, ctx, iosb, astadr, (argc > 7) ? astprm : 0);D ior->specior.from2.length = sizeof(ior->specior.from2.address);1 ior->spec_userfrom = (sasize == 0) ? 0 : sa;{4 ior->spec_length = (sasize == 0) ? 0 : *sasize; ior->spec_retlen = salen;! ior->spec_xnewctx = xnewctx;p ior->spec_newctx = newctx;s' ior->iorflags = IOR_M_NEW_CONTEXT; ! if (ior->spec_userfrom != 0)e+ ior->iorflags |= IOR_M_COPY_FROM2;eN status = sys$qio(netlib_asynch_efn, newctx->chan, IO$_ACCEPT, &ior->iosb,& io_completion, ior,C &ior->specior.from2, sizeof(ior->specior.from2),s' ctx->chan, 0, 0, 0);o } else { struct {  unsigned int length;i struct SINDEF address;( } from;! struct NETLIBIOSBDEF myiosb;l( from.length = sizeof(from.address);B status = sys$qiow(netlib_synch_efn, newctx->chan, IO$_ACCEPT,! &myiosb, 0, 0, ' &from, sizeof(from),{' ctx->chan, 0, 0, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb); A if (argc > 5 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);C if (OK(status)) { *xnewctx = newctx;r2 if (argc > 3 && sa != 0 && sasize != 0) { unsigned int len;W len = from.length;+ if (len > *sasize) len = *sasize;m) memcpy(sa, &from.address, len);N3 if (argc > 4 && salen != 0) *salen = len;O  NETLIB_SRC.BCKwn?[NETLIB]NETLIB_SRI.C;34XPf< } } } return status;} /* netlib_accept */ /***++** ROUTINE: netlib_setsockopt**** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.t**** COMPLETION CODES: ****** SIDE EFFECTS: None.****--*/2unsigned int netlib_setsockopt (struct CTX **xctx,= unsigned int *level, unsigned int *option,v5 void *value, unsigned int *vallen,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status, lev; int argc;  VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 5) return SS$_INSFARG;mF if (option == 0 || value == 0 || vallen == 0) return SS$_BADPARAM;0 if (level == 0) lev = NETLIB_K_LEVEL_SOCKET; else lev = *level;O if (lev == NETLIB_K_LEVEL_SOCKET && *option == NETLIB_K_OPTION_REUSEADDR) {n, ctx->flags |= CTX_M_USER_SET_REUSEADDR; } " if (argc > 6 && astadr != 0) { struct IOR *ior;> GET_IOR(ior, ctx, iosb, astadr, (argc > 7) ? astprm : 0);O status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SETSOCKOPT, &ior->iosb,o4 io_completion, ior, lev, *option,) value, *vallen, 0, 0); } else {! struct NETLIBIOSBDEF myiosb;_C status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SETSOCKOPT,iF &myiosb, 0, 0, lev, *option, value, *vallen, 0, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);A if (argc > 5 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);a }n return status;} /* netlib_setsockopt */T P/***++** ROUTINE: netlib_getsockopt**** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.e**** COMPLETION CODES: ****** SIDE EFFECTS: None.****--*/2unsigned int netlib_getsockopt (struct CTX **xctx,= unsigned int *level, unsigned int *option, 6 void *value, unsigned int *valsize,( unsigned int *vallen,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status, lev;i int argc;  VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 5) return SS$_INSFARG;uG if (option == 0 || value == 0 || valsize == 0) return SS$_BADPARAM; 0 if (level == 0) lev = NETLIB_K_LEVEL_SOCKET; else lev = *level;" if (argc > 7 && astadr != 0) { struct IOR *ior; > GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0); ior->spec_retlen = vallen;_! ior->spec_length = *valsize; ' ior->iorflags = IOR_M_COPY_LENGTH; O status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_GETSOCKOPT, &ior->iosb,e4 io_completion, ior, lev, *option,3 value, &ior->spec_length, 0, 0);b } else {! struct NETLIBIOSBDEF myiosb;n unsigned int length;p length = *valsize;C status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_GETSOCKOPT,*6 &myiosb, 0, 0, lev, *option, value," &length, 0, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb); A if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);IA if (OK(status) && argc > 5 && vallen != 0) *vallen = length;r }  return status;} /* netlib_getsockopt */s e/***++#** ROUTINE: netlib_name_to_addressL**** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.=**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Munsigned int netlib_name_to_address (struct CTX **xctx, unsigned int *whichp,G1 struct dsc$descriptor *namdsc,:. struct INADDRDEF *addrlist,? unsigned int *listsize, unsigned int *count,i. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; struct INADDRDEF addr; unsigned int status, which; int argc;  VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 5) return SS$_INSFARG; K if (namdsc == 0 || addrlist == 0 || listsize == 0) return SS$_BADPARAM;e. if (OK(netlib_strtoaddr(namdsc, &addr))) { addrlist[0] = addr;, if (argc > 5 && count != 0) *count = 1;! if (argc > 6 && iosb != 0) {,* iosb->iosb_w_status = SS$_NORMAL; iosb->iosb_w_count = 1;! iosb->iosb_l_unused = 0; }# if (argc > 7 && astadr != 0) {I? return sys$dclast(astadr, (argc > 8) ? astprm : 0, 0);i } else {_ return SS$_NORMAL;u } }o1 if (whichp == 0) which = NETLIB_K_LOOKUP_DNS;n else which = *whichp; ' if (which == NETLIB_K_LOOKUP_DNS) { G return netlib___dns_name_to_addr(ctx, namdsc, addrlist, *listsize,o! (argc > 5) ? count : 0,u! (argc > 6) ? iosb : 0, " (argc > 7) ? astadr : 0,# (argc > 8) ? astprm : 0);t }lE return netlib___ht_name_to_addr(ctx, namdsc, addrlist, *listsize,t! (argc > 5) ? count : 0,!! (argc > 6) ? iosb : 0, " (argc > 7) ? astadr : 0,# (argc > 8) ? astprm : 0); } /* netlib_name_to_address */ /***++#** ROUTINE: netlib_address_to_namei**** FUNCTIONAL DESCRIPTION:,**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.O**** COMPLETION CODES: ****** SIDE EFFECTS: None.****--*/Munsigned int netlib_address_to_name (struct CTX **xctx, unsigned int *whichp,s* struct INADDRDEF *addr,* unsigned int *addrsize,1 struct dsc$descriptor *namdsc,s* unsigned short *retlen,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status, which; int argc; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 5) return SS$_INSFARG;eG if (addr == 0 || addrsize == 0 || namdsc == 0) return SS$_BADPARAM;-1 if (whichp == 0) which = NETLIB_K_LOOKUP_DNS;r else which = *whichp; ' if (which == NETLIB_K_LOOKUP_DNS) {dC return netlib___dns_addr_to_name(ctx, addr, *addrsize, namdsc,," (argc > 5) ? retlen : 0," (argc > 6) ? iosb : 0," (argc > 7) ? astadr : 0,# (argc > 8) ? astprm : 0);a } A return netlib___ht_addr_to_name(ctx, addr, *addrsize, namdsc,x" (argc > 5) ? retlen : 0," (argc > 6) ? iosb : 0," (argc > 7) ? astadr : 0,# (argc > 8) ? astprm : 0);f} /* netlib_address_to_name */ &/***++ ** ROUTINE: netlib___cvt_status**** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES: ****** SIDE EFFECTS: None. NETLIB_SRC.BCKwn?[NETLIB]NETLIB_SRI.C;34XP K****--*/Fstatic unsigned int netlib___cvt_status (struct NETLIBIOSBDEF *iosb) { int errnum;a= if (iosb->iosb_w_status == SS$_NORMAL) return SS$_NORMAL;-C else if (iosb->iosb_w_status == SS$_CANCEL) return SS$_TIMEOUT;I1 errnum = (iosb->iosb_w_status & 0x7fff) >> 3;sH if (errnum > sizeof(errorvec)/sizeof(errorvec[0])) return SS$_ABORT; return errorvec[errnum-1];} /* netlib___cvt_status */_ H/***++** ROUTINE: netlib___cvt_iosb**** FUNCTIONAL DESCRIPTION:B**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:-****** SIDE EFFECTS: None.****--*/9static void netlib___cvt_iosb (struct NETLIBIOSBDEF *dst,D0 struct NETLIBIOSBDEF *src) { int errnum; ! switch (src->iosb_w_status) { case SS$_NORMAL: case SS$_LINKDISCON: case SS$_TIMEOUT:;- dst->iosb_w_status = src->iosb_w_status; break; default:1 errnum = (src->iosb_w_status & 0x7fff) >> 3;  dst->iosb_w_status = D (errnum > sizeof(errorvec)/sizeof(errorvec[0])) ? SS$_ABORT: : errorvec[errnum-1]; } * dst->iosb_w_count = src->iosb_w_count; dst->iosb_l_unused = 0;c} /* netlib___cvt_iosb */  /***++!** ROUTINE: netlib_dns_mx_lookup **** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:o****** SIDE EFFECTS: None.****--*/4unsigned int netlib_dns_mx_lookup(struct CTX **xctx,B struct dsc$descriptor *namdsc, struct MXRRDEF *mxrr,> unsigned int *mxrrsize, unsigned int *mxrrcount,K struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm) {f struct CTX *ctx; int argc;  VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 4) return SS$_INSFARG;? return netlib___dns_mx_lookup(xctx, namdsc, mxrr, mxrrsize,I; (argc > 4) ? mxrrcount : 0, (argc > 5) ? iosb : 0,s; (argc > 6) ? astadr : 0, (argc > 7) ? astprm : 0);s} /* netlib_dns_mx_lookup */**** IMPLICIT OUTPUTS: None.***** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/2static unsigned int io_timeout (struct IOR *ior) {>  NETLIB_SRC.BCKRRn?[NETLIB]NETLIB_SRI_SUPPORT.C;4Yj*[NETLIB]NETLIB_SRI_SUPPORT.C;4+,RR./ @ 4Yb-n?0123KPWO56фr7|g3фr8.?ӗ89V$ǘG @HJ #ifdef __DECC#pragma module MODULE_NAME#else#module MODULE_NAME#endif/***++** FACILITY: NETLIB**<** ABSTRACT: Routines specific to MultiNet/TCPware/PathWay.**** MODULE DESCRIPTION:**** tbs**** AUTHOR: M. MadisonG** COPYRIGHT 1994, MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** CREATION DATE: 20-OCT-1994**** MODIFICATION HISTORY:**1** 20-OCT-1994 V1.0 Madison Initial coding.**--*/#include "netlib_sri.h"#include "netlib.h"#include #include #include #if defined(MULTINET)#include "netlib_multinet.h"#elif defined(TCPWARE)#include "netlib_tcpware.h"#elif defined(PATHWAY)#include "netlib_pathway.h"#endif/*** Forward declarations*/L unsigned int netlib_get_hostname(void *bufdsc, unsigned short *retlenp);: unsigned int netlib___ht_name_to_addr(struct CTX *ctx,D struct dsc$descriptor *namdsc, struct INADDRDEF *addrlist,5 unsigned int listsize, unsigned int *count,% struct NETLIBIOSBDEF *iosb,( void (*astadr), void *astprm);: unsigned int netlib___ht_addr_to_name(struct CTX *ctx,8 struct INADDRDEF *addr, unsigned int addrsize,@ struct dsc$descriptor *bufdsc, unsigned short *retlen,% struct NETLIBIOSBDEF *iosb,( void (*astadr), void *astprm);- int netlib___get_nameservers(QUEUE *nsq);F int netlib___get_domain(char *, unsigned short, unsigned short *);/*** OWN storage*/: static $DESCRIPTOR(nameserver_tabnam, "LNM$FILE_DEV");/*** External references*/P unsigned int netlib___find_symbol(char *imgnam, char *symnam, void *symptr);S unsigned int netlib_strtoaddr(struct dsc$descriptor *dsc, struct INADDRDEF *a); /***++ ** ROUTINE: netlib_get_hostname**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Junsigned int netlib_get_hostname (void *bufdsc, unsigned short *retlenp) { char buf[256]; unsigned int status; unsigned short retlen;$ static int (*gethostname)() = 0; int argc; SETARGCOUNT(argc); if (gethostname == 0) { int i, j;M for (i = 0; i < sizeof(socket_library)/sizeof(socket_library[0]); i++) {S for (j = 0; j < sizeof(gethostname_ent)/sizeof(gethostname_ent[0]); j++) {: status = netlib___find_symbol(socket_library[i],6 gethostname_ent[j], &gethostname); if (OK(status)) break; } }$ if (!OK(status)) return status; }? if ((*gethostname)(buf, sizeof(buf)) < 0) return SS$_ABORT; retlen = strlen(buf);. status = str$copy_r(bufdsc, &retlen, buf);# if (!OK(status)) return status;4 if (argc > 1 && retlenp != 0) *retlenp = retlen; return SS$_NORMAL;} /* netlib_get_hostname */ /***++%** ROUTINE: netlib___ht_name_to_addr**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/7unsigned int netlib___ht_name_to_addr (struct CTX *ctx,D struct dsc$descriptor *bufdsc, struct INADDRDEF *addrlist,5 unsigned int listsize, unsigned int *count,% struct NETLIBIOSBDEF *iosb,) void (*astadr), void *astprm) {  char *namp, name[256]; unsigned short namlen; unsigned int status; struct hostent *hp;3 static struct hostent *(*_gethostbyname)() = 0; int argc, i, j;2 if (lib$ast_in_prog()) return SS$_UNSUPPORTED; SETARGCOUNT(argc);7 status = lib$analyze_sdesc(bufdsc, &namlen, &namp);# if (!OK(status)) return status;9 if (namlen > sizeof(name)-1) namlen = sizeof(name)-1; memcpy(name, namp, namlen); name[namlen] = '\0'; if (_gethostbyname == 0) {M for (i = 0; i < sizeof(socket_library)/sizeof(socket_library[0]); i++) {Y for (j = 0; j < sizeof(_gethostbyname_ent)/sizeof(_gethostbyname_ent[0]); j++) {: status = netlib___find_symbol(socket_library[i],< _gethostbyname_ent[j], &_gethostbyname); if (OK(status)) break; } }$ if (!OK(status)) return status; }! hp = (*_gethostbyname)(name);& if (hp == 0) return SS$_ENDOFFILE;O for (i = 0, j = 0; (j < listsize) && (hp->h_addr_list[i] != 0); i++, j++) {> addrlist[j] = *((struct INADDRDEF *) hp->h_addr_list[i]); }+ if (argc > 4 && count != 0) *count = j; if (argc > 5 && iosb != 0) {& iosb->iosb_w_status = SS$_NORMAL; iosb->iosb_w_count = j; iosb->iosb_l_unused = 0; }P if (argc > 6 && astadr != 0) sys$dclast(astadr, (argc > 7) ? astprm : 0, 0); return SS$_NORMAL; } /* netlib___ht_name_to_addr */ /***++%** ROUTINE: netlib___ht_addr_to_name**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/7unsigned int netlib___ht_addr_to_name (struct CTX *ctx,8 struct INADDRDEF *addr, unsigned int addrsize,@ struct dsc$descriptor *bufdsc, unsigned short *retlen,% struct NETLIBIOSBDEF *iosb,) void (*astadr), void *astprm) { unsigned int status; unsigned short len; struct hostent *hp;3 static struct hostent *(*_gethostbyaddr)() = 0; int argc;2 if (lib$ast_in_prog()) return SS$_UNSUPPORTED; SETARGCOUNT(argc); if (_gethostbyaddr == 0) { int i, j;M for (i = 0; i < sizeof(socket_library)/sizeof(socket_library[0]); i++) {Y for (j = 0; j < sizeof(_gethostbyaddr_ent)/sizeof(_gethostbyaddr_ent[0]); j++) {: status = netlib___find_symbol(socket_library[i],< _gethostbyaddr_ent[j], &_gethostbyaddr); if (OK(status)) break; } }$ if (!OK(status)) return status; }= hp = (*_gethostbyaddr)(addr, addrsize, NETLIB_K_AF_INET);& if (hp == 0) return SS$_ENDOFFILE; len = strlen(hp->h_name);2 status = str$copy_r(bufdsc, &len, hp->h_name);# if (!OK(status)) return status;/ if (argc > 4 && retlen != 0) *retlen = len; if (argc > 5 && iosb != 0) {& iosb->iosb_w_status = SS$_NORMAL; iosb->iosb_w_count = len; iosb->iosb_l_unused = 0; }P if (argc > 6 && astadr != 0) sys$dclast(astadr, (argc > 7) ? astprm : 0, 0); return SS$_NORMAL; } /* netlib___ht_addr_to_name */ /***++%** ROUTINE: netlib___get_nameservers**** FUNCTIONAL DES NETLIB_SRC.BCKRRn?[NETLIB]NETLIB_SRI_SUPPORT.C;4Y CRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/+int netlib___get_nameservers (QUEUE *nsq) { struct NAMESERVER *ns; struct INADDRDEF a;) struct dsc$descriptor dsc, lognamdsc; ITMLST lnmlst[4];! char name[256], *cp, *anchor;& unsigned int status, size, maxidx; unsigned short namlen; int index, i, remain;A ITMLST_INIT(lnmlst[0], LNM$_INDEX, sizeof(index), &index, 0);E ITMLST_INIT(lnmlst[1], LNM$_STRING, sizeof(name), name, &namlen);G ITMLST_INIT(lnmlst[2], LNM$_MAX_INDEX, sizeof(maxidx), &maxidx, 0);' ITMLST_INIT(lnmlst[3], 0, 0, 0, 0);R for (i = 0; i < sizeof(nameserver_lognam)/sizeof(nameserver_lognam[0]); i++) {O INIT_SDESC(lognamdsc, strlen(nameserver_lognam[i]), nameserver_lognam[i]);K status = sys$trnlnm(0, &nameserver_tabnam, &lognamdsc, 0, &lnmlst[2]); if (OK(status)) break; } if (!OK(status)) return 0;' ITMLST_INIT(lnmlst[2], 0, 0, 0, 0);/ for (index = 0; index <= maxidx; index++) {G status = sys$trnlnm(0, &nameserver_tabnam, &lognamdsc, 0, lnmlst);+ if (!OK(status) || namlen == 0) break;5 for (anchor = name, remain = namlen; remain > 0;8 remain -= i+1, anchor = cp+1) {* cp = memchr(anchor, ',', remain);! if (cp == 0) i = remain; else i = cp - anchor;$ INIT_SDESC(dsc, i, anchor);7 if (!OK(netlib_strtoaddr(&dsc, &a))) continue;* size = sizeof(struct NAMESERVER);) status = lib$get_vm(&size, &ns); if (!OK(status)) break; ns->addr = a;% queue_insert(ns, nsq->tail); } } return index; } /* netlib___get_nameservers */ /***++ ** ROUTINE: netlib___get_domain**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Uint netlib___get_domain (char *buf, unsigned short bufsize, unsigned short *retlen) {) struct dsc$descriptor dsc, lognamdsc; ITMLST lnmlst[2]; char name[256], *cp; unsigned int status; unsigned short namlen; int i;E ITMLST_INIT(lnmlst[0], LNM$_STRING, sizeof(name), name, &namlen);' ITMLST_INIT(lnmlst[1], 0, 0, 0, 0);J for (i = 0; i < sizeof(domain_lognam)/sizeof(domain_lognam[0]); i++) {G INIT_SDESC(lognamdsc, strlen(domain_lognam[i]), domain_lognam[i]);G status = sys$trnlnm(0, &nameserver_tabnam, &lognamdsc, 0, lnmlst); if (OK(status)) { cp = name; break; } } if (!OK(status)) {) INIT_SDESC(dsc, sizeof(name), name);; if (!OK(netlib_get_hostname(&dsc, &namlen))) return 0;$ cp = memchr(name, '.', namlen); if (cp == 0) return 0; cp += 1; namlen -= (cp - name); }/ if (memchr(cp, '.', namlen) == 0) return 0;/ if (namlen > bufsize-1) namlen = bufsize-1; memcpy(buf, cp, namlen); *retlen = namlen; return 1;} /* netlib___get_domain */ NETLIB_SRC.BCK~=n?[NETLIB]NETLIB_UCX.C;38W_Ci*[NETLIB]NETLIB_UCX.C;38+,~=._/ @ 4W_]-n?0123KPWO`56eʘ7N,౔ʘ8N,89G @HJ/***++** FACILITY: NETLIB**'** ABSTRACT: Routines specific to UCX.**** MODULE DESCRIPTION:**** tbs**** AUTHOR: M. MadisonM** COPYRIGHT 1994, 1995 MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** CREATION DATE: 26-OCT-1994**** MODIFICATION HISTORY:**1** 26-OCT-1994 V1.0 Madison Initial coding.E** 09-JAN-1995 V1.0-1 Madison Fix some missing args on some QIOs.C** 19-JAN-1995 V1.0-2 Madison Handle 0-length writes specially.B** 28-FEB-1995 V1.0-3 Madison Fix missing arg on $DCLAST call.**--*/#include "netlib_ucx.h"#include "netlib.h"#include /*3** We don't actually do any cond_value conversions%** because we're using the UCX ones.*/$#define netlib___cvt_status(_iosb) \O ((_iosb)->iosb_w_status == SS$_CANCEL ? SS$_TIMEOUT : (_iosb)->iosb_w_status)(#define netlib___cvt_iosb(_dst, _src) {\8 (_dst)->iosb_w_status = (_src)->iosb_w_status;\7 (_dst)->iosb_w_count = (_src)->iosb_w_count;\$ (_dst)->iosb_l_unused = 0;}/*@** This is so we don't need UCX$IPC.OLB when we link with VAX C*/ #ifdef __DECC$#define gethostname decc$gethostname#else$#define gethostname vaxc$gethostname#endif/*** Forward declarations*/E unsigned int netlib_socket(struct CTX **xctx, unsigned int *type,* unsigned int *family);J unsigned int netlib_server_setup(struct CTX **xctx, struct SINDEF *sa,) unsigned int *salen);B unsigned int netlib_bind(struct CTX **xctx, struct SINDEF *sa,C unsigned int *salen, struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);7 static unsigned int io_completion(struct IOR *ior);H unsigned int netlib_getsockname(struct CTX **ctx, struct SINDEF *sa,? unsigned int *sasize, unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,5 void (*astadr)(), void *astprm);H unsigned int netlib_getpeername(struct CTX **ctx, struct SINDEF *sa,? unsigned int *sasize, unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,5 void (*astadr)(), void *astprm);D unsigned int netlib_connect(struct CTX **ctx, struct SINDEF *sa,) unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,5 void (*astadr)(), void *astprm);K unsigned int netlib_write(struct CTX **ctx, struct dsc$descriptor *dsc,: struct SINDEF *sa, unsigned int *salen,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);J unsigned int netlib_read(struct CTX **ctx, struct dsc$descriptor *dsc,; struct SINDEF *sa, unsigned int *sasize,2 unsigned int *salen, TIME *tmo,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);4 static unsigned int io_timeout(struct IOR *ior);K unsigned int netlib_shutdown(struct CTX **xctx, unsigned int *shuttype,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);1 unsigned int netlib_close(struct CTX **xctx);H unsigned int netlib_listen(struct CTX **xctx, unsigned int *backlog,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);F unsigned int netlib_accept(struct CTX **ctx, struct CTX **xnewctx,; struct SINDEF *sa, unsigned int *sasize,C unsigned int *salen, struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);5 unsigned int netlib_setsockopt(struct CTX **xctx,= unsigned int *level, unsigned int *option,5 void *value, unsigned int *vallen,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);5 unsigned int netlib_getsockopt(struct CTX **xctx,= unsigned int *level, unsigned int *option,6 void *value, unsigned int *valsize,( unsigned int *vallen,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);P unsigned int netlib_name_to_address(struct CTX **xctx, unsigned int *whichp,1 struct dsc$descriptor *namdsc,. struct INADDRDEF *addrlist,? unsigned int *listsize, unsigned int *count,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);P unsigned int netlib_address_to_name(struct CTX **xctx, unsigned int *whichp,* struct INADDRDEF *addr,* unsigned int *addrsize,1 struct dsc$descriptor *namdsc,* unsigned short *retlen,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);L unsigned int netlib_get_hostname(void *bufdsc, unsigned short *retlenp);- int netlib___get_nameservers(QUEUE *nsq);W int netlib___get_domain(char *buf, unsigned short bufsize, unsigned short *retlen);8 unsigned int netlib_dns_mx_lookup(struct CTX **xctx,B struct dsc$descriptor *namdsc, struct MXRRDEF *mxrr,> unsigned int *mxrrsize, unsigned int *mxrrcount,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);/*** OWN storage*/1 static $DESCRIPTOR(inetdevice, "UCX$DEVICE");: static $DESCRIPTOR(nameserver_tabnam, "LNM$FILE_DEV");> static unsigned int hostent_size = sizeof(struct HOSTENT);/*** External references*/O unsigned int netlib_strtoaddr(struct dsc$descriptor *, struct INADDRDEF *);! int gethostname(void *, int);: unsigned int netlib___dns_mx_lookup(struct CTX **xctx,B struct dsc$descriptor *namdsc, struct MXRRDEF *mxrr,> unsigned int *mxrrsize, unsigned int *mxrrcount,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm); /***++** ROUTINE: netlib_socket**** FUNCTIONAL DESCRIPTION:**** Create a "socket".**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Bunsigned int netlib_socket (struct CTX **xctx, unsigned int *type,+ unsigned int *family) { struct CTX *ctx; struct NETLIBIOSBDEF myiosb; struct { unsigned short protocol; unsigned char type; unsigned char domain; } sockdef; unsigned int status, af, ty; int argc; SETARGCOUNT(argc);% if (argc < 1) return SS$_INSFARG;4 status = netlib___alloc_ctx(&ctx, SPECCTX_SIZE);# if (!OK(status)) return status;7 status = sys$assign(&inetdevice, &ctx->chan, 0, 0); if (!OK(status)) { netlib___free_ctx(ctx); return status; }K  NETLIB_SRC.BCK~=n?[NETLIB]NETLIB_UCX.C;38W_ sockdef.type = (argc >= 2 && type != 0) ? *type : NETLIB_K_TYPE_STREAM;M sockdef.domain = (argc >= 3 && family != 0) ? *family : NETLIB_K_AF_INET;H sockdef.protocol = (sockdef.type == NETLIB_K_TYPE_DGRAM) ? UCX$C_UDP4 : UCX$C_TCP;? status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SETMODE, &myiosb, 0, 0,( &sockdef, 0, 0, 0, 0, 0);: if (OK(status)) status = netlib___cvt_status(&myiosb); if (!OK(status)) { sys$dassgn(ctx->chan); netlib___free_ctx(ctx); return status; } *xctx = ctx; return SS$_NORMAL;} /* netlib_socket */ /***++ ** ROUTINE: netlib_server_setup**** FUNCTIONAL DESCRIPTION:**** Create a "server_setup".**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Gunsigned int netlib_server_setup (struct CTX **xctx, struct SINDEF *sa,/ unsigned int *salen) { struct CTX *ctx; struct NETLIBIOSBDEF myiosb; struct { unsigned short protocol; unsigned char type; unsigned char domain; } sockdef; unsigned int status;* static $DESCRIPTOR(device, "SYS$NET");4 status = netlib___alloc_ctx(&ctx, SPECCTX_SIZE);# if (!OK(status)) return status;3 status = sys$assign(&device, &ctx->chan, 0, 0); if (!OK(status)) { netlib___free_ctx(ctx); return status; }! sockdef.protocol = UCX$C_TCP;( sockdef.type = INET_PROTYP$C_STREAM; sockdef.domain = UCX$C_AUXS;? status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SETMODE, &myiosb, 0, 0,( &sockdef, 0, 0, 0, 0, 0);: if (OK(status)) status = netlib___cvt_status(&myiosb); if (!OK(status)) { sys$dassgn(ctx->chan); netlib___free_ctx(ctx); return status; } *xctx = ctx; return SS$_NORMAL;} /* netlib_server_setup */ /***++** ROUTINE: netlib_bind**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/?unsigned int netlib_bind (struct CTX **xctx, struct SINDEF *sa,C unsigned int *salen, struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; ITMLST2 sockdsc; int argc; static unsigned int one = 1; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 3) return SS$_INSFARG;3 if (sa == 0 || salen == 0) return SS$_BADPARAM;< if (*salen < sizeof(struct SINDEF)) return SS$_BADPARAM;3 if (!(ctx->flags & CTX_M_USER_SET_REUSEADDR)) { ITMLST2 rulst, sockopt;C ITMLST2_INIT(rulst, UCX$C_SOCKOPT, sizeof(sockopt), &sockopt);I ITMLST2_INIT(sockopt, NETLIB_K_OPTION_REUSEADDR, sizeof(one), &one);@ sys$qiow(netlib_synch_efn, ctx->chan, IO$_SETMODE, 0, 0, 0,% 0, 0, 0, 0, &rulst, 0); }) ITMLST2_INIT(sockdsc, 0, *salen, sa);" if (argc > 4 && astadr != 0) { struct IOR *ior;> GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);L status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SETMODE, &ior->iosb,@ io_completion, ior, 0, 0, &sockdsc, 0, 0, 0); } else {! struct NETLIBIOSBDEF myiosb;I status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SETMODE, &myiosb,2 0, 0, 0, 0, &sockdsc, 0, 0, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);A if (argc > 3 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); } return status;} /* netlib_bind */ /***++** ROUTINE: io_completion**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/5static unsigned int io_completion (struct IOR *ior) { struct CTX *ctx = ior->ctx;( ior->iorflags |= IOR_M_IO_COMPLETED;; if (ior->iorflags & IOR_M_IO_TIMED) sys$cantim(ior, 0);. if (ior->iosb.iosb_w_status == SS$_CANCEL)+ ior->iosb.iosb_w_status = SS$_TIMEOUT;C if (ior->iosbp != 0) netlib___cvt_iosb(ior->iosbp, &ior->iosb);, if (ior->iorflags & IOR_M_COPY_LENGTH) {> if (OK(ior->iosb.iosb_w_status) && ior->spec_retlen != 0)@ *(unsigned int *) ior->spec_retlen = ior->spec_length;) ior->iorflags &= ~IOR_M_COPY_LENGTH; }* if (ior->iorflags & IOR_M_COPY_FROM) {B if (OK(ior->iosb.iosb_w_status) && ior->spec_userfrom != 0) { unsigned int len;$ len = ior->specior.fromlen;< if (len > ior->spec_length) len = ior->spec_length;= memcpy(ior->spec_userfrom, &ior->specior.from, len);L if (ior->spec_retlen != 0) *(unsigned int *)ior->spec_retlen = len; }( ior->iorflags &= ~IOR_M_COPY_FROM; }+ if (ior->iorflags & IOR_M_COPY_ADDRS) { struct HOSTENT *h; h = ior->spec_hostent;' if (OK(ior->iosb.iosb_w_status)) { char *base; unsigned int *offlst; int i; base = (char *) h; i = 0;' if (h->addrlist_offset != 0) {8 struct INADDRDEF *alist = ior->spec_useralist;> offlst = (unsigned int *) (base+h->addrlist_offset);: while (i < ior->spec_length && offlst[i] != 0) {B alist[i] = *(struct INADDRDEF *) (base + offlst[i]); i++; } }J if (ior->spec_retlen != 0) *(unsigned int *)ior->spec_retlen = i; }$ lib$free_vm(&hostent_size, &h);( ior->iorflags &= ~IOR_M_COPY_ADDRS; }. if (ior->iorflags & IOR_M_COPY_HOSTNAME) { struct HOSTENT *h; h = ior->spec_hostent;' if (OK(ior->iosb.iosb_w_status)) {< str$copy_r(ior->spec_usrdsc, &ior->specior.fromlen,$ h->buffer);# if (ior->spec_retlen != 0)/ *(unsigned short *)ior->spec_retlen =3 ior->specior.fromlen; }$ lib$free_vm(&hostent_size, &h);+ ior->iorflags &= ~IOR_M_COPY_HOSTNAME; }, if (ior->iorflags & IOR_M_NEW_CONTEXT) {' if (OK(ior->iosb.iosb_w_status)) {? *(struct CTX **) ior->spec_xnewctx = ior->spec_newctx; } else {< sys$dassgn(((struct CTX *)ior->spec_newctx)->chan);< netlib___free_ctx((struct CTX *) ior->spec_newctx); }, ior->iorflags &= ~IOR_M_NEW_CONTEXT; }8 if (ior->astadr != 0) (*(ior->astadr))(ior->astprm); FREE_IOR(ior); return SS$_NORMAL;} /* io_completion */ /***++** ROUTINE: netlib_getsockname**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Funsigned int netlib_getsockname (struct CTX **xctx, struct SINDEF *sa,? unsigned int *sasize, unsigned int *salen,0   NETLIB_SRC.BCK~=n?[NETLIB]NETLIB_UCX.C;38W_ struct NETLIBIOSBDEF *iosb,6 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; ITMLST slst; int argc; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);4 if (sa == 0 || sasize == 0) return SS$_BADPARAM;" if (argc > 5 && astadr != 0) { struct IOR *ior;> GET_IOR(ior, ctx, iosb, astadr, (argc > 6) ? astprm : 0);: ITMLST_INIT(slst, 0, *sasize, sa, &ior->spec_length); ior->spec_retlen = salen;' ior->iorflags = IOR_M_COPY_LENGTH;N status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SENSEMODE, &ior->iosb,= io_completion, ior, 0, 0, &slst, 0, 0, 0); } else {! struct NETLIBIOSBDEF myiosb; unsigned short length;0 ITMLST_INIT(slst, 0, *sasize, sa, &length);B status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SENSEMODE, &myiosb,/ 0, 0, 0, 0, &slst, 0, 0, 0);1 if (argc > 3 && salen != 0) *salen = length;; if (OK(status)) status = netlib___cvt_status(&myiosb);A if (argc > 4 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); } return status;} /* netlib_getsockname */ /***++** ROUTINE: netlib_getpeername**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Funsigned int netlib_getpeername (struct CTX **xctx, struct SINDEF *sa,? unsigned int *sasize, unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,6 void (*astadr)(), void *astprm) { struct CTX *ctx; ITMLST slst; unsigned int status; int argc;n VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 3) return SS$_INSFARG; 4 if (sa == 0 || sasize == 0) return SS$_BADPARAM;" if (argc > 5 && astadr != 0) { struct IOR *ior; > GET_IOR(ior, ctx, iosb, astadr, (argc > 6) ? astprm : 0);: ITMLST_INIT(slst, 0, *sasize, sa, &ior->spec_length); ior->spec_length = *sasize; ior->spec_retlen = salen;' ior->iorflags = IOR_M_COPY_LENGTH;sN status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SENSEMODE, &ior->iosb,= io_completion, ior, 0, 0, 0, &slst, 0, 0);t } else {! struct NETLIBIOSBDEF myiosb;  unsigned short length;s0 ITMLST_INIT(slst, 0, *sasize, sa, &length);B status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SENSEMODE,8 &myiosb, 0, 0, 0, 0, 0, &slst, 0, 0);1 if (argc > 3 && salen != 0) *salen = length;t; if (OK(status)) status = netlib___cvt_status(&myiosb);dA if (argc > 4 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);  }  return status;} /* netlib_getpeername */ v/***++** ROUTINE: netlib_connectE**** FUNCTIONAL DESCRIPTION:n**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.a**** COMPLETION CODES: ****** SIDE EFFECTS: None.****--*/Bunsigned int netlib_connect (struct CTX **xctx, struct SINDEF *sa,) unsigned int *salen, 0 struct NETLIBIOSBDEF *iosb,6 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; ITMLST2 sname; int argc;x VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);3 if (sa == 0 || salen == 0) return SS$_BADPARAM;s< if (*salen < sizeof(struct SINDEF)) return SS$_BADPARAM;' ITMLST2_INIT(sname, 0, *salen, sa);i$ if (argc > 4 && astadr != 0) {  struct IOR *ior; > GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);K status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_ACCESS, &ior->iosb,i> io_completion, ior, 0, 0, &sname, 0, 0, 0); } else {! struct NETLIBIOSBDEF myiosb;nH status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_ACCESS, &myiosb,0 0, 0, 0, 0, &sname, 0, 0, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);rA if (argc > 3 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); }  return status;} /* netlib_connect */ /***++** ROUTINE: netlib_writes**** FUNCTIONAL DESCRIPTION:a**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.L**** COMPLETION CODES: ****** SIDE EFFECTS: None.****--*/Iunsigned int netlib_write (struct CTX **xctx, struct dsc$descriptor *dsc,n: struct SINDEF *sa, unsigned int *salen,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; void *bufptr;T unsigned int status; unsigned short buflen; ITMLST2 sname, *snaddr; int argc;g VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);6 status = lib$analyze_sdesc(dsc, &buflen, &bufptr);# if (!OK(status)) return status;c! if (argc > 3 && salen != 0) { ( ITMLST2_INIT(sname, 0, *salen, sa); snaddr = &sname;n } else snaddr = 0;" if (argc > 5 && astadr != 0) { struct IOR *ior; > GET_IOR(ior, ctx, iosb, astadr, (argc > 6) ? astprm : 0); if (buflen == 0) {x. ior->iosb.iosb_w_status = SS$_NORMAL;$ ior->iosb.iosb_w_count = 0;% ior->iosb.iosb_l_unused = 0; 4 status = sys$dclast(io_completion, ior, 0); } else {LF status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_WRITEVBLK, &ior->iosb,> io_completion, ior, bufptr, buflen, snaddr, 0, 0, 0); } } else {! struct NETLIBIOSBDEF myiosb;  if (buflen == 0) { 4 status = myiosb.iosb_w_status = SS$_NORMAL;! myiosb.iosb_w_count = 0; " myiosb.iosb_l_unused = 0; } else { F status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_WRITEVBLK,9 &myiosb, 0, 0, bufptr, buflen, snaddr,  0, 0, 0);? if (OK(status)) status = netlib___cvt_status(&myiosb);  }A if (argc > 4 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);  } return status;} /* netlib_write */ )/***++** ROUTINE: netlib_read**** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.u**** COMPLETION CODES: ****** SIDE EFFECTS: None.****--*/Hunsigned int netlib_read (struct CTX **xctx, struct dsc$descriptor *dsc,; struct SINDEF *sa, unsigned int *sasize, 6 unsigned int *salen, TIME *timeout,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; struct IOR *ior; unsigned int status; ITMLST sname; int argc, do_from; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);E if (dsc->dsc$b_dtype != DSC$K_DTYPE_T && dsc->dsc$b_dtype != 0) {_ return SS$_BADPARAM;, } E if (dsc->dsc$b_class != DSC$K_CLASS_S && dsc->dsc$b_class != 0) {  return SS$_BADPARAM;n }iC do_from = (argc > 3 && sa != 0 && sasize != 0 && *sasize != 0);)" ! NETLIB_SRC.BCK~=n?[NETLIB]NETLIB_UCX.C;38W_%- if (argc > 7 && astadr != 0) { struct IOR *ior;t> GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0);> if (do_from) ITMLST_INIT(sname, 0, sizeof(struct SINDEF),9 &ior->specior.from, &ior->specior.fromlen);T if (do_from) {*! ior->spec_userfrom = sa; $ ior->spec_length = *sasize;" ior->spec_retlen = salen;) ior->iorflags = IOR_M_COPY_FROM;u } else ior->iorflags = 0; if (timeout != 0) {) ior->iorflags |= IOR_M_IO_TIMED;NJ status = sys$setimr(netlib_asynch_efn, timeout, io_timeout, ior);( if (!OK(status)) return status; }M status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_READVBLK, &ior->iosb,N: io_completion, ior, dsc->dsc$a_pointer,E dsc->dsc$w_length, do_from ? &sname : 0, 0, 0, 0);t } else {! struct NETLIBIOSBDEF myiosb;c struct SINDEF from; unsigned short fromlen;> if (do_from) ITMLST_INIT(sname, 0, sizeof(struct SINDEF), &from, &fromlen); $ if (argc > 5 && timeout != 0) {$ GET_IOR(ior, ctx, 0, 0, 0);( ior->iorflags = IOR_M_IO_TIMED;J status = sys$setimr(netlib_asynch_efn, timeout, io_timeout, ior); if (!OK(status)) {  FREE_IOR(ior); return status; } }A status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_READVBLK,0! &myiosb, 0, 0, 9 dsc->dsc$a_pointer, dsc->dsc$w_length,s2 do_from ? &sname : 0, 0, 0, 0);$ if (argc > 5 && timeout != 0) { sys$cantim(ior, 0); FREE_IOR(ior);* }; if (OK(status)) status = netlib___cvt_status(&myiosb);*A if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);! if (OK(status) && do_from) {r unsigned int len; len = fromlen;:* if (len > *sasize) len = *sasize; memcpy(sa, &from, len);2 if (argc > 4 && salen != 0) *salen = len; } } return status;} /* netlib_read */p t/***++** ROUTINE: io_timeout**** FUNCTIONAL DESCRIPTION:e**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:s****** SIDE EFFECTS: None.****--*/2static unsigned int io_timeout (struct IOR *ior) {> if (ior->iorflags & IOR_M_IO_COMPLETED) return SS$_NORMAL;& return sys$cancel(ior->ctx->chan);} /* io_timeout */ n/***++** ROUTINE: netlib_shutdown**** FUNCTIONAL DESCRIPTION:c**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:k****** SIDE EFFECTS: None.****--*/Hunsigned int netlib_shutdown (struct CTX **xctx, unsigned int *shuttype,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; int argc;O VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);" if (argc > 3 && astadr != 0) { struct IOR *ior;)> GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);O status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_DEACCESS|IO$M_SHUTDOWN,D< &ior->iosb, io_completion, ior, 0, 0, 0, : (shuttype == 0) ? 0 : *shuttype, 0, 0); } else {! struct NETLIBIOSBDEF myiosb;T3 status = sys$qiow(netlib_synch_efn, ctx->chan,(7 IO$_DEACCESS|IO$M_SHUTDOWN, &myiosb,i! 0, 0, 0, 0, 0, F (argc > 1 && shuttype != 0) ? *shuttype : 0, 0, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);IA if (argc > 2 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);  }l return status;} /* netlib_shutdown */ /***++** ROUTINE: netlib_closeE**** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.n**** COMPLETION CODES:,****** SIDE EFFECTS: None.****--*//unsigned int netlib_close (struct CTX **xctx) { struct CTX *ctx; unsigned int status; VERIFY_CTX(xctx, ctx);# status = sys$dassgn(ctx->chan);m# if (!OK(status)) return status;a netlib___free_ctx(ctx);D *xctx = 0; return SS$_NORMAL;} /* netlib_close */ 0/***++** ROUTINE: netlib_listen**** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:l****** SIDE EFFECTS: None.****--*/Eunsigned int netlib_listen (struct CTX **xctx, unsigned int *backlog,e. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; int argc;  VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);" if (argc > 3 && astadr != 0) { struct IOR *ior;N> GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);L status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SETMODE, &ior->iosb,0 io_completion, ior, 0, 0, 0, 8 (backlog == 0) ? 4 : *backlog, 0, 0); } else {! struct NETLIBIOSBDEF myiosb;=I status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SETMODE, &myiosb,o! 0, 0, 0, 0, 0,gD (argc > 1 && backlog != 0) ? *backlog : 4, 0, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);lA if (argc > 2 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); } return status;} /* netlib_listen */  i/***++** ROUTINE: netlib_accept**** FUNCTIONAL DESCRIPTION:u**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:=****** SIDE EFFECTS: None.****--*/Dunsigned int netlib_accept (struct CTX **xctx, struct CTX **xnewctx,; struct SINDEF *sa, unsigned int *sasize,C unsigned int *salen, struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx, *newctx;s ITMLST sname;  unsigned int status; int argc;o VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 2) return SS$_INSFARG;n* if (xnewctx == 0) return SS$_BADPARAM;7 status = netlib___alloc_ctx(&newctx, SPECCTX_SIZE);# if (!OK(status)) return status;D: status = sys$assign(&inetdevice, &newctx->chan, 0, 0); if (!OK(status)) { netlib___free_ctx(newctx);n return status;t };" if (argc > 6 && astadr != 0) { struct IOR *ior;f> GET_IOR(ior, ctx, iosb, astadr, (argc > 7) ? astprm : 0);1 ior->spec_userfrom = (sasize == 0) ? 0 : sa; 4 ior->spec_length = (sasize == 0) ? 0 : *sasize; ior->spec_retlen = salen;! ior->spec_xnewctx = xnewctx;r ior->spec_newctx = newctx;h1 ITMLST_INIT(sname, 0, sizeof(struct SINDEF), 5 &ior->specior.from, &ior->specior.fromlen); 7 ior->iorflags = IOR_M_COPY_FROM|IOR_M_NEW_CONTEXT; K status = sys$qio(netlib_asynch_efn, ctx->chan" NETLIB_SRC.BCK~=n?[NETLIB]NETLIB_UCX.C;38W_<, IO$_ACCESS|IO$M_ACCEPT,2 &ior->iosb, io_completion, ior,6 0, 0, &sname, &newctx->chan, 0, 0); } else { struct SINDEF from;! struct NETLIBIOSBDEF myiosb;  unsigned short fromlen;1 ITMLST_INIT(sname, 0, sizeof(struct SINDEF),c &from, &fromlen);eK status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_ACCESS|IO$M_ACCEPT,f' &myiosb, 0, 0, 0, 0,>0 &sname, &newctx->chan, 0, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);nA if (argc > 5 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); if (OK(status)) { *xnewctx = newctx;t2 if (argc > 3 && sa != 0 && sasize != 0) { unsigned int len;. len = fromlen;+ if (len > *sasize) len = *sasize;! memcpy(sa, &from, len);-3 if (argc > 4 && salen != 0) *salen = len;c } } }  return status;} /* netlib_accept */  /***++** ROUTINE: netlib_setsockopt**** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.(**** COMPLETION CODES:u****** SIDE EFFECTS: None.****--*/2unsigned int netlib_setsockopt (struct CTX **xctx,= unsigned int *level, unsigned int *option,,5 void *value, unsigned int *vallen,t. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status, lev;_ ITMLST2 optdsc;, int argc;) VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 5) return SS$_INSFARG;_F if (option == 0 || value == 0 || vallen == 0) return SS$_BADPARAM;0 if (level == 0) lev = NETLIB_K_LEVEL_SOCKET; else lev = *level;O if (lev == NETLIB_K_LEVEL_SOCKET && *option == NETLIB_K_OPTION_REUSEADDR) {e, ctx->flags |= CTX_M_USER_SET_REUSEADDR; }a" if (argc > 6 && astadr != 0) { struct IOR *ior;i> GET_IOR(ior, ctx, iosb, astadr, (argc > 7) ? astprm : 0);A ITMLST2_INIT(ior->specior.sockopt, *option, *vallen, value);* ITMLST2_INIT(optdsc,N> (lev == NETLIB_K_LEVEL_SOCKET) ? UCX$C_SOCKOPT : lev,> sizeof(ior->specior.sockopt), &ior->specior.sockopt);L status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SETMODE, &ior->iosb,? io_completion, ior, 0, 0, 0, 0, &optdsc, 0);i } else {! struct NETLIBIOSBDEF myiosb;t ITMLST2 sockopt; 4 ITMLST2_INIT(sockopt, *option, *vallen, value); ITMLST2_INIT(optdsc,s> (lev == NETLIB_K_LEVEL_SOCKET) ? UCX$C_SOCKOPT : lev,$ sizeof(sockopt), &sockopt);@ status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SETMODE,: &myiosb, 0, 0, 0, 0, 0, 0, &optdsc, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);=A if (argc > 5 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);  }  return status;} /* netlib_setsockopt */r >/***++** ROUTINE: netlib_getsockopt**** FUNCTIONAL DESCRIPTION:h**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.i**** COMPLETION CODES:_****** SIDE EFFECTS: None.****--*/2unsigned int netlib_getsockopt (struct CTX **xctx,= unsigned int *level, unsigned int *option,g6 void *value, unsigned int *valsize,( unsigned int *vallen,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status, lev;a ITMLST2 optdsc; int argc;s VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 5) return SS$_INSFARG;*G if (option == 0 || value == 0 || valsize == 0) return SS$_BADPARAM;s0 if (level == 0) lev = NETLIB_K_LEVEL_SOCKET; else lev = *level;" if (argc > 7 && astadr != 0) { struct IOR *ior;.> GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0);= ITMLST_INIT(ior->specior.sockopt_get, *option, *valsize,n) value, &ior->spec_length);N ITMLST2_INIT(optdsc, > (lev == NETLIB_K_LEVEL_SOCKET) ? UCX$C_SOCKOPT : lev,F sizeof(ior->specior.sockopt_get), &ior->specior.sockopt_get); ior->spec_retlen = vallen;t' ior->iorflags = IOR_M_COPY_LENGTH;cN status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_SENSEMODE, &ior->iosb,? io_completion, ior, 0, 0, 0, 0, 0, &optdsc);S } else { ITMLST sockopt_get;! struct NETLIBIOSBDEF myiosb; unsigned short length; A ITMLST_INIT(sockopt_get, *option, *valsize, value, &length);( ITMLST2_INIT(optdsc, > (lev == NETLIB_K_LEVEL_SOCKET) ? UCX$C_SOCKOPT : lev,, sizeof(sockopt_get), &sockopt_get);B status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_SENSEMODE,: &myiosb, 0, 0, 0, 0, 0, 0, 0, &optdsc);; if (OK(status)) status = netlib___cvt_status(&myiosb);mA if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);iA if (OK(status) && argc > 5 && vallen != 0) *vallen = length;i } return status;} /* netlib_getsockopt */  /***++#** ROUTINE: netlib_name_to_address***** FUNCTIONAL DESCRIPTION:***** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.***** COMPLETION CODES:******* SIDE EFFECTS: None.****--*/Munsigned int netlib_name_to_address (struct CTX **xctx, unsigned int *whichp, 1 struct dsc$descriptor *namdsc, . struct INADDRDEF *addrlist,? unsigned int *listsize, unsigned int *count,X. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; struct INADDRDEF addr; struct NETLIBIOSBDEF myiosb; struct HOSTENT hostent;c% unsigned int status, subfunction;s ITMLST2 subfdsc; ITMLST2 entdsc;a unsigned short helen;I int argc;s VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 5) return SS$_INSFARG;{K if (namdsc == 0 || addrlist == 0 || listsize == 0) return SS$_BADPARAM;p. if (OK(netlib_strtoaddr(namdsc, &addr))) { addrlist[0] = addr;, if (argc > 5 && count != 0) *count = 1;! if (argc > 6 && iosb != 0) {0* iosb->iosb_w_status = SS$_NORMAL; iosb->iosb_w_count = 1;! iosb->iosb_l_unused = 0;_ }# if (argc > 7 && astadr != 0) { ? return sys$dclast(astadr, (argc > 8) ? astprm : 0, 0);b } else { return SS$_NORMAL; } }l" if (argc > 7 && astadr != 0) { struct IOR *ior;0> GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0);< status = lib$get_vm(&hostent_size, &ior->spec_hostent); if (!OK(status)) {  FREE_IOR(ior);t return status;  } ior->specior.subfunction =bH (INETACP$C_HOSTENT_OFFSET << 8) | INETACP_FUNC$C_GETHOSTBYNAME;? ITMLST2_INIT(subfdsc, 0, sizeof(ior->specior.subfunction), ) &ior->specior.subfunction);s> ITMLST2_INIT(entdsc, 0, hostent_size, ior->spec_hostent); /$ ior->spec_useralist = addrlist;" ior->spec_length = *listsiz# NETLIB_SRC.BCK~=n?[NETLIB]NETLIB_UCX.C;38W_pKe; ior->spec_retlen = count;& ior->iorflags = IOR_M_COPY_ADDRS;M return sys$qio(netlib_asynch_efn, ctx->chan, IO$_ACPCONTROL, &ior->iosb,.8 io_completion, ior, &subfdsc, namdsc,9 &ior->specior.fromlen, &entdsc, 0, 0);i }t subfunction =CH (INETACP$C_HOSTENT_OFFSET << 8) | INETACP_FUNC$C_GETHOSTBYNAME;@ ITMLST2_INIT(subfdsc, 0, sizeof(subfunction), &subfunction);4 ITMLST2_INIT(entdsc, 0, hostent_size, &hostent);K status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_ACPCONTROL, &myiosb,X> 0, 0, &subfdsc, namdsc, &helen, &entdsc, 0, 0);: if (OK(status)) status = netlib___cvt_status(&myiosb);@ if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); if (OK(status)) {t char *base; unsigned int *offlst; int i;( base = (char *) &hostent; i = 0;$( if (hostent.addrlist_offset != 0) {B offlst = (unsigned int *) (base+hostent.addrlist_offset);2 while (i < *listsize && offlst[i] != 0) {A addrlist[i] = *(struct INADDRDEF *) (base + offlst[i]);> i++; } }, if (argc > 5 && count != 0) *count = i; }  return status; } /* netlib_name_to_address */ d/***++#** ROUTINE: netlib_address_to_name**** FUNCTIONAL DESCRIPTION:z**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:r****** SIDE EFFECTS: None.****--*/Munsigned int netlib_address_to_name (struct CTX **xctx, unsigned int *whichp,a* struct INADDRDEF *addr,* unsigned int *addrsize,1 struct dsc$descriptor *namdsc,_* unsigned short *retlen,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; struct NETLIBIOSBDEF myiosb;$ ITMLST2 subfdsc, entdsc, adrdsc;% unsigned int status, subfunction;  char buf[1024];R unsigned short length; int argc;s VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 5) return SS$_INSFARG;G if (addr == 0 || addrsize == 0 || namdsc == 0) return SS$_BADPARAM;aC if (*addrsize != sizeof(struct INADDRDEF)) return SS$_BADPARAM;x- ITMLST2_INIT(adrdsc, 0, *addrsize, addr);b" if (argc > 7 && astadr != 0) { struct IOR *ior;_ struct HOSTENT *h; > GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0);, status = lib$get_vm(&hostent_size, &h); if (!OK(status)) {} FREE_IOR(ior);a return status;( } ior->spec_usrdsc = namdsc;0 ior->spec_retlen = retlen;) ior->specior.subfunction =m? (INETACP$C_TRANS << 8) | INETACP_FUNC$C_GETHOSTBYADDR; ? ITMLST2_INIT(subfdsc, 0, sizeof(ior->specior.subfunction),n. &ior->specior.subfunction);; ITMLST2_INIT(entdsc, 0, sizeof(h->buffer), h->buffer);e ior->spec_hostent = h;T) ior->iorflags = IOR_M_COPY_HOSTNAME;PM return sys$qio(netlib_asynch_efn, ctx->chan, IO$_ACPCONTROL, &ior->iosb,n9 io_completion, ior, &subfdsc, &adrdsc,L9 &ior->specior.fromlen, &entdsc, 0, 0);* }EH subfunction = (INETACP$C_TRANS << 8) | INETACP_FUNC$C_GETHOSTBYADDR;@ ITMLST2_INIT(subfdsc, 0, sizeof(subfunction), &subfunction);. ITMLST2_INIT(entdsc, 0, sizeof(buf), buf);K status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_ACPCONTROL, &myiosb,:@ 0, 0, &subfdsc, &adrdsc, &length, &entdsc, 0, 0);: if (OK(status)) status = netlib___cvt_status(&myiosb);@ if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); if (OK(status)) {L& str$copy_r(namdsc, &length, buf);3 if (argc > 5 && retlen != 0) *retlen = length;- }n return status;} /* netlib_address_to_name */ /***++** ROUTINE: x**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.r**** COMPLETION CODES: ****** SIDE EFFECTS: None.****--*/Junsigned int netlib_get_hostname (void *bufdsc, unsigned short *retlenp) { char buf[256]; unsigned int status; unsigned short retlen; int argc;, SETARGCOUNT(argc);< if (gethostname(buf, sizeof(buf)) < 0) return SS$_ABORT; retlen = strlen(buf);b. status = str$copy_r(bufdsc, &retlen, buf);# if (!OK(status)) return status;S4 if (argc > 1 && retlenp != 0) *retlenp = retlen; return SS$_NORMAL;} /* netlib_get_hostname */? h/***++%** ROUTINE: netlib___get_nameservers **** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.D**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/+int netlib___get_nameservers (QUEUE *nsq) { struct NAMESERVER *ns; struct INADDRDEF a;C struct CTX *tmpctx;*) struct dsc$descriptor dsc, lognamdsc;C ITMLST lnmlst[4];. char name[256], lognam[256], *cp, *anchor;& unsigned int status, size, maxidx; unsigned short namlen; int index, i, remain;t static unsigned int one = 1; tmpctx = 0;tA ITMLST_INIT(lnmlst[0], LNM$_INDEX, sizeof(index), &index, 0); E ITMLST_INIT(lnmlst[1], LNM$_STRING, sizeof(name), name, &namlen);n' ITMLST_INIT(lnmlst[2], 0, 0, 0, 0);I% INIT_SDESC(lognamdsc, 0, lognam);_+ for (index = 0; index <= 16; index++) {eL lognamdsc.dsc$w_length = sprintf(lognam, "UCX$BIND_SERVER%03d", index);G status = sys$trnlnm(0, &nameserver_tabnam, &lognamdsc, 0, lnmlst);C. if (!OK(status) || namlen == 0) continue;5 for (anchor = name, remain = namlen; remain > 0; 8 remain -= i+1, anchor = cp+1) {* cp = memchr(anchor, ',', remain);! if (cp == 0) i = remain;t else i = cp - anchor;$ INIT_SDESC(dsc, i, anchor);/ if (!OK(netlib_strtoaddr(&dsc, &a))) {  if (tmpctx == 0) {> if (!OK(netlib_socket(&tmpctx, 0, 0))) continue; }(G if (!OK(netlib_name_to_address(&tmpctx, 0, &dsc, &a, &one, 0, ( 0, 0, 0))) continue; }* size = sizeof(struct NAMESERVER);) status = lib$get_vm(&size, &ns); if (!OK(status)) break; ns->addr = a;% queue_insert(ns, nsq->tail);, } } + if (tmpctx != 0) netlib_close(&tmpctx);c return index; } /* netlib___get_nameservers */ t/***++ ** ROUTINE: netlib___get_domain**** FUNCTIONAL DESCRIPTION:m**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.l**** COMPLETION CODES:n****** SIDE EFFECTS: None.****--*/Uint netlib___get_domain (char *buf, unsigned short bufsize, unsigned short *retlen) {S struct dsc$descriptor dsc; ITMLST lnmlst[2];i char name[256], *cp; unsigned int status; unsigned short namlen;5 static $DESCRIPTOR(lognamdsc, "UCX$BIND_DOMAIN"); / static $DESCRIPTOR(tabnam, "LNM$FILE_DEV");FE ITMLST_INIT(lnmlst[0], LNM$_STRING, sizeof(name), name, &namle$ NETLIB_SRC.BCK~=n?[NETLIB]NETLIB_UCX.C;38W_|Zn);t' ITMLST_INIT(lnmlst[1], 0, 0, 0, 0);; status = sys$trnlnm(0, &tabnam, &lognamdsc, 0, lnmlst);, if (OK(status)) cp = name; else {) INIT_SDESC(dsc, sizeof(name), name);t; if (!OK(netlib_get_hostname(&dsc, &namlen))) return 0;($ cp = memchr(name, '.', namlen); if (cp == 0) return 0; cp += 1;a namlen -= (cp - name);h }0/ if (memchr(cp, '.', namlen) == 0) return 0;n/ if (namlen > bufsize-1) namlen = bufsize-1;( memcpy(buf, cp, namlen); *retlen = namlen; return 1;t} /* netlib___get_domain */s m/***++!** ROUTINE: netlib_dns_mx_lookup0**** FUNCTIONAL DESCRIPTION:t**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:r****** SIDE EFFECTS: None.****--*/4unsigned int netlib_dns_mx_lookup(struct CTX **xctx,B struct dsc$descriptor *namdsc, struct MXRRDEF *mxrr,> unsigned int *mxrrsize, unsigned int *mxrrcount,K struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm) { struct CTX *ctx; int argc;  VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 4) return SS$_INSFARG;o? return netlib___dns_mx_lookup(xctx, namdsc, mxrr, mxrrsize, ; (argc > 4) ? mxrrcount : 0, (argc > 5) ? iosb : 0,,; (argc > 6) ? astadr : 0, (argc > 7) ? astprm : 0);i} /* netlib_dns_mx_lookup */vt_status(&myiosb);nA if (argc > 5 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); if (OK(status)) { *xnewctx = newctx;t2 if (argc > 3 && sa != 0 && sasize != 0) { unsigned int len;. len = fromlen;+ if (len > *sasize) len = *sasize;! memcpy(sa, &from, len);-3 if (argc > 4 && salen != 0) *salen = len;c } } }  return status;} /* netlib_accept */  /***++** ROUTIN% NETLIB_SRC.BCK?~n?[NETLIB]NETLIB_CMU.C;50Xs*[NETLIB]NETLIB_CMU.C;50+,?~.s/ @ 4Xso-n?0123KPWOt56nYȔʘ7Ȕʘ889G @HJ/***++** FACILITY: NETLIB**.** ABSTRACT: Routines specific to CMU TCP/IP.**** MODULE DESCRIPTION:**** tbs**** AUTHOR: M. MadisonG** COPYRIGHT 1994, MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** CREATION DATE: 26-OCT-1994**** MODIFICATION HISTORY:**1** 31-OCT-1994 V1.0 Madison Initial coding.:** 19-NOV-1994 V1.1 Madison Add CMU resolver bypass.;** 09-JAN-1995 V1.1-1 Madison Fix $CANTIM coding error.H** 13-JAN-1995 V1.1-2 Madison Fix potential memory leaks, timer bug.B** 23-JAN-1995 V1.1-3 Madison Fix ASTPRM check on async close.3** 17-FEB-1995 V1.1-4 Madison Fix UDP connects.@** 28-FEB-1995 V1.1-5 Madison UDP sockets need to be OPENed;4** arg missing on $DCLAST.**--*/#include "netlib_cmu.h"#include "netlib.h"#include /*** Forward declarations*/E unsigned int netlib_socket(struct CTX **xctx, unsigned int *type,* unsigned int *family);J unsigned int netlib_server_setup(struct CTX **xctx, struct SINDEF *sa,) unsigned int *salen);B unsigned int netlib_bind(struct CTX **xctx, struct SINDEF *sa,C unsigned int *salen, struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);7 static unsigned int io_completion(struct IOR *ior);H unsigned int netlib_getsockname(struct CTX **ctx, struct SINDEF *sa,? unsigned int *sasize, unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,5 void (*astadr)(), void *astprm);H unsigned int netlib_getpeername(struct CTX **ctx, struct SINDEF *sa,? unsigned int *sasize, unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,5 void (*astadr)(), void *astprm);D unsigned int netlib_connect(struct CTX **ctx, struct SINDEF *sa,) unsigned int *salen,0 struct NETLIBIOSBDEF *iosb,5 void (*astadr)(), void *astprm);K unsigned int netlib_write(struct CTX **ctx, struct dsc$descriptor *dsc,: struct SINDEF *sa, unsigned int *salen,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);J unsigned int netlib_read(struct CTX **ctx, struct dsc$descriptor *dsc,; struct SINDEF *sa, unsigned int *sasize,2 unsigned int *salen, TIME *tmo,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);4 static unsigned int io_timeout(struct IOR *ior);K unsigned int netlib_shutdown(struct CTX **xctx, unsigned int *shuttype,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);1 unsigned int netlib_close(struct CTX **xctx);H unsigned int netlib_listen(struct CTX **xctx, unsigned int *backlog,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);F unsigned int netlib_accept(struct CTX **ctx, struct CTX **xnewctx,; struct SINDEF *sa, unsigned int *sasize,C unsigned int *salen, struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);5 unsigned int netlib_setsockopt(struct CTX **xctx,= unsigned int *level, unsigned int *option,5 void *value, unsigned int *vallen,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);5 unsigned int netlib_getsockopt(struct CTX **xctx,= unsigned int *level, unsigned int *option,6 void *value, unsigned int *valsize,( unsigned int *vallen,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);P unsigned int netlib_name_to_address(struct CTX **xctx, unsigned int *whichp,1 struct dsc$descriptor *namdsc,. struct INADDRDEF *addrlist,? unsigned int *listsize, unsigned int *count,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);P unsigned int netlib_address_to_name(struct CTX **xctx, unsigned int *whichp,* struct INADDRDEF *addr,* unsigned int *addrsize,1 struct dsc$descriptor *namdsc,* unsigned short *retlen,. struct NETLIBIOSBDEF *iosb,3 void (*astadr)(), void *astprm);L unsigned int netlib_get_hostname(void *bufdsc, unsigned short *retlenp);- int netlib___get_nameservers(QUEUE *nsq);W int netlib___get_domain(char *buf, unsigned short bufsize, unsigned short *retlen);H static unsigned int netlib___cvt_status(struct NETLIBIOSBDEF *iosb);X static void netlib___cvt_iosb(struct NETLIBIOSBDEF *dst, struct NETLIBIOSBDEF *src);N static void expand(char *, unsigned int, unsigned char *, unsigned int *);8 unsigned int netlib_dns_mx_lookup(struct CTX **xctx,B struct dsc$descriptor *namdsc, struct MXRRDEF *mxrr,> unsigned int *mxrrsize, unsigned int *mxrrcount,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);) static int bypass_cmu_resolver(void);/*** OWN storage*/2 static $DESCRIPTOR(inetdevice, "INET$DEVICE");/ static $DESCRIPTOR(backup_device, "_IP0:");= static unsigned int rr_info_size = sizeof(struct CMU_RR);A static unsigned int name_info_size = sizeof(struct CMU_AtoN);A static unsigned int addr_info_size = sizeof(struct CMU_NtoA);E static unsigned int conn_info_size = sizeof(struct CMU_ConnInfo);/*** External references*/O unsigned int netlib_strtoaddr(struct dsc$descriptor *, struct INADDRDEF *);; unsigned int netlib___dns_name_to_addr(struct CTX *ctx,H struct dsc$descriptor *namdsc, struct INADDRDEF *addrlist,9 unsigned int listsize, unsigned int *count,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);; unsigned int netlib___dns_addr_to_name(struct CTX *ctx,@ struct INADDRDEF *addrlist, unsigned int addrsize,D struct dsc$descriptor *namdsc, unsigned short *retlen,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm);: unsigned int netlib___dns_mx_lookup(struct CTX **xctx,B struct dsc$descriptor *namdsc, struct MXRRDEF *mxrr,> unsigned int *mxrrsize, unsigned int *mxrrcount,J struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm); /***++** ROUTINE: netlib_socket**** FUNCTIONAL DESCRIPTION:**** Create a "socket".**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Bunsigned int netlib_socket (& NETLIB_SRC.BCK?~n?[NETLIB]NETLIB_CMU.C;50Xsw%struct CTX **xctx, unsigned int *type,+ unsigned int *family) { struct CTX *ctx; struct { unsigned short protocol; unsigned char type; unsigned char domain; } sockdef; unsigned int status, af, ty; int argc; SETARGCOUNT(argc);% if (argc < 1) return SS$_INSFARG;> status = netlib___alloc_ctx(&ctx, sizeof(struct SPECCTX));# if (!OK(status)) return status;7 status = sys$assign(&inetdevice, &ctx->chan, 0, 0);K if (!OK(status)) status = sys$assign(&backup_device, &ctx->chan, 0, 0); if (!OK(status)) { netlib___free_ctx(ctx); return status; } ctx->specctx->socket_type =< (argc < 2 || type == 0) ? NETLIB_K_TYPE_STREAM : *type; *xctx = ctx; return SS$_NORMAL;} /* netlib_socket */ /***++ ** ROUTINE: netlib_server_setup**** FUNCTIONAL DESCRIPTION:**** Create a "server_setup".**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Gunsigned int netlib_server_setup (struct CTX **xctx, struct SINDEF *sa,/ unsigned int *salen) { struct CTX *ctx; struct NETLIBIOSBDEF iosb;" unsigned int status, type, af;3 if (sa == 0 || salen == 0) return SS$_BADPARAM; type = NETLIB_K_TYPE_STREAM; af = NETLIB_K_AF_INET;- status = netlib_socket(&ctx, &type, &af);< status = sys$qiow(netlib_synch_efn, ctx->chan, IO__OPEN, &iosb, 0, 0,6 0, 0, netlib_word_swap(sa->sin_w_port),& 0, CMU_K_PROTO_TCP, 0);8 if (OK(status)) status = netlib___cvt_status(&iosb); if (!OK(status)) { sys$dassgn(ctx->chan); netlib___free_ctx(ctx); return status; } *xctx = ctx; return SS$_NORMAL;} /* netlib_server_setup */ /***++** ROUTINE: netlib_bind**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/?unsigned int netlib_bind (struct CTX **xctx, struct SINDEF *sa,C unsigned int *salen, struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; int argc; static unsigned int one = 1; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);3 if (sa == 0 || salen == 0) return SS$_BADPARAM;< if (*salen < sizeof(struct SINDEF)) return SS$_BADPARAM;. ctx->specctx->local_addr = sa->sin_x_addr;@ ctx->specctx->local_port = netlib_word_swap(sa->sin_w_port);< if (ctx->specctx->socket_type == NETLIB_K_TYPE_STREAM) {! if (argc > 3 && iosb != 0) {* iosb->iosb_w_status = SS$_NORMAL; iosb->iosb_w_count = 0;! iosb->iosb_l_unused = 0; }# if (argc > 4 && astadr != 0) {8 sys$dclast(astadr, (argc > 5) ? astprm : 0, 0); } return SS$_NORMAL; }" if (argc > 4 && astadr != 0) { struct IOR *ior;> GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);I status = sys$qio(netlib_asynch_efn, ctx->chan, IO__OPEN, &ior->iosb,F io_completion, ior, 0, 0, ctx->specctx->local_port,; CMU_M_OPEN_UDPDATA, CMU_K_PROTO_UDP, 0); } else {! struct NETLIBIOSBDEF myiosb;F status = sys$qiow(netlib_synch_efn, ctx->chan, IO__OPEN, &myiosb,8 0, 0, 0, 0, ctx->specctx->local_port,; CMU_M_OPEN_UDPDATA, CMU_K_PROTO_UDP, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);A if (argc > 3 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); } return status;} /* netlib_bind */ /***++** ROUTINE: io_completion**** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/5static unsigned int io_completion (struct IOR *ior) {( ior->iorflags |= IOR_M_IO_COMPLETED;; if (ior->iorflags & IOR_M_IO_TIMED) sys$cantim(ior, 0);. if (ior->iosb.iosb_w_status == SS$_CANCEL)+ ior->iosb.iosb_w_status = SS$_TIMEOUT;C if (ior->iosbp != 0) netlib___cvt_iosb(ior->iosbp, &ior->iosb);* if (ior->iorflags & IOR_M_COPY_FROM) {B if (OK(ior->iosb.iosb_w_status) && ior->spec_userfrom != 0) { unsigned int len; struct SINDEF *sa;! sa = ior->spec_userfrom;% len = sizeof(struct SINDEF);< if (len > ior->spec_length) len = ior->spec_length;; if (len >= 2) sa->sin_w_family = NETLIB_K_AF_INET;' if (len >= 4) sa->sin_w_port =? netlib_word_swap(ior->specior.from.ipa_w_srcport);H if (len >= 8) sa->sin_x_addr = ior->specior.from.ipa_x_srcaddr;6 if (len > 8) memset(sa->sin_x_mbz, 0, len-8);M if (ior->spec_retlen != 0) *(unsigned int *) ior->spec_retlen = len; }' ior->iorflags &= ~IOR_M_COPY_FROM; }. if (ior->iorflags & IOR_M_COPY_CI_LOCAL) {' if (OK(ior->iosb.iosb_w_status)) {! struct CMU_ConnInfo *ci; struct SINDEF *sa; int len;" ci = ior->spec_conn_info;! sa = ior->spec_userfrom;% len = sizeof(struct SINDEF);@ if (ior->spec_usersize < len) len = ior->spec_usersize;; if (len >= 2) sa->sin_w_family = NETLIB_K_AF_INET;N if (len >= 4) sa->sin_w_port = netlib_word_swap(ci->ci_l_local_port);? if (len >= 8) sa->sin_x_addr = ci->ci_x_local_address;6 if (len > 8) memset(sa->sin_x_mbz, 0, len-8);L if (ior->spec_retlen != 0) *(unsigned int *)ior->spec_retlen = len; }8 lib$free_vm(&conn_info_size, &ior->spec_conn_info);+ ior->iorflags &= ~IOR_M_COPY_CI_LOCAL; }/ if (ior->iorflags & IOR_M_COPY_CI_REMOTE) {' if (OK(ior->iosb.iosb_w_status)) {! struct CMU_ConnInfo *ci; struct SINDEF *sa; int len;" ci = ior->spec_conn_info; sa = ior->spec_userfrom;% len = sizeof(struct SINDEF);@ if (ior->spec_usersize < len) len = ior->spec_usersize;; if (len >= 2) sa->sin_w_family = NETLIB_K_AF_INET;O if (len >= 4) sa->sin_w_port = netlib_word_swap(ci->ci_l_remote_port);@ if (len >= 8) sa->sin_x_addr = ci->ci_x_remote_address;6 if (len > 8) memset(sa->sin_x_mbz, 0, len-8);L if (ior->spec_retlen != 0) *(unsigned int *)ior->spec_retlen = len; }8 lib$free_vm(&conn_info_size, &ior->spec_conn_info);, ior->iorflags &= ~IOR_M_COPY_CI_REMOTE; }+ if (ior->iorflags & IOR_M_COPY_ADDRS) {' if (OK(ior->iosb.iosb_w_status)) {! struct INADDRDEF *alist;5 struct CMU_NtoA *ntoa = ior->spec_addr_info; int i;# alist = ior->spec_userbuf;K for (i = 0; i < ior->spec_length && i < ntoa->ntoa_l_count; i++) {* alist[i] = ntoa->ntoa_x_addr[i]; }J if (ior->spec_retlen != 0) *(unsigned int *)ior->spec_retlen = i; }8 lib$free_vm(&addr_info_size, &ior->spec_addr_info);( ior->iorflags &= ~IOR_M_COPY_' NETLIB_SRC.BCK?~n?[NETLIB]NETLIB_CMU.C;50XsADDRS; }. if (ior->iorflags & IOR_M_COPY_HOSTNAME) {* if (OK(ior->iosb.iosb_w_status)) {$ struct dsc$descriptor *dsc;3 struct CMU_AtoN *ni = ior->spec_name_info;! dsc = ior->spec_userbuf;? str$copy_r(dsc, &ni->aton_l_namelen, ni->aton_t_name);% if (ior->spec_retlen != 0) {G *(unsigned short *) ior->spec_retlen = ni->aton_l_namelen; } }8 lib$free_vm(&name_info_size, &ior->spec_name_info);+ ior->iorflags &= ~IOR_M_COPY_HOSTNAME; }+ if (ior->iorflags & IOR_M_COPY_MXRRS) {' if (OK(ior->iosb.iosb_w_status)) { struct MXRRDEF *mxrr;/ struct CMU_RR *rr = ior->spec_rr_info; unsigned int i, len; int remain; unsigned char *cp;" mxrr = ior->spec_userbuf; cp = rr->rr_x_data + 1;& remain = rr->rr_w_length - 1; i = 0;5 while (remain > 0 && i < ior->spec_length) {2 len = *(unsigned short *)cp; cp += 2;@ mxrr[i].mxrr_l_preference = *(unsigned short *) cp;A expand(mxrr[i].mxrr_t_name, NETLIB_S_MXRR_NAME, cp + 2,' &mxrr[i].mxrr_l_length); remain -= len + 2; cp += len; i++; }J if (ior->spec_retlen != 0) *(unsigned int *)ior->spec_retlen = i; }4 lib$free_vm(&rr_info_size, &ior->spec_rr_info);( ior->iorflags &= ~IOR_M_COPY_MXRRS; }, if (ior->iorflags & IOR_M_NEW_CONTEXT) {' if (OK(ior->iosb.iosb_w_status)) { ? *(struct CTX **) ior->spec_xnewctx = ior->spec_newctx;*- ior->iorflags &= ~IOR_M_NEW_CONTEXT;*' if (ior->spec_userfrom != 0) {T unsigned int len;$ len = ior->spec_length;& ior->iosb.iosb_w_status =B netlib_getpeername(&(struct CTX *) ior->spec_newctx,+ ior->spec_userfrom, &len,-, ior->spec_retlen, ior->iosbp,) ior->astadr, ior->astprm);i, if (OK(ior->iosb.iosb_w_status)) { FREE_IOR(ior); return SS$_NORMAL; } else {M if (ior->iosbp != 0) netlib___cvt_iosb(ior->iosbp, &ior->iosb);dA sys$dassgn(((struct CTX *)ior->spec_newctx)->chan);.A netlib___free_ctx((struct CTX *) ior->spec_newctx);e } } } else {s< sys$dassgn(((struct CTX *)ior->spec_newctx)->chan);< netlib___free_ctx((struct CTX *) ior->spec_newctx); }) ior->iorflags &= ~IOR_M_NEW_CONTEXT;x }t8 if (ior->astadr != 0) (*(ior->astadr))(ior->astprm); FREE_IOR(ior); return SS$_NORMAL;} /* io_completion */  /***++** ROUTINE: netlib_getsocknameS**** FUNCTIONAL DESCRIPTION:v**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:g****** SIDE EFFECTS: None.****--*/Funsigned int netlib_getsockname (struct CTX **xctx, struct SINDEF *sa,? unsigned int *sasize, unsigned int *salen,N0 struct NETLIBIOSBDEF *iosb,6 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; ITMLST slst; int argc;n VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);4 if (sa == 0 || sasize == 0) return SS$_BADPARAM;" if (argc > 5 && astadr != 0) { struct IOR *ior; > GET_IOR(ior, ctx, iosb, astadr, (argc > 6) ? astprm : 0);@ status = lib$get_vm(&conn_info_size, &ior->spec_conn_info); if (!OK(status)) {  FREE_IOR(ior);  return status;L }" ior->spec_usersize = *sasize; ior->spec_userfrom = sa;  ior->spec_retlen = salen;) ior->iorflags = IOR_M_COPY_CI_LOCAL; I status = sys$qio(netlib_asynch_efn, ctx->chan, IO__INFO, &ior->iosb, < io_completion, ior, ior->spec_conn_info, / conn_info_size, 0, 0, 0, 0);a } else {! struct NETLIBIOSBDEF myiosb;o struct CMU_ConnInfo ci;= status = sys$qiow(netlib_synch_efn, ctx->chan, IO__INFO,*& &myiosb, 0, 0, &ci,/ conn_info_size, 0, 0, 0, 0);a; if (OK(status)) status = netlib___cvt_status(&myiosb);CA if (argc > 4 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);i if (OK(status)) { int len;c% len = sizeof(struct SINDEF); * if (*sasize < len) len = *sasize;; if (len >= 2) sa->sin_w_family = NETLIB_K_AF_INET;tM if (len >= 4) sa->sin_w_port = netlib_word_swap(ci.ci_l_local_port); > if (len >= 8) sa->sin_x_addr = ci.ci_x_local_address;6 if (len > 8) memset(sa->sin_x_mbz, 0, len-8);2 if (argc > 3 && salen != 0) *salen = len; } }s return status;} /* netlib_getsockname */ /***++** ROUTINE: netlib_getpeername **** FUNCTIONAL DESCRIPTION:B**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:l****** SIDE EFFECTS: None.****--*/Funsigned int netlib_getpeername (struct CTX **xctx, struct SINDEF *sa,? unsigned int *sasize, unsigned int *salen,t0 struct NETLIBIOSBDEF *iosb,6 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; ITMLST slst; int argc;s VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);4 if (sa == 0 || sasize == 0) return SS$_BADPARAM;" if (argc > 5 && astadr != 0) { struct IOR *ior;d> GET_IOR(ior, ctx, iosb, astadr, (argc > 6) ? astprm : 0);@ status = lib$get_vm(&conn_info_size, &ior->spec_conn_info); if (!OK(status)) {  FREE_IOR(ior);r return status;  } ior->spec_userfrom = sa; " ior->spec_usersize = *sasize; ior->spec_retlen = salen;* ior->iorflags = IOR_M_COPY_CI_REMOTE;I status = sys$qio(netlib_asynch_efn, ctx->chan, IO__INFO, &ior->iosb,g< io_completion, ior, ior->spec_conn_info, / conn_info_size, 0, 0, 0, 0);t } else {! struct NETLIBIOSBDEF myiosb;u struct CMU_ConnInfo ci;= status = sys$qiow(netlib_synch_efn, ctx->chan, IO__INFO,s& &myiosb, 0, 0, &ci,/ conn_info_size, 0, 0, 0, 0); ; if (OK(status)) status = netlib___cvt_status(&myiosb);tA if (argc > 4 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);X if (OK(status)) { int len;x% len = sizeof(struct SINDEF); * if (*sasize < len) len = *sasize;; if (len >= 2) sa->sin_w_family = NETLIB_K_AF_INET;vN if (len >= 4) sa->sin_w_port = netlib_word_swap(ci.ci_l_remote_port);? if (len >= 8) sa->sin_x_addr = ci.ci_x_remote_address;c6 if (len > 8) memset(sa->sin_x_mbz, 0, len-8);2 if (argc > 3 && salen != 0) *salen = len; } }  return status;} /* netlib_getpeername */ U/***++** ROUTINE: netlib_connecti**** FUNCTIONAL DESCRIPTION:I**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:d****** SIDE EFFECTS: None.****--*/Bunsigned int netlib_connect (struc( NETLIB_SRC.BCK?~n?[NETLIB]NETLIB_CMU.C;50Xs<-t CTX **xctx, struct SINDEF *sa,) unsigned int *salen,d0 struct NETLIBIOSBDEF *iosb,6 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; int argc;t VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);3 if (sa == 0 || salen == 0) return SS$_BADPARAM; < if (*salen < sizeof(struct SINDEF)) return SS$_BADPARAM;/*?** For UDP sockets, save the remote address/port for later useE*/; if (ctx->specctx->socket_type == NETLIB_K_TYPE_DGRAM) {r0 ctx->specctx->remote_addr = sa->sin_x_addr;0 ctx->specctx->remote_port = sa->sin_w_port;# if (argc > 4 && astadr != 0) {N struct IOR *ior;CB GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);M status = sys$qio(netlib_asynch_efn, ctx->chan, IO__OPEN, &ior->iosb,T/ io_completion, ior, 0, 0, 0,*; CMU_M_OPEN_UDPDATA, CMU_K_PROTO_UDP, 0); } else {n% struct NETLIBIOSBDEF myiosb;,J status = sys$qiow(netlib_synch_efn, ctx->chan, IO__OPEN, &myiosb,! 0, 0, 0, 0, 0,u; CMU_M_OPEN_UDPDATA, CMU_K_PROTO_UDP, 0);s? if (OK(status)) status = netlib___cvt_status(&myiosb);,E if (argc > 3 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);u } return status;= }_" if (argc > 4 && astadr != 0) { struct IOR *ior;)> GET_IOR(ior, ctx, iosb, astadr, (argc > 5) ? astprm : 0);I status = sys$qio(netlib_asynch_efn, ctx->chan, IO__OPEN, &ior->iosb,c& io_completion, ior,1 &sa->sin_x_addr.inaddr_l_addr, 4 netlib_word_swap(sa->sin_w_port),, ctx->specctx->local_port,: CMU_M_OPEN_ACTIVE|CMU_M_OPEN_BYADDRESS,' CMU_K_PROTO_TCP, 0);n } else {! struct NETLIBIOSBDEF myiosb;NL status = sys$qiow(netlib_synch_efn, ctx->chan, IO__OPEN, &myiosb, 0, 0,1 &sa->sin_x_addr.inaddr_l_addr,:4 netlib_word_swap(sa->sin_w_port),, ctx->specctx->local_port,: CMU_M_OPEN_ACTIVE|CMU_M_OPEN_BYADDRESS,' CMU_K_PROTO_TCP, 0);C; if (OK(status)) status = netlib___cvt_status(&myiosb);gA if (argc > 3 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);F } return status;} /* netlib_connect */ /***++** ROUTINE: netlib_write**** FUNCTIONAL DESCRIPTION:A**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:a****** SIDE EFFECTS: None.****--*/Iunsigned int netlib_write (struct CTX **xctx, struct dsc$descriptor *dsc,(: struct SINDEF *sa, unsigned int *salen,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; void *bufptr;: unsigned int status; unsigned short buflen; struct CMU_IPAddr ipa; int argc, do_address;) VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);6 status = lib$analyze_sdesc(dsc, &buflen, &bufptr);# if (!OK(status)) return status; do_address = 0;C! if (argc > 3 && salen != 0) {d do_address = 1;" memset(&ipa, 0, sizeof(ipa));K if (*salen >= 4) ipa.ipa_w_dstport = netlib_word_swap(sa->sin_w_port); 9 if (*salen >= 8) ipa.ipa_x_dstaddr = sa->sin_x_addr;C2 ipa.ipa_w_srcport = ctx->specctx->local_port;2 ipa.ipa_x_srcaddr = ctx->specctx->local_addr;B } else if (ctx->specctx->socket_type == NETLIB_K_TYPE_DGRAM) { do_address = 1;" memset(&ipa, 0, sizeof(ipa));E ipa.ipa_w_dstport = netlib_word_swap(ctx->specctx->remote_port);a3 ipa.ipa_x_dstaddr = ctx->specctx->remote_addr;(2 ipa.ipa_w_srcport = ctx->specctx->local_port;2 ipa.ipa_x_srcaddr = ctx->specctx->local_addr; } " if (argc > 5 && astadr != 0) { struct IOR *ior;-> GET_IOR(ior, ctx, iosb, astadr, (argc > 6) ? astprm : 0); if (buflen == 0) { . ior->iosb.iosb_w_status = SS$_NORMAL;$ ior->iosb.iosb_w_count = 0;% ior->iosb.iosb_l_unused = 0;>4 status = sys$dclast(io_completion, ior, 0); } else {iR status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_WRITEVBLK, &ior->iosb,? io_completion, ior, bufptr, buflen, 0, 1, 0, * do_address ? &ipa : 0); } } else {! struct NETLIBIOSBDEF myiosb;  if (buflen == 0) {E4 status = myiosb.iosb_w_status = SS$_NORMAL;! myiosb.iosb_w_count = 0;s" myiosb.iosb_l_unused = 0; } else {cF status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_WRITEVBLK,: &myiosb, 0, 0, bufptr, buflen, 0, 1, 0,* do_address ? &ipa : 0);? if (OK(status)) status = netlib___cvt_status(&myiosb);t }A if (argc > 4 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);D }I return status;} /* netlib_write */ l/***++** ROUTINE: netlib_read**** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.s**** COMPLETION CODES:o****** SIDE EFFECTS: None.****--*/Hunsigned int netlib_read (struct CTX **xctx, struct dsc$descriptor *dsc,; struct SINDEF *sa, unsigned int *sasize,T6 unsigned int *salen, TIME *timeout,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; struct IOR *ior; unsigned int status; int argc, do_from; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);E if (dsc->dsc$b_dtype != DSC$K_DTYPE_T && dsc->dsc$b_dtype != 0) {> return SS$_BADPARAM;l })E if (dsc->dsc$b_class != DSC$K_CLASS_S && dsc->dsc$b_class != 0) {p return SS$_BADPARAM;_ }aC do_from = (argc > 3 && sa != 0 && sasize != 0 && *sasize != 0);a" if (argc > 7 && astadr != 0) {> GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0); if (do_from) {t! ior->spec_userfrom = sa;e$ ior->spec_length = *sasize;" ior->spec_retlen = salen;) ior->iorflags = IOR_M_COPY_FROM;O } else ior->iorflags = 0;* ior->iorflags &= ~IOR_M_IO_COMPLETED;! if (timeout != 0) { a( ior->iorflags = IOR_M_IO_TIMED;J status = sys$setimr(netlib_asynch_efn, timeout, io_timeout, ior);( if (!OK(status)) return status; }M status = sys$qio(netlib_asynch_efn, ctx->chan, IO$_READVBLK, &ior->iosb,E: io_completion, ior, dsc->dsc$a_pointer,% dsc->dsc$w_length, > do_from ? &ior->specior.from : 0, 0, 0, 0); } else {! struct NETLIBIOSBDEF myiosb;n struct CMU_IPAddr from;$ if (argc > 5 && timeout != 0) {$ GET_IOR(ior, ctx, 0, 0, 0);( ior->iorflags = IOR_M_IO_TIMED;J status = sys$setimr(netlib_asynch_efn, timeout, io_timeout, ior); if (!OK(status)) { FREE_IOR(ior); return status; } }A status = sys$qiow(netlib_synch_efn, ctx->chan, IO$_READVBLK, ! &myiosb, 0, 0,i9 dsc->dsc$a_pointer, dsc->dsc$w_length,1 do_from ? &from : 0, 0, 0, 0);p$ ) NETLIB_SRC.BCK?~n?[NETLIB]NETLIB_CMU.C;50XsF< if (argc > 5 && timeout != 0) { sys$cantim(ior, 0); FREE_IOR(ior);> }; if (OK(status)) status = netlib___cvt_status(&myiosb); A if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); ! if (OK(status) && do_from) {  unsigned int len;% len = sizeof(struct SINDEF);r* if (len > *sasize) len = *sasize;; if (len >= 2) sa->sin_w_family = NETLIB_K_AF_INET;s' if (len >= 4) sa->sin_w_port = / netlib_word_swap(from.ipa_w_srcport); ; if (len >= 8) sa->sin_x_addr = from.ipa_x_srcaddr;a6 if (len > 8) memset(sa->sin_x_mbz, 0, len-8);2 if (argc > 4 && salen != 0) *salen = len; } }  return status;} /* netlib_read */< o/***++** ROUTINE: io_timeout **** FUNCTIONAL DESCRIPTION:**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.P**** COMPLETION CODES:(****** SIDE EFFECTS: None.****--*/2static unsigned int io_timeout (struct IOR *ior) {> if (ior->iorflags & IOR_M_IO_COMPLETED) return SS$_NORMAL;& return sys$cancel(ior->ctx->chan);} /* io_timeout */ s/***++** ROUTINE: netlib_shutdown**** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.I**** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Hunsigned int netlib_shutdown (struct CTX **xctx, unsigned int *shuttype,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status; int argc;u VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);" if (argc > 3 && astadr != 0) { struct IOR *ior;a> GET_IOR(ior, ctx, iosb, astadr, (argc > 4) ? astprm : 0);J status = sys$qio(netlib_asynch_efn, ctx->chan, IO__CLOSE, &ior->iosb,9 io_completion, ior, 0, 0, 0, 0, 0, 0);M } else {! struct NETLIBIOSBDEF myiosb;lG status = sys$qiow(netlib_synch_efn, ctx->chan, IO__CLOSE, &myiosb, + 0, 0, 0, 0, 0, 0, 0, 0);r; if (OK(status)) status = netlib___cvt_status(&myiosb); A if (argc > 2 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);r }a return status;} /* netlib_shutdown */i l/***++** ROUTINE: netlib_closeO**** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.**** COMPLETION CODES:c****** SIDE EFFECTS: None.****--*//unsigned int netlib_close (struct CTX **xctx) {i struct CTX *ctx; unsigned int status; VERIFY_CTX(xctx, ctx);# status = sys$dassgn(ctx->chan); # if (!OK(status)) return status;  netlib___free_ctx(ctx);t *xctx = 0; return SS$_NORMAL;} /* netlib_close */ ;/***++** ROUTINE: netlib_listen**** FUNCTIONAL DESCRIPTION:o**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES: ****** SIDE EFFECTS: None.****--*/Eunsigned int netlib_listen (struct CTX **xctx, unsigned int *backlog, . struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; int argc;  VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc); if (argc > 2 && iosb != 0) {& iosb->iosb_w_status = SS$_NORMAL; iosb->iosb_w_count = 0; iosb->iosb_l_unused = 0;) } N if (argc > 3 && astadr != 0) sys$dclast(astadr, argc > 4 ? astprm : 0, 0); return SS$_NORMAL;} /* netlib_listen */N D/***++** ROUTINE: netlib_accept**** FUNCTIONAL DESCRIPTION:t**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:i****** SIDE EFFECTS: None.****--*/Dunsigned int netlib_accept (struct CTX **xctx, struct CTX **xnewctx,; struct SINDEF *sa, unsigned int *sasize,0C unsigned int *salen, struct NETLIBIOSBDEF *iosb,r4 void (*astadr)(), void *astprm) { struct CTX *ctx, *newctx;  ITMLST sname;m unsigned int status; int argc; VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 2) return SS$_INSFARG;>* if (xnewctx == 0) return SS$_BADPARAM;A status = netlib___alloc_ctx(&newctx, sizeof(struct SPECCTX));I# if (!OK(status)) return status;y: status = sys$assign(&inetdevice, &newctx->chan, 0, 0);N if (!OK(status)) status = sys$assign(&backup_device, &newctx->chan, 0, 0); if (!OK(status)) { netlib___free_ctx(newctx);E return status; }r" if (argc > 6 && astadr != 0) { struct IOR *ior;,> GET_IOR(ior, ctx, iosb, astadr, (argc > 7) ? astprm : 0);1 ior->spec_userfrom = (sasize == 0) ? 0 : sa; 4 ior->spec_length = (sasize == 0) ? 0 : *sasize; ior->spec_retlen = salen;! ior->spec_xnewctx = xnewctx;) ior->spec_newctx = newctx; ' ior->iorflags = IOR_M_NEW_CONTEXT;t@ status = sys$qio(netlib_asynch_efn, newctx->chan, IO__OPEN,2 &ior->iosb, io_completion, ior,5 0, 0, ctx->specctx->local_port, 0,p' CMU_K_PROTO_TCP, 0);> } else {! struct NETLIBIOSBDEF myiosb; @ status = sys$qiow(netlib_synch_efn, newctx->chan, IO__OPEN,' &myiosb, 0, 0, 0, 0, D ctx->specctx->local_port, 0, CMU_K_PROTO_TCP, 0);; if (OK(status)) status = netlib___cvt_status(&myiosb);DA if (argc > 5 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb);u if (OK(status)) { *xnewctx = newctx;*2 if (argc > 3 && sa != 0 && sasize != 0) {: status = netlib_getpeername(&newctx, sa, sasize,9 (argc > 4) ? salen : 0, 0, 0, 0);t4 if (!OK(status)) sys$dassgn(newctx->chan); } } }g, if (!OK(status)) netlib___free_ctx(ctx); return status;} /* netlib_accept */  /***++** ROUTINE: netlib_setsockopt**** FUNCTIONAL DESCRIPTION:i**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.s**** COMPLETION CODES:O****** SIDE EFFECTS: None.****--*/2unsigned int netlib_setsockopt (struct CTX **xctx,= unsigned int *level, unsigned int *option, 5 void *value, unsigned int *vallen, . struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status, lev;a int argc;e VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 5) return SS$_INSFARG;>F if (option == 0 || value == 0 || vallen == 0) return SS$_BADPARAM;0 if (level == 0) lev = NETLIB_K_LEVEL_SOCKET; else lev = *level; if (argc > 5 && iosb != 0) {& iosb->iosb_w_status = SS$_NORMAL; iosb->iosb_w_count = 0; iosb->iosb_l_unused = 0;z },N* NETLIB_SRC.BCK?~n?[NETLIB]NETLIB_CMU.C;50XsOK if (argc > 6 && astadr != 0) sys$dclast(astadr, argc > 7 ? astprm : 0, 0); return SS$_NORMAL;} /* netlib_setsockopt */X /***++** ROUTINE: netlib_getsockopt**** FUNCTIONAL DESCRIPTION:E**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.o**** COMPLETION CODES:)****** SIDE EFFECTS: None.****--*/2unsigned int netlib_getsockopt (struct CTX **xctx,= unsigned int *level, unsigned int *option, 6 void *value, unsigned int *valsize,( unsigned int *vallen,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; unsigned int status, lev; int argc;P VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 5) return SS$_INSFARG;CG if (option == 0 || value == 0 || valsize == 0) return SS$_BADPARAM;x0 if (level == 0) lev = NETLIB_K_LEVEL_SOCKET; else lev = *level;- if (argc > 5 && vallen != 0) *vallen = 0; if (argc > 6 && iosb != 0) {& iosb->iosb_w_status = SS$_NORMAL; iosb->iosb_w_count = 0; iosb->iosb_l_unused = 0;x } N if (argc > 7 && astadr != 0) sys$dclast(astadr, argc > 8 ? astprm : 0, 0); return SS$_NORMAL;} /* netlib_getsockopt */; /***++#** ROUTINE: netlib_name_to_addresss**** FUNCTIONAL DESCRIPTION:(**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:O****** SIDE EFFECTS: None.****--*/Munsigned int netlib_name_to_address (struct CTX **xctx, unsigned int *whichp,h1 struct dsc$descriptor *namdsc,o. struct INADDRDEF *addrlist,? unsigned int *listsize, unsigned int *count,s. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; struct CMU_NtoA ntoa; struct INADDRDEF addr; struct NETLIBIOSBDEF myiosb; unsigned int status; unsigned short namlen; char *namp, nambuf[256]; int argc;c VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 5) return SS$_INSFARG;rK if (namdsc == 0 || addrlist == 0 || listsize == 0) return SS$_BADPARAM;>. if (OK(netlib_strtoaddr(namdsc, &addr))) { addrlist[0] = addr;, if (argc > 5 && count != 0) *count = 1;! if (argc > 6 && iosb != 0) {a* iosb->iosb_w_status = SS$_NORMAL; iosb->iosb_w_count = 1;! iosb->iosb_l_unused = 0;t }# if (argc > 7 && astadr != 0) {_? return sys$dclast(astadr, (argc > 8) ? astprm : 0, 0); } else {e return SS$_NORMAL;  } }s if (bypass_cmu_resolver()) {G return netlib___dns_name_to_addr(ctx, namdsc, addrlist, *listsize,a! (argc > 5) ? count : 0,t! (argc > 6) ? iosb : 0, " (argc > 7) ? astadr : 0,# (argc > 8) ? astprm : 0);C }U7 status = lib$analyze_sdesc(namdsc, &namlen, &namp);C# if (!OK(status)) return status;b= if (namlen > sizeof(nambuf)-1) namlen = sizeof(nambuf)-1;_! memcpy(nambuf, namp, namlen); nambuf[namlen] = '\0';" if (argc > 7 && astadr != 0) { struct IOR *ior;> GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0);? status = lib$get_vm(addr_info_size, &ior->spec_addr_info);T if (!OK(status)) { FREE_IOR(ior);. return status;S }" ior->spec_userbuf = addrlist;" ior->spec_length = *listsize; ior->spec_retlen = count;& ior->iorflags = IOR_M_COPY_ADDRS;H return sys$qio(netlib_asynch_efn, ctx->chan, IO__GTHST, &ior->iosb,& io_completion, ior,8 &ior->spec_addr_info, addr_info_size,7 CMU_K_GTHST_NAMEADDR, nambuf, 0, 0);i }uF status = sys$qiow(netlib_synch_efn, ctx->chan, IO__GTHST, &myiosb,) 0, 0, &ntoa, sizeof(ntoa),;3 CMU_K_GTHST_NAMEADDR, nambuf, 0, 0);s: if (OK(status)) status = netlib___cvt_status(&myiosb);@ if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); if (OK(status)) { int i;i? for (i = 0; i < *listsize && i < ntoa.ntoa_l_count; i++) {e+ addrlist[i] = ntoa.ntoa_x_addr[i];a }, if (argc > 5 && count != 0) *count = i; }w return status; } /* netlib_name_to_address */ c/***++#** ROUTINE: netlib_address_to_namep**** FUNCTIONAL DESCRIPTION:P**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.t**** COMPLETION CODES:c****** SIDE EFFECTS: None.****--*/Munsigned int netlib_address_to_name (struct CTX **xctx, unsigned int *whichp,{* struct INADDRDEF *addr,* unsigned int *addrsize,1 struct dsc$descriptor *namdsc,s* unsigned short *retlen,. struct NETLIBIOSBDEF *iosb,4 void (*astadr)(), void *astprm) { struct CTX *ctx; struct NETLIBIOSBDEF myiosb; struct CMU_AtoN aton;O unsigned int status; int argc;  VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 5) return SS$_INSFARG; if (bypass_cmu_resolver()) {C return netlib___dns_addr_to_name(ctx, addr, *addrsize, namdsc,b" (argc > 5) ? retlen : 0," (argc > 6) ? iosb : 0," (argc > 7) ? astadr : 0,# (argc > 8) ? astprm : 0);n }yG if (addr == 0 || addrsize == 0 || namdsc == 0) return SS$_BADPARAM;rC if (*addrsize != sizeof(struct INADDRDEF)) return SS$_BADPARAM; " if (argc > 7 && astadr != 0) { struct IOR *ior; > GET_IOR(ior, ctx, iosb, astadr, (argc > 8) ? astprm : 0);@ status = lib$get_vm(&name_info_size, &ior->spec_name_info); if (!OK(status)) {t FREE_IOR(ior);N return status;  } ior->spec_userbuf = namdsc;0 ior->spec_retlen = (unsigned int *) retlen;) ior->iorflags = IOR_M_COPY_HOSTNAME;:H return sys$qio(netlib_asynch_efn, ctx->chan, IO__GTHST, &ior->iosb,& io_completion, ior,7 ior->spec_name_info, name_info_size, D CMU_K_GTHST_ADDRNAME, addr->inaddr_l_addr, 0, 0); }iF status = sys$qiow(netlib_synch_efn, ctx->chan, IO__GTHST, &myiosb,) 0, 0, &aton, sizeof(aton), @ CMU_K_GTHST_ADDRNAME, addr->inaddr_l_addr, 0, 0);: if (OK(status)) status = netlib___cvt_status(&myiosb);@ if (argc > 6 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); if (OK(status)) {b@ str$copy_r(namdsc, &aton.aton_l_namelen, aton.aton_t_name);! if (argc > 5 && retlen != 0)s' *retlen = aton.aton_l_namelen;s }s return status;} /* netlib_address_to_name */ o/***++ ** ROUTINE: netlib_get_hostname**** FUNCTIONAL DESCRIPTION:&**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES:****** SIDE EFFECTS: None.****--*/Junsigned int netlib_get_hostname (void *bufdsc, unsigned short *retlenp) { char buf+ NETLIB_SRC.BCK?~n?[NETLIB]NETLIB_CMU.C;50XsZ[256]; ITMLST lnmlst[2];o unsigned int status; unsigned short retlen; int argc;e- static $DESCRIPTOR(tabnam, "LNM$SYSTEM");K5 static $DESCRIPTOR(lognam, "INTERNET_HOST_NAME");( SETARGCOUNT(argc);C ITMLST_INIT(lnmlst[0], LNM$_STRING, sizeof(buf), buf, &retlen);d' ITMLST_INIT(lnmlst[1], 0, 0, 0, 0);c8 status = sys$trnlnm(0, &tabnam, &lognam, 0, lnmlst);> if (OK(status)) status = str$copy_r(bufdsc, &retlen, buf);# if (!OK(status)) return status;;4 if (argc > 1 && retlenp != 0) *retlenp = retlen; return SS$_NORMAL;} /* netlib_get_hostname */I I/***++%** ROUTINE: netlib___get_nameserverse**** FUNCTIONAL DESCRIPTION: **** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None. **** COMPLETION CODES: ****** SIDE EFFECTS: None.****--*/+int netlib___get_nameservers (QUEUE *nsq) {0 struct NAMESERVER *ns; struct INADDRDEF a;s struct CTX *tmpctx; ) struct dsc$descriptor dsc, lognamdsc;t ITMLST lnmlst[4];c. char name[256], lognam[256], *cp, *anchor;& unsigned int status, size, maxidx; unsigned short namlen; int index, i, remain; static unsigned int one = 1;: static $DESCRIPTOR(nameserver_tabnam, "LNM$FILE_DEV"); tmpctx = 0;)A ITMLST_INIT(lnmlst[0], LNM$_INDEX, sizeof(index), &index, 0);nE ITMLST_INIT(lnmlst[1], LNM$_STRING, sizeof(name), name, &namlen);i' ITMLST_INIT(lnmlst[2], 0, 0, 0, 0);s% INIT_SDESC(lognamdsc, 0, lognam);-+ for (index = 0; index <= 16; index++) {&K lognamdsc.dsc$w_length = sprintf(lognam, "NETLIB_NAMESERVERS", index);iG status = sys$trnlnm(0, &nameserver_tabnam, &lognamdsc, 0, lnmlst);S. if (!OK(status) || namlen == 0) continue;5 for (anchor = name, remain = namlen; remain > 0;*8 remain -= i+1, anchor = cp+1) {* cp = memchr(anchor, ',', remain);! if (cp == 0) i = remain;E else i = cp - anchor;$ INIT_SDESC(dsc, i, anchor);/ if (!OK(netlib_strtoaddr(&dsc, &a))) {O if (tmpctx == 0) {> if (!OK(netlib_socket(&tmpctx, 0, 0))) continue; }G if (!OK(netlib_name_to_address(&tmpctx, 0, &dsc, &a, &one, 0,t( 0, 0, 0))) continue; }* size = sizeof(struct NAMESERVER);) status = lib$get_vm(&size, &ns); if (!OK(status)) break; ns->addr = a;% queue_insert(ns, nsq->tail); } }n+ if (tmpctx != 0) netlib_close(&tmpctx);u return index;p } /* netlib___get_nameservers */ B/***++ ** ROUTINE: netlib___get_domain**** FUNCTIONAL DESCRIPTION:t**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.i**** COMPLETION CODES:c****** SIDE EFFECTS: None.****--*/Uint netlib___get_domain (char *buf, unsigned short bufsize, unsigned short *retlen) {0 struct dsc$descriptor dsc; ITMLST lnmlst[2];E char name[256], *cp; unsigned int status; unsigned short namlen;3 static $DESCRIPTOR(lognamdsc, "NETLIB_DOMAIN"); / static $DESCRIPTOR(tabnam, "LNM$FILE_DEV");iE ITMLST_INIT(lnmlst[0], LNM$_STRING, sizeof(name), name, &namlen);r' ITMLST_INIT(lnmlst[1], 0, 0, 0, 0);t; status = sys$trnlnm(0, &tabnam, &lognamdsc, 0, lnmlst); if (OK(status)) cp = name; else {) INIT_SDESC(dsc, sizeof(name), name);g; if (!OK(netlib_get_hostname(&dsc, &namlen))) return 0;$ cp = memchr(name, '.', namlen); if (cp == 0) return 0;* cp += 1;N namlen -= (cp - name);F } / if (memchr(cp, '.', namlen) == 0) return 0;r/ if (namlen > bufsize-1) namlen = bufsize-1;n memcpy(buf, cp, namlen); *retlen = namlen; return 1;s} /* netlib___get_domain */t s/***++ ** ROUTINE: netlib___cvt_status**** FUNCTIONAL DESCRIPTION:e**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.t**** COMPLETION CODES:R****** SIDE EFFECTS: None.****--*/Fstatic unsigned int netlib___cvt_status (struct NETLIBIOSBDEF *iosb) { struct CMUIosb *cmuiosb;M if (iosb->iosb_w_status == SS$_CANCEL) iosb->iosb_w_status = SS$_TIMEOUT;gE if (iosb->iosb_w_status != SS$_ABORT) return iosb->iosb_w_status;v& cmuiosb = (struct CMUIosb *) iosb;" switch (cmuiosb->cmu_status) { case NET$_IR: case NET$_UCT:( case NET$_CSE:c case NET$_VTF: return SS$_INSFMEM; case NET$_IFC:i case NET$_IPC:  case NET$_IFS:= case NET$_ILP:f case NET$_NUC:! case NET$_CIP:r case NET$_CDE:  case NET$_FSU:S return SS$_BADPARAM;n case NET$_NOPRV:  case NET$_NOINA: case NET$_NOANA:R return SS$_NOPRIV;* case NET$_CC: case NET$_CR: case NET$_CCAN: case NET$_KILL: return SS$_LINKDISCON;I case NET$_UNN:  case NET$_UNA:e case NET$_UNU:N return SS$_IVADDR;F case NET$_BTS:* return SS$_IVBUFLEN;e case NET$_URC:, case NET$_NRT:, return SS$_UNREACHABLE; case NET$_CTO:a case NET$_TWT:  case NET$_FTO:l case NET$_NMLTO:F return SS$_TIMEOUT; case NET$_TE: case NET$_NSEXIT: return SS$_SHUT;T case NET$_DSNOADDR: case NET$_DSNONAME: case NET$_DSNAMERR: case NET$_DSREFEXC: return SS$_ENDOFFILE; case NET$_CREF: return SS$_REJECT;D default:t return SS$_ABORT; }o} /* netlib___cvt_status */O t/***++** ROUTINE: netlib___cvt_iosb**** FUNCTIONAL DESCRIPTION:n**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.f**** COMPLETION CODES:{****** SIDE EFFECTS: None.****--*/9static void netlib___cvt_iosb (struct NETLIBIOSBDEF *dst,e0 struct NETLIBIOSBDEF *src) {2 dst->iosb_w_status = netlib___cvt_status(src);* dst->iosb_w_count = src->iosb_w_count; dst->iosb_l_unused = 0; } /* netlib___cvt_iosb */s I/***++ ** ROUTINE: netlib_dns_mxlookup**** FUNCTIONAL DESCRIPTION:_**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.E**** COMPLETION CODES:s****** SIDE EFFECTS: None.****--*/4unsigned int netlib_dns_mx_lookup(struct CTX **xctx,B struct dsc$descriptor *namdsc, struct MXRRDEF *mxrr,> unsigned int *mxrrsize, unsigned int *mxrrcount,K struct NETLIBIOSBDEF *iosb, void (*astadr)(), void *astprm) {( struct CTX *ctx; struct IOR *ior; struct NETLIBIOSBDEF myiosb; struct CMU_RR rr_info; char *namp, nambuf[256]; unsigned short namlen; unsigned int status; int argc;  VERIFY_CTX(xctx, ctx); SETARGCOUNT(argc);% if (argc < 4) return SS$_INSFARG;fG if (namdsc == 0 || mxrr == 0 || mxrrsize == 0) return SS$_BADPARAM;i if (bypass_cmu_resolver()) {@ return netlib___dns_mx_look, NETLIB_SRC.BCK?~n?[NETLIB]NETLIB_CMU.C;50Xsiup(xctx, namdsc, mxrr, mxrrsize,< (argc > 4) ? mxrrcount : 0, (argc > 5) ? iosb : 0,< (argc > 6) ? astadr : 0, (argc > 7) ? astprm : 0); }P7 status = lib$analyze_sdesc(namdsc, &namlen, &namp);E# if (!OK(status)) return status;S= if (namlen > sizeof(nambuf)-2) namlen = sizeof(nambuf)-2;t! memcpy(nambuf, namp, namlen);s+ if (memchr(nambuf, '.', namlen) != 0) { 9 if (nambuf[namlen-1] != '.') nambuf[namlen++] = '.';  }  nambuf[namlen] = '\0'; " if (argc > 6 && astadr != 0) {> GET_IOR(ior, ctx, iosb, astadr, (argc > 6) ? astprm : 0);< status = lib$get_vm(&rr_info_size, &ior->spec_rr_info); if (!OK(status)) {( FREE_IOR(ior);A return status;  }! ior->spec_userbuf = mxrr;D" ior->spec_length = *mxrrsize;" ior->spec_retlen = mxrrcount;& ior->iorflags = IOR_M_COPY_MXRRS;H return sys$qio(netlib_asynch_efn, ctx->chan, IO__GTHST, &ior->iosb,5 io_completion, ior, ior->spec_rr_info,c rr_info_size,% CMU_K_GTHST_DNSLOOKUP,0 nambuf, NETLIB_K_DNS_TYPE_MX, 0); }F status = sys$qiow(netlib_synch_efn, ctx->chan, IO__GTHST, &myiosb,/ 0, 0, &rr_info, sizeof(rr_info),w% CMU_K_GTHST_DNSLOOKUP,*0 nambuf, NETLIB_K_DNS_TYPE_MX, 0);: if (OK(status)) status = netlib___cvt_status(&myiosb);@ if (argc > 5 && iosb != 0) netlib___cvt_iosb(iosb, &myiosb); if (OK(status)) {s unsigned int i, len; int remain; unsigned char *cp;i cp = rr_info.rr_x_data + 1;& remain = rr_info.rr_w_length - 1; i = 0; * while (remain > 0 && i < *mxrrsize) {. len = *(unsigned short *)cp; cp += 2;< mxrr[i].mxrr_l_preference = *(unsigned short *) cp;@ expand(mxrr[i].mxrr_t_name, NETLIB_S_MXRR_NAME, cp + 2,' &mxrr[i].mxrr_l_length);  remain -= len + 2;S cp += len;n i++;= }4 if (argc > 4 && mxrrcount != 0) *mxrrcount = i; }  return status;} /* netlib_dns_mx_lookup */ (/***++** ROUTINE: x**** FUNCTIONAL DESCRIPTION:&**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.8**** COMPLETION CODES:e****** SIDE EFFECTS: None.****--*/3static void expand (char *out, unsigned int maxlen,5 unsigned char *in, unsigned int *len) {U unsigned char *cp; char *cp1; unsigned int i; cp1 = out; cp = in; while ((cp1-out) < maxlen) { i = *cp++;S if (i == 0) break;I" if (cp1 != out) *cp1++ = '.';' if ((cp1-out) + i > maxlen) break;t memcpy(cp1, cp, i); cp1 += i; cp += i;c }  *len = (cp1 - out);$} /* expand */ /***++ ** ROUTINE: bypass_cmu_resolver**** FUNCTIONAL DESCRIPTION:n**** tbs**B** RETURNS: cond_value, longword (unsigned), write only, by value**** PROTOTYPE:**** tbs**** IMPLICIT INPUTS: None.**** IMPLICIT OUTPUTS: None.o**** COMPLETION CODES:d****** SIDE EFFECTS: None.****--*/'static int bypass_cmu_resolver (void) {! static unsigned int zero = 0; / static $DESCRIPTOR(tabnam, "LNM$FILE_DEV");O= static $DESCRIPTOR(lognam, "NETLIB_BYPASS_CMU_RESOLVER");(9 return OK(sys$trnlnm(0, &tabnam, &lognam, 0, &zero));P} /* bypass_cmu_resolver */tdd- NETLIB_SRC.BCK=0n?ETLIB]NETLIB_VECTOR.MAR;3D*[NETLIB]NETLIB_VECTOR.MAR;3+,=0./ @ 4D\-n?0123KPWO56 ĵq7 @еq849|"9V$ǘG @HJ  .TITLE NETLIB_VECTOR .IDENT /V2.0/;; FACILITY: NETLIB;D; ABSTRACT: This module defines the transfer vectors for the NETLIB0; common network routines library.;; AUTHOR: M. Madison;; MODIFICATION HISTORY:;0; 28-JAN-1991 V1.0 Madison Initial coding.;; 04-DEC-1991 V1.1 Madison Add NET_SET_TRACE_ROUTINE.2; 24-OCT-1994 V2.0 Madison All new for V2.0.; .DISABLE GLOBAL;,; Macro to generate a transfer vector entry.; .MACRO ROUTINE NAME .EXTRN NAME .ALIGN QUAD .TRANSFER NAME .MASK NAME JMP NAME+2 .ENDM; .PSECT $$NETLIB_VECTOR -, PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT,QUAD;,; Old routines - for compatibility with V1; ROUTINE NET_ASSIGN ROUTINE NET_BIND ROUTINE NET_DEASSIGN ROUTINE NET_GET_ADDRESS ROUTINE NET_ADDR_TO_NAME ROUTINE NET_GET_INFO ROUTINE NET_GET_HOSTNAME; ROUTINE TCP_CONNECT ROUTINE TCP_CONNECT_ADDR ROUTINE TCP_DISCONNECT ROUTINE TCP_ACCEPT ROUTINE TCP_SEND ROUTINE TCP_RECEIVE ROUTINE TCP_GET_LINE; ROUTINE UDP_SEND ROUTINE UDP_RECEIVE ROUTINE DNS_MXLOOK ROUTINE NET_SET_TRACE_ROUTINE;; New, Improved Routines !; ROUTINE NETLIB_SOCKET ROUTINE NETLIB_SERVER_SETUP ROUTINE NETLIB_BIND ROUTINE NETLIB_GETSOCKNAME ROUTINE NETLIB_GETPEERNAME ROUTINE NETLIB_CONNECT ROUTINE NETLIB_WRITE ROUTINE NETLIB_WRITELINE ROUTINE NETLIB_READ ROUTINE NETLIB_READLINE ROUTINE NETLIB_SHUTDOWN ROUTINE NETLIB_CLOSE ROUTINE NETLIB_LISTEN ROUTINE NETLIB_ACCEPT ROUTINE NETLIB_GET_HOSTNAME ROUTINE NETLIB_SETSOCKOPT ROUTINE NETLIB_GETSOCKOPT# ROUTINE NETLIB_NAME_TO_ADDRESS# ROUTINE NETLIB_ADDRESS_TO_NAME ROUTINE NETLIB_DNS_QUERY ROUTINE NETLIB_DNS_SKIPNAME" ROUTINE NETLIB_DNS_EXPANDNAME ROUTINE NETLIB_STRTOADDR ROUTINE NETLIB_ADDRTOSTR# ROUTINE NETLIB_CONNECT_BY_NAME! ROUTINE NETLIB_DNS_MX_LOOKUP ROUTINE NETLIB_HTON_LONG ROUTINE NETLIB_NTOH_LONG ROUTINE NETLIB_HTON_WORD ROUTINE NETLIB_NTOH_WORD; .END. NETLIB_SRC.BCK 0n?[NETLIB]NETLIB_SHRXFR.MAR;11C *[NETLIB]NETLIB_SHRXFR.MAR;11+, 0. / @ 4C 0-n?0123KPWO 56|4?s7X4?s8TgŖ|"9V$ǘG @HJ  .TITLE NETLIB_SHRXFR .IDENT /V2.0/;; FACILITY: NETLIB;; ABSTRACT: tbs;; AUTHOR: M. Madison;; MODIFICATION HISTORY:;2; 24-OCT-1994 V2.0 Madison All new for V2.0.;0 .NTYPE R22TYPE,R22 ; get symbol type for "R22"0R22TYPE = -5 ; type 5 = register .IF EQ,R22TYPEEVAX = 1 BIGPAGE = 1ADDRESSBITS = 32 .ENDC .DISABLE GLOBAL .EXTRN LIB$FIND_IMAGE_SYMBOL4 .PSECT $$$COPYRIGHT,SHR,NOEXE,RD,NOWRT,PIC,GBL,QUADC .ASCII /Copyright 1994, MadGoat Software. All Rights Reserved./1 .PSECT DATAPSECT,NOSHR,NOEXE,RD,WRT,PIC,GBL,QUADIMGNAM: .ASCID /NETLIB_SHR// .PSECT CODEPSECT,SHR,EXE,RD,NOWRT,PIC,GBL,QUAD;,; Macro to generate a transfer vector entry.; .MACRO ROUTINE NAME .PSECT DATAPSECT .ALIGN LONG NAME'_PTR: .LONG 0 NAME'_STR: .ASCID /NAME/ .PSECT CODEPSECT .IF DF,EVAX-NAME:: .CALL_ENTRY MAX_ARGS=14,HOME_ARGS=TRUE .IFF .ENTRY NAME,^M<> .ENDC TSTL NAME'_PTR BNEQ 5$ PUSHAL NAME'_PTR PUSHAQ NAME'_STR PUSHAQ IMGNAM! CALLS #3,G^LIB$FIND_IMAGE_SYMBOL BLBC R0,10$5$: CALLG (AP),@NAME'_PTR10$: RET .ENDM;,; Old routines - for compatibility with V1; ROUTINE NET_ASSIGN ROUTINE NET_BIND ROUTINE NET_DEASSIGN ROUTINE NET_GET_ADDRESS ROUTINE NET_ADDR_TO_NAME ROUTINE NET_GET_INFO ROUTINE NET_GET_HOSTNAME; ROUTINE TCP_CONNECT ROUTINE TCP_CONNECT_ADDR ROUTINE TCP_DISCONNECT ROUTINE TCP_ACCEPT ROUTINE TCP_SEND ROUTINE TCP_RECEIVE ROUTINE TCP_GET_LINE; ROUTINE UDP_SEND ROUTINE UDP_RECEIVE ROUTINE DNS_MXLOOK ROUTINE NET_SET_TRACE_ROUTINE;; New, Improved Routines !; ROUTINE NETLIB_SOCKET ROUTINE NETLIB_SERVER_SETUP ROUTINE NETLIB_BIND ROUTINE NETLIB_GETSOCKNAME ROUTINE NETLIB_GETPEERNAME ROUTINE NETLIB_CONNECT ROUTINE NETLIB_WRITE ROUTINE NETLIB_WRITELINE ROUTINE NETLIB_READ ROUTINE NETLIB_READLINE ROUTINE NETLIB_SHUTDOWN ROUTINE NETLIB_CLOSE ROUTINE NETLIB_LISTEN ROUTINE NETLIB_ACCEPT ROUTINE NETLIB_GET_HOSTNAME ROUTINE NETLIB_SETSOCKOPT ROUTINE NETLIB_GETSOCKOPT# ROUTINE NETLIB_NAME_TO_ADDRESS# ROUTINE NETLIB_ADDRESS_TO_NAME ROUTINE NETLIB_DNS_QUERY ROUTINE NETLIB_DNS_SKIPNAME" ROUTINE NETLIB_DNS_EXPANDNAME ROUTINE NETLIB_STRTOADDR ROUTINE NETLIB_ADDRTOSTR# ROUTINE NETLIB_CONNECT_BY_NAME! ROUTINE NETLIB_DNS_MX_LOOKUP ROUTINE NETLIB_HTON_LONG ROUTINE NETLIB_NTOH_LONG ROUTINE NETLIB_HTON_WORD ROUTINE NETLIB_NTOH_WORD .END/ NETLIB_SRC.BCKŖ#n?[NETLIB]NETLIB_SRI.H;69d*[NETLIB]NETLIB_SRI.H;6+,Ŗ#./ @ 49-n?0123KPWO56ބny7޹ny8Tݖ|"9V$ǘG @HJ#ifndef __NETLIB_SRI_H__#define __NETLIB_SRI_H__#ifndef __NETLIB_BUILD__#define __NETLIB_BUILD__#endif#include "netlibdef.h"#include ##define IOR_M_COPY_LENGTH (1<<16)##define IOR_M_COPY_FROM (1<<17)##define IOR_M_NEW_CONTEXT (1<<18)##define IOR_M_COPY_FROM2 (1<<19)$#define IOR_M_CHECK_LENGTH (1<<20)(#define spec_retlen arg[0].address)#define spec_length arg[1].longword)#define spec_userfrom arg[2].address+#define spec_newctx arg[3].address(#define spec_xnewctx arg[4].address#define __SPECCTX void#define SPECCTX_SIZE 0 struct SPECIOR { struct { unsigned short length; struct SINDEF address; } from; struct { unsigned int length; struct SINDEF address; } from2; }; #define __SPECIOR struct SPECIOR#define IO$S_FCODE 6 #define IO$_SEND (IO$_WRITEVBLK)"#define IO$_RECEIVE (IO$_READVBLK)3#define IO$_SOCKET (IO$_ACCESS | (0 << IO$S_FCODE))1#define IO$_BIND (IO$_ACCESS | (1 << IO$S_FCODE))3#define IO$_LISTEN (IO$_ACCESS | (2 << IO$S_FCODE))3#define IO$_ACCEPT (IO$_ACCESS | (3 << IO$S_FCODE))4#define IO$_CONNECT (IO$_ACCESS | (4 << IO$S_FCODE))7#define IO$_SETSOCKOPT (IO$_ACCESS | (5 << IO$S_FCODE))7#define IO$_GETSOCKOPT (IO$_ACCESS | (6 << IO$S_FCODE))2#define IO$_IOCTL (IO$_ACCESS | (8 << IO$S_FCODE))9#define IO$_ACCEPT_WAIT (IO$_ACCESS | (10 << IO$S_FCODE))9#define IO$_NETWORK_PTY (IO$_ACCESS | (11 << IO$S_FCODE))6#define IO$_SHUTDOWN (IO$_ACCESS | (12 << IO$S_FCODE))9#define IO$_GETSOCKNAME (IO$_ACCESS | (13 << IO$S_FCODE))9#define IO$_GETPEERNAME (IO$_ACCESS | (15 << IO$S_FCODE))4#define IO$_SELECT (IO$_ACCESS | (17 << IO$S_FCODE))#endif /* __NETLIB_SRI_H__ */0 NETLIB_SRC.BCK n?ETLIB]NETLIB_MULTINET.H;2@i*[NETLIB]NETLIB_MULTINET.H;2+, ./ @ 4@T-n?0123KPWO56$uPl7uPl8v|"9V$ǘG @HJ#ifndef __NETLIB_MULTINET_H__#define __NETLIB_MULTINET_H__/*** NETLIB_MULTINET.H**;** MultiNet-specific definitions for NETLIB_SRI_SUPPORT.C.**** 25-OCT-1994*/@ static char *socket_library[] = {"MULTINET_SOCKET_LIBRARY"};@ static char *nameserver_lognam[] = {"MULTINET_NAMESERVERS"};5 static char *gethostname_ent[] = {"GETHOSTNAME"};; static char *_gethostbyname_ent[] = {"_GETHOSTBYNAME"};; static char *_gethostbyaddr_ent[] = {"_GETHOSTBYADDR"};< static char *domain_lognam[] = {"MULTINET_LOCALDOMAIN"};"#endif /* __NETLIB_MULTINET_H__ */1 NETLIB_SRC.BCKrNn?[NETLIB]NETLIB_TCPWARE.H;3TY*[NETLIB]NETLIB_TCPWARE.H;3+,rN./ @ 4T-n?0123KPWO56 =or7P$=or8|"9V$ǘG @HJ#ifndef __NETLIB_TCPWARE_H__#define __NETLIB_TCPWARE_H__/*** NETLIB_TCPWARE.H**:** TCPware-specific definitions for NETLIB_SRI_SUPPORT.C.**** 25-OCT-1994*/M static char *socket_library[] = {"TCPWARE_SOCKLIB_SHR", "TCPIP_SOCKLIB"};T static char *nameserver_lognam[] = {"TCPWARE_NAMESERVERS", "TCPIP_NAMESERVERS"};L static char *gethostname_ent[] = {"TCPWARE_GETHOSTNAME", "GETHOSTNAME"};S static char *_gethostbyname_ent[] = {"TCPWARE_GETHOSTBYNAME", "GETHOSTBYADDR"};S static char *_gethostbyaddr_ent[] = {"TCPWARE_GETHOSTBYADDR", "GETHOSTBYNAME"};P static char *domain_lognam[] = {"TCPWARE_LOCALDOMAIN", "TCPIP_LOCALDOMAIN"};!#endif /* __NETLIB_TCPWARE_H__ */2 NETLIB_SRC.BCKn?[NETLIB]NETLIB_PATHWAY.H;3<e*[NETLIB]NETLIB_PATHWAY.H;3+,./ @ 4<4-n?0123KPWO56E+89V$ǘG @HJ#ifndef __NETLIB_UCX_H__#define __NETLIB_UCX_H__#ifndef __NETLIB_BUILD__#define __NETLIB_BUILD__#endif#include "netlibdef.h"#include #include typedef struct item_list_2 {# unsigned short bufsiz, itmcod; void *bufadr; } ITMLST2;'#define ITMLST2_INIT(_i, _c, _s, _a) {\: _i.bufsiz = (_s); _i.itmcod = (_c); _i.bufadr = (_a);}(#define spec_retlen arg[0].address%#define spec_length arg[1].word)#define spec_userfrom arg[2].address+#define spec_newctx arg[3].address(#define spec_xnewctx arg[4].address(#define spec_hostent arg[4].address*#define spec_useralist arg[5].address(#define spec_usrdsc arg[5].address##define IOR_M_COPY_LENGTH (1<<16)##define IOR_M_COPY_FROM (1<<17)##define IOR_M_NEW_CONTEXT (1<<18)##define IOR_M_COPY_ADDRS (1<<19)##define IOR_M_COPY_HOSTNAME (1<<20)#define __SPECCTX void#define SPECCTX_SIZE 0 struct SPECIOR { unsigned short fromlen; unsigned int subfunction; struct SINDEF from; ITMLST2 sockopt; struct {' unsigned short bufsiz, itmcod; void *bufadr, *retlen; } sockopt_get; }; #define __SPECIOR struct SPECIOR struct HOSTENT { unsigned int name_offset;$ unsigned int alias_list_offset; unsigned int addrtype; unsigned int addrlen;" unsigned int addrlist_offset; unsigned char buffer[492]; };#endif /* __NETLIB_UCX_H__ */4 NETLIB_SRC.BCKqn?[NETLIB]NETLIB_CMU.H;13.y{*[NETLIB]NETLIB_CMU.H;13+,q./ @ 4. v-n?0123KPWO56D/7>80/9V$ǘG @HJ#ifndef __NETLIB_CMU_H__#define __NETLIB_CMU_H__#ifndef __NETLIB_BUILD__#define __NETLIB_BUILD__#endif#include "netlibdef.h"#include #define IO__OPEN IO$_CREATE#define IO__CLOSE IO$_DELETE"#define IO__STATUS IO$_ACPCONTROL#define IO__INFO IO$_MODIFY #define IO__GTHST IO$_SKIPFILE #define CMU_K_GTHST_LOCAL_HOST 0#define CMU_K_GTHST_NAMEADDR 1#define CMU_K_GTHST_ADDRNAME 2#define CMU_K_GTHST_DNSLOOKUP 3#define CMU_M_OPEN_ACTIVE 1#define CMU_M_OPEN_UDPDATA 1#define CMU_M_OPEN_NOWAIT 2#define CMU_M_OPEN_BYADDRESS 4#define CMU_K_PROTO_TCP 0#define CMU_K_PROTO_UDP 1 struct CMU_ConnInfo {$ unsigned char ci_b_remote_host;# unsigned char ci_b_local_host;! char ci_t_foreign_host[128]; unsigned short ci_w_fill1;# unsigned int ci_l_remote_port; char ci_t_local_host[128];" unsigned int ci_l_local_port;) struct INADDRDEF ci_x_local_address;* struct INADDRDEF ci_x_remote_address; }; struct CMU_IPAddr {$ struct INADDRDEF ipa_x_srcaddr;$ struct INADDRDEF ipa_x_dstaddr;" unsigned short ipa_w_srcport;" unsigned short ipa_w_dstport; unsigned int ipa_l_fill1; }; struct CMU_NtoA { unsigned int ntoa_l_count;& struct INADDRDEF ntoa_x_addr[20];! unsigned int ntoa_l_namelen; char ntoa_t_name[128]; }; struct CMU_AtoN {! unsigned int aton_l_namelen; char aton_t_name[128]; }; struct CMU_RR { unsigned short rr_w_length;" unsigned char rr_x_data[512]; }; struct CMUIosb { unsigned short status; unsigned short count; unsigned long cmu_status; }; #define __SPECCTX struct SPECCTX struct SPECCTX { unsigned int socket_type;, unsigned short local_port, remote_port;. struct INADDRDEF local_addr, remote_addr; };(#define spec_retlen arg[0].address%#define spec_length arg[1].word)#define spec_userfrom arg[2].address+#define spec_newctx arg[3].address(#define spec_xnewctx arg[4].address(#define spec_userbuf arg[5].address*#define spec_addr_info arg[6].address*#define spec_name_info arg[6].address(#define spec_rr_info arg[6].address*#define spec_conn_info arg[6].address*#define spec_usersize arg[7].longword##define IOR_M_COPY_LENGTH (1<<16)##define IOR_M_COPY_FROM (1<<17)##define IOR_M_NEW_CONTEXT (1<<18)##define IOR_M_COPY_ADDRS (1<<19)##define IOR_M_COPY_HOSTNAME (1<<20)$#define IOR_M_COPY_CI_REMOTE (1<<21)##define IOR_M_COPY_CI_LOCAL (1<<22)##define IOR_M_COPY_MXRRS (1<<23) struct SPECIOR { unsigned short fromlen; struct CMU_IPAddr from; struct CMU_NtoA addr_info; }; #define __SPECIOR struct SPECIOR#define NET$_IR 0X0863800A#define NET$_IFC 0X08638012#define NET$_IPC 0X0863801A#define NET$_UCT 0X08638022#define NET$_IFS 0X0863802A#define NET$_ILP 0X08638032#define NET$_NUC 0X0863803A#define NET$_CSE 0X08638042#define NET$_NOPRV 0X0863804A#define NET$_CIP 0X08638052#define NET$_CDE 0X0863805A#define NET$_CR 0X08638062#define NET$_FSU 0X0863806A#define NET$_UNN 0X08638072#define NET$_VTF 0X0863807A#define NET$_CREF 0X08638082#define NET$_CCAN 0X0863808A#define NET$_FIP 0X08638092#define NET$_BTS 0X0863809A#define NET$_IHI 0X086380A2#define NET$_BDI 0X086380AA#define NET$_EPD 0X086380B2#define NET$_URC 0X086380BA#define NET$_IGF 0X086380C2#define NET$_UNA 0X086380CA#define NET$_UNU 0X086380D2#define NET$_CC 0X086380DA#define NET$_CTO 0X086380E2#define NET$_TWT 0X086380EA#define NET$_TE 0X086380F2#define NET$_FTO 0X086380FA#define NET$_NYI 0X08638102#define NET$_NOPN 0X0863810A#define NET$_NOINA 0X08638112#define NET$_NOANA 0X0863811A#define NET$_NOADR 0X08638122#define NET$_GTHFUL 0X0863812A#define NET$_DAE 0X08638132#define NET$_NMLTO 0X0863813A#define NET$_NSEXIT 0X08638142#define NET$_NONS 0X0863814A#define NET$_NSQFULL 0X08638152#define NET$_DSDOWN 0X0863815A#define NET$_DSNODS 0X08638162 #define NET$_DSINCOMP 0X0863816A #define NET$_DSNOADDR 0X08638172 #define NET$_DSNONAME 0X0863817A #define NET$_DSFMTERR 0X08638182 #define NET$_DSSRVERR 0X0863818A #define NET$_DSNAMERR 0X08638192 #define NET$_DSNOTIMP 0X0863819A #define NET$_DSREFUSD 0X086381A2 #define NET$_DSNONSRV 0X086381AA #define NET$_DSUNKERR 0X086381B2 #define NET$_DSREFEXC 0X086381BA #define NET$_GREENERR 0X086381C2!#define NET$_GP_INVREQ 0X086381CA!#define NET$_GP_INVINF 0X086381D2!#define NET$_GP_INVNAM 0X086381DA!#define NET$_GP_INVADR 0X086381E2!#define NET$_GP_INVMBX 0X086381EA!#define NET$_GP_INVCLS 0X086381F2!#define NET$_GP_RSBUSY 0X086381FA!#define NET$_GP_NONMSR 0X08638202!#define NET$_GP_NOHINF 0X0863820A!#define NET$_GP_NOTFND 0X08638212!#define NET$_GP_UNKMBX 0X0863821A!#define NET$_GP_NOTIMP 0X08638222!#define NET$_GP_TOOBIG 0X0863822A!#define NET$_GP_NSDOWN 0X08638232#define NET$_NRT 0X0863823A#define NET$_KILL 0X08638242#endif /* __NETLIB_CMU_H__ */5 NETLIB_SRC.BCK^Zn?[NETLIB]NETLIB.H;30Yp*[NETLIB]NETLIB.H;30+,^Z./ @ 4Y -n?0123KPWO56LNz7>ZNz84 `/9V$ǘG @HJ#ifndef NETLIB_H_LOADED#define NETLIB_H_LOADED/* ** NETLIB.H**"** Main #include file for NETLIB.**=** COPYRIGHT 1993, MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** MODIFICATION HISTORY:**0** 29-Sep-1993 Madison Initial commenting.*/#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __DECC#include #else#pragma builtins#endif#ifndef __NETLIB_BUILD__#define __NETLIB_BUILD__#endif#include "netlibdef.h"#ifdef __ALPHA#pragma member_alignment save#pragma nomember_alignment#endif,typedef struct { void *head, *tail; } QUEUE;3typedef struct { unsigned int long1, long2; } TIME;&typedef struct dsc$descriptor DESCRIP;Ptypedef struct { unsigned short bufsiz, itmcod; void *bufadr, *retlen; } ITMLST;#ifdef __ALPHA #pragma member_alignment restore#endif/*** Handy macros*/$#define OK(s) $VMS_STATUS_SUCCESS(s)U#define INIT_DYNDSCPTR(str) {str->dsc$w_length = 0; str->dsc$a_pointer = (void *) 0;\M str->dsc$b_class = DSC$K_CLASS_D; str->dsc$b_dtype = DSC$K_DTYPE_T;}Q#define INIT_DYNDESC(str) {str.dsc$w_length = 0; str.dsc$a_pointer = (void *) 0;\K str.dsc$b_class = DSC$K_CLASS_D; str.dsc$b_dtype = DSC$K_DTYPE_T;}Y#define INIT_SDESC(str,len,ptr) {str.dsc$w_length=(len);str.dsc$a_pointer=(void *)(ptr);\G str.dsc$b_class=DSC$K_CLASS_S; str.dsc$b_dtype=DSC$K_DTYPE_T;}B#define ITMLST_INIT(itm,c,s,a,r) {itm.bufsiz=(s); itm.itmcod=(c);\) itm.bufadr=(a); itm.retlen=(r);}5#define INIT_QUEUE(que) {que.head = que.tail = &que;}"#define SETARGCOUNT(x) va_count(x)D#define VERIFY_CTX(x,c) {if ((x) == 0) return SS$_BADPARAM; c = *x;}H#define GET_IOR(x, _ctx, _iosb, _astadr, _astprm) {unsigned int status;\* status = netlib___alloc_ior(&x);\< if (!OK(status)) return status; (x)->ctx = (_ctx);\K (x)->iosbp=(_iosb); (x)->astadr=(_astadr); (x)->astprm=(_astprm);})#define FREE_IOR(x) netlib___free_ior(x);K#define GET_DNSREQ(x, _ctx, _iosb, _astadr, _astprm) {unsigned int status;\- status = netlib___alloc_dnsreq(&x);\) if (!OK(status)) return status;\3 status = netlib___alloc_ior(&((x)->ior));\D if (!OK(status)) {netlib___free_dnsreq(x); return status;}\! (x)->ior->ctx = (_ctx);\> (x)->ior->iosbp=(_iosb); (x)->ior->astadr=(_astadr);\% (x)->ior->astprm=(_astprm);}O#define FREE_DNSREQ(x) {netlib___free_ior(((x)->ior));netlib___free_dnsreq(x);}#ifdef __ALPHAL#define queue_insert(item,pred) __PAL_INSQUEL((void *)(pred),(void *)(item))?#define queue_remove(entry,addr) (((QUEUE *)(entry))->head == \K (QUEUE *) (entry) ? 0:(__PAL_REMQUEL((void *)(entry),(void *)(addr)),1))#else2#define queue_insert(item,pred) _INSQUE(item,pred)H#define queue_remove(entry,addr) (((QUEUE *)entry)->head == entry ? 0 :\+ (_REMQUE(entry,addr),1))#endif/*** Generic context structure*/#ifndef __SPECCTX#define __SPECCTX void#endif struct NAMESERVER {& struct NAMESERVER *flink, *blink; struct INADDRDEF addr; }; struct DOMAIN {" struct DOMAIN *flink, *blink; int length; char name[1]; }; struct DNSCTX { QUEUE nsq; QUEUE domq; TIME timeout; int retry_count; unsigned int flags; unsigned short queryid; };#define CTX_S_LINEBUF 32768 struct CTX { struct CTX *flink, *blink; TIME exptime; unsigned int flags;*#define CTX_M_USER_SET_REUSEADDR (1<<0)'#define CTX_M_LINE_FOUND_CR (1<<1)$#define CTX_M_NO_DNS (1<<2) unsigned short chan; __SPECCTX *specctx; unsigned int specctx_size;4 unsigned char *linebuf, *linebufp, *lineanchor;% struct dsc$descriptor *line_dsc;! unsigned short *line_retlen; unsigned int line_flags; int line_remain; TIME *line_tmo; struct DNSCTX *dnsctx; };#define SPECIOR_SPACE 64#ifndef __SPECIOR#define __SPECIOR void *#endif#pragma nostandard struct IOR { struct IOR *flink, *blink; struct NETLIBIOSBDEF iosb; TIME timeout; struct CTX *ctx;! struct NETLIBIOSBDEF *iosbp; unsigned int iorflags;'#define IOR_M_IO_COMPLETED (1<<0)&#define IOR_M_IO_TIMED (1<<1) void (*astadr)(); void *astprm; union { void *address; unsigned int longword; unsigned short word; } arg[8]; variant_union {4 unsigned char specior_space[SPECIOR_SPACE]; __SPECIOR specior; } specior_overlay; };#pragma standard struct DNSREQ {" struct DNSREQ *flink, *blink; struct IOR *ior; struct CTX *ctx; struct NAMESERVER *curns; struct DOMAIN *curdom; char *query_name;! unsigned short query_namlen; unsigned int query_flags; unsigned char *query_rbuf;! unsigned int query_rbufsize; unsigned int query_class; unsigned int query_type;# unsigned int buflen, replylen; int retries; struct SINDEF sin; struct SINDEF rsin; unsigned char buf[1024]; };#ifndef __NETLIB_MODULE_MEM__#pragma nostandard, globalref unsigned int netlib_synch_efn;- globalref unsigned int netlib_asynch_efn;#pragma standardA unsigned int netlib___alloc_ctx(struct CTX **, unsigned int);1 unsigned int netlib___free_ctx(struct CTX *);3 unsigned int netlib___alloc_ior(struct IOR **);1 unsigned int netlib___free_ior(struct IOR *);9 unsigned int netlib___alloc_dnsreq(struct DNSREQ **);7 unsigned int netlib___free_dnsreq(struct DNSREQ *);#endif#endif /* NETLIB_H_LOADED */6 NETLIB_SRC.BCKSn?[NETLIB]NETLIBDEF.H;14\*[NETLIB]NETLIBDEF.H;14+,S./ @ 4\n-n?0123KPWO566$y7T.8y8T6S`/9V$ǘG @HJ/*** NETLIBDEF.H**-** Definitions for use with NETLIB routines.**=** COPYRIGHT 1993, MADGOAT SOFTWARE. ALL RIGHTS RESERVED.**** MODIFICATION HISTORY:**,** 29-Sep-1993 Madison Initial coding.*/#ifndef __NETLIBDEF_H_LOADED__#define __NETLIBDEF_H_LOADED__##define NETLIB_K_TYPE_STREAM 1##define NETLIB_K_TYPE_DGRAM 2(#define NETLIB_K_OPTION_REUSEADDR 0x04(#define NETLIB_K_OPTION_KEEPALIVE 0x08(#define NETLIB_K_OPTION_BROADCAST 0x20)#define NETLIB_K_OPTION_SNDBUF 0x1001)#define NETLIB_K_OPTION_RCVBUF 0x1002*#define NETLIB_K_OPTION_SNDLOWAT 0x1003*#define NETLIB_K_OPTION_RCVLOWAT 0x1004(#define NETLIB_K_LEVEL_SOCKET 0xffff##define NETLIB_K_AF_INET 2##define NETLIB_K_LOOKUP_DNS 1&#define NETLIB_K_LOOKUP_HOST_TABLE 2&#define NETLIB_K_SHUTDOWN_RECEIVER 0&#define NETLIB_K_SHUTDOWN_SENDER 1%#define NETLIB_K_SHUTDOWN_BOTH 2'#define NETLIB_M_ALLOW_LF (1<<0))#define NETLIB_M_DOMAIN_SEARCH (1<<0)(#define NETLIB_M_NO_RECURSION (1<<1)##define NETLIB_K_DNS_TYPE_A 0x01##define NETLIB_K_DNS_TYPE_NS 0x02##define NETLIB_K_DNS_TYPE_MD 0x03##define NETLIB_K_DNS_TYPE_MF 0x04&#define NETLIB_K_DNS_TYPE_CNAME 0x05$#define NETLIB_K_DNS_TYPE_SOA 0x06##define NETLIB_K_DNS_TYPE_MB 0x07##define NETLIB_K_DNS_TYPE_MG 0x08##define NETLIB_K_DNS_TYPE_MR 0x09%#define NETLIB_K_DNS_TYPE_NULL 0x0A$#define NETLIB_K_DNS_TYPE_WKS 0x0B$#define NETLIB_K_DNS_TYPE_PTR 0x0C&#define NETLIB_K_DNS_TYPE_HINFO 0x0D&#define NETLIB_K_DNS_TYPE_MINFO 0x0E##define NETLIB_K_DNS_TYPE_MX 0x0F$#define NETLIB_K_DNS_TYPE_TXT 0x10)#define NETLIB_K_DNS_QTYPE_ALL 0xFF$#define NETLIB_K_DNS_CLASS_IN 0x01$#define NETLIB_K_DNS_CLASS_CS 0x02$#define NETLIB_K_DNS_CLASS_CH 0x03$#define NETLIB_K_DNS_CLASS_HS 0x04&#define NETLIB_K_DNS_QCLASS_ALL 0xFF #define NETLIB_K_DNS_OP_STDQ 0 #define NETLIB_K_DNS_OP_INVQ 1"#define NETLIB_K_DNS_OP_STATUS 2##define NETLIB_K_DNS_RC_SUCCESS 0"#define NETLIB_K_DNS_RC_FMTERR 1##define NETLIB_K_DNS_RC_SRVFAIL 2"#define NETLIB_K_DNS_RC_NAMERR 3"#define NETLIB_K_DNS_RC_NOTIMP 4"#define NETLIB_K_DNS_RC_REFUSE 5#ifdef __ALPHA#pragma member_alignment save#pragma nomember_alignment#endif#pragma nostandard struct NETLIB_DNS_HEADER {" unsigned short dns_w_queryid; variant_union {$ unsigned short dns_w_flags; variant_struct {6 unsigned int dns_v_recursion_desired : 1;/ unsigned int dns_v_truncated : 1;/ unsigned int dns_v_authoritative : 1;- unsigned int dns_v_opcode : 4;, unsigned int dns_v_reply : 1;/ unsigned int dns_v_reply_code : 4;/ unsigned int dns_v_xx_unsused_xx : 3;6 unsigned int dns_v_recursion_available : 1; } dns_x_flags; } dns_r_flags_overlay;" unsigned short dns_w_qdcount;" unsigned short dns_w_ancount;" unsigned short dns_w_nscount;" unsigned short dns_w_arcount; };#pragma standard struct SOCKADDRDEF {& unsigned short sockaddr_w_family;( unsigned char sockaddr_x_data[14]; }; struct INADDRDEF {! unsigned long inaddr_l_addr; }; struct SINDEF {! unsigned short sin_w_family; unsigned short sin_w_port;! struct INADDRDEF sin_x_addr; unsigned char sin_x_mbz[8]; }; struct NETLIBIOSBDEF {" unsigned short iosb_w_status;! unsigned short iosb_w_count;" unsigned long iosb_l_unused; };#define NETLIB_S_MXRR_NAME 128 struct MXRRDEF {$ unsigned int mxrr_l_preference; unsigned int mxrr_l_length;/ char mxrr_t_name[NETLIB_S_MXRR_NAME]; };#ifdef __ALPHA #pragma member_alignment restore#endif>#define netlib_word_swap(x) ((((x)>>8)&0xff)|(((x)&0xff)<<8 ))\#define netlib_long_swap(x) ((((x)>>24)&0xff)|(((x)>>8)&0xff00)|(((x)&0xff00)<<8)|((x)<<24))#ifndef __NETLIB_BUILD__#ifdef __cplusplus extern "C" {#endif3 unsigned int netlib_socket(void **socket, ...);S unsigned int netlib_server_setup(void **socket, void *sa, unsigned int *salen);P unsigned int netlib_bind(void **socket, void *sa, unsigned int *salen, ...);< unsigned int netlib_getsockname(void **socket, void *sa,> unsigned int *sasize, unsigned int *salen, ...);< unsigned int netlib_getpeername(void **socket, void *sa,> unsigned int *sasize, unsigned int *salen, ...);S unsigned int netlib_connect(void **socket, void *sa, unsigned int *salen, ...);@ unsigned int netlib_write(void **socket, void *bufdsc, ...);D unsigned int netlib_writeline(void **socket, void *bufdsc, ...);? unsigned int netlib_read(void **socket, void *bufdsc, ...);C unsigned int netlib_readline(void **socket, void *bufdsc, ...);5 unsigned int netlib_shutdown(void **socket, ...);2 unsigned int netlib_close(void **socket, ...);3 unsigned int netlib_listen(void **socket, ...);C unsigned int netlib_accept(void **socket, void **newsock, ...);8 unsigned int netlib_get_hostname(void *bufdsc, ...);F unsigned int netlib_setsockopt(void **socket, unsigned int *level,L unsigned int *option, void *value, unsigned int *vallen, ...);F unsigned int netlib_getsockopt(void **socket, unsigned int *level,N unsigned int *option, void *buffer, unsigned int *bufsize, ...);Y unsigned int netlib_name_to_address(void **socket, unsigned int *which, void *namdsc,? void *addrlist, unsigned int *addrlistsize, ...);V unsigned int netlib_address_to_name(void *socket, unsigned int *which, void *addr,9 unsigned int *addrsize, void *namdsc, ...);I int netlib_dns_skipname(unsigned char *bufp, unsigned short *buflen);R unsigned int netlib_dns_expandname(unsigned char *buf, unsigned short *buflen,6 unsigned char *bufp, void *namdsc, ...);> unsigned int netlib_dns_query(void **socket, void *namdsc,6 unsigned int *class, unsigned int *type,@ unsigned char *buf, unsigned short *bufsize, ...);B unsigned int netlib_strtoaddr(void *dsc, struct INADDRDEF *a);G unsigned int netlib_addrtostr(struct INADDRDEF *a, void *dsc, ...);6 unsigned int netlib_connect_by_name(void **socket,4 void *dsc, unsigned short *port, ...);? unsigned int netlib_dns_mx_lookup(void **socket, void *dsc,7 void *mxrr, unsigned int *mxrrsize, ...);7 unsigned int netlib_hton_long(unsigned int *value);7 unsigned int netlib_ntoh_long(unsigned int *value);; unsigned short netlib_hton_word(unsigned short *value);; unsigned short netlib_ntoh_word(unsigned short *value);#ifdef __cplusplus}#endif!#endif /* not __NETLIB_BUILD__ */##endif /* __NETLIBDEF_H_LOADED__ */7 NETLIB_SRC.BCK}7n?[NETLIB]NETLIBDEF.R32;4@ qY*[NETLIB]NETLIBDEF.R32;4+,}7. / @ 4@ p-n?0123KPWO 56\ӻr7Ir8mn|"9V$ǘG @HJ!++! NETLIBDEF.R32! -! Definitions for use with NETLIB routines.! =! COPYRIGHT 1994, MADGOAT SOFTWARE. ALL RIGHTS RESERVED.! ! MODIFICATION HISTORY:! 7! 04-NOV-1994 Madison Initial coding (for V2.0).!--LITERAL! NETLIB_K_TYPE_STREAM = 1,! NETLIB_K_TYPE_DGRAM = 2,$ NETLIB_K_OPTION_REUSEADDR = 4,$ NETLIB_K_OPTION_KEEPALIVE = 8,% NETLIB_K_OPTION_BROADCAST = 32,& NETLIB_K_OPTION_SNDBUF = %X'1001',& NETLIB_K_OPTION_RCVBUF = %X'1002',+ NETLIB_K_OPTION_SNDLOWAT = %X'1003',+ NETLIB_K_OPTION_RCVLOWAT = %X'1004',% NETLIB_K_LEVEL_SOCKET = %X'FFFF', NETLIB_K_AF_INET = 2, NETLIB_K_LOOKUP_DNS = 1,$ NETLIB_K_LOOKUP_HOST_TABLE = 2,$ NETLIB_K_SHUTDOWN_RECEIVER = 0,$ NETLIB_K_SHUTDOWN_SENDER = 1, NETLIB_K_SHUTDOWN_BOTH = 2;LITERAL NETLIB_M_ALLOW_LF = 1;LITERAL NETLIB_M_DOMAIN_SEARCH = 1, NETLIB_M_NO_RECURSION = 2;LITERAL" NETLIB_K_DNS_TYPE_A = %X'01'," NETLIB_K_DNS_TYPE_NS = %X'02'," NETLIB_K_DNS_TYPE_MD = %X'03'," NETLIB_K_DNS_TYPE_MF = %X'04',% NETLIB_K_DNS_TYPE_CNAME = %X'05',# NETLIB_K_DNS_TYPE_SOA = %X'06'," NETLIB_K_DNS_TYPE_MB = %X'07'," NETLIB_K_DNS_TYPE_MG = %X'08'," NETLIB_K_DNS_TYPE_MR = %X'09',$ NETLIB_K_DNS_TYPE_NULL = %X'0A',# NETLIB_K_DNS_TYPE_WKS = %X'0B',# NETLIB_K_DNS_TYPE_PTR = %X'0C',% NETLIB_K_DNS_TYPE_HINFO = %X'0D',% NETLIB_K_DNS_TYPE_MINFO = %X'0E'," NETLIB_K_DNS_TYPE_MX = %X'0F',# NETLIB_K_DNS_TYPE_TXT = %X'10',$ NETLIB_K_DNS_QTYPE_ALL = %X'FF',# NETLIB_K_DNS_CLASS_IN = %X'01',# NETLIB_K_DNS_CLASS_CS = %X'02',# NETLIB_K_DNS_CLASS_CH = %X'03',# NETLIB_K_DNS_CLASS_HS = %X'04',% NETLIB_K_DNS_QCLASS_ALL = %X'FF', NETLIB_K_DNS_OP_STDQ = 0, NETLIB_K_DNS_OP_INVQ = 1, NETLIB_K_DNS_OP_STATUS = 2, NETLIB_K_DNS_RC_SUCCESS = 0, NETLIB_K_DNS_RC_FMTERR = 1, NETLIB_K_DNS_RC_SRVFAIL = 2, NETLIB_K_DNS_RC_NAMERR = 3, NETLIB_K_DNS_RC_NOTIMP = 4, NETLIB_K_DNS_RC_REFUSE = 5;LITERAL DNS_S_HEADER = 12;MACRO% DNS_W_QUERYID = 0,0,16,0%,% DNS_W_FLAGS = 2,0,16,0%,' DNS_V_RECURSION_DESIRED = 2,0,1,0%,$ DNS_V_TRUNCATED = 2,1,1,0%,' DNS_V_AUTHORITATIVE = 2,2,1,0%,$ DNS_V_OPCODE = 2,3,4,0%,$ DNS_V_REPLY = 2,7,1,0%,$ DNS_V_REPLY_CODE = 2,8,4,0%,* DNS_V_RECURSION_AVAILABLE = 2,15,1,0%,% DNS_W_QDCOUNT = 4,0,16,0%,% DNS_W_ANCOUNT = 6,0,16,0%,% DNS_W_NSCOUNT = 8,0,16,0%,& DNS_W_ARCOUNT = 10,0,16,0%,7 NETLIB_DNS_HEADER = BLOCK [DNS_S_HEADER,BYTE]%;LITERAL! SOCKADDR_S_SOCKADDRDEF = 16, SOCKADDR_S_DATA = 14;MACRO& SOCKADDR_W_FAMILY = 0,0,16,0%,$ SOCKADDR_X_DATA = 2,0,0,0%,@ SOCKADDRDEF = BLOCK [SOCKADDR_S_SOCKADDRDEF,BYTE]%;LITERAL INADDR_S_INADDRDEF = 4;MACRO% INADDR_L_ADDR = 0,0,32,0%,: INADDRDEF = BLOCK [INADDR_S_INADDRDEF,BYTE]%;LITERAL SIN_S_SINDEF = 16, SIN_S_MBZ = 8;MACRO% SIN_W_FAMILY = 0,0,16,0%,$ SIN_W_PORT = 2,0,16,0%,$ SIN_X_ADDR = 4,0,32,0%," SIN_X_MBZ = 8,0,0,0%,3 SINDEF = BLOCK [SIN_S_SINDEF,BYTE]%;LITERAL IOSB_S_IOSBDEF = 8;MACRO% IOSB_W_STATUS = 0,0,16,0%,% IOSB_W_COUNT = 2,0,16,0%,% IOSB_L_UNUSED = 4,0,32,0%,5 IOSBDEF = BLOCK [IOSB_S_IOSBDEF,BYTE]%;LITERAL MXRR_S_MXRRDEF = 136, MXRR_S_NAME = 128," NETLIB_S_MXRR_NAME = 128;MACRO& MXRR_L_PREFERENCE = 0,0,32,0%,% MXRR_L_LENGTH = 4,0,32,0%,$ MXRR_T_NAME = 8,0,0,0%,5 MXRRDEF = BLOCK [MXRR_S_MXRRDEF,BYTE]%;!+)! Definitions for V1 NETLIB - OBSOLETE!!-LITERAL NET_K_TCP = 1, NET_K_UDP = 2, NET_M_PUSH = 1, NET_M_NOTRM = 2;MACRO NET_V_PUSH = 0,0,1,0%, NET_V_NOTRM = 0,1,1,0%; 8 NETLIB_SRC.BCKkSqn?[NETLIB]NETLIB.OPT;14:*[NETLIB]NETLIB.OPT;14+,kSq./ @ 4:-n?0123KPWO56wp743p843¢/9V$ǘG @HJIDENT="NETLIB V2.0C"GSMATCH=LEQUAL,1,63CLUSTER=$$NETLIB_VECTOR,,,BIN_DIR:NETLIB_VECTOR.OBJCLUSTER=$$NETLIB_CPYRGT!PSECT_ATTR=$$$COPYRIGHT,NOWRT,SHR$COLLECT=$$NETLIB_CPYRGT,$$$COPYRIGHT:BIN_DIR:NETLIB_COMMON.OLB/INCLUDE=(DNS,DNS_MXLOOK)/LIBRARYSYS$SHARE:VAXCRTL/SHARE9 NETLIB_SRC.BCKRn?ETLIB]NETLIB.ALPHA_OPT;22:*[NETLIB]NETLIB.ALPHA_OPT;22+,R./ @ 4:-n?0123KPWO56p7tp8t֬/9V$ǘG @HJIDENT="NETLIB V2.0C"GSMATCH=LEQUAL,1,6!PSECT_ATTR=$$$COPYRIGHT,NOWRT,SHRCLUSTER=$$NETLIB_CPYRGT$COLLECT=$$NETLIB_CPYRGT,$$$COPYRIGHT:BIN_DIR:NETLIB_COMMON.OLB/INCLUDE=(DNS,DNS_MXLOOK)/LIBRARYSYMBOL_VECTOR=(-! NET_ASSIGN = PROCEDURE,- NET_BIND = PROCEDURE,-" NET_DEASSIGN = PROCEDURE,-" NET_GET_ADDRESS = PROCEDURE,-" NET_ADDR_TO_NAME = PROCEDURE,-" NET_GET_INFO = PROCEDURE,-" NET_GET_HOSTNAME = PROCEDURE,-" TCP_CONNECT = PROCEDURE,-" TCP_CONNECT_ADDR = PROCEDURE,-" TCP_DISCONNECT = PROCEDURE,-! TCP_ACCEPT = PROCEDURE,- TCP_SEND = PROCEDURE,-" TCP_RECEIVE = PROCEDURE,-" TCP_GET_LINE = PROCEDURE,- UDP_SEND = PROCEDURE,-" UDP_RECEIVE = PROCEDURE,-! DNS_MXLOOK = PROCEDURE,-' NET_SET_TRACE_ROUTINE = PROCEDURE,-" NETLIB_SOCKET = PROCEDURE,-% NETLIB_SERVER_SETUP = PROCEDURE,-" NETLIB_BIND = PROCEDURE,-$ NETLIB_GETSOCKNAME = PROCEDURE,-$ NETLIB_GETPEERNAME = PROCEDURE,-" NETLIB_CONNECT = PROCEDURE,-" NETLIB_WRITE = PROCEDURE,-" NETLIB_WRITELINE = PROCEDURE,-" NETLIB_READ = PROCEDURE,-" NETLIB_READLINE = PROCEDURE,-" NETLIB_SHUTDOWN = PROCEDURE,-" NETLIB_CLOSE = PROCEDURE,-" NETLIB_LISTEN = PROCEDURE,-" NETLIB_ACCEPT = PROCEDURE,-% NETLIB_GET_HOSTNAME = PROCEDURE,-# NETLIB_SETSOCKOPT = PROCEDURE,-# NETLIB_GETSOCKOPT = PROCEDURE,-( NETLIB_NAME_TO_ADDRESS = PROCEDURE,-( NETLIB_ADDRESS_TO_NAME = PROCEDURE,-" NETLIB_DNS_QUERY = PROCEDURE,-% NETLIB_DNS_SKIPNAME = PROCEDURE,-' NETLIB_DNS_EXPANDNAME = PROCEDURE,-" NETLIB_STRTOADDR = PROCEDURE,-" NETLIB_ADDRTOSTR = PROCEDURE,-( NETLIB_CONNECT_BY_NAME = PROCEDURE,-& NETLIB_DNS_MX_LOOKUP = PROCEDURE,-" NETLIB_HTON_LONG = PROCEDURE,-" NETLIB_NTOH_LONG = PROCEDURE,-" NETLIB_HTON_WORD = PROCEDURE,-! NETLIB_NTOH_WORD = PROCEDURE): NETLIB_SRC.BCKpwAn?[NETLIB]NETLIB_DOC.SDML;19dK*[NETLIB]NETLIB_DOC.SDML;19+,pwA./ @ 4d-n?0123KPWO56 }Uɘ7ވUɘ8ވ79ɘG @HJ(NETLIB_DOC_1) "(NETLIB Programmer's Guide)�<ABSTRACT>(November, 1994);�<P>This manual contains information about NETLIB, a library�.�for TCP/IP network programming on VMS systems. �<ENDABSTRACT>�&�<REVISION_INFO>(This is a new manual.)D�<REVISION_INFO>(Operating System and Version:\VAX/VMS V5.2 or later;�OpenVMS AXP V1.0 or later).�<REVISION_INFO>(Software Version:\NETLIB V2.0)6�<ENDTITLE_PAGE>(Matthew Madison<LINE>MadGoat Software)���<COPYRIGHT_PAGE>�<PRINT_DATE>(01 November 1994)C�<p>Permission is granted to copy and redistribute this document for��no commercial gain.�H�<P>The information in this document is subject to change without notice :�and should not be construed as a commitment by the author.9�The author assumes no responsibility for any errors that ��may appear in this document.D�<p><emphasis>(DISCLAIMER:\bold) The author, the author's employer,C� and MadGoat Software make no representations or warranties with�A� respect to the contents hereof and specifically disclaim any�Q� implied warranties of merchantability or fitness for any particular purpose.�S�<P>AXP, DEC, VAX, VMS, and OpenVMS are trademarks of Digital Equipment Corporation.�8�<P>UNIX is a trademark of Unix System Laboratories, Inc.'�<P>MultiNet is a trademark of TGV, Inc.�:�<P>TCPware is a trademark of Process Software Corporation.7�<P>PathWay is a trademark of The Wollongong Group, Inc.�>�<COPYRIGHT_DATE>(1994\MadGoat Software. All Rights Reserved.)�<ENDCOPYRIGHT_PAGE>����<CONTENTS_FILE>����<PREFACE>(\NETLIB_DOC_2) ��<P>�H�There are several TCP/IP packages available for VMS systems today. EachJ�provides a VMS-style programming interface, using the $QIO system service,E�and most also provide a <quote>(socket) programming library, based on�0�the communications model developed for BSD UNIX.E�Unfortunately, there is no standard among all of the packages for the�G�$QIO-based programming interface (most, but not all, emulate Digital's,�B�at least to some degree), and the $QIO-based interface is not very �easy to use.�<P>�D�The socket libraries provided with these packages provide a somewhatL�easier-to-use programming interface, but don't permit VMS-style asynchronousG�programming (using ASTs), and generally require at least a re-LINK, and�E�sometimes source modifications, when moving from one vendor's library� �to another.��<P>�E�NETLIB was originally developed to support MadGoat Software's Message�I�Exchange mail package, which needed to support many TCP/IP packages doing�L�VMS-style asynchronous programming. NETLIB provides a consistent, VMS-styleF�interface for TCP/IP-based network programs, operating with all of theE�currently available TCP/IP packages available today for VMS (with one�=�minor exception). In addition, NETLIB allows for flexibility�A�in the use of a TCP/IP package, by selecting the vendor-dependent�0�library code at run-time, rather than link-time.��(�<head1>(Intended Audience\NETLIB_INST_3)H�<p>This manual is intended for programmers writing applications that use�NETLIB.�)�<head1>(Document Structure\NETLIB_INST_4)�J�<p>This document consists of an introductory chapter, a section containingJ�routine descriptions, and an appendix describing the status codes returned�by NETLIB routines.���(�<head1>(Related Documents\NETLIB_INST_5)M�<p>The <emphasis>(NETLIB Installation Guide) describes how to install NETLIB.��� �<endpreface>�<ENDFRONT_MATTER>���$�<CHAPTER>(Using NETLIB\NETLIB_DOC_3)�<P>�8�This chapter discusses the NETLIB programming interface.���<HEAD1>(Overview\NETLIB_DOC_4)B�<P>NETLIB provides a single programming interface that can be usedD�with almost any TCP/IP package for VMS systems. While every packageA�provides a $QIO interface and most also provide a socket library,�+�the advantages to using NETLIB instead are:��<list>(unnumbered)I�<le>NETLIB allows VMS-style asynchronous programming (using ASTs) without�@�having to use the $QIO interface directly. The $QIO programming'�interface varies from vendor to vendor.�I�<le>NETLIB selects its vendor-specific support code at run-time, allowing�F�you to switch between TCP/IP packages without re-linking your program.E�You can even have the same application, installed just once, run over�B�different TCP/IP packages at the same time on different nodes in a�VMScluster system.>�<le>NETLIB provides a VMS common language environment style ofC�programming interface, making it easier to use from other languages�:�than a UNIX-type socket library written for C programmers. �<endlist>���%�<head2>(NETLIB Services\NETLIB_DOC_5)�F�<P>NETLIB provides services for writing TCP/IP-based network programs,E�both client and server. Servers can either be standalone, AST-driven�D�programs, or can be single-threaded server processes <quote>(forked)@�by the <quote>(master server) provided with each TCP/IP package.�<p>�5�NETLIB services can be grouped into four basic areas:��<list>(unnumbered))�<le><emphasis>(Connection services\bold).�C�These routines provide the services necessary for performing TCP/IP� �network I/O.@�<le><emphasis>(Line-mode services\bold). These routines provideE�a line-oriented network reads and writes, for line-oriented protocols��that run over TCP.C�<le><emphasis>(DNS resolver services\bold). These routines provide�B�host name and address lookup services. A direct DNS query routine�is also provided.�>�<le><emphasis>(Utility routines\bold). These are routines for@�doing byte-order conversions, IP address parsing and formatting,!�and other miscellaneous services.� �<endlist>���"�<HEAD1>(Header files\NETLIB_DOC_6)�<P>�E�NETLIB includes header files for both C and BLISS programming, called�E�NETLIBDEF.H and NETLIBDEF.R32, respectively. The header files reside�J�in the NETLIB_DIR: directory. These files define constants and structures2�that are used by the NETLIB programming interface.��,�<HEAD1>(NETLIB Data Structures\NETLIB_DOC_7)�<P>�G�NETLIB uses several data structures in its programming interface. Some�E�of these data structures (INADDRDEF and SINDEF) are common to all BSD�K�socket-oriented programming libraries, one (MXRRDEF) is special to NETLIB. ��The header files provided�A�with NETLIB defines these structures for BLISS and C programmers.�)�<HEAD2>(INADDRDEF Structure\NETLIB_DOC_8)�K�<p>The INADDRDEF structure is used for passing an IP address. The contents�P�is (currently) a longword, in network byte order (see <reference>(byte_ordering)4�for more information). Its definition is (in C) is: �<interactive>�� struct INADDRDEF {!� unsigned long inaddr_l_addr;�� }��<endinteractive>&�<HEAD2>(SINDEF Structure\NETLIB_DOC_9)M�<P>The SINDEF structure defines an IP <quote>(socket,) which is a combination�B�of an IP address and a TCP or UDP port number. Its definition is: �<interactive>�� struct SINDEF {�!� unsigned short sin_w_family;�� unsigned short sin_w_port;�$� struct INADDRDEF sin_x_addr;#� unsigned char sin_x_mbz[8];�� }��<endinteractive>C�<cp>The <emphasis>(sin_w_family\bold) field should always be set to�H�NETLIB_K_AF_INET (value 2). The <emphasis>(sin_w_mbz\������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������;����������������������������� �����NETLIB_SRC.BCK�����������������pwA��n?��[NETLIB]NETLIB_DOC.SDML;19�����������������������������������������������������������������������������������������������������d������������������������������C�������������bold) field should�always be zeroed.�I�<cp>This is a specific form of the more general SOCKADDRDEF structure for�E�use with IP-based sockets. NETLIB currently only supports IP network�<�programming, so other types of addresses should not be used.��(�<HEAD2>(MXRRDEF Structure\NETLIB_DOC_10)I�<P>The MXRRDEF structure is used to return MX resource record information�"�in a call to NETLIB_DNS_MX_LOOKUP: �<interactive>�� struct MXRRDEF {'� unsigned int mxrr_l_preference;�#� unsigned int mxrr_l_length;�&� char mxrr_t_name[128];� }��<endinteractive>%�<p>This structure is NETLIB-specific.���2�<HEAD2>(NETLIB_DNS_HEADER Structure\NETLIB_DOC_11)I�<p>A domain name server accepts queries and returns replies prefixed with�G�with a standard header. A definition of this header is provided in the�D�NETLIB_DNS_HEADER structure. Refer to the NETLIBDEF header file andF�the appropriate DNS RFCs (such as RFC 1035) for more information aboutH�this header. Only those programs which use the NETLIB_DNS_QUERY routine!�will need this header definition.���0�<HEAD1>(Byte-Order Considerations\byte_ordering)�<P>�D�In NETLIB routines, addresses and port numbers are expected to be inF�<quote>(network order;) that is, with the high-order byte first. ThisG�is opposite the natural byte-order for VAX and AXP systems running VMS,�E�which places the low-order byte first. NETLIB provides routines that�C�can be used to reverse byte order for use in the calls which expect��it.���=�<HEAD1>(Synchronous vs. Asynchronous Operation\NETLIB_DOC_12)��<P>�E�Most NETLIB routines can be executed synchronously (where the routine�G�uses $QIOW) or asynchronously ($QIO is used instead of $QIOW). To have�T�a routine called asynchronously, specify a non-zero <emphasis>(astadr\bold) argumentK�(and, optionally, the <emphasis>(astprm\bold) argument, to have a parameter��passed to the AST routine).���'�<HEAD1>(I/O Status Block\NETLIB_DOC_13)��<P>�F�Most NETLIB routines include an optional parameter for a VMS-style I/ON�status block (IOSB), which is used to return status information to the callingF�program. The first word of the IOSB is the NETLIB status code for theF�call; the second word, for read and write operations, is the number ofJ�bytes transferred. The second longword of the IOSB is not used by NETLIB.��.�<HEAD1>(Linking NETLIB Programs\NETLIB_DOC_14)�<p>�F�To link your program with NETLIB, include the following line in a LINK �options file:� �<interactive>�� NETLIB_SHRXFR/SHARE��<endinteractive>�<p>�N�Referencing this logical name will link your program against NETLIB's transferG�vector, which at run-time will activate the appropriate vendor-specific�>�version of NETLIB (pointed to by the NETLIB_SHR logical name).��,�<HEAD1>(Contacting the Author\NETLIB_DOC_15)M�<p>There is no formal support for NETLIB. If you have Internet connectivity,�J�however, you may wish to subscribe to one or more of the following MadGoat�Software mailing lists:��<list>(simple)0�<le><emphasis>(Info-MadGoat@wkuvx1.wku.edu\bold)�<p>�D� Discussion of MadGoat Software products by users and MadGoat4� developers. To subscribe, send a message to4� <emphasis>(Info-MadGoat-Request@wkuvx1.wku.edu)D� with the word SUBSCRIBE in the first line of the body of the� message.4�<le><emphasis>(MadGoat-Announce@wkuvx1.wku.edu\bold)�<p>�D� Announcements of new releases and new products from MadGoat.'� To subscribe, send a message to�3�<emphasis>(MadGoat-Announce-Request@wkuvx1.wku.edu)�D� with the word SUBSCRIBE in the first line of the body of the� message.0�<le><emphasis>(MadGoat-Bugs@wkuvx1.wku.edu\bold)�<p>�H� Address for reporting bugs in MadGoat Software products. PleaseI� include the name of the package and version in the subject header�H� of the message, so the report can be more easily directed to the� appropriate developer. �<endlist>�����$�<part>(Routine Descriptions\rtnpart) �<part_page>�7�<title>(<reference>(rtnpart)\<reference>(rtnpart\text))� �<abstract>4�This part describes the each of the NETLIB routines. �<endabstract>��<endpart_page>(renumber)����&�<routine_section>(NETLIB Routines\RTN)��;�<set_template_heading>(rsdeflist\CONDITION VALUES RETURNED)���K�<comment>(----------------------------------------------------------------)�E�<routine>(NETLIB_ACCEPT\Accept an incoming connection\\NETLIB_DOC_16)��� �<overview>G�NETLIB_ACCEPT waits for an incoming connection and accepts it, creating�$�a new socket for the new connection. �<endoverview>����<format>�<frtn>(NETLIB_ACCEPT)�`�<fargs>(socket ,newsocket [,remaddr] [,remaddr-size] [,remaddr-len] [,iosb] [,astadr] [,astprm]) �<endformat>�=�<returns>(cond_value\longword (unsigned)\write only\by value)� �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)2�<argdef>Socket that was established as a listener.R�<argitem>(newsocket\longword_unsigned\longword (unsigned)\write only\by reference)H�<argdef>Socket for the accepted connection (created and returned by this �routine).�H�<argitem>(remaddr\structure\longword (unsigned)\write only\by reference)C�<argdef>Address of a socket_address structure into which the remote�;�address/port information for the new connection is written.�T�<argitem>(remaddr-size\longword_unsigned\longword (unsigned)\read only\by reference)7�<argdef>Size of the <emphasis>(remaddr\bold) structure.�T�<argitem>(remaddr-len\longword_unsigned\longword (unsigned)\write only\by reference)L�<argdef>Longword into which the actual returned lenght of the socket address �is written.�K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)�=�<argdef>I/O status block to receive the status for this call.�A�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)�P�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)�2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>��� �<description>�K�This routine is used as part of a <quote>(passive) open sequence, typically�G�by servers that bind a socket to a specific port number, then establish�K�a listener to handle the incoming connections. This call is used to accept�J�an incoming connection, creating a new socket for the new connection. TheK�listener socket is not affected by this call, so you can call NETLIB_ACCEPT�H�again to wait for another incoming connection on the same port after one�accept completes.��<p>�D�If you want to know the address and port number of the remote end ofI�the accepted connection, you can either use the <emphasis>(remaddr\bold),�Q�<emphasis>(remaddr-size\bold), and <emphasis>(remaddr-len\bold) arguments on this�<�call, or follow this call with a call to NETLIB_GETPEERNAME.�<enddescription>��K�<comment>(----------------------------------------------------------------)�T�<routine>(NETLIB_ADDRESS_TO_NAME\Get the host name for an IP address\\NETLIB_DOC_17)�� �<overview>H�NETLIB_ADDRESS_TO_NAME performs an inverse host lookup, returning a name�associated with an IP address. �<endoverview>����<format>�<frtn>(NETLIB_ADDRESS_TO_NAME)[�<fargs>(socket, [which], address, addrsize, hostname [,retlen] [,iosb] [,astadr] [,astprm])� �<endformat>�=�<returns>(cond_value\longword (unsigned)\write only\by value)� �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)I�<argdef>The socket about which you wish to obtain the option information.�M�<argitem>(which\longword_unsigned\longword (unsigned)\read only\by reference)�N�<argdef>A code���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������<����������������������������� �����NETLIB_SRC.BCK�����������������pwA��n?��[NETLIB]NETLIB_DOC.SDML;19�����������������������������������������������������������������������������������������������������d������������������������������������������� indicating the type of lookup to be performed. Possible valuesL�are NETLIB_K_LOOKUP_DNS (1), which requests that the name be looked up usingJ�the Domain Name System, and NETLIB_K_LOOKUP_HOST_TABLE (2), which requestsL�that the name be looked up in the local host table. If omitted, the defaultG�is NETLIB_K_LOOKUP_DNS. See the Description section for information on�2�package-specific restrictions with this parameter.G�<argitem>(address\structure\longword (unsigned)\read only\by reference)�F�<argdef>An INADDRDEF structure containing the address to be looked up.P�<argitem>(addrsize\longword_unsigned\longword (unsigned)\read only\by reference)Q�<argdef>The size of the address passed in the <emphasis>(address\bold) parameter.�I�<argitem>(hostname\char_string\character string\write only\by descriptor)�C�<argdef>A buffer into which the returned host name will be written.�G�<argitem>(retlen\word_unsigned\word (unsigned)\write only\by reference)�7�<argdef>The returned length of the host name, in bytes.�K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)�=�<argdef>I/O status block to receive the status for this call.�A�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)�P�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)�2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>��� �<description>�L�This routine performs an address-to-name lookup on the specified IP address.E�Each TCP/IP package implements this function slightly differently, so 7�there are some restrictions on the use of this routine.n�<p>oG�For MultiNet, TCPware, and Pathway, the <emphasis>(which\bold) argumentyG�is used to determine whether the lookup should occur using NETLIB's DNS_J�resolver support or using the TCP/IP package's host-table access routines.M�For these packages, the host-table access method cannot be used at AST level.tG�Also, if a DNS lookup is attempted and the system is not configured foro/�DNS, an SS$_UNSUPPORTED error will be returned.d�<P>sM�For UCX and CMU TCP/IP, the <emphasis>(which\bold) argument is ignored, sincecK�these packages do not provide separate access to DNS and local host tables.cF�For UCX, host table lookup will occur first, followed by a DNS lookup. �For CMU, this order is reversed.�<enddescription>��K�<comment>(----------------------------------------------------------------)oK�<routine>(NETLIB_ADDRTOSTR\Format an IP address to a string\\NETLIB_DOC_18)n�� �<overview>B�NETLIB_ADDRTOSTR is a utility routine for formatting an IP address�as a character string. �<endoverview>e���<format>�<frtn>(NETLIB_ADDRTOSTR)"�<fargs>(address, string [,retlen]) �<endformat>�=�<returns>(cond_value\longword (unsigned)\write only\by value)M �<argdeflist>Q�<argitem>(address\INADDRDEF structure\longword (unsigned)\read only\by reference)�F�<argdef>An INADDRDEF structure containing the address to be formatted.G�<argitem>(string\char_string\character string\write only\by descriptor)�1�<argdef>The string to hold the formatted address.�G�<argitem>(retlen\word_unsigned\word (unsigned)\write only\by reference)hD�<argdef>The number of characters written to <emphasis>(string\bold).�<endargdeflist>a�� �<description>oD�This is a utility routine which formats an IP address to a character(�string, using the dotted-decimal format.�<enddescription>��K�<comment>(----------------------------------------------------------------) F�<routine>(NETLIB_BIND\Bind a socket to an address/port\\NETLIB_DOC_19)�� �<overview>=�NETLIB_BIND sets the address and/or port number for a socket.i �<endoverview>e���<format>�<frtn>(NETLIB_BIND)sI�<fargs>(socket, socket-address, sockaddr-len [,iosb] [,astadr] [,astprm])n �<endformat>)=�<returns>(cond_value\longword (unsigned)\write only\by value)r �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)�<argdef>Socket to be bound.dN�<argitem>(socket-address\structure\longword (unsigned)\read only\by reference)J�<argdef>Socket_address structure describing the addreses and port to which�the socket is to be bound.T�<argitem>(sockaddr-len\longword_unsigned\longword (unsigned)\read only\by reference)-�<argdef>Size of the socket address structure. K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)u=�<argdef>I/O status block to receive the status for this call.rA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)dP�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)�2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>i�� �<description>cE�This routine is used primarily by server programs to bind a socket toIG�a particular port, and is typically followed by a call to NETLIB_LISTENs*�to open a passive connection on that port.I�<P>If a program does not bind a socket to a particular local address/portEE�combination, the underlying TCP/IP software will automatically assign �an address and/or port.r�<enddescription>��K�<comment>(----------------------------------------------------------------)s:�<routine>(NETLIB_CLOSE\Close down a socket\\NETLIB_DOC_20)�� �<overview>�NETLIB_CLOSE closes a socket.d �<endoverview>a���<format>�<frtn>(NETLIB_CLOSE)�<fargs>(socket)� �<endformat>e=�<returns>(cond_value\longword (unsigned)\write only\by value)n �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)�<argdef>Socket to be closed.�<endargdeflist>c�� �<description>cI�This routine deletes the specified socket, closing the associated networkaN�communications channel, if one is open. Once closed, the socket can no longer=�be used; you must open a new one with the NETLIB_SOCKET call.s�<enddescription>��K�<comment>(----------------------------------------------------------------)nR�<routine>(NETLIB_CONNECT\Connect a socket to a remote address/port\\NETLIB_DOC_21)�� �<overview>:�NETLIB_CONNECT connects a socket to a remote address/port. �<endoverview>E���<format>�<frtn>(NETLIB_CONNECT)I�<fargs>(socket, socket-address, sockaddr-len [,iosb] [,astadr] [,astprm])n �<endformat> =�<returns>(cond_value\longword (unsigned)\write only\by value)n �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)�<argdef>Socket to be connected.EN�<argitem>(socket-address\structure\longword (unsigned)\read only\by reference)J�<argdef>Socket_address structure describing the addreses and port to which�the socket is to be connected.T�<argitem>(sockaddr-len\longword_unsigned\longword (unsigned)\read only\by reference)-�<argdef>Size of the socket address structure.iK�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)l=�<argdef>I/O status block to receive the status for this call.iA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)>P�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)�2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>u�� �<description>fE�This routine is used primarily with TCP-based programs to establish a,F�connection to a remote system. When used with UDP, this routine fixes;�the address to which subsequent UDP datagrams will be sent.y�<enddescription>��K�<comment>(----------------------------------------------------------------)u]�<routine>(NETLIB_CONNECT_BY_NAME\Establish a TCP connection to a host by name\\NETLIB_DOC_22)D�� �<overview>G�NETLIB_CONNECT_BY_NAME establishes a TCP connection to a h���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������=����������������������������� �����NETLIB_SRC.BCK�����������������pwA��n?��[NETLIB]NETLIB_DOC.SDML;19�����������������������������������������������������������������������������������������������������d������������������������������G� �����-�������ost using theX(�host's name, rather than its IP address. �<endoverview>����<format>�<frtn>(NETLIB_CONNECT_BY_NAME);�<fargs>(socket, hostname, port [,iosb] [,astadr] [,astprm])D �<endformat>e=�<returns>(cond_value\longword (unsigned)\write only\by value)n �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference):�<argdef>A STREAM-type socket allocated with NETLIB_SOCKET.H�<argitem>(hostname\char_string\character string\read only\by descriptor)I�<argdef>A character string containing either a host name or an IP addressu�in dotted-decimal format.(D�<argitem>(port\word_unsigned\word (unsigned)\read only\by reference)F�<argdef>The port number to connect to on the destination host. UnlikeA�the SIN_W_PORT field of a SINDEF (socket address) structure, this�A�number is specified in <emphasis>(host order), not network order.bD�NETLIB_CONNECT_BY_NAME will automatically convert the port number to�network order for you.K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)h=�<argdef>I/O status block to receive the status for this call.rA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)EP�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)P2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>o�� �<description>NE�This routine converts the specified name or dotted-decimal address toiJ�an IP address and uses NETLIB_CONNECT to connect to the specified host andG�port. If multiple addresses are returned by the host name lookup, eachrH�address will be tried until a connection is established or all addresses�have been tried.�<enddescription>��K�<comment>(----------------------------------------------------------------)oO�<routine>(NETLIB_DNS_EXPANDNAME\Expand a name in a DNS response\\NETLIB_DOC_23)N�� �<overview>L�NETLIB_DNS_EXPANDNAME is a utility routine used for extracting a domain name�from a DNS response. �<endoverview>m���<format>�<frtn>(NETLIB_DNS_EXPANDNAME)i>�<fargs>(bufstart, buflen, bufptr, name [,retlen] [,skipcount]) �<endformat>d=�<returns>(cond_value\longword (unsigned)\write only\by value)e �<argdeflist>B�<argitem>(bufstart\pointer\longword (unsigned)\read only\by value):�<argdef>A pointer to the start of the DNS response buffer.F�<argitem>(buflen\word_unsigned\word (unsigned)\read only\by reference))�<argdef>The size of the buffer, in bytes.r@�<argitem>(bufptr\pointer\longword (unsigned)\read only\by value)F�<argdef>A pointer to the area of the buffer containing the domain name�to be expanded. E�<argitem>(name\char_string\character string\write only\by descriptor)lA�<argdef>A descriptor for a character string buffer into which thec�expanded name will be written.G�<argitem>(retlen\word_unsigned\word (unsigned)\write only\by reference)o;�<argdef>The returned length of the expanded name, in bytes.)J�<argitem>(skipcount\word_unsigned\word (unsigned)\write only\by reference)G�<argdef>The number of bytes in the buffer that were us������3�������ed for the domaini�name.s�<endargdeflist>u�� �<description>tB�This is a utility routine used when parsing a response returned byE�a call to NETLIB_DNS_QUERY. It expands a domain name stored in a DNSsB�response out to the typical, human-readable, dotted-domain format.�<p>tF�This routine is needed because of the way domain names are representedJ�in DNS responses. Refer to RFC 1035 for further information on the format�of DNS queries and responses. �<enddescription>��K�<comment>(----------------------------------------------------------------)rS�<routine>(NETLIB_DNS_MX_LOOKUP\Look up MX records for a domain name\\NETLIB_DOC_24) �� �<overview>D�NETLIB_DNS_MX_LOOKUP looks up a host name, returning any MX records. �<endoverview>i���<format>�<frtn>(NETLIB_DNS_MX_LOOKUP)[�<fargs>(socket, hostname, mxrrlist, mxrrlist-size [,mxrrcount] [,iosb] [,astadr] [,astprm])s �<endformat>n=�<returns>(cond_value\longword (unsigned)\write only\by value)l �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)0�<argdef>Any socket allocated with NETLIB_SOCKET.H�<argitem>(hostname\char_string\character string\read only\by descriptor)&�<argdef>The host name to be looked up.S�<argitem>(mxrrlist\array of structures\longword (unsigned)\write only\by reference)pH�<argdef>An array of MXRRDEF structures into which the MX records will be�written.U�<argitem>(mxrrlist-size\longword_unsigned\longword (unsigned)\read only\by reference)iF�<argdef>The number of elements in the <emphasis>(mxrrlist\bold) array.R�<argitem>(mxrrcount\longword_unsigned\longword (unsigned)\write only\by reference)M�<argdef>The actual number of MX records written to <emphasis>(mxrrlist\bold). K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)o=�<argdef>I/O status block to receive the status for this call. A�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)�P�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)e2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>g�� �<description>�G�This routine performs a DNS lookup on the specified name, returning anyt*�Mail Exchanger (MX) records for that name.�<p>-H�For MultiNet, TCPware, and Pathway, and UCX, this routine is a front-end6�that uses NETLIB_DNS_QUERY to perform the DNS queries.@�For CMU TCP/IP, the MX lookups are performed using NAMRES calls.�<enddescription>��K�<comment>(----------------------------------------------------------------)N>�<routine>(NETLIB_DNS_QUERY\Perform a DNS query\\NETLIB_DOC_25)�� �<overview>D�NETLIB_DNS_QUERY formats a domain name service query and returns the�response from a DNS server.l �<endoverview>a���<format>�<frtn>(NETLIB_DNS_QUERY)Z�<fargs>(socket, name, [class], type, buffer, bufsize [,flags] [,iosb] [,astadr] [,astprm]) �<endformat>�=�<returns>(cond_value\longword (unsigned)\write only\by value) �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)G�<argdef>A socket allocated with NETLIB_SOCKET. Any socket can be used. D�<argitem>(name\char_string\character string\read only\by descriptor)(�<argdef>The domain name to be looked up.M�<argitem>(class\longword_unsigned\longword (unsigned)\read only\by reference)rJ�<argdef>The class of the query. For Internet domain names, this should beI�NETLIB_K_DNS_CLASS_IN, which is the default if this parameter is omitted.nL�<argitem>(type\longword_unsigned\longword (unsigned)\read only\by reference)K�<argdef>The type of query. Valid type codes are specified by Internet RFCsnN�on the DNS, the codes provided by NETLIB are listed in <reference>(dns_types).2�<table>(Domain Name Service query types\dns_types)�<table_setup>(3\25\5)c.�<table_heads>(Symbolic name\Value\Description)6�<table_row>(NETLIB_K_DNS_TYPE_A\1\Address (A) records)<�<table_row>(NETLIB_K_DNS_TYPE_NS\2\Name Server (NS) records)E�<table_row>(NETLIB_K_DNS_TYPE_CNAME\5\Canonical Name (CNAME) records)�E�<table_row>(NETLIB_K_DNS_TYPE_SOA\6\Start-of-Authority (SOA) records)oE�<table_row>(NETLIB_K_DNS_TYPE_WKS\11\Well-known-server (WKS) records)o;�<table_row>(NETLIB_K_DNS_TYPE_PTR\12\Pointer (PTR) records) H�<table_row>(NETLIB_K_DNS_TYPE_HINFO\13\Host information (HINFO) records)@�<table_row>(NETLIB_K_DNS_TYPE_MX\15\Mail Exchanger (MX) records)8�<table_row>(NETLIB_K_DNS_TYPE_TXT\16\Text (TXT) records)A�<table_row>(NETLIB_K_DNS_QTYPE_ALL\255\Any available information)r �<endtable>I�<argitem>(buffer\varying_arg\longword (unsigned)\write only\by reference)r<�<argdef>A �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������>����������������������������� �����NETLIB_SRC.BCK�����������������pwA��n?��[NETLIB]NETLIB_DOC.SDML;19�����������������������������������������������������������������������������������������������������d������������������������������������<�������buffer into which the DNS response will be copied.G�<argitem>(bufsize\word_unsigned\word (unsigned)\read only\by reference)(6�<argdef>The size of <emphasis>(buffer\bold), in bytes.I�<argitem>(flags\longword_mask\longword (unsigned)\read only\by reference)-J�<argdef>A bitmask of flags specifying options for this query. Valid flagsF�are listed in <reference>(query_flags). If omitted, the default value�for this parameter is 1.5�<table>(Flag values for NETLIB_DNS_QUERY\query_flags)n�<table_setup>(3\25\5)t.�������=�������<table_heads>(Symbolic name\Value\Description)K�<table_row>(NETLIB_M_DOMAIN_SEARCH\1\Perform a domain search on the defaultt�domain.)C�<table_row>(NETLIB_M_NO_RECURSION\2\Specify a non-recursive query.)e �<endtable>K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)n=�<argdef>I/O status block to receive the status for this call.kA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)mP�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)s2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist> �� �<description>aL�This routine formats a DNS query and returns the response from any answering>�name server. If the query fails, an error status is returned.�<p>sF�For MultiNet, TCPware, and Pathway, and UCX, the name servers that areK�queried are those specified for those packages. With MultiNet, for example,rB�the ones listed in the translation string for the logical name forL�MULTINET_NAMESERVERS are used. For the CMU TCP/IP package, the name serversJ�used by NAMRES are not available to NETLIB, so you must define the logicalI�name NETLIB_NAMESERVERS with the IP address(es) of the name server(s) youoH�want NETLIB to use. If no name servers can be found, SS$_UNSUPPORTED is �returned. �<enddescription>��K�<comment>(----------------------------------------------------------------)iK�<routine>(NETLIB_DNS_SKIPNAME\Skip a name in a DNS response\\NETLIB_DOC_26)s�� �<overview>G�NETLIB_DNS_SKIPNAME is a utility routine used for parsing DNS responsese�which skips over a domain name. �<endoverview> ���<format>�<frtn>(NETLIB_DNS_SKIPNAME)r�<fargs>(bufptr, buflen)r �<endformat>e@�<returns>(longword_signed\longword (signed)\write only\by value) �<argdeflist>@�<argitem>(bufptr\pointer\longword (unsigned)\read only\by value)D�<argdef>A pointer to the area of the DNS response buffer that begins�the name to be skipped.iF�<argitem>(buflen\word_unsigned\word (unsigned)\read only\by reference)C�<argdef>A count of the number of bytes in the buffer, starting fromh�<emphasis>(bufptr\bold).�<endargdeflist>s�� �<description>�B�This is a utility routine used when parsing a response returned by@�a call to NETLIB_DNS_QUERY. It returns a count of the number ofC�bytes to skip allocated to the domain name positioned in the bufferlC�at location <emphasis>(bufptr\bold). If the operation fails, -1 isc�returned to indicate an error.�<p>fF�This routine is needed because of the way domain names are representedJ�in DNS responses. Refer to RFC 1035 for further information on the format�of DNS queries and responses.n�<enddescription>��K�<comment>(----------------------------------------------------------------)cF�<routine>(NETLIB_GETPEERNAME\Get remote socket address\\NETLIB_DOC_27)�� �<overview>F�NETLIB_GETSOCKNAME returns the remote address and port information for�a connected socket.- �<endoverview>-���<format>�<frtn>(NETLIB_GETPEERNAME)>�<fargs>(socket, socket-address, sockaddr-size, sockaddr-retlen%� [,iosb] [,astadr] [,astprm]) �<endformat> =�<returns>(cond_value\longword (unsigned)\write only\by value)� �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference);�<argdef>Socket for which the information is to be returned.aO�<argitem>(socket-address\structure\longword (unsigned)\write only\by reference)�J�<argdef>Socket_address structure which will hold the returned address/port �information.U�<argitem>(sockaddr-size\longword_unsigned\longword (unsigned)\read only\by reference)f-�<argdef>Size of the socket address structure.nX�<argitem>(sockaddr-retlen\longword_unsigned\longword (unsigned)\write only\by reference)5�<argdef>Returned actual length of the socket address.iK�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)t=�<argdef>I/O status block to receive the status for this call.mA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)-P�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)k2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>t�� �<description> L�This routine is used to return the remote address and port information for a,�socket that is connected to a remote system.�<enddescription>��K�<comment>(----------------------------------------------------------------)eE�<routine>(NETLIB_GETSOCKNAME\Get local socket address\\NETLIB_DOC_28)s�� �<overview>E�NETLIB_GETSOCKNAME returns the local address and port information fors �a socket. �<endoverview>o���<format>�<frtn>(NETLIB_GETSOCKNAME)>�<fargs>(socket, socket-address, sockaddr-size, sockaddr-retlen%� [,iosb] [,astadr] [,astprm])s �<endformat>a=�<returns>(cond_value\longword (unsigned)\write only\by value)r �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference);�<argdef>Socket for which the information is to be returned.rO�<argitem>(socket-address\structure\longword (unsigned)\write only\by reference)sJ�<argdef>Socket_address structure which will hold the returned address/port �information.U�<argitem>(sockaddr-size\longword_unsigned\longword (unsigned)\read only\by reference) -�<argdef>Size of the socket address structure.lX�<argitem>(sockaddr-retlen\longword_unsigned\longword (unsigned)\write only\by reference)5�<argdef>Returned actual length of the socket address.tK�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)w=�<argdef>I/O status block to receive the status for this call.eA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)-P�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)f2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>s�� �<description>wK�This routine is used to return the local address and port information for a_(�socket that has been bound or connected.�<enddescription>��K�<comment>(----------------------------------------------------------------)s>�<routine>(NETLIB_GETSOCKOPT\Get socket options\\NETLIB_DOC_29)�� �<overview><�NETLIB_GETSOCKOPT gets the current state of a socket option. �<endoverview>p���<format>�<frtn>(NETLIB_GETSOCKOPT)lT�<fargs>(socket, level, option, value, valsize [,vallen] [,iosb] [,astadr] [,astprm]) �<endformat>n=�<returns>(cond_value\longword (unsigned)\write only\by value)/ �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)I�<argdef>The socket about which you wish to obtain the option information.tM�<argitem>(level\longword_unsigned\longword (unsigned)\read only\by reference)oH�<argdef><quote>(Level) of the option being set. The only level globallyG�supported is NETLIB_K_LEVEL_SOCKET (value X'FFFF'). Some packages alsoa'�support protocol-level option settings.(N�<argitem>(option\longword_unsigned\longword (unsigned)\read only\by reference)M�<argdef>Longword representing the option being set. Not all packages support K�all options, but most support the ones listed �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������?����������������������������� �����NETLIB_SRC.BCK�����������������pwA��n?��[NETLIB]NETLIB_DOC.SDML;19�����������������������������������������������������������������������������������������������������d������������������������������14������K�������in <reference>(option_table).)I�<P>Consult your package-specific documentation on other available optionsaL�and on option value ranges. The CMU TCP/IP package is not based on sockets,E�so this call will always return success status with 0 returned length( �on systems running that package.H�<argitem>(value\varying_arg\longword (unsigned)\write only\by reference)H�<argdef>Value to set for the option. Values vary from option to option.O�<argitem>(valsize\longword_unsigned\longword (unsigned)\read only\by ref������L�������erence)d>�<argdef>Size of the <emphasis>(value\bold) argument, in bytes.O�<argitem>(vallen\longword_unsigned\longword (unsigned)\write only\by reference) C�<argdef>Actual returned length of <emphasis>(value\bold), in bytes.aK�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)-=�<argdef>I/O status block to receive the status for this call.EA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)_P�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)�2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>e�� �<description>aM�This routine provides an interface to the <emphasis>(getsockopt\bold) serviceeB�provided by most TCP/IP packages (most are based on the BSD socketD�communications model). Note that not all options are available withF�all packages, and for the CMU TCP/IP this call is a no-operation -- itE�will always return a success status, with 0 as the returned length ofn�the option value.e�<enddescription>��K�<comment>(----------------------------------------------------------------) W�<routine>(NETLIB_HTON_LONG\Convert host-order longword to network order\\NETLIB_DOC_30)e�� �<overview>B�NETLIB_HTON_LONG is a utility routine for converting a longword in8�the local host's byte order to a network-order longword. �<endoverview>_���<format>�<frtn>(NETLIB_HTON_LONG)�<fargs>(value) �<endformat>oD�<returns>(longword_unsigned\longword (unsigned)\write only\by value) �<argdeflist>M�<argitem>(value\longword_unsigned\longword (unsigned)\read only\by reference)a%�<argdef>The longword to be converted.y�<endargdeflist>g�� �<description> E�This is a utility routine which reverses the byte order of a longwordsA�to convert it from the native format for the local host (which isaF�<quote>(little-endian) for VAX and AXP systems running VMS) to network@�order (which is <quote>(big-endian)). The returned value is the�network-order longword.n�<enddescription>��K�<comment>(----------------------------------------------------------------)rS�<routine>(NETLIB_HTON_WORD\Convert host-order word to network order\\NETLIB_DOC_31)l�� �<overview>>�NETLIB_HTON_WORD is a utility routine for converting a word in4�the local host's byte order to a network-order word. �<endoverview>e���<format>�<frtn>(NETLIB_HTON_WORD)�<fargs>(value) �<endformat>_<�<returns>(word_unsigned\word (unsigned)\write only\by value) �<argdeflist>E�<argitem>(value\word_unsigned\word (unsigned)\read only\by reference)�!�<argdef>The word to be converted.r�<endargdeflist>l�� �<description>[A�This is a utility routine which reverses the byte order of a word A�to convert it from the native format for the local host (which ispF�<quote>(little-endian) for VAX and AXP systems running VMS) to network>�order (which is <quote>(big-endian)). The return value is the�network-order word.a�<enddescription>��K�<comment>(----------------------------------------------------------------)rG�<routine>(NETLIB_LISTEN\Listen for incoming connections\\NETLIB_DOC_32)f�� �<overview>B�NETLIB_LISTEN sets a socket up to listen for incoming connections. �<endoverview>t���<format>�<frtn>(NETLIB_LISTEN)e6�<fargs>(socket [,backlog] [,iosb] [,astadr] [,astprm]) �<endformat> =�<returns>(cond_value\longword (unsigned)\write only\by value)) �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)*�<argdef>Socket to be set up as a listener.J�<argitem>(backlog\unsigned int\longword (unsigned)\read only\by reference)G�<argdef>The number of backlogged connections to allow on this listener.sK�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)L=�<argdef>I/O status block to receive the status for this call.nA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)�P�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)f2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>-�� �<description>-K�This routine is used as part of a <quote>(passive) open sequence, typicallypG�by servers that bind a socket to a specific port number, then establishMM�a listener to handle the incoming connections. This call is usually followedrO�by one or more invocations of NETLIB_ACCEPT to accept the incoming connections.s�<enddescription>��K�<comment>(----------------------------------------------------------------)gW�<routine>(NETLIB_NAME_TO_ADDRESS\Get the IP address(es) for a host name\\NETLIB_DOC_33)s�� �<overview>J�NETLIB_NAME_TO_ADDRESS looks up a host name, returning its IP address(es). �<endoverview>_���<format>�<frtn>(NETLIB_NAME_TO_ADDRESS)d�<fargs>(socket, [which], hostname, addrlist, addrlist-size [,addrcount] [,iosb] [,astadr] [,astprm]) �<endformat>\=�<returns>(cond_value\longword (unsigned)\write only\by value)c �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)I�<argdef>The socket about which you wish to obtain the option information.iM�<argitem>(which\longword_unsigned\longword (unsigned)\read only\by reference)nN�<argdef>A code indicating the type of lookup to be performed. Possible valuesL�are NETLIB_K_LOOKUP_DNS (1), which requests that the name be looked up usingJ�the Domain Name System, and NETLIB_K_LOOKUP_HOST_TABLE (2), which requestsL�that the name be looked up in the local host table. If omitted, the defaultG�is NETLIB_K_LOOKUP_DNS. See the Description section for information ont2�package-specific restrictions with this parameter.H�<argitem>(hostname\char_string\character string\read only\by descriptor)&�<argdef>The host name to be looked up.S�<argitem>(addrlist\array of structures\longword (unsigned)\write only\by reference)EI�<argdef>An array of INADDRDEF structures into which the addresses will bew�written.U�<argitem>(addrlist-size\longword_unsigned\longword (unsigned)\read only\by reference)�F�<argdef>The number of elements in the <emphasis>(addrlist\bold) array.R�<argitem>(addrcount\longword_unsigned\longword (unsigned)\write only\by reference)L�<argdef>The actual number of addresses written to <emphasis>(addrlist\bold).K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)�=�<argdef>I/O status block to receive the status for this call.>A�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)fP�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)k2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>g�� �<description>cJ�This routine performs a name-to-address lookup on the specified host name.E�Each TCP/IP package implements this function slightly differently, soo7�there are some restrictions on the use of this routine.d�<p>iG�For MultiNet, TCPware, and Pathway, the <emphasis>(which\bold) argumentrG�is used to determine whether the lookup should occur using NETLIB's DNSaJ�resolver support or using the TCP/IP package's host-table access routines.M�For these packages, the host-table access method canno�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������@����������������������������� �����NETLIB_SRC.BCK�����������������pwA��n?��[NETLIB]NETLIB_DOC.SDML;19�����������������������������������������������������������������������������������������������������d������������������������������`y������Z�������t be used at AST level.dG�Also, if a DNS lookup is attempted and the system is not configured forL/�DNS, an SS$_UNSUPPORTED error will be returned.(�<P>nM�For UCX and CMU TCP/IP, the <emphasis>(which\bold) argument is ignored, sincebK�these packages do not provide separate access to DNS and local host tables.eF�For UCX, host table lookup will occur first, followed by a DNS lookup. �For CMU, this order is reversed.�<enddescription>��K�<comment>(----------------------------------------------------------------)rW�<routine>(NETLIB_NTOH_LONG\Convert network-order longword to host order\\NETLIB_DOC_34)r�� �<overview>B�NETLIB_NTOH_LONG is a utility routine for converting a longword in0�the network byte order to a host-order longword. �<endoverview>K���<format>�<frtn>(NETLIB_NTOH_LONG)�<fargs>(value) �<endformat>DD�<returns>(longword_unsigned\longword (unsigned)\write only\by value) �<argdeflist>M�<argitem>(value\longword_unsigned\longword (unsigned)\read only\by reference))%�<argdef>The longword to be converted.u�<endargdeflist>h�� �<description>lE�This is a utility routine which reverses the byte order of a longword\H�to convert it from network order to host order. The return value is the�host-order longword.�<enddescription>��K�<comment>(----------------------------------------------------------------) S�<routine>(NETLIB_NTOH_WORD\Convert network-order word to host order\\NETLIB_DOC_35)e�� �<overview>>�NETLIB_NTOH_WORD is a utility routine for converting a word in,�the network byte order to a host-order word. �<endoverview>b���<format>�<frtn>(NETLIB_NTOH_WORD)�<fargs>(value) �<endformat>P<�<returns>(word_unsigned\word (unsigned)\write only\by value) �<argdeflist>E�<argitem>(value\word_unsigned\word (unsigned)\read only\by reference)i!�<argdef>The word to be converted.w�<endargdeflist>r�� �<description>/A�This is a utility routine which reverses the byte order of a wordaA�to convert it from network order to host order. The return values�is the host-order word. �<enddescription>��K�<comment>(----------------------------------------------------------------)\E�<routine>(NETLIB_READ\Receive data from remote system\\NETLIB_DOC_36)d�� �<overview>=�NETLIB_READ reads data sent by a remote system from a socket.r �<endoverview>y���<format>�<frtn>(NETLIB_READ)qI�<fargs>(socket, buffer [,socket-address] [,sockaddr-size] [,sockaddr-len]P1� [,timeout] [,iosb] [,astadr] [,astprm]) �<endformat>c=�<returns>(cond_value\longword (unsigned)\write only\by value)s �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)/�<argdef>Socket to which data should be written.bY�<argitem>(buffer\unspecified\longword (unsigned)\write only\by descriptor (fixed-length))RE�<argdef>The address of a descriptor for a buffer to receive the data.eO�<argitem>(socket-address\structure\longword (unsigned)\write only\by reference)oL�<argdef>Socket_address structure to receive the addreses and port from whichK�the data is to be sent. Typically used only with unconnected UDP sockets)._U�<argitem>(sockaddr-size\longword_unsigned\longword (unsigned)\read only\by reference)nS�<argdef>Size of the socket address structure. Typically used only with unconnected_ �UDP sockets.T�<argitem>(sockaddr-len\longword_unsigned\longword (unsigned)\read only\by reference)8�<argdef>Returned length of the socket address structure.1�Typically used only with unconnected UDP sockets.oF�<argitem>(timeout\delta_time\quadword (signed)\read only\by reference)M�<argdef>Amount of time that NETLIB_READ should wait for the read to complete.c�If omitted, no timeout is used. K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)i=�<argdef>I/O status block to receive the status for this call.sA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference) P�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)n2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist> �� �<description> B�This routine reads data from the socket into the specified buffer.D�The read will complete when the buffer is full, or if the read timesJ�out (if <emphasis>(timeout\bold) is specified). A fixed-length descriptorD�should be used for the buffer. To obtain the actual number of bytes+�read in this call, use an I/O status block.��<enddescription>��K�<comment>(----------------------------------------------------------------)dF�<routine>(NETLIB_READLINE\Read a <quote>(line) of data\\NETLIB_DOC_37)�� �<overview>>�NETLIB_READLINE reads a <quote>(line) of data from the socket. �<endoverview>t���<format>�<frtn>(NETLIB_READLINE)sQ�<fargs>(socket, buffer [,retlen] [,flags] [,timeout] [,iosb] [,astadr] [,astprm])w �<endformat>)=�<returns>(cond_value\longword (unsigned)\write only\by value)i �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference).�<argdef>Socket from which data should be read.G�<argitem>(buffer\char_string\character string\write only\by descriptor)sD�<argdef>The address of a descriptor for the buffer to hold the line.G�<argitem>(retlen\word_unsigned\word (unsigned)\write only\by reference)oE�<argdef>The address of a word which receives the actual length of thee�received line.C�<argitem>(flags\bitmask\longword (unsigned)\read only\by reference) H�<argdef>The address of a bitmask containing flags controlling this call.F�Only one flag is currently defined, NETLIB_M_ALLOW_LF (value 1), whichF�causes NETLIB_READLINE to consider either a CR/LF pair or a bare LF asE�a line terminator. If this argument is omitted, this flag is enablednO�by default. Otherwise, only a CR/LF pair will be considered a line terminator.�F�<argitem>(timeout\delta_time\quadword (signed)\read only\by reference)H�<argdef>The address of a VMS delta time value specifying the timeout for �this read.K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)-=�<argdef>I/O status block to receive the status for this call.cA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)rP�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)o2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>��� �<description>tC�This routine is intended for TCP-based programs that use a protocolsH�which delimits commands and replies with carriage-return/linefeed pairs.E�It completes only when the specified buffer is full; when a complete,�E�terminated, line has been received; or if a timeout occurs. The linef.�terminator is stripped from the returned data.�<enddescription>��K�<comment>(----------------------------------------------------------------)gV�<routine>(NETLIB_SERVER_SETUP\Socket setup for <quote>(forked) servers\\NETLIB_DOC_38) �<overview>C�NETLIB_SERVER_SETUP creates and sets up the socket used by a servereG�process <quote>(forked) from a TCP/IP package's <quote>(master server).m �<endoverview>s�<format>�<frtn>(NETLIB_SERVER_SETUP)y.�<fargs>(socket, socket-address, sockaddr-size) �<endformat>f=�<returns>(cond_value\longword (unsigned)\write only\by value)c �<argdeflist>O�<argitem>(socket\longword_unsigned\longword (unsigned)\write only\by reference)tB�<argdef>Returned socket handle for use in subsequent NETLIB calls.V�<argitem>(socket-address\special_structure\longword (unsigned)\read only\by reference)M�<argdef>Socket address describing port being opened. See note in description �section.U�<argitem>(sockaddr-size\longword_unsigned\longword (unsigned)\read only\by reference)-Q�<argdef>Size of the struct���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������A����������������������������� �����NETLIB_SRC.BCK�����������������pwA��n?��[NETLIB]NETLIB_DOC.SDML;19�����������������������������������������������������������������������������������������������������d������������������������������������i�������ure passed in <emphasis>(socket-address\bold) argument.t�<endargdeflist>D�� �<description>eC�This routine creates a NETLIB socket for the communications channeldI�in a server program invoked by a TCP/IP package's <quote>(master server.)o'�The <emphasis>(socket-address\bold) and,-�<emphasis>(sockaddr-size\bold) arguments mustdI�be provided, although for all packages except CMU TCP/IP they are ignoredo8�(the actual address and port number are pre-determined).�<NOTE>@�For at least some TCP/IP packages, this routine should be calledC�<emphasis>(before) any language-specific I/O routines (for example,dJ�the <emphasis>(printf\bold) routine in the C run-time library) are called,I�to prevent the run-time system from interfering with the network channel.m �<ENDNOTE>a�<enddescription>��K�<comment>(----------------------------------------------------------------)g>�<routine>(NETLIB_SETSOCKOPT\Set socket options\\NETLIB_DOC_39)�� �<overview>4�NETLIB_SETSOCKOPT modifies attributes of a a socket. �<endoverview>s���<format>�<frtn>(NETLIB_SETSOCKOPT)�I�<fargs>(socket, level, option, value, vallen [,iosb] [,astadr] [,astprm])� �<endformat> =�<returns>(cond_value\longword (unsigned)\write only\by value)� �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)&�<argdef>The socket you wish to modify.M�<argitem>(level\longword_unsigned\longword (unsigned)\read only\by reference)oH�<argdef><quote>(Level) of the option being set. The only level globallyG�supported is NETLIB_K_LEVEL_SOCKET (value X'FFFF'). Some packages alsoa'�support protocol-level option settings.gN�<argitem>(option\longword_unsigned\longword (unsigned)\read only\by reference)M�<argdef>Longword representing the option being set. Not all packages supportoK�all options, but most support the ones listed in <reference>(option_table). $�<table>(Socket options\option_table)�<table_setup>(3\25\5)(.�<table_heads>(Symbolic name\Value\Description)J�<table_row>(NETLIB_K_OPTION_REUSEADDR\4\Allows a port number to be reused.I�Value is a longword, either 1 (on) or 0 (off). Default for most packagesvK�is off, but NETLIB turns this option on automatically unless you explicitly�"�call NETLIB_SETSOCKOPT to set it.)J�<table_row>(NETLIB_K_OPTION_SNDBUF\4097\Sets socket buffer size for sends.>�Value is a longword, typically with a maximum value of 32768.)M�<table_row>(NETLIB_K_OPTION_RCVBUF\4098\Sets socket buffer size for receives.o>�Value is a longword, typically with a maximum value of 32768.) �<endtable>I�<P>Consult your package-specific documentation on other available optionscL�and on option value ranges. The CMU TCP/IP package is not based on sockets,;�so this call has no effect on systems running that package.gG�<argitem>(value\varying_arg\longword (unsigned)\read only\by reference) H�<argdef>Value to set for the option. Values vary from option to option.N�<argitem>(vallen\longword_unsigned\longword (unsigned)\read only\by reference)>�<argdef>Size of the <emphasis>(value\bold) argument, in bytes.K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)o=�<argdef>I/O status block to receive the status for this call.eA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference) P�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)(2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist> �� �<description>(M�This routine provides an interface to the <emphasis>(setsockopt\bold) servicetB�provided by most TCP/IP packages (most are based on the BSD socketD�communications model). Note that not all options are available withA�all packages, and for the CMU TCP/IP this call is a no-operation. �<enddescription>��K�<comment>(----------------------------------------------------------------)�@�<routine>(NETLIB_SHUTDOWN\Shut down a connection\\NETLIB_DOC_40)�� �<overview>D�NETLIB_SHUTDOWN shuts down a connection without deleting the socket. �<endoverview>t���<format>�<frtn>(NETLIB_SHUTDOWN)d7�<fargs>(socket [,shuttype] [,iosb] [,astadr] [,astprm])t �<endformat>d=�<returns>(cond_value\longword (unsigned)\write only\by value)e �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)*�<argdef>Socket to be set up as a listener.K�<argitem>(shuttype\unsigned int\longword (unsigned)\read only\by reference)rE�<argdef>Type of shutdown to be performed. Possible values are listed(7�in <reference>(shut_table). If omitted, the default is-�NETLIB_K_SHUTDOWN_RECEIVER.S"�<table>(Shutdown types\shut_table)�<table_setup>(3\25\5)e.�<table_heads>(Symbolic name\Value\Description)G�<table_row>(NETLIB_K_SHUTDOWN_RECEIVER\0\Prevent any further receives.)TB�<table_row>(NETLIB_K_SHUTDOWN_SENDER\1\Prevent any further sends.)I�<table_row>(NETLIB_K_SHUTDOWN_BOTH\2\Prevent any further sends/receives.)g �<endtable>C�<P>This parameter has no meaning when using the CMU TCP/IP package.eK�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)d=�<argdef>I/O status block to receive the status for this call.uA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)mP�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)r2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>f�� �<description>o@�This routine closes the network connection currently open on theF�specified socket, without deleting the socket. Any data still waitingD�to be received or sent can be discarded or retained by specifying an7�appropriate shutdown type in <emphasis>(shuttype\bold).eE�<P>For the CMU TCP/IP package, the shutdown type is not used; the CMUt-�close operation does not provide this option.n�<enddescription>��K�<comment>(----------------------------------------------------------------)cN�<routine>(NETLIB_SOCKET\Create a NETLIB communication endpoint\\NETLIB_DOC_41)�� �<overview>H�NETLIB_SOCKET creates a <quote>(socket) -- that is, a local endpoint for�TCP/IP communication. �<endoverview>I���<format>�<frtn>(NETLIB_SOCKET)M/�<fargs>(socket [,socket-type] [,socket-family])I �<endformat>.=�<returns>(cond_value\longword (unsigned)\write only\by value)f �<argdeflist>O�<argitem>(socket\longword_unsigned\longword (unsigned)\write only\by reference)mH�<argdef>The returned socket context, for use in subsequent NETLIB calls.U�<argitem>(socket-type\longword_unsigned \longword (unsigned)\read only\by referencee)bB�<argdef>Type of socket to be created. Allowed values are shown in;�<reference>(socket_type_table). If omitted, the default iso�NETLIB_K_TYPE_STREAM.\'�<table>(Socket types\socket_type_table) �<table_setup>(3\25\5)e.�<table_heads>(Symbolic name\Value\Description)I�<table_row>(NETLIB_K_TYPE_STREAM\1\Connection-oriented socket (for TCP).) C�<table_row>(NETLIB_K_TYPE_DGRAM\2\Connectionless socket (for UDP).)n �<endtable>U�<argitem>(socket-family\longword_unsigned\longword (unsigned)\read only\by reference)eO�<argdef>Address/protocol family. Only NETLIB_K_AF_INET (value 2) is permitted, %�and is assumed by default if omitted.i�<endargdeflist>n�� �<description>s?�This routine creates a <quote>(socket) (an endpoint for networkiD�communication). One socket is required for each network connection.D�This will be the first call in most NETLIB-based programs. The onlyA�exception to this rule is a program that is intended to be run as(H�a <quote>(forked) server from a TCP/IP package's <quote>(master server),7�which will use the NETLIB_SERVER_SETUP routine instead.g�<enddescription>��K�<comment>(--------------------���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������B����������������������������� �����NETLIB_SRC.BCK�����������������pwA��n?��[NETLIB]NETLIB_DOC.SDML;19�����������������������������������������������������������������������������������������������������d������������������������������Y � �����x�������--------------------------------------------)sR�<routine>(NETLIB_STRTOADDR\Convert a dotted-address to binary form\\NETLIB_DOC_42)�� �<overview>G�NETLIB_STRTOADDR is a utility routine for converting a character stringi@�holding a dotted-decimal IP addreses into its binary equivalent. �<endoverview>g���<format>�<frtn>(NETLIB_STRTOADDR)�<fargs>(string, address) �<endformat>�=�<returns>(cond_value\longword (unsigned)\write only\by value)e �<argdeflist>F�<argitem>(string\char_string\character string\read only\by descriptor)9�<argdef>The string containing the dotted-decimal address. R�<argitem>(address\INADDRDEF structure\longword (unsigned)\write only\by reference)<�<argdef>An INADDRDEF structure to hold the returned address.�<endargdeflist>u�� �<description>aD�This is a utility routine which parses a character string containingK�an IP address in dotted-decimal format, returning the binary representationnH�of that address in network order (suitable for a call to NETLIB_CONNECT, �for example).c�<enddescription>��K�<comment>(----------------------------------------------------------------)tA�<routine>(NETLIB_WRITE\Send data to remote system\\NETLIB_DOC_43)��� �<overview>I�NETLIB_WRITE writes data to a socket for transmission to a remote system.s �<endoverview>o���<format>�<frtn>(NETLIB_WRITE)U�<fargs>(socket, buffer [,socket-address] [,sockaddr-len] [,iosb] [,astadr] [,astprm])l �<endformat>M=�<returns>(cond_value\longword (unsigned)\write only\by value)- �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)/�<argdef>Socket to which data should be written.OI�<argitem>(buffer\unspecified\longword (unsigned)\read only\by descriptor)a<�<argdef>The address of a descriptor for the data to be sent.N�<argitem>(socket-address\structure\longword (unsigned)\read only\by reference)J�<argdef>Socket_address structure describing the addreses and port to whichA�the data is to be sent. Used only with unconnected UDP sockets).\T�<argitem>(sockaddr-len\longword_unsigned\longword (unsigned)\read only\by reference)I�<argdef>Size of the socket address structure. Used only with unconnecteda �UDP sockets.K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)o=�<argdef>I/O status block to receive the status for this call.-A�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)NP�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value) 2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>��� �<description>HE�This routine writes the specified data to the socket for transmissioniC�to the remote system. For UDP sockets that have not been connectedeJ�to a specific remote address, the <emphasis>(socket-address\bold) argumentF�specifies the remote address/port to which the datagram is to be sent.�<enddescription>��K�<comment>(----------------------------------------------------------------)aK�<routine>(NETLIB_WRITELINE\Send data with CR/LF termination\\NETLIB_DOC_������~�������44)-�� �<overview>M�NETLIB_WRITELINE writes data to a socket for transmission to a remote system,e'�terminating the data with a CR/LF pair.> �<endoverview>e���<format>�<frtn>(NETLIB_WRITELINE)3�<fargs>(socket, buffer [,iosb] [,astadr] [,astprm])_ �<endformat>s=�<returns>(cond_value\longword (unsigned)\write only\by value)l �<argdeflist>N�<argitem>(socket\longword_unsigned\longword (unsigned)\read only\by reference)/�<argdef>Socket to which data should be written.lF�<argitem>(buffer\char_string\character string\read only\by descriptor)<�<argdef>The address of a descriptor for the data to be sent.K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)f=�<argdef>I/O status block to receive the status for this call.rA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference) P�<argdef>Address of an AST routine to be invoked on completion of this operation.A�<argitem>(astprm\user_arg\longword (unsigned)\read only\by value)y2�<argdef>Parameter to be passed to the AST routine.�<endargdeflist>o�� �<description>oO�This routine functions identically to NETLIB_WRITE, but adds a carriage-return/rD�linefeed pair to the data sent to the remote system. It is intendedF�for TCP-based programs that use a protocol which delimits commands and�responses with CR/LFs.�<enddescription>���<endroutine_section>��%�<APPENDIX>(Status Codes\status_codes)c�<P>o@�NETLIB translates all TCP/IP status codes into the codes used by7�DEC TCP/IP Services. The status codes are described iniJ�<reference>(status_table). For synchronous NETLIB calls, these codes are J�returned in R0 and also in the IOSB, if one is specified; for asynchronousE�calls, you should always specify an IOSB to receive the status of thep�network I/O operation.�<P>cH�Some NETLIB routines may also return status codes from other facilities,;�such as the LIB$ and STR$ routines when processing strings.d��)�<table>(NETLIB Status Codes\status_table)a�<table_setup>(2\20) (�<table_heads>(Symbolic Name\Description)L�<table_row>(SS$_ABORT\Catch-all code for errors not covered by other codes.)G�<table_row>(SS$_INSFARG\Not enough arguments specified on NETLIB call.)uL�<table_row>(SS$_BADPARAM\Invalid value specified for an argument to a NETLIBE�call. This code can also be returned by the underlying TCP/IP driveri@�when an invalid value is specified for a network I/O operation.)9�<table_row>(SS$_NOSUCHNODE\Destination address required.)-3�<table_row>(SS$_INSFMEM\Memory allocation failure.)lG�<table_row>(SS$_NOPRIV\Insufficient privilege for requested operation.)e9�<table_row>(SS$_ACCVIO\Invalid memory address specified.)>4�<table_row>(SS$_FILALRACC\Socket already connected.)?�<table_row>(SS$_LINKDISCON\Network link has been disconnected.)m@�<table_row>(SS$_TOOMUCHDATA\Result too large for user's buffer.)5�<table_row>(SS$_SUSPENDED\I/O operation would block.)nN�<table_row>(SS$_NOTNETDEV\Network operation requested for non-network device.)E�<table_row>(SS$_PROTOCOL\Protocol type or option incorrect. Protocole?�or socket type not supported. Other general protocol failure.) ?�<table_row>(SS$_ILLCNTRFUNC\Operation not supported on socket.)i5�<table_row>(SS$_DUPLNAM\Address/port already in use.)h(�<table_row>(SS$_IVADDR\Invalid address.)9�<table_row>(SS$_UNREACHABLE\Network or host unreachable.)e9�<table_row>(SS$_RESET\Network connection has been reset.)nB�<table_row>(SS$_LINKABORT\Connection aborted by network software.)I�<table_row>(SS$_CONNECFAIL\Connection failure, or reset by peer process.)r1�<table_row>(SS$_NOLINKS\Socket is not connected.)aK�<table_row>(SS$_SHUT\Socket, host, or network software has been shut down.)i-�<table_row>(SS$_TIMEOUT\Operation timed out.) +�<table_row>(SS$_REJECT\Connection refused.)a �<endtable> �<ENDAPPENDIX> ference)H�<argdef>The address of a VMS delta time value specifying the timeout for �this read.K�<argitem>(iosb\io_status_block\longword (unsigned)\write only\by reference)-=�<argdef>I/O status block to receive the status for this call.cA�<argitem>(astadr\procedure\longword (unsigned)\call\by reference)rP�<argdef>Address of������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������C����������������������������� �����NETLIB_SRC.BCK�����������������0O�n?��[NETLIB]NETLIB_INST.SDML;9�����������������������������������������������������������������������������������������������������S���������������������������������������������*�[NETLIB]NETLIB_INST.SDML;9�+��,�0O��.�����/� �@� �4�S���������������������������-�n?����0���1����2���3������K��P���W���O�����5���6�n){��7�){��8�|"��9�V$ǘ��G� �@��H��J�����������������������N�<COMMENT>(This file processed with symbol generator: 5-NOV-1994 12:42:41.25.)���<FRONT_MATTER>(NETLIB_INST_1)��� �<TITLE_PAGE>"�<TITLE>(NETLIB Installation Guide)�<ABSTRACT>(November, 1994)B�<P>This manual describes the installation of NETLIB, a library for*�writing TCP/IP-based network applications. �<ENDABSTRACT>�&�<REVISION_INFO>(This is a new manual.)E�<REVISION_INFO>(Operating System and Version:\VAX/VMS V5.2 or later; ��OpenVMS AXP V1.0 or later).�<REVISION_INFO>(Software Version:\NETLIB V2.0)6�<ENDTITLE_PAGE>(Matthew Madison<LINE>MadGoat Software)���<COPYRIGHT_PAGE>�<PRINT_DATE>(17 November 1994)C�<p>Permission is granted to copy and redistribute this document for��no commercial gain.�H�<P>The information in this document is subject to change without notice :�and should not be construed as a commitment by the author.9�The author assumes no responsibility for any errors that ��may appear in this document.H�<p><emphasis>(DISCLAIMER:\bold) The author, the author's employer, and?� MadGoat Software make no representations or warranties with�A� respect to the contents hereof and specifically disclaim any�Q� implied warranties of merchantability or fitness for any particular purpose.�S�<P>AXP, DEC, VAX, VMS, and OpenVMS are trademarks of Digital Equipment Corporation.�8�<P>UNIX is a trademark of Unix System Laboratories, Inc.'�<P>MultiNet is a trademark of TGV, Inc.�:�<P>TCPware is a trademark of Process Software Corporation.7�<P>PathWay is a trademark of The Wollongong Group, Inc.�>�<COPYRIGHT_DATE>(1994\MadGoat Software. All Rights Reserved.)�<ENDCOPYRIGHT_PAGE>��<CONTENTS_FILE>��<PREFACE>(\NETLIB_INST_2)��<P>�H�There are several TCP/IP packages available for VMS systems today. EachJ�provides a VMS-style programming interface, using the $QIO system service,E�and most also provide a <quote>(socket) programming library, based on�0�the communications model developed for BSD UNIX.E�Unfortunately, there is no standard among all of the packages for the�G�$QIO-based programming interface (most, but not all, emulate Digital's,�B�at least to some degree), and the $QIO-based interface is not very �easy to use.�<P>�D�The socket libraries provided with these packages provide a somewhatL�easier-to-use programming interface, but don't permit VMS-style asynchronousG�programming (using ASTs), and generally require at least a re-LINK, and�E�sometimes source modifications, when moving from one vendor's library� �to another.��<P>�E�NETLIB was originally developed to support MadGoat Software's Message�I�Exchange mail package, which needed to support many TCP/IP packages doing�L�VMS-style asynchronous programming. NETLIB provides a consistent, VMS-styleF�interface for TCP/IP-based network programs, operating with all of theE�currently available TCP/IP packages available today for VMS (with one�@�minor exception). In addition, NETLIB allows for flexibility inA�in the use of a TCP/IP package, by selecting the vendor-dependent�0�library code at run-time, rather than link-time.��(�<head1>(Intended Audience\NETLIB_INST_3)7�<p>This manual is intended for system managers or users�1�responsible for installing and setting up NETLIB.�)�<head1>(Document Structure\NETLIB_INST_4)�C�<p>This document consists of two chapters. Chapter 1 describes the�E�installation of NETLIB, the network interface library used by NETLIB.�A�Chapter 2 describes the installation and configuration of NETLIB.���(�<head1>(Related Documents\NETLIB_INST_5)H�<p>The <emphasis>(NETLIB Programmer's Guide) describes how to use NETLIB1�and provides descriptions of the NETLIB routines.��� �<ENDPREFACE>�<ENDFRONT_MATTER>�4�<CHAPTER>(Preparing to Install NETLIB\NETLIB_INST_6)�<P>�I�This chapter describes the steps that should be taken prior to installing��NETLIB.���-�<HEAD1>(Prerequisite Software\NETLIB_INST_11)��<P>�E�NETLIB requires VAX/VMS V5.2 or later, or any version of OpenVMS AXP.�9�It supports any of the following TCP/IP packages for VMS:��<table>��<table_setup>(2\30)�0�<table_row>(CMU TCP/IP\(VAX only) V6.5 or later)6�<table_row>(DEC TCP/IP Services for VMS\V2.0 or later):�<table_row>(PathWay from The Wollongong Group\any version)B�<table_row>(TCPware from Process Software Corporation\any version)%�<table_row>(TGV MultiNet\any version)� �<endtable>@�<P>The target packages do not have to be installed or running onA�the system in order for NETLIB to be installed; however, you must�B�be running the target package before any NETLIB-based applications�are run.*�<head1>(VMScluster Support\NETLIB_INST_12)�<P>�E�NETLIB supports all VMScluster configurations. For mixed VAX and AXP�G�cluster configurations, you must install NETLIB twice, once for VAX and�D�once for AXP. Different directories must be used for each platform.�<P>�G�If you are running different TCP/IP packages on different nodes in your�F�cluster, you can still install NETLIB just once (once per platform for-�mixed VAX/AXP clusters) and select all of the�C�TCP/IP packages you use for the one installation. Follow the steps�B�described in <reference>(postinstall) to modify the NETLIB startupD�procedure for selecting the appropriate TCP/IP support on a per-node�basis.1�<head1>(Installation Requirements\NETLIB_INST_13)�+�<P>NETLIB requires the following resources:��<list>(unnumbered)D�<le>Approximately 3,000 (VAX) or 4,000 (AXP) free disk blocks on theH�installation working device (the system disk, or the device specified in�the AWD option for VMSINSTAL).B�<le>Approximately 1,000 disk blocks after installation on the diskJ�where NETLIB is installed for common files, plus an additional 50 (VAX) or2�(100) AXP disk blocks per TCP/IP package selected.5�<le>If NETLIB is installed system-wide, you will need�@�3 global sections and 14 (VAX) or 112 (AXP) global pages for theA�common NETLIB transfer vector library, plus 3 global sections and�I�approximately 50 (VAX) or 210 (AXP) global pages for each TCP/IP-specific��library.E�<le>Approximately 5 to 20 mintues for installation time, depending on�#�system type and installation media.�C�<le>If you are running CMU TCP/IP, the SYSGEN parameter MAXBUF must��be set to at least 2300. �<endlist>���%�<HEAD1>(Release Notes\NETLIB_INST_14)�E�<p>NETLIB is provided in a distribution kit suitable for installation�H�with VMSINSTAL. The release notes in the A save set of the distributionD�kit describe installation requirements for NETLIB. You can retrieve2�the release notes by using OPTIONS N on VMSINSTAL: �<interactive>�A�<s>($ )<u>(@SYS$UPDATE:VMSINSTAL NETLIB020 load-device OPTIONS N)��<endinteractive>?�<p>where <emphasis>(load-device) represents the location of the��NETLIB installation kit.��6�<chapter>(Installing NETLIB System-wide\NETLIB_INST_8)K�<P>This chapter describes the NETLIB installation process for a system-wide��NETLIB installation.;�<HEAD1>(Invoking the Installation Procedure\NETLIB_INST_15)�4�<P>NETLIB is installled using the VMSINSTAL utility: �<interactive>�7�<s>($ )<u>(@SYS$UPDATE:VMSINSTAL NETLIB020 load-device)��<endinteractive>F�<p>where <emphasis>(load-device) represents the location of the NETLIB�installation kit.�1�<SUBHEAD1>(Insta������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������D����������������������������� �����NETLIB_SRC.BCK�����������������0O�n?��[NETLIB]NETLIB_INST.SDML;9�����������������������������������������������������������������������������������������������������S������������������������������I�������������llation Questions\NETLIB_INST_16)��<p>�?�The NETLIB installation procedure will ask you for a device and�J�directory specification for the location where NETLIB should be installed,J�and will ask you to select the TCP/IP package support you want to install.M�The procedure attempts to select automatically the appropriate TCP/IP support��for your system.F�<P>You will next be asked to specify a directory into which the NETLIBI�libraries will be installed. If NETLIB is already installed and started,�D�the installation procedure will provide the current NETLIB directoryJ�location as the default answer; otherwise, it will use SYS$COMMON:[SYSLIB]E�as the default. If the directory you specify does not already exist,�1�it will be created by the installation procedure.�A�<P>After selecting a directory, you will be asked if you want the�E�NETLIB programming support files and documentation installed. If so,�F�you will be asked for a directory into which the documentation will beL�placed (the programming support files go into the NETLIB library directory).<�<P>Once all questions, the appropriate binaries (VAX or AXP)E�are loaded, and the requested libraries are created and moved to the �C�directory you specified. If you elected to install the programming�B�support and/or documentation, those files will be loaded and moved!�into the appropriate directories.���,�<HEAD1>(Post-Installation Steps\postinstall)J�<P>If you have installed NETLIB with support for multiple TCP/IP packages,K�you should review the startup command procedure created by the installation�L�to ensure that the correct TCP/IP support has been selected. For VMSclusterF�environments, you should customize the startup procedure to select the9�appropriate TCP/IP support for each node in your cluster.�G�<P>The name of the startup procedure is SYS$STARTUP:NETLIB_STARTUP.COM.�K�TCP/IP support is selected through the definition of the NETLIB_SHR logical�G�name. The translation strings for selecting a TCP/IP package are shown��in <reference>(trstr_table).&�<table>(NETLIB_SHR Values\trstr_table)�<table_setup>(2\30)�9�<table_heads>(Translation String\TCP/IP Package Selected)�1�<table_row>(NETLIB_DIR:NETLIB_CMU_SHR\CMU TCP/IP)�8�<table_row>(NETLIB_DIR:NETLIB_MULTINET_SHR\TGV MultiNet)6�<table_row>(NETLIB_DIR:NETLIB_PATHWAY_SHR\TWG PathWay)6�<table_row>(NETLIB_DIR:NETLIB_TCPWARE_SHR\PSC TCPware):�<table_row>(NETLIB_DIR:NETLIB_UCX_SHR\DEC TCP/IP Services) �<endtable>'�<head2>(Starting NETLIB\NETLIB_INST_18)�C�<p>Once NETLIB has been installed, it should be started by invoking��its startup command procedure: �<interactive>�'�<s>($ )<u>(@SYS$STARTUP:NETLIB_STARTUP)��<endinteractive>:�<p>This should be done from a suitably privileged account.>�This invocation of NETLIB_STARTUP should also be added to your!�system startup command procedure.���>�<CHAPTER>(Installing NETLIB for Personal Use\personal_install)D�<P>If you are not a system manager but still want to use NETLIB, youD�can install a copy of NETLIB for your own personal use. To do this,;�create a temporary working directory and SET DEFAULT to it:� �<interactive>�$�<s>($ )<u>(CREATE/DIRECTORY [.TEMP])�<s>($ )<u>(SET DEFAULT [.TEMP])��<endinteractive>E�<p>Next, unload the contents of the NETLIB save sets into the working�5�directory. All installations require the A save set:� �<interactive>�0�<s>($ )<U>(BACKUP disk:[dir]NETLIB020.A/SAVE [])�<endinteractive>1�<P>For VAX systems, you will need the B save set:� �<interactive>�0�<s>($ )<U>(BACKUP disk:[dir]NETLIB020.B/SAVE [])�<endinteractive>1�<P>For AXP systems, you will need the C save set:� �<interactive>�0�<s>($ )<U>(BACKUP disk:[dir]NETLIB020.C/SAVE [])�<endinteractive>3�<P>Next, invoke the user-install command procedure:� �<interactive>� �<S>($ )<U>(@NETLIB_USER_INSTALL)�<endinteractive>C�<p>Answer the questions from the installation script and the NETLIB�D�files will be created. Once the installation procedure is complete,3�you can delete the files and the working directory:� �<interactive>��<s>($ )<u>(SET DEFAULT [-])��<s>($ )<u>(DELETE [.TEMP]*.*;*)�*�<s>($ )<U>(SET PROTECTION=O:RWED TEMP.DIR)�<S>($ )<U>(DELETE TEMP.DIR;)�<ENDINTERACTIVE>�<P>�B�If you want to use the programming support files or documentation,5�use BACKUP to retrieve them from saveset NETLIB020.D.���3�<head1>(Personal NETLIB Restriction\NETLIB_INST_10)�G�<p>You cannot use a personal NETLIB with NETLIB-based applications that��are installed with privileges.����+�<chapter>(On-Line Documentation\online_doc)��<P>�H�The NETLIB documentation set is provided in a form suitable for use withD�the VMS DECwindows Bookreader program (VMS V5.3 and later). To makeL�the NETLIB on-line documentation available automatically through Bookreader,H�you should add a reference to the directory containing the documentationF�(if you elected to install those files) to the DECW$BOOK logical name.��+�<appendix>(CMU TCP/IP Considerations\cmuip)��<P>�F�All of the TCP/IP packages that NETLIB supports, with the exception ofF�CMU TCP/IP, are already based on the Berkeley socket model for networkL�programming, and all except CMU use the BIND (Berkeley Internet Name Daemon)/�software for performing domain name resolution.��<head1>(DNS Resolver\cmudns)I�<P>Emulating sockets over CMU TCP/IP is not difficult, but due to the way�L�the CMU name resolver, NAMRES, is implemented, performing BIND-style queriesH�requires some additional setup over the other TCP/IP packages. The listG�of DNS servers that NAMRES uses is not available to NETLIB, so you must�C�define an additional logical name for NETLIB's DNS_QUERY routine to��be used: �<interactive>�/�<S>($ )<U>(DEFINE NETLIB_NAMESERVERS "x.x.x.x")��<ENDINTERACTIVE>F�<P>Where <quote>(x.x.x.x) is the dotted-decimal IP address of the nameL�server that DNS_QUERY should use. You may specify more than one nameserver,J�by defining NETLIB_NAMESERVERS as a search-list logical name. The logicalG�name should be defined in the system logical name table to be available��to all users on the system.��� �<head1>(Bypassing NAMRES\bypass)�<p>�G�By default, NETLIB's support for the CMU TCP/IP package uses the native�I�NAMRES for all name and address lookups (routines NETLIB_NAME_TO_ADDRESS,�<�NETLIB_ADDRESS_TO_NAME, and NETLIB_DNS_MX_LOOKUP). However,H�you can configure NETLIB to bypass NAMRES and use NETLIB's name resolver.�routines instead by defining the logical name:�� �<INTERACTIVE>�6�<S>($ )<U>(DEFINE NETLIB_BYPASS_CMU_RESOLVER anyvalue)�<ENDINTERACTIVE>H�<P>The NETLIB_NAMESERVERS logical name <emphasis>(must also) be defined.F�If the above logical name is defined, NETLIB will automatically bypass9�NAMRES and use its own resolver routines for all lookups.�O�<P>Please note that NETLIB's name resolver, unlike NAMRES, <emphasis>(does not)�N�cache the results it gets (this is typical behavior for BIND-style resolvers).J�Bypassing NAMRES, therefore, can increase network traffic for DNS lookups.?�For this reason, when using bypass mode, you should ensure that�O�NETLIB_NAMESERVERS references only name servers that are on your local network.�G�<P>In addition, bypassing NAMRES will cause name lookups to be resolved�B�<emphasis>(only) through the Domain Name System. Local host table"�definitions will not be available. �<endappendix>������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������E����������������������������� �����NETLIB_SRC.BCK�����������������;|��n?��[NETLIB]NETLIB020.SDML;12������������������������������������������������������������������������������������������������������[���������������������������������������������*�[NETLIB]NETLIB020.SDML;12�+��,�;|���.�����/� �@� �4�[������ ���������������������-�n?����0���1����2���3������K��P���W���O�����5���6�^ɕʘ��7�^Tɕʘ��8�^Ti8��9����������G� �@��H��J�����������������������<DEFINE_SYMBOL>(ver\V2.0C)�<FRONT_MATTER>�� �<TITLE_PAGE>�<TITLE>(NETLIB Release Notes)��<ABSTRACT>(February, 1995)G�<P>This file contains the release notes for the NETLIB TCP/IP interface�J�library. It describes any last-minute features, restrictions, changes, or�additions made to NETLIB.� �<ENDABSTRACT>�*�<REVISION_INFO>(This is a revised manual.)D�<REVISION_INFO>(Operating System and Version:\VAX/VMS V5.2 or later;$� OpenVMS AXP V1.0 or later):�<REVISION_INFO>(Software Version:\NETLIB <REFERENCE>(VER))6�<ENDTITLE_PAGE>(Matthew Madison<LINE>MadGoat Software)���<COPYRIGHT_PAGE>�<PRINT_DATE>(28 February 1995)D�<p><emphasis>(DISCLAIMER:\bold) The author, the author's employer,C� and MadGoat Software make no representations or warranties with�A� respect to the contents hereof and specifically disclaim any�Q� implied warranties of merchantability or fitness for any particular purpose.�[�<P>AXP, DEC, ULTRIX, VAX, VMS, and OpenVMS are trademarks of Digital Equipment Corporation.�8�<P>UNIX is a trademark of Unix System Laboratories, Inc.'�<P>MultiNet is a trademark of TGV, Inc.�:�<P>TCPware is a trademark of Process Software Corporation.7�<P>PathWay is a trademark of The Wollongong Group, Inc.�D�<COPYRIGHT_DATE>(1994, 1995\MadGoat Software. All Rights Reserved.)�<ENDCOPYRIGHT_PAGE>��<CONTENTS_FILE>��<ENDFRONT_MATTER>���&�<chapter>(Updates in <reference>(ver))B�<p><reference>(ver) is a maintenance update to V2.0 which includes�the following changes:�<list>(numbered)J�<le>The TCP_DISCONNECT V1-compatibility routine now ignores SS$_LINKDISCONM�errors coming back from NETLIB_SHUTDOWN. The original V1 routine ignored the�J�status in the IOSB, which, for CMU TCP/IP, can be an error status when theI�connection has been closed by the remote side. This fixes the LINKDISCON�:�error problems during transfers using MGFTP on CMU TCP/IP.H�<le>For NETLIB_CONNECT calls on UDP sockets with CMU TCP/IP, the connect �is now faked.�B�<le>Fixed missing argument on a couple of $DCLAST calls in the CMU�and UCX interfaces.� �<endlist>�6�<p>The following changes from V2.0B are also included:�<list>(numbered)G�<le>NETLIB_CONNECT_BY_NAME logic for async connects wasn't quite right.�K�<le>Fixed NETLIB_WRITE in UCX interface to treat 0-length writes specially.�G�<le>Fixed NETLIB_READLINE to correctly handle the case where a carriage�1�return is not immediately followed by a linefeed.� �<endlist>�6�<p>The following changes from V2.0A are also included:�<list>(numbered)J�<le>NETLIB_READLINE has been changed to read data in chunks no larger thanI�1,024 bytes, to prevent EXQUOTA and INSFMEM errors when using CMU TCP/IP.�B�<le>Some typos in $QIO calls in the UCX interface have been fixed.N�<le>Some typos in $CANTIM calls in the UCX and CMU interfaces have been fixed.3�<le>Some V1-compatibility problems have been fixed.�1�<le>A NETLIB_READLINE parsing bug has been fixed.�E�<le>The MUTEX-wait (running out of TQEs) problem in the CMU interface��has been fixed.� �<endlist>����<chapter>(New Features)�:�<p>This chapter describes the features new to NETLIB V2.0.�<Head1>(Major Changes)A�<P>NETLIB V2.0 is a complete rewrite, from scratch, of the entire��library.�<subhead1>(New Implementation)B�<P>It has been rewritten in C, and now includes a fully-documentedD�programming interface. The V1 programming interface continues to beE�supported for compatibility with older NETLIB-based applications, but�E�is not documented. All new applications should use the documented V2� �interface.%�<subhead1>(New Programming Interface)�I�<P>The new programming interface for V2.0 is oriented toward socket-style�H�programming. All routines that perform network I/O can be called eitherF�synchronously or asynchronously, with asynchronous completion signaledE�by delivery of an AST. Specifying a non-zero AST address on a NETLIB�7�call indicates that asynchronous completion is desired.���&�<subhead1>(Support for Forked Servers)A�<P>Since all TCP/IP packages now include a <quote>(master server)�F�process that can fork off server processes on a per-port basis, NETLIBG�now includes a NETLIB_SERVER_SETUP routine for use when writing servers�6�that should be invoked from a package's master server.���<subhead1>(Documentation)�N�<P>The installation kit now includes documentation in PostScript, plain ASCII,M�and BookReader formats. All files are installed in the NETLIB_DIR directory.���6�<head1>(Support Discontinued for Some TCP/IP Packages)N�<P>With the V2.0 release, support has been dropped for CMU-Tek TCP/IP V6.4 andE�DEC VMS/ULTRIX Connection (UCX) V1.x. Users of these packages should� �upgrade to more recent releases.��0�<head1>(Support Discontinued for VMS V5.0, V5.1)J�<p>NETLIB V2.0 requires VAX/VMS V5.2 or later. This change was necessary I�because some NETLIB routines supporting DEC TCP/IP Services call routines�A�that were not added to the VAX C Run-Time Library until VMS V5.2.���#�<chapter>(Known Bugs, Restrictions)��<P>�E�There are no known bugs in NETLIB. Known restrictions are documented�8�in the programmer's guide, with the following exception:�<list>(unnumbered)I�<LE>You may only have one call to NETLIB_WRITELINE outstanding at a time,�M�in order to ensure proper ordering of outgoing data with all TCP/IP packages.� �<ENDLIST>�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������