OpenVMS Source Code Demos

decode_sys$rem_id.com

$! =============================================================
$! title  : decode_hex_addr.com
$! author : Neil Rieck
$! created: 2023-12-21
$! purpose: a tool needed to diagnose a connection fubar
$! Notes  :
$! 1) tested with MultiNet on OpenVMS-8.4 for Itanium
$! 2) should work with TCPware or "TCPIP Services for OpenVMS"
$! =============================================================
$ set noon
$ say :== write sys$output
$ ask :== inquire/nopunct
$ remid = "init"
$ remid = f$trnlnm("SYS$REM_ID")
$ if remid .eqs. "init"
$ then
$     remid = "8EB4DDF3:E9BA"
$     say "-i-"SYS$REM_ID" was blank so using : ",remid
$ else
$     say "-i-current value of SYS$REM_ID is ",remid
$ endif
$!==============================================================
$ strlen = f$length(remid)
$ colon = f$locate(":",remid)
$ if (colon .eq. strlen)
$ then
$	say "-w-colon not found so exiting"
$	exit
$ else
$	addr = f$extract(0,colon,remid)
$	port = f$extract(colon+1,strlen-colon,remid)
$ endif
$!==============================================================
$!	paste the folowing code in your inbound script
$!==============================================================
$ loop:
$ if (f$length(addr) .lt 8)
$ then					! must be on 10 network 
$	addr = "0" + addr
$	goto loop
$ endif
$ say "-i-hex-addr: ",addr," hex-port: ",port
$ if (f$length(addr) .eq. 8)
$ then
$	say "-i-performing IPv4 conversion"
$	stub1 = f$extract(0,2,addr)
$	stub2 = f$extract(2,2,addr)
$	stub3 = f$extract(4,2,addr)
$	stub4 = f$extract(6,2,addr)
$	ipv4 =  f$string(%X'stub1') +"."+ f$string(%X'stub2') +"."+ f$string(%X'stub3') +"."+ f$string(%X'stub4')
$	say "-i-ipv4: ",ipv4
$ endif
$ exit