XMKPRD ;ISC-SF/GMB-DNS Interface ;07/11/2002 08:09
;;8.0;MailMan;;Jun 28, 2002
NEXTIPF(XMSITE,XMIPT,XMIPLIST) ; Function returns next IP address to try.
; IN:
; XMSITE - .01 field of domain in file 4.2 (not a synonym)
; XMIPT - List of IP addresses, separated by ",", already tried
; XMIPLIST - (optional) List of IP addresses, separated by ",", to try
I '$D(XMIPLIST) D
. D SHOW(42260) ;Call DNS for IP Address list ...
. S XMIPLIST=$$IPADDR(XMSITE)
. D SHOW($S(XMIPLIST="":42261,1:42262),XMIPLIST) ;Returned: Nothing!/|1|
I XMIPLIST="" Q ""
I $G(XMIPT)="" Q $P(XMIPLIST,",")
N XMJ,XMIP
F XMJ=1:1:$L(XMIPT,",") D Q:XMIP=""!(","_XMIPT_","'[(","_XMIP_","))
. S XMIP=$P(XMIPT,",",XMJ)
. D NEXTIP(.XMIP,.XMIPLIST)
Q XMIP
IPADDR(XMSITE) ;
N XMIPARY,XMIP,XMIPSITE,XMI,XMIPREC,XMIPLIST
D MAIL^XLFNSLK(.XMIPARY,XMSITE)
S XMI=0
F S XMI=$O(XMIPARY(XMI)) Q:'XMI D
. S XMIPREC=XMIPARY(XMI)
. S XMIP=$P(XMIPREC,U,2)
. ;I XMIP'?1.N1"."1.N1"."1.N1".".E D Q
. I XMIP="" D Q
. . D SHOW(42260.1,XMIPREC) ;Ignore '|1|' - no IP address
. S XMIPSITE=$$UP^XLFSTR($P(XMIPREC,U,1))
. ; Accept whatever DNS returns, except for FORUM. We accept FORUM if
. ; we're trying to get to FORUM, but we don't want messages destined
. ; for another site to be routed through FORUM. If this is a non-VA
. ; site, then it's OK to route through FORUM.
. I ^XMB("NETNAME")[".VA.GOV",XMSITE'["FORUM.VA.GOV",XMIPSITE["FORUM.VA.GOV" D Q
. . D SHOW(42260.2,XMIPREC) ;Ignore '|1|' - that's a different site
. ;I '$$SAMESITE(XMIPSITE,XMSITE) D Q
. ;. D SHOW(42260.2,XMIPREC) ;Ignore '|1|' - that's a different site
. I ","_$G(XMIPLIST)_","[(","_XMIP_",") D Q
. . D SHOW(42260.3,XMIPREC) ;Ignore '|1|' - already have that IP address
. D SHOW(42260.4,XMIPREC) ;Accept '|1|'
. I $G(XMIPLIST)="" S XMIPLIST=XMIP Q
. S XMIPLIST=XMIPLIST_","_XMIP
Q $G(XMIPLIST)
SAMESITE(X,XMSITE) ;
N DIC,Y,D
I $E(X,$L(X))="." S X=$E(X,1,$L(X)-1)
S DIC="^DIC(4.2,",DIC(0)="FMXZ",D="B^C"
F D MIX^DIC1 Q:Y>0!(X'[".") S X=$P(X,".",2,99)
I Y,Y(0,0)=XMSITE Q 1
Q 0
SHOW(XMDIALOG,XM1) ;
I $D(ZTQUEUED)!'$G(XMC("PLAY")) Q
I +XMDIALOG=XMDIALOG W !,$$EZBLD^DIALOG(XMDIALOG,$G(XM1)) Q
W !,XMDIALOG
Q
NEXTIP(XMIP,XMIPLIST) ;
N XMI
F XMI=1:1:$L(XMIPLIST,",") Q:$P(XMIPLIST,",",XMI)=XMIP
I XMIP'=$P(XMIPLIST,",",XMI) S XMIP=$P(XMIPLIST,","),XMIPLIST=$P(XMIPLIST,",",2,99) Q
I XMI=1 S XMIPLIST=$P(XMIPLIST,",",2,99)
E I XMI=$L(XMIPLIST,",") S XMIPLIST=$P(XMIPLIST,",",1,XMI-1)
E S XMIPLIST=$P(XMIPLIST,",",1,XMI-1)_","_$P(XMIPLIST,",",XMI+1,99)
S XMIP=$P(XMIPLIST,","),XMIPLIST=$P(XMIPLIST,",",2,99)
Q
; *** The following is not used ***
CONNECT(XMSITE,XMIP,XMPORT) ; Function tries to connect to site.
; Returns the IP address if success; 0 if failure
; XMSITE - Site name to connect to
; XMIP - Site IP address to try first (optional). If none given,
; or if attempt fails, DNS is called to retrieve address(es).
; XMPORT - Port number to use (optional, default=25)
N XMIPLIST,XMOK
I '$G(XMPORT) S XMPORT=25
D SHOW("Connect to "_XMSITE_" on port "_XMPORT_$S($G(XMIP):", IP Address "_XMIP,1:""))
I $G(XMIP)="" D NEXTIPR(XMSITE,.XMIP,.XMIPLIST) Q:XMIP="" 0
S XMOK=0
F D TRYIP(XMIP,.XMOK) Q:XMOK D NEXTIPR(XMSITE,.XMIP,.XMIPLIST) Q:XMIP=""
Q:XMOK XMIP
D SHOW("Connect failed. Try again later.")
Q 0
NEXTIPR(XMSITE,XMIP,XMIPLIST) ; Routine returns next IP address to try
; IN/OUT:
; XMIP - in: Last IP address tried
; out: Next IP address to try
; XMIPLIST - in: (optional) List of IP addresses, separated by ",",
; we haven't yet tried
; out: Same, but with XMIP (out) removed
I '$D(XMIPLIST) D
. D SHOW(42260) ;Call DNS for IP Address list ...
. S XMIPLIST=$$IPADDR(XMSITE)
. D SHOW($S(XMIPLIST="":42261,1:42262),XMIPLIST) ;Returned: Nothing!/|1|
I XMIPLIST="" S XMIP="" Q
I $G(XMIP)="" S XMIP=$P(XMIPLIST,","),XMIPLIST=$P(XMIPLIST,",",2,99) Q
D NEXTIP(.XMIP,.XMIPLIST)
Q
TRYIP(XMIP,XMOK) ; Try the IP address, if it works, set XMOK=1
D SHOW("Trying "_XMIP)
D CALL^%ZISTCP(XMIP,XMPORT)
S XMOK='POP
I 'XMOK D SHOW("Attempt failed.")
Q
XMKPRD ;ISC-SF/GMB-DNS Interface ;07/11/2002 08:09
+1 ;;8.0;MailMan;;Jun 28, 2002
NEXTIPF(XMSITE,XMIPT,XMIPLIST) ; Function returns next IP address to try.
+1 ; IN:
+2 ; XMSITE - .01 field of domain in file 4.2 (not a synonym)
+3 ; XMIPT - List of IP addresses, separated by ",", already tried
+4 ; XMIPLIST - (optional) List of IP addresses, separated by ",", to try
+5 IF '$DATA(XMIPLIST)
Begin DoDot:1
+6 ;Call DNS for IP Address list ...
DO SHOW(42260)
+7 SET XMIPLIST=$$IPADDR(XMSITE)
+8 ;Returned: Nothing!/|1|
DO SHOW($SELECT(XMIPLIST="":42261,1:42262),XMIPLIST)
End DoDot:1
+9 IF XMIPLIST=""
QUIT ""
+10 IF $GET(XMIPT)=""
QUIT $PIECE(XMIPLIST,",")
+11 NEW XMJ,XMIP
+12 FOR XMJ=1:1:$LENGTH(XMIPT,",")
Begin DoDot:1
+13 SET XMIP=$PIECE(XMIPT,",",XMJ)
+14 DO NEXTIP(.XMIP,.XMIPLIST)
End DoDot:1
IF XMIP=""!(","_XMIPT_","'[(","_XMIP_","))
QUIT
+15 QUIT XMIP
IPADDR(XMSITE) ;
+1 NEW XMIPARY,XMIP,XMIPSITE,XMI,XMIPREC,XMIPLIST
+2 DO MAIL^XLFNSLK(.XMIPARY,XMSITE)
+3 SET XMI=0
+4 FOR
SET XMI=$ORDER(XMIPARY(XMI))
IF 'XMI
QUIT
Begin DoDot:1
+5 SET XMIPREC=XMIPARY(XMI)
+6 SET XMIP=$PIECE(XMIPREC,U,2)
+7 ;I XMIP'?1.N1"."1.N1"."1.N1".".E D Q
+8 IF XMIP=""
Begin DoDot:2
+9 ;Ignore '|1|' - no IP address
DO SHOW(42260.1,XMIPREC)
End DoDot:2
QUIT
+10 SET XMIPSITE=$$UP^XLFSTR($PIECE(XMIPREC,U,1))
+11 ; Accept whatever DNS returns, except for FORUM. We accept FORUM if
+12 ; we're trying to get to FORUM, but we don't want messages destined
+13 ; for another site to be routed through FORUM. If this is a non-VA
+14 ; site, then it's OK to route through FORUM.
+15 IF ^XMB("NETNAME")[".VA.GOV"
IF XMSITE'["FORUM.VA.GOV"
IF XMIPSITE["FORUM.VA.GOV"
Begin DoDot:2
+16 ;Ignore '|1|' - that's a different site
DO SHOW(42260.2,XMIPREC)
End DoDot:2
QUIT
+17 ;I '$$SAMESITE(XMIPSITE,XMSITE) D Q
+18 ;. D SHOW(42260.2,XMIPREC) ;Ignore '|1|' - that's a different site
+19 IF ","_$GET(XMIPLIST)_","[(","_XMIP_",")
Begin DoDot:2
+20 ;Ignore '|1|' - already have that IP address
DO SHOW(42260.3,XMIPREC)
End DoDot:2
QUIT
+21 ;Accept '|1|'
DO SHOW(42260.4,XMIPREC)
+22 IF $GET(XMIPLIST)=""
SET XMIPLIST=XMIP
QUIT
+23 SET XMIPLIST=XMIPLIST_","_XMIP
End DoDot:1
+24 QUIT $GET(XMIPLIST)
SAMESITE(X,XMSITE) ;
+1 NEW DIC,Y,D
+2 IF $EXTRACT(X,$LENGTH(X))="."
SET X=$EXTRACT(X,1,$LENGTH(X)-1)
+3 SET DIC="^DIC(4.2,"
SET DIC(0)="FMXZ"
SET D="B^C"
+4 FOR
DO MIX^DIC1
IF Y>0!(X'[".")
QUIT
SET X=$PIECE(X,".",2,99)
+5 IF Y
IF Y(0,0)=XMSITE
QUIT 1
+6 QUIT 0
SHOW(XMDIALOG,XM1) ;
+1 IF $DATA(ZTQUEUED)!'$GET(XMC("PLAY"))
QUIT
+2 IF +XMDIALOG=XMDIALOG
WRITE !,$$EZBLD^DIALOG(XMDIALOG,$GET(XM1))
QUIT
+3 WRITE !,XMDIALOG
+4 QUIT
NEXTIP(XMIP,XMIPLIST) ;
+1 NEW XMI
+2 FOR XMI=1:1:$LENGTH(XMIPLIST,",")
IF $PIECE(XMIPLIST,",",XMI)=XMIP
QUIT
+3 IF XMIP'=$PIECE(XMIPLIST,",",XMI)
SET XMIP=$PIECE(XMIPLIST,",")
SET XMIPLIST=$PIECE(XMIPLIST,",",2,99)
QUIT
+4 IF XMI=1
SET XMIPLIST=$PIECE(XMIPLIST,",",2,99)
+5 IF '$TEST
IF XMI=$LENGTH(XMIPLIST,",")
SET XMIPLIST=$PIECE(XMIPLIST,",",1,XMI-1)
+6 IF '$TEST
SET XMIPLIST=$PIECE(XMIPLIST,",",1,XMI-1)_","_$PIECE(XMIPLIST,",",XMI+1,99)
+7 SET XMIP=$PIECE(XMIPLIST,",")
SET XMIPLIST=$PIECE(XMIPLIST,",",2,99)
+8 QUIT
+9 ; *** The following is not used ***
CONNECT(XMSITE,XMIP,XMPORT) ; Function tries to connect to site.
+1 ; Returns the IP address if success; 0 if failure
+2 ; XMSITE - Site name to connect to
+3 ; XMIP - Site IP address to try first (optional). If none given,
+4 ; or if attempt fails, DNS is called to retrieve address(es).
+5 ; XMPORT - Port number to use (optional, default=25)
+6 NEW XMIPLIST,XMOK
+7 IF '$GET(XMPORT)
SET XMPORT=25
+8 DO SHOW("Connect to "_XMSITE_" on port "_XMPORT_$SELECT($GET(XMIP):", IP Address "_XMIP,1:""))
+9 IF $GET(XMIP)=""
DO NEXTIPR(XMSITE,.XMIP,.XMIPLIST)
IF XMIP=""
QUIT 0
+10 SET XMOK=0
+11 FOR
DO TRYIP(XMIP,.XMOK)
IF XMOK
QUIT
DO NEXTIPR(XMSITE,.XMIP,.XMIPLIST)
IF XMIP=""
QUIT
+12 IF XMOK
QUIT XMIP
+13 DO SHOW("Connect failed. Try again later.")
+14 QUIT 0
NEXTIPR(XMSITE,XMIP,XMIPLIST) ; Routine returns next IP address to try
+1 ; IN/OUT:
+2 ; XMIP - in: Last IP address tried
+3 ; out: Next IP address to try
+4 ; XMIPLIST - in: (optional) List of IP addresses, separated by ",",
+5 ; we haven't yet tried
+6 ; out: Same, but with XMIP (out) removed
+7 IF '$DATA(XMIPLIST)
Begin DoDot:1
+8 ;Call DNS for IP Address list ...
DO SHOW(42260)
+9 SET XMIPLIST=$$IPADDR(XMSITE)
+10 ;Returned: Nothing!/|1|
DO SHOW($SELECT(XMIPLIST="":42261,1:42262),XMIPLIST)
End DoDot:1
+11 IF XMIPLIST=""
SET XMIP=""
QUIT
+12 IF $GET(XMIP)=""
SET XMIP=$PIECE(XMIPLIST,",")
SET XMIPLIST=$PIECE(XMIPLIST,",",2,99)
QUIT
+13 DO NEXTIP(.XMIP,.XMIPLIST)
+14 QUIT
TRYIP(XMIP,XMOK) ; Try the IP address, if it works, set XMOK=1
+1 DO SHOW("Trying "_XMIP)
+2 DO CALL^%ZISTCP(XMIP,XMPORT)
+3 SET XMOK='POP
+4 IF 'XMOK
DO SHOW("Attempt failed.")
+5 QUIT