]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/commitdiff
Cleaned up cross-references in internal rm transport API
authorJustin Sobota <jsobota@ti.com>
Thu, 14 Feb 2013 18:39:07 +0000 (13:39 -0500)
committerJustin Sobota <jsobota@ti.com>
Thu, 14 Feb 2013 18:39:07 +0000 (13:39 -0500)
include/rm_internal.h [new file with mode: 0644]
include/rm_loc.h
include/rm_transportloc.h
rm.h
rm_transport.h
src/rm.c
src/rm_transport.c
test/rm_test.c

diff --git a/include/rm_internal.h b/include/rm_internal.h
new file mode 100644 (file)
index 0000000..5221a84
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ *  file  rm_internal.h
+ *
+ *  Data structures used by more than one internal RM module.
+ *
+ *  ============================================================================
+ *      (C) Copyright 2012-2013, Texas Instruments, Inc.
+ * 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  \par
+*/
+
+#ifndef RM_INTERNAL_H_
+#define RM_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Standard includes */
+#include <stdbool.h>
+
+/* RM external includes */
+#include <ti/drv/rm/rm.h>
+
+/* RM resource information */
+typedef struct {
+    /* Resource name */
+    char     name[RM_NAME_MAX_CHARS];
+    /* Resource base value */
+    int32_t  base;
+    /* Resource length value */
+    uint32_t length;
+    /* Resource alignment */
+    int32_t  alignment;
+    /* NameServer name tied to resource */
+    char     nameServerName[RM_NAME_MAX_CHARS];
+} Rm_ResourceInfo;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RM_INTERNAL_H_ */
+
index b74aa39d0f67956979b0f9de7cbeb3af60dccd40..1379ce68018abc54de7cd08939ca2fc1cb0b1f44 100644 (file)
@@ -45,28 +45,16 @@ extern "C" {
 #endif
 
 /* RM external includes */
+#include <ti/drv/rm/rm.h>
 #include <ti/drv/rm/rm_services.h>
-#include <ti/drv/rm/rm_transport.h>
 
 /* RM internal includes */
+#include <ti/drv/rm/include/rm_internal.h>
 #include <ti/drv/rm/include/rm_policyloc.h>
+#include <ti/drv/rm/include/rm_transportloc.h>
 #include <ti/drv/rm/include/rm_nameserverloc.h>
 #include <ti/drv/rm/include/rm_treeloc.h>
 
-/* RM resource information */
-typedef struct {
-    /* Resource name */
-    char     name[RM_NAME_MAX_CHARS];
-    /* Resource base value */
-    int32_t  base;
-    /* Resource length value */
-    uint32_t length;
-    /* Resource alignment */
-    int32_t  alignment;
-    /* NameServer name tied to resource */
-    char     nameServerName[RM_NAME_MAX_CHARS];
-} Rm_ResourceInfo;
-
 /* Service transaction linked list node */
 typedef struct Rm_Transaction_s {
     /* Transaction service type */
@@ -177,14 +165,11 @@ typedef struct {
      * Applicable to CD and Client instances */
     bool                    registeredWithDelegateOrServer;
     /* Linked list of transports registered by the application */
-    void                   *transports;
+    Rm_Transport           *transports;
     /* Service transaction sequence number tracker */
     uint32_t                transactionSeqNum;
     /* Service transaction linked list queue */
     Rm_Transaction         *transactionQueue;
-    /* Transport callout functions provided by application during transport
-     * registration */
-    Rm_TransportCallouts    transportCallouts;
     /* [Server] Pointer to the global policy */
     void                   *policy;
     /* [Server] Pointer to root entry of the global policy valid instance tree */
index 8ea1c6deac38496d223fe5beb94cae06df9a4074..3cfb64ac90ac46af002fc39e39f3a0db68678fad 100644 (file)
@@ -49,7 +49,7 @@ extern "C" {
 #include <ti/drv/rm/rm_transport.h>
 
 /* RM internal includes */
-#include <ti/drv/rm/include/rm_loc.h>
+#include <ti/drv/rm/include/rm_internal.h>
 
 /* This macro generates compilier error if postulate is false, so 
  * allows 0 overhead compile time size check.  This "works" when
@@ -80,6 +80,9 @@ typedef struct Rm_Transport_s {
     Rm_InstType            remoteInstType;
     /* Remote RM instance name */
     char                   remoteInstName[RM_NAME_MAX_CHARS];
+    /* Transport callout functions provided by application during transport
+     * registration */
+    Rm_TransportCallouts   callouts;    
     /* Link to next transport node */
     struct Rm_Transport_s *nextTransport;
 } Rm_Transport;
@@ -173,14 +176,6 @@ typedef struct {
 
 Rm_Transport *rmTransportFindRemoteName(Rm_Transport *transports, char *remoteName);
 Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports, Rm_InstType remoteInstType);
-Rm_PacketHandle rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,
-                                                Rm_Transaction *transaction);
-Rm_PacketHandle rmTransportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,
-                                                     Rm_Transaction *transaction);
-Rm_PacketHandle rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,
-                                              Rm_Transaction *transaction);
-Rm_PacketHandle rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,
-                                               Rm_Transaction *transaction);
 
 #ifdef __cplusplus
 }
