Date: Fri, 31 Aug 2001 15:01:39 +0300 From: Ruslan Ermilov <ru@FreeBSD.ORG> To: Anuranjan <anu@nttmcl.com> Cc: questions@FreeBSD.ORG Subject: Re: why wouldn't this code work :( Message-ID: <20010831150139.B60910@sunbay.com> In-Reply-To: <002001c13198$56e8c550$f64545d8@ntt27f48otgmw8>; from anu@nttmcl.com on Thu, Aug 30, 2001 at 02:11:29PM -0700 References: <002001c13198$56e8c550$f64545d8@ntt27f48otgmw8>
next in thread | previous in thread | raw e-mail | index | archive | help
These questions are better answered on freebsd-net. BSD dropped support for these route(4) ioctl's yet in 1993. The error is generated by rtioctl() in sys/net/route.c. On Thu, Aug 30, 2001 at 02:11:29PM -0700, Anuranjan wrote: > Hi, > Following is an attempt to add an entry into the kernel routing table using > ioctl ..... it give errno = EOPNOTSUPP. I understand that this means there's > some problem in the rtentry parameter I'm passing to ioctl ... but for the > world of me I can't understand how to make this work!!! Help greatly > appreciated.......... > --A > > ---------------------------------------------------------------------------- > ---------------------------------------------------------------------------- > ---------------- > > > add_entry(char *srcIPaddr) > { > int err; > struct rtentry *rt; > struct sockaddr_in *s; > int sockfd; > > struct sockaddr_in gway; > > srcIPaddr = "4.5.6.7"; > > memset(&gway, 0, sizeof(struct sockaddr_in)); > gway.sin_family = AF_INET; > gway.sin_addr.s_addr = inet_addr("2.3.4.1"); > > s->sin_len = sizeof(struct sockaddr_in); > s->sin_family = AF_INET; > s->sin_addr.s_addr = inet_addr(srcIPaddr); > > rt = (struct rtentry*)malloc(sizeof(struct rtentry)); > memset(rt, 0, (sizeof(struct rtentry))); > rt->rt_flags |= RTF_HOST; > > rt->rt_gateway = (struct sockaddr *)&gway; > rt->rt_flags |= RTF_UP | RTF_GATEWAY; > rt->rt_use = 0; > > rt_key(rt) = (struct sockaddr*)s; > > fwd_enable(1); > > sockfd = socket(AF_INET, SOCK_DGRAM, 0); > > if( ioctl(sockfd, SIOCADDRT, rt) < 0) > { > if (errno != EINVAL) > { > printf ("ioctl error :%d\n", errno); > } > } > } -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010831150139.B60910>