summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-11-10 10:58:20 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-11-10 10:58:20 +0000
commit6707cf5b9a373d6c5b7da9596f815b8e32213f7a (patch)
tree14403c34af372b7f73b2ad29324f5ee34f4c0362 /src
parent3de3de0b37ec1bec5da7b3737a063fe28c332d46 (diff)
downloadopenocd_libswd-6707cf5b9a373d6c5b7da9596f815b8e32213f7a.tar.gz
openocd_libswd-6707cf5b9a373d6c5b7da9596f815b8e32213f7a.tar.bz2
openocd_libswd-6707cf5b9a373d6c5b7da9596f815b8e32213f7a.tar.xz
openocd_libswd-6707cf5b9a373d6c5b7da9596f815b8e32213f7a.zip
broadcast mac address in UDP hello message
git-svn-id: svn://svn.berlios.de/openocd/trunk@1152 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/ecosboard.c54
1 files changed, 30 insertions, 24 deletions
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();
}