OpenVMS Source Code Demos

wcsm_tcp_support_109

	!========================================================================================================================
	! title      : [.inc]WCSM_TCP_support_108.inc
	! author     : Neil Rieck
	! created    : 2014-08-15
	! history    :
	! ver who when   what
	! --- --- ------ --------------------------------------------------------------------------------------------------------
	! 108 NSR 140905 1. derived from TCPIP$TCP_CLIENT_QIO_2014E.INC
	! 109 NSR 140930 1. added a declaration for nsr_dns_ghnt (get host name + type)
	!========================================================================================================================
	!
	!	system references
	!
	%include "starlet"	%from %library "sys$library:basic$starlet"	! system services
	%include "$ssdef"	%from %library "sys$library:basic$starlet"	! ss$
	%include "$iodef"	%from %library "sys$library:basic$starlet"	! io$
	%include "$efndef"	%from %library "sys$library:basic$starlet"	! efn$
	%include "lib$routines"	%from %library "sys$library:basic$starlet"	! lib$
	%include "$libdef"	%from %library "sys$library:basic$starlet"	! eg. lib$_normal
	%include "$dscdef"	%from %library "sys$library:basic$starlet"	! descriptor stuff
	%include "$iledef"      %from %library "sys$library:basic$starlet"      ! ile3$ (Item List Entry 3 structures)
!~~~	%include "sys$common:[tcpware.include]ucx$inetdef.h"			x candidate for conversion to BASIC
!~~~    %include "sys$library:ucx$inetdef.bas"                                  x ucx defs   (for tcpip <  v5.0)
        %include "sys$library:tcpip$inetdef.bas"                                ! tcpip defs (for tcpip >= v5.0)
!~~~	%include "$iosbdef"     %from %library "sys$library:basic$starlet"	x iosb$ (iosb structures)
	!
	!	I need the following iosb to get around a limitation found in the BASIC version of starlet
	!	(the library definition of sys$qio requires a quad datatype for iosb)
	!
	!	question : How did I know?
	!	answer   : Hacking
	!	reference: https://neilrieck.net/docs/openvms_notes_hacking_starlet.html
	!
	record my_iosb_rec							!
	    variant								!
		case								! vanilla
		    group a							!
			word		iosb$w_status				!
			word		iosb$w_bcnt				!
			long		iosb$l_dev_depend			!
		    end group							!
		case								! used in sys$getqui
		    group b							!
			long		iosb$l_getxxi_status			!
			long		iosb$l_reserved				!
		    end group							!
		case								! used to satisfy the compiler
		    group c							!
			basic$quadword	iosb$bqw_quad				!
		    end group							!
		case								!
		    group d							!
			word		iosb$w_words(3)				! 0-3; easier to pass this on the stack
		    end group							!
		case								!
		    group e							!
			quad		iosb$q_quad				! easier to pass this on the stack
		    end group							!
	    end variant								!
	end record								!
	!
	record sc_rec								! socket characteristics
	    variant
		case
		    group a
			word	sc$w_prot					! protocol
			byte	sc$b_type					! type
			byte	sc$b_af						! address family
		    end group							!
		case								!
		    group b							!
			word	sc$w_words(1)					! 0-1; easier to pass this on the stack
		    end group							!
		case
		    group c							!
			quad	sc$q_quad					!
		    end group							!
	    end variant								!
	end record 								!
	!
	record my_itmlst2_rec							! item-list 2 descriptor
	    word	il2$w_length						! length
	    word	il2$w_type						!
	    long	il2$l_address						!
	end record								!
	!
	!	NCV ("NSR Connection Variables" a.k.a. "Network Connection Variables")
	!
	!	think object - although such a concept is not possible with this BASIC
	!
	record ncv_rec								!
	    long		tcp_ef						!
	    long		tcp_ef_state					!
	    long		tmr_ef						!
	    long		tmr_ef_state					!
	    long		mask						!
	    long		ip_address					!
	    word		tcp_port					!
	    word		vms_channel					!
	    long		nvt_cycle					!
	    long		nvt_total_msgs_received				!
	    long		nvt_total_bytes_sent				!
	    my_iosb_rec		iosb						! i/o status block
	    sc_rec 		cscb						! connection socket characteristics buffer
	    variant								! serv_addr block
		case								!
		    group a							!
			SOCKADDRIN	serv_addr				! server socket address from inet structure
		    end group							!
		case								!
		    group b							!
			quad		ccb$q_quad				!
		    end group							!
		case								!
	    end variant	    							!
	    my_itmlst2_rec	serv_itemlst					!
	end record								!
	!
	!	octet stuffing is more efficient than doing 32-bit math
	!	(if we ever go to IPv6 then it may be the only way forward)
	!
	record stuffer32_rec							!
	    variant
		case
		    group a
			long	long_offset00	! octet 0 stuffs here
			long	fill		!
		    end group
		case
		    group b			!
			byte	fill		! octet 1 stuffs here
			long	long_offset08	!
			byte	fill		!
			byte	fill		!
			byte	fill		!
		    end group
		case
		    group c			!
			byte	fill		!
			byte	fill		!
			long	long_offset16	! octet 2 stuffs here
			byte	fill		!
			byte	fill		!
		    end group
		case
		    group d			!
			byte	fill		!
			byte	fill		!
			byte	fill		!
			long	long_offset24	! octet 3 stuffs here
			byte	fill		!
		    end group			!
		case
		    group e			!
			quad	quad0		! quad pulled from here
		    end group			!
	    end variant
	end record
	!
	!	home brewed code
	!
