	.TITLE NTCONB
	.ENABLE LC
	.IDENT /060188/

;
;	File:[22,310]NTCONB.MAC
;	Author: Jim Bostwick   1-JUN-1988 
;	History: 
;
;	Last Edit: jmb -  1-JUN-1988 17:48:13
;

.REM |

Procedure NTCONB (
	node: Ch6;
	obj: byte;
	task: packed array [lo..hi] of char	
	VAR conb: Net_Request_block;
	VAR Stat: Integer; 
	);External;

{*USER*
 Builds a network connect block in CONB. The connect block is in a format
suitable for DECnet - no attempt has been made to map it's contents to 
Pascal. 
 NODE specifies the remote node name. 
 OBJ is the remote object number to be connected to. Specify 0 (zero) for 
named objects, or an object number (1..255). If OBJ is zero, TASK must
be specified. 
 TASK is the remote task name for OBJ=0 connections. It is ignored if OBJ
is not zero. Although specified as a conformant array parameter, TASK 
must be less than or equal to 16. characters. 
} 

{*WIZZARD*
 No access control information is provided by this procedure. It is assumed
that all network tasks will use network aliases, thus moving the access
control  out of the program and into the alias definitions. 

 Although no record definition for the connect block exists, masochists may
crack the thing using the offsets defined in the CONL$$ section of the 
MACRO-11 section of the DECNET-RSX Programmer's Reference Manual.
The information in this section may also be used to manually initialize
the user access information fields in the connect block. 

 The 'short' connect block formats are not supported.  
}

|

;
; Assemble with PASMAC.MAC as prefix file.
;

	.library /lb:[1,1]netlib.mlb/
	.mcall CRBDF$

	CRBDF$				; define connect block offsets

	PROC NTCONB
	PARAM NODE, 6*CHAR		; node name (ch6)
	PARAM OBJ, CHAR			; object number (BYTE)
	PARAM TASK, Address		; task name string address
	PARAM tasklo, Integer		; lo bound
	PARAM taskhi, Integer		; hi bound
	PARAM conb, Address		; connect block
	PARAM status, Integer		; return status

	SAVE <R0,R1,R2,R3>
	BEGIN
	mov	conb(sp), r0		; r0-> conb
	mov	sp, r1			; r1 -> node string
	add	#node, r1		; 
	mov	#6, r2			; count
	mov	r0, r3			; r3 -> node in conb
	add	#n.rnd, r3		;

10$:	movb	(r1)+, (r3)+		; copy node name
	sob	r2, 10$

	clrb	M.RFM(r0)		; assume format 0 (obj <> 0)
	movb	obj(sp), M.ROT(r0)	; copy object number
	bne	100$			; if ne, skip task name

	incb	M.RFM(r0)		; obj=0 ==> format 1
	mov	sp, r1			; r1 -> task name
	add 	#task, r1		; 
	tst	tasklo(sp)		; Type-0?
	beq	50$			; yes - br

	; process type-1 name string
	mov	r1, r3		
	add	taskhi(sp), r3		; point past end
	inc	r3
	mov	taskhi(sp), r2		; set count

20$:	tstb	-(r3)			
	bne	60$			; done - br
	sob	r2, 20$			; drop count
	movb	#-1, @status(sp)	; must have length - 
					; return IE.BAD
	br	errout			; quit

50$:	; process type-0 name string
	movb	(r1)+, r2		; r2 = length, and skip length byte
	bic	#^C377, r2		; zap high byte
	cmp	#16., r2		; within specs?
	bhis	60$			; yes - br
	mov	#-1, @status(sp)	; return IE.BAD
	br	errout			; and quit

60$:	; common copy loop
	mov	r0, r3			; r3 -> conb
	mov	r2, M.RDEC(r3)		; stuff task name length
	add	#M.RDE, r3		; r3 -> task name in conb

70$:	movb	(r1)+, (r3)+		; copy task name to conb
	sob	r2, 70$

100$: 	; zap unused accounting fields
	add	#m.ridc, r0		; r0-> access info area
	mov	#<<40.+m.rac-m.ridc>/2>, r2	; r2 = word count

110$:	clr	(r0)+			; clear access area
	sob	r2, 110$

	mov	#1, @status(sp)		; show success (clears carry)
	br	done

errout:	sec

done:	
	ENDPR

	.END

