summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2982b2f)
raw | patch | inline | side by side (parent: 2982b2f)
author | Justin Sobota <jsobota@ti.com> | |
Wed, 20 Feb 2013 22:50:48 +0000 (17:50 -0500) | ||
committer | Justin Sobota <jsobota@ti.com> | |
Wed, 20 Feb 2013 22:50:48 +0000 (17:50 -0500) |
include/rm_loc.h | patch | blob | history | |
src/rm.c | patch | blob | history | |
src/rm_nameserver.c | patch | blob | history | |
src/rm_services.c | patch | blob | history | |
src/rm_transport.c | patch | blob | history |
diff --git a/include/rm_loc.h b/include/rm_loc.h
index 1d0ffb409a65fd7c40a88fddcd2e6d5b417f3fce..ca4cd1c7a024e7b40ab138c0ed9c64a3a71f409c 100644 (file)
--- a/include/rm_loc.h
+++ b/include/rm_loc.h
Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst);
Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId);
int32_t rmTransactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId);
-void rmTransactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction);
+void rmProcessRouter(Rm_Inst *rmInst, Rm_Transaction *transaction);
#ifdef __cplusplus
}
diff --git a/src/rm.c b/src/rm.c
index a23fd5c18e9875ef1c81c9596c4de478f1b4e6e1..5a8b481335502a9a95ba50729d1499d5e29e89cf 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
return;
}
+/* FUNCTION PURPOSE: Handles static allocation requests
+ ***********************************************************************
+ * DESCRIPTION: Validates allocation requests received on CDs and
+ * Clients prior to the instance's registering
+ * with a Server. The allocation request is validated
+ * against a static policy.
+ */
+static void staticAllocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
+{
+ Rm_PolicyCheckCfg privCheckCfg;
+
+ if (rmInst->staticInfo.staticPolicy) {
+ if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
+ (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)) {
+ /* Check request against startup policy */
+ memset((void *)&privCheckCfg, 0, sizeof(Rm_PolicyCheckCfg));
+
+ if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
+ privCheckCfg.type = Rm_policyCheck_INIT;
+ }
+ else {
+ privCheckCfg.type = Rm_policyCheck_USE;
+ }
+ privCheckCfg.policyDtb = rmInst->staticInfo.staticPolicy;
+ privCheckCfg.validInstNode = rmPolicyGetValidInstNode(rmInst->staticInfo.staticValidInstTree,
+ rmInst->instName);
+ privCheckCfg.resourceOffset = rmPolicyGetResourceOffset(rmInst->staticInfo.staticPolicy,
+ transaction->resourceInfo.name);
+ privCheckCfg.resourceBase = transaction->resourceInfo.base;
+ privCheckCfg.resourceLength = transaction->resourceInfo.length;
+
+ if (rmPolicyCheckPrivilege(&privCheckCfg, &transaction->state)) {
+ transaction->state = RM_SERVICE_APPROVED_STATIC;
+ }
+ else if (transaction->state == RM_SERVICE_PROCESSING) {
+ /* Privilege check returned false without error */
+ transaction->state = RM_SERVICE_DENIED_BY_STATIC_POLICY;
+ }
+ }
+ else {
+ transaction->state = RM_SERVICE_DENIED_INVALID_STATIC_REQUEST;
+ }
+ }
+ else {
+ transaction->state = RM_ERROR_REQ_FAILED_NO_STATIC_POLICY;
+ }
+}
+
/* FUNCTION PURPOSE: Arbitrates allocation service requests
***********************************************************************
* DESCRIPTION: Issues a set of allocator operations in order to
* retrieved from the NameServer prior to the allocation
* attempt.
*/
-static void allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validInstNode,
- uint32_t allocType)
+static void allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
{
Rm_AllocatorOpInfo opInfo;
+
Rm_NameServerObjCfg nameServerObjCfg;
int32_t retVal = transaction->state;
- memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
-
if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
- /* Forward all allocation requests to Server if transport is up. Otherwise, just queue. */
- if (rmInst->registeredWithDelegateOrServer) {
- transactionForwarder(rmInst, transaction);
- }
+ transactionForwarder(rmInst, transaction);
}
else if (rmInst->instType == Rm_instType_SERVER) {
+ memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
+
opInfo.policy = rmInst->policy;
opInfo.resourceInfo = &transaction->resourceInfo;
- opInfo.serviceSrcInstNode = validInstNode;
- opInfo.allocType = allocType;
-
- /* Populated NameServer name has precedence over base */
- if (strlen(transaction->resourceInfo.nameServerName) > 0) {
- if ((transaction->resourceInfo.base == 0) &&
- (transaction->resourceInfo.length == 0) &&
- (transaction->resourceInfo.alignment == 0)) {
- memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
- nameServerObjCfg.nameServerTree = rmInst->nameServer;
- nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
- if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
- strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
- transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
- transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
- }
- }
- else {
- retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;
+ opInfo.serviceSrcInstNode = rmPolicyGetValidInstNode(rmInst->validInstances, transaction->serviceSrcInstName);
+ if (opInfo.serviceSrcInstNode) {
+ switch (transaction->type) {
+ case Rm_service_RESOURCE_ALLOCATE_INIT:
+ RM_policy_SET_PERM(opInfo.allocType, RM_POLICY_PERM_INIT_SHIFT, 1);
+ break;
+ case Rm_service_RESOURCE_ALLOCATE_USE:
+ RM_policy_SET_PERM(opInfo.allocType, RM_POLICY_PERM_USE_SHIFT, 1);
+ break;
+ }
+
+ /* Populated NameServer name has precedence over base */
+ if (strlen(transaction->resourceInfo.nameServerName) > 0) {
+ if ((transaction->resourceInfo.base == 0) &&
+ (transaction->resourceInfo.length == 0) &&
+ (transaction->resourceInfo.alignment == 0)) {
+ memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
+ nameServerObjCfg.nameServerTree = rmInst->nameServer;
+ nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
+ if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
+ strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+ transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
+ transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
+ }
+ }
+ else {
+ retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;
+ }
}
- }
- if (retVal == RM_SERVICE_PROCESSING) {
- if (transaction->resourceInfo.base == RM_RESOURCE_BASE_UNSPECIFIED) {
- opInfo.operation = Rm_allocatorOp_PRE_ALLOCATE;
- retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+ if (retVal == RM_SERVICE_PROCESSING) {
+ if (transaction->resourceInfo.base == RM_RESOURCE_BASE_UNSPECIFIED) {
+ opInfo.operation = Rm_allocatorOp_PRE_ALLOCATE;
+ retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+ }
+
+ if (retVal == RM_SERVICE_PROCESSING) {
+ opInfo.operation = Rm_allocatorOp_ALLOCATE;
+ retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+ }
}
-
- if (retVal == RM_SERVICE_PROCESSING) {
- opInfo.operation = Rm_allocatorOp_ALLOCATE;
- retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
- }
}
-
- transaction->state = retVal;
-
- if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
- /* Source of allocation was not the server instance, provide the transaction
- * to the transaction responder */
- transactionResponder(rmInst, transaction);
+ else {
+ retVal = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
}
- /* Otherwise let the return stack return the transaction to the serviceHandler */
+
+ transaction->state = retVal;
}
}
@@ -433,58 +483,226 @@ static void allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, voi
* retrieved from the NameServer prior to the free
* attempt.
*/
-static void freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction, void *validInstNode)
+static void freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
{
Rm_AllocatorOpInfo opInfo;
Rm_NameServerObjCfg nameServerObjCfg;
int32_t retVal = transaction->state;
-
- memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
- /* Forward all free requests to Server if transport is up. Otherwise, just queue. */
- if (rmInst->registeredWithDelegateOrServer) {
- transactionForwarder(rmInst, transaction);
- }
+ transactionForwarder(rmInst, transaction);
}
else if (rmInst->instType == Rm_instType_SERVER) {
+ memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
+
opInfo.policy = rmInst->policy;
opInfo.resourceInfo = &transaction->resourceInfo;
- opInfo.serviceSrcInstNode = validInstNode;
+ opInfo.serviceSrcInstNode = rmPolicyGetValidInstNode(rmInst->validInstances, transaction->serviceSrcInstName);
+ if (opInfo.serviceSrcInstNode) {
+ /* Populated NameServer name has precedence over base */
+ if (strlen(transaction->resourceInfo.nameServerName) > 0) {
+ if ((transaction->resourceInfo.base == 0) &&
+ (transaction->resourceInfo.length == 0) &&
+ (transaction->resourceInfo.alignment == 0)) {
+ memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
+ nameServerObjCfg.nameServerTree = rmInst->nameServer;
+ nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
+ if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
+ strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+ transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
+ transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
+ }
+ }
+ else {
+ retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;
+ }
+ }
+
+ if(retVal == RM_SERVICE_PROCESSING) {
+ opInfo.operation = Rm_allocatorOp_FREE;
+ retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+ }
+ }
+ else {
+ retVal = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
+ }
+
+ transaction->state = retVal;
+ }
+}
+
+/* FUNCTION PURPOSE: Client transaction handling process
+ ***********************************************************************
+ * DESCRIPTION: Client process for handling transactions created
+ * from services received via the service handle or the
+ * transport. The Client process:
+ * - Performs static allocations if no transport
+ * to CD or Server has been registered
+ * - Forwards all service requests to CD or Server
+ * once transport has been registered
+ */
+static void clientProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
+{
+ Rm_Transaction *transQ = rmInst->transactionQueue;
+
+ if (!rmInst->registeredWithDelegateOrServer) {
+ staticAllocationHandler(rmInst, transaction);
+ }
+ else {
+ if (transaction->state == RM_SERVICE_PROCESSING) {
+ /* Forward all new transactions to CD or Server */
+ transactionForwarder(rmInst, transaction);
+ }
+ else {
+ /* Transaction validated. Return result. */
+ serviceResponder(rmInst, transaction);
+ }
+
+ /* Forward any queued static requests that weren't forwarded */
+ while(transQ) {
+ if ((transQ->state == RM_SERVICE_APPROVED_STATIC) &&
+ (!transQ->hasBeenForwarded)) {
+ transactionForwarder(rmInst, transQ);
+ }
+ transQ = transQ->nextTransaction;
+ }
+ }
+ /* Let call stack return transaction result app via Rm_serviceHandler */
+}
+
+/* FUNCTION PURPOSE: Client Delegate transaction handling process
+ ***********************************************************************
+ * DESCRIPTION: Client Delegate process for handling transactions created
+ * from services received via the service handle or the
+ * transport. The Client Delegate process:
+ * - Performs static allocations if no transport
+ * to Server has been registered
+ * - Forwards all NameServer related service requests
+ * to Server once transport has been registered
+ * - Attempts to complete resource service requests
+ * received from registered Clients
+ */
+static void clientDelegateProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
+{
+ Rm_Transaction *transQ = rmInst->transactionQueue;
+
+ if (!rmInst->registeredWithDelegateOrServer) {
+ if ((transaction->state == RM_SERVICE_PROCESSING) &&
+ (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS) == 0)) {
+ staticAllocationHandler(rmInst, transaction);
+ }
+ /* Everything else left in transaction queue for forwarding once transport to
+ * Server is registered */
+ }
+ else {
+ if ((transaction->state == RM_SERVICE_PROCESSING) ||
+ (transaction->state == RM_SERVICE_APPROVED_STATIC)) {
+ if ((transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) ||
+ (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) ||
+ (transaction->type == Rm_service_RESOURCE_UNMAP_NAME)) {
+ /* Forward all NameServer requests. */
+ transactionForwarder(rmInst, transaction);
+ }
+ else if (transaction->type == Rm_service_RESOURCE_FREE) {
+ freeHandler(rmInst, transaction);
+ }
+ else {
+ allocationHandler(rmInst, transaction);
+ }
+
+ if ((transaction->state != RM_SERVICE_PROCESSING) &&
+ (transaction->state != RM_SERVICE_APPROVED_STATIC)) {
+ /* Transaction error occurred. Return result */
+ if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
+ /* Source of failed transaction was not CD, return transaction via responder */
+ transactionResponder(rmInst, transaction);
+ }
+ /* Otherwise let call stack return failed transaction result app via Rm_serviceHandler */
+ }
+ }
+ else {
+ /* Transaction validated. Return result. */
+ if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
+ /* Transaction did not originate on this instance */
+ transactionResponder(rmInst, transaction);
+ }
+ else {
+ /* Transaction originated on this instance */
+ serviceResponder(rmInst, transaction);
+ }
+ }
- /* Populated NameServer name has precedence over base */
- if (strlen(transaction->resourceInfo.nameServerName) > 0) {
- if ((transaction->resourceInfo.base == 0) &&
- (transaction->resourceInfo.length == 0) &&
- (transaction->resourceInfo.alignment == 0)) {
+ /* Forward any queued static requests (local and received from any registered
+ * Clients that weren't forwarded */
+ while(transQ) {
+ if (((transQ->state == RM_SERVICE_PROCESSING) ||
+ (transQ->state == RM_SERVICE_APPROVED_STATIC)) &&
+ (!transQ->hasBeenForwarded)) {
+ transactionForwarder(rmInst, transQ);
+ }
+ transQ = transQ->nextTransaction;
+ }
+ }
+}
+
+/* FUNCTION PURPOSE: Server transaction handling process
+ ***********************************************************************
+ * DESCRIPTION: Server process for handling transactions created
+ * from services received via the service handle or the
+ * transport. The Server process:
+ * - Validates all service requests received from
+ * the service handle and registered CDs and
+ * Clients
+ */
+static void serverProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
+{
+ Rm_NameServerObjCfg nameServerObjCfg;
+
+ switch (transaction->type) {
+ case Rm_service_RESOURCE_ALLOCATE_INIT:
+ case Rm_service_RESOURCE_ALLOCATE_USE:
+ allocationHandler(rmInst, transaction);
+ break;
+ case Rm_service_RESOURCE_FREE:
+ freeHandler(rmInst, transaction);
+ break;
+ case Rm_service_RESOURCE_MAP_TO_NAME:
+ case Rm_service_RESOURCE_GET_BY_NAME:
+ case Rm_service_RESOURCE_UNMAP_NAME:
+ if (rmInst->nameServer) {
memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
nameServerObjCfg.nameServerTree = rmInst->nameServer;
nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
- if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
- strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
- transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
- transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
- }
+ if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {
+ nameServerObjCfg.nodeCfg.resourceName = transaction->resourceInfo.name;
+ nameServerObjCfg.nodeCfg.resourceBase= transaction->resourceInfo.base;
+ nameServerObjCfg.nodeCfg.resourceLength = transaction->resourceInfo.length;
+ transaction->state = rmNameServerAddObject(&nameServerObjCfg);
+ }
+ else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
+ if ((transaction->state = rmNameServerFindObject(&nameServerObjCfg)) ==
+ RM_SERVICE_PROCESSING) {
+ strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+ transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
+ transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
+ transaction->state = RM_SERVICE_APPROVED;
+ }
+ }
+ else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {
+ transaction->state = rmNameServerDeleteObject(&nameServerObjCfg);
+ }
}
else {
- retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;
- }
- }
-
- if(retVal == RM_SERVICE_PROCESSING) {
- opInfo.operation = Rm_allocatorOp_FREE;
- retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
- }
-
- transaction->state = retVal;
+ transaction->state = RM_ERROR_NAMESERVER_DOES_NOT_EXIST;
+ }
+ break;
+ }
- if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
- /* Source of allocation was not the server instance, provide the transaction
- * to the transaction responder */
- transactionResponder(rmInst, transaction);
- }
- /* Otherwise let the return stack return the transaction to the serviceHandler */
- }
+ if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
+ /* Source of transaction was not Server, return transaction via responder */
+ transactionResponder(rmInst, transaction);
+ }
+ /* Otherwise let call stack return transaction result app via Rm_serviceHandler */
}
/**********************************************************************
return (retVal);
}
-/* FUNCTION PURPOSE: Processes a transaction
+/* FUNCTION PURPOSE: Routes a transaction for processing
***********************************************************************
- * DESCRIPTION: Processes transactions created from services
- * received via the service handle or the transport.
- * Transactions will be routed within the RM system
- * based on the RM instance type and the type of
- * the transaction.
+ * DESCRIPTION: Routes a received transaction to the appropriate
+ * instance processing routine
*/
-void rmTransactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction)
+void rmProcessRouter (Rm_Inst *rmInst, Rm_Transaction *transaction)
{
- void *validInstNode;
- Rm_PolicyCheckCfg privCheckCfg;
- Rm_NameServerObjCfg nameServerObjCfg;
- uint32_t allocType = 0;
-
- /* Handle static transactions originating on this instance. Any other static transactions will be
- * stored in transaction queue until all transports are up. */
- if (((rmInst->instType == Rm_instType_CLIENT) || (rmInst->instType == Rm_instType_CLIENT_DELEGATE)) &&
- (!rmInst->registeredWithDelegateOrServer) &&
- (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS) == 0)) {
- if (rmInst->staticInfo.staticPolicy) {
- if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
- (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)) {
- /* Check request against startup policy */
- memset((void *)&privCheckCfg, 0, sizeof(Rm_PolicyCheckCfg));
-
- if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
- privCheckCfg.type = Rm_policyCheck_INIT;
- }
- else {
- privCheckCfg.type = Rm_policyCheck_USE;
- }
- privCheckCfg.policyDtb = rmInst->staticInfo.staticPolicy;
- privCheckCfg.validInstNode = rmPolicyGetValidInstNode(rmInst->staticInfo.staticValidInstTree,
- rmInst->instName);
- privCheckCfg.resourceOffset = rmPolicyGetResourceOffset(rmInst->staticInfo.staticPolicy,
- transaction->resourceInfo.name);
- privCheckCfg.resourceBase = transaction->resourceInfo.base;
- privCheckCfg.resourceLength = transaction->resourceInfo.length;
-
- if (rmPolicyCheckPrivilege(&privCheckCfg, &transaction->state)) {
- transaction->state = RM_SERVICE_APPROVED_STATIC;
- }
- else if (transaction->state == RM_SERVICE_PROCESSING) {
- /* Privilege check returned false without error */
- transaction->state = RM_SERVICE_DENIED_BY_STATIC_POLICY;
- }
- }
- else {
- transaction->state = RM_SERVICE_DENIED_INVALID_STATIC_REQUEST;
- }
- }
- else {
- transaction->state = RM_ERROR_REQ_FAILED_NO_STATIC_POLICY;
- }
- }
- else {
- /* Handle auto-forwarded transactions. These transactions include:
- * - All request transactions received on Clients are forwarded to the Client Delegate
- * - NameServer requests received on the Client Delegate are forwarded to the Server */
- if ((rmInst->instType == Rm_instType_CLIENT) ||
- ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&
- ((transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) ||
- (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) ||
- (transaction->type == Rm_service_RESOURCE_UNMAP_NAME)))) {
-
- if ((transaction->state != RM_SERVICE_PROCESSING) &&
- (transaction->state != RM_SERVICE_APPROVED_STATIC)) {
- if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
- /* Transaction did not originate on this instance */
- transactionResponder(rmInst, transaction);
- }
- else {
- /* Transaction originated on this instance */
- serviceResponder(rmInst, transaction);
- }
- }
- else {
- /* Forward request if transport is up. Otherwise, just queue. */
- if (rmInst->registeredWithDelegateOrServer) {
- transactionForwarder(rmInst, transaction);
- }
- }
- }
- else {
- /* Validate service's originating instance name */
- if (rmInst->instType == Rm_instType_SERVER) {
- validInstNode = rmPolicyGetValidInstNode(rmInst->validInstances, transaction->serviceSrcInstName);
- if (validInstNode == NULL) {
- transaction->state = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
-
- /* Send result via responder if transaction did not originate from this instance */
- if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
- transactionResponder(rmInst, transaction);
- }
- }
- }
-
- switch (transaction->type) {
- case Rm_service_RESOURCE_ALLOCATE_INIT:
- case Rm_service_RESOURCE_ALLOCATE_USE:
- case Rm_service_RESOURCE_FREE:
- if ((transaction->state != RM_SERVICE_PROCESSING) &&
- (transaction->state != RM_SERVICE_APPROVED_STATIC)) {
- /* Transaction complete */
- if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
- /* Transaction result not destined for this instance */
- transactionResponder(rmInst, transaction);
- }
- else {
- /* Transaction result destined for this instance */
- serviceResponder(rmInst, transaction);
- }
- }
- else {
- /* Complete allocation/free request */
- if (transaction->type == Rm_service_RESOURCE_FREE) {
- freeHandler(rmInst, transaction, validInstNode);
- }
- else {
- switch (transaction->type) {
- case Rm_service_RESOURCE_ALLOCATE_INIT:
- RM_policy_SET_PERM(allocType, RM_POLICY_PERM_INIT_SHIFT, 1);
- break;
- case Rm_service_RESOURCE_ALLOCATE_USE:
- RM_policy_SET_PERM(allocType, RM_POLICY_PERM_USE_SHIFT, 1);
- break;
- }
- allocationHandler(rmInst, transaction, validInstNode, allocType);
- }
- }
- break;
- case Rm_service_RESOURCE_MAP_TO_NAME:
- case Rm_service_RESOURCE_GET_BY_NAME:
- case Rm_service_RESOURCE_UNMAP_NAME:
- /* NameServer resides on server */
- memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
- if (rmInst->nameServer) {
- nameServerObjCfg.nameServerTree = rmInst->nameServer;
- nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
- if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {
- nameServerObjCfg.nodeCfg.resourceName = transaction->resourceInfo.name;
- nameServerObjCfg.nodeCfg.resourceBase= transaction->resourceInfo.base;
- nameServerObjCfg.nodeCfg.resourceLength = transaction->resourceInfo.length;
- transaction->state = rmNameServerAddObject(&nameServerObjCfg);
- }
- else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
- if ((transaction->state = rmNameServerFindObject(&nameServerObjCfg)) ==
- RM_SERVICE_PROCESSING) {
- strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
- transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
- transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
- transaction->state = RM_SERVICE_APPROVED;
- }
- }
- else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {
- transaction->state = rmNameServerDeleteObject(&nameServerObjCfg);
- }
- }
- else {
- transaction->state = RM_ERROR_NAMESERVER_DOES_NOT_EXIST;
- }
-
- /* Send result via responder if transaction did not originate from this instance */
- if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
- transactionResponder(rmInst, transaction);
- }
- break;
- }
- }
+ if (rmInst->instType == Rm_instType_CLIENT) {
+ clientProcess(rmInst, transaction);
}
-
- /* Forward any queued requests that weren't forwarded yet */
- if (rmInst->registeredWithDelegateOrServer) {
- transaction = rmInst->transactionQueue;
- while(transaction) {
- if (((transaction->state == RM_SERVICE_PROCESSING) ||
- (transaction->state == RM_SERVICE_APPROVED_STATIC)) &&
- !transaction->hasBeenForwarded) {
- transactionForwarder(rmInst, transaction);
- }
- transaction = transaction->nextTransaction;
- }
+ else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+ clientDelegateProcess(rmInst, transaction);
}
+ else if (rmInst->instType == Rm_instType_SERVER) {
+ serverProcess(rmInst, transaction);
+ }
}
/**********************************************************************
diff --git a/src/rm_nameserver.c b/src/rm_nameserver.c
index e6e765e0a9a0b9d847d009f2bcd5a660092f4552..b6293fc74a1609cbf6009bea6cc5a6fa76b48f63 100644 (file)
--- a/src/rm_nameserver.c
+++ b/src/rm_nameserver.c
*/
int32_t rmNameServerAddObject(Rm_NameServerObjCfg *objCfg)
{
- Rm_NameServerNode *newNode = NULL;
- int32_t retVal = RM_SERVICE_APPROVED;
+ Rm_NameServerNode *newNode = NULL;
+ int32_t retVal = RM_SERVICE_APPROVED;
if (newNode = rmNameServerNodeNew(&objCfg->nodeCfg)) {
if (RB_INSERT(_Rm_NameServerTree, objCfg->nameServerTree, newNode)) {
diff --git a/src/rm_services.c b/src/rm_services.c
index f8af02dcdfec633656a55286365093f0ead5df7e..ab09e705bb497571f9d4609959aeb90ae6ea28d5 100644 (file)
--- a/src/rm_services.c
+++ b/src/rm_services.c
void Rm_serviceHandler (void *rmHandle, const Rm_ServiceReqInfo *serviceRequest,
Rm_ServiceRespInfo *serviceResponse)
{
- Rm_Inst *rmInst = (Rm_Inst *)rmHandle;
- Rm_Transaction *transaction;
+ Rm_Inst *rmInst = (Rm_Inst *)rmHandle;
+ Rm_Transaction *transaction;
if (rmInst->isLocked) {
serviceResponse->serviceState = RM_SERVICE_DENIED_RM_INSTANCE_LOCKED;
strncpy(transaction->resourceInfo.nameServerName, serviceRequest->resourceNsName, RM_NAME_MAX_CHARS);
}
- rmTransactionProcessor (rmInst, transaction);
+ /* Process received transaction */
+ rmProcessRouter(rmInst, transaction);
+
memset((void *)serviceResponse, 0, sizeof(Rm_ServiceRespInfo));
serviceResponse->serviceState = transaction->state;
if ((serviceResponse->serviceState == RM_SERVICE_PROCESSING) ||
diff --git a/src/rm_transport.c b/src/rm_transport.c
index e815441d4d856587b67cff8028b295e94b496f00..8b93933d5b4070ab0debcfacc2531e32321c0d14 100644 (file)
--- a/src/rm_transport.c
+++ b/src/rm_transport.c
***********************************************************************\r
* DESCRIPTION: The application provides RM packets received on the\r
* application transports to RM via this API. Function\r
- * can be called from polling or ISR contexts. */\r
+ * can be called from polling or ISR contexts. Assume \r
+ * invoking application will free packet after this\r
+ * function returns.\r
+ */\r
int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pkt)\r
{\r\r\r
Rm_Transport *transport = (Rm_Transport *)transportHandle;\r
Rm_Inst *rmInst = (Rm_Inst *)transport->rmHandle;\r
Rm_Transaction *transaction;\r
+ int32_t retVal = RM_OK;\r
\r
if (!transportIsRegistered(transport->rmHandle, transport)) {\r
- return (RM_ERROR_TRANSPORT_HANDLE_DOES_NOT_EXIST);\r
+ retVal = RM_ERROR_TRANSPORT_HANDLE_DOES_NOT_EXIST;\r
+ goto errorExit;\r
}\r
\r
switch (pkt->pktType) {\r
@@ -311,7 +316,6 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
transaction->state = RM_SERVICE_PROCESSING;\r
memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceReqPkt->resourceInfo),\r
sizeof(Rm_ResourceInfo));\r
- rmTransactionProcessor(rmInst, transaction);\r
break;\r
}\r
case Rm_pktType_RESOURCE_RESPONSE:\r
@@ -334,10 +338,10 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceRespPkt->resourceInfo),\r
sizeof(Rm_ResourceInfo));\r
}\r
- rmTransactionProcessor(rmInst, transaction);\r
}\r
else {\r
- return (RM_ERROR_PKT_RESP_DOES_NOT_MATCH_ANY_REQ);\r
+ retVal = RM_ERROR_PKT_RESP_DOES_NOT_MATCH_ANY_REQ;\r
+ goto errorExit;\r
}\r
break;\r
}\r
@@ -359,8 +363,7 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
strncpy(transaction->serviceSrcInstName, nsRequestPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
transaction->state = RM_SERVICE_PROCESSING;\r
memcpy ((void *)&(transaction->resourceInfo), (void *)&(nsRequestPkt->resourceInfo),\r
- sizeof(Rm_ResourceInfo));\r
- rmTransactionProcessor(rmInst, transaction); \r
+ sizeof(Rm_ResourceInfo)); \r
break;\r
}\r
case Rm_pktType_NAMESERVER_RESPONSE:\r
@@ -375,17 +378,21 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
rmInst->isLocked = true;\r
} \r
transaction->state = nsResponsePkt->requestState; \r
- rmTransactionProcessor(rmInst, transaction);\r
}\r
else {\r
- return (RM_ERROR_PKT_RESP_DOES_NOT_MATCH_ANY_REQ);\r
+ retVal = RM_ERROR_PKT_RESP_DOES_NOT_MATCH_ANY_REQ;\r
+ goto errorExit;\r
}\r
break;\r
}\r
default:\r
- return (RM_ERROR_RECEIVED_INVALID_PACKET_TYPE);\r
- }\r
+ retVal = RM_ERROR_RECEIVED_INVALID_PACKET_TYPE;\r
+ goto errorExit;\r
+ }\r
\r
- return (RM_OK);\r
+ /* Process received transaction */\r
+ rmProcessRouter(rmInst, transaction); \r
+errorExit:\r
+ return(retVal);\r
}\r
\r