rebuild geeqie
[oi-userland.git] / components / network / iftop / patches / 06.addrs_dlpi.c.patch
blob7ffe5205bc081f154ad7caba98f7650803ad8684
1 --- addrs_dlpi.c.orig Tue Feb 10 13:55:04 2009
2 +++ addrs_dlpi.c Fri Jan 16 12:42:53 2009
3 @@ -24,11 +24,8 @@
4 #include <sys/sockio.h>
5 #include <sys/ioctl.h>
6 #include <sys/socket.h>
7 -#include <sys/dlpi.h>
8 #include <net/if.h>
10 -#include "dlcommon.h"
12 extern char *split_dname(char *device, int *unitp);
13 extern char *strncpy2(char *dest, char *src, int n);
14 extern char *strncat2(char *dest, char *src, int n);
15 @@ -56,123 +53,8 @@
16 int got_ip_addr = 0;
18 int fd;
19 - long buf[MAXDLBUF]; /* long aligned */
20 - union DL_primitives *dlp;
22 - char *cp;
23 - int unit_num = 0;
24 - int sap = 0;
26 - char *devname = NULL;
27 - char *devname2 = NULL;
28 - char fulldevpath[256];
30 struct ifreq ifr = {};
32 - /* -- */
34 - memset(if_hw_addr, 0, 6);
36 - // we want to be able to process either a fully qualified /dev/ge0
37 - // type interface definition, or just ge0.
39 - if (strncmp(interface, "/dev/", strlen("/dev/")) == 0) {
40 - devname = interface + strlen("/dev/");
41 - } else {
42 - devname = interface;
43 - }
45 - strncpy2(fulldevpath, "/dev/", sizeof(fulldevpath)-1);
46 - cp = strncat2(fulldevpath, interface, sizeof(fulldevpath));
48 - if (strlen(cp) != 0) {
49 - fprintf(stderr, "device name buffer overflow %s\n", fulldevpath);
50 - return -1;
51 - }
53 - fprintf(stderr,"interface: %s\n", devname);
55 - // on Solaris, even though we are wanting to talk to ethernet device
56 - // ge0, we have to open /dev/ge, then bind to unit 0. Dupe our
57 - // full path, then identify and cut off the unit number
59 - devname2 = strdup(fulldevpath);
61 - cp = split_dname(devname2, &unit_num);
63 - if (cp == NULL) {
64 - free(devname2);
65 - goto get_ip_address;
66 - } else {
67 - *cp = '\0'; /* null terminate devname2 right before numeric extension */
68 - }
70 - // devname2 should now be something akin to /dev/ge. Try to open
71 - // it, and if it fails, fall back to the full /dev/ge0.
73 - if ((fd = open(devname2, O_RDWR)) < 0) {
74 - if (errno != ENOENT) {
75 - fprintf(stderr, "Couldn't open %s\n", devname2);
76 - free(devname2);
77 - goto get_ip_address;
78 - } else {
79 - if ((fd = open(fulldevpath, O_RDWR)) < 0) {
80 - fprintf(stderr, "Couldn't open %s\n", fulldevpath);
81 - free(devname2);
82 - goto get_ip_address;
83 - }
84 - }
85 - }
87 - free(devname2);
88 - devname2 = NULL;
90 - /* Use the dlcommon functions to get access to the DLPI information for this
91 - * interface. All of these functions exit() out on failure
92 - */
94 - dlp = (union DL_primitives*) buf;
96 - /*
97 - * DLPI attach to our low-level device
98 - */
100 - dlattachreq(fd, unit_num);
101 - dlokack(fd, buf);
103 - /*
104 - * DLPI bind
105 - */
107 - dlbindreq(fd, sap, 0, DL_CLDLS, 0, 0);
108 - dlbindack(fd, buf);
110 - /*
111 - * DLPI DL_INFO_REQ
112 - */
114 - dlinforeq(fd);
115 - dlinfoack(fd, buf);
117 - /*
118 - printdlprim(dlp); // uncomment this to dump out info from DLPI
119 - */
121 - if (dlp->info_ack.dl_addr_length + dlp->info_ack.dl_sap_length == 6) {
122 - memcpy(if_hw_addr,
123 - OFFADDR(dlp, dlp->info_ack.dl_addr_offset),
124 - dlp->info_ack.dl_addr_length);
125 - got_hw_addr = 1;
126 - } else {
127 - fprintf(stderr, "Error, bad length for hardware interface %s -- %d\n",
128 - interface,
129 - dlp->info_ack.dl_addr_length);
132 - close(fd);
134 - get_ip_address:
136 /* Get the IP address of the interface */
138 #ifdef SIOCGIFADDR