starting CIFS support

git-svn-id: http://svn.code.sf.net/p/netboot65/code@298 93682198-c243-4bdb-bd91-e943c89aac3b
This commit is contained in:
jonnosan 2011-01-02 01:14:45 +00:00
parent f3c149044e
commit 6505e7c31d
4 changed files with 269 additions and 0 deletions

View File

@ -35,6 +35,7 @@ ETHOBJS= \
arithmetic.o\
ip.o \
icmp.o \
cifs.o \
udp.o
all: ip65.lib ip65_tcp.lib ip65_wiznet.lib

126
client/ip65/cifs.s Normal file
View File

@ -0,0 +1,126 @@
;a simple NETBIOS over TCP server
;aka "Common Internet File System"
;
; refs: RFC1001, RFC1002, "Implementing CIFS" - http://ubiqx.org/cifs/
.include "../inc/common.i"
.ifndef KPR_API_VERSION_NUMBER
.define EQU =
.include "../inc/kipper_constants.i"
.endif
.export cifs_l1_encode
.export cifs_l1_decode
.importzp copy_src
;given an ASCII (or PETSCII) hostname, convert to
;canonical 'level 1 encoded' form.
;
;only supports the default scope (' ' : 0x20)
;inputs:
; AX: pointer to null terminated hostname to be encoded
;outputs:
; AX: pointer to decoded hostname
cifs_l1_encode:
stax copy_src
lda #0
tax
sta hostname_buffer+32
@empty_buffer_loop:
lda #$43
sta hostname_buffer,x
inx
lda #$41
sta hostname_buffer,x
inx
cpx #$20
bmi @empty_buffer_loop
ldy #0
ldx #0
@copy_loop:
lda (copy_src),y
beq @done
lsr
lsr
lsr
lsr
clc
adc #$41
sta hostname_buffer,x
inx
lda (copy_src),y
and #$0F
clc
adc #$41
sta hostname_buffer,x
inx
iny
cpx #$1D
bmi @copy_loop
@done:
ldax #hostname_buffer
rts
;given a 'level 1 encoded' hostname, decode to ASCII .
;
;inputs:
; AX: pointer to encoded hostname to be decoded
;outputs:
; AX: pointer to decoded hostname (will be 16 byte hostname, right padded with spaces, nul terminated)
cifs_l1_decode:
stax copy_src
ldy #0
ldx #0
@decode_loop:
lda (copy_src),y
sec
sbc #$41
asl
asl
asl
asl
sta hi_nibble
iny
lda (copy_src),y
sec
sbc #$41
clc
adc hi_nibble
sta hostname_buffer,x
iny
inx
cpx #$10
bmi @decode_loop
lda #0
sta hostname_buffer,x
ldax #hostname_buffer
rts
rts
.bss
hostname_buffer:
.res 33
hi_nibble: .res 1
;-- LICENSE FOR cifs.s --
; 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/
;
; 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.
;
; The Original Code is ip65.
;
; 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.
; -- LICENSE END --

View File

@ -23,6 +23,7 @@ all: \
drivers \
test_getc.prg \
testdns.prg \
test_cifs.prg \
test_disk_io.prg \
testdns.pg2 \
testtftp.prg \

141
client/test/test_cifs.s Normal file
View File

@ -0,0 +1,141 @@
.include "../inc/common.i"
.include "../inc/commonprint.i"
.include "../inc/net.i"
.import exit_to_basic
.import cfg_get_configuration_ptr
.import cifs_l1_encode
.import cifs_l1_decode
.import __CODE_LOAD__
.import __CODE_SIZE__
.import __RODATA_SIZE__
.import __DATA_SIZE__
.segment "STARTUP" ;this is what gets put at the start of the file on the C64
.word basicstub ; load address
basicstub:
.word @nextline
.word 2003
.byte $9e
.byte <(((init / 1000) .mod 10) + $30)
.byte <(((init / 100 ) .mod 10) + $30)
.byte <(((init / 10 ) .mod 10) + $30)
.byte <(((init ) .mod 10) + $30)
.byte 0
@nextline:
.word 0
.segment "EXEHDR" ;this is what gets put an the start of the file on the Apple 2
.addr __CODE_LOAD__-$11 ; Start address
.word __CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; Size
jmp init
.code
init:
; jsr print_cr
; jsr print_ip_config
; init_ip_via_dhcp
; jsr overwrite_with_hardcoded_dns_server
; jsr print_ip_config
ldax #hostname_1
jsr do_encoding_test
ldax #hostname_2
jsr do_encoding_test
ldax #hostname_3
jsr do_encoding_test
ldax #hostname_4
jsr do_encoding_test
ldax #hostname_5
jsr do_encoding_test
ldax #hostname_6
jsr do_encoding_test
jmp exit_to_basic
do_encoding_test:
stax hostname_ptr
jsr print
lda #' '
jsr print_a
lda #':'
jsr print_a
lda #' '
jsr print_a
ldax hostname_ptr
jsr cifs_l1_encode
stax hostname_ptr
jsr print
jsr print_cr
ldax hostname_ptr
jsr cifs_l1_decode
jsr print
jsr print_cr
rts
.rodata
hostname_ptr: .res 2
hostname_1:
.byte "Neko",0 ;this should be an A record
hostname_2:
.byte "NEKO",0 ;this should be a CNAME
hostname_3:
.byte "HOSTNAMEWITHLOTSOFCHARSINNAME",0 ;this should be another CNAME
hostname_4:
.byte "FOO.BAR.BOGUS",0 ;this should fail
hostname_5: ;this should work (without hitting dns)
.byte "111.22.3.4",0
hostname_6: ;make sure doesn't get treated as a number
.byte "3COM.COM",0
sample_msg:
.byte $ff, $ff, $ff, $ff, $ff, $ff, $f8, $1e, $df, $dc, $47, $a1, $08, $00, $45, $00
.byte $00, $4e, $9e, $cf, $00, $00, $40, $11, $c4, $c5, $0a, $05, $01, $02, $0a, $05
.byte $01, $ff, $fe, $66, $00, $89, $00, $3a, $86, $0a, $00, $02, $01, $10, $00, $01
.byte $00, $00, $00, $00, $00, $00, $20, $45, $48, $45, $50, $45, $50, $45, $43, $45
.byte $46, $46, $43, $43, $41, $43, $41, $43, $41, $43, $41, $43, $41, $43, $41, $43
.byte $41, $43, $41, $43, $41, $43, $41, $00, $00, $20, $00, $01
;-- LICENSE FOR testdns.s --
; 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/
;
; 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.
;
; The Original Code is ip65.
;
; 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.
; -- LICENSE END --