mirror of
https://github.com/bobbimanners/emailler.git
synced 2025-02-08 05:31:15 +00:00
git-svn-id: http://svn.code.sf.net/p/netboot65/code@136 93682198-c243-4bdb-bd91-e943c89aac3b
This commit is contained in:
parent
eade2778dd
commit
1f536b8c7c
@ -102,12 +102,14 @@ exit_cart:
|
|||||||
sta $0001 ;turns off ordinary cartridge by modifying HIRAM/LORAM (this will also bank out BASIC)
|
sta $0001 ;turns off ordinary cartridge by modifying HIRAM/LORAM (this will also bank out BASIC)
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
|
get_value_of_axy: ;some more self-modifying code
|
||||||
|
lda $ffff,y
|
||||||
|
rts
|
||||||
|
|
||||||
call_downloaded_prg:
|
call_downloaded_prg:
|
||||||
jsr $0000 ;overwritten when we load a file
|
jsr $0000 ;overwritten when we load a file
|
||||||
jmp init
|
jmp init
|
||||||
|
|
||||||
.bss
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.segment "CARTRIDGE_HEADER"
|
.segment "CARTRIDGE_HEADER"
|
||||||
@ -378,18 +380,22 @@ cmp #KEYCODE_F7
|
|||||||
|
|
||||||
@tftp_boot:
|
@tftp_boot:
|
||||||
|
|
||||||
|
|
||||||
|
ldax #tftp_dir_filemask
|
||||||
|
|
||||||
|
@get_tftp_directory_listing:
|
||||||
|
stax nb65_param_buffer+NB65_TFTP_FILENAME
|
||||||
|
|
||||||
|
|
||||||
ldax #tftp_dir_buffer
|
ldax #tftp_dir_buffer
|
||||||
stax nb65_param_buffer+NB65_TFTP_POINTER
|
stax nb65_param_buffer+NB65_TFTP_POINTER
|
||||||
|
|
||||||
ldax #getting_dir_listing_msg
|
ldax #getting_dir_listing_msg
|
||||||
jsr print
|
jsr print
|
||||||
|
|
||||||
ldax #tftp_dir_filemask
|
|
||||||
stax nb65_param_buffer+NB65_TFTP_FILENAME
|
|
||||||
|
|
||||||
ldax #nb65_param_buffer
|
ldax #nb65_param_buffer
|
||||||
nb65call #NB65_TFTP_DOWNLOAD
|
nb65call #NB65_TFTP_DOWNLOAD
|
||||||
|
|
||||||
bcs @dir_failed
|
bcs @dir_failed
|
||||||
|
|
||||||
lda tftp_dir_buffer ;get the first byte that was downloaded
|
lda tftp_dir_buffer ;get the first byte that was downloaded
|
||||||
@ -408,6 +414,33 @@ cmp #KEYCODE_F7
|
|||||||
bcc @tftp_filename_set
|
bcc @tftp_filename_set
|
||||||
jmp main_menu
|
jmp main_menu
|
||||||
@tftp_filename_set:
|
@tftp_filename_set:
|
||||||
|
stax copy_dest
|
||||||
|
stax get_value_of_axy+1
|
||||||
|
ldy #0
|
||||||
|
jsr get_value_of_axy ;A now == first char in string we just downloaded
|
||||||
|
cmp #'$'
|
||||||
|
bne @not_directory_name
|
||||||
|
;it's a directory name, so we need to append the file mask to end of it
|
||||||
|
;this will fail if the file path is more than 255 characters long
|
||||||
|
@look_for_trailing_zero:
|
||||||
|
iny
|
||||||
|
inc copy_dest
|
||||||
|
bne :+
|
||||||
|
inc copy_dest+1
|
||||||
|
:
|
||||||
|
jsr get_value_of_axy ;A now == next char in string we just downloaded
|
||||||
|
bne @look_for_trailing_zero
|
||||||
|
|
||||||
|
; got trailing zero
|
||||||
|
ldax #tftp_dir_filemask+1 ;skip the leading '$'
|
||||||
|
stax copy_src
|
||||||
|
ldax #$07
|
||||||
|
jsr copymem
|
||||||
|
ldax get_value_of_axy+1
|
||||||
|
jmp @get_tftp_directory_listing
|
||||||
|
|
||||||
|
@not_directory_name:
|
||||||
|
ldax get_value_of_axy+1
|
||||||
jsr download
|
jsr download
|
||||||
bcc @file_downloaded_ok
|
bcc @file_downloaded_ok
|
||||||
@tftp_boot_failed:
|
@tftp_boot_failed:
|
||||||
@ -567,7 +600,7 @@ new:
|
|||||||
.byte"NEW ",0
|
.byte"NEW ",0
|
||||||
|
|
||||||
tftp_dir_filemask:
|
tftp_dir_filemask:
|
||||||
.asciiz "$*.prg"
|
.asciiz "$/*.prg"
|
||||||
|
|
||||||
tftp_file:
|
tftp_file:
|
||||||
.asciiz "BOOTC64.PRG"
|
.asciiz "BOOTC64.PRG"
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
@progname=File.basename($0)
|
@progname=File.basename($0)
|
||||||
def show_options
|
def show_options
|
||||||
puts "valid options are: #{@cartridge_offsets.keys.join(", ")}"
|
puts "valid options are: #{@cartridge_offsets.keys.join(", ")}"
|
||||||
|
puts "mac auto will automagically generate a pseudorandom MAC"
|
||||||
end
|
end
|
||||||
def usage
|
def usage
|
||||||
puts "#{@progname} <image> <option> <value> [<option> <value> ..]"
|
puts "#{@progname} <image> <option> <value> [<option> <value> ..]"
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
# TFTP spec : http://www.ietf.org/rfc/rfc1350.txt
|
# TFTP spec : http://www.ietf.org/rfc/rfc1350.txt
|
||||||
|
|
||||||
require 'socket'
|
require 'socket'
|
||||||
|
require 'file_list'
|
||||||
class Netboot65TFTPServer
|
class Netboot65TFTPServer
|
||||||
|
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ class Netboot65TFTPServer
|
|||||||
|
|
||||||
attr_reader :bootfile_dir,:port,:server_thread
|
attr_reader :bootfile_dir,:port,:server_thread
|
||||||
def initialize(bootfile_dir,port=69)
|
def initialize(bootfile_dir,port=69)
|
||||||
@bootfile_dir=bootfile_dir
|
@file_list=FileList.new(bootfile_dir)
|
||||||
@port=port
|
@port=port
|
||||||
@server_thread=nil
|
@server_thread=nil
|
||||||
@current_connection={}
|
@current_connection={}
|
||||||
@ -165,27 +166,16 @@ class Netboot65TFTPServer
|
|||||||
opcode,filename_and_mode=data.unpack("nA*")
|
opcode,filename_and_mode=data.unpack("nA*")
|
||||||
filename,mode=filename_and_mode.split(0.chr)
|
filename,mode=filename_and_mode.split(0.chr)
|
||||||
log_msg "RRQ for #{filename} (#{mode})"
|
log_msg "RRQ for #{filename} (#{mode})"
|
||||||
if filename=~/^\./ || filename=~/\.\./ then #looks like something dodgy - either a dotfile or a directory traversal attempt
|
if filename=~/^\./ || filename=~/\.\./ #looks like something dodgy - either a dotfile or a directory traversal attempt
|
||||||
send_error(client_ip,client_port,1,"'#{filename}' invalid filename")
|
send_error(client_ip,client_port,1,"'#{filename}' invalid filename")
|
||||||
elsif filename=~/^\$(.*)/ then #it's a directory request
|
else
|
||||||
filemask="/#{$1}"
|
begin
|
||||||
filemask="#{filemask}/*.*" unless filemask=~/\*/
|
data_to_send=@file_list[filename]
|
||||||
log_msg "DIR for #{filemask}"
|
Thread.new {send_data(client_ip,client_port,filename,data_to_send)}
|
||||||
data_to_send=""
|
rescue Exception=>e
|
||||||
Dir.glob("#{bootfile_dir}#{filemask}").each do |full_filename|
|
send_error(client_ip,client_port,1,"error retrieving '#{filename}':#{e.to_s}")
|
||||||
filename=full_filename.sub(/^#{bootfile_dir}\/*/,'')
|
log_msg(e.backtrace.join("\n"))
|
||||||
data_to_send<<"#{filename}\000"
|
|
||||||
end
|
end
|
||||||
data_to_send<<0.chr
|
|
||||||
Thread.new {send_data(client_ip,client_port,"DIR of #{filemask}",data_to_send)}
|
|
||||||
else
|
|
||||||
full_filename="#{bootfile_dir}/#{filename}"
|
|
||||||
if File.file?(full_filename) then
|
|
||||||
data_to_send=File.open(full_filename,"rb").read
|
|
||||||
Thread.new {send_data(client_ip,client_port,full_filename,data_to_send)}
|
|
||||||
else
|
|
||||||
send_error(client_ip,client_port,1,"'#{filename}' not found")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
when 2 : #WRITE REQUEST
|
when 2 : #WRITE REQUEST
|
||||||
opcode,filename_and_mode=data.unpack("nA*")
|
opcode,filename_and_mode=data.unpack("nA*")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user