diff --git a/rm.h b/rm.h
index 4203e0c248c1471ac2b0c706f5dbbb654816d1fd..77143d4b6698345b155b65b36b4364e845c2bbec 100644 (file)
--- a/rm.h
+++ b/rm.h
@@ -296,18 +296,19 @@ extern "C" {
 /** RM client attempted to register with more than one Server or CD or a CD attempted to register 
  *  with more than one Server */
 #define RM_ERROR_ALREADY_REGD_SERVER_OR_CD         RM_ERROR_BASE-37
-/** Transport registration callout function pointers specified as valid but were NULL */
-#define RM_ERROR_NULL_CALLOUTS_WHEN_VALID          RM_ERROR_BASE-38
 /** Service has both a NameServer name and a base, length, or alignment specified */
-#define RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT      RM_ERROR_BASE-39
+#define RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT      RM_ERROR_BASE-38
 /** Instance type not recognized */
-#define RM_ERROR_INVALID_INST_TYPE                 RM_ERROR_BASE-40
+#define RM_ERROR_INVALID_INST_TYPE                 RM_ERROR_BASE-39
 /** Linux DTB alias properties specified in GRL but no Linux DTB provided during server instance init */
-#define RM_ERROR_GRL_LINUX_ALIAS_BUT_NO_DTB        RM_ERROR_BASE-41
+#define RM_ERROR_GRL_LINUX_ALIAS_BUT_NO_DTB        RM_ERROR_BASE-40
 /** RM attempted to allocate a transport packet but the rmAllocPkt callout was not registered */
-#define RM_ERROR_TRANSPORT_ALLOC_PKT_NOT_REGD      RM_ERROR_BASE-42
+#define RM_ERROR_TRANSPORT_ALLOC_PKT_NOT_REGD      RM_ERROR_BASE-41
 /** RM attempted to send a packet but the rmSendPkt callout was not registered */
-#define RM_ERROR_TRANSPORT_SEND_NOT_REGD           RM_ERROR_BASE-43
+#define RM_ERROR_TRANSPORT_SEND_NOT_REGD           RM_ERROR_BASE-42
+/** RM attempted to send a response packet but the transport to the remote instance that sent
+ *  the request packet is not registered */
+#define RM_ERROR_TRANSPORT_REMOTE_HNDL_NOT_REGD    RM_ERROR_BASE-43
 
 /** 
  * @brief Maximum number of characters allowed for RM instance, resource, and
@@ -390,17 +391,17 @@ typedef struct {
      *  must match an instance name defined in the "valid-instances" lists contained
      *  in the global and static policy DTS files.  Resources and privileges to the
      *  resources will be based on the name assigned to the RM instance*/
-    const char *instName;
+    const char  *instName;
     /** The type of RM instance that will be created. */
-    Rm_InstType instType;
+    Rm_InstType  instType;
     /** Instance-type specific configurations */
     union {
         /** #Rm_ServerCfg */
-        Rm_ServerCfg serverCfg;
+        Rm_ServerCfg         serverCfg;
         /** #Rm_ClientDelegateCfg */
         Rm_ClientDelegateCfg cdCfg;
         /** #Rm_ClientCfg */
-        Rm_ClientCfg clientCfg;
+        Rm_ClientCfg         clientCfg;
     } instCfg;
 } Rm_InitCfg;
 
