Fix ARP wrappers and add ARP test stub: test/025.

This commit is contained in:
Ivan Baravy 2020-05-12 02:29:29 +03:00
parent 38a4a20b36
commit 4585cd3d62
5 changed files with 118 additions and 12 deletions

33
shell.c
View File

@ -1622,7 +1622,7 @@ void shell_net_arp_get_count(int argc, char **argv) {
void shell_net_arp_get_entry(int argc, char **argv) {
const char *usage = \
"usage: net_arp_get_entry <dev_num>\n"
"usage: net_arp_get_entry <dev_num> <arp_num>\n"
" dev_num device number as returned by net_add_device\n"
" arp_num arp number as returned by net_add_device";
if (argc != 3) {
@ -1638,8 +1638,8 @@ void shell_net_arp_get_entry(int argc, char **argv) {
} else {
fprintf(fout, "arp #%u: IP %d.%d.%d.%d, "
"mac %2.2" SCNu8 ":%2.2" SCNu8 ":%2.2" SCNu8
":%2.2" SCNu8 ":%2.2" SCNu8 ":%2.2" SCNu8 " "
"status %" PRIu16 " "
":%2.2" SCNu8 ":%2.2" SCNu8 ":%2.2" SCNu8 ", "
"status %" PRIu16 ", "
"ttl %" PRIu16 "\n",
arp_num,
(uint8_t)(arp.ip >> 0), (uint8_t)(arp.ip >> 8),
@ -1654,7 +1654,10 @@ void shell_net_arp_add_entry(int argc, char **argv) {
const char *usage = \
"usage: net_arp_add_entry <dev_num> <addr> <mac> <status> <ttl>\n"
" dev_num device number as returned by net_add_device\n"
" arp_num arp number as returned by net_add_device";
" addr IP addr\n"
" mac ethernet addr\n"
" status see ARP.inc\n"
" ttl Time to live";
if (argc != 6) {
puts(usage);
return;
@ -1668,13 +1671,26 @@ void shell_net_arp_add_entry(int argc, char **argv) {
arp.mac+3, arp.mac+4, arp.mac+5);
arp.status = strtoul(argv[4], NULL, 0);
arp.ttl = strtoul(argv[5], NULL, 0);
fprintf(fout, "## before\n");
f76ret_t r = umka_sys_net_arp_add_entry(dev_num, &arp);
fprintf(fout, "## after\n");
if (r.eax == UINT32_MAX) {
fprintf(fout, "status: fail\n");
} else {
fprintf(fout, "%" PRIi32 "\n", r.eax);
}
}
void shell_net_arp_del_entry(int argc, char **argv) {
const char *usage = \
"usage: net_arp_del_entry <dev_num> <arp_num>\n"
" dev_num device number as returned by net_add_device\n"
" arp_num arp number as returned by net_add_device";
if (argc != 3) {
puts(usage);
return;
}
uint32_t dev_num = strtoul(argv[1], NULL, 0);
int32_t arp_num = strtoul(argv[2], NULL, 0);
f76ret_t r = umka_sys_net_arp_del_entry(dev_num, arp_num);
if (r.eax == UINT32_MAX) {
fprintf(fout, "status: fail\n");
}
}
@ -1855,6 +1871,7 @@ func_table_t funcs[] = {
{ "net_arp_get_count", shell_net_arp_get_count },
{ "net_arp_get_entry", shell_net_arp_get_entry },
{ "net_arp_add_entry", shell_net_arp_add_entry },
{ "net_arp_del_entry", shell_net_arp_del_entry },
{ "bg_set_size", shell_bg_set_size },
{ "bg_put_pixel", shell_bg_put_pixel },
{ "bg_redraw", shell_bg_redraw },

View File

@ -0,0 +1,3 @@
/> i40 18 16
eax = 00020000 131072 131072
ebx = 00000010 16 16

View File

@ -0,0 +1,69 @@
stack_init
net_get_dev_count
net_get_dev_name 0
net_add_device
net_get_dev_count
net_get_dev_name 1
net_dev_reset 1
net_arp_get_count 1
net_arp_add_entry 1 192.168.1.11 01:01:01:01:01:01 2 61
net_arp_get_count 1
net_arp_get_entry 1 0
net_arp_add_entry 1 192.168.1.12 02:02:02:02:02:02 2 62
net_arp_get_count 1
net_arp_get_entry 1 0
net_arp_get_entry 1 1
net_arp_add_entry 1 192.168.1.13 03:03:03:03:03:03 2 63
net_arp_get_count 1
net_arp_get_entry 1 0
net_arp_get_entry 1 1
net_arp_get_entry 1 2
net_arp_del_entry 1 2
net_arp_get_count 1
net_arp_get_entry 1 0
net_arp_get_entry 1 1
net_arp_get_entry 1 2
net_arp_del_entry 1 1
net_arp_get_count 1
net_arp_get_entry 1 0
net_arp_get_entry 1 1
net_arp_get_entry 1 2
net_arp_del_entry 1 10
net_arp_get_count 1
net_arp_get_entry 1 0
net_arp_get_entry 1 1
net_arp_get_entry 1 2
net_arp_del_entry 1 20
net_arp_get_count 1
net_arp_get_entry 1 0
net_arp_get_entry 1 1
net_arp_get_entry 1 2
net_arp_del_entry 1 0
net_arp_get_count 1
net_arp_get_entry 1 0
net_arp_add_entry 1 192.168.1.11 01:01:01:01:01:01 2 61
net_arp_add_entry 1 192.168.1.12 02:02:02:02:02:02 2 62
net_arp_get_count 1
net_arp_del_entry 1 -1
net_arp_get_count 1

View File

@ -19,8 +19,11 @@ unicode_tests := $(addsuffix .out.log, $(basename $(wildcard *\#unicode_*.t)))
v5_tests := $(addsuffix .out.log, $(basename $(wildcard *\#v5_*.t)))
draw_tests := $(addsuffix .out.log, $(basename $(wildcard *\#draw_*.t)))
coverage_tests := $(addsuffix .out.log, $(basename $(wildcard *\#coverage_*.t)))
i40_tests := $(addsuffix .out.log, $(basename $(wildcard *\#i40_*.t)))
net_tests := $(addsuffix .out.log, $(basename $(wildcard *\#net_*.t)))
arp_tests := $(addsuffix .out.log, $(basename $(wildcard *\#arp_*.t)))
all: xfs s05k s4k f30 f70 f70s0 f70s1 f70s5 lookup bug xattr unicode v5 draw coverage
all: xfs s05k s4k f30 f70 f70s0 f70s1 f70s5 lookup bug xattr unicode v5 draw coverage i40 net arp
@echo all tests passed
xfs: $(xfs_tests)
@ -38,8 +41,11 @@ unicode: $(unicode_tests)
v5: $(v5_tests)
draw: $(draw_tests)
coverage: $(coverage_tests)
i40: $(i40_tests)
net: $(net_tests)
arp: $(arp_tests)
%.out.log: %.ref.log %.t
%.out.log: %.t
$(UMKA_SHELL) < $*.t > $@
@ cmp $*.{out,ref}.log
@ if [ -f "$*.ref.png" ]; then cmp $*.{out,ref}.png; fi

15
umka.h
View File

@ -1361,9 +1361,20 @@ static inline f76ret_t umka_sys_net_arp_add_entry(uint32_t dev_num,
return r;
}
static inline f76ret_t umka_sys_net_arp_del_entry(uint32_t dev_num,
int32_t arp_num) {
f76ret_t r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
"=b"(r.ebx)
: "a"(76),
"b"((5 << 16) + (dev_num << 8) + 5),
"c"(arp_num)
: "memory");
return r;
}
// Function 76, Protocol 5 - ARP, Subfunction 4, Add ARP entry ====
// Function 76, Protocol 5 - ARP, Subfunction 5, Remove ARP entry ====
// Function 76, Protocol 5 - ARP, Subfunction 6, Send ARP announce ==
// Function 76, Protocol 5 - ARP, Subfunction 7, Read # conflicts ===