diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libnet/libnet.code | 23 | ||||
-rw-r--r-- | lib/libnet/netapps.h | 3 | ||||
-rw-r--r-- | lib/libnet/netload.c | 21 |
3 files changed, 23 insertions, 24 deletions
diff --git a/lib/libnet/libnet.code b/lib/libnet/libnet.code index ab67fac..3602543 100644 --- a/lib/libnet/libnet.code +++ b/lib/libnet/libnet.code @@ -2,20 +2,15 @@ #include <netapps.h> PRIM(NET_X2d_LOAD) - int slen = TOS.n; POP; - char *arg = TOS.a; - char *argvs[8]; - int i, p; - argvs[0] = arg; - i = 1; - for (p = 0; p < slen; p++) { - if (arg[p] == ' ') { - arg[p] = 0; - argvs[i] = &arg[p + 1]; - i++; - } - } - TOS.n = netboot(i, argvs); + int alen = TOS.n; POP; + char *arg = TOS.a; POP; + int blocksize = TOS.n; POP; + int hugeload = TOS.n; POP; + void *replybuf = TOS.a; POP; + long maxlen = TOS.n; POP; + void *loadaddr = TOS.a; + TOS.n = netload(loadaddr, maxlen, replybuf, hugeload, blocksize, + arg, alen); MIRP PRIM(NET_X2d_PING) diff --git a/lib/libnet/netapps.h b/lib/libnet/netapps.h index 00b6318..91c1ebd 100644 --- a/lib/libnet/netapps.h +++ b/lib/libnet/netapps.h @@ -18,7 +18,8 @@ struct filename_ip; -extern int netboot(int argc, char *argv[]); +extern int netload(char *buffer, int len, char *ret_buffer, int huge_load, + int block_size, char *args_fs, int alen); extern int netsave(int argc, char *argv[]); extern int ping(char *args_fs, int alen); extern int dhcp(char *ret_buffer, struct filename_ip *fn_ip, diff --git a/lib/libnet/netload.c b/lib/libnet/netload.c index 6429405..848609d 100644 --- a/lib/libnet/netload.c +++ b/lib/libnet/netload.c @@ -386,14 +386,11 @@ static void seed_rng(uint8_t mac[]) srand(seed); } -int -netboot(int argc, char *argv[]) +int netload(char *buffer, int len, char *ret_buffer, int huge_load, + int block_size, char *args_fs, int alen) { char buf[256]; int rc; - int len = strtol(argv[2], 0, 16); - char *buffer = (char *) strtol(argv[1], 0, 16); - char *ret_buffer = (char *) strtol(argv[3], 0, 16); filename_ip_t fn_ip; int fd_device; tftp_err_t tftp_err; @@ -403,8 +400,6 @@ netboot(int argc, char *argv[]) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - int huge_load = strtol(argv[4], 0, 10); - int32_t block_size = strtol(argv[5], 0, 10); uint8_t own_mac[6]; puts("\n Initializing NIC"); @@ -458,8 +453,16 @@ netboot(int argc, char *argv[]) seed_rng(own_mac); - if (argc > 6) { - parse_args(argv[6], &obp_tftp_args); + if (alen > 0) { + char args[256]; + if (alen > sizeof(args) - 1) { + puts("ERROR: Parameter string is too long."); + return -7; + } + /* Convert forth string into NUL-terminated C-string */ + strncpy(args, args_fs, alen); + args[alen] = 0; + parse_args(args, &obp_tftp_args); if(obp_tftp_args.bootp_retries - rc < DEFAULT_BOOT_RETRIES) obp_tftp_args.bootp_retries = DEFAULT_BOOT_RETRIES; else |