[Title]change sdb packet format
authormunkyu.im <munkyu.im@samsung.com>
Mon, 13 Aug 2012 10:54:47 +0000 (19:54 +0900)
committermunkyu.im <munkyu.im@samsung.com>
Mon, 13 Aug 2012 10:54:47 +0000 (19:54 +0900)
[Type]
[Module]
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/src/emulator.h
tizen/src/sdb.c

index eaa0d9b026d8bc2fc6aba7f9145870deb47363c3..a30f731a826b4043c241899695e65a913b9d93d3 100644 (file)
@@ -38,6 +38,7 @@
 #define __EMULATOR_H__
 
 #define MAXLEN  512
+#define MAXPACKETLEN 60
 
 extern char tizen_target_path[MAXLEN];
 
index 90a5cf19dbac8a30c6682ec35e7ed5120c19ef0e..e6322d5df9a7b635702d63f448aaea370fd896b2 100644 (file)
@@ -23,6 +23,7 @@
 #include <netdb.h>
 #endif /* !_WIN32 */
 
+#include "emulator.h"
 #include "net/slirp.h"
 #include "qemu_socket.h"
 #include "sdb.h"
@@ -338,32 +339,33 @@ int sdb_loopback_client(int port, int type)
 }
 
 void notify_sdb_daemon_start(void) {
+    
     int s;
     /* 
      * send a simple message to the SDB host server to tell it we just started.
      * it should be listening on port 26099.
      */
-    do {
-        char tmp[32] = { 0 };
-
-        // when connecting to loopback:26099, do not use tcp_socket_outgoing function
-        // tcp_socket_outgoing may occur "dns name service not known" in case of network unavaliable status.
-        s = sdb_loopback_client(SDB_HOST_PORT, SOCK_STREAM);
-        if (s < 0) {
-            INFO("can't create socket to talk to the SDB server \n");
-            INFO("This emulator will be scaned by the SDB server \n");
-            break;
-        }
-
-        /* length is hex: 0x13 = 19 */
-        sprintf(tmp, "0013host:emulator:%d", tizen_base_port + 1);
-
-        if (socket_send(s, tmp, 30) < 0) {
-            ERR( "message sending to sdb server error!\n");
-        }
+    char *targetname = g_path_get_basename(tizen_target_path);
+    char tmp[MAXPACKETLEN] = { 0 };
+    // when connecting to loopback:26099, do not use tcp_socket_outgoing function
+    // tcp_socket_outgoing may occur "dns name service not known" in case of network unavaliable status.
+    s = sdb_loopback_client(SDB_HOST_PORT, SOCK_STREAM);
+    if (s < 0) {
+        INFO("can not create socket to talk to the SDB server.\n");
+        INFO("SDB server might not be started yet.\n");
+        free(targetname);
+        return;
+    }
 
-    } while (0);
+    /* length is hex host:emulator:port: -> 0x13 = 20 */
+    sprintf(tmp, "00%2xhost:emulator:%d:%s", 20 + strlen(targetname), tizen_base_port + 1, targetname);
+    INFO("message to send to SDB server: %s\n", tmp);
+    if (socket_send(s, tmp, MAXPACKETLEN) < 0) {
+        ERR( "message sending to SDB server error!\n");
+    }
 
     if (s >= 0)
         socket_close(s);
+   
+    free(targetname);
 }