From owner-freebsd-net@FreeBSD.ORG Fri May 4 21:54:08 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8ACAC106566C for ; Fri, 4 May 2012 21:54:08 +0000 (UTC) (envelope-from hapvbk@yahoo.co.uk) Received: from nm5.bullet.mail.ird.yahoo.com (nm5.bullet.mail.ird.yahoo.com [77.238.189.62]) by mx1.freebsd.org (Postfix) with SMTP id B9DB88FC19 for ; Fri, 4 May 2012 21:54:07 +0000 (UTC) Received: from [77.238.189.50] by nm5.bullet.mail.ird.yahoo.com with NNFMP; 04 May 2012 21:54:01 -0000 Received: from [212.82.108.237] by tm3.bullet.mail.ird.yahoo.com with NNFMP; 04 May 2012 21:54:01 -0000 Received: from [127.0.0.1] by omp1002.mail.ird.yahoo.com with NNFMP; 04 May 2012 21:54:01 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 340527.71671.bm@omp1002.mail.ird.yahoo.com Received: (qmail 88644 invoked by uid 60001); 4 May 2012 21:54:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1336168441; bh=b06bLCjSgTTKVqi/4WmCMbu2JJ+MNH+nvgpL+EEYci8=; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=NlQxH2L+IaaeWUvyL5t1iQ+oZzEPmmQN/NSBEDbUm3a7Dt8eE2KLUePHxfEsAKb3a7HmOC9J+mW4fn57rBGxnOQB18ca7VbQeZa1JTRdFRkPUCFfUpcCf99aPiot4in8uINllQ//dVuw9qH4qfdL/YWxiqtw8ThDKQqyFvkkiJ0= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=zI7Kbs0gJxobByMK+Y7pH6IYa4lPNh3pDkEjAcInL2fss7g5KTi2nC0qjY1C9dhdqY88IBMmDNXQcp36bSDXAVA5nN0UsVLmWODM5+fFSciZSkWq9Nujimj7SV7Ugz75p8j9771Ure11KALBj7li3gtE0bCmooEWtjFhaYmJaS8=; X-YMail-OSG: khLTNc0VM1nvoNLpY4oELAFnzzX02Z3QMgYpIg2P1X1S9k_ npQCFSB6Img2iLFpJaDgKBfrh3BAoLhfKl3qMbRwcT1xxW6noU_bRY_rhb6V b7j77FJBZRlWGYO6y.g8Q66WVCd_v3RJR8mQRZmX_WHe.UY1H6EucUOdiKPY tMqHLjOKEW9oxHnJ5.2Y8ryhqBo4wBXN5wW.lKC4dK26uWonr09_jeRdq2Aq cK6mXsh2D9Itro18X8tNspMF_dDNFyS2uRQNZmmPq.kPsRTJyNUBLw1Z0Lun Qov5Pve5zPt9uFRaE0GMw9f.dPYfgWabkmyUMgVHX5AfkeWF1ZgzmtpSmgRj 5UhU5x0J.7ALNzCl5ODTvDb_GeXD7Xh5QR9fxFwZHrFo8ua_fvV.qLN8.wec IcKIZHiMvXoxH8.eXUWXC8GlnyXPBNl1Z7CY- Received: from [204.138.59.246] by web28805.mail.ir2.yahoo.com via HTTP; Fri, 04 May 2012 22:54:00 BST X-Mailer: YahooMailWebService/0.8.117.340979 References: <1336168076.28222.YahooMailNeo@web28802.mail.ir2.yahoo.com> Message-ID: <1336168440.88161.YahooMailNeo@web28805.mail.ir2.yahoo.com> Date: Fri, 4 May 2012 22:54:00 +0100 (BST) From: Pham Viet Ha To: "net@freebsd.org" , "freebsd-net@freebsd.org" In-Reply-To: <1336168076.28222.YahooMailNeo@web28802.mail.ir2.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: Re: sysctl command with struct X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Pham Viet Ha List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 21:54:08 -0000 Hi all,=0A=0AI am writing a code using sysctl to manipulate a kernel variab= le. The variable is a data structure with two fields, protocol number (uint= 16_t) and description (char *).=0A=0AI have some difficulties with sysctl c= ommand to pass both protocol number and description at a time to the kernel= . I used CTLTYPE_OPAQUE in SYSCTL_ADD_PROC call, then I used=A0sysctl_handl= e_opaque to read data.=A0=0A=0AIt does not work correctly. I don't know how= what is the format I have to use when I type in "sysctl ..." at the prompt= .=A0=0A=0Astruct protodesc {=A0=0Auint16_t protonumber;=A0=0Achar descripti= on[256];=0A}Add the proc:=A0=0A=0ASYSCTL_ADD_PROC(&ctx, SYSCTL_CHILDREN(tre= e_oidp), OID_AUTO,=0A =A0 =A0"protodesc", CTLTYPE_OPAQUE | CTLFLAG_RW, 0, 0= ,=0A =A0 =A0sysctl_protodesc_update, "S,protodesc",=0A =A0 =A0"To update pr= otocol and description");=0A=0AIn=A0sysctl_protodesc_update, a call to=A0sy= sctl_handle_opaque:=A0=0A=0Aerror =3D sysctl_handle_opaque(oidp, &entry, si= zeof entry, req);=0A=0Aentry is of type protodesc.=A0=0A=0ACompilation and = running both ok. The only issue is that I cannot type in the values for pro= todesc at sysctl command. I don't know what the format is.=A0=0AError messa= ge:=A0sysctl: oid 'protodesc' is type 5, cannot set that.=A0=0A=0A=0AThanks= for any help.=A0=0A=0AP/S: I sent an=A0incomplete=A0email by accident. Sor= ry for that.=A0=0A=0AHAPVBK