route -n get

In QNX 6.1, I can use “route -n -get destination gateway” to look up and
display the route for a destination. The “get” option is no longer
available in QNX 6.2. What’s been replaced with ?

Thanks,
-Beth

It works for me in 6.2.1. The syntax is:

route get

route -n get

-seanb

Beth <id@address.com> wrote:

In QNX 6.1, I can use “route -n -get destination gateway” to look up and
display the route for a destination. The “get” option is no longer
available in QNX 6.2. What’s been replaced with ?

Thanks,
-Beth

It’s documented in 6.1 and it works in 6.1. But it’s not documented in 6.2 and
I am
running 6.2 ( not 6.2.1), it’s not working in 6.2.
Maybe it’s added back to 6.2.1. Any one can verify this?

Thanks,
-Beth Chen

Sean Boudreau wrote:

It works for me in 6.2.1. The syntax is:

route get <dst

route -n get <dst

-seanb

Beth <> id@address.com> > wrote:
In QNX 6.1, I can use “route -n -get destination gateway” to look up and
display the route for a destination. The “get” option is no longer
available in QNX 6.2. What’s been replaced with ?

Thanks,
-Beth

Beth <id@address.com> wrote:
B > It’s documented in 6.1 and it works in 6.1. But it’s not documented in 6.2 and
B > I am
B > running 6.2 ( not 6.2.1), it’s not working in 6.2.
B > Maybe it’s added back to 6.2.1. Any one can verify this?

I’m running 6.21. It works for me.

/root>route get qnx.com
route to: qnx.com
destination: default
mask: default
gateway: 192.168.2.5
local addr: poly-rtp.qat
interface: en0
flags: <UP,GATEWAY,DONE>
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1500 0

We have verified that the “route get” command works on QNX6.1 and QNX 6.2.1. But it
didn’t work on QNX 6.2.
How can we get this supported on QNX 6.2?

-Beth

Bill Caroselli wrote:

Beth <> id@address.com> > wrote:
B > It’s documented in 6.1 and it works in 6.1. But it’s not documented in 6.2 and
B > I am
B > running 6.2 ( not 6.2.1), it’s not working in 6.2.
B > Maybe it’s added back to 6.2.1. Any one can verify this?

I’m running 6.21. It works for me.

/root>route get qnx.com
route to: qnx.com
destination: default
mask: default
gateway: 192.168.2.5
local addr: poly-rtp.qat
interface: en0
flags: <UP,GATEWAY,DONE
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1500 0

If you copy the route utility from 6.2.1 it “should” work.

-seanb

Beth <id@address.com> wrote:

We have verified that the “route get” command works on QNX6.1 and QNX 6.2.1. But it
didn’t work on QNX 6.2.
How can we get this supported on QNX 6.2?

-Beth

Bill Caroselli wrote:

Beth <> id@address.com> > wrote:
B > It’s documented in 6.1 and it works in 6.1. But it’s not documented in 6.2 and
B > I am
B > running 6.2 ( not 6.2.1), it’s not working in 6.2.
B > Maybe it’s added back to 6.2.1. Any one can verify this?

I’m running 6.21. It works for me.

/root>route get qnx.com
route to: qnx.com
destination: default
mask: default
gateway: 192.168.2.5
local addr: poly-rtp.qat
interface: en0
flags: <UP,GATEWAY,DONE
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1500 0

This is not going work since I don’t know what version of QNX my program will run. I use
the “route get” command to get interface name and gateway address for a giving ip
address. For Tiny TCP, I parse the /proc/ipstat file to get these information. What I
should really ask is how to get interface name, and gateway address of a giving ip
address programmatically? That will take care both tiny and full TCPIP.

Appreciate any help.

-Beth

Sean Boudreau wrote:

If you copy the route utility from 6.2.1 it “should” work.

-seanb

Beth <> id@address.com> > wrote:
We have verified that the “route get” command works on QNX6.1 and QNX 6.2.1. But it
didn’t work on QNX 6.2.
How can we get this supported on QNX 6.2?

-Beth

Bill Caroselli wrote:

Beth <> id@address.com> > wrote:
B > It’s documented in 6.1 and it works in 6.1. But it’s not documented in 6.2 and
B > I am
B > running 6.2 ( not 6.2.1), it’s not working in 6.2.
B > Maybe it’s added back to 6.2.1. Any one can verify this?

I’m running 6.21. It works for me.

/root>route get qnx.com
route to: qnx.com
destination: default
mask: default
gateway: 192.168.2.5
local addr: poly-rtp.qat
interface: en0
flags: <UP,GATEWAY,DONE
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1500 0

The best way to do this for the full stack is to use a routing
socket directly from C. See the thread entitled “Reading routing
entries” in this group for an example.

-seanb

