Author: mladen.turk(a)jboss.com
Date: 2007-09-19 05:21:52 -0400 (Wed, 19 Sep 2007)
New Revision: 1032
Modified:
trunk/sight/native/os/linux/netadapter.c
Log:
Add support for IPV6 routes/gateways
Modified: trunk/sight/native/os/linux/netadapter.c
===================================================================
--- trunk/sight/native/os/linux/netadapter.c 2007-09-19 08:51:27 UTC (rev 1031)
+++ trunk/sight/native/os/linux/netadapter.c 2007-09-19 09:21:52 UTC (rev 1032)
@@ -338,6 +338,49 @@
return 0;
}
+static int get_ipv6_route(JNIEnv *_E, const char *name,
+ net_ifc_data_t *id)
+{
+ sight_arr_t *i6r;
+ net_ifc_addr_t *ca;
+ int i;
+
+ if (!id)
+ return 0; /* No rec, nothing to do */
+ if ((i6r = sight_arr_rload(PROC_NET_ROUTE6)) != NULL) {
+ for (i = 0; i < i6r->siz; i++) {
+ char iface[16], nname[64];
+ char dsta[128], neta[128], hopa[128];
+ struct in6_addr ipd, ipn, iph;
+
+ int al, iflags, metric, refcnt, use, plen, slen;
+
+ al = sscanf(i6r->arr[i],
+ "%64s %02X %64s %02X %64s %08X %08X %08X %08X %s",
+ dsta, &plen, neta, &slen, hopa, &metric, &use,
+ &refcnt, &iflags, iface);
+ if (al < 10 || !(iflags & RTF_GATEWAY))
+ continue;
+ if (strcmp(iface, name))
+ continue;
+ sprintf(nname, "%s.r6.%d", name, i);
+ /* TODO: Deal with RTF_HOST flags */
+ if (!(ca = get_ifc_addr(_E, nname, id))) {
+ sight_arr_free(i6r);
+ return 1;
+ }
+ if (ca->route)
+ continue;
+ ca->route = 1;
+ /* XXX: Is it source network or next hop ? */
+ sight_hex2bin(neta, ipd.s6_addr, 16);
+ sight_inet_ntop6(ipd.s6_addr, ca->ip6a, 64);
+ }
+ }
+ sight_arr_free(i6r);
+ return 0;
+}
+
SIGHT_EXPORT_DECLARE(jlong, NetworkAdapter, enum0)(SIGHT_STDARGS,
jlong pool)
{
@@ -497,12 +540,13 @@
else {
net_ifc_addr_t *ca;
- if (!(ca = get_ifc_addr(_E, ifr->ifr_name, id))) {
+ if (!(ca = get_ifc_addr(_E, ifi.ifr_name, id))) {
sight_arr_free(i6a);
goto cleanup;
}
strcpy(ca->ip6a, las);
}
+ get_ipv6_route(_E, ifi.ifr_name, id);
}
sight_arr_free(i6a);
}