From owner-freebsd-net Sun Aug 13 20: 1:28 2000 Delivered-To: freebsd-net@freebsd.org Received: from mailserv.waikato.ac.nz (mailserv.waikato.ac.nz [130.217.66.61]) by hub.freebsd.org (Postfix) with ESMTP id 6FE4D37B991 for ; Sun, 13 Aug 2000 20:01:24 -0700 (PDT) (envelope-from mjl12@waikato.ac.nz) Received: from stu_ex2.waikato.ac.nz (stu-ex2.waikato.ac.nz [130.217.70.20]) by mailserv.waikato.ac.nz (8.9.3/8.9.0) with ESMTP id PAA39652 for ; Mon, 14 Aug 2000 15:05:31 +1200 Received: by stu-ex2.waikato.ac.nz with Internet Mail Service (5.5.2650.21) id <23A4WV36>; Mon, 14 Aug 2000 14:56:40 +1200 Message-ID: <45E87454FFC2D211AD9800508B65009420F8E8@stu-ex1.waikato.ac.nz> From: "MATTHEW JOHN,LUCKIE" To: freebsd-net@freebsd.org Subject: determing ip->ip_src Date: Mon, 14 Aug 2000 15:01:06 +1200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Hi there I am writing some code that records the source address of the packet in the data segment of the ip packet. This code is part of a kernel module loaded via syscall How do i deduce what source address to record in the data area of the packet as i want to before it is sent to ip_output? I realise that ip_output will sort ip_src out for me, but i want to know this value ahead of calling ip_output() I have tried the following code, based on what happens in ip_output when a packet with no source address is passed to it and the destination address is not a multicast address, but it does not get me any further as the second test for ro.ro_rt fails. Even if it didnt fail, i dont think the following fragment would be any good, given that i do not take any account of the destination address. What should I be doing? Is there a higher level function available for me to all that will return the value? Thanks Matthew ------------- u_int32_t getoutif() { struct in_addr in_addr; struct in_ifaddr *ia; struct route ro; bzero(&ro, sizeof ro); if(ro.ro_rt == 0) { rtalloc_ign(&ro, RTF_PRCLONING); } if(ro.ro_rt == 0) { printf("INADDR_ANY"); return INADDR_ANY; } ia = ifatoia(ro.ro_rt->rt_ifa); ro.ro_rt->rt_use++; in_addr = IA_SIN(ia)->sin_addr; RTFREE(ro.ro_rt); print_ip(in_addr); return in_addr.s_addr; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message