From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 14 07:44:46 2009 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 BF1091065690 for ; Fri, 14 Aug 2009 07:44:46 +0000 (UTC) (envelope-from max@love2party.net) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.171]) by mx1.freebsd.org (Postfix) with ESMTP id 54B318FC62 for ; Fri, 14 Aug 2009 07:44:46 +0000 (UTC) Received: from vampire.homelinux.org (dslb-088-067-247-105.pools.arcor-ip.net [88.67.247.105]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0MKv5w-1MbrSv0LJa-0003r5; Fri, 14 Aug 2009 09:44:45 +0200 Received: (qmail 99277 invoked from network); 14 Aug 2009 07:44:44 -0000 Received: from kvm.laiers.local (HELO kvm.localnet) (192.168.4.200) by laiers.local with SMTP; 14 Aug 2009 07:44:44 -0000 From: Max Laier Organization: FreeBSD To: freebsd-hackers@freebsd.org Date: Fri, 14 Aug 2009 09:44:43 +0200 User-Agent: KMail/1.12.0 (Linux/2.6.30-ARCH; KDE/4.3.0; x86_64; ; ) References: <9527461a0908132029xb2c6149r9f51c775d22ae670@mail.gmail.com> In-Reply-To: <9527461a0908132029xb2c6149r9f51c775d22ae670@mail.gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200908140944.44141.max@love2party.net> X-Provags-ID: V01U2FsdGVkX182iKNFkxtJdqFv70nCiF8kVY4srlhLKKZ23ft 8EXTOF5YyeTW+l0/MKCrXr/Za1XyFjEPmun0zwqXStrIyrw00e PHdCoa4jztIXQRkmQJelg== Cc: bert wiley Subject: Re: Need help trying to to use the ntohl() call with in_addr 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: Fri, 14 Aug 2009 07:44:46 -0000 On Friday 14 August 2009 05:29:19 bert wiley wrote: > Hi everyone > > Im new to list and this question may be out of place. This is my first > post. Im new to freebsd and trying to understand how to create a jail from > some system calls. I followed the jail subsystem description from the > handbook and im having a problem or may be using the call incorrectly. But > here is what im trying to do. > > > int main() > { > struct in_addr ipaddr; > struct jail myjail; > > char path[PATH_MAX]; > > realpath("/tmp", path); > > myjail.version = 1; > myjail.path = path; > myjail.hostname = "testjail"; > > const char *ip; > ip = "192.168.1.142"; > > inet_aton(ip, &ipaddr); > myjail.ip4 = ntohl(ipaddr.s_addr); // I get and error here, invalid > conversion from _uint32_t' to in_addr* > myjail.ip4 = ipaddr.s_addr; // and and error here, invlid > conversion from in_addr_t to in_addr* > } > > > I know that there is more that needs to be done but this just a test stub > as im trying to work thru the calls and understand whats going on. > Any would be appreciated thanks. Take a look at the jail(2) man page: The ``ip4s'' and ``ip6s'' give the numbers of IPv4 and IPv6 addresses that will be passed via their respective pointers. The ``ip4'' and ``ip6'' pointers can be set to an arrays of IPv4 and IPv6 addresses to be assigned to the prison, or NULL if none. IPv4 addresses must be in network byte order. So you'd do something like the following: myjail.ip4s = 1; inet_aton(ip, &ipaddr); myjail.ip4 = &ipaddr; You don't have to switch byte order. -- /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News