From owner-freebsd-net@FreeBSD.ORG Fri Aug 29 11:06:40 2003 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7348E16A4BF for ; Fri, 29 Aug 2003 11:06:40 -0700 (PDT) Received: from hysteria.spc.org (hysteria.spc.org [195.206.69.234]) by mx1.FreeBSD.org (Postfix) with SMTP id ED50844057 for ; Fri, 29 Aug 2003 11:05:18 -0700 (PDT) (envelope-from bms@hysteria.spc.org) Received: (qmail 25502 invoked by uid 5013); 29 Aug 2003 18:02:06 -0000 Date: Fri, 29 Aug 2003 19:02:06 +0100 From: Bruce M Simpson To: "Khoa A. To" Message-ID: <20030829180206.GK1417@spc.org> Mail-Followup-To: Bruce M Simpson , "Khoa A. To" , FreeBSD_Net References: <20030829154401.GA417@newluxor.skynet.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i Organization: SPC cc: FreeBSD_Net Subject: Re: Reversed MAC lookup inside FreeBSD kernel? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2003 18:06:40 -0000 On Fri, Aug 29, 2003 at 11:17:16AM -0500, Khoa A. To wrote: > I need to get a translation of MAC addresses to IP addresses in the kernel. > I saw some postings about how to translate MAC to IP in the user level, but > they seem to require the host to send a packet to that MAC address and some > other ways that also require the host to actually send some request packets > out. All my MAC-IP addresses are already set statically using "arp -s" in > the ARP table. When I'm in the kernel, how do I get a hold of the ARP table > and do some kind of reversed search to get the IP address out? ARP information is held in the routing table. Look at the output of netstat -arn and look for routes containing the L flag (LLINFO). If you need to walk through the routing table, look at how rtalloc() does it. 'struct rtentry' should be pretty self explanatory... BMS