Changeset 36799d4 in rtems


Ignore:
Timestamp:
01/03/03 18:09:57 (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
f6161c72
Parents:
5bb1a93c
Message:

2002-11-26 Chris Johns <cjohns@…>

  • Makefile.am: Added sys/linker_set.h
  • kern/Makefile.am: Added kern_mib.c and kern_sysctl.c.
  • kern/uipc_socket.c: OID changed from KERN_SOMAXCONN to KIPC_SOMAXCONN.
  • kern/uipc_socket2.c: OID changed from KERN_MAXSOCKBUF to KIPC_MAXSOCKBUF.
  • net/if_ethersubr.c: FreeBSD 2.2.2 does not have a _net_link node while 5.0 does.
  • net/if_ppp.c: Removed the TEXT_SET define as these macros are now implemented.
  • net/rtsock.c: Enable sysctl support plus fix the bug with the lastest FreeBSD sysctl header file.
  • netinet/icmp_var.h: FreeBSD 2.2.2 does not have a _net_inet_icmp node while 5.0 does.
  • netinet/if_ether.c: FreeBSD 2.2.2 does not have a _net_link_ether node while 5.0 does.
  • netinet/igmp_var.h: FreeBSD 2.2.2 does not have a _net_inet_igmp node while 5.0 does.
  • netinet/in_pcb.c: Fixed the arguments to the sysctl call. Add inp_gencnt and ipi_count. These are used when listing connections.
  • netinet/in_pcb.h: Added counters to aid the listing of connections.
  • netinet/in_var.h: Provide the _net_inet_ip and _net_inet_raw nodes.
  • netinet/ip_fw.c: Disable the firewall sysctl calls.
  • netinet/tcp_subr.c: Merge tcp_pcblist from the lastest FreeBSD source.
  • netinet/tcp_var.h: Add structures needed by net-snmp to list connections.
  • netinet/udp_usrreq.c: Merged udp_pcblist from the lastest FreeBSD source.
  • netinet/udp_var.h: Added the sysctl id UDPCTL_PCBLIST. Used by net-snmp.
  • rtems_glue.c: Call sysctl_register_all when initialising the network stack to register all the sysctl calls. These are in the special sections and required an updated linker script.
  • rtems/rtems_syscall.c: Add the sysctl call.
  • sys/kernel.h: Use the lastest FreeBSD method of handling sysctl structures. This now held in the sys/linker_set.h file.
  • sys/queue.h: This is from the lastest FreeBSD code with the circular code merged back in as it is not used in the lastest FreeBSD kernel.
  • sys/sysctl.h: The lastest sysctl. This was needed to use with the new linker set method. The FreeBSD 2.2.2 version has asm hacks. The lastest version of the FreeBSD does not have these hacks. It uses gcc attribute directives.
Location:
cpukit/libnetworking
Files:
3 added
23 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libnetworking/ChangeLog

    r5bb1a93c r36799d4  
     12002-11-26      Chris Johns <cjohns@cybertec.com.au>
     2
     3        * Makefile.am: Added sys/linker_set.h
     4        * kern/Makefile.am: Added kern_mib.c and kern_sysctl.c.
     5        * kern/uipc_socket.c: OID changed from KERN_SOMAXCONN to KIPC_SOMAXCONN.
     6        * kern/uipc_socket2.c: OID changed from KERN_MAXSOCKBUF to
     7        KIPC_MAXSOCKBUF.
     8        * net/if_ethersubr.c: FreeBSD 2.2.2 does not have a _net_link node
     9        while 5.0 does.
     10        * net/if_ppp.c: Removed the TEXT_SET define as these macros are
     11        now implemented.
     12        * net/rtsock.c: Enable sysctl support plus fix the bug with the
     13        lastest FreeBSD sysctl header file.
     14        * netinet/icmp_var.h: FreeBSD 2.2.2 does not have a _net_inet_icmp
     15        node while 5.0 does.
     16        * netinet/if_ether.c: FreeBSD 2.2.2 does not have a _net_link_ether
     17        node while 5.0 does.
     18        * netinet/igmp_var.h: FreeBSD 2.2.2 does not have a _net_inet_igmp
     19        node while 5.0 does.
     20        * netinet/in_pcb.c: Fixed the arguments to the sysctl call. Add
     21        inp_gencnt and ipi_count. These are used when listing connections.
     22        * netinet/in_pcb.h: Added counters to aid the listing of connections.
     23        * netinet/in_var.h: Provide the _net_inet_ip and _net_inet_raw nodes.
     24        * netinet/ip_fw.c: Disable the firewall sysctl calls.
     25        * netinet/tcp_subr.c: Merge tcp_pcblist from the lastest FreeBSD source.
     26        * netinet/tcp_var.h: Add structures needed by net-snmp to list
     27        connections.
     28        * netinet/udp_usrreq.c: Merged udp_pcblist from the lastest FreeBSD
     29        source.
     30        * netinet/udp_var.h: Added the sysctl id UDPCTL_PCBLIST. Used by
     31        net-snmp.
     32        * rtems_glue.c: Call sysctl_register_all when initialising the
     33        network stack to register all the sysctl calls. These are in the
     34        special sections and required an updated linker script.
     35        * rtems/rtems_syscall.c: Add the sysctl call.
     36        * sys/kernel.h: Use the lastest FreeBSD method of handling sysctl
     37        structures.  This now held in the sys/linker_set.h file.
     38        * sys/queue.h: This is from the lastest FreeBSD code with the circular
     39        code merged back in as it is not used in the lastest FreeBSD kernel.
     40        * sys/sysctl.h: The lastest sysctl. This was needed to use with the new
     41        linker set method. The FreeBSD 2.2.2 version has asm hacks. The lastest
     42        version of the FreeBSD does not have these hacks. It uses gcc attribute
     43        directives.
     44
    1452002-12-18      Eric Norum <eric.norum@usask.ca>
    246        * Makefile.am: Include netinet sources.
  • cpukit/libnetworking/Makefile.am

    r5bb1a93c r36799d4  
    4545## kern
    4646
    47 kern_C_FILES = kern/kern_subr.c kern/uipc_domain.c kern/uipc_mbuf.c \
    48    kern/uipc_socket.c kern/uipc_socket2.c
     47kern_C_FILES = kern/kern_mib.c kern/kern_subr.c kern/uipc_domain.c \
     48   kern/uipc_mbuf.c kern/uipc_socket.c kern/uipc_socket2.c
    4949OBJS = $(kern_C_FILES:kern/%.c=$(ARCH)/%.$(OBJEXT))
    5050
     
    173173
    174174include_sys_HEADERS = sys/buf.h sys/callout.h sys/conf.h sys/domain.h \
    175     sys/kernel.h sys/libkern.h sys/malloc.h sys/mbuf.h sys/mount.h \
     175    sys/kernel.h sys/libkern.h sys/linker_set.h sys/malloc.h sys/mbuf.h sys/mount.h \
    176176    sys/proc.h sys/protosw.h sys/queue.h sys/reboot.h sys/resourcevar.h \
    177177    sys/rtprio.h sys/select.h sys/signalvar.h sys/socket.h sys/socketvar.h \
  • cpukit/libnetworking/kern/uipc_socket.c

    r5bb1a93c r36799d4  
    5353
    5454static int somaxconn = SOMAXCONN;
    55 SYSCTL_INT(_kern, KERN_SOMAXCONN, somaxconn, CTLFLAG_RW, &somaxconn, 0, "");
     55SYSCTL_INT(_kern, KIPC_SOMAXCONN, somaxconn, CTLFLAG_RW, &somaxconn, 0, "");
    5656
    5757/*
  • cpukit/libnetworking/kern/uipc_socket2.c

    r5bb1a93c r36799d4  
    6060
    6161u_long  sb_max = SB_MAX;                /* XXX should be static */
    62 SYSCTL_INT(_kern, KERN_MAXSOCKBUF, maxsockbuf, CTLFLAG_RW, &sb_max, 0, "")
     62SYSCTL_INT(_kern, KIPC_MAXSOCKBUF, maxsockbuf, CTLFLAG_RW, &sb_max, 0, "");
    6363
    6464static  u_long sb_efficiency = 8;       /* parameter for sbreserve() */
  • cpukit/libnetworking/net/if_ethersubr.c

    r5bb1a93c r36799d4  
    896896}
    897897
     898SYSCTL_DECL(_net_link);
    898899SYSCTL_NODE(_net_link, IFT_ETHER, ether, CTLFLAG_RW, 0, "Ethernet");
    899900
  • cpukit/libnetworking/net/if_ppp.c

    r5bb1a93c r36799d4  
    180180static struct timeval    ppp_time;
    181181
     182#ifndef __rtems__
    182183TEXT_SET(pseudo_set, ppp_rxdaemon);
    183 
     184#endif
    184185
    185186static rtems_task ppp_rxdaemon(rtems_task_argument arg)
  • cpukit/libnetworking/net/rtsock.c

    r5bb1a93c r36799d4  
    6868                    struct rt_addrinfo *, caddr_t, struct walkarg *));
    6969static int      rt_xaddrs __P((caddr_t, caddr_t, struct rt_addrinfo *));
    70 #if !defined(__rtems__)
    7170static int      sysctl_dumpentry __P((struct radix_node *rn, void *vw));
    7271static int      sysctl_iflist __P((int af, struct walkarg *w));
    73 #endif
    7472static int       route_output __P((struct mbuf *, struct socket *));
    7573static int       route_usrreq __P((struct socket *,
     
    678676 * This is used in dumping the kernel table via sysctl().
    679677 */
    680 #if !defined(__rtems__)
    681678int
    682679sysctl_dumpentry(rn, vw)
     
    711708        return (error);
    712709}
    713 #endif
    714 
    715 #if !defined(__rtems__)
     710
    716711int
    717712sysctl_iflist(af, w)
     
    740735                        ifm->ifm_data = ifp->if_data;
    741736                        ifm->ifm_addrs = info.rti_addrs;
    742                         error =0;
     737                        error = SYSCTL_OUT(w->w_req,(caddr_t)ifm, len);
    743738                        if (error)
    744739                                return (error);
     
    759754                                ifam->ifam_metric = ifa->ifa_metric;
    760755                                ifam->ifam_addrs = info.rti_addrs;
    761                                 error = 0;
     756                                error = SYSCTL_OUT(w->w_req, w->w_tmem, len);
    762757                                if (error)
    763758                                        return (error);
     
    768763        return (0);
    769764}
    770 #endif
    771 
    772 #if !defined(__rtems__)
     765
    773766static int
    774 sysctl_rtsock SYSCTL_HANDLER_ARGS
     767sysctl_rtsock(SYSCTL_HANDLER_ARGS)
    775768{
    776769        int     *name = (int *)arg1;
     
    815808
    816809SYSCTL_NODE(_net, PF_ROUTE, routetable, CTLFLAG_RD, sysctl_rtsock,"");
    817 #endif
    818810
    819811/*
  • cpukit/libnetworking/netinet/icmp_var.h

    r5bb1a93c r36799d4  
    7373
    7474#ifdef KERNEL
     75SYSCTL_DECL(_net_inet_icmp);
    7576extern struct   icmpstat icmpstat;
    7677#endif
  • cpukit/libnetworking/netinet/if_ether.c

    r5bb1a93c r36799d4  
    6363#define SDL(s) ((struct sockaddr_dl *)s)
    6464
     65SYSCTL_DECL(_net_link_ether);
    6566SYSCTL_NODE(_net_link_ether, PF_INET, inet, CTLFLAG_RW, 0, "");
    6667
  • cpukit/libnetworking/netinet/igmp_var.h

    r5bb1a93c r36799d4  
    9494void    igmp_fasttimo __P((void));
    9595void    igmp_slowtimo __P((void));
     96
     97SYSCTL_DECL(_net_inet_igmp);
     98
    9699#endif
    97100
  • cpukit/libnetworking/netinet/in_pcb.c

    r5bb1a93c r36799d4  
    8080        else if ((var) > (max)) { (var) = (max); }
    8181
    82 #if 0
    8382static int
    84 sysctl_net_ipport_check SYSCTL_HANDLER_ARGS
     83sysctl_net_ipport_check(SYSCTL_HANDLER_ARGS)
    8584{
    8685        int error = sysctl_handle_int(oidp,
     
    9695        return error;
    9796}
    98 #endif
    9997
    10098#undef RANGECHK
     
    127125                return (ENOBUFS);
    128126        bzero((caddr_t)inp, sizeof(*inp));
     127        inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
    129128        inp->inp_pcbinfo = pcbinfo;
    130129        inp->inp_socket = so;
    131130        s = splnet();
    132131        LIST_INSERT_HEAD(pcbinfo->listhead, inp, inp_list);
     132        pcbinfo->ipi_count++;
    133133        in_pcbinshash(inp);
    134134        splx(s);
     
    446446{
    447447        struct socket *so = inp->inp_socket;
     448        struct inpcbinfo *ipi = inp->inp_pcbinfo;
    448449        int s;
    449450
     451        inp->inp_gencnt = ++ipi->ipi_gencnt;
    450452        so->so_pcb = 0;
    451453        sofree(so);
     
    754756
    755757        LIST_INSERT_HEAD(head, inp, inp_hash);
     758        inp->inp_pcbinfo->ipi_count--;
    756759        splx(s);
    757760}
  • cpukit/libnetworking/netinet/in_pcb.h

    r5bb1a93c r36799d4  
    4949LIST_HEAD(inpcbhead, inpcb);
    5050
     51typedef u_int64_t inp_gen_t;
     52
    5153struct inpcb {
    5254        LIST_ENTRY(inpcb) inp_list;             /* list for all PCBs of this proto */
     
    6769        u_char  pad[1];                 /* alignment */
    6870        struct  ip_moptions *inp_moptions; /* IP multicast options */
     71        inp_gen_t       inp_gencnt;     /* generation count of this instance */
    6972#if 0 /* Someday, perhaps... */
    7073        struct  ip inp_ip;              /* header prototype; should have more */
    7174#endif
    7275};
     76
     77/*
     78 * Interface exported to userland by various protocols which use
     79 * inpcbs.  Hack alert -- only define if struct xsocket is in scope.
     80 *
     81 * ccj - 20 Nov 2002
     82 * Double hack alert. This is taken from the pre 5.0 sources and
     83 * merged into RTEMS. This allows the TCPCTL_PCBLIST code in
     84 * net-snmp to work.
     85 */
     86#ifdef _SYS_SOCKETVAR_H_
     87typedef u_int64_t so_gen_t; /* should be in sys/sockvar.h */
     88
     89struct  xinpcb {
     90        size_t  xi_len;         /* length of this structure */
     91        struct  inpcb xi_inp;
     92/*      struct  xsocket xi_socket; ccj removed */
     93        u_int64_t       xi_alignment_hack;
     94};
     95
     96
     97struct  xinpgen {
     98        size_t  xig_len;        /* length of this structure */
     99        u_int   xig_count;      /* number of PCBs at this time */
     100        inp_gen_t xig_gen;      /* generation count at this time */
     101        so_gen_t xig_sogen;     /* socket generation count at this time */
     102};
     103#endif /* _SYS_SOCKETVAR_H_ */
    73104
    74105struct inpcbinfo {
     
    79110        unsigned short lastlow;
    80111        unsigned short lasthi;
     112        u_int   ipi_count;      /* number of pcbs in this list */
     113        u_int64_t ipi_gencnt;   /* current generation count */
    81114};
    82115
  • cpukit/libnetworking/netinet/in_var.h

    r5bb1a93c r36799d4  
    162162
    163163#ifdef KERNEL
     164
     165#ifdef SYSCTL_DECL
     166SYSCTL_DECL(_net_inet_ip);
     167SYSCTL_DECL(_net_inet_raw);
     168#endif
     169
    164170/*
    165171 * Structure used by macros below to remember position when stepping through
  • cpukit/libnetworking/netinet/ip_fw.c

    r5bb1a93c r36799d4  
    6161LIST_HEAD (ip_fw_head, ip_fw_chain) ip_fw_chain;
    6262
     63/*
     64 * ccj - No current need for firewall so have provided the MIB.
     65 */
     66#if 0
    6367#ifdef SYSCTL_NODE
    6468SYSCTL_NODE(_net_inet_ip, OID_AUTO, fw, CTLFLAG_RW, 0, "Firewall");
     
    6670SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, verbose, CTLFLAG_RW, &fw_verbose, 0, "");
    6771SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, verbose_limit, CTLFLAG_RW, &fw_verbose_limit, 0, "");
     72#endif
    6873#endif
    6974
  • cpukit/libnetworking/netinet/tcp_subr.c

    r5bb1a93c r36799d4  
    458458}
    459459
     460#ifdef __rtems__
     461#define INP_INFO_RLOCK
     462#define INP_INFO_RUNLOCK
     463#define INP_LOCK
     464#define INP_UNLOCK
     465#endif
     466
     467static int
     468tcp_pcblist(SYSCTL_HANDLER_ARGS)
     469{
     470        int error, i, n, s;
     471        struct inpcb *inp, **inp_list;
     472        inp_gen_t gencnt;
     473        struct xinpgen xig;
     474
     475        /*
     476         * The process of preparing the TCB list is too time-consuming and
     477         * resource-intensive to repeat twice on every request.
     478         */
     479        if (req->oldptr == 0) {
     480                n = tcbinfo.ipi_count;
     481                req->oldidx = 2 * (sizeof xig)
     482                        + (n + n/8) * sizeof(struct xtcpcb);
     483                return 0;
     484        }
     485
     486        if (req->newptr != 0)
     487                return EPERM;
     488
     489        /*
     490         * OK, now we're committed to doing something.
     491         */
     492        s = splnet();
     493        INP_INFO_RLOCK(&tcbinfo);
     494        gencnt = tcbinfo.ipi_gencnt;
     495        n = tcbinfo.ipi_count;
     496        INP_INFO_RUNLOCK(&tcbinfo);
     497        splx(s);
     498
     499        sysctl_wire_old_buffer(req, 2 * (sizeof xig)
     500                + n * sizeof(struct xtcpcb));
     501
     502        xig.xig_len = sizeof xig;
     503        xig.xig_count = n;
     504        xig.xig_gen = gencnt;
     505/*      xig.xig_sogen = so_gencnt; remove by ccj */
     506        error = SYSCTL_OUT(req, &xig, sizeof xig);
     507        if (error)
     508                return error;
     509
     510        /* ccj add exit if the count is 0 */
     511        if (!n)
     512                return error;
     513 
     514        inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
     515        if (inp_list == 0)
     516                return ENOMEM;
     517       
     518        s = splnet();
     519        INP_INFO_RLOCK(&tcbinfo);
     520        for (inp = LIST_FIRST(tcbinfo.listhead), i = 0; inp && i < n;
     521             inp = LIST_NEXT(inp, inp_list)) {
     522                INP_LOCK(inp);
     523                if (inp->inp_gencnt <= gencnt)
     524#if 0
     525      &&
     526                    cr_canseesocket(req->td->td_ucred, inp->inp_socket) == 0)
     527#endif
     528                        inp_list[i++] = inp;
     529                INP_UNLOCK(inp);
     530        }
     531        INP_INFO_RUNLOCK(&tcbinfo);
     532        splx(s);
     533        n = i;
     534
     535        error = 0;
     536        for (i = 0; i < n; i++) {
     537                inp = inp_list[i];
     538                INP_LOCK(inp);
     539                if (inp->inp_gencnt <= gencnt) {
     540                        struct xtcpcb xt;
     541                        caddr_t inp_ppcb;
     542                        xt.xt_len = sizeof xt;
     543                        /* XXX should avoid extra copy */
     544                        bcopy(inp, &xt.xt_inp, sizeof *inp);
     545                        inp_ppcb = inp->inp_ppcb;
     546                        if (inp_ppcb != NULL)
     547                                bcopy(inp_ppcb, &xt.xt_tp, sizeof xt.xt_tp);
     548                        else
     549                                bzero((char *) &xt.xt_tp, sizeof xt.xt_tp);
     550#if 0     
     551                        if (inp->inp_socket)
     552                                sotoxsocket(inp->inp_socket, &xt.xt_socket);
     553#endif
     554                        error = SYSCTL_OUT(req, &xt, sizeof xt);
     555                }
     556                INP_UNLOCK(inp);
     557        }
     558        if (!error) {
     559                /*
     560                 * Give the user an updated idea of our state.
     561                 * If the generation differs from what we told
     562                 * her before, she knows that something happened
     563                 * while we were processing this request, and it
     564                 * might be necessary to retry.
     565                 */
     566                s = splnet();
     567                INP_INFO_RLOCK(&tcbinfo);
     568                xig.xig_gen = tcbinfo.ipi_gencnt;
     569#if 0   
     570                xig.xig_sogen = so_gencnt;
     571#endif
     572                xig.xig_count = tcbinfo.ipi_count;
     573                INP_INFO_RUNLOCK(&tcbinfo);
     574                splx(s);
     575                error = SYSCTL_OUT(req, &xig, sizeof xig);
     576        }
     577        free(inp_list, M_TEMP);
     578        return error;
     579}
     580
     581SYSCTL_PROC(_net_inet_tcp, TCPCTL_PCBLIST, pcblist, CTLFLAG_RD, 0, 0,
     582            tcp_pcblist, "S,xtcpcb", "List of active TCP connections");
     583
    460584void
    461585tcp_ctlinput(cmd, sa, vip)
  • cpukit/libnetworking/netinet/tcp_var.h

    r5bb1a93c r36799d4  
    308308
    309309/*
     310 * TCB structure exported to user-land via sysctl(3).
     311 * Evil hack: declare only if in_pcb.h and sys/socketvar.h have been
     312 * included.  Not all of our clients do.
     313 */
     314#if defined(_NETINET_IN_PCB_H_) && defined(_SYS_SOCKETVAR_H_)
     315struct  xtcpcb {
     316        size_t  xt_len;
     317        struct  inpcb   xt_inp;
     318        struct  tcpcb   xt_tp;
     319#if 0
     320        struct  xsocket xt_socket;
     321        u_quad_t        xt_alignment_hack;
     322#endif
     323};
     324#endif
     325
     326/*
    310327 * Names for TCP sysctl objects
    311328 */
     
    320337#define TCPCTL_RECVSPACE        9       /* receive buffer space */
    321338#define TCPCTL_KEEPINIT         10      /* receive buffer space */
    322 #define TCPCTL_MAXID            11
     339#define TCPCTL_PCBLIST          11      /* list of all outstanding PCBs */
     340#define TCPCTL_MAXID            12
    323341
    324342#define TCPCTL_NAMES { \
     
    337355
    338356#ifdef KERNEL
     357#ifdef SYSCTL_DECL
     358SYSCTL_DECL(_net_inet_tcp);
     359#endif
     360
    339361extern  struct inpcbhead tcb;           /* head of queue of active tcpcb's */
    340362extern  struct inpcbinfo tcbinfo;
  • cpukit/libnetworking/netinet/udp_usrreq.c

    r5bb1a93c r36799d4  
    456456}
    457457
     458#ifdef __rtems__
     459#define INP_INFO_RLOCK
     460#define INP_INFO_RUNLOCK
     461#define INP_LOCK
     462#define INP_UNLOCK
     463#endif
     464
     465static int
     466udp_pcblist(SYSCTL_HANDLER_ARGS)
     467{
     468        int error, i, n, s;
     469        struct inpcb *inp, **inp_list;
     470        inp_gen_t gencnt;
     471        struct xinpgen xig;
     472
     473        /*
     474         * The process of preparing the TCB list is too time-consuming and
     475         * resource-intensive to repeat twice on every request.
     476         */
     477        if (req->oldptr == 0) {
     478                n = udbinfo.ipi_count;
     479                req->oldidx = 2 * (sizeof xig)
     480                        + (n + n/8) * sizeof(struct xinpcb);
     481                return 0;
     482        }
     483
     484        if (req->newptr != 0)
     485                return EPERM;
     486
     487        /*
     488         * OK, now we're committed to doing something.
     489         */
     490        s = splnet();
     491        gencnt = udbinfo.ipi_gencnt;
     492        n = udbinfo.ipi_count;
     493        splx(s);
     494
     495        sysctl_wire_old_buffer(req, 2 * (sizeof xig)
     496                + n * sizeof(struct xinpcb));
     497
     498        xig.xig_len = sizeof xig;
     499        xig.xig_count = n;
     500        xig.xig_gen = gencnt;
     501#if 0
     502        xig.xig_sogen = so_gencnt;
     503#endif
     504        error = SYSCTL_OUT(req, &xig, sizeof xig);
     505        if (error)
     506                return error;
     507
     508  /* ccj add the exit if count is 0 */
     509  if (!n)
     510    return error;
     511 
     512        inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
     513        if (inp_list == 0)
     514                return ENOMEM;
     515       
     516        s = splnet();
     517        INP_INFO_RLOCK(&udbinfo);
     518        for (inp = LIST_FIRST(udbinfo.listhead), i = 0; inp && i < n;
     519             inp = LIST_NEXT(inp, inp_list)) {
     520                INP_LOCK(inp);
     521                if (inp->inp_gencnt <= gencnt)
     522#if 0
     523      &&
     524                    cr_canseesocket(req->td->td_ucred, inp->inp_socket) == 0)
     525#endif
     526                        inp_list[i++] = inp;
     527                INP_UNLOCK(inp);
     528        }
     529        INP_INFO_RUNLOCK(&udbinfo);
     530        splx(s);
     531        n = i;
     532
     533        error = 0;
     534        for (i = 0; i < n; i++) {
     535                inp = inp_list[i];
     536                INP_LOCK(inp);
     537                if (inp->inp_gencnt <= gencnt) {
     538                        struct xinpcb xi;
     539                        xi.xi_len = sizeof xi;
     540                        /* XXX should avoid extra copy */
     541                        bcopy(inp, &xi.xi_inp, sizeof *inp);
     542#if 0
     543                        if (inp->inp_socket)
     544                                sotoxsocket(inp->inp_socket, &xi.xi_socket);
     545#endif
     546                        error = SYSCTL_OUT(req, &xi, sizeof xi);
     547                }
     548                INP_UNLOCK(inp);
     549        }
     550        if (!error) {
     551                /*
     552                 * Give the user an updated idea of our state.
     553                 * If the generation differs from what we told
     554                 * her before, she knows that something happened
     555                 * while we were processing this request, and it
     556                 * might be necessary to retry.
     557                 */
     558                s = splnet();
     559                INP_INFO_RLOCK(&udbinfo);
     560                xig.xig_gen = udbinfo.ipi_gencnt;
     561#if 0
     562                xig.xig_sogen = so_gencnt;
     563#endif
     564                xig.xig_count = udbinfo.ipi_count;
     565                INP_INFO_RUNLOCK(&udbinfo);
     566                splx(s);
     567                error = SYSCTL_OUT(req, &xig, sizeof xig);
     568        }
     569        free(inp_list, M_TEMP);
     570        return error;
     571}
     572
     573SYSCTL_PROC(_net_inet_udp, UDPCTL_PCBLIST, pcblist, CTLFLAG_RD, 0, 0,
     574            udp_pcblist, "S,xinpcb", "List of active UDP sockets");
     575
    458576static u_long   udp_sendspace = 9216;           /* really max datagram size */
    459577                                        /* 40 1K datagrams */
  • cpukit/libnetworking/netinet/udp_var.h

    r5bb1a93c r36799d4  
    7979#define UDPCTL_MAXDGRAM         3       /* max datagram size */
    8080#define UDPCTL_RECVSPACE        4       /* default receive buffer space */
    81 #define UDPCTL_MAXID            5
     81#define UDPCTL_PCBLIST          5       /* list of PCBs for UDP sockets */
     82#define UDPCTL_MAXID            6
    8283
    8384#define UDPCTL_NAMES { \
     
    9091
    9192#ifdef KERNEL
     93SYSCTL_DECL(_net_inet_udp);
     94
    9295extern struct   inpcbhead udb;
    9396extern struct   inpcbinfo udbinfo;
  • cpukit/libnetworking/rtems/rtems_glue.c

    r5bb1a93c r36799d4  
    3838
    3939/*
     40 * Sysctl init all.
     41 */
     42void sysctl_register_all(void *arg);
     43
     44/*
    4045 * Memory allocation
    4146 */
     
    197202        }
    198203
     204  /*
     205   * Setup the sysctl, normally done by a SYSINIT call.
     206   */
     207  sysctl_register_all(0);
     208   
    199209        /*
    200210         * Set up interfaces
  • cpukit/libnetworking/rtems/rtems_syscall.c

    r5bb1a93c r36799d4  
    77/* #include <stdlib.h> */
    88#include <stdio.h>
     9#include <errno.h>
    910
    1011#include <rtems.h>
     
    634635}
    635636
     637int
     638sysctl(int *name, u_int namelen, void *oldp,
     639       size_t *oldlenp, void *newp, size_t newlen)
     640{
     641  int    error;
     642        size_t j;
     643
     644  rtems_bsdnet_semaphore_obtain (); 
     645  error = userland_sysctl (0, name, namelen, oldp, oldlenp, 1, newp, newlen, &j);
     646  rtems_bsdnet_semaphore_release ();
     647
     648  if (oldlenp)
     649    *oldlenp = j;
     650 
     651  if (error)
     652  {
     653    errno = error;
     654    return -1;
     655  }
     656  return 0;
     657}
     658
    636659/*
    637660 ************************************************************************
  • cpukit/libnetworking/sys/kernel.h

    r5bb1a93c r36799d4  
    7373extern long timedelta;
    7474
     75#if FREEBSD_RELENG_2_2_2_BASE
    7576/*
    7677 * The following macros are used to declare global sets of objects, which
     
    8788#define ABS_SET(set, sym)  MAKE_SET(set, sym, 21)
    8889
     90#else
     91
     92/*
     93 * RTEMS specific port using the updated sys/linker_set.h
     94 * from the lastest FreeBSD (2002-Nov-15). This is a better
     95 * way.
     96 *
     97 * Chris Johns (ccj@acm.org> 18 Nov 2002.
     98 */
     99#include <sys/linker_set.h>
     100
     101#endif
    89102
    90103/*
  • cpukit/libnetworking/sys/queue.h

    r5bb1a93c r36799d4  
    3232 *
    3333 *      @(#)queue.h     8.5 (Berkeley) 8/20/94
    34  * $Id$
     34 * $FreeBSD: src/sys/sys/queue.h,v 1.54 2002/08/05 05:18:43 alfred Exp $
    3535 */
    3636
     
    3838#define _SYS_QUEUE_H_
    3939
    40 /*
    41  * This file defines five types of data structures: singly-linked lists,
    42  * slingly-linked tail queues, lists, tail queues, and circular queues.
     40#include <sys/cdefs.h>
     41
     42/*
     43 * This file defines four types of data structures: singly-linked lists,
     44 * singly-linked tail queues, lists and tail queues.
    4345 *
    4446 * A singly-linked list is headed by a single forward pointer. The elements
     
    7577 * traverse the list. New elements can be added to the list before or
    7678 * after an existing element, at the head of the list, or at the end of
    77  * the list. A tail queue may only be traversed in the forward direction.
    78  *
    79  * A circle queue is headed by a pair of pointers, one to the head of the
    80  * list and the other to the tail of the list. The elements are doubly
    81  * linked so that an arbitrary element can be removed without a need to
    82  * traverse the list. New elements can be added to the list before or after
    83  * an existing element, at the head of the list, or at the end of the list.
    84  * A circle queue may be traversed in either direction, but has a more
    85  * complex end of list detection.
     79 * the list. A tail queue may be traversed in either direction.
    8680 *
    8781 * For details on the use of these macros, see the queue(3) manual page.
    88  */
    89 
    90 /*
    91  * Singly-linked List definitions.
    92  */
    93 #define SLIST_HEAD(name, type)                                          \
     82 *
     83 *
     84 *                      SLIST   LIST    STAILQ  TAILQ
     85 * _HEAD                +       +       +       +
     86 * _HEAD_INITIALIZER    +       +       +       +
     87 * _ENTRY               +       +       +       +
     88 * _INIT                +       +       +       +
     89 * _EMPTY               +       +       +       +
     90 * _FIRST               +       +       +       +
     91 * _NEXT                +       +       +       +
     92 * _PREV                -       -       -       +
     93 * _LAST                -       -       +       +
     94 * _FOREACH             +       +       +       +
     95 * _FOREACH_REVERSE     -       -       -       +
     96 * _INSERT_HEAD         +       +       +       +
     97 * _INSERT_BEFORE       -       +       -       +
     98 * _INSERT_AFTER        +       +       +       +
     99 * _INSERT_TAIL         -       -       +       +
     100 * _CONCAT              -       -       +       +
     101 * _REMOVE_HEAD         +       -       +       -
     102 * _REMOVE              +       +       +       +
     103 *
     104 */
     105#define QUEUE_MACRO_DEBUG 0
     106#if QUEUE_MACRO_DEBUG
     107/* Store the last 2 places the queue element or head was altered */
     108struct qm_trace {
     109        char * lastfile;
     110        int lastline;
     111        char * prevfile;
     112        int prevline;
     113};
     114
     115#define TRACEBUF        struct qm_trace trace;
     116#define TRASHIT(x)      do {(x) = (void *)-1;} while (0)
     117
     118#define QMD_TRACE_HEAD(head) do {                                       \
     119        (head)->trace.prevline = (head)->trace.lastline;                \
     120        (head)->trace.prevfile = (head)->trace.lastfile;                \
     121        (head)->trace.lastline = __LINE__;                              \
     122        (head)->trace.lastfile = __FILE__;                              \
     123} while (0)
     124
     125#define QMD_TRACE_ELEM(elem) do {                                       \
     126        (elem)->trace.prevline = (elem)->trace.lastline;                \
     127        (elem)->trace.prevfile = (elem)->trace.lastfile;                \
     128        (elem)->trace.lastline = __LINE__;                              \
     129        (elem)->trace.lastfile = __FILE__;                              \
     130} while (0)
     131
     132#else
     133#define QMD_TRACE_ELEM(elem)
     134#define QMD_TRACE_HEAD(head)
     135#define TRACEBUF
     136#define TRASHIT(x)
     137#endif  /* QUEUE_MACRO_DEBUG */
     138
     139/*
     140 * Singly-linked List declarations.
     141 */
     142#define SLIST_HEAD(name, type)                                          \
    94143struct name {                                                           \
    95144        struct type *slh_first; /* first element */                     \
    96145}
     146
     147#define SLIST_HEAD_INITIALIZER(head)                                    \
     148        { NULL }
    97149 
    98 #define SLIST_ENTRY(type)                                               \
     150#define SLIST_ENTRY(type)                                               \
    99151struct {                                                                \
    100152        struct type *sle_next;  /* next element */                      \
     
    104156 * Singly-linked List functions.
    105157 */
    106 #define SLIST_INIT(head) {                                              \
    107         (head)->slh_first = NULL;                                       \
    108 }
    109 
    110 #define SLIST_INSERT_AFTER(slistelm, elm, field) {                      \
    111         (elm)->field.sle_next = (slistelm)->field.sle_next;             \
    112         (slistelm)->field.sle_next = (elm);                             \
    113 }
    114 
    115 #define SLIST_INSERT_HEAD(head, elm, field) {                           \
    116         (elm)->field.sle_next = (head)->slh_first;                      \
    117         (head)->slh_first = (elm);                                      \
    118 }
    119 
    120 #define SLIST_REMOVE_HEAD(head, field) {                                \
    121         (head)->slh_first = (head)->slh_first->field.sle_next;          \
    122 }
    123 
    124 #define SLIST_REMOVE(head, elm, type, field) {                          \
    125         if ((head)->slh_first == (elm)) {                               \
     158#define SLIST_EMPTY(head)       ((head)->slh_first == NULL)
     159
     160#define SLIST_FIRST(head)       ((head)->slh_first)
     161
     162#define SLIST_FOREACH(var, head, field)                                 \
     163        for ((var) = SLIST_FIRST((head));                               \
     164            (var);                                                      \
     165            (var) = SLIST_NEXT((var), field))
     166
     167#define SLIST_FOREACH_PREVPTR(var, varp, head, field)                   \
     168        for ((varp) = &SLIST_FIRST((head));                             \
     169            ((var) = *(varp)) != NULL;                                  \
     170            (varp) = &SLIST_NEXT((var), field))
     171
     172#define SLIST_INIT(head) do {                                           \
     173        SLIST_FIRST((head)) = NULL;                                     \
     174} while (0)
     175
     176#define SLIST_INSERT_AFTER(slistelm, elm, field) do {                   \
     177        SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field);       \
     178        SLIST_NEXT((slistelm), field) = (elm);                          \
     179} while (0)
     180
     181#define SLIST_INSERT_HEAD(head, elm, field) do {                        \
     182        SLIST_NEXT((elm), field) = SLIST_FIRST((head));                 \
     183        SLIST_FIRST((head)) = (elm);                                    \
     184} while (0)
     185
     186#define SLIST_NEXT(elm, field)  ((elm)->field.sle_next)
     187
     188#define SLIST_REMOVE(head, elm, type, field) do {                       \
     189        if (SLIST_FIRST((head)) == (elm)) {                             \
    126190                SLIST_REMOVE_HEAD((head), field);                       \
    127191        }                                                               \
    128192        else {                                                          \
    129                 struct type *curelm = (head)->slh_first;                \
    130                 while( curelm->field.sle_next != (elm) )                \
    131                         curelm = curelm->field.sle_next;                \
    132                 curelm->field.sle_next =                                \
    133                     curelm->field.sle_next->field.sle_next;             \
    134         }                                                               \
    135 }
    136 
    137 /*
    138  * Singly-linked Tail queue definitions.
    139  */
    140 #define STAILQ_HEAD(name, type)                                         \
     193                struct type *curelm = SLIST_FIRST((head));              \
     194                while (SLIST_NEXT(curelm, field) != (elm))              \
     195                        curelm = SLIST_NEXT(curelm, field);             \
     196                SLIST_NEXT(curelm, field) =                             \
     197                    SLIST_NEXT(SLIST_NEXT(curelm, field), field);       \
     198        }                                                               \
     199} while (0)
     200
     201#define SLIST_REMOVE_HEAD(head, field) do {                             \
     202        SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);   \
     203} while (0)
     204
     205/*
     206 * Singly-linked Tail queue declarations.
     207 */
     208#define STAILQ_HEAD(name, type)                                         \
    141209struct name {                                                           \
    142210        struct type *stqh_first;/* first element */                     \
     
    144212}
    145213
    146 #define STAILQ_ENTRY(type)                                              \
     214#define STAILQ_HEAD_INITIALIZER(head)                                   \
     215        { NULL, &(head).stqh_first }
     216
     217#define STAILQ_ENTRY(type)                                              \
    147218struct {                                                                \
    148219        struct type *stqe_next; /* next element */                      \
     
    152223 * Singly-linked Tail queue functions.
    153224 */
    154 #define STAILQ_INIT(head) {                                             \
    155         (head)->stqh_first = NULL;                                      \
    156         (head)->stqh_last = &(head)->stqh_first;                        \
    157 }
    158 
    159 #define STAILQ_INSERT_HEAD(head, elm, field) {                          \
    160         if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)      \
    161                 (head)->stqh_last = &(elm)->field.stqe_next;            \
    162         (head)->stqh_first = (elm);                                     \
    163 }
    164 
    165 #define STAILQ_INSERT_TAIL(head, elm, field) {                          \
    166         (elm)->field.stqe_next = NULL;                                  \
     225#define STAILQ_CONCAT(head1, head2) do {                                \
     226        if (!STAILQ_EMPTY((head2))) {                                   \
     227                *(head1)->stqh_last = (head2)->stqh_first;              \
     228                (head1)->stqh_last = (head2)->stqh_last;                \
     229                STAILQ_INIT((head2));                                   \
     230        }                                                               \
     231} while (0)
     232
     233#define STAILQ_EMPTY(head)      ((head)->stqh_first == NULL)
     234
     235#define STAILQ_FIRST(head)      ((head)->stqh_first)
     236
     237#define STAILQ_FOREACH(var, head, field)                                \
     238        for((var) = STAILQ_FIRST((head));                               \
     239           (var);                                                       \
     240           (var) = STAILQ_NEXT((var), field))
     241
     242#define STAILQ_INIT(head) do {                                          \
     243        STAILQ_FIRST((head)) = NULL;                                    \
     244        (head)->stqh_last = &STAILQ_FIRST((head));                      \
     245} while (0)
     246
     247#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do {               \
     248        if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
     249                (head)->stqh_last = &STAILQ_NEXT((elm), field);         \
     250        STAILQ_NEXT((tqelm), field) = (elm);                            \
     251} while (0)
     252
     253#define STAILQ_INSERT_HEAD(head, elm, field) do {                       \
     254        if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
     255                (head)->stqh_last = &STAILQ_NEXT((elm), field);         \
     256        STAILQ_FIRST((head)) = (elm);                                   \
     257} while (0)
     258
     259#define STAILQ_INSERT_TAIL(head, elm, field) do {                       \
     260        STAILQ_NEXT((elm), field) = NULL;                               \
    167261        *(head)->stqh_last = (elm);                                     \
    168         (head)->stqh_last = &(elm)->field.stqe_next;                    \
    169 }
    170 
    171 #define STAILQ_INSERT_AFTER(head, tqelm, elm, field) {                  \
    172         if (((elm)->field.stqe_next = (tqelm)->field.stqe_next) == NULL)\
    173                 (head)->stqh_last = &(elm)->field.stqe_next;            \
    174         (tqelm)->field.stqe_next = (elm);                               \
    175 }
    176 
    177 #define STAILQ_REMOVE_HEAD(head, field) {                               \
    178         if (((head)->stqh_first =                                       \
    179              (head)->stqh_first->field.stqe_next) == NULL)              \
    180                 (head)->stqh_last = &(head)->stqh_first;                \
    181 }
    182 
    183 #define STAILQ_REMOVE(head, elm, type, field) {                         \
    184         if ((head)->stqh_first == (elm)) {                              \
    185                 STAILQ_REMOVE_HEAD(head, field);                        \
     262        (head)->stqh_last = &STAILQ_NEXT((elm), field);                 \
     263} while (0)
     264
     265#define STAILQ_LAST(head, type, field)                                  \
     266        (STAILQ_EMPTY((head)) ?                                         \
     267                NULL :                                                  \
     268                ((struct type *)                                        \
     269                ((char *)((head)->stqh_last) - __offsetof(struct type, field))))
     270
     271#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
     272
     273#define STAILQ_REMOVE(head, elm, type, field) do {                      \
     274        if (STAILQ_FIRST((head)) == (elm)) {                            \
     275                STAILQ_REMOVE_HEAD((head), field);                      \
    186276        }                                                               \
    187277        else {                                                          \
    188                 struct type *curelm = (head)->stqh_first;               \
    189                 while( curelm->field.stqe_next != (elm) )               \
    190                         curelm = curelm->field.stqe_next;               \
    191                 if((curelm->field.stqe_next =                           \
    192                     curelm->field.stqe_next->field.stqe_next) == NULL)  \
    193                         (head)->stqh_last = &(curelm)->field.stqe_next; \
    194         }                                                               \
    195 }
    196 
    197 /*
    198  * List definitions.
    199  */
    200 #define LIST_HEAD(name, type)                                           \
     278                struct type *curelm = STAILQ_FIRST((head));             \
     279                while (STAILQ_NEXT(curelm, field) != (elm))             \
     280                        curelm = STAILQ_NEXT(curelm, field);            \
     281                if ((STAILQ_NEXT(curelm, field) =                       \
     282                     STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
     283                        (head)->stqh_last = &STAILQ_NEXT((curelm), field);\
     284        }                                                               \
     285} while (0)
     286
     287#define STAILQ_REMOVE_HEAD(head, field) do {                            \
     288        if ((STAILQ_FIRST((head)) =                                     \
     289             STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL)         \
     290                (head)->stqh_last = &STAILQ_FIRST((head));              \
     291} while (0)
     292
     293#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do {                 \
     294        if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \
     295                (head)->stqh_last = &STAILQ_FIRST((head));              \
     296} while (0)
     297
     298/*
     299 * List declarations.
     300 */
     301#define LIST_HEAD(name, type)                                           \
    201302struct name {                                                           \
    202303        struct type *lh_first;  /* first element */                     \
    203304}
    204305
    205 #define LIST_ENTRY(type)                                                \
     306#define LIST_HEAD_INITIALIZER(head)                                     \
     307        { NULL }
     308
     309#define LIST_ENTRY(type)                                                \
    206310struct {                                                                \
    207311        struct type *le_next;   /* next element */                      \
     
    212316 * List functions.
    213317 */
    214 #define LIST_INIT(head) {                                               \
    215         (head)->lh_first = NULL;                                        \
    216 }
    217 
    218 #define LIST_INSERT_AFTER(listelm, elm, field) {                        \
    219         if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)  \
    220                 (listelm)->field.le_next->field.le_prev =               \
    221                     &(elm)->field.le_next;                              \
    222         (listelm)->field.le_next = (elm);                               \
    223         (elm)->field.le_prev = &(listelm)->field.le_next;               \
    224 }
    225 
    226 #define LIST_INSERT_BEFORE(listelm, elm, field) {                       \
     318
     319#define LIST_EMPTY(head)        ((head)->lh_first == NULL)
     320
     321#define LIST_FIRST(head)        ((head)->lh_first)
     322
     323#define LIST_FOREACH(var, head, field)                                  \
     324        for ((var) = LIST_FIRST((head));                                \
     325            (var);                                                      \
     326            (var) = LIST_NEXT((var), field))
     327
     328#define LIST_INIT(head) do {                                            \
     329        LIST_FIRST((head)) = NULL;                                      \
     330} while (0)
     331
     332#define LIST_INSERT_AFTER(listelm, elm, field) do {                     \
     333        if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
     334                LIST_NEXT((listelm), field)->field.le_prev =            \
     335                    &LIST_NEXT((elm), field);                           \
     336        LIST_NEXT((listelm), field) = (elm);                            \
     337        (elm)->field.le_prev = &LIST_NEXT((listelm), field);            \
     338} while (0)
     339
     340#define LIST_INSERT_BEFORE(listelm, elm, field) do {                    \
    227341        (elm)->field.le_prev = (listelm)->field.le_prev;                \
    228         (elm)->field.le_next = (listelm);                               \
     342        LIST_NEXT((elm), field) = (listelm);                            \
    229343        *(listelm)->field.le_prev = (elm);                              \
    230         (listelm)->field.le_prev = &(elm)->field.le_next;               \
    231 }
    232 
    233 #define LIST_INSERT_HEAD(head, elm, field) {                            \
    234         if (((elm)->field.le_next = (head)->lh_first) != NULL)          \
    235                 (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
    236         (head)->lh_first = (elm);                                       \
    237         (elm)->field.le_prev = &(head)->lh_first;                       \
    238 }
    239 
    240 #define LIST_REMOVE(elm, field) {                                       \
    241         if ((elm)->field.le_next != NULL)                               \
    242                 (elm)->field.le_next->field.le_prev =                   \
     344        (listelm)->field.le_prev = &LIST_NEXT((elm), field);            \
     345} while (0)
     346
     347#define LIST_INSERT_HEAD(head, elm, field) do {                         \
     348        if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL)     \
     349                LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
     350        LIST_FIRST((head)) = (elm);                                     \
     351        (elm)->field.le_prev = &LIST_FIRST((head));                     \
     352} while (0)
     353
     354#define LIST_NEXT(elm, field)   ((elm)->field.le_next)
     355
     356#define LIST_REMOVE(elm, field) do {                                    \
     357        if (LIST_NEXT((elm), field) != NULL)                            \
     358                LIST_NEXT((elm), field)->field.le_prev =                \
    243359                    (elm)->field.le_prev;                               \
    244         *(elm)->field.le_prev = (elm)->field.le_next;                   \
    245 }
    246 
    247 /*
    248  * Tail queue definitions.
    249  */
    250 #define TAILQ_HEAD(name, type)                                          \
     360        *(elm)->field.le_prev = LIST_NEXT((elm), field);                \
     361} while (0)
     362
     363/*
     364 * Tail queue declarations.
     365 */
     366#define TAILQ_HEAD(name, type)                                          \
    251367struct name {                                                           \
    252368        struct type *tqh_first; /* first element */                     \
    253369        struct type **tqh_last; /* addr of last next element */         \
    254 }
    255 
    256 #define TAILQ_HEAD_INITIALIZER(head)                                    \
     370        TRACEBUF                                                        \
     371}
     372
     373#define TAILQ_HEAD_INITIALIZER(head)                                    \
    257374        { NULL, &(head).tqh_first }
    258375
    259 #define TAILQ_ENTRY(type)                                               \
     376#define TAILQ_ENTRY(type)                                               \
    260377struct {                                                                \
    261378        struct type *tqe_next;  /* next element */                      \
    262379        struct type **tqe_prev; /* address of previous next element */  \
     380        TRACEBUF                                                        \
    263381}
    264382
     
    266384 * Tail queue functions.
    267385 */
    268 #define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
    269 
    270 #define TAILQ_FIRST(head) ((head)->tqh_first)
    271 
    272 #define TAILQ_LAST(head) ((head)->tqh_last)
    273 
    274 #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
    275 
    276 #define TAILQ_PREV(elm, field) ((elm)->field.tqe_prev)
    277 
    278 #define TAILQ_INIT(head) {                                              \
    279         (head)->tqh_first = NULL;                                       \
    280         (head)->tqh_last = &(head)->tqh_first;                          \
    281 }
    282 
    283 #define TAILQ_INSERT_HEAD(head, elm, field) {                           \
    284         if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)        \
    285                 (head)->tqh_first->field.tqe_prev =                     \
    286                     &(elm)->field.tqe_next;                             \
     386#define TAILQ_CONCAT(head1, head2, field) do {                          \
     387        if (!TAILQ_EMPTY(head2)) {                                      \
     388                *(head1)->tqh_last = (head2)->tqh_first;                \
     389                (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
     390                (head1)->tqh_last = (head2)->tqh_last;                  \
     391                TAILQ_INIT((head2));                                    \
     392                QMD_TRACE_HEAD(head);                                   \
     393                QMD_TRACE_HEAD(head2);                                  \
     394        }                                                               \
     395} while (0)
     396
     397#define TAILQ_EMPTY(head)       ((head)->tqh_first == NULL)
     398
     399#define TAILQ_FIRST(head)       ((head)->tqh_first)
     400
     401#define TAILQ_FOREACH(var, head, field)                                 \
     402        for ((var) = TAILQ_FIRST((head));                               \
     403            (var);                                                      \
     404            (var) = TAILQ_NEXT((var), field))
     405
     406#define TAILQ_FOREACH_REVERSE(var, head, headname, field)               \
     407        for ((var) = TAILQ_LAST((head), headname);                      \
     408            (var);                                                      \
     409            (var) = TAILQ_PREV((var), headname, field))
     410
     411#define TAILQ_INIT(head) do {                                           \
     412        TAILQ_FIRST((head)) = NULL;                                     \
     413        (head)->tqh_last = &TAILQ_FIRST((head));                        \
     414        QMD_TRACE_HEAD(head);                                           \
     415} while (0)
     416
     417#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do {              \
     418        if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
     419                TAILQ_NEXT((elm), field)->field.tqe_prev =              \
     420                    &TAILQ_NEXT((elm), field);                          \
     421        else {                                                          \
     422                (head)->tqh_last = &TAILQ_NEXT((elm), field);           \
     423                QMD_TRACE_HEAD(head);                                   \
     424        }                                                               \
     425        TAILQ_NEXT((listelm), field) = (elm);                           \
     426        (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field);          \
     427        QMD_TRACE_ELEM(&(elm)->field);                                  \
     428        QMD_TRACE_ELEM(&listelm->field);                                \
     429} while (0)
     430
     431#define TAILQ_INSERT_BEFORE(listelm, elm, field) do {                   \
     432        (elm)->field.tqe_prev = (listelm)->field.tqe_prev;              \
     433        TAILQ_NEXT((elm), field) = (listelm);                           \
     434        *(listelm)->field.tqe_prev = (elm);                             \
     435        (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field);          \
     436        QMD_TRACE_ELEM(&(elm)->field);                                  \
     437        QMD_TRACE_ELEM(&listelm->field);                                \
     438} while (0)
     439
     440#define TAILQ_INSERT_HEAD(head, elm, field) do {                        \
     441        if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL)   \
     442                TAILQ_FIRST((head))->field.tqe_prev =                   \
     443                    &TAILQ_NEXT((elm), field);                          \
    287444        else                                                            \
    288                 (head)->tqh_last = &(elm)->field.tqe_next;              \
    289         (head)->tqh_first = (elm);                                      \
    290         (elm)->field.tqe_prev = &(head)->tqh_first;                     \
    291 }
    292 
    293 #define TAILQ_INSERT_TAIL(head, elm, field) {                           \
    294         (elm)->field.tqe_next = NULL;                                   \
     445                (head)->tqh_last = &TAILQ_NEXT((elm), field);           \
     446        TAILQ_FIRST((head)) = (elm);                                    \
     447        (elm)->field.tqe_prev = &TAILQ_FIRST((head));                   \
     448        QMD_TRACE_HEAD(head);                                           \
     449        QMD_TRACE_ELEM(&(elm)->field);                                  \
     450} while (0)
     451
     452#define TAILQ_INSERT_TAIL(head, elm, field) do {                        \
     453        TAILQ_NEXT((elm), field) = NULL;                                \
    295454        (elm)->field.tqe_prev = (head)->tqh_last;                       \
    296455        *(head)->tqh_last = (elm);                                      \
    297         (head)->tqh_last = &(elm)->field.tqe_next;                      \
    298 }
    299 
    300 #define TAILQ_INSERT_AFTER(head, listelm, elm, field) {                 \
    301         if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
    302                 (elm)->field.tqe_next->field.tqe_prev =                 \
    303                     &(elm)->field.tqe_next;                             \
    304         else                                                            \
    305                 (head)->tqh_last = &(elm)->field.tqe_next;              \
    306         (listelm)->field.tqe_next = (elm);                              \
    307         (elm)->field.tqe_prev = &(listelm)->field.tqe_next;             \
    308 }
    309 
    310 #define TAILQ_INSERT_BEFORE(listelm, elm, field) {                      \
    311         (elm)->field.tqe_prev = (listelm)->field.tqe_prev;              \
    312         (elm)->field.tqe_next = (listelm);                              \
    313         *(listelm)->field.tqe_prev = (elm);                             \
    314         (listelm)->field.tqe_prev = &(elm)->field.tqe_next;             \
    315 }
    316 
    317 #define TAILQ_REMOVE(head, elm, field) {                                \
    318         if (((elm)->field.tqe_next) != NULL)                            \
    319                 (elm)->field.tqe_next->field.tqe_prev =                 \
     456        (head)->tqh_last = &TAILQ_NEXT((elm), field);                   \
     457        QMD_TRACE_HEAD(head);                                           \
     458        QMD_TRACE_ELEM(&(elm)->field);                                  \
     459} while (0)
     460
     461#define TAILQ_LAST(head, headname)                                      \
     462        (*(((struct headname *)((head)->tqh_last))->tqh_last))
     463
     464#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
     465
     466#define TAILQ_PREV(elm, headname, field)                                \
     467        (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
     468
     469#define TAILQ_REMOVE(head, elm, field) do {                             \
     470        if ((TAILQ_NEXT((elm), field)) != NULL)                         \
     471                TAILQ_NEXT((elm), field)->field.tqe_prev =              \
    320472                    (elm)->field.tqe_prev;                              \
    321         else                                                            \
     473        else {                                                          \
    322474                (head)->tqh_last = (elm)->field.tqe_prev;               \
    323         *(elm)->field.tqe_prev = (elm)->field.tqe_next;                 \
    324 }
     475                QMD_TRACE_HEAD(head);                                   \
     476        }                                                               \
     477        *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field);              \
     478        TRASHIT((elm)->field.tqe_next);                                 \
     479        TRASHIT((elm)->field.tqe_prev);                                 \
     480        QMD_TRACE_ELEM(&(elm)->field);                                  \
     481} while (0)
     482
    325483
    326484/*
     
    414572#ifdef  __GNUC__
    415573
    416 #if (defined(__GNUC__) && defined(__arm__))
    417574static __inline void
    418575insque(void *a, void *b)
    419576{
    420         struct quehead *element;
    421         struct quehead *head;
    422     element = (struct quehead *) (((unsigned int) a + 0x3) & ~0x3);
    423     head = (struct quehead *) (((unsigned int) b + 0x3) & ~0x3);
     577        struct quehead *element = (struct quehead *)a,
     578                 *head = (struct quehead *)b;
    424579
    425580        element->qh_link = head->qh_link;
     
    432587remque(void *a)
    433588{
    434         struct quehead *element;
    435 
    436     element = (struct quehead *) (((unsigned int) a + 0x3) & ~0x3);
     589        struct quehead *element = (struct quehead *)a;
    437590
    438591        element->qh_link->qh_rlink = element->qh_rlink;
     
    441594}
    442595
    443 #else /*if (defined(__GNUC__) && defined(__arm__))*/
    444 
    445 static __inline void
    446 insque(void *a, void *b)
    447 {
    448         struct quehead *element = a, *head = b;
    449 
    450         element->qh_link = head->qh_link;
    451         element->qh_rlink = head;
    452         head->qh_link = element;
    453         element->qh_link->qh_rlink = element;
    454 }
    455 
    456 static __inline void
    457 remque(void *a)
    458 {
    459         struct quehead *element = a;
    460 
    461         element->qh_link->qh_rlink = element->qh_rlink;
    462         element->qh_rlink->qh_link = element->qh_link;
    463         element->qh_rlink = 0;
    464 }
    465 #endif /*if-else (defined(__GNUC__) && defined(__arm__))*/
    466 
    467596#else /* !__GNUC__ */
    468597
    469 void    insque __P((void *a, void *b));
    470 void    remque __P((void *a));
     598void    insque(void *a, void *b);
     599void    remque(void *a);
    471600
    472601#endif /* __GNUC__ */
    473602
    474 #endif /* KERNEL */
     603#endif /* _KERNEL */
    475604
    476605#endif /* !_SYS_QUEUE_H_ */
  • cpukit/libnetworking/sys/sysctl.h

    r5bb1a93c r36799d4  
    3535 *
    3636 *      @(#)sysctl.h    8.1 (Berkeley) 6/2/93
    37  * $Id$
     37 * $FreeBSD: src/sys/sys/sysctl.h,v 1.110 2002/10/20 22:48:08 phk Exp $
    3838 */
    3939
     
    4141#define _SYS_SYSCTL_H_
    4242
     43#include <sys/queue.h>
     44
     45struct thread;
    4346/*
    4447 * Definitions for sysctl call.  The sysctl call uses a hierarchical name
     
    7174#define CTLTYPE_OPAQUE  5       /* name describes a structure */
    7275#define CTLTYPE_STRUCT  CTLTYPE_OPAQUE  /* name describes a structure */
     76#define CTLTYPE_UINT    6       /* name describes an unsigned integer */
     77#define CTLTYPE_LONG    7       /* name describes a long */
     78#define CTLTYPE_ULONG   8       /* name describes an unsigned long */
    7379
    7480#define CTLFLAG_RD      0x80000000      /* Allow reads of variable */
     
    7783#define CTLFLAG_NOLOCK  0x20000000      /* XXX Don't Lock */
    7884#define CTLFLAG_ANYBODY 0x10000000      /* All users can set this var */
     85#define CTLFLAG_SECURE  0x08000000      /* Permit set only if securelevel<=0 */
     86#define CTLFLAG_PRISON  0x04000000      /* Prisoned roots can fiddle */
     87#define CTLFLAG_DYN     0x02000000      /* Dynamic oid - can be freed */
     88#define CTLFLAG_SKIP    0x01000000      /* Skip this sysctl when listing */
    7989
    8090/*
     
    8292 * to get dynamically assigned sysctl entries using the linker-set
    8393 * technology. This is the way nearly all new sysctl variables should
    84  * be implimented.
     94 * be implemented.
    8595 * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, "");
    8696 */
    8797#define OID_AUTO        (-1)
    8898
     99/*
     100 * The starting number for dynamically-assigned entries.  WARNING!
     101 * ALL static sysctl entries should have numbers LESS than this!
     102 */
     103#define CTL_AUTO_START  0x100
     104
    89105#ifdef KERNEL
    90 #define SYSCTL_HANDLER_ARGS (struct sysctl_oid *oidp, void *arg1, int arg2, \
    91         struct sysctl_req *req)
     106#define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, int arg2, \
     107        struct sysctl_req *req
    92108
    93109/*
     
    96112 */
    97113struct sysctl_req {
    98         struct proc     *p;
     114        struct thread   *td;            /* used for access checking */
    99115        int             lock;
    100116        void            *oldptr;
    101         int             oldlen;
    102         int             oldidx;
    103         int             (*oldfunc)(struct sysctl_req *, const void *, int);
     117        size_t          oldlen;
     118        size_t          oldidx;
     119        int             (*oldfunc)(struct sysctl_req *, const void *, size_t);
    104120        void            *newptr;
    105         int             newlen;
    106         int             newidx;
    107         int             (*newfunc)(struct sysctl_req *, void *, int);
     121        size_t          newlen;
     122        size_t          newidx;
     123        int             (*newfunc)(struct sysctl_req *, void *, size_t);
    108124};
     125
     126SLIST_HEAD(sysctl_oid_list, sysctl_oid);
    109127
    110128/*
     
    113131 */
    114132struct sysctl_oid {
     133        struct sysctl_oid_list *oid_parent;
     134        SLIST_ENTRY(sysctl_oid) oid_link;
    115135        int             oid_number;
    116         int             oid_kind;
     136        u_int           oid_kind;
    117137        void            *oid_arg1;
    118138        int             oid_arg2;
    119139        const char      *oid_name;
    120         int             (*oid_handler) SYSCTL_HANDLER_ARGS;
     140        int             (*oid_handler)(SYSCTL_HANDLER_ARGS);
    121141        const char      *oid_fmt;
     142        int             oid_refcnt;
     143        const char      *descr;
    122144};
    123145
    124 #define SYSCTL_IN(r, p, l)
    125 #define SYSCTL_OUT(r, p, l)
    126 
    127 int sysctl_handle_int SYSCTL_HANDLER_ARGS;
    128 int sysctl_handle_string SYSCTL_HANDLER_ARGS;
    129 int sysctl_handle_opaque SYSCTL_HANDLER_ARGS;
    130 
    131 /* This is the "raw" function for a mib-oid */
    132 #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr)
    133 
    134 /* This makes a node from which other oids can hang */
    135 #define SYSCTL_NODE(parent, nbr, name, access, handler, descr)
    136 
    137 /* This is a string len can be 0 to indicate '\0' termination */
    138 #define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr)
    139 
    140 /* This is a integer, if ptr is NULL, val is returned */
    141 #define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr)
    142 
    143 /* This is anything, specified by a pointer and a lenth */
    144 #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr)
    145 
    146 /* This is a struct, specified by a pointer and type */
    147 #define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr)
    148 
    149 /* Needs a proc.  Specify by pointer and arg */
    150 #define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr)
     146#define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l)
     147#define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l)
     148
     149int sysctl_handle_int(SYSCTL_HANDLER_ARGS);
     150int sysctl_handle_long(SYSCTL_HANDLER_ARGS);
     151int sysctl_handle_intptr(SYSCTL_HANDLER_ARGS);
     152int sysctl_handle_string(SYSCTL_HANDLER_ARGS);
     153int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS);
     154
     155/*
     156 * These functions are used to add/remove an oid from the mib.
     157 */
     158void sysctl_register_oid(struct sysctl_oid *oidp);
     159void sysctl_unregister_oid(struct sysctl_oid *oidp);
     160
     161/* Declare a static oid to allow child oids to be added to it. */
     162#define SYSCTL_DECL(name)                                       \
     163        extern struct sysctl_oid_list sysctl_##name##_children
     164
     165/* Hide these in macros */
     166#define SYSCTL_CHILDREN(oid_ptr) (struct sysctl_oid_list *) \
     167        (oid_ptr)->oid_arg1
     168#define SYSCTL_STATIC_CHILDREN(oid_name) \
     169        (&sysctl_##oid_name##_children)
     170
     171/* === Structs and macros related to context handling === */
     172
     173/* All dynamically created sysctls can be tracked in a context list. */
     174struct sysctl_ctx_entry {
     175        struct sysctl_oid *entry;
     176        TAILQ_ENTRY(sysctl_ctx_entry) link;
     177};
     178
     179TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
     180
     181/* This constructs a "raw" MIB oid. */
     182#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
     183        static struct sysctl_oid sysctl__##parent##_##name = {           \
     184                &sysctl_##parent##_children, { 0 },                      \
     185                nbr, kind, a1, a2, #name, handler, fmt, 0, descr };      \
     186        DATA_SET(sysctl_set, sysctl__##parent##_##name)
     187
     188#define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
     189        sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr)
     190
     191/* This constructs a node from which other oids can hang. */
     192#define SYSCTL_NODE(parent, nbr, name, access, handler, descr)              \
     193        struct sysctl_oid_list sysctl_##parent##_##name##_children;         \
     194        SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|(access),                \
     195                   (void*)&sysctl_##parent##_##name##_children, 0, handler, \
     196                   "N", descr)
     197
     198#define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr)     \
     199        sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access),       \
     200        0, 0, handler, "N", descr)
     201
     202/* Oid for a string.  len can be 0 to indicate '\0' termination. */
     203#define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \
     204        SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), \
     205                arg, len, sysctl_handle_string, "A", descr)
     206
     207#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr)  \
     208        sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access),     \
     209        arg, len, sysctl_handle_string, "A", descr)
     210
     211/* Oid for an int.  If ptr is NULL, val is returned. */
     212#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \
     213        SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|(access), \
     214                ptr, val, sysctl_handle_int, "I", descr)
     215
     216#define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr)     \
     217        sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|(access),        \
     218        ptr, val, sysctl_handle_int, "I", descr)
     219
     220/* Oid for an unsigned int.  If ptr is NULL, val is returned. */
     221#define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \
     222        SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|(access), \
     223                ptr, val, sysctl_handle_int, "IU", descr)
     224
     225#define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr)    \
     226        sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access),       \
     227        ptr, val, sysctl_handle_int, "IU", descr)
     228
     229/* Oid for a long.  The pointer must be non NULL. */
     230#define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \
     231        SYSCTL_OID(parent, nbr, name, CTLTYPE_LONG|(access), \
     232                ptr, val, sysctl_handle_long, "L", descr)
     233
     234#define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr)         \
     235        sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|(access),       \
     236        ptr, 0, sysctl_handle_long, "L", descr)
     237
     238/* Oid for a long.  The pointer must be non NULL. */
     239#define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr) \
     240        SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|(access), \
     241                ptr, val, sysctl_handle_long, "LU", descr)
     242
     243#define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr)        \
     244        sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|(access),      \
     245        ptr, 0, sysctl_handle_long, "LU", descr)
     246
     247/* Oid for an opaque object.  Specified by a pointer and a length. */
     248#define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \
     249        SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \
     250                ptr, len, sysctl_handle_opaque, fmt, descr)
     251
     252#define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr)\
     253        sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access),     \
     254        ptr, len, sysctl_handle_opaque, fmt, descr)
     255
     256/* Oid for a struct.  Specified by a pointer and a type. */
     257#define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \
     258        SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \
     259                ptr, sizeof(struct type), sysctl_handle_opaque, \
     260                "S," #type, descr)
     261
     262#define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \
     263        sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access),     \
     264        ptr, sizeof(struct type), sysctl_handle_opaque, "S," #type, descr)
     265
     266/* Oid for a procedure.  Specified by a pointer and an arg. */
     267#define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
     268        SYSCTL_OID(parent, nbr, name, (access), \
     269                ptr, arg, handler, fmt, descr)
     270
     271#define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
     272        sysctl_add_oid(ctx, parent, nbr, name, (access),                            \
     273        ptr, arg, handler, fmt, descr)
     274
    151275#endif /* KERNEL */
    152276
     
    157281#define CTL_KERN        1               /* "high kernel": proc, limits */
    158282#define CTL_VM          2               /* virtual memory */
    159 #define CTL_VFS         3               /* file system, mount type is next */
     283#define CTL_VFS         3               /* filesystem, mount type is next */
    160284#define CTL_NET         4               /* network, see socket.h */
    161285#define CTL_DEBUG       5               /* debugging parameters */
     
    163287#define CTL_MACHDEP     7               /* machine dependent */
    164288#define CTL_USER        8               /* user-level */
    165 #define CTL_MAXID       9               /* number of valid top-level ids */
     289#define CTL_P1003_1B    9               /* POSIX 1003.1B */
     290#define CTL_MAXID       10              /* number of valid top-level ids */
    166291
    167292#define CTL_NAMES { \
     
    175300        { "machdep", CTLTYPE_NODE }, \
    176301        { "user", CTLTYPE_NODE }, \
     302        { "p1003_1b", CTLTYPE_NODE }, \
    177303}
    178304
     
    209335#define KERN_MAXPROCPERUID      28      /* int: max processes per uid */
    210336#define KERN_DUMPDEV            29      /* dev_t: device to dump on */
    211 #define KERN_SOMAXCONN          30      /* int: max connections in listen q */
    212 #define KERN_MAXSOCKBUF         31      /* int: max size of a socket buffer */
     337#define KERN_IPC                30      /* node: anything related to IPC */
     338#define KERN_DUMMY              31      /* unused */
    213339#define KERN_PS_STRINGS         32      /* int: address of PS_STRINGS */
    214340#define KERN_USRSTACK           33      /* int: address of USRSTACK */
    215 #define KERN_MAXID              34      /* number of valid kern ids */
     341#define KERN_LOGSIGEXIT         34      /* int: do we log sigexit procs? */
     342#define KERN_IOV_MAX            35      /* int: value of UIO_MAXIOV */
     343#define KERN_MAXID              36      /* number of valid kern ids */
    216344
    217345#define CTL_KERN_NAMES { \
     
    227355        { "securelevel", CTLTYPE_INT }, \
    228356        { "hostname", CTLTYPE_STRING }, \
    229         { "hostid", CTLTYPE_INT }, \
     357        { "hostid", CTLTYPE_UINT }, \
    230358        { "clockrate", CTLTYPE_STRUCT }, \
    231359        { "vnode", CTLTYPE_STRUCT }, \
     
    241369        { "update", CTLTYPE_INT }, \
    242370        { "osreldate", CTLTYPE_INT }, \
    243         { "ntp_pll", CTLTYPE_NODE }, \
     371        { "ntp_pll", CTLTYPE_NODE }, \
    244372        { "bootfile", CTLTYPE_STRING }, \
    245373        { "maxfilesperproc", CTLTYPE_INT }, \
    246374        { "maxprocperuid", CTLTYPE_INT }, \
    247         { "dumpdev", CTLTYPE_STRUCT }, /* we lie; don't print as int */ \
    248         { "somaxconn", CTLTYPE_INT }, \
    249         { "maxsockbuf", CTLTYPE_INT }, \
     375        { "ipc", CTLTYPE_NODE }, \
     376        { "dummy", CTLTYPE_INT }, \
    250377        { "ps_strings", CTLTYPE_INT }, \
    251378        { "usrstack", CTLTYPE_INT }, \
     379        { "logsigexit", CTLTYPE_INT }, \
     380        { "iov_max", CTLTYPE_INT }, \
    252381}
    253382
     
    255384 * CTL_VFS identifiers
    256385 */
    257 #define VFS_VFSCONF             0       /* get configured filesystems */
    258 #define VFS_MAXID               1       /* number of items */
    259 
    260386#define CTL_VFS_NAMES { \
    261387        { "vfsconf", CTLTYPE_STRUCT }, \
     
    272398#define KERN_PROC_UID           5       /* by effective uid */
    273399#define KERN_PROC_RUID          6       /* by real uid */
     400#define KERN_PROC_ARGS          7       /* get/set arguments/proctitle */
     401
     402/*
     403 * KERN_IPC identifiers
     404 */
     405#define KIPC_MAXSOCKBUF         1       /* int: max size of a socket buffer */
     406#define KIPC_SOCKBUF_WASTE      2       /* int: wastage factor in sockbuf */
     407#define KIPC_SOMAXCONN          3       /* int: max length of connection q */
     408#define KIPC_MAX_LINKHDR        4       /* int: max length of link header */
     409#define KIPC_MAX_PROTOHDR       5       /* int: max length of network header */
     410#define KIPC_MAX_HDR            6       /* int: max total length of headers */
     411#define KIPC_MAX_DATALEN        7       /* int: max length of data? */
    274412
    275413/*
     
    295433        { "ncpu", CTLTYPE_INT }, \
    296434        { "byteorder", CTLTYPE_INT }, \
    297         { "physmem", CTLTYPE_INT }, \
    298         { "usermem", CTLTYPE_INT }, \
     435        { "physmem", CTLTYPE_ULONG }, \
     436        { "usermem", CTLTYPE_ULONG }, \
    299437        { "pagesize", CTLTYPE_INT }, \
    300438        { "disknames", CTLTYPE_STRUCT }, \
     
    352490}
    353491
     492#define CTL_P1003_1B_ASYNCHRONOUS_IO            1       /* boolean */
     493#define CTL_P1003_1B_MAPPED_FILES               2       /* boolean */
     494#define CTL_P1003_1B_MEMLOCK                    3       /* boolean */
     495#define CTL_P1003_1B_MEMLOCK_RANGE              4       /* boolean */
     496#define CTL_P1003_1B_MEMORY_PROTECTION          5       /* boolean */
     497#define CTL_P1003_1B_MESSAGE_PASSING            6       /* boolean */
     498#define CTL_P1003_1B_PRIORITIZED_IO             7       /* boolean */
     499#define CTL_P1003_1B_PRIORITY_SCHEDULING        8       /* boolean */
     500#define CTL_P1003_1B_REALTIME_SIGNALS           9       /* boolean */
     501#define CTL_P1003_1B_SEMAPHORES                 10      /* boolean */
     502#define CTL_P1003_1B_FSYNC                      11      /* boolean */
     503#define CTL_P1003_1B_SHARED_MEMORY_OBJECTS      12      /* boolean */
     504#define CTL_P1003_1B_SYNCHRONIZED_IO            13      /* boolean */
     505#define CTL_P1003_1B_TIMERS                     14      /* boolean */
     506#define CTL_P1003_1B_AIO_LISTIO_MAX             15      /* int */
     507#define CTL_P1003_1B_AIO_MAX                    16      /* int */
     508#define CTL_P1003_1B_AIO_PRIO_DELTA_MAX         17      /* int */
     509#define CTL_P1003_1B_DELAYTIMER_MAX             18      /* int */
     510#define CTL_P1003_1B_MQ_OPEN_MAX                19      /* int */
     511#define CTL_P1003_1B_PAGESIZE                   20      /* int */
     512#define CTL_P1003_1B_RTSIG_MAX                  21      /* int */
     513#define CTL_P1003_1B_SEM_NSEMS_MAX              22      /* int */
     514#define CTL_P1003_1B_SEM_VALUE_MAX              23      /* int */
     515#define CTL_P1003_1B_SIGQUEUE_MAX               24      /* int */
     516#define CTL_P1003_1B_TIMER_MAX                  25      /* int */
     517
     518#define CTL_P1003_1B_MAXID              26
     519
     520#define CTL_P1003_1B_NAMES { \
     521        { 0, 0 }, \
     522        { "asynchronous_io", CTLTYPE_INT }, \
     523        { "mapped_files", CTLTYPE_INT }, \
     524        { "memlock", CTLTYPE_INT }, \
     525        { "memlock_range", CTLTYPE_INT }, \
     526        { "memory_protection", CTLTYPE_INT }, \
     527        { "message_passing", CTLTYPE_INT }, \
     528        { "prioritized_io", CTLTYPE_INT }, \
     529        { "priority_scheduling", CTLTYPE_INT }, \
     530        { "realtime_signals", CTLTYPE_INT }, \
     531        { "semaphores", CTLTYPE_INT }, \
     532        { "fsync", CTLTYPE_INT }, \
     533        { "shared_memory_objects", CTLTYPE_INT }, \
     534        { "synchronized_io", CTLTYPE_INT }, \
     535        { "timers", CTLTYPE_INT }, \
     536        { "aio_listio_max", CTLTYPE_INT }, \
     537        { "aio_max", CTLTYPE_INT }, \
     538        { "aio_prio_delta_max", CTLTYPE_INT }, \
     539        { "delaytimer_max", CTLTYPE_INT }, \
     540        { "mq_open_max", CTLTYPE_INT }, \
     541        { "pagesize", CTLTYPE_INT }, \
     542        { "rtsig_max", CTLTYPE_INT }, \
     543        { "nsems_max", CTLTYPE_INT }, \
     544        { "sem_value_max", CTLTYPE_INT }, \
     545        { "sigqueue_max", CTLTYPE_INT }, \
     546        { "timer_max", CTLTYPE_INT }, \
     547}
     548
    354549#ifdef KERNEL
    355550
    356 extern char     cpu_model[];
     551/*
     552 * Declare some common oids.
     553 */
     554extern struct sysctl_oid_list sysctl__children;
     555SYSCTL_DECL(_kern);
     556SYSCTL_DECL(_sysctl);
     557SYSCTL_DECL(_vm);
     558SYSCTL_DECL(_vfs);
     559SYSCTL_DECL(_net);
     560SYSCTL_DECL(_debug);
     561SYSCTL_DECL(_debug_sizeof);
     562SYSCTL_DECL(_hw);
     563SYSCTL_DECL(_machdep);
     564SYSCTL_DECL(_user);
     565SYSCTL_DECL(_compat);
     566
    357567extern char     machine[];
    358568extern char     osrelease[];
    359569extern char     ostype[];
    360570
    361 int kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *oldlenp, void *new, size_t newlen, int *retval);
    362 int userland_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *oldlenp, int inkernel, void *new, size_t newlen, int *retval);
    363 /*
    364 int     sysctl_clockrate __P((char *, size_t*));
    365 int     sysctl_file __P((char *, size_t*));
    366 int     sysctl_doproc __P((int *, u_int, char *, size_t*));
    367 int     sysctl_doprof __P((int *, u_int, void *, size_t *, void *, size_t));
    368 */
     571/* Dynamic oid handling */
     572struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist,
     573                struct sysctl_oid_list *parent, int nbr, const char *name,
     574                int kind, void *arg1, int arg2,
     575                int (*handler) (SYSCTL_HANDLER_ARGS),
     576                const char *fmt, const char *descr);
     577int     sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse);
     578int     sysctl_ctx_init(struct sysctl_ctx_list *clist);
     579int     sysctl_ctx_free(struct sysctl_ctx_list *clist);
     580struct  sysctl_ctx_entry *sysctl_ctx_entry_add(struct sysctl_ctx_list *clist,
     581                struct sysctl_oid *oidp);
     582struct  sysctl_ctx_entry *sysctl_ctx_entry_find(struct sysctl_ctx_list *clist,
     583                struct sysctl_oid *oidp);
     584int     sysctl_ctx_entry_del(struct sysctl_ctx_list *clist,
     585                struct sysctl_oid *oidp);
     586
     587int     kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
     588                      size_t *oldlenp, void *new, size_t newlen,
     589                      size_t *retval);
     590int     kernel_sysctlbyname(struct thread *td, char *name,
     591                void *old, size_t *oldlenp, void *new, size_t newlen,
     592                size_t *retval);
     593int     userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
     594                        size_t *oldlenp, int inkernel, void *new, size_t newlen,
     595                        size_t *retval);
     596int     sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid,
     597                        int *nindx, struct sysctl_req *req);
     598void    sysctl_wire_old_buffer(struct sysctl_req *req, size_t len);
    369599
    370600#else   /* !KERNEL */
     
    372602
    373603__BEGIN_DECLS
    374 int     sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
    375 int     sysctlbyname __P((const char *, void *, size_t *, void *, size_t));
     604int     sysctl(int *, u_int, void *, size_t *, void *, size_t);
     605int     sysctlbyname(const char *, void *, size_t *, void *, size_t);
     606int     sysctlnametomib(const char *, int *, size_t *);
    376607__END_DECLS
    377608#endif  /* KERNEL */
Note: See TracChangeset for help on using the changeset viewer.