Beth <id@address.com> wrote:

This is not going work since I don’t know what version of QNX my program will run. I use
the “route get” command to get interface name and gateway address for a giving ip
address. For Tiny TCP, I parse the /proc/ipstat file to get these information. What I
should really ask is how to get interface name, and gateway address of a giving ip
address programmatically? That will take care both tiny and full TCPIP.

Appreciate any help.

-Beth

Sean Boudreau wrote:

If you copy the route utility from 6.2.1 it “should” work.

-seanb

Beth <> id@address.com> > wrote:
We have verified that the “route get” command works on QNX6.1 and QNX 6.2.1. But it
didn’t work on QNX 6.2.
How can we get this supported on QNX 6.2?

-Beth

Bill Caroselli wrote:

Beth <> id@address.com> > wrote:
B > It’s documented in 6.1 and it works in 6.1. But it’s not documented in 6.2 and
B > I am
B > running 6.2 ( not 6.2.1), it’s not working in 6.2.
B > Maybe it’s added back to 6.2.1. Any one can verify this?

I’m running 6.21. It works for me.

/root>route get qnx.com
route to: qnx.com
destination: default
mask: default
gateway: 192.168.2.5
local addr: poly-rtp.qat
interface: en0
flags: <UP,GATEWAY,DONE
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1500 0

Sean, Thanks for your help. I have tried the sample you suggested. I works on getting the
default route for full tcp stack, but not on tiny tcp. Is there any way that I can write the
code so that it can be used for both tiny and full tcp?
Secondly, I am having difficulty on getting the information that I need using the following
code. I want to get an interface name and gateway address for an given ip address. Please
help…

#include <sys/socket.h>
#include <sys/uio.h>
#include <unistd.h>
#include <net/route.h>
#include <net/if_dl.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <libgen.h>
#include <arpa/inet.h>
#include <process.h>
#include <errno.h>

struct my_rt_t {
struct rt_msghdr rtm;
struct sockaddr_in dst;
struct sockaddr_in gw;
struct sockaddr_in ifa;
struct sockaddr_dl ifp;
};

int main() {
struct my_rt_t my_rt;
struct rt_msghdr *rtm;
struct sockaddr_in *dst, *ifa, *gw;
struct sockaddr_dl *ifp;
int s;

if ((s=socket(AF_ROUTE, SOCK_RAW, 0)) == -1) {
printf(“error on socket”);
return 0;
}

memset(&my_rt, 0x0, sizeof(my_rt));
rtm = &(my_rt.rtm);
dst = &(my_rt.dst);
ifp = &(my_rt.ifp);
gw = &(my_rt.gw);

dst->sin_len = sizeof(*dst);
dst->sin_family = AF_INET;
dst->sin_addr.s_addr = inet_addr(“19.19.19.15”);

ifa->sin_len = sizeof(*ifa);
ifa->sin_family = AF_INET;

ifp->sdl_len = sizeof(*ifp);
ifp->sdl_family = AF_INET;


rtm->rtm_type = RTM_GET;
rtm->rtm_flags |= RTF_UP;
rtm->rtm_msglen = sizeof(my_rt);
rtm->rtm_version = RTM_VERSION;
rtm->rtm_seq = 1234;
rtm->rtm_addrs = RTA_DST| RTA_IFP|RTA_IFA;
rtm->rtm_pid = getpid();
if (write(s, rtm, rtm->rtm_msglen) < 0) {
printf(“error on write : %s”, strerror(errno));
return 0;
}

/* Read back the response */
if(read(s, rtm, rtm->rtm_msglen) == -1) {
printf(“error on write : %s”, strerror(errno));
return 1;
}

printf(“gateway is : %s\n”, inet_ntoa(gw->sin_addr));
printf(“interface is: %s\n”, ifp->sdl_data);
printf(“if address is: %s\n”, inet_ntoa(ifa->sin_addr));
return 0;

}


Sean Boudreau wrote:

The best way to do this for the full stack is to use a routing
socket directly from C. See the thread entitled “Reading routing
entries” in this group for an example.

-seanb

Beth <> id@address.com> > wrote:

This is not going work since I don’t know what version of QNX my program will run. I use
the “route get” command to get interface name and gateway address for a giving ip
address. For Tiny TCP, I parse the /proc/ipstat file to get these information. What I
should really ask is how to get interface name, and gateway address of a giving ip
address programmatically? That will take care both tiny and full TCPIP.

Appreciate any help.

-Beth

Sean Boudreau wrote:

If you copy the route utility from 6.2.1 it “should” work.

-seanb

Beth <> id@address.com> > wrote:
We have verified that the “route get” command works on QNX6.1 and QNX 6.2.1. But it
didn’t work on QNX 6.2.
How can we get this supported on QNX 6.2?