index a98b99918ad7f3a7f2e3eb2e7faeb901b9b30fd0..ede4acc1c4e83e347b7784cebaba875ca27b7ded 100644 (file)
@@ -210,17 +210,14 @@ typedef struct {
     /** Pointer to the remote RM instance name at other end of the 
      *  application transport "pipe". */
     const char            *remoteInstName;
-    /** Specifies whether the transport callouts are valid.
-     *  TRUE  - Transport callouts are valid and can be stored by the RM
-     *          instance.
-     *  FALSE - Transport callouts are not valid and cannot not be stored by
-     *          the RM instance. */
-    bool                   transportCalloutsValid;
     /** Pointers to application implemented transport APIs.  The APIs for the
      *  provided functions must match the prototypes defined in the
-     *  #Rm_TransportCallouts structure.  Callouts need only be defined
-     *  once per RM instance.  Multiple transport registrations on the same
-     *  intance need the transportsCallouts defined and set as valid once. */
+     *  #Rm_TransportCallouts structure.  Callouts need to be defined
+     *  for each registered transport.  However, based on the application's
+     *  implementation of transport code the same function can be provided
+     *  for each transport registration.  In these cases, the transport
+     *  must mux/demux the packets it receives from RM based on the 
+     *  #Rm_TransportHandle. */
     Rm_TransportCallouts   transportCallouts;   
 } Rm_TransportCfg;
 
index d66ae06494669a74a004f62e7b9aea6a431b61e0..f66643c9974cc4f4231047cf9eb73a78b6b90855 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -951,6 +951,105 @@ static int32_t treeFree(Rm_Allocator *allocator, Rm_AllocatorOpInfo *opInfo)
     return(retVal);  
 }
 
