Commit 286accd4 authored by Josh Kunz's avatar Josh Kunz

Add node_grant.rp0() method to obtain node rp0

parent ba83300e
......@@ -82,6 +82,8 @@ static cn_method_t __cn_method_for_CPObjMethod(Cp__CPObjMethod m) {
return CN_MEMBRANE_RECV_WAIT;
case CP__CPOBJ_METHOD__CPOBJMETHOD_NODE_GRANT_GRANT:
return CN_NODE_GRANT_GRANT;
case CP__CPOBJ_METHOD__CPOBJMETHOD_NODE_GRANT_RP0:
return CN_NODE_GRANT_RP0;
case CP__CPOBJ_METHOD__CPOBJMETHOD_SEALER_UNSEALER_SEAL:
return CN_SEALER_UNSEALER_SEAL;
case CP__CPOBJ_METHOD__CPOBJMETHOD_SEALER_UNSEALER_UNSEAL:
......@@ -1324,6 +1326,15 @@ int cn_dispatch_invoke(cn_principal_t *as, cn_dispatch_result_t *result,
}
}
break;
case CN_NODE_GRANT_RP0: {
cptr_t rp0;
if (cn_node_grant_rp0(obj_cnode, &rp0) != 0) {
res = fail_invoke(result, "failed to get rp0 from node grant");
goto fail1;
}
push_item_cptr(result, rp0, CN_RP);
}
break;
case CN_SEALER_UNSEALER_SEAL: {
cn_dispatch_invoke_sealer_unsealer_seal_args_t * seal_args = args;
cn_objtype_t type;
......
......@@ -32,6 +32,7 @@ typedef enum {
CN_MEMBRANE_CLEAR,
CN_MEMBRANE_RECV_WAIT,
CN_NODE_GRANT_GRANT,
CN_NODE_GRANT_RP0,
CN_SEALER_UNSEALER_SEAL,
CN_SEALER_UNSEALER_UNSEAL,
CN_SEALER_UNSEALER_RESTRICT_TO_SEAL,
......@@ -53,6 +54,7 @@ static const char * METHOD_NAMES[] = {
"membrane_clear",
"membrane_recv_wait",
"node_grant_grant",
"node_grant_rp0",
"sealer_unsealer_seal",
"sealer_unsealer_unseal",
"sealer_unsealer_restrict_to_seal",
......
......@@ -1627,6 +1627,28 @@ int cn_node_grant_grant(struct cnode * grant_cnode,
return res;
}
int cn_node_grant_rp0(struct cnode * grant_cnode, cptr_t *o_rp_cap) {
assert(cn_cnode_type(grant_cnode) == CN_NODE_GRANT);
cn_node_grant_t * grant = (cn_node_grant_t *) cn_cnode_object(grant_cnode);
cn_obj_lock(grant);
cn_obj_lock(grant->node);
cn_objtype_t type;
int res = cn_membrane_grant(cap_cnode_metadata(grant_cnode), /*recv_meta=*/NULL,
grant->node->secret, grant->node->rp0,
cn_cnode_principal(grant_cnode), o_rp_cap, &type);
if (res != 0) {
cncerr("cn_membrane_grant failed for node_grant_rp0");
}
cn_obj_unlock(grant->node);
cn_obj_unlock(grant);
return res;
}
/* sec: RP Manipulation */
/* Forward declarations */
......
......@@ -883,6 +883,10 @@ int cn_node_grant_grant(struct cnode * grant_cnode,
cn_principal_t *p, cptr_t cap,
cptr_t *o_cap, cn_objtype_t * o_type);
/* Fetch the RP0 of the node this grant is for. A capability to the node's
* RP0 is stored in `o_rp_cap`. Returns 0 on success. */
int cn_node_grant_rp0(struct cnode * grant_cnode, cptr_t *o_rp_cap);
/* --------- RP Manipulation --------- */
/* Creates a "normal" rp_elem struct that consistes of a principal and a
......
......@@ -170,6 +170,7 @@ enum CPObjMethod {
CPOBJMETHOD_BROKER_LOOKUP = 7;
CPOBJMETHOD_BROKER_LOOKUP_WAIT = 17;
CPOBJMETHOD_NODE_GRANT_GRANT = 10;
CPOBJMETHOD_NODE_GRANT_RP0 = 18;
CPOBJMETHOD_SEALER_UNSEALER_SEAL = 13;
CPOBJMETHOD_SEALER_UNSEALER_UNSEAL = 14;
CPOBJMETHOD_SEALER_UNSEALER_RESTRICT_TO_SEAL = 15;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment