Operating System - OpenVMS
1753277 Members
4953 Online
108792 Solutions
New Discussion

Re: Using ioctl() to add an entry to TCPIP routing table

 
Brian Lindauer
Occasional Contributor

Using ioctl() to add an entry to TCPIP routing table

Is anyone familiar with using ioctl() in C to add or delete an entry in the TCPIP routing table? I have the call set as follows:

status = ioctl( sock_id, SIOCADDRT, &rt_entry)

rt_entry is a structure I found in TCPIP$EXAMPLES. I am not sure if it is the correct structure to use since I did not find it anywhere else defined. When I call the ioctl() function I get "Invalid argument". Could someone please tell me what the correct format of the structure is suppose to be. Also is there a way to specify the network mask for the routing IP address in the ioctl function?
1 REPLY 1
Jim_McKinney
Honored Contributor

Re: Using ioctl() to add an entry to TCPIP routing table

I've not had occasion to have to add an entry to the routing table but it appears that your rt_entry structure should look like the rtentry structure in SYS$COMMON:[SYSHLP.EXAMPLES.TCPIP.LIBPCAP]ROUTE.H. The mask is defined by rt_mask field within this structure.

struct rtentry {
struct radix_node rt_nodes[2]; /* tree glue, and other values */
#define rt_key(r) ((struct sockaddr *)((r)->rt_nodes->rn_key))
#define rt_mask(r) ((struct sockaddr *)((r)->rt_nodes->rn_mask))
struct sockaddr *rt_gateway; /* value */
int rt_flags; /* up/down?, host/net */
int rt_refcnt; /* # held references */
u_long rt_use; /* raw # packets forwarded */
struct ifnet *rt_ifp; /* the answer: interface to use */
struct ifaddr *rt_ifa; /* the answer: interface to use */
struct sockaddr *rt_genmask; /* for generation of cloned routes */
caddr_t rt_llinfo; /* pointer to link level info cache */
struct rt_metrics rt_rmx; /* metrics used by rx'ing protocols */
short rt_idle; /* easy to tell llayer still live */
short rt_aliasid; /* cluster aliasid id of dst */
u_int rt_precedence; /* precedence */
#if SEC_NET
struct tnrh_rem_host *rt_host; /* Remote host structure. */
#endif
struct rtentry *rt_gwroute; /* entry for gateway route */
struct mip6_binding_cache *rt_mip6cache;/* ptr to Mobile IPv6 binding */
u_long rt_reserved[5]; /* reserved for future use */
};