teaclave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ms...@apache.org
Subject [incubator-teaclave] branch develop updated: [binder] Polish and cleanup
Date Thu, 20 Feb 2020 22:04:31 GMT
This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git


The following commit(s) were added to refs/heads/develop by this push:
     new 487ef78  [binder] Polish and cleanup
487ef78 is described below

commit 487ef7806a90f61431257c29eb176699a01cadcc
Author: Mingshen Sun <bob@mssun.me>
AuthorDate: Thu Feb 20 13:47:04 2020 -0800

    [binder] Polish and cleanup
---
 binder/src/binder.rs                       |  8 +++----
 binder/src/proto.rs                        | 37 +++++++-----------------------
 services/access_control/enclave/src/lib.rs |  6 ++---
 services/authentication/enclave/src/lib.rs |  6 ++---
 services/execution/enclave/src/lib.rs      |  6 ++---
 services/frontend/enclave/src/lib.rs       |  6 ++---
 services/management/enclave/src/lib.rs     |  6 ++---
 services/storage/enclave/src/lib.rs        |  6 ++---
 tests/functional/enclave/src/lib.rs        |  6 ++---
 tests/integration/enclave/src/lib.rs       |  6 ++---
 tests/unit/enclave/src/lib.rs              |  6 ++---
 11 files changed, 38 insertions(+), 61 deletions(-)

diff --git a/binder/src/binder.rs b/binder/src/binder.rs
index 867e9be..3365e9e 100644
--- a/binder/src/binder.rs
+++ b/binder/src/binder.rs
@@ -28,7 +28,7 @@ use crate::proto::{
 };
 use teaclave_types::TeeServiceResult;
 
