From: oharboe Date: Mon, 10 Nov 2008 10:58:20 +0000 (+0000) Subject: broadcast mac address in UDP hello message X-Git-Tag: v0.1.0~167 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6707cf5b9a373d6c5b7da9596f815b8e32213f7a;p=openocd broadcast mac address in UDP hello message git-svn-id: svn://svn.berlios.de/openocd/trunk@1152 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- diff --git a/src/ecosboard.c b/src/ecosboard.c index 7ed12fec..f0ec433f 100644 --- a/src/ecosboard.c +++ b/src/ecosboard.c @@ -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(); }