From owner-freebsd-questions Fri Aug 31 5: 3:10 2001 Delivered-To: freebsd-questions@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 502C237B403 for ; Fri, 31 Aug 2001 05:02:58 -0700 (PDT) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.2/8.11.2) id f7VC1dd66303; Fri, 31 Aug 2001 15:01:39 +0300 (EEST) (envelope-from ru) Date: Fri, 31 Aug 2001 15:01:39 +0300 From: Ruslan Ermilov To: Anuranjan Cc: questions@FreeBSD.ORG Subject: Re: why wouldn't this code work :( Message-ID: <20010831150139.B60910@sunbay.com> References: <002001c13198$56e8c550$f64545d8@ntt27f48otgmw8> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <002001c13198$56e8c550$f64545d8@ntt27f48otgmw8>; from anu@nttmcl.com on Thu, Aug 30, 2001 at 02:11:29PM -0700 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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