public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Unable to add route using routing socket
@ 2006-12-20 10:42 aditya veer singh
  0 siblings, 0 replies; only message in thread
From: aditya veer singh @ 2006-12-20 10:42 UTC (permalink / raw)
  To: ecos-discuss

Hi,

I am using ecos taken from CVS branch of FEB 2006.
I want to add a route to BSD TCP/IP stacks IP route table 
using routing sockets.
I have written the below code:

	u_int32_t g,m,d;
	int routes;
	struct{
		struct rt_msghdr	hdr;
		struct sockaddr_in	dst;
		struct sockaddr_in	gway;
		struct sockaddr_in	mask;
	}rtmsg;

	if((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET) < 0)){
		diag_printf("\nError route socket");
	}

	memset(&rtmsg, 0, sizeof(rtmsg));

	rtmsg.hdr.rtm_msglen = sizeof(rtmsg);
	rtmsg.hdr.rtm_version = RTM_VERSION;
	rtmsg.hdr.rtm_type = RTM_ADD;
	rtmsg.hdr.rtm_addrs = RTA_DST|RTA_GATEWAY|RTA_NETMASK;
	rtmsg.hdr.rtm_flags = RTF_UP|RTF_HOST|RTF_STATIC;
		
	rtmsg.dst.sin_len = sizeof(rtmsg.dst);
	rtmsg.dst.sin_family = AF_INET;
	inet_pton(AF_INET, "192.168.9.55",(char *)&rtmsg.dst.sin_addr);

	rtmsg.gway.sin_len = sizeof(rtmsg.gway);
	rtmsg.gway.sin_family = AF_INET;
	inet_pton(AF_INET, "192.168.7.43",(char *)&rtmsg.gway.sin_addr);

	rtmsg.mask.sin_len = sizeof(rtmsg.mask);
	rtmsg.mask.sin_family = AF_INET;
	inet_pton(AF_INET, "255.255.255.255",(char *)&rtmsg.mask.sin_addr);

	if(write (routes, &rtmsg, sizeof(rtmsg)) < 0){
		perror("write");
	}

On executing it I get error in write "Bad file handle".
What needs to be done correct it?

Regards,
Aditya


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-12-20 10:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-20 10:42 [ECOS] Unable to add route using routing socket aditya veer singh

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).