1 | This patch against rtems-4.6.0pre4 addresses the following issue |
---|
2 | - replaced call to inet_ntoa() by inet_ntop() (reentrancy) |
---|
3 | - fixed address printing: check sa_family only for the |
---|
4 | ifa_addr field. |
---|
5 | |
---|
6 | Index: rtems/src-20030128/cpukit/libnetworking/rtems/rtems_showifstat.c |
---|
7 | diff -c rtems/src-20030128/cpukit/libnetworking/rtems/rtems_showifstat.c:1.1.1.2 rtems/src-20030128/cpukit/libnetworking/rtems/rtems_showifstat.c:1.2 |
---|
8 | *** rtems/src-20030128/cpukit/libnetworking/rtems/rtems_showifstat.c:1.1.1.2 Wed Jan 29 14:58:01 2003 |
---|
9 | --- rtems/src-20030128/cpukit/libnetworking/rtems/rtems_showifstat.c Tue Jul 22 18:06:00 2003 |
---|
10 | *************** |
---|
11 | *** 12,17 **** |
---|
12 | --- 12,18 ---- |
---|
13 | #include <sys/ioctl.h> |
---|
14 | #include <net/if.h> |
---|
15 | #include <netinet/in.h> |
---|
16 | + #include <arpa/inet.h> |
---|
17 | |
---|
18 | /* |
---|
19 | * Display an address |
---|
20 | *************** |
---|
21 | *** 20,31 **** |
---|
22 | showaddress (char *name, struct sockaddr *a) |
---|
23 | { |
---|
24 | struct sockaddr_in *sa; |
---|
25 | |
---|
26 | ! if (!a || (a->sa_family != AF_INET)) |
---|
27 | return 0; |
---|
28 | printf ("%s:", name); |
---|
29 | sa = (struct sockaddr_in *)a; |
---|
30 | ! printf ("%-16s", inet_ntoa (sa->sin_addr)); |
---|
31 | return 1; |
---|
32 | } |
---|
33 | |
---|
34 | --- 21,33 ---- |
---|
35 | showaddress (char *name, struct sockaddr *a) |
---|
36 | { |
---|
37 | struct sockaddr_in *sa; |
---|
38 | + char buf[17]; |
---|
39 | |
---|
40 | ! if (!a) |
---|
41 | return 0; |
---|
42 | printf ("%s:", name); |
---|
43 | sa = (struct sockaddr_in *)a; |
---|
44 | ! printf ("%-16s", inet_ntop (AF_INET, &sa->sin_addr, buf, sizeof(buf))); |
---|
45 | return 1; |
---|
46 | } |
---|
47 | |
---|
48 | *************** |
---|
49 | *** 44,49 **** |
---|
50 | --- 46,53 ---- |
---|
51 | for (ifp = ifnet; ifp; ifp = ifp->if_next) { |
---|
52 | printf ("***** %s%d *****\n", ifp->if_name, ifp->if_unit); |
---|
53 | for (ifa = ifp->if_addrlist ; ifa ; ifa = ifa->ifa_next) { |
---|
54 | + if ( !ifa->ifa_addr || AF_INET != ifa->ifa_addr->sa_family ) |
---|
55 | + continue; |
---|
56 | printed = showaddress ("Address", ifa->ifa_addr); |
---|
57 | if (ifp->if_flags & IFF_BROADCAST) |
---|
58 | printed |= showaddress ("Broadcast Address", ifa->ifa_broadaddr); |
---|