]> git.sur5r.net Git - openocd/commitdiff
broadcast mac address in UDP hello message
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 10 Nov 2008 10:58:20 +0000 (10:58 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 10 Nov 2008 10:58:20 +0000 (10:58 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@1152 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/ecosboard.c

index 7ed12feccfe93eb8aae5529a998f46dbd24da738..f0ec433fd495bbb5259883c9891a475259a10175 100644 (file)
@@ -119,6 +119,7 @@ void diag_write(char *buf, int len)
 static bool serialLog = true;
 static bool writeLog = true;
 
+char hwaddr[512];
 
 struct FastLoad
 {
@@ -1215,33 +1216,9 @@ zylinjtag_Jim_Command_mac(Jim_Interp *interp,
                                    int argc,
                Jim_Obj * const *argv)
 {
-       int s;
-       struct ifreq ifr;
-       s = socket(AF_INET, SOCK_DGRAM, 0);
-       if (s >= 0)
-       {
-               strcpy(ifr.ifr_name, "eth0");
-               int res;
-               res = ioctl(s, SIOCGIFHWADDR, &ifr);
-               close(s);
-
-               if (res < 0)
-               {
-                       return JIM_OK;
-               }
-       }
 
        Jim_Obj *tclOutput = Jim_NewStringObj(interp, "", 0);
 
-       char hwaddr[512];
-       sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x",
-                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[0],
-                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[1],
-                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[2],
-                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[3],
-                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[4],
-                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[5]);
-
        Jim_AppendString(httpstate.jim_interp, tclOutput, hwaddr, strlen(hwaddr));
 
        Jim_SetResult(interp, tclOutput);
@@ -1295,6 +1272,7 @@ zylinjtag_Jim_Command_ip(Jim_Interp *interp,
 
 extern Jim_Interp *interp;
 
+
 static void zylinjtag_startNetwork()
 {
        // Bring TCP/IP up immediately before we're ready to accept commands.
@@ -1337,6 +1315,34 @@ static void zylinjtag_startNetwork()
 
        diag_printf("Web server running\n");
 
+       int s;
+       struct ifreq ifr;
+       s = socket(AF_INET, SOCK_DGRAM, 0);
+       if (s >= 0)
+       {
+               strcpy(ifr.ifr_name, "eth0");
+               int res;
+               res = ioctl(s, SIOCGIFHWADDR, &ifr);
+               close(s);
+
+               if (res < 0)
+               {
+                       diag_printf("Can't obtain MAC address\n");
+                       reboot();
+               }
+       }
+
+       sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x",
+                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[0],
+                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[1],
+                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[2],
+                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[3],
+                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[4],
+                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[5]);
+
+
+       discover_message=alloc_printf("ZY1000 Zylin JTAG debugger MAC %s", hwaddr);
+
        discover_launch();
 }