+
+/* FUNCTION PURPOSE: Creates a resource request packet
+ ***********************************************************************
+ * DESCRIPTION: Returns a RM packet handle that points to a RM
+ *              resource request packet that has been prepared
+ *              for sending to another RM instance.  The packet
+ *              is allocated via the rmAllocPkt API using the
+ *              appTransport handle provided by the application
+ */
+void createResourceReqPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction *transaction)
+{
+    Rm_ResourceRequestPkt *resourceReqPkt = NULL;
+       
+    rmPkt->pktType = Rm_pktType_RESOURCE_REQUEST;
+    resourceReqPkt = (Rm_ResourceRequestPkt *) rmPkt->data;
+    resourceReqPkt->requestId = transaction->localId;
+    if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
+        resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_INIT;
+    }
+    else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
+        resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_USE;
+    }    
+    else if (transaction->type == Rm_service_RESOURCE_FREE) {
+        resourceReqPkt->resourceReqType = Rm_resReqPktType_FREE;
+    }
+    else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
+        resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_NAMED;
+    }
+    strncpy(resourceReqPkt->pktSrcInstName, localInstName, RM_NAME_MAX_CHARS);
+    strncpy(resourceReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
+    memcpy ((void *)&(resourceReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),
+            sizeof(Rm_ResourceInfo));
+}
+
+/* FUNCTION PURPOSE: Creates a resource response packet
+ ***********************************************************************
+ * DESCRIPTION: Returns a RM packet handle that points to a RM
+ *              resource response packet that has been prepared
+ *              for sending to another RM instance.  The packet
+ *              is allocated via the rmAllocPkt API using the
+ *              appTransport handle provided by the application
+ */
+void createResourceResponsePkt(Rm_Packet *rmPkt, Rm_Transaction *transaction)
+{
+    Rm_ResourceResponsePkt *resourceRespPkt = NULL;
+     
+    rmPkt->pktType = Rm_pktType_RESOURCE_RESPONSE;                 
+    resourceRespPkt = (Rm_ResourceResponsePkt *)rmPkt->data;
+    resourceRespPkt->responseId = transaction->remoteOriginatingId;
+    resourceRespPkt->requestState = transaction->state;
+    memcpy ((void *)&(resourceRespPkt->resourceInfo), (void *)&(transaction->resourceInfo),
+            sizeof(Rm_ResourceInfo));
+}
+
+/* FUNCTION PURPOSE: Creates a NameServer request packet
+ ***********************************************************************
+ * DESCRIPTION: Returns a RM packet handle that points to a RM
+ *              NameServer request packet that has been prepared
+ *              for sending to another RM instance.  The packet
+ *              is allocated via the rmAllocPkt API using the
+ *              appTransport handle provided by the application
+ */
+void createNsRequestPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction *transaction)
+{ 
+    Rm_NsRequestPkt *nsReqPkt = NULL;
+
+    rmPkt->pktType = Rm_pktType_NAMESERVER_REQUEST;                   
+    nsReqPkt = (Rm_NsRequestPkt *)rmPkt->data;
+    nsReqPkt->requestId = transaction->localId;
+    if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {
+        nsReqPkt->nsRequestType = Rm_nsReqPktType_MAP_RESOURCE;
+    }
+    else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {
+        nsReqPkt->nsRequestType = Rm_nsReqPktType_UNMAP_RESOURCE;
+    }
+    strncpy(nsReqPkt->pktSrcInstName, localInstName, RM_NAME_MAX_CHARS);
+    strncpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
+    memcpy ((void *)&(nsReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),
+            sizeof(Rm_ResourceInfo));
+}
+
+/* FUNCTION PURPOSE: Creates a NameServer response packet
+ ***********************************************************************
+ * DESCRIPTION: Returns a RM packet handle that points to a RM
+ *              NameServer response packet that has been prepared
+ *              for sending to another RM instance.  The packet
+ *              is allocated via the rmAllocPkt API using the
+ *              appTransport handle provided by the application
+ */
+void createNsResponsePkt(Rm_Packet *rmPkt, Rm_Transaction *transaction)
+{
+    Rm_NsResponsePkt *nsRespPkt = NULL;
+
+    rmPkt->pktType = Rm_pktType_NAMESERVER_RESPONSE;                
+    nsRespPkt = (Rm_NsResponsePkt *)rmPkt->data;
+    nsRespPkt->responseId = transaction->remoteOriginatingId;
+    nsRespPkt->requestState = transaction->state;
+}
+
 /* FUNCTION PURPOSE: Issues a service response to application
  ***********************************************************************
  * DESCRIPTION: Provides a service response back to the application
@@ -998,36 +1097,44 @@ static void serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
 static void transactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
 {
     Rm_Transport    *dstTransport = NULL;
+    Rm_Packet       *rmPkt = NULL;
     Rm_PacketHandle  pktHandle = NULL;
 
-    dstTransport = rmTransportFindRemoteName((Rm_Transport *) rmInst->transports, transaction->pktSrcInstName);
-
-    switch (transaction->type) {
-        case Rm_service_RESOURCE_ALLOCATE_INIT:
-        case Rm_service_RESOURCE_ALLOCATE_USE:
-        case Rm_service_RESOURCE_FREE:
-        case Rm_service_RESOURCE_GET_BY_NAME:
-            pktHandle = rmTransportCreateResourceResponsePkt(rmInst, dstTransport->appTransportHandle, 
-                                                             transaction);
-            break;
-        case Rm_service_RESOURCE_MAP_TO_NAME:
-        case Rm_service_RESOURCE_UNMAP_NAME:
-            pktHandle = rmTransportCreateNsResponsePkt(rmInst, dstTransport->appTransportHandle,
-                                                       transaction);
-            break;
-    }
+    if (dstTransport = rmTransportFindRemoteName(rmInst->transports, transaction->pktSrcInstName)) {
+        rmPkt = dstTransport->callouts.rmAllocPkt(dstTransport->appTransportHandle, 
+                                                  sizeof(Rm_Packet), &pktHandle);
+        if (!rmPkt || !pktHandle) {
+            transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;
+            goto errorExit;
+        }
 
-    if (pktHandle) {
-        if (rmInst->transportCallouts.rmSendPkt) {
-            if (rmInst->transportCallouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_OK) {
-                transaction->state = RM_ERROR_TRANSPORT_SEND_ERROR;
-            }
+        switch (transaction->type) {
+            case Rm_service_RESOURCE_ALLOCATE_INIT:
+            case Rm_service_RESOURCE_ALLOCATE_USE:
+            case Rm_service_RESOURCE_FREE:
+            case Rm_service_RESOURCE_GET_BY_NAME:
+                createResourceResponsePkt(rmPkt, transaction);
+                break;
+            case Rm_service_RESOURCE_MAP_TO_NAME:
+            case Rm_service_RESOURCE_UNMAP_NAME:
+                createNsResponsePkt(rmPkt, transaction);
+                break;
         }
-        else {
-            transaction->state = RM_ERROR_TRANSPORT_SEND_NOT_REGD;
+        if (dstTransport->callouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_OK) {
+            transaction->state = RM_ERROR_TRANSPORT_SEND_ERROR;
+            goto errorExit;
         }
+        
+        /* Response packet sent: Delete transaction from queue */
+        rmTransactionQueueDelete(rmInst, transaction->localId);
     }
