From owner-freebsd-net Thu Jul 11 15:29:55 2002 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 324AA37B400 for ; Thu, 11 Jul 2002 15:29:48 -0700 (PDT) Received: from smtp.noos.fr (camus.noos.net [212.198.2.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3798C43E42 for ; Thu, 11 Jul 2002 15:29:47 -0700 (PDT) (envelope-from root@gits.dyndns.org) Received: (qmail 40196139 invoked by uid 0); 11 Jul 2002 22:29:45 -0000 Received: from unknown (HELO gits.gits.dyndns.org) ([212.198.229.153]) (envelope-sender ) by 212.198.2.70 (qmail-ldap-1.03) with SMTP for ; 11 Jul 2002 22:29:45 -0000 Received: from gits.gits.dyndns.org (n2msrn0jbdrw89mv@localhost [127.0.0.1]) by gits.gits.dyndns.org (8.12.5/8.12.5) with ESMTP id g6BMThTL023642; Fri, 12 Jul 2002 00:29:44 +0200 (CEST) (envelope-from root@gits.dyndns.org) Received: (from root@localhost) by gits.gits.dyndns.org (8.12.5/8.12.5/Submit) id g6BMTd4H023639; Fri, 12 Jul 2002 00:29:39 +0200 (CEST) (envelope-from root) Date: Fri, 12 Jul 2002 00:29:39 +0200 From: Cyrille Lefevre To: Juan Francisco Rodriguez Hervella Cc: freebsd-net@FreeBSD.ORG Subject: Re: sysctl inferface question Message-ID: <20020711222939.GE21234@gits.dyndns.org> Mail-Followup-To: Cyrille Lefevre , Juan Francisco Rodriguez Hervella , freebsd-net@FreeBSD.ORG References: <3D2D9D4E.74A1B6F4@it.uc3m.es> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3D2D9D4E.74A1B6F4@it.uc3m.es> User-Agent: Mutt/1.3.99i Organization: ACME X-Face: V|+c;4!|B?E%BE^{E6);aI.[< List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Thu, Jul 11, 2002 at 04:59:26PM +0200, Juan Francisco Rodriguez Hervella wrote: > > I'm very confused with the sysctl internals. > > For example, looking at the kernel source code of FreeBSD, I've realized > > of the following: > > netinet/in_proco.c: > SYSCTL_NODE(_net_inet6, IPPROTO_DIVERT, divert, > CTLFLAG_RW, 0, "DIVERT"); > netinet/ip_divert.c: > SYSCTL_DECL(_net_inet_divert); > netinet/ip_divert.c: > SYSCTL_PROC(_net_inet_divert, OID_AUTO, pcblist, CTLFLAG_RD, > 0, 0, > div_pcblist, "S,xinpcb", "List of active divert sockets"); > > Isn't this redundant ? I mean, if there is a "SYSCTL_NODE", there is > *no* need for having > "SYSCTL_DECL" in "ip_divert.c"... I am wrong ? to define a node (pcblist here), you have to declare the node (_net_inet_divert here) you want attach it before. > Also, I don't undertand the meaning of the "fmt" field....what is it for > ? What's the > meaning of "S,xinpcb" in the above example ? the format strings isn't used by the kernel but is by the sysctl(1) command. take a look around lines 556-589 (show_var) in /usr/src/sbin/sysctl/sysctl.c : case 'S': i = 0; if (strcmp(fmt, "S,clockinfo") == 0) func = S_clockinfo; else if (strcmp(fmt, "S,timeval") == 0) func = S_timeval; else if (strcmp(fmt, "S,loadavg") == 0) func = S_loadavg; else if (strcmp(fmt, "T,dev_t") == 0) func = T_dev_t; else func = NULL; if (func) { if (!nflag) printf("%s%s", name, sep); return ((*func)(len, p)); } /* FALL THROUGH */ default: if (!oflag && !xflag) return (1); if (!nflag) printf("%s%s", name, sep); printf("Format:%s Length:%d Dump:0x", fmt, len); while (len-- && (xflag || p < val + 16)) printf("%02x", *p++); if (!xflag && len > 16) printf("..."); return (0); so, the "S" is required, but, IMHO, ",xinpcb" is just informative for now. # sysctl net.inet.divert # sysctl net.inet.divert.pcblist # sysctl -A net.inet.divert net.inet.divert.pcblist: Format:S,xinpcb Length:336 Dump:0x18000000010000000100000000000000... # sysctl -A net.inet.divert.pcblist (same) Cyrille. -- Cyrille Lefevre mailto:cyrille.lefevre@laposte.net 12, Rue de Bizerte 75017 Paris http://clefevre.fr.st tel/fax: +33 (0)1 45 22 83 85 gsm: +33 (0)6 80 94 76 63 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message