-Beth

Bill Caroselli wrote:

Beth <> id@address.com> > wrote:
B > It’s documented in 6.1 and it works in 6.1. But it’s not documented in 6.2 and
B > I am
B > running 6.2 ( not 6.2.1), it’s not working in 6.2.
B > Maybe it’s added back to 6.2.1. Any one can verify this?

I’m running 6.21. It works for me.

/root>route get qnx.com
route to: qnx.com
destination: default
mask: default
gateway: 192.168.2.5
local addr: poly-rtp.qat
interface: en0
flags: <UP,GATEWAY,DONE
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1500 0

Yes, routing sockets are only supported by the full stack.
If the socket() calls fails, you are probably running
under the tiny stack or no stack. If under the tiny stack,
the only way to get the current routes is via /proc/ipstats
as you are currently doing.

-seanb



Beth <id@address.com> wrote:

Sean, Thanks for your help. I have tried the sample you suggested. I works on getting the
default route for full tcp stack, but not on tiny tcp. Is there any way that I can write the
code so that it can be used for both tiny and full tcp?
Secondly, I am having difficulty on getting the information that I need using the following
code. I want to get an interface name and gateway address for an given ip address. Please
help…

#include <sys/socket.h
#include <sys/uio.h
#include <unistd.h
#include <net/route.h
#include <net/if_dl.h
#include <netinet/in.h
#include <netdb.h
#include <stdio.h
#include <libgen.h
#include <arpa/inet.h
#include <process.h
#include <errno.h

struct my_rt_t {
struct rt_msghdr rtm;
struct sockaddr_in dst;
struct sockaddr_in gw;
struct sockaddr_in ifa;
struct sockaddr_dl ifp;
};

int main() {
struct my_rt_t my_rt;
struct rt_msghdr *rtm;
struct sockaddr_in *dst, *ifa, *gw;
struct sockaddr_dl *ifp;
int s;

if ((s=socket(AF_ROUTE, SOCK_RAW, 0)) == -1) {
printf(“error on socket”);
return 0;
}

memset(&my_rt, 0x0, sizeof(my_rt));
rtm = &(my_rt.rtm);
dst = &(my_rt.dst);
ifp = &(my_rt.ifp);
gw = &(my_rt.gw);

dst->sin_len = sizeof(*dst);
dst->sin_family = AF_INET;
dst->sin_addr.s_addr = inet_addr(“19.19.19.15”);

ifa->sin_len = sizeof(*ifa);
ifa->sin_family = AF_INET;

ifp->sdl_len = sizeof(*ifp);
ifp->sdl_family = AF_INET;



rtm->rtm_type = RTM_GET;
rtm->rtm_flags |= RTF_UP;
rtm->rtm_msglen = sizeof(my_rt);
rtm->rtm_version = RTM_VERSION;
rtm->rtm_seq = 1234;
rtm->rtm_addrs = RTA_DST| RTA_IFP|RTA_IFA;
rtm->rtm_pid = getpid();
if (write(s, rtm, rtm->rtm_msglen) < 0) {
printf(“error on write : %s”, strerror(errno));
return 0;
}

/* Read back the response */
if(read(s, rtm, rtm->rtm_msglen) == -1) {
printf(“error on write : %s”, strerror(errno));
return 1;
}

printf(“gateway is : %s\n”, inet_ntoa(gw->sin_addr));
printf(“interface is: %s\n”, ifp->sdl_data);
printf(“if address is: %s\n”, inet_ntoa(ifa->sin_addr));
return 0;

}



Sean Boudreau wrote:

The best way to do this for the full stack is to use a routing
socket directly from C. See the thread entitled “Reading routing
entries” in this group for an example.

-seanb

Beth <> id@address.com> > wrote:

This is not going work since I don’t know what version of QNX my program will run. I use
the “route get” command to get interface name and gateway address for a giving ip
address. For Tiny TCP, I parse the /proc/ipstat file to get these information. What I
should really ask is how to get interface name, and gateway address of a giving ip
address programmatically? That will take care both tiny and full TCPIP.

Appreciate any help.

-Beth

Sean Boudreau wrote:

If you copy the route utility from 6.2.1 it “should” work.

-seanb

Beth <> id@address.com> > wrote:
We have verified that the “route get” command works on QNX6.1 and QNX 6.2.1. But it
didn’t work on QNX 6.2.
How can we get this supported on QNX 6.2?

-Beth

Bill Caroselli wrote:

Beth <> id@address.com> > wrote:
B > It’s documented in 6.1 and it works in 6.1. But it’s not documented in 6.2 and
B > I am
B > running 6.2 ( not 6.2.1), it’s not working in 6.2.
B > Maybe it’s added back to 6.2.1. Any one can verify this?

