0 ' Developed by Eugeny Brychkov 06 Sep 2017 1 ' Requires firmware datecode 20170905 or later 2 ON STOP GOSUB 190:STOP ON:ON ERROR GOTO 190 10 PRINT"This program performs DNS query":PRINT"to the google's server 8.8.8.8 using" 20 PRINT"UDP: device":PRINT"Press any key to continue":A$=INPUT$(1):PRINT:CALLNETGETHOST(,H$) 30 INPUT"Remote host name";A$:OPEN"UDPA:"AS#1 40 ' Make up DNS query packet 50 RESTORE 1000:GOSUB 990:P=1 60 GOSUB900:IF P<>-1 THEN 60 70 RESTORE 1010:GOSUB 990 80 ' Send the packet to 8.8.8.8 90 CALLNETSNDDTG(1,8,8,8,8,53):PRINT"Waiting for reply from DNS" 100 ' Wait for reply 110 IF EOF(1) GOTO 110 120 ' Getting packet header 130 A$=INPUT$(8,1):PRINT"Reply from ";:FOR I=1 TO 4:Q$=STR$(ASC(MID$(A$,I,1))):L=LEN(Q$):PRINT RIGHT$(Q$,L-1);:IF I<>4 THEN PRINT"."; 140 NEXT I:P=ASC(MID$(A$,5,1))*256+ASC(MID$(A$,6,1)):PRINT" port";P;:S=ASC(MID$(A$,7,1))*256+ASC(MID$(A$,8,1)):PRINT"size";S 150 ' Read packet contents into GR8NET temp buffer 160 FOR I=0 TO S-1:A$=INPUT$(1,1):CALLNETSETMEM(0,&H6000+I,ASC(A$)):NEXT I 170 ' Display packet contents' dump 180 PRINT"DNS reply packet contents":CALLNETDUMP(0,&H6000,S) 190 CLOSE #1:ON ERROR GOTO 0:STOP OFF 200 PRINT:PRINT"Application finished":END 900 ' Parse host name up to . and put into buffer 910 L=LEN(A$):Q$="":FOR I=P TO L:Z$=MID$(A$,I,1):IF Z$="." THEN P=I+1:GOTO 930 920 Q$=Q$+Z$:NEXT I:P=-1 930 L=LEN(Q$):PRINT#1,CHR$(L);:PRINT#1,Q$;:RETURN 980 ' Put preferined data into the TX buffer 990 READ A:FOR I=1 TO A:READ B:PRINT#1,CHR$(B);:NEXT I:RETURN 1000 DATA 12,0,1,1,0,0,1,0,0,0,0,0,0 1010 DATA 5,0,0,1,0,1