[SLOF] [PATCH v2 06/10] Add a Forth-to-C wrapper for the ping command, too
Thomas Huth
thuth at redhat.com
Tue Sep 20 05:08:28 AEST 2016
Now that we link libnet to Paflof, we can call the ping
function there directly instead of using the one from
net-snk. We add a similar Forth-to-C wrapper like it has
already been done for netboot() - simplification and clean-up
will be done in a later patch once we do not link against
net-snk anymore.
Signed-off-by: Thomas Huth <thuth at redhat.com>
---
lib/libnet/libnet.code | 17 +++++++++++++++++
lib/libnet/libnet.in | 1 +
slof/fs/packages/obp-tftp.fs | 5 ++++-
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/lib/libnet/libnet.code b/lib/libnet/libnet.code
index 66f955f..a1c5a90 100644
--- a/lib/libnet/libnet.code
+++ b/lib/libnet/libnet.code
@@ -17,3 +17,20 @@ PRIM(NET_X2d_LOAD)
}
TOS.n = netboot(i, argvs);
MIRP
+
+PRIM(NET_X2d_PING)
+ 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 = ping(i, argvs);
+MIRP
diff --git a/lib/libnet/libnet.in b/lib/libnet/libnet.in
index 365587c..00b8658 100644
--- a/lib/libnet/libnet.in
+++ b/lib/libnet/libnet.in
@@ -1,2 +1,3 @@
cod(NET-LOAD)
+cod(NET-PING)
diff --git a/slof/fs/packages/obp-tftp.fs b/slof/fs/packages/obp-tftp.fs
index e26025d..84ac439 100644
--- a/slof/fs/packages/obp-tftp.fs
+++ b/slof/fs/packages/obp-tftp.fs
@@ -70,5 +70,8 @@ INSTANCE VARIABLE ciregs-buffer
;
: ping ( -- )
- s" ping " my-args $cat (client-exec)
+ s" ping " my-args $cat
+ \ Zero-terminate string:
+ s" " $cat 2dup + 1 - 0 swap c!
+ net-ping
;
--
1.8.3.1
More information about the SLOF
mailing list