I’m running 6.21. It works for me.

/root>route get qnx.com
route to: qnx.com
destination: default
mask: default
gateway: 192.168.2.5
local addr: poly-rtp.qat
interface: en0
flags: <UP,GATEWAY,DONE
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1500 0

Thanks for your help. Any idea why the code is not working on getting the information?

-Beth



Sean Boudreau wrote:

Yes, routing sockets are only supported by the full stack.
If the socket() calls fails, you are probably running
under the tiny stack or no stack. If under the tiny stack,
the only way to get the current routes is via /proc/ipstats
as you are currently doing.

-seanb

Beth <> id@address.com> > wrote:
Sean, Thanks for your help. I have tried the sample you suggested. I works on getting the
default route for full tcp stack, but not on tiny tcp. Is there any way that I can write the
code so that it can be used for both tiny and full tcp?
Secondly, I am having difficulty on getting the information that I need using the following
code. I want to get an interface name and gateway address for an given ip address. Please
help…

#include <sys/socket.h
#include <sys/uio.h
#include <unistd.h
#include <net/route.h
#include <net/if_dl.h
#include <netinet/in.h
#include <netdb.h
#include <stdio.h
#include <libgen.h
#include <arpa/inet.h
#include <process.h
#include <errno.h

struct my_rt_t {
struct rt_msghdr rtm;
struct sockaddr_in dst;
struct sockaddr_in gw;
struct sockaddr_in ifa;
struct sockaddr_dl ifp;
};

int main() {
struct my_rt_t my_rt;
struct rt_msghdr *rtm;
struct sockaddr_in *dst, *ifa, *gw;
struct sockaddr_dl *ifp;
int s;

if ((s=socket(AF_ROUTE, SOCK_RAW, 0)) == -1) {
printf(“error on socket”);
return 0;
}

memset(&my_rt, 0x0, sizeof(my_rt));
rtm = &(my_rt.rtm);
dst = &(my_rt.dst);
ifp = &(my_rt.ifp);
gw = &(my_rt.gw);

dst->sin_len = sizeof(*dst);
dst->sin_family = AF_INET;
dst->sin_addr.s_addr = inet_addr(“19.19.19.15”);

ifa->sin_len = sizeof(*ifa);
ifa->sin_family = AF_INET;

ifp->sdl_len = sizeof(*ifp);
ifp->sdl_family = AF_INET;

rtm->rtm_type = RTM_GET;
rtm->rtm_flags |= RTF_UP;
rtm->rtm_msglen = sizeof(my_rt);
rtm->rtm_version = RTM_VERSION;
rtm->rtm_seq = 1234;
rtm->rtm_addrs = RTA_DST| RTA_IFP|RTA_IFA;
rtm->rtm_pid = getpid();
if (write(s, rtm, rtm->rtm_msglen) < 0) {
printf(“error on write : %s”, strerror(errno));
return 0;
}

/* Read back the response */
if(read(s, rtm, rtm->rtm_msglen) == -1) {
printf(“error on write : %s”, strerror(errno));
return 1;
}

printf(“gateway is : %s\n”, inet_ntoa(gw->sin_addr));
printf(“interface is: %s\n”, ifp->sdl_data);
printf(“if address is: %s\n”, inet_ntoa(ifa->sin_addr));
return 0;

}

Sean Boudreau wrote:

The best way to do this for the full stack is to use a routing
socket directly from C. See the thread entitled “Reading routing
entries” in this group for an example.

-seanb

Beth <> id@address.com> > wrote:

This is not going work since I don’t know what version of QNX my program will run. I use
the “route get” command to get interface name and gateway address for a giving ip
address. For Tiny TCP, I parse the /proc/ipstat file to get these information. What I
should really ask is how to get interface name, and gateway address of a giving ip
address programmatically? That will take care both tiny and full TCPIP.

Appreciate any help.

-Beth

Sean Boudreau wrote:

If you copy the route utility from 6.2.1 it “should” work.

-seanb

Beth <> id@address.com> > wrote:
We have verified that the “route get” command works on QNX6.1 and QNX 6.2.1. But it
didn’t work on QNX 6.2.
How can we get this supported on QNX 6.2?

-Beth

Bill Caroselli wrote:

Beth <> id@address.com> > wrote:
B > It’s documented in 6.1 and it works in 6.1. But it’s not documented in 6.2 and
B > I am
B > running 6.2 ( not 6.2.1), it’s not working in 6.2.
B > Maybe it’s added back to 6.2.1. Any one can verify this?

I’m running 6.21. It works for me.

/root>route get qnx.com
route to: qnx.com
destination: default
mask: default
gateway: 192.168.2.5
local addr: poly-rtp.qat
interface: en0
flags: <UP,GATEWAY,DONE
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1500 0