	.TITLE	CHKNETDEV	- Check for Network Devices
	.IDENT	'V4.1'

;++
; FACILITY:	WATCHDOG
;
; ABSTRACT:	Search I/O Database for Network Devices (_NET***)
;
; ENVIRONMENT:	native/kernal mode, privileged code
;
; AUTHOR:	 
;	George H. Walrod III	CREATION DATE: 17-MAR-1986
;
; MODIFICATION HISTORY:
;	None
;
;	CALLS/G	CHKNETDEV
;
; INPUT PARAMETERS:
;	4(AP)	Address of Longword for Index Type Pid
;
; OUTPUT PARAMETERS:
;	R0	Status of Call	- Longword
;
; IMPLICIT OUTPUTS:
;	NONE
;
; COMPLETION CODES:
;	NONE
;
; SIDE EFFECTS:
;
;--
	.LIBRARY	/SYS$LIBRARY:LIB.MLB/

	.psect	pure,nowrt,noexe
net_device:
	.ascii	/NET/
net_length = . - net_device

	.psect	data,wrt,noexe
status:	.blkl	1
ipid:	.blkl	1

	.psect	code,exe,nowrt,rd
chknetdev::
	.word	0
	movl	@4(ap),ipid
	$CMKRNL_S	-
		routin = chkdevinfo, -
		arglst = #0
	movl	status, r0
	ret

chkdevinfo::
	.word	^m<r2,r3,r4,r5,r9,r10,r11>
	dsbint	#ipl$_astdel		; Raise IPL to Astdel to Access DB
	movl	#ss$_nopriv,status	; Set Bad Status
	movl	g^ioc$gl_devlist,r11	; Set first DDB
10$:
	cvtbl	ddb$t_name(r11),r9
	cmpc5	r9,	 -		; Check the Device
		ddb$t_name+1(r11), -
		#0,		-
		#net_length,	-
		net_device
	beql	20$			; That do Match	
	tstl	ddb$l_link(r11)		; Was That the Last DDB
	beql	100$			; Yep, Sure Was
	movl	ddb$l_link(r11),r11	; Goto Next DDB
	brb	10$
20$:
	movl	ddb$l_ucb(r11),r10	; Set Ucb
30$:
	cmpl	ucb$l_pid(r10),ipid	; Does This Process Own the Device
	beql	40$			; YES!
	tstl	ucb$l_link(r10)		; Was That the Last UCB
	beql	100$			; Yep, Sure Was
	movl	ucb$l_link(r10),r10	; Goto Next DDB
	brb	30$
40$:
        movl	#ss$_normal,status	; Set Normal Status
100$:
	enbint				; Restore IPL
        movl	#ss$_normal,r0		; Come Out of Kernal Mode Clean
	ret				; That's all in Kernal Mode.
	.end
