emailler/test/dns.s

126 lines
2.3 KiB
ArmAsm
Raw Normal View History

.include "../inc/common.i"
.include "../inc/commonprint.i"
.include "../inc/net.i"
2013-12-13 21:24:03 +00:00
.export start
.import exit_to_basic
2013-12-13 21:24:03 +00:00
.import dns_set_hostname
.import dns_resolve
.import dns_ip
2013-12-13 21:24:03 +00:00
2014-04-28 16:41:54 +00:00
; keep LD65 happy
.segment "INIT"
.segment "ONCE"
2014-04-28 16:41:54 +00:00
.segment "STARTUP"
; switch to lower case charset
lda #14
jsr print_a
start:
2013-12-13 21:24:03 +00:00
jsr print_cr
init_ip_via_dhcp
; jsr overwrite_with_hardcoded_dns_server
2013-12-13 21:24:03 +00:00
jsr print_ip_config
2013-12-13 21:24:03 +00:00
ldax #hostname_1
jsr do_dns_query
2013-12-13 21:24:03 +00:00
ldax #hostname_2
jsr do_dns_query
2013-12-13 21:24:03 +00:00
ldax #hostname_3
jsr do_dns_query
2013-12-13 21:24:03 +00:00
ldax #hostname_4
jsr do_dns_query
2013-12-13 21:24:03 +00:00
ldax #hostname_5
jsr do_dns_query
2013-12-13 21:24:03 +00:00
ldax #hostname_6
jsr do_dns_query
2013-12-13 21:24:03 +00:00
jmp exit_to_basic
do_dns_query:
pha
jsr print
lda #' '
jsr print_a
lda #':'
jsr print_a
lda #' '
jsr print_a
pla
jsr dns_set_hostname
jsr dns_resolve
bcc :+
ldax #dns_lookup_failed_msg
jsr print
jmp print_cr
: ldax #dns_ip
2013-12-13 21:24:03 +00:00
jsr print_dotted_quad
jmp print_cr
2013-12-13 21:24:03 +00:00
overwrite_with_hardcoded_dns_server:
ldx #3
: lda hardcoded_dns_server,x
2013-12-13 21:24:03 +00:00
sta cfg_dns,x
dex
bpl :-
rts
.rodata
2013-12-13 21:24:03 +00:00
hostname_1:
.byte "SLASHDOT.ORG",0 ; this should be an A record
2013-12-13 21:24:03 +00:00
hostname_2:
.byte "VICTA.JAMTRONIX.COM",0 ; this should be a CNAME
2013-12-13 21:24:03 +00:00
hostname_3:
.byte "WWW.JAMTRONIX.COM",0 ; this should be another CNAME
2013-12-13 21:24:03 +00:00
hostname_4:
.byte "FOO.BAR.BOGUS",0 ; this should fail
2013-12-13 21:24:03 +00:00
hostname_5:
.byte "111.22.3.4",0 ; this should work (without hitting dns)
2013-12-13 21:24:03 +00:00
hostname_6:
.byte "3COM.COM",0 ; make sure doesn't get treated as a number
2013-12-13 21:24:03 +00:00
hardcoded_dns_server:
; .byte 61,9,195,193
; .byte 64,127,100,12
.byte 205,171,3,65
.byte 69,111,95,106
2013-12-13 21:24:03 +00:00
2014-04-13 16:36:04 +00:00
; -- LICENSE FOR dns.s --
2013-12-13 21:24:03 +00:00
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
2013-12-13 21:24:03 +00:00
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
2013-12-13 21:24:03 +00:00
; The Original Code is ip65.
;
2013-12-13 21:24:03 +00:00
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
2013-12-13 21:24:03 +00:00
; -- LICENSE END --