Index: /trunk/FACT++/src/Dim.cc
===================================================================
--- /trunk/FACT++/src/Dim.cc	(revision 10645)
+++ /trunk/FACT++/src/Dim.cc	(revision 10645)
@@ -0,0 +1,77 @@
+#include "Dim.h"
+
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+
+#include <iostream>
+
+using namespace std;
+
+string Dim::GetLocalIp()
+{
+    const char *kDnsIp = getenv("DIM_DNS_NODE");
+
+    struct addrinfo hints, *servinfo, *p;
+
+    memset(&hints, 0, sizeof hints);
+    hints.ai_family   = AF_INET; //AF_UNSPEC; // use AF_INET6 to force IPv6
+    hints.ai_socktype = SOCK_STREAM;
+
+    int rv;
+    if ((rv = getaddrinfo(kDnsIp, NULL, &hints, &servinfo)) != 0)
+    {
+        cout << "WARNING - getaddrinfo: " << gai_strerror(rv) << endl;
+        return kDnsIp;
+    }
+
+    // loop through all the results and connect to the first we can
+    for (p=servinfo; p; p=p->ai_next)
+    {
+        const int sock = socket(AF_INET, SOCK_DGRAM, 0);
+        if (sock==-1)
+            continue;
+
+        if (connect(sock, p->ai_addr, p->ai_addrlen)==-1)
+        {
+            cout << "WARNING - connect: " << strerror(errno) << endl;
+            close(sock);
+            continue;
+        }
+
+        sockaddr_in name;
+        socklen_t namelen = sizeof(name);
+        if (getsockname(sock, (sockaddr*)&name, &namelen)==-1)
+        {
+            cout << "WARNING - getsockname: " << strerror(errno) << endl;
+            close(sock);
+            continue;
+        }
+
+        char buffer[16];
+        if (!inet_ntop(AF_INET, &name.sin_addr, buffer, 16))
+        {
+            cout << "WARNING - inet_ntop: " << strerror(errno) << endl;
+            close(sock);
+            continue;
+        }
+
+        close(sock);
+
+        freeaddrinfo(servinfo); // all done with this structure
+
+        cout << "DIM_HOST_NODE=" << buffer << endl;
+        return buffer;
+    }
+
+    freeaddrinfo(servinfo); // all done with this structure
+
+    return kDnsIp;
+}
+
+void Dim::Setup(const std::string &dns)
+{
+    setenv("DIM_DNS_NODE",  dns.c_str(),          1);
+    setenv("DIM_HOST_NODE", GetLocalIp().c_str(), 1);
+}
Index: /trunk/FACT++/src/Dim.h
===================================================================
--- /trunk/FACT++/src/Dim.h	(revision 10645)
+++ /trunk/FACT++/src/Dim.h	(revision 10645)
@@ -0,0 +1,26 @@
+#ifndef FACT_Dim
+#define FACT_Dim
+
+#include <string>
+
+#include "dic.hxx"
+
+namespace Dim
+{
+    inline bool SendCommand(const std::string &command)
+    {
+        return DimClient::sendCommand(command.c_str(), NULL, 0);
+    }
+
+    template<typename T>
+        inline bool SendCommand(const std::string &command, const T &t)
+    {
+        return DimClient::sendCommand(command.c_str(), (void*)&t, sizeof(t));
+    }
+
+    std::string GetLocalIp();
+
+    void Setup(const std::string &dns);
+}
+
+#endif
