summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bc6f807)
raw | patch | inline | side by side (parent: bc6f807)
author | vwan@ti.com <vwan@ti.com> | |
Mon, 16 Feb 2015 22:45:58 +0000 (14:45 -0800) | ||
committer | Robert Tivy <rtivy@ti.com> | |
Thu, 19 Feb 2015 22:19:58 +0000 (14:19 -0800) |
This commit cleans up how the maximum name length is configured in NameServer.
Now the user only needs to configure it during instance creation, and to
configure it at the remote level in
packages/ti/ipc/namesrv/_NameServerRemoteRpmsg.h.
When a name passed to the NameServer remote exceeds the length it can support,
it now returns NameServer_E_NAMETOOLONG.
The NameServerApp is updated to test for long names that exceed the
maximum length.
This commit addresses SDOCM00111686.
Signed-off-by: VW <vwan@ti.com>
Now the user only needs to configure it during instance creation, and to
configure it at the remote level in
packages/ti/ipc/namesrv/_NameServerRemoteRpmsg.h.
When a name passed to the NameServer remote exceeds the length it can support,
it now returns NameServer_E_NAMETOOLONG.
The NameServerApp is updated to test for long names that exceed the
maximum length.
This commit addresses SDOCM00111686.
Signed-off-by: VW <vwan@ti.com>
13 files changed:
diff --git a/hlos_common/include/_NameServerRemoteRpmsg.h b/hlos_common/include/_NameServerRemoteRpmsg.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2012-2014, Texas Instruments Incorporated
- * All rights reserved.
- *
- * 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.
- */
-
-#define NAMESERVER_REQUEST 0
-#define NAMESERVER_RESPONSE 1
-
-#define NAME_SERVER_RPMSG_ADDR 0
-
-#define MAXNAMEINCHAR 80
-#define NAMEARRAYSZIE (((MAXNAMEINCHAR - 1) / sizeof(Bits32)) + 1)
-#define MAXVALUELEN 75
-
-#define NAMESERVER_GET_TIMEOUT 40000 /* microseconds */
-
-#define NAMESERVER_MSG_TOKEN 0x5678abcd
-
-/* message sent to remote procId */
-typedef struct NameServerMsg {
- Bits32 reserved; /* reserved field: must be first! */
- Bits32 value; /* holds value */
- Bits32 request; /* whether its a request/response */
- Bits32 requestStatus; /* status of request */
- Bits32 seqNum; /* NameServer request sequence # */
- /* name of NameServer instance */
- Bits32 instanceName[NAMEARRAYSZIE];
- /* name of NameServer entry */
- Bits32 name[NAMEARRAYSZIE];
- Bits32 valueLen; /* len of value */
- Bits32 valueBuf[MAXVALUELEN]; /* value buffer */
-} NameServerMsg;
diff --git a/linux/include/_lad.h b/linux/include/_lad.h
index 69c8367bcc10d55bf8761aaa9733f3aedd3f5180..00a0c1e6b9216552071698fb71f1992f4c60bdce 100644 (file)
--- a/linux/include/_lad.h
+++ b/linux/include/_lad.h
#include <_GateMP.h>
#include <GateHWSpinlock.h>
#include <sys/time.h>
+#include <ti/ipc/namesrv/_NameServerRemoteRpmsg.h>
extern Bool logFile;
extern FILE *logPtr;
#define LAD_MESSAGEQCREATEMAXNAMELEN 32
-#define LAD_MAXENTRYNAMELEN 32 /* size limit for LAD NameServer name */
+#define LAD_MAXENTRYNAMELEN MAXNAMEINCHAR /* max for LAD NameServer name */
#define LAD_MAXENTRYVALUELEN 32 /* size limit for LAD NameServer value */
typedef enum {
index f81f0322dd6e39efa4faa57d00d13bc5fc835448..1d2d8620305cd9f6953485e463032b3314e7f6bf 100644 (file)
##
# additional include paths necessary to compile the program
-AM_CFLAGS = -I$(top_srcdir)/hlos_common/include -D_GNU_SOURCE -Wall
+AM_CFLAGS = -I$(top_srcdir)/hlos_common/include -D_GNU_SOURCE -Wall \
+ -DKERNEL_INSTALL_DIR="$(KERNEL_INSTALL_DIR)"
if DRA7XX
AM_CFLAGS += -DGATEMP_SUPPORT
index 74cba7199e6554725f0c095e525e4ed99b49a08e..2fb200c80957cc7f8dcb2c0da2bf2e63a2d61b87 100644 (file)
/* Internal stuff: */
#include <_NameServer.h>
-#include <_NameServerRemoteRpmsg.h>
+#include <ti/ipc/namesrv/_NameServerRemoteRpmsg.h>
/* Socket utils: */
#include <SocketFxns.h>
/* structure for NameServer module state */
typedef struct NameServer_ModuleObject {
CIRCLEQ_HEAD(dummy1, NameServer_Object) objList;
- Int32 refCount;
- int sendSock[MultiProc_MAXPROCESSORS];
+ Int32 refCount;
+ int sendSock[MultiProc_MAXPROCESSORS];
/* Sockets for sending to remote proc nameserver ports: */
- int recvSock[MultiProc_MAXPROCESSORS];
+ int recvSock[MultiProc_MAXPROCESSORS];
/* Sockets for recving from remote proc nameserver ports: */
- pthread_t listener;
+ pthread_t listener;
/* Listener thread for NameServer replies and requests. */
- int unblockFd;
+ int unblockFd;
/* Event to post to exit listener. */
- int waitFd;
+ int waitFd;
/* Event to post to NameServer_get. */
- NameServerMsg nsMsg;
+ NameServerRemote_Msg nsMsg;
/* NameServer Message cache. */
- NameServer_Params defInstParams;
+ NameServer_Params defInstParams;
/* Default instance paramters */
- pthread_mutex_t modGate;
+ pthread_mutex_t modGate;
} NameServer_ModuleObject;
#define CIRCLEQ_destruct(head) { \
return (hash);
}
-static void NameServerRemote_processMessage(NameServerMsg * msg, UInt16 procId)
+static void NameServerRemote_processMessage(NameServerRemote_Msg * msg, UInt16 procId)
{
NameServer_Handle handle;
Int status = NameServer_E_FAIL;
/* send response message to remote processor */
clusterId = procId - MultiProc_getBaseIdOfCluster();
err = send(NameServer_module->sendSock[clusterId], msg,
- sizeof(NameServerMsg), 0);
+ sizeof(NameServerRemote_Msg), 0);
if (err < 0) {
LOG2("NameServer: send failed: %d, %s\n", errno, strerror(errno))
}
LOG1(", value: 0x%x\n", msg->value)
/* Save the response message. */
- memcpy(&NameServer_module->nsMsg, msg, sizeof(NameServerMsg));
+ memcpy(&NameServer_module->nsMsg, msg, sizeof(NameServerRemote_Msg));
/* Post the eventfd upon which NameServer_get() is waiting */
write(waitFd, &buf, sizeof(uint64_t));
UInt16 procId;
struct sockaddr_rpmsg fromAddr;
unsigned int len;
- NameServerMsg msg;
+ NameServerRemote_Msg msg;
int byteCount;
UInt16 numProcs = MultiProc_getNumProcsInCluster();
UInt16 baseId = MultiProc_getBaseIdOfCluster();
memset(&fromAddr, 0, sizeof(fromAddr));
len = sizeof(fromAddr);
- byteCount = recvfrom(sock, &msg, sizeof(NameServerMsg), 0,
+ byteCount = recvfrom(sock, &msg, sizeof(NameServerRemote_Msg), 0,
(struct sockaddr *)&fromAddr, &len);
if (len != sizeof(fromAddr)) {
LOG1("recvfrom: got bad addr len (%d)\n", len)
/* Calculate the hash */
hash = stringHash(name);
+ pthread_mutex_lock(&handle->gate);
+
+ if (strlen(name) > handle->params.maxNameLen - 1) {
+ status = NameServer_E_INVALIDARG;
+ LOG0("NameServer_add: name length exceeded maximum!\n")
+ new_node = NULL;
+ goto exit;
+ }
+
if (len > handle->params.maxValueLen) {
status = NameServer_E_INVALIDARG;
LOG0("NameServer_add: value length exceeded maximum!\n")
goto exit;
}
- pthread_mutex_lock(&handle->gate);
-
/* Traverse the list to find duplicate check */
CIRCLEQ_traverse(node, &handle->nameList, NameServer_TableEntry_tag) {
/* Hash matches */
{
Int status = NameServer_S_SUCCESS;
struct NameServer_Object *obj = (struct NameServer_Object *)(handle);
- NameServerMsg nsMsg;
- NameServerMsg *replyMsg;
+ NameServerRemote_Msg nsMsg;
+ NameServerRemote_Msg *replyMsg;
fd_set rfds;
int ret = 0, sock, maxfd, waitFd;
struct timeval tv;
Bool done = FALSE;
UInt16 clusterId;
+ if (strlen(name) >= MAXNAMEINCHAR) {
+ LOG0("Name is too long in remote query\n");
+ return NameServer_E_NAMETOOLONG;
+ }
+
+ if (strlen(obj->name) >= MAXNAMEINCHAR) {
+ LOG0("Instance name is too long for remote query\n");
+ return NameServer_E_NAMETOOLONG;
+ }
+
/* Set Timeout to wait: */
tv.tv_sec = 0;
tv.tv_usec = NAMESERVER_GET_TIMEOUT;
procId, (String)nsMsg.instanceName)
LOG1("%s...\n", (String)nsMsg.name)
- err = send(sock, &nsMsg, sizeof(NameServerMsg), 0);
+ err = send(sock, &nsMsg, sizeof(NameServerRemote_Msg), 0);
if (err < 0) {
LOG2("NameServer_getRemote: send failed: %d, %s\n",
errno, strerror(errno))
index 1cb6e555a0c1698afba320e31114e5725960a2a1..7a12633d0cddedf33f85dc5eab2779aa608caffc 100644 (file)
/*
- * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * Copyright (c) 2012-2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*/
#define NSNAME "MyNS"
#define NSNAME2 "MyNS2"
+#define NSLONGNAME "LongNameabcdefghijklmnopqrstuvwxyz1234567890abcdefghi" \
+ "jklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890"
/** ============================================================================
* Globals
* ============================================================================
*/
+Int nameLenTest()
+{
+ NameServer_Params params;
+ NameServer_Handle nsHandle;
+ Int32 status = 0;
+ Ptr ptr;
+ UInt32 val;
+
+ printf("Testing long names...\n");
+
+ NameServer_Params_init(¶ms);
+
+ params.maxValueLen = sizeof(UInt32);
+ params.maxNameLen = 32;
+
+ nsHandle = NameServer_create(NSLONGNAME, ¶ms);
+ if (nsHandle == NULL) {
+ printf("Failed to create NameServer '%s'\n", NSLONGNAME);
+ return -1;
+ }
+ else {
+ printf("Created NameServer '%s'\n", NSLONGNAME);
+ }
+
+ /* This name should be too long for creation params and results in error */
+ printf("Trying to add a name that exceeds maxNameLen...\n");
+ ptr = NameServer_addUInt32(nsHandle, NSLONGNAME, 0xdeadbeef);
+ if (ptr == NULL) {
+ printf(" ...got expected Failure from NameServer_addUInt32()\n");
+ }
+ else {
+ printf(" Error: NameServer_addUInt32() returned non-NULL %p (but "
+ "was expected to fail)\n", ptr);
+ NameServer_delete(&nsHandle);
+ return -1;
+ }
+
+ printf("Deleting nsHandle...\n");
+ NameServer_delete(&nsHandle);
+
+ NameServer_Params_init(¶ms);
+
+ params.maxValueLen = sizeof(UInt32);
+ params.maxNameLen = 180;
+
+ nsHandle = NameServer_create(NSLONGNAME, ¶ms);
+ if (nsHandle == NULL) {
+ printf("Failed to create NameServer '%s'\n", NSLONGNAME);
+ return -1;
+ }
+ else {
+ printf("Created NameServer '%s'\n", NSLONGNAME);
+ }
+
+ /* This name is too long for remote to handle and results in error */
+ printf("Trying to get a name that the remote cannot handle...\n");
+ val = 0x00c0ffee;
+ status = NameServer_getUInt32(nsHandle, NSLONGNAME, &val, NULL);
+ if (status == NameServer_E_NAMETOOLONG) {
+ printf(" ...got expected Failure from NameServer_getUInt32()\n");
+ }
+ else {
+ printf(" Error: NameServer_getUint32() returned unexpected "
+ "result: %d\n", status);
+ return -1;
+ }
+
+ printf("Deleting nsHandle...\n");
+ NameServer_delete(&nsHandle);
+
+ NameServer_Params_init(¶ms);
+
+ params.maxValueLen = sizeof(UInt32);
+ params.maxNameLen = 32;
+
+ nsHandle = NameServer_create(NSLONGNAME, ¶ms);
+ if (nsHandle == NULL) {
+ printf("Failed to create NameServer '%s'\n", NSLONGNAME);
+ return -1;
+ }
+ else {
+ printf("Created NameServer '%s'\n", NSLONGNAME);
+ }
+
+ /* The instance name is too long for remote and results in error */
+ printf("Trying to use an instance name that the remote cannot "
+ "handle...\n");
+ val = 0x00c0ffee;
+ status = NameServer_getUInt32(nsHandle, "Key", &val, NULL);
+ if (status == NameServer_E_NAMETOOLONG) {
+ printf(" ...got expected Failure from NameServer_getUInt32()\n");
+ }
+ else {
+ printf(" Error: NameServer_getUint32() returned unexpected "
+ "result: %d\n", status);
+ return -1;
+ }
+
+ printf("Deleting nsHandle...\n");
+ NameServer_delete(&nsHandle);
+
+ return 0;
+}
Int testNS(NameServer_Handle nsHandle, String name)
{
goto again;
}
+ status = nameLenTest();
+ if (status != 0) {
+ printf("Name Length test failed\n");
+ return status;
+ }
+
printf("Calling NameServer_destroy()...\n");
NameServer_destroy();
index b77929e6d99a19c40794a9701844314b6f6ab1b6..1f8192ac793653e8c82e05a8e2cd750bea6bb90e 100644 (file)
/*
- * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * Copyright (c) 2012-2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*/
#define NameServer_E_RESTART (-10)
+/*!
+ * @brief Name is too long.
+ *
+ * The underlying remote implementation was unable to handle such a long
+ * instance or entry name.
+ * See these files for the maximum number of characters that can be specified
+ * in a name for common NameServer remote implementations:
+ *
+ * - NameServerRemoteRpmsg:
+ * packages/ti/ipc/namesrv/_NameServerRemoteRpmsg.h
+ *
+ */
+#define NameServer_E_NAMETOOLONG (-11)
+
/* =============================================================================
* Macros
* =============================================================================
* @param buf Pointer to value for the name/value pair
* @param len length of the value
*
- * @return Unique entry identifier
+ * @return Unique entry identifier, or NULL if unsuccessful
*
* @sa NameServer_addUInt32()
* @sa NameServer_get()
* @param name Name for the name/value pair
* @param value Value for the name/value pair
*
- * @return Unique entry identifier
+ * @return Unique entry identifier, or NULL if unsuccessful
*
* @sa NameServer_add()
* @sa NameServer_getUInt32()
* - #NameServer_S_SUCCESS: Successfully found entry
* - #NameServer_E_NOTFOUND: Entry was not found, len unchanged
* - #NameServer_E_FAIL: Error searching for entry
+ * - #NameServer_E_NAMETOOLONG: Instance name or query name is
+ * too long for NameServer remote to process
*
* @sa NameServer_add()
* @sa NameServer_getLocal()
diff --git a/packages/ti/ipc/namesrv/NameServerRemoteRpmsg.c b/packages/ti/ipc/namesrv/NameServerRemoteRpmsg.c
index 35e2b7376899025370755bd065addda5b9d12ed3..4bd874722ff5270c3fab2ae2df1fd6e18e532700 100644 (file)
/*
- * Copyright (c) 2013-2014, Texas Instruments Incorporated
+ * Copyright (c) 2013-2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
msg.seqNum = seqNum++;
len = strlen(instanceName);
- Assert_isTrue(len < MAXNAMEINCHAR, NameServerRemoteRpmsg_A_nameIsTooLong);
+ if (len >= MAXNAMEINCHAR) {
+ Log_print1(Diags_INFO, FXNN": Instance name is too long. It exceeds"
+ " %d chars\n", MAXNAMEINCHAR - 1);
+ /* return timeout failure */
+ status = NameServer_E_NAMETOOLONG;
+ goto exit;
+ }
strncpy((Char *)msg.instanceName, instanceName, MAXNAMEINCHAR - 1);
((Char *)msg.instanceName)[MAXNAMEINCHAR - 1] = '\0';
len = strlen(name);
- Assert_isTrue(len < MAXNAMEINCHAR, NameServerRemoteRpmsg_A_nameIsTooLong);
+ if (len >= MAXNAMEINCHAR) {
+ Log_print1(Diags_INFO, FXNN": Entry name is too long. It exceeds"
+ " %d chars\n", MAXNAMEINCHAR - 1);
+ /* return timeout failure */
+ status = NameServer_E_NAMETOOLONG;
+ goto exit;
+ }
strncpy((Char *)msg.name, name, MAXNAMEINCHAR - 1);
((Char *)msg.name)[MAXNAMEINCHAR - 1] = '\0';
diff --git a/packages/ti/ipc/namesrv/_NameServerRemoteRpmsg.h b/packages/ti/ipc/namesrv/_NameServerRemoteRpmsg.h
index e95a26aae65e931fadeeb0207172de588a873506..72782cd25eaebd07ac7d7e08f0b29da59f362324 100644 (file)
/*
- * Copyright (c) 2012-2014, Texas Instruments Incorporated
+ * Copyright (c) 2012-2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#define NAMESERVER_MSG_TOKEN 0x5678abcd
+#if defined (IPC_BUILDOS_QNX) || defined (IPC_BUILDOS_ANDROID) || \
+ defined (KERNEL_INSTALL_DIR)
+#define NAMESERVER_GET_TIMEOUT 40000 /* microseconds */
+
+#define NAMESERVER_REQUEST 0
+#define NAMESERVER_RESPONSE 1
+
+#else /* SYSBIOS only */
+
/* That special per processor RPMSG channel reserved to multiplex MessageQ */
/* Duplicated in _TransportRpmsg.h: move to a common rpmsg_ports.h? */
#define RPMSG_MESSAGEQ_PORT 61
extern void NameServerRemote_processMessage(NameServerRemote_Msg * ns_msg);
extern void NameServerRemote_SetNameServerPort(UInt port);
+#endif
+
#if defined (__cplusplus)
}
#endif /* defined (__cplusplus) */
index bb7250601a3e1027ee6feb2a91cc20026ccfce9c..f3a0060d6fc8bb8fa96ad6cf29f18ca3a00e28d8 100644 (file)
/*
- * Copyright (c) 2013, Texas Instruments Incorporated
+ * Copyright (c) 2013-2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*/
#define NSNAME "MyNS"
#define NSNAME2 "MyNS2"
+#define NSLONGNAME "LongNameabcdefghijklmnopqrstuvwxyz1234567890abcdefghi" \
+ "jklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890"
/* private data */
Registry_Desc Registry_CURDESC;
* Globals
* ============================================================================
*/
+Int nameLenTest()
+{
+ NameServer_Params params;
+ NameServer_Handle nsHandle;
+ Int32 status = 0;
+ UInt32 val;
+
+ Log_print0(Diags_INFO, "Testing long names...\n");
+#if 0 /* Commented out due to assertion thrown when name length > maxNameLen */
+ NameServer_Params_init(¶ms);
+
+ params.maxValueLen = sizeof(UInt32);
+ params.maxNameLen = 32;
+
+ nsHandle = NameServer_create(NSLONGNAME, ¶ms);
+ if (nsHandle == NULL) {
+ Log_print1(Diags_INFO, "Failed to create NameServer '%s'\n",
+ (IArg)NSLONGNAME);
+ return -1;
+ }
+ else {
+ printf("Created NameServer '%s'\n", NSLONGNAME);
+ }
+
+ /* This name should be too long for creation params and results in error */
+ printf("Trying to add a name that exceeds maxNameLen...\n");
+ ptr = NameServer_addUInt32(nsHandle, NSLONGNAME, 0xdeadbeef);
+ if (ptr == NULL) {
+ Log_print0(Diags_INFO,
+ " ...got expected Failure from NameServer_addUInt32()\n");
+ }
+ else {
+ Log_print1(Diags_INFO,
+ " Error: NameServer_addUInt32() returned non-NULL %p (but "
+ "was expected to fail)\n", (IArg)ptr);
+ NameServer_delete(&nsHandle);
+ return -1;
+ }
+
+ Log_print0(Diags_INFO, "Deleting nsHandle...\n");
+ NameServer_delete(&nsHandle);
+#endif
+ NameServer_Params_init(¶ms);
+
+ params.maxValueLen = sizeof(UInt32);
+ params.maxNameLen = 180;
+
+ nsHandle = NameServer_create(NSNAME, ¶ms);
+ if (nsHandle == NULL) {
+ Log_print1(Diags_INFO, "Failed to create NameServer '%s'\n",
+ (IArg)NSNAME);
+ return -1;
+ }
+ else {
+ Log_print1(Diags_INFO, "Created NameServer '%s'\n", (IArg)NSNAME);
+ }
+
+ /* This name is too long for remote to handle and results in error */
+ Log_print0(Diags_INFO,
+ "Trying to get a name that the remote cannot handle...\n");
+ val = 0x00c0ffee;
+ status = NameServer_getUInt32(nsHandle, NSLONGNAME, &val, NULL);
+ if (status == NameServer_E_NAMETOOLONG) {
+ Log_print0(Diags_INFO,
+ " ...got expected Failure from NameServer_getUInt32()\n");
+ }
+ else {
+ Log_print1(Diags_INFO,
+ " Error: NameServer_getUint32() returned unexpected "
+ "result: %d\n", (IArg)status);
+ return -1;
+ }
+
+ Log_print0(Diags_INFO, "Deleting nsHandle...\n");
+ NameServer_delete(&nsHandle);
+
+ NameServer_Params_init(¶ms);
+
+ params.maxValueLen = sizeof(UInt32);
+ params.maxNameLen = 32;
+
+ nsHandle = NameServer_create(NSLONGNAME, ¶ms);
+ if (nsHandle == NULL) {
+ Log_print1(Diags_INFO, "Failed to create NameServer '%s'\n",
+ (IArg)NSLONGNAME);
+ return -1;
+ }
+ else {
+ Log_print1(Diags_INFO, "Created NameServer '%s'\n", (IArg)NSLONGNAME);
+ }
+
+ /* The instance name is too long for remote and results in error */
+ Log_print0(Diags_INFO,
+ "Trying to use an instance name that the remote cannot handle...\n");
+ val = 0x00c0ffee;
+ status = NameServer_getUInt32(nsHandle, "Key", &val, NULL);
+ if (status == NameServer_E_NAMETOOLONG) {
+ Log_print0(Diags_INFO,
+ " ...got expected Failure from NameServer_getUInt32()\n");
+ }
+ else {
+ Log_print1(Diags_INFO,
+ " Error: NameServer_getUint32() returned unexpected "
+ "result: %d\n", (IArg)status);
+ return -1;
+ }
+
+ Log_print0(Diags_INFO, "Deleting nsHandle...\n");
+ NameServer_delete(&nsHandle);
+
+ return 0;
+}
Int testNS(NameServer_Handle nsHandle, String name)
{
goto again;
}
+ status = nameLenTest();
+ if (status != 0) {
+ Log_print0(Diags_INFO, "Name Length test failed\n");
+ return status;
+ }
+
// Log_print0(Diags_INFO, "Calling NameServer_destroy()...\n");
// NameServer_destroy();
index 731a7109cb309b3e886d0328c6ab3bec60f241a0..ac5d24c00cd868bb169f88aadf110f8271ecce75 100644 (file)
/*
- * Copyright (c) 2013-2014, Texas Instruments Incorporated
+ * Copyright (c) 2013-2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+var BIOS = xdc.useModule('ti.sysbios.BIOS');
/* Bring in the platform-specific config */
if (Program.cpu.deviceName.match(/^OMAP5430$/) &&
Program.cpu.attrs.cpuCore.match(/^CM4$/)) {
+ xdc.loadPackage('ti.ipc.ipcmgr');
+ BIOS.addUserStartupFunction('&IpcMgr_ipcStartup');
+
xdc.loadCapsule("IpcCommon_omap5.cfg.xs");
xdc.loadCapsule("IpuSmp.cfg");
xdc.loadCapsule("IpuAmmu_omap5.cfg");
}
else if (Program.cpu.deviceName.match(/^OMAP5430$/) &&
Program.cpu.attrs.cpuCore.match(/^64T$/)) {
+ xdc.loadPackage('ti.ipc.ipcmgr');
+ BIOS.addUserStartupFunction('&IpcMgr_ipcStartup');
+
xdc.loadCapsule("Dsp.cfg");
xdc.loadCapsule("DspAmmu.cfg");
}
else if (Program.platformName.match(/^ti\.platforms\.evmDRA7XX/) &&
Program.cpu.attrs.cpuCore.match(/^CM4$/)) {
+ xdc.loadPackage('ti.ipc.ipcmgr');
+ BIOS.addUserStartupFunction('&IpcMgr_ipcStartup');
xdc.loadCapsule("IpcCommon_vayu.cfg.xs");
if (Program.platformName.match(/^ti\.platforms\.evmDRA7XX\:ipu1/)) {
xdc.loadCapsule("Ipu1Smp.cfg");
}
else if (Program.platformName.match(/^ti\.platforms\.evmDRA7XX/) &&
Program.cpu.attrs.cpuCore.match(/^6600$/)) {
+ xdc.loadPackage('ti.ipc.ipcmgr');
+ BIOS.addUserStartupFunction('&IpcMgr_ipcStartup');
xdc.loadCapsule("Dsp_vayu.cfg");
}
else {
diff --git a/qnx/src/ipc3x_dev/ti/syslink/utils/hlos/knl/NameServer_daemon.c b/qnx/src/ipc3x_dev/ti/syslink/utils/hlos/knl/NameServer_daemon.c
index 09f259800f3fc0d91e08d3aa3b9e71c88e748625..fde0bb2f00da7c2308262df42ff13362bf37cdbb 100644 (file)
/* Internal stuff: */
#include <_MessageQCopy.h>
#include <_NameServer.h>
-#include <_NameServerRemoteRpmsg.h>
+#include <ti/ipc/namesrv/_NameServerRemoteRpmsg.h>
#include <_IpcLog.h>
/* TI Ipc utils: */
/* structure for NameServer module state */
typedef struct NameServer_ModuleObject {
CIRCLEQ_HEAD(dummy1, NameServer_Object) objList;
- Int32 refCount;
- MessageQCopy_Handle mq;
+ Int32 refCount;
+ MessageQCopy_Handle mq;
/* MessageQCopy instance to receive from remote proc nameserver ports: */
- UInt32 recvAddr;
+ UInt32 recvAddr;
/* Local endpoint for receiving from remote proc nameserver ports: */
- pthread_t listener;
+ pthread_t listener;
/* Listener thread for NameServer replies and requests. */
- int waitFdW;
- int waitFdR;
+ int waitFdW;
+ int waitFdR;
/* Pipe to post to NameServer_get. */
- NameServerMsg nsMsg;
+ NameServerRemote_Msg nsMsg;
/* NameServer Message cache. */
- NameServer_Params defInstParams;
+ NameServer_Params defInstParams;
/* Default instance paramters */
- pthread_mutex_t modGate;
+ pthread_mutex_t modGate;
} NameServer_ModuleObject;
#define CIRCLEQ_destruct(head) { \
return (hash);
}
-static void NameServerRemote_processMessage(NameServerMsg * msg, UInt16 procId)
+static void NameServerRemote_processMessage(NameServerRemote_Msg * msg, UInt16 procId)
{
NameServer_Handle handle;
Int status = NameServer_E_FAIL;
/* send response message to remote processor */
status = MessageQCopy_send(procId, MultiProc_self(),
MESSAGEQ_RPMSG_PORT, RPMSG_RESERVED_ADDRESSES, msg,
- sizeof(NameServerMsg), TRUE);
+ sizeof(NameServerRemote_Msg), TRUE);
if (status < 0) {
LOG0("NameServer: MessageQCopy_send failed\n")
}
LOG1(", value: 0x%x\n", msg->value)
/* Save the response message. */
- memcpy(&NameServer_module->nsMsg, msg, sizeof(NameServerMsg));
+ memcpy(&NameServer_module->nsMsg, msg, sizeof(NameServerRemote_Msg));
/* Post the eventfd upon which NameServer_get() is waiting */
write(waitFd, &buf, sizeof(buf));
static Void _listener_cb(MessageQCopy_Handle handle, void * data, int len,
void * priv, UInt32 src, UInt16 srcProc)
{
- NameServerMsg msg;
+ NameServerRemote_Msg msg;
LOG0("listener_cb: Entered Listener thread.\n")
/* Get NameServer message and process: */
memcpy(&msg, data, len);
- if (len != sizeof(NameServerMsg)) {
- LOG1("NameServer: got bad NameServerMsg len (%d)\n",
+ if (len != sizeof(NameServerRemote_Msg)) {
+ LOG1("NameServer: got bad NameServerRemote_Msg len (%d)\n",
len)
}
else {
/* Calculate the hash */
hash = stringHash(name);
+ pthread_mutex_lock(&handle->gate);
+
+ if (strlen(name) > handle->params.maxNameLen - 1) {
+ status = NameServer_E_INVALIDARG;
+ LOG0("NameServer_add: name length exceeded maximum!\n")
+ new_node = NULL;
+ goto exit;
+ }
+
if (len > handle->params.maxValueLen) {
status = NameServer_E_INVALIDARG;
LOG0("NameServer_add: value length exceeded maximum!\n")
goto exit;
}
- pthread_mutex_lock(&handle->gate);
-
/* Traverse the list to find duplicate check */
CIRCLEQ_traverse(node, &handle->nameList, NameServer_TableEntry_tag) {
/* Hash matches */
Int status = NameServer_S_SUCCESS;
Int mqcStatus = -1;
struct NameServer_Object *obj = (struct NameServer_Object *)(handle);
- NameServerMsg nsMsg;
- NameServerMsg *replyMsg;
+ NameServerRemote_Msg nsMsg;
+ NameServerRemote_Msg *replyMsg;
fd_set rfds;
int ret = 0, maxfd, waitFd;
struct timeval tv;
static int seqNum = 0;
Bool done = FALSE;
+ if (strlen(name) >= MAXNAMEINCHAR) {
+ LOG0("Name is too long in remote query\n");
+ return NameServer_E_NAMETOOLONG;
+ }
+
+ if (strlen(obj->name) >= MAXNAMEINCHAR) {
+ LOG0("Instance name is too long for remote query\n");
+ return NameServer_E_NAMETOOLONG;
+ }
+
pthread_mutex_lock(&NameServer_module->modGate);
/* Set Timeout to wait: */
/* send message */
mqcStatus = MessageQCopy_send(procId, MultiProc_self(), MESSAGEQ_RPMSG_PORT,
- RPMSG_RESERVED_ADDRESSES, &nsMsg, sizeof(NameServerMsg),
+ RPMSG_RESERVED_ADDRESSES, &nsMsg, sizeof(NameServerRemote_Msg),
TRUE);
if (mqcStatus < 0) {
LOG0("NameServer_getRemote: Can't send to remote endpoint\n")
diff --git a/qnx/src/ipc3x_dev/ti/syslink/utils/hlos/usr/Qnx/NameServerDrv.c b/qnx/src/ipc3x_dev/ti/syslink/utils/hlos/usr/Qnx/NameServerDrv.c
index 91b8dfcc091d11078bfd926dc4717f9ed4294618..e62fb187996a895dac6543ececc7e7f66acaa248 100644 (file)
*
* ============================================================================
*
- * Copyright (c) 2008-2013, Texas Instruments Incorporated
+ * Copyright (c) 2008-2015, Texas Instruments Incorporated
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
SETIOV(&nameserver_add_iov[1], cargs->args.add.name,
cargs->args.add.nameLen);
SETIOV( &nameserver_add_iov[2], cargs->args.add.buf,
- cargs->args.add.len);
+ cargs->args.add.len);
osStatus = devctlv(IpcDrv_handle, DCMD_NAMESERVER_ADD, 3, 3,
nameserver_add_iov, nameserver_add_iov, NULL);
sizeof(NameServerDrv_CmdArgs));
count++;
SETIOV( &nameserver_get_iov[count], cargs->args.getUInt32.name,
- NameServer_Params_MAXNAMELEN);
+ strlen(cargs->args.getUInt32.name) + 1);
count++;
if (cargs->args.getUInt32.procId != NULL) {
diff --git a/qnx/src/tests/NameServerApp/NameServerApp.c b/qnx/src/tests/NameServerApp/NameServerApp.c
index 288251b633681125a4644eda3e2ffb9f01c40dad..b553db5a110234c2e3bdc43a11e8296a044191f0 100644 (file)
/*
- * Copyright (c) 2013, Texas Instruments Incorporated
+ * Copyright (c) 2013-2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*/
#define NSNAME "MyNS"
#define NSNAME2 "MyNS2"
+#define NSLONGNAME "LongNameabcdefghijklmnopqrstuvwxyz1234567890abcdefghi" \
+ "jklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890"
/** ============================================================================
* Globals
* ============================================================================
*/
+Int nameLenTest()
+{
+ NameServer_Params params;
+ NameServer_Handle nsHandle;
+ Int32 status = 0;
+ Ptr ptr;
+ UInt32 val;
+
+ printf("Testing long names...\n");
+
+ NameServer_Params_init(¶ms);
+
+ params.maxValueLen = sizeof(UInt32);
+ params.maxNameLen = 32;
+
+ nsHandle = NameServer_create(NSLONGNAME, ¶ms);
+ if (nsHandle == NULL) {
+ printf("Failed to create NameServer '%s'\n", NSLONGNAME);
+ return -1;
+ }
+ else {
+ printf("Created NameServer '%s'\n", NSLONGNAME);
+ }
+
+ /* This name should be too long for creation params and results in error */
+ printf("Trying to add a name that exceeds maxNameLen...\n");
+ ptr = NameServer_addUInt32(nsHandle, NSLONGNAME, 0xdeadbeef);
+ if (ptr == NULL) {
+ printf(" ...got expected Failure from NameServer_addUInt32()\n");
+ }
+ else {
+ printf(" Error: NameServer_addUInt32() returned non-NULL %p (but "
+ "was expected to fail)\n", ptr);
+ NameServer_delete(&nsHandle);
+ return -1;
+ }
+
+ printf("Deleting nsHandle...\n");
+ NameServer_delete(&nsHandle);
+
+ NameServer_Params_init(¶ms);
+
+ params.maxValueLen = sizeof(UInt32);
+ params.maxNameLen = 180;
+
+ nsHandle = NameServer_create(NSLONGNAME, ¶ms);
+ if (nsHandle == NULL) {
+ printf("Failed to create NameServer '%s'\n", NSLONGNAME);
+ return -1;
+ }
+ else {
+ printf("Created NameServer '%s'\n", NSLONGNAME);
+ }
+
+ /* This name is too long for remote to handle and results in error */
+ printf("Trying to get a name that the remote cannot handle...\n");
+ val = 0x00c0ffee;
+ status = NameServer_getUInt32(nsHandle, NSLONGNAME, &val, NULL);
+ if (status == NameServer_E_NAMETOOLONG) {
+ printf(" ...got expected Failure from NameServer_getUInt32()\n");
+ }
+ else {
+ printf(" Error: NameServer_getUint32() returned unexpected "
+ "result: %d\n", status);
+ return -1;
+ }
+
+ printf("Deleting nsHandle...\n");
+ NameServer_delete(&nsHandle);
+
+ NameServer_Params_init(¶ms);
+
+ params.maxValueLen = sizeof(UInt32);
+ params.maxNameLen = 32;
+
+ nsHandle = NameServer_create(NSLONGNAME, ¶ms);
+ if (nsHandle == NULL) {
+ printf("Failed to create NameServer '%s'\n", NSLONGNAME);
+ return -1;
+ }
+ else {
+ printf("Created NameServer '%s'\n", NSLONGNAME);
+ }
+
+ /* The instance name is too long for remote and results in error */
+ printf("Trying to use an instance name that the remote cannot "
+ "handle...\n");
+ val = 0x00c0ffee;
+ status = NameServer_getUInt32(nsHandle, "Key", &val, NULL);
+ if (status == NameServer_E_NAMETOOLONG) {
+ printf(" ...got expected Failure from NameServer_getUInt32()\n");
+ }
+ else {
+ printf(" Error: NameServer_getUint32() returned unexpected "
+ "result: %d\n", status);
+ return -1;
+ }
+
+ printf("Deleting nsHandle...\n");
+ NameServer_delete(&nsHandle);
+
+ return 0;
+}
Int testNS(NameServer_Handle nsHandle, String name)
{
goto again;
}
+ status = nameLenTest();
+ if (status != 0) {
+ printf("Name Length test failed\n");
+ return status;
+ }
+
printf("Calling NameServer_destroy()...\n");
NameServer_destroy();