-    rmTransactionQueueDelete(rmInst, transaction->localId);
+    else {
+        transaction->state = RM_ERROR_TRANSPORT_REMOTE_HNDL_NOT_REGD;
+    }
+errorExit:
+    /* Do not delete transaction on error.  Error transactions should be visible from
+     * from Rm_printInstanceStatus() */
+    return;
 }
 
 /* FUNCTION PURPOSE: Sends RM request packets
@@ -1040,18 +1147,27 @@ static void transactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
 static void transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)
 {
     Rm_Transport    *dstTransport = NULL;
+    Rm_Packet       *rmPkt = NULL;    
     Rm_PacketHandle  pktHandle = NULL;
 
-    if (rmInst->registeredWithDelegateOrServer) {
-        if (rmInst->instType == Rm_instType_CLIENT) {
-            dstTransport = rmTransportFindRemoteInstType((Rm_Transport *) rmInst->transports, Rm_instType_CLIENT_DELEGATE);
+    if (rmInst->instType == Rm_instType_CLIENT) {
+        dstTransport = rmTransportFindRemoteInstType(rmInst->transports, Rm_instType_CLIENT_DELEGATE);
 
-            if (!dstTransport) {
-                dstTransport = rmTransportFindRemoteInstType((Rm_Transport *) rmInst->transports, Rm_instType_SERVER);
-            }
-        } 
-        else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
-            dstTransport = rmTransportFindRemoteInstType((Rm_Transport *) rmInst->transports, Rm_instType_SERVER);
+        if (!dstTransport) {
+            dstTransport = rmTransportFindRemoteInstType(rmInst->transports, Rm_instType_SERVER);
+        }
+    } 
+    else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+        dstTransport = rmTransportFindRemoteInstType(rmInst->transports, Rm_instType_SERVER);
+    }
+
+    /* Just queue transaction if transport hasn't been registered.  Do not return error */
+    if (dstTransport) {            
+        rmPkt = dstTransport->callouts.rmAllocPkt(dstTransport->appTransportHandle, 
+                                                  sizeof(Rm_Packet), &pktHandle);
+        if (!rmPkt || !pktHandle) {
+            transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;
+            goto errorExit;
         }
 
         switch (transaction->type) {
@@ -1059,28 +1175,23 @@ static void transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)
             case Rm_service_RESOURCE_ALLOCATE_USE:
             case Rm_service_RESOURCE_FREE:
             case Rm_service_RESOURCE_GET_BY_NAME:
-                pktHandle = rmTransportCreateResourceReqPkt(rmInst, dstTransport->appTransportHandle, transaction);
+                createResourceReqPkt(rmPkt, rmInst->instName, transaction);
                 break;
             case Rm_service_RESOURCE_MAP_TO_NAME:
             case Rm_service_RESOURCE_UNMAP_NAME:
-                pktHandle = rmTransportCreateNsRequestPkt(rmInst, dstTransport->appTransportHandle, transaction);
+                createNsRequestPkt(rmPkt, rmInst->instName, transaction);
                 break;
         }
-
-        if (pktHandle) {
-            if (rmInst->transportCallouts.rmSendPkt) {            
-                if (rmInst->transportCallouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_OK) {
-                    transaction->state = RM_ERROR_TRANSPORT_SEND_ERROR;
-                }
-            }
-            else {
-                transaction->state = RM_ERROR_TRANSPORT_SEND_NOT_REGD;
-            }                
-        }
-
+  
+        if (dstTransport->callouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_OK) {
+            transaction->state = RM_ERROR_TRANSPORT_SEND_ERROR;
+            goto errorExit;
+        }              
         transaction->hasBeenForwarded = true;
         /* Transaction not deleted.  Waiting for response from RM CD or Server */
     }
