From owner-freebsd-net@FreeBSD.ORG Thu Jun 5 16:05:27 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 7C27E37B404 for ; Thu, 5 Jun 2003 16:05:27 -0700 (PDT) Received: from handler11.mail.rice.edu (handler11.mail.rice.edu [128.42.58.211]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8223143FA3 for ; Thu, 5 Jun 2003 16:05:26 -0700 (PDT) (envelope-from takhoa@rice.edu) Received: from localhost (localhost [127.0.0.1]) by handler11.mail.rice.edu (Postfix) with SMTP id 07BBD1DBC6 for ; Thu, 5 Jun 2003 18:05:26 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by handler11.mail.rice.edu (Postfix) with ESMTP id C9DE91DBC4 for ; Thu, 5 Jun 2003 18:05:25 -0500 (CDT) Received: from ece4 (ece-4.ece.rice.edu [128.42.4.36]) by handler11.mail.rice.edu (Postfix) with SMTP id DD87C1DBC1 for ; Thu, 5 Jun 2003 18:05:24 -0500 (CDT) From: "Khoa To" To: Date: Thu, 5 Jun 2003 18:10:45 -0500 Message-ID: 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 IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Virus-Scanned: by AMaViS snapshot-20020300 X-DCC--Metrics: handler11.mail.rice.edu 1066; Body=1 Fuz1=1 Fuz2=1 Subject: netgraph hook for iface node 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: Thu, 05 Jun 2003 23:05:27 -0000 Hello, I need to implement a routing protocol on top of IP (i.e. the packet is encapsulated within an IP packet). I'm new to network programming, and from searching the web, it looks like netgraph can help me a lot. But I have some problems with applying netgraph to my implementation, and I am wondering if someone can help me or give me some pointers. (I would like to implement the code in user space as much as possible) I think I should use an iface node if I want to get an IP packet. I tried and successfully get IP packets printed out on the console when I: - Configure the iface node with the command "ifconfig ng0 1.1.1.1 2.2.2.2" - Used "nghook -a ng0: inet" to connect to the inet hook from the user space - Ping 2.2.2.2 But how do I connect this iface node to the regular ethernet interface so that I can capture IP packets coming from the wire to my regular ethernet card? I can get raw ethernet packets by hooking to the "lower" hook of eth0, but I want the Ethernet codes to do the parsing for me and give me a clean IP packet. I tried to connect the upper hook of eth0 to the inet hook (it probably the wrong way to do it anyway), but I couldn't because I already connected the inet hook to my user level program via nghook. Also, on the way down (i.e. from the application layer), after I assemble my protocol-specific packet, is there a hook in netgraph that I can pass the packet to that would do all the IP encapsulation and generate checksums, etc. and send it down to the network interface for transmission? (Or what type of node that I should create that would allow me to do that?) I really appreciate any hints/help that you guys can provide. Thank you very much, Khoa.