Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Accessiing routing information

Posted on 1998-07-21
7
Medium Priority
?
308 Views
Last Modified: 2010-04-21
I have to access the routing information in my program. The file route.h contains the hashed linked list structure as defined in most of the books. But on my Unixware 1.14 version, the structure doesn't contain the "rt_next" member which points to the next routing entry. If this is the case how can you know the exact structure in the system for the routing tables. Where do I get information for this(manuals, header files etc)
0
Comment
Question by:vividh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 2

Expert Comment

by:JYoungman
ID: 2009121
You are almost certainly better off parsing the output of
"netstat -r".

0
 
LVL 2

Accepted Solution

by:
seedy earned 800 total points
ID: 2009122
> The file route.h contains the hashed linked list structure
Which structure are you referring to?  I am familiar with UnixWare 2.1.

On 2.1 you would use ioctl(SIOCGRTTAB)call on /dev/ip to retrieve the routing information.  The info will be retunred in an array of struct rtrecord.  SIOCGRTSIZ can be used to get the number of route entries.

Check on the sockio.h for the #defines for the above calls.  If they are present, they should work on 1.1x too.

BTW, you should be previllaged to read this info.
0
 
LVL 2

Expert Comment

by:seedy
ID: 2009123
Let me know if you need a code segment that shows how this is done.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:vividh
ID: 2009124
Seedy can you send me the code segment which will extract me the routing tables from the kernel.
0
 
LVL 2

Expert Comment

by:seedy
ID: 2009125
Here you go!

--- code segment start ---
int     fd, iRet;
struct  strioctl ioc;
struct  rtrecord *rtent;
int     iEntries;
int     ii;

if ((fd = open("/dev/ip", O_RDONLY)) < 0) {
        return(-1);
}

/* First find how many entries are in the routing table */
ioc.ic_cmd = SIOCGRTSIZ;
ioc.ic_timout = 0;
ioc.ic_len = 0;
ioc.ic_dp = (caddr_t) NULL ;
if ((iEntries = ioctl(fd, I_STR, (caddr_t) &ioc)) < 0) {
        return(-1);
}

/* Make space for as many entries */
rtent = (struct rtrecord *) malloc(sizeof(struct rtrecord) * iEntries);
if ( rtent == NULL ) {
        return(-1);  
}

/* Get the entries */
ioc.ic_cmd = SIOCGRTTAB;
ioc.ic_timout = 0;
ioc.ic_len = sizeof(struct rtrecord) * iEntries;
ioc.ic_dp = (caddr_t) rtent ;
if ((iRet = ioctl(fd, I_STR, (caddr_t) &ioc)) < 0) {
        return(-1);
}

/* Entries are in rtent ; loop over each entry and do what you want */
for ( ii = 0; ii < iEntries; ii++) {
        /*******   ADD YOUR CODE HERE *****/
        rtent++;
}

--- code segment end ---
0
 

Author Comment

by:vividh
ID: 2009126
The SIOCGRTSIZ defination is not available in Unixware 1.1.2/1.1.4. With 2.1 it is perfect but my limitation is that I am currently working on 1.1.2/1.1.4. If you have worked on these pls help me so.

0
 
LVL 2

Expert Comment

by:seedy
ID: 2009127
I am sorry, as I said already, I am familiar only with 2.1.  And I do not have a 1.x around here to look into.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question