+errorExit: 
+    return;
 }
 
 /* FUNCTION PURPOSE: Issues an allocator operation
@@ -1924,7 +2035,7 @@ void Rm_printResourceStatus(Rm_Handle rmServerHandle)
 void Rm_printInstanceStatus(Rm_Handle rmHandle)
 {
     Rm_Inst        *rmInst = (Rm_Inst *)rmHandle;
-    Rm_Transport   *transportList = (Rm_Transport *)rmInst->transports;
+    Rm_Transport   *transportList = rmInst->transports;
     Rm_Transaction *transactionQ = rmInst->transactionQueue;
 
     Rm_osalLog("Instance name: %s\n", rmInst->instName);
index 48f33bec2a8ac4bb27863928c44141d79a27fe97..e815441d4d856587b67cff8028b295e94b496f00 100644 (file)
@@ -78,6 +78,8 @@ static Rm_Transport *transportAdd(const Rm_TransportCfg *transportCfg)
         newTransport->appTransportHandle = transportCfg->appTransportHandle;\r
         newTransport->remoteInstType = transportCfg->remoteInstType;\r
         strncpy(newTransport->remoteInstName, transportCfg->remoteInstName, RM_NAME_MAX_CHARS);\r
+        newTransport->callouts.rmAllocPkt = transportCfg->transportCallouts.rmAllocPkt;\r
+        newTransport->callouts.rmSendPkt = transportCfg->transportCallouts.rmSendPkt;\r
         newTransport->nextTransport = NULL;\r
 \r
         if (transports) {\r
@@ -87,7 +89,7 @@ static Rm_Transport *transportAdd(const Rm_TransportCfg *transportCfg)
             transports->nextTransport = newTransport;\r
         }\r
         else {\r
-            rmInst->transports = (void *)newTransport;\r
+            rmInst->transports = newTransport;\r
         }\r
     }\r
     return (newTransport);\r
@@ -134,7 +136,7 @@ static void transportDelete(Rm_Transport *transport)
     }\r
 \r
     if (prevTransport == NULL) {\r
-         rmInst->transports = (void *)transport->nextTransport;\r
+         rmInst->transports = transport->nextTransport;\r
     }\r
     else {\r
          prevTransport->nextTransport = transport->nextTransport;\r
@@ -182,172 +184,6 @@ Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports, Rm_InstTyp
     return (transports);\r
 }\r
 \r
-/* FUNCTION PURPOSE: Creates a resource request packet\r
- ***********************************************************************\r
- * DESCRIPTION: Returns a RM packet handle that points to a RM\r
- *              resource request packet that has been prepared\r
- *              for sending to another RM instance.  The packet\r
- *              is allocated via the rmAllocPkt API using the\r
- *              appTransport handle provided by the application\r
- */\r
-Rm_PacketHandle rmTransportCreateResourceReqPkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,\r
-                                                Rm_Transaction *transaction)\r
-{\r
-    Rm_Packet             *rmPkt = NULL;\r
-    Rm_PacketHandle        pktHandle = NULL;\r
-    Rm_ResourceRequestPkt *resourceReqPkt = NULL;\r
-\r
-    if (rmInst->transportCallouts.rmAllocPkt) {\r
-        if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, \r
-                                                          sizeof(Rm_Packet),\r
-                                                          &pktHandle)) == NULL) {\r
-            transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
-            return (NULL);\r
-        }\r
-       \r
-        rmPkt->pktType = Rm_pktType_RESOURCE_REQUEST;\r
-        resourceReqPkt = (Rm_ResourceRequestPkt *) rmPkt->data;\r
-        resourceReqPkt->requestId = transaction->localId;\r
-        if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {\r
-            resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_INIT;\r
-        }\r
-        else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {\r
-            resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_USE;\r
-        }    \r
-        else if (transaction->type == Rm_service_RESOURCE_FREE) {\r
-            resourceReqPkt->resourceReqType = Rm_resReqPktType_FREE;\r
-        }\r
-        else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {\r
-            resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_NAMED;\r
-        }\r
-        strncpy(resourceReqPkt->pktSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);\r
-        strncpy(resourceReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
-        memcpy ((void *)&(resourceReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
-                sizeof(Rm_ResourceInfo));\r
-    }\r
-    else {\r
-        transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_NOT_REGD;\r
-    }        \r
-    \r
-    return (pktHandle);\r
-}\r
-\r
-/* FUNCTION PURPOSE: Creates a resource response packet\r
- ***********************************************************************\r
- * DESCRIPTION: Returns a RM packet handle that points to a RM\r
- *              resource response packet that has been prepared\r
- *              for sending to another RM instance.  The packet\r
- *              is allocated via the rmAllocPkt API using the\r
- *              appTransport handle provided by the application\r
- */\r
-Rm_PacketHandle rmTransportCreateResourceResponsePkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,\r
-                                                     Rm_Transaction *transaction)\r
-{\r
-    Rm_Packet              *rmPkt = NULL;\r
-    Rm_PacketHandle         pktHandle = NULL;\r
-    Rm_ResourceResponsePkt *resourceRespPkt = NULL;\r
-\r
-    if (rmInst->transportCallouts.rmAllocPkt) {\r
-        if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, \r
-                                                          sizeof(Rm_Packet),\r
-                                                          &pktHandle)) == NULL) {\r
-            transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
-            return (NULL);\r
-        }\r
-     \r
-        rmPkt->pktType = Rm_pktType_RESOURCE_RESPONSE;                 \r
-        resourceRespPkt = (Rm_ResourceResponsePkt *)rmPkt->data;\r
-        resourceRespPkt->responseId = transaction->remoteOriginatingId;\r
-        resourceRespPkt->requestState = transaction->state;\r
-        memcpy ((void *)&(resourceRespPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
-                sizeof(Rm_ResourceInfo));\r
-    }\r
-    else {\r
-        transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_NOT_REGD;\r
-    }        \r
-\r
-    return (pktHandle);\r
-}\r
-\r
-/* FUNCTION PURPOSE: Creates a NameServer request packet\r
- ***********************************************************************\r
- * DESCRIPTION: Returns a RM packet handle that points to a RM\r
- *              NameServer request packet that has been prepared\r
- *              for sending to another RM instance.  The packet\r
- *              is allocated via the rmAllocPkt API using the\r
- *              appTransport handle provided by the application\r
- */\r
-Rm_PacketHandle rmTransportCreateNsRequestPkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,\r
-                                              Rm_Transaction *transaction)\r
-{\r
-    Rm_Packet       *rmPkt = NULL;\r
-    Rm_PacketHandle  pktHandle = NULL;    \r
-    Rm_NsRequestPkt *nsReqPkt = NULL;\r
-\r
-    if (rmInst->transportCallouts.rmAllocPkt) {\r
-        if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, \r
-                                                          sizeof(Rm_Packet),\r
-                                                          &pktHandle)) == NULL) {\r
-            transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
-            return (NULL);\r
-        }\r
-\r
-        rmPkt->pktType = Rm_pktType_NAMESERVER_REQUEST;                   \r
-        nsReqPkt = (Rm_NsRequestPkt *)rmPkt->data;\r
-        nsReqPkt->requestId = transaction->localId;\r
-        if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {\r
-            nsReqPkt->nsRequestType = Rm_nsReqPktType_MAP_RESOURCE;\r
-        }\r
-        else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {\r
-            nsReqPkt->nsRequestType = Rm_nsReqPktType_UNMAP_RESOURCE;\r
-        }\r
-        strncpy(nsReqPkt->pktSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);\r
-        strncpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
-        memcpy ((void *)&(nsReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),\r
-                sizeof(Rm_ResourceInfo));\r
-    }\r
-    else {\r
-        transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_NOT_REGD;\r
-    }        \r
-    \r
-    return (pktHandle);\r
-}\r
-\r
-/* FUNCTION PURPOSE: Creates a NameServer response packet\r
- ***********************************************************************\r
- * DESCRIPTION: Returns a RM packet handle that points to a RM\r
- *              NameServer response packet that has been prepared\r
- *              for sending to another RM instance.  The packet\r
- *              is allocated via the rmAllocPkt API using the\r
- *              appTransport handle provided by the application\r
- */\r
-Rm_PacketHandle rmTransportCreateNsResponsePkt(Rm_Inst *rmInst, Rm_AppTransportHandle appTransport,\r
-                                               Rm_Transaction *transaction)\r
-{\r
-    Rm_Packet        *rmPkt = NULL;\r
-    Rm_PacketHandle   pktHandle = NULL;\r
-    Rm_NsResponsePkt *nsRespPkt = NULL;\r
-\r
-    if (rmInst->transportCallouts.rmAllocPkt) {\r
-        if ((rmPkt = rmInst->transportCallouts.rmAllocPkt(appTransport, \r
-                                                          sizeof(Rm_Packet),\r
-                                                          &pktHandle)) == NULL) {\r
-            transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;\r
-            return (NULL);\r
-        }\r
-     \r
-        rmPkt->pktType = Rm_pktType_NAMESERVER_RESPONSE;                \r
-        nsRespPkt = (Rm_NsResponsePkt *)rmPkt->data;\r
-        nsRespPkt->responseId = transaction->remoteOriginatingId;\r
-        nsRespPkt->requestState = transaction->state;\r
-    }\r
-    else {\r
-        transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_NOT_REGD;\r
-    }\r
-\r
-    return (pktHandle);\r
-}\r
-\r
 /**********************************************************************\r
  ********************* Application visible APIs ***********************\r
  **********************************************************************/\r
