From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 12 22:26:11 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 66A2E106566C for ; Mon, 12 Jul 2010 22:26:11 +0000 (UTC) (envelope-from spawk@acm.poly.edu) Received: from acm.poly.edu (acm.poly.edu [128.238.9.200]) by mx1.freebsd.org (Postfix) with ESMTP id 08A3A8FC0C for ; Mon, 12 Jul 2010 22:26:09 +0000 (UTC) Received: (qmail 11480 invoked from network); 12 Jul 2010 22:26:08 -0000 Received: from unknown (HELO ?10.0.0.174?) (spawk@128.238.64.31) by acm.poly.edu with AES256-SHA encrypted SMTP; 12 Jul 2010 22:26:08 -0000 Message-ID: <4C3B9682.2040309@acm.poly.edu> Date: Mon, 12 Jul 2010 18:26:10 -0400 From: Boris Kochergin User-Agent: Thunderbird 2.0.0.24 (X11/20100530) MIME-Version: 1.0 To: Bartosz Marcin Kojak References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: inet_* functions in kernel? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jul 2010 22:26:11 -0000 Bartosz Marcin Kojak wrote: > > Hi. > > Currently I'm writing a kernel module using MAC Framework to control > binding to local IP addresses (kind of mac_portacl variation) and I > need some advice. > > I want to be able to write rules for module through sysctl (rule will > contain IP addresses in human-readable format, e.g. > "uid:1002:192.168.2.3") and I'm wondering how to translate addresses > to network byte order without inet_* functions. Well, they look like > they're available to use in kernel (using ) but it's no > able to compile module with inet_* functions using typical Makefile > (this one with ".include " line) - it just produces > warnings, and all warnings are treated as errors in this case. > > So, possible solutions are: just add custom CFLAGS without "-Werror" > to Makefile (but it's quite ugly though) or write an userspace > application that will write an addresses in NBO to sysctl (but now > sysctl won't be easy to read and modify by hand). > > What do you think? > > Thanks in advance for any useful hints. > Check out the byteorder(9) man page. -Boris