SDOCM00115373 NameServer local get methods are missing on Linux
authorRamsey Harris <ramsey@ti.com>
Wed, 25 Mar 2015 23:59:11 +0000 (16:59 -0700)
committerRobert Tivy <rtivy@ti.com>
Thu, 26 Mar 2015 23:42:37 +0000 (16:42 -0700)
Add enum entries for missing API methods. Add union members
in the command object only, reuse existing union members in
the response object. Add API stub calls in LAD command loop.
No logging in LAD command loop because some transports use this
method for each message (would generate too many log events).

linux/include/_lad.h
linux/src/api/NameServer.c
linux/src/daemon/lad.c

index bd756c037d00d29ff934eaf97692bf008777f5a3..47684eabfabc178397b58ab9d18a43fc9f2a2891 100644 (file)
@@ -163,6 +163,8 @@ typedef enum {
     LAD_NAMESERVER_GET,
     LAD_NAMESERVER_ADDUINT32,
     LAD_NAMESERVER_GETUINT32,
+    LAD_NAMESERVER_GETLOCAL,
+    LAD_NAMESERVER_GETLOCALUINT32,
     LAD_NAMESERVER_REMOVE,
     LAD_NAMESERVER_REMOVEENTRY,
     LAD_NAMESERVER_ATTACH,
@@ -221,6 +223,15 @@ struct LAD_CommandObj {
             Char name[LAD_MAXENTRYNAMELEN];
             UInt16 procId[MultiProc_MAXPROCESSORS];
         } getUInt32;
+        struct {
+            NameServer_Handle handle;
+            Char name[LAD_MAXENTRYNAMELEN];
+            UInt32 len;
+        } getLocal;
+        struct {
+            NameServer_Handle handle;
+            Char name[LAD_MAXENTRYNAMELEN];
+        } getLocalUInt32;
         struct {
             NameServer_Handle handle;
             Char name[LAD_MAXENTRYNAMELEN];
index 7b3da335526723d14554087d207976ea6f734d46..4f0d6867da304d923d321e66fb313d948d32724d 100644 (file)
@@ -414,6 +414,96 @@ Int NameServer_getUInt32(NameServer_Handle nsHandle, String name, Ptr buf,
     return status;
 }
 
+/*
+ *  ======== NameServer_getLocal ========
+ */
+Int NameServer_getLocal(NameServer_Handle ns, String name, Ptr buf, UInt32 *len)
+{
+    Int status;
+    LAD_ClientHandle clHandle;
+    struct LAD_CommandObj cmd;
+    union LAD_ResponseObj rsp;
+
+    clHandle = LAD_findHandle();
+
+    if (clHandle == LAD_MAXNUMCLIENTS) {
+        PRINTVERBOSE0("NameServer_getLocal: not connected to LAD\n");
+        return (NameServer_E_RESOURCE);
+    }
+
+    cmd.cmd = LAD_NAMESERVER_GETLOCAL;
+    cmd.clientId = clHandle;
+    cmd.args.getLocal.handle = ns;
+    strncpy(cmd.args.getLocal.name, name, LAD_MAXENTRYNAMELEN);
+    cmd.args.getLocal.len = *len;
+
+    if ((status = LAD_putCommand(&cmd)) != LAD_SUCCESS) {
+        PRINTVERBOSE1("NameServer_getLocal: sending LAD command failed, "
+                "status=%d\n", status)
+        return (NameServer_E_FAIL);
+    }
+
+    if ((status = LAD_getResponse(clHandle, &rsp)) != LAD_SUCCESS) {
+        PRINTVERBOSE1("NameServer_getLocal: no LAD response, status=%d\n",
+                status)
+        return (NameServer_E_FAIL);
+    }
+
+    *len = rsp.get.len;
+    if (rsp.get.buf != NULL) {
+        memcpy(buf, rsp.get.buf, *len);
+    }
+
+    status = rsp.get.status;
+
+    PRINTVERBOSE1("NameServer_getLocal: LAD response, status=%d\n", status)
+    return (status);
+}
+
+/*
+ *  ======== NameServer_getLocalUInt32 ========
+ */
+Int NameServer_getLocalUInt32(NameServer_Handle ns, String name, Ptr buf)
+{
+    Int status;
+    LAD_ClientHandle clHandle;
+    UInt32 *val;
+    struct LAD_CommandObj cmd;
+    union LAD_ResponseObj rsp;
+
+    clHandle = LAD_findHandle();
+
+    if (clHandle == LAD_MAXNUMCLIENTS) {
+        PRINTVERBOSE0("NameServer_getLocalUInt32: not connected to LAD\n");
+        return (NameServer_E_RESOURCE);
+    }
+
+    cmd.cmd = LAD_NAMESERVER_GETLOCALUINT32;
+    cmd.clientId = clHandle;
+    cmd.args.getLocalUInt32.handle = ns;
+    strncpy(cmd.args.getLocalUInt32.name, name, LAD_MAXENTRYNAMELEN);
+
+    if ((status = LAD_putCommand(&cmd)) != LAD_SUCCESS) {
+        PRINTVERBOSE1("NameServer_getLocalUInt32: sending LAD command failed, "
+                "status=%d\n", status)
+        return (NameServer_E_FAIL);
+    }
+
+    if ((status = LAD_getResponse(clHandle, &rsp)) != LAD_SUCCESS) {
+        PRINTVERBOSE1("NameServer_getLocalUInt32: no LAD response, status=%d\n",
+                status)
+        return (NameServer_E_FAIL);
+    }
+
+    val = (UInt32 *)buf;
+    *val = rsp.getUInt32.val;
+    status = rsp.getUInt32.status;
+
+    PRINTVERBOSE1("NameServer_getLocalUInt32: LAD response, status=%d\n",
+            status)
+    return (status);
+}
+
 Int NameServer_remove(NameServer_Handle nsHandle, String name)
 {
     Int status;
index ca0b1ca12123d7756ebaab094dc9fadc9215c6cf..1cbd314253790d53b08a10ec846f19ba54c11db9 100644 (file)
@@ -503,6 +503,19 @@ opencommandFIFO:
 
             break;
 
+          case LAD_NAMESERVER_GETLOCAL:
+            rsp.get.status = NameServer_getLocal(cmd.args.getLocal.handle,
+                cmd.args.getLocal.name, &rsp.get.buf, &cmd.args.getLocal.len);
+            rsp.get.len = cmd.args.getLocal.len;
+            break;
+
+          case LAD_NAMESERVER_GETLOCALUINT32:
+            rsp.getUInt32.status = NameServer_getLocalUInt32(
+                cmd.args.getLocalUInt32.handle,
+                cmd.args.getLocalUInt32.name,
+                &rsp.getUInt32.val);
+            break;
+
           case LAD_NAMESERVER_REMOVE:
             LOG2("LAD_NAMESERVER_REMOVE: calling NameServer_remove(%p, '%s')...\n", cmd.args.remove.handle, cmd.args.remove.name)
 
@@ -721,6 +734,8 @@ opencommandFIFO:
           case LAD_NAMESERVER_GET:
           case LAD_NAMESERVER_ADDUINT32:
           case LAD_NAMESERVER_GETUINT32:
+          case LAD_NAMESERVER_GETLOCAL:
+          case LAD_NAMESERVER_GETLOCALUINT32:
           case LAD_NAMESERVER_REMOVE:
           case LAD_NAMESERVER_REMOVEENTRY:
           case LAD_NAMESERVER_ATTACH: