#endif /* Solaris */
#if defined(__linux)
char buf[256];
char tbuf[256];
const char * uidStart;
FILE *p;
snprintf(buf, 255, "%s route get %s", IP_BINARY, ip);
p = popen(buf, "r");
fgets(buf, 255, p);
/* TODO: check for failure of fgets */
route = strdup(buf);
/* Starting with iproute2 4.10.0, call to 'ip route get' will contain uid value.
* Still uid should not be used in other calls (i.e. replace, delete). */
uidStart = strstr(buf, " uid");
if (uidStart) {
snprintf(tbuf, uidStart - buf + 1, "%s", buf);
route = strdup(tbuf);
}
else {
pclose(p);
/* TODO: check for failure of command */
#endif /* __linux__ */