-static ENCLAVE_FILE_SUFFIX: &str = "_enclave.signed.so";
+const ENCLAVE_FILE_SUFFIX: &str = "_enclave.signed.so";
 
 #[derive(thiserror::Error, Debug)]
 pub enum TeeBinderError {
@@ -55,10 +55,9 @@ impl TeeBinder {
 
         let tee = TeeBinder { enclave };
 
-        let input = InitEnclaveInput::default();
         let _ = tee.invoke::<InitEnclaveInput, TeeServiceResult<InitEnclaveOutput>>(
             ECallCommand::InitEnclave,
-            input,
+            InitEnclaveInput,
         )?;
 
         Ok(tee)
@@ -80,10 +79,9 @@ impl TeeBinder {
     }
 
     pub fn finalize(&self) {
-        let input = FinalizeEnclaveInput::default();
         match self.invoke::<FinalizeEnclaveInput, TeeServiceResult<FinalizeEnclaveOutput>>(
             ECallCommand::FinalizeEnclave,
-            input,
+            FinalizeEnclaveInput,
         ) {
             Ok(_) => {}
             Err(e) => info!("{:?}", e),
diff --git a/binder/src/proto.rs b/binder/src/proto.rs
index f868314..e08b19c 100644
--- a/binder/src/proto.rs
+++ b/binder/src/proto.rs
@@ -17,7 +17,6 @@
 
 use serde::{Deserialize, Serialize};
 use std::convert::From;
-use std::os::raw::c_int;
 use std::prelude::v1::*;
 
 pub enum ECallCommand {
@@ -25,7 +24,6 @@ pub enum ECallCommand {
     InitEnclave,
     FinalizeEnclave,
     RunTest,
-    ServeConnection,
     Unimplemented,
 }
 
@@ -37,7 +35,6 @@ impl From<u32> for ECallCommand {
             0x0000_1001 => ECallCommand::InitEnclave,
             0x0000_1002 => ECallCommand::FinalizeEnclave,
             0x0000_1003 => ECallCommand::RunTest,
-            0x0000_1004 => ECallCommand::ServeConnection,
             _ => ECallCommand::Unimplemented,
         }
     }
@@ -51,7 +48,6 @@ impl Into<u32> for ECallCommand {
             ECallCommand::InitEnclave => 0x0000_1001,
             ECallCommand::FinalizeEnclave => 0x0000_1002,
             ECallCommand::RunTest => 0x0000_1003,
-            ECallCommand::ServeConnection => 0x0000_1004,
             ECallCommand::Unimplemented => 0xffff_ffff,
         }
     }
@@ -68,40 +64,23 @@ impl StartServiceInput {
     }
 }
 
-#[derive(Clone, Serialize, Deserialize, Debug, Default)]
+#[derive(Serialize, Deserialize, Debug)]
 pub struct StartServiceOutput;
 
-#[derive(Clone, Serialize, Deserialize, Debug, Default)]
+#[derive(Serialize, Deserialize, Debug)]
 pub struct InitEnclaveInput;
 
-#[derive(Clone, Serialize, Deserialize, Debug, Default)]
+#[derive(Serialize, Deserialize, Debug)]
 pub struct InitEnclaveOutput;
 
-#[derive(Clone, Serialize, Deserialize, Debug, Default)]
+#[derive(Serialize, Deserialize, Debug)]
 pub struct FinalizeEnclaveInput;
 
-#[derive(Clone, Serialize, Deserialize, Debug, Default)]
+#[derive(Serialize, Deserialize, Debug)]
 pub struct FinalizeEnclaveOutput;
 
-#[derive(Clone, Serialize, Deserialize, Debug, Default)]
+#[derive(Serialize, Deserialize, Debug)]
 pub struct RunTestInput;
 
-#[derive(Clone, Serialize, Deserialize, Debug, Default)]
-pub struct RunTestOutput {
-    pub failed_count: usize,
-}
-
-#[derive(Clone, Serialize, Deserialize, Debug)]
-pub struct ServeConnectionInput {
-    pub socket_fd: c_int,
-    pub port: u16,
-}
-
-#[derive(Clone, Serialize, Deserialize, Debug, Default)]
-pub struct ServeConnectionOutput;
-
-impl ServeConnectionInput {
-    pub fn new(socket_fd: c_int, port: u16) -> ServeConnectionInput {
-        ServeConnectionInput { socket_fd, port }
-    }
-}
+#[derive(Serialize, Deserialize, Debug)]
+pub struct RunTestOutput;
diff --git a/services/access_control/enclave/src/lib.rs b/services/access_control/enclave/src/lib.rs
index 7163a62..14ee3b8 100644
--- a/services/access_control/enclave/src/lib.rs
+++ b/services/access_control/enclave/src/lib.rs
@@ -106,19 +106,19 @@ fn start_service(config: &RuntimeConfig) -> anyhow::Result<()>
{
 #[handle_ecall]
 fn handle_start_service(input: &StartServiceInput) -> TeeServiceResult<StartServiceOutput>
{
     start_service(&input.config).map_err(|_| TeeServiceError::ServiceError)?;
-    Ok(StartServiceOutput::default())
+    Ok(StartServiceOutput)
 }
 
 #[handle_ecall]
 fn handle_init_enclave(_: &InitEnclaveInput) -> TeeServiceResult<InitEnclaveOutput>
{
     ServiceEnclave::init(env!("CARGO_PKG_NAME"))?;
-    Ok(InitEnclaveOutput::default())
+    Ok(InitEnclaveOutput)
 }
 
 #[handle_ecall]
 fn handle_finalize_enclave(_: &FinalizeEnclaveInput) -> TeeServiceResult<FinalizeEnclaveOutput>
{
     ServiceEnclave::finalize()?;
-    Ok(FinalizeEnclaveOutput::default())
+    Ok(FinalizeEnclaveOutput)
 }
 
 register_ecall_handler!(
diff --git a/services/authentication/enclave/src/lib.rs b/services/authentication/enclave/src/lib.rs
index d3808dc..642c229 100644
--- a/services/authentication/enclave/src/lib.rs
+++ b/services/authentication/enclave/src/lib.rs
@@ -180,19 +180,19 @@ fn start_service(config: &RuntimeConfig) -> anyhow::Result<()>
{
 #[handle_ecall]
 fn handle_start_service(input: &StartServiceInput) -> TeeServiceResult<StartServiceOutput>
{
     start_service(&input.config).map_err(|_| TeeServiceError::ServiceError)?;
-    Ok(StartServiceOutput::default())
+    Ok(StartServiceOutput)
 }
 
 #[handle_ecall]
 fn handle_init_enclave(_: &InitEnclaveInput) -> TeeServiceResult<InitEnclaveOutput>
{
     ServiceEnclave::init(env!("CARGO_PKG_NAME"))?;
-    Ok(InitEnclaveOutput::default())
+    Ok(InitEnclaveOutput)
 }
 
 #[handle_ecall]
 fn handle_finalize_enclave(_: &FinalizeEnclaveInput) -> TeeServiceResult<FinalizeEnclaveOutput>
{
     ServiceEnclave::finalize()?;
-    Ok(FinalizeEnclaveOutput::default())
+    Ok(FinalizeEnclaveOutput)
 }
 
 register_ecall_handler!(
diff --git a/services/execution/enclave/src/lib.rs b/services/execution/enclave/src/lib.rs
index a88ee3f..e2699e8 100644
--- a/services/execution/enclave/src/lib.rs
+++ b/services/execution/enclave/src/lib.rs
@@ -75,19 +75,19 @@ fn start_service(config: &RuntimeConfig) -> anyhow::Result<()>
{
 #[handle_ecall]
 fn handle_start_service(input: &StartServiceInput) -> TeeServiceResult<StartServiceOutput>
{
     start_service(&input.config).map_err(|_| TeeServiceError::ServiceError)?;
-    Ok(StartServiceOutput::default())
+    Ok(StartServiceOutput)
 }
 
 #[handle_ecall]
 fn handle_init_enclave(_: &InitEnclaveInput) -> TeeServiceResult<InitEnclaveOutput>
{
     ServiceEnclave::init(env!("CARGO_PKG_NAME"))?;
-    Ok(InitEnclaveOutput::default())
+    Ok(InitEnclaveOutput)
 }
 
 #[handle_ecall]
 fn handle_finalize_enclave(_: &FinalizeEnclaveInput) -> TeeServiceResult<FinalizeEnclaveOutput>
{
     ServiceEnclave::finalize()?;
-    Ok(FinalizeEnclaveOutput::default())
+    Ok(FinalizeEnclaveOutput)
 }
 
 register_ecall_handler!(
diff --git a/services/frontend/enclave/src/lib.rs b/services/frontend/enclave/src/lib.rs
index 4dd7e04..1e55879 100644
--- a/services/frontend/enclave/src/lib.rs
+++ b/services/frontend/enclave/src/lib.rs
@@ -114,19 +114,19 @@ fn start_service(config: &RuntimeConfig) -> anyhow::Result<()>
{
 #[handle_ecall]
 fn handle_start_service(input: &StartServiceInput) -> TeeServiceResult<StartServiceOutput>
{
     start_service(&input.config).map_err(|_| TeeServiceError::ServiceError)?;
-    Ok(StartServiceOutput::default())
+    Ok(StartServiceOutput)
 }
 
 #[handle_ecall]
 fn handle_init_enclave(_: &InitEnclaveInput) -> TeeServiceResult<InitEnclaveOutput>
{
     ServiceEnclave::init(env!("CARGO_PKG_NAME"))?;
-    Ok(InitEnclaveOutput::default())
+    Ok(InitEnclaveOutput)
 }
 
 #[handle_ecall]
 fn handle_finalize_enclave(_: &FinalizeEnclaveInput) -> TeeServiceResult<FinalizeEnclaveOutput>
{
     ServiceEnclave::finalize()?;
-    Ok(FinalizeEnclaveOutput::default())
+    Ok(FinalizeEnclaveOutput)
 }
 
 register_ecall_handler!(
diff --git a/services/management/enclave/src/lib.rs b/services/management/enclave/src/lib.rs
index ee6fa37..9a60f89 100644
--- a/services/management/enclave/src/lib.rs
+++ b/services/management/enclave/src/lib.rs
@@ -126,19 +126,19 @@ fn start_service(config: &RuntimeConfig) -> anyhow::Result<()>
{
 #[handle_ecall]
 fn handle_start_service(input: &StartServiceInput) -> TeeServiceResult<StartServiceOutput>
{
     start_service(&input.config).map_err(|_| TeeServiceError::ServiceError)?;
-    Ok(StartServiceOutput::default())
+    Ok(StartServiceOutput)
 }
 
 #[handle_ecall]
 fn handle_init_enclave(_: &InitEnclaveInput) -> TeeServiceResult<InitEnclaveOutput>
{
     ServiceEnclave::init(env!("CARGO_PKG_NAME"))?;
-    Ok(InitEnclaveOutput::default())
+    Ok(InitEnclaveOutput)
 }
 
 #[handle_ecall]
 fn handle_finalize_enclave(_: &FinalizeEnclaveInput) -> TeeServiceResult<FinalizeEnclaveOutput>
{
     ServiceEnclave::finalize()?;
-    Ok(FinalizeEnclaveOutput::default())
+    Ok(FinalizeEnclaveOutput)
 }
 
 register_ecall_handler!(
diff --git a/services/storage/enclave/src/lib.rs b/services/storage/enclave/src/lib.rs
index 19a86d4..bbdbc5b 100644
--- a/services/storage/enclave/src/lib.rs
+++ b/services/storage/enclave/src/lib.rs
@@ -119,19 +119,19 @@ fn start_service(config: &RuntimeConfig) -> anyhow::Result<()>
{
 #[handle_ecall]
 fn handle_start_service(input: &StartServiceInput) -> TeeServiceResult<StartServiceOutput>
{
     start_service(&input.config).map_err(|_| TeeServiceError::ServiceError)?;
-    Ok(StartServiceOutput::default())
+    Ok(StartServiceOutput)
 }
 
 #[handle_ecall]
 fn handle_init_enclave(_: &InitEnclaveInput) -> TeeServiceResult<InitEnclaveOutput>
{
     ServiceEnclave::init(env!("CARGO_PKG_NAME"))?;
-    Ok(InitEnclaveOutput::default())
+    Ok(InitEnclaveOutput)
 }
 
 #[handle_ecall]
 fn handle_finalize_enclave(_: &FinalizeEnclaveInput) -> TeeServiceResult<FinalizeEnclaveOutput>
{
     ServiceEnclave::finalize()?;
-    Ok(FinalizeEnclaveOutput::default())
+    Ok(FinalizeEnclaveOutput)
 }
 
 register_ecall_handler!(
diff --git a/tests/functional/enclave/src/lib.rs b/tests/functional/enclave/src/lib.rs
index cd81445..a87e120 100644
--- a/tests/functional/enclave/src/lib.rs
+++ b/tests/functional/enclave/src/lib.rs
@@ -54,19 +54,19 @@ fn handle_run_test(_: &RunTestInput) -> TeeServiceResult<RunTestOutput>
{
     );
 
     assert_eq!(ret, true);
-    Ok(RunTestOutput::default())
+    Ok(RunTestOutput)
 }
 
 #[handle_ecall]
 fn handle_init_enclave(_: &InitEnclaveInput) -> TeeServiceResult<InitEnclaveOutput>
{
     ServiceEnclave::init(env!("CARGO_PKG_NAME"))?;
-    Ok(InitEnclaveOutput::default())
+    Ok(InitEnclaveOutput)
 }
 
 #[handle_ecall]
 fn handle_finalize_enclave(_: &FinalizeEnclaveInput) -> TeeServiceResult<FinalizeEnclaveOutput>
{
     ServiceEnclave::finalize()?;
-    Ok(FinalizeEnclaveOutput::default())
+    Ok(FinalizeEnclaveOutput)
 }
 
 register_ecall_handler!(
diff --git a/tests/integration/enclave/src/lib.rs b/tests/integration/enclave/src/lib.rs
index 52804ba..449c1b8 100644
--- a/tests/integration/enclave/src/lib.rs
+++ b/tests/integration/enclave/src/lib.rs
@@ -50,19 +50,19 @@ fn handle_run_test(_: &RunTestInput) -> TeeServiceResult<RunTestOutput>
{
     );
     assert_eq!(ret, true);
 
-    Ok(RunTestOutput::default())
+    Ok(RunTestOutput)
 }
 
 #[handle_ecall]
 fn handle_init_enclave(_: &InitEnclaveInput) -> TeeServiceResult<InitEnclaveOutput>
{
     ServiceEnclave::init(env!("CARGO_PKG_NAME"))?;
-    Ok(InitEnclaveOutput::default())
+    Ok(InitEnclaveOutput)
 }
 
 #[handle_ecall]
 fn handle_finalize_enclave(_: &FinalizeEnclaveInput) -> TeeServiceResult<FinalizeEnclaveOutput>
{
     ServiceEnclave::finalize()?;
-    Ok(FinalizeEnclaveOutput::default())
+    Ok(FinalizeEnclaveOutput)
 }
 
 register_ecall_handler!(
diff --git a/tests/unit/enclave/src/lib.rs b/tests/unit/enclave/src/lib.rs
index 25f0791..7a12fa7 100644
--- a/tests/unit/enclave/src/lib.rs
+++ b/tests/unit/enclave/src/lib.rs
@@ -55,19 +55,19 @@ fn handle_run_test(_: &RunTestInput) -> TeeServiceResult<RunTestOutput>
{
     #[cfg(not(sgx_sim))]
     assert!(teaclave_attestation::tests::run_tests());
 
-    Ok(RunTestOutput::default())
+    Ok(RunTestOutput)
 }
 
 #[handle_ecall]
 fn handle_init_enclave(_: &InitEnclaveInput) -> TeeServiceResult<InitEnclaveOutput>
{
     ServiceEnclave::init(env!("CARGO_PKG_NAME"))?;
-    Ok(InitEnclaveOutput::default())
+    Ok(InitEnclaveOutput)
 }
 
 #[handle_ecall]
 fn handle_finalize_enclave(_: &FinalizeEnclaveInput) -> TeeServiceResult<FinalizeEnclaveOutput>
{
     ServiceEnclave::finalize()?;
-    Ok(FinalizeEnclaveOutput::default())
+    Ok(FinalizeEnclaveOutput)
 }
 
 register_ecall_handler!(


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org


Mime
View raw message