mirror of
https://github.com/bobbimanners/emailler.git
synced 2024-11-18 06:08:04 +00:00
udp send / receive now working via NB65 API
git-svn-id: http://svn.code.sf.net/p/netboot65/code@87 93682198-c243-4bdb-bd91-e943c89aac3b
This commit is contained in:
parent
641453ffe9
commit
2a938cceed
@ -6,14 +6,6 @@ NB65_DISPATCH_VECTOR = $800d
|
||||
NB65_PERIODIC_PROCESSING_VECTOR = $8010
|
||||
NB65_VBL_VECTOR = $8013
|
||||
|
||||
;offsets in IP packet of various interesting bits:
|
||||
NB65_IP_SRC = 12 ;offset of "source address" field in an IP packet header
|
||||
NB65_IP_DEST = 16 ;offset of "destination address" field in an IP packet header
|
||||
NB65_UDP_SRC_PORT = 20 ;offset of udp source port field in ip packet
|
||||
NB65_UDP_DEST_PORT = 22 ;offset of udp source port field in ip packet
|
||||
NB65_UDP_DATA_LENGTH = 24 ;offset of length field in udp packet
|
||||
NB65_UDP_DATA = 28 ;offset of data in udp packet
|
||||
|
||||
;offsets in NB65 configuration structure
|
||||
NB65_CFG_MAC = $00 ;6 byte MAC address
|
||||
NB65_CFG_IP = $06 ;4 byte local IP address (will be overwritten by DHCP)
|
||||
@ -62,7 +54,8 @@ NB65_DNS_RESOLVE_HOSTNAME =$07 ;inputs: AX points to a DNS parameter structu
|
||||
;NB65_DNS_HOSTNAME_IP updated with IP address corresponding to hostname.
|
||||
NB65_UDP_ADD_LISTENER =$08 ;inputs: AX points to a UDP listener parameter structure, outputs: none
|
||||
NB65_GET_INPUT_PACKET_INFO =$09 ;inputs: AX points to a UDP packet parameter structure, outputs: UDP packet structure filled in
|
||||
NB65_UNHOOK_VBL_IRQ =$0A ;inputs: none, outputs: none (removes call to NB65_VBL_VECTOR on IRQ chain)
|
||||
NB65_SEND_UDP_PACKET =$0A ;inputs: AX points to a UDP packet parameter structure, outputs: none packet is sent
|
||||
NB65_UNHOOK_VBL_IRQ =$0B ;inputs: none, outputs: none (removes call to NB65_VBL_VECTOR on IRQ chain)
|
||||
|
||||
NB65_PRINT_ASCIIZ =$80 ;inputs: AX= pointer to null terminated string to be printed to screen, outputs: none
|
||||
NB65_PRINT_HEX =$81 ;inputs: A = byte digit to be displayed on screen as (zero padded) hex digit, outputs: none
|
||||
|
@ -26,7 +26,12 @@
|
||||
.import udp_add_listener
|
||||
.import ip_inp
|
||||
.import udp_inp
|
||||
|
||||
.import udp_send
|
||||
.import udp_send_src
|
||||
.import udp_send_src_port
|
||||
.import udp_send_dest
|
||||
.import udp_send_dest_port
|
||||
.import udp_send_len
|
||||
.import copymem
|
||||
.import cfg_mac
|
||||
.importzp copy_src
|
||||
@ -227,18 +232,59 @@ irq_handler_installed:
|
||||
sta (nb65_params),y
|
||||
|
||||
iny
|
||||
lda #<udp_inp+8 ;payload ptr (lo byte)
|
||||
lda #<(udp_inp+8) ;payload ptr (lo byte)
|
||||
sta (nb65_params),y
|
||||
|
||||
iny
|
||||
lda #>udp_inp+8 ;payload ptr (hi byte)
|
||||
lda #>(udp_inp+8) ;payload ptr (hi byte)
|
||||
sta (nb65_params),y
|
||||
|
||||
clc
|
||||
rts
|
||||
:
|
||||
|
||||
cpy #NB65_SEND_UDP_PACKET
|
||||
bne :+
|
||||
ldy #3
|
||||
@copy_dest_ip:
|
||||
lda (nb65_params),y
|
||||
sta udp_send_dest,y
|
||||
dey
|
||||
bpl @copy_dest_ip
|
||||
|
||||
ldy #NB65_REMOTE_PORT
|
||||
lda (nb65_params),y
|
||||
sta udp_send_dest_port
|
||||
iny
|
||||
lda (nb65_params),y
|
||||
sta udp_send_dest_port+1
|
||||
iny
|
||||
|
||||
lda (nb65_params),y
|
||||
sta udp_send_src_port
|
||||
iny
|
||||
lda (nb65_params),y
|
||||
sta udp_send_src_port+1
|
||||
iny
|
||||
|
||||
|
||||
lda (nb65_params),y
|
||||
sta udp_send_len
|
||||
iny
|
||||
lda (nb65_params),y
|
||||
sta udp_send_len+1
|
||||
iny
|
||||
|
||||
;AX should point at data to send
|
||||
lda (nb65_params),y
|
||||
pha
|
||||
iny
|
||||
lda (nb65_params),y
|
||||
tax
|
||||
pla
|
||||
jmp udp_send
|
||||
|
||||
:
|
||||
cpy #NB65_UNHOOK_VBL_IRQ
|
||||
bne :+
|
||||
ldax jmp_old_irq+1
|
||||
|
@ -23,7 +23,7 @@
|
||||
print_a = $ffd2
|
||||
|
||||
.zeropage
|
||||
temp_ptr: .res 2
|
||||
temp_ptr: .res 2
|
||||
|
||||
.bss
|
||||
nb65_param_buffer: .res $20
|
||||
@ -202,12 +202,13 @@ udp_callback:
|
||||
lda nb65_param_buffer+NB65_PAYLOAD_LENGTH
|
||||
ldy #NB65_PRINT_HEX
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
|
||||
print_cr
|
||||
ldax #data
|
||||
ldy #NB65_PRINT_ASCIIZ
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
|
||||
ldax nb65_param_buffer+NB65_PAYLOAD_POINTER
|
||||
|
||||
stax temp_ptr
|
||||
ldx nb65_param_buffer+NB65_PAYLOAD_LENGTH ;assumes length is < 255
|
||||
ldy #0
|
||||
@ -216,12 +217,27 @@ udp_callback:
|
||||
jsr print_a
|
||||
iny
|
||||
dex
|
||||
bne :-
|
||||
bpl :-
|
||||
|
||||
print_cr
|
||||
|
||||
rts
|
||||
|
||||
;make and send reply
|
||||
ldax #reply_message
|
||||
stax nb65_param_buffer+NB65_PAYLOAD_POINTER
|
||||
|
||||
ldax #reply_message_length
|
||||
stax nb65_param_buffer+NB65_PAYLOAD_LENGTH
|
||||
|
||||
ldax #nb65_param_buffer
|
||||
ldy #NB65_SEND_UDP_PACKET
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
bcc :+
|
||||
jmp print_errorcode
|
||||
:
|
||||
ldax #reply_sent
|
||||
ldy #NB65_PRINT_ASCIIZ
|
||||
jmp NB65_DISPATCH_VECTOR
|
||||
|
||||
do_dns_query: ;AX points at the hostname on entry
|
||||
stax nb65_param_buffer+NB65_DNS_HOSTNAME
|
||||
|
||||
@ -309,7 +325,11 @@ recv_from:
|
||||
listening:
|
||||
.byte "LISTENING.",13,0
|
||||
|
||||
|
||||
|
||||
reply_sent:
|
||||
.byte "REPLY SENT.",13,0
|
||||
|
||||
|
||||
initialized:
|
||||
.byte " INITIALIZED.",13,0
|
||||
|
||||
@ -334,3 +354,8 @@ ok_msg:
|
||||
|
||||
dns_lookup_failed_msg:
|
||||
.byte "DNS LOOKUP FAILED", 0
|
||||
|
||||
reply_message:
|
||||
.byte "PONG!"
|
||||
reply_message_end:
|
||||
reply_message_length=reply_message_end-reply_message
|
||||
|
Loading…
Reference in New Issue
Block a user