@@ -369,6 +205,8 @@ Rm_TransportHandle Rm_transportRegister (const Rm_TransportCfg *transportCfg, in
     Rm_Inst      *rmInst = (Rm_Inst *) transportCfg->rmHandle;\r
     Rm_Transport *transport = NULL;\r
 \r
+    *result = RM_OK;\r
+\r
     /* RM Servers cannot connect to other Servers.  \r
      * RM Client Delegates cannot connect to other Client Delegates.\r
      * RM Clients cannot connect to other Clients */\r
@@ -379,7 +217,6 @@ Rm_TransportHandle Rm_transportRegister (const Rm_TransportCfg *transportCfg, in
         ((rmInst->instType == Rm_instType_CLIENT) &&\r
          (transportCfg->remoteInstType == Rm_instType_CLIENT))) {\r
         *result = RM_ERROR_INVALID_REMOTE_INST_TYPE;\r
-        return(NULL);\r
     }\r
 \r
     /* Verify Clients are not registering with more than one Client Delegate or Server. And\r
@@ -390,28 +227,23 @@ Rm_TransportHandle Rm_transportRegister (const Rm_TransportCfg *transportCfg, in
          ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&\r
           (transportCfg->remoteInstType == Rm_instType_SERVER)))) {\r
         *result = RM_ERROR_ALREADY_REGD_SERVER_OR_CD;\r
-        return(NULL);\r
     }         \r
     \r
-    if (transportCfg->transportCalloutsValid &&\r
-        ((transportCfg->transportCallouts.rmAllocPkt == NULL) ||\r
-         (transportCfg->transportCallouts.rmSendPkt == NULL))) {\r
-        *result = RM_ERROR_NULL_CALLOUTS_WHEN_VALID;\r
-        return(NULL);\r
+    if (!transportCfg->transportCallouts.rmAllocPkt) {\r
+        *result = RM_ERROR_TRANSPORT_ALLOC_PKT_NOT_REGD;\r
     }\r
-    else {\r
-        rmInst->transportCallouts.rmAllocPkt = transportCfg->transportCallouts.rmAllocPkt;\r
-        rmInst->transportCallouts.rmSendPkt = transportCfg->transportCallouts.rmSendPkt;\r
+    else if (!transportCfg->transportCallouts.rmSendPkt) {\r
+        *result = RM_ERROR_TRANSPORT_SEND_NOT_REGD;\r
     }\r
 \r
-    transport = transportAdd(transportCfg);\r
-\r
-    if ((transport->remoteInstType == Rm_instType_CLIENT_DELEGATE) ||\r
-        (transport->remoteInstType == Rm_instType_SERVER)) {\r
-        rmInst->registeredWithDelegateOrServer = true;\r
+    if (*result == RM_OK) {\r
+        transport = transportAdd(transportCfg);\r
+        if ((transport->remoteInstType == Rm_instType_CLIENT_DELEGATE) ||\r
+            (transport->remoteInstType == Rm_instType_SERVER)) {\r
+            rmInst->registeredWithDelegateOrServer = true;\r
+        }\r
     }\r
 \r
-    *result = RM_OK;\r
     return ((Rm_TransportHandle) transport);\r
 }\r
 \r
index 0837905826b992fd42c3712257bd6f4082f84513..363b1b9fa52a5274c542fbe1ed33bcad718d8429 100644 (file)
@@ -1229,8 +1229,6 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) serverToCdQId;
         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
         rmTransportCfg.remoteInstName = &rmClientDelegateName[0];
-        /* Set the callouts as valid for the first transport configuration on Server instance */
-        rmTransportCfg.transportCalloutsValid = true;
         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
         serverCdHandle = Rm_transportRegister(&rmTransportCfg, &result);
@@ -1259,9 +1257,6 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToServerQId;
         rmTransportCfg.remoteInstType = Rm_instType_SERVER;
         rmTransportCfg.remoteInstName = &rmServerName[0];
-        /* Set the callouts as valid for the first transport configuration on Client Delegate instance */
-
-        rmTransportCfg.transportCalloutsValid = true;
         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
         cdServerHandle = Rm_transportRegister(&rmTransportCfg, &result);
@@ -1288,8 +1283,8 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) cdToClientQId;
         rmTransportCfg.remoteInstType = Rm_instType_CLIENT;
         rmTransportCfg.remoteInstName = &rmClientName[0];
-        /* Callouts already set on the Client Delegate so set them as invalid */
-        rmTransportCfg.transportCalloutsValid = false;
+        rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
+        rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
         cdClientHandle = Rm_transportRegister(&rmTransportCfg, &result);
 
         /* Store the mapping information in the transport map */
@@ -1315,8 +1310,6 @@ Void startupRmTsk(UArg arg0, UArg arg1)
         rmTransportCfg.appTransportHandle = (Rm_AppTransportHandle) clientToCdQId;
         rmTransportCfg.remoteInstType = Rm_instType_CLIENT_DELEGATE;
         rmTransportCfg.remoteInstName = &rmClientDelegateName[0];
-        /* Set the callouts as valid for the first transport configuration on Client instance */
-        rmTransportCfg.transportCalloutsValid = true;
         rmTransportCfg.transportCallouts.rmAllocPkt = transportAlloc;
         rmTransportCfg.transportCallouts.rmSendPkt = transportSend;
         clientCdHandle = Rm_transportRegister(&rmTransportCfg, &result);