* [ECOS] How to print IP routing table with eCOS ?
@ 2003-11-05 16:00 Sebastien Couret
2003-11-08 14:42 ` Andrew Lunn
0 siblings, 1 reply; 2+ messages in thread
From: Sebastien Couret @ 2003-11-05 16:00 UTC (permalink / raw)
To: ecos-discuss
Hello,
I.m trying to get the routing tables from the FreeBSD IP stack ported to eCOS.
The API show_network_tables() just stall my software and display nothing.
I.ve tried by the use of the sysctl() API (option checked in FreeBSD configuration) whith the following code :
int GetRoutes(void)
{
int mib[6];
size_t needed=0;
char *buf = NULL;
char *next=NULL;
char *lim = NULL;
struct sockaddr *sa=NULL;
struct rt_msghdr *rtm=NULL;
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
mib[2] = 0;
mib[3] = 0;
mib[4] = NET_RT_DUMP;
mib[5] = 0;
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
LOG(LOG_ERR,"Route sysctl");
return(-1);
}
LOG(LOG_INFO,.Free space needed : %d\n",needed);
if (needed > 0)
{
if ((buf = malloc(needed)) == 0)
{
LOG(LOG_ERR,"out of space (%i octets)\n",needed);
return(-1);
}
if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
{
LOG(LOG_ERR,"sysctl of routing table");
return(-1);
}
lim = buf + needed;
} // fin du if needed
LOG(LOG_INFO,"Routing tables\n");
if (buf)
{
LOG(LOG_INFO,"Here comes the routing table\n");
for (next = buf; next < lim; next += rtm->rtm_msglen)
{
rtm = (struct rt_msghdr *)next;
sa = (struct sockaddr *)(rtm + 1);
if (sa->sa_family != AF_INET)
continue;
LOG(LOG_INFO,"Here.s one route\n");
//p_rtentry(rtm);
} free(buf);
}
return(0);
}
This doesn.t work because sysctl always set needed to 0 even if routes have been added to the routing tables.
Someone got a clue ?
Thanks for your help.
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [ECOS] How to print IP routing table with eCOS ?
2003-11-05 16:00 [ECOS] How to print IP routing table with eCOS ? Sebastien Couret
@ 2003-11-08 14:42 ` Andrew Lunn
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2003-11-08 14:42 UTC (permalink / raw)
To: Sebastien Couret; +Cc: ecos-discuss
On Wed, Nov 05, 2003 at 06:01:10PM +0100, Sebastien Couret wrote:
> Hello,
>
> I.m trying to get the routing tables from the FreeBSD IP stack ported to eCOS.
>
> The API show_network_tables() just stall my software and display nothing.
It does work. Here is a run on the synthetic target which calls both
show_network_tables() and then uses your sysclt code (plus the bug fix
i just committed).
Routing tables
Destination Gateway Mask Flags Interface
127.0.0.0 127.0.0.1 255.0.0.0 UG lo0
192.168.10.0 192.168.10.0 255.255.255.0 U eth0
Interface statistics
eth0 IP: 192.168.10.10, Broadcast: 192.168.10.255, Netmask: 255.255.255.0
UP BROADCAST RUNNING MULTICAST ALLMULTI MTU: 1500, Metric: 0
Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0
lo0 IP: 127.0.0.1, Broadcast: 127.0.0.1, Netmask: 255.0.0.0
UP LOOPBACK RUNNING MULTICAST MTU: 16384, Metric: 0
Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0
Free space needed : 508
Routing tables
Here comes the routing table
Here.s one route
Here.s one route
Here.s one route
Andrew
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-11-08 14:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-05 16:00 [ECOS] How to print IP routing table with eCOS ? Sebastien Couret
2003-11-08 14:42 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).