From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21272 invoked by alias); 5 Nov 2003 16:00:34 -0000 Mailing-List: contact ecos-discuss-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@sources.redhat.com Received: (qmail 21263 invoked from network); 5 Nov 2003 16:00:33 -0000 Received: from unknown (HELO melelios.dmz.elios-informatique.fr) (194.250.150.132) by sources.redhat.com with SMTP; 5 Nov 2003 16:00:33 -0000 Received: from ECoSyst3m3 ([192.168.8.253]) by melelios.dmz.elios-informatique.fr with Microsoft SMTPSVC(5.0.2195.5329); Wed, 5 Nov 2003 17:06:58 +0100 Received: from ecos by ECoSyst3m3 with local (Exim 3.35 #1 (Debian)) id 1AHR1q-0002Wa-00 for ; Wed, 05 Nov 2003 18:01:10 +0100 To: ecos-discuss@sources.redhat.com Message-Id: From: Sebastien Couret Date: Wed, 05 Nov 2003 16:00:00 -0000 X-OriginalArrivalTime: 05 Nov 2003 16:06:59.0156 (UTC) FILETIME=[D782E140:01C3A3B6] Subject: [ECOS] How to print IP routing table with eCOS ? X-SW-Source: 2003-11/txt/msg00055.txt.bz2 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