!	external long function htonl(long)					x host to network long
!	external long function htons(word)					x host to network short
!	external long function qtol(quad)					x quad to long
	external long function get_ef_bit_vector(long)				! required for used with SYS$WFLOR
	!
	external long function nsr_tcp_prep(long, ncv_rec						)
	external long function nsr_tcp_open(long, ncv_rec, long, word, string				)
	external long function nsr_tcp_send(long, ncv_rec, string, long, string				)
	external long function nsr_tcp_recv(long, ncv_rec, string, long, long, string			)
	external long function nsr_tcp_clos(long, ncv_rec						)
	external long function nsr_tcp_free(long, ncv_rec						)
	external long function nsr_dns_prep(long, ncv_rec						)
	external long function nsr_dns_ghbn(long, string, long, string, long dim() by ref, string	)
	external long function nsr_nvt_scan(long, ncv_rec, string, long, string, string, long, long	)
	external long function nsr_adr_prep(long,string,string,long					)
	external long function nsr_dns_ghnt(long, string, string, long, string, long dim() by ref, string)
	!
	!=========================================================================================================================
	! title  : [.inc]wcsm_tcp_nvt_definitions_108.inc
	! author : Neil Rieck
	! created: 2007-07-30
	! history:
        ! ver who when   what
        ! --- --- ------ ---------------------------------------------------------------------------------------------------------
        ! 100 NSR 070730 1. original effort (dervived from file "csmis$dvlp:nvt_definitions.inc")
	!=========================================================================================================================
	!
	!	see RFC-764, RFC-731 and RFC-854
	!	notes:
	!	    1. this is a partial list
	!	    2. used a "k" prefix ("k"=constant because "c"=char; maybe we should use "t"=TELNET).
	!	    3. Google this string for more information: "telnet iac sb se 250 240 nvt"
	!	    4. some of these numbers came from telnet.h (8.2 Berkeley)
	!
	declare long constant	kWILL		= 251	,! Sender "requests to begin" or "confirms" something	&
				kWONT		= 252	,! Demands to stop or not start something		&
				kDO		= 253	,! Requests other side to begin or confirm		&
				kDONT		= 254	,! Demands other side to stop				&
				kIAC		= 255	,! I/nterpret A/s C/ommand				&
				kSB		= 250	,! sub command						&
				kGA		= 249	,! go ahead (roger; you may reverse the line)		&
				kNOP		= 240	,! no operation						&
				kSE		= 240	,! sub end						&
				kEOR		= 239	,! end-of-record					&
				kBINARY		= 0	,! binary transmission					&
				kECHO		= 1	,!							&
				kRECCONECTION	= 2	,!							&
				kSGA		= 3	,! supress go-ahead					&
				kMSG_SIZ_NEG	= 4	,! approx message size negotiation			&
				kSTATUS		= 5	,!							&
				kTIMING_MARK	= 6	,!							&
				kEXTENDED_ASCII = 17	,!							&
				kLOGOUT		= 18	,!							&
				kBM		= 19	,! Byte Macro						&
				kDET		= 20	,! Data Entry Terminal					&
				kSUPDUP     	= 21	,!							&
				kSUPDUP_OUT	= 22	,!							&
				kSEND_LOCATION	= 23	,!							&
				kTERM_TYPE	= 24	,!							&
				kOPTION_EOR	= 25	,! end-of-record (the option number, not the signal)	&
				kTUID		= 26	,! TACACS user identification				&
				kOutput_Marking	= 27	,!							&
				kTerm_Loc_Number= 28	,!							&
				kWINDOW_SIZE	= 31	,! a.k.a. NAWS (negotiate about window size)		&
				kTERM_SPEED	= 32	,!							&
				kREMOTE_FLOW_CTL= 33	,!							&
				kLINE_MODE	= 34	,!							&
				kXDISPLAY_LOC	= 35	,!							&
				kOLD_ENVIRON	= 36	,!							&
				kAUTHENTICATION	= 37	,!							&
				kNEW_ENVIRON	= 39	,!							&
				kTN3270E	= 40	,!							&
				kSEND		=  1	,! SEND TT (RFC-1091)					&
				kIS		=  0	 ! IS   TT (RFC-1091)
	!=========================================================================================================================

home Back to Home
Neil Rieck
Waterloo, Ontario, Canada.