From owner-freebsd-questions Thu Aug 30 14:14:38 2001 Delivered-To: freebsd-questions@freebsd.org Received: from alicia.nttmcl.com (alicia.nttmcl.com [216.69.69.10]) by hub.freebsd.org (Postfix) with ESMTP id 51C7837B406 for ; Thu, 30 Aug 2001 14:14:22 -0700 (PDT) (envelope-from anu@nttmcl.com) Received: from ntt27f48otgmw8 (dhcp246.nttmcl.com [216.69.69.246]) by alicia.nttmcl.com (8.10.1/8.10.1) with SMTP id f7ULBhv10199 for ; Thu, 30 Aug 2001 14:11:43 -0700 (PDT) Reply-To: From: "Anuranjan" To: Subject: why wouldn't this code work :( Date: Thu, 30 Aug 2001 14:11:29 -0700 Message-ID: <002001c13198$56e8c550$f64545d8@ntt27f48otgmw8> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal 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 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); } } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message