[HECnet] VMS API for NML/NICE?

Brian Schenkenberger, VAXman- system at TMESIS.COM
Wed May 28 23:56:07 PDT 2014


"Bob Armstrong" <bob at jfcl.com> writes:

I want to write a little C program that talks to NML without, say,
spawning NCP to execute commands.       I found a specification for Phase IV
NICE, which is doable but a bit complicated.   Does anyone know if there's an
NML/NICE interface library of some kind?

================
File NML.MAR is:
================

;++
; Copyright   1992, by Brian Schenkenberger and TMESIS.   ALL RIGHTS RESERVED.
;
; This software is provided "AS IS" and is supplied for informational purpose
; only.   No warranty is expressed or implied and no liability can be accepted
; for any actions or circumstances incurred from the use of this software or 
; from the information contained herein.   The author makes no claim as to the
; suitablility or fitness of the software or information contain herein for a
; particular purpose.
;
; Permission is hereby granted *ONLY* for the "not-for-profit" redistribution
; of this software provided that ALL SOURCE and/or OBJECT CODE remains intact
; and ALL COPYRIGHT NOTICES remain intact from its original distribution.   
;
;(!) NO TITLE TO AND/OR OWNERSHIP OF THIS SOFTWARE IS HEREBY TRANSFERRED. (!)
;--
; This program uses the DECnet Network Information Command Exchange Protocol
; or NICE protocol (which it is anything but nice if you should have a chance
; to read the functional spec.)
;
; This is a quick and dirty ditty to print out the nodes which your node can
; see as active or reachable nodes.   
;
; NICE is comprised of a set of functions (LOOP, LOAD, READ, etc.) to which 
; a structure of option functions is attached.   A callable interface, the
; NML$xxx calls, facilitate the use of the NICE codes.   FYI, you can also
; open a channel to another nodes NML object and request information from it
; using NICE protocols.
; 
; I built this example with the NML$xxx calls because it facilitates the 
; disassembly of the information returned by the requested NICE command.
;
; I'm a MacroMan so naturally, this example is in Macro.   If you're one of 
; the followers of fanciful programming fad, you can probaby translate this
; into (eek) 'C' or any other HOL.
;--
; To build:
; $ MACRO NML
; $ LINK NML,SYS$INPUT/OPT
;     SYS$SHARE:NMLSHR.EXE/SHARE 
;     ^Z
;--
	.TITLE	NML

	.LIBRARY	"SYS$LIBRARY:STARLET.MLB"	; look here for...
	$DSCDEF		; defines, symbolocally, OpenVMS descriptor codes
	$LIB$ROUTINESDEF; defines macros for the OpenVMS LIB$ RTL routines

	.LIBRARY	"SYS$LIBRARY:LIB.MLB"		; look here for...
	$NMADEF		; defines, symbolically, NICE/NML function codes

	.PSECT	$$DATA,WRT,NOEXE,5

;++
; Read function options (RTFM. Sec 6.8 of DNA NML Network Mgt Spec #AA-X437A-TK)
;--
OPTION	= <NMA$C_ENT_NOD at NMA$V_OPT_ENT>!-	; Entity type = node
	  <NMA$C_OPINF_SUM at NMA$V_OPT_INF>!-	; inform type = summary
	  <0 at NMA$V_OPT_PER>			; Read volatile database
;	  <1 at NMA$V_OPT_PER>			; Read permanent database

REQST:	.ASCID	<NMA$C_FNC_REA><OPTION><NMA$C_ENT_KNO>		

	.ALIGN	QUAD
NODE:	.ADDRESS DESC
DESC:	.QUAD	0

OUTPUT:	.LONG	<DSC$K_CLASS_D@<DSC$B_CLASS at 3>>!-
		<DSC$K_DTYPE_T@<DSC$B_DTYPE at 3>>,0

FORMAT:	.ASCID	/Node: !6AS   DECnet address: !UL.!UL/

	.PSECT	$$CODE,NOWRT,EXE
	.ENTRY	START_NML,0

	CALLS	#0,G^NML$INITIALIZE	; init the NML interface

	PUSHAB	CALLBACK_ROUTINE	; addr of rtn to output data
	PUSHAB	REQST			; desc of NICE request
	CALLS	#2,G^NML$PROCESS_NICE	; call interface, process request

	CALLS	#0,G^NML$TERMINATE
	$EXIT_S
	RET
;++
; The callback routine is called by the NML$PROCESS_NICE function with 
; the address of a descriptor and will called repeatedly until all the
; information requested is exhausted.   First byte of the data described
; by the descriptor is a status byte.   The rest is data, passed in a 
; format with is unique to each NICE functional operation and is detailed
; in the functional spec.
;--

	$OFFDEF	CALLBACK_ROUTINE,DESCRIPTOR

	.ENTRY	CALLBACK_ROUTINE,0

	MOVQ	@CALLBACK_ROUTINE$_DESCRIPTOR(AP),R0
	CMPB	(R1),#NMA$_SUCCESS
	BEQL	10$
	RET

;++
; Here, as per the NML spec, the information is process... The beginning of
; the response string is formatted as such:
;
;
;                                                                         |<-- ascic node name
;                                                                         |         |<-- node number
;                                                                         |         |               |<-- status
;             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
;             |   |   |   | F| E| D| C| B| A| #|   |   |   |   |   |   |
;             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
;--

10$:	TSTL	(R1)+			; move pointer forward 4 bytes
	MOVZWL	(R1)+,R0		; get the node number
	EXTZV	#0,#7,(R1)+,DESC	; get the node name length
	MOVAB	(R1),DESC+4		; get the node name address
	
	EXTZV	#NMA$V_ADDR,#NMA$S_ADDR,R0,R1	; get the node number
	EXTZV	#NMA$V_AREA,#NMA$S_AREA,R0,R0	; get the area number

	$LIB_SYS_FAO_S	character_string = FORMAT,-
			resultant_string = OUTPUT,-
			directive_argument1 = NODE,-
			directive_argument2 = R0,-
			directive_argument3 = R1

	$LIB_PUT_OUTPUT_S	message_string = OUTPUT
	RET

	.END	START_NML

================
File NML.OPT is:
================
SYS$SHARE:NMLSHR.EXE/SHAREABLE



$ MACRO NML.MAR
$ LINK NML.MAR,NML.OPT/OPTION

-- 
VAXman- A Bored Certified VMS Kernel Mode Hacker       VAXman(at)TMESIS(dot)ORG

I speak to machines with the voice of humanity.



More information about the Hecnet-list mailing list