This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Synth ethernet - build fix
- From: Gary Thomas <gary at mlbassoc dot com>
- To: eCos patches <ecos-patches at sources dot redhat dot com>
- Date: 16 Jul 2003 12:18:38 -0600
- Subject: Synth ethernet - build fix
- Organization: MLB Associates
These changes were necessary to build the host side tools
with the latest tools (Red Hat 9)
--
Gary Thomas <gary@mlbassoc.com>
MLB Associates
Index: devs/eth/synth/ecosynth/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/synth/ecosynth/current/ChangeLog,v
retrieving revision 1.14
diff -u -5 -p -r1.14 ChangeLog
--- devs/eth/synth/ecosynth/current/ChangeLog 9 Jul 2003 15:31:36 -0000 1.14
+++ devs/eth/synth/ecosynth/current/ChangeLog 16 Jul 2003 18:15:44 -0000
@@ -1,5 +1,10 @@
+2003-07-16 Gary Thomas <gary@mlbassoc.com>
+
+ * host/rawether.c: Change error reporting to use standard 'strerror()'
+ function since the use of sys_errlist[] is depricated.
+
2003-07-09 Bart Veer <bartv@ecoscentric.com>
* host/Makefile.am: add a dummy install-data-hook if not
supported.
Index: devs/eth/synth/ecosynth/current/host/rawether.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/synth/ecosynth/current/host/rawether.c,v
retrieving revision 1.3
diff -u -5 -p -r1.3 rawether.c
--- devs/eth/synth/ecosynth/current/host/rawether.c 15 Apr 2003 10:31:22 -0000 1.3
+++ devs/eth/synth/ecosynth/current/host/rawether.c 8 Jul 2003 21:11:43 -0000
@@ -184,11 +184,11 @@ real_handle_rx(void)
int result;
size = recv(ether_fd, rx_buffer + 4, MTU, MSG_TRUNC);
#if (DEBUG > 0)
- fprintf(stderr, "rawether dbg: rx returned %d, errno %s (%d)\n", size, (errno < sys_nerr) ? sys_errlist[errno] : "<unknown>", errno);
+ fprintf(stderr, "rawether dbg: rx returned %d, errno %s (%d)\n", size, strerror(errno), errno);
#endif
if (size < 0) {
return; // Ignore errors, just go around the main loop again.
}
@@ -330,27 +330,27 @@ real_init(char* devname)
// All ioctl() operations need a socket. We might as well create the
// raw socket immediately and use that.
ether_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (ether_fd < 0) {
snprintf(msg, MSG_SIZE, "Unable to create a raw socket for accessing network device\n"
- " Error %s (errno %d)\n", (errno < sys_nerr) ? sys_errlist[errno] : "unknown", errno);
+ " Error %s (errno %d)\n", strerror(errno), errno);
report_error(msg);
}
strncpy(request.ifr_name, real_devname, IFNAMSIZ);
if (ioctl(ether_fd, SIOCGIFINDEX, &request) < 0) {
snprintf(msg, MSG_SIZE, "Device %s does not correspond to a valid interface.\n"
- " Error %s (errno %d)\n", real_devname, (errno < sys_nerr) ? sys_errlist[errno] : "unknown", errno);
+ " Error %s (errno %d)\n", real_devname, strerror(errno), errno);
report_error(msg);
}
real_ifindex = request.ifr_ifindex;
// The interface exists. Now check that it is usable.
strncpy(request.ifr_name, real_devname, IFNAMSIZ);
if (ioctl(ether_fd, SIOCGIFFLAGS, &request) < 0) {
snprintf(msg, MSG_SIZE, "Failed to get current interface flags for %s\n"
- " Error %s (errno %d)\n", real_devname, (errno < sys_nerr) ? sys_errlist[errno] : "unknown", errno);
+ " Error %s (errno %d)\n", real_devname, strerror(errno), errno);
report_error(msg);
}
if (request.ifr_flags & (IFF_UP | IFF_RUNNING)) {
snprintf(msg, MSG_SIZE, "Network device %s is already up and running.\n"
@@ -372,11 +372,11 @@ real_init(char* devname)
// The flags look ok. Now get hold of the hardware address.
strncpy(request.ifr_name, real_devname, IFNAMSIZ);
if (ioctl(ether_fd, SIOCGIFHWADDR, &request) < 0) {
snprintf(msg, MSG_SIZE, "Failed to get hardware address for %s\n"
- " Error %s (errno %d)\n", real_devname, (errno < sys_nerr) ? sys_errlist[errno] : "unknown", errno);
+ " Error %s (errno %d)\n", real_devname, strerror(errno), errno);
report_error(msg);
}
if (ARPHRD_ETHER != request.ifr_hwaddr.sa_family) {
snprintf(msg, MSG_SIZE, "Device %s is not an ethernet device.\n", real_devname);
report_error(msg);
@@ -387,11 +387,11 @@ real_init(char* devname)
addr.sll_family = AF_PACKET;
addr.sll_protocol = htons(ETH_P_ALL);
addr.sll_ifindex = real_ifindex;
if (bind(ether_fd, (struct sockaddr*) &addr, sizeof(addr)) < 0) {
snprintf(msg, MSG_SIZE, "Failed to bind socket for direct hardware address to %s\n"
- " Error %s (errno %d)\n", real_devname, (errno < sys_nerr) ? sys_errlist[errno] : "unknown", errno);
+ " Error %s (errno %d)\n", real_devname, strerror(errno), errno);
report_error(msg);
}
// Make sure the interface gets shut down when rawether exits.
atexit(real_atexit);
@@ -457,11 +457,11 @@ tap_handle_rx(void)
int result;
// select() has succeeded so this read() should never block.
size = read(ether_fd, rx_buffer + 4, MTU);
#if (DEBUG > 0)
- fprintf(stderr, "rawether dbg: rx returned %d, errno %s (%d)\n", size, (errno < sys_nerr) ? sys_errlist[errno] : "<unknown>", errno);
+ fprintf(stderr, "rawether dbg: rx returned %d, errno %s (%d)\n", size, strerror(errno), errno);
#endif
if (size < 0) {
return; // Ignore errors, just go around the main loop again.
}
@@ -584,32 +584,31 @@ tap_init(int argc, char** argv)
persistent = !strncmp(argv[1], "persistent", 10);
}
ether_fd = open("/dev/net/tun", O_RDWR);
if (ether_fd < 0) {
- snprintf(msg, MSG_SIZE, "Failed to open /dev/net/tun, errno %s (%d)\n", (errno < sys_nerr) ? sys_errlist[errno] : "<unknown>", errno);
+ snprintf(msg, MSG_SIZE, "Failed to open /dev/net/tun, errno %s (%d)\n", strerror(errno), errno);
report_error(msg);
}
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
if (NULL != devname) {
strncpy(ifr.ifr_name, devname, IFNAMSIZ - 1);
}
if (ioctl(ether_fd, TUNSETIFF, (void*)&ifr) < 0) {
- snprintf(msg, MSG_SIZE, "Failed to initialize /dev/net/tun, errno %s (%d)\n", (errno < sys_nerr) ? sys_errlist[errno] : "<unknown>", errno);
+ snprintf(msg, MSG_SIZE, "Failed to initialize /dev/net/tun, errno %s (%d)\n", strerror(errno), errno);
report_error(msg);
}
// Supporting multicasts is a no-op
multicast_supported = 1;
if (persistent) {
if (ioctl(ether_fd, TUNSETPERSIST, 1) < 0) {
snprintf(msg, MSG_SIZE, "Failed to set persistent flag, errno %s (%d)\n",
- ( errno < sys_nerr) ?
- sys_errlist[errno] : "<unknown>", errno);
+ strerror(errno), errno);
report_error(msg);
}
}
// All done.
}
@@ -653,13 +652,11 @@ handle_ecosynth_request(void)
// has not been put into non-blocking mode.
if ((EINTR == errno) || (EAGAIN == errno)) {
return;
} else {
fprintf(stderr, "rawether: unexpected error reading request from ecosynth\n");
- if (errno < sys_nerr) {
- fprintf(stderr, " %s\n", sys_errlist[errno]);
- }
+ fprintf(stderr, " %s\n", strerror(errno));
exit(1);
}
}
if (result < 4) {
fprintf(stderr, "rawether: unexpected error reading request from ecosynth\n Expected 4 bytes, only received %d\n", result);