[Cryptech-Commits] [sw/libhal] 04/04: Move hal_rpc_server_main() to test code.
git at cryptech.is
git at cryptech.is
Mon Apr 17 20:37:53 UTC 2017
This is an automated email from the git hooks/post-receive script.
paul at psgd.org pushed a commit to branch ksng
in repository sw/libhal.
commit 22a58216681df01d20cfa0a5cfc5c49d15e6c606
Author: Paul Selkirk <paul at psgd.org>
AuthorDate: Mon Apr 17 15:06:25 2017 -0400
Move hal_rpc_server_main() to test code.
---
hal.h | 4 +---
rpc_server.c | 21 ---------------------
tests/test-rpc_server.c | 21 +++++++++++++++++++++
3 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/hal.h b/hal.h
index bfb727a..abcaf52 100644
--- a/hal.h
+++ b/hal.h
@@ -4,7 +4,7 @@
* Memory map, access functions, and HAL for Cryptech cores.
*
* Authors: Joachim Strombergson, Paul Selkirk, Rob Austein
- * Copyright (c) 2015-2016, NORDUnet A/S All rights reserved.
+ * Copyright (c) 2015-2017, NORDUnet A/S All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -850,8 +850,6 @@ extern hal_error_t hal_rpc_server_close(void);
extern hal_error_t hal_rpc_server_dispatch(const uint8_t * const ibuf, const size_t ilen,
uint8_t * const obuf, size_t * const olen);
-extern void hal_rpc_server_main(void);
-
#endif /* _HAL_H_ */
/*
diff --git a/rpc_server.c b/rpc_server.c
index b28f90c..8d8af18 100644
--- a/rpc_server.c
+++ b/rpc_server.c
@@ -985,27 +985,6 @@ hal_error_t hal_rpc_server_dispatch(const uint8_t * const ibuf, const size_t ile
return HAL_OK;
}
-#define interrupt 0
-
-static uint8_t inbuf[HAL_RPC_MAX_PKT_SIZE], outbuf[HAL_RPC_MAX_PKT_SIZE];
-
-void hal_rpc_server_main(void)
-{
- size_t ilen, olen;
- void *opaque;
- hal_error_t ret;
-
- while (!interrupt) {
- ilen = sizeof(inbuf);
- ret = hal_rpc_recvfrom(inbuf, &ilen, &opaque);
- if (ret == HAL_OK) {
- olen = sizeof(outbuf);
- if (hal_rpc_server_dispatch(inbuf, ilen, outbuf, &olen) == HAL_OK)
- hal_rpc_sendto(outbuf, olen, opaque);
- }
- }
-}
-
/*
* Dispatch vectors.
*/
diff --git a/tests/test-rpc_server.c b/tests/test-rpc_server.c
index b0b2fd0..9736cc1 100644
--- a/tests/test-rpc_server.c
+++ b/tests/test-rpc_server.c
@@ -1,5 +1,26 @@
#include <hal.h>
+#define interrupt 0
+
+static uint8_t inbuf[HAL_RPC_MAX_PKT_SIZE], outbuf[HAL_RPC_MAX_PKT_SIZE];
+
+static void hal_rpc_server_main(void)
+{
+ size_t ilen, olen;
+ void *opaque;
+ hal_error_t ret;
+
+ while (!interrupt) {
+ ilen = sizeof(inbuf);
+ ret = hal_rpc_recvfrom(inbuf, &ilen, &opaque);
+ if (ret == HAL_OK) {
+ olen = sizeof(outbuf);
+ if (hal_rpc_server_dispatch(inbuf, ilen, outbuf, &olen) == HAL_OK)
+ hal_rpc_sendto(outbuf, olen, opaque);
+ }
+ }
+}
+
int main (int argc, char *argv[])
{
if (hal_rpc_server_init() != HAL_OK)
More information about the Commits
mailing list