Annotation of kernel/bsd/sys/protosw.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
                     26: /*-
                     27:  * Copyright (c) 1982, 1986, 1993
                     28:  *     The Regents of the University of California.  All rights reserved.
                     29:  *
                     30:  * Redistribution and use in source and binary forms, with or without
                     31:  * modification, are permitted provided that the following conditions
                     32:  * are met:
                     33:  * 1. Redistributions of source code must retain the above copyright
                     34:  *    notice, this list of conditions and the following disclaimer.
                     35:  * 2. Redistributions in binary form must reproduce the above copyright
                     36:  *    notice, this list of conditions and the following disclaimer in the
                     37:  *    documentation and/or other materials provided with the distribution.
                     38:  * 3. All advertising materials mentioning features or use of this software
                     39:  *    must display the following acknowledgement:
                     40:  *     This product includes software developed by the University of
                     41:  *     California, Berkeley and its contributors.
                     42:  * 4. Neither the name of the University nor the names of its contributors
                     43:  *    may be used to endorse or promote products derived from this software
                     44:  *    without specific prior written permission.
                     45:  *
                     46:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     47:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     48:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     49:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     50:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     51:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     52:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     53:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     54:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     55:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     56:  * SUCH DAMAGE.
                     57:  *
                     58:  *     @(#)protosw.h   8.1 (Berkeley) 6/2/93
                     59:  */
                     60: 
                     61: /*
                     62:  * Protocol switch table.
                     63:  *
                     64:  * Each protocol has a handle initializing one of these structures,
                     65:  * which is used for protocol-protocol and system-protocol communication.
                     66:  *
                     67:  * A protocol is called through the pr_init entry before any other.
                     68:  * Thereafter it is called every 200ms through the pr_fasttimo entry and
                     69:  * every 500ms through the pr_slowtimo for timer based actions.
                     70:  * The system will call the pr_drain entry if it is low on space and
                     71:  * this should throw away any non-critical data.
                     72:  *
                     73:  * Protocols pass data between themselves as chains of mbufs using
                     74:  * the pr_input and pr_output hooks.  Pr_input passes data up (towards
                     75:  * UNIX) and pr_output passes it down (towards the imps); control
                     76:  * information passes up and down on pr_ctlinput and pr_ctloutput.
                     77:  * The protocol is responsible for the space occupied by any the
                     78:  * arguments to these entries and must dispose it.
                     79:  *
                     80:  * The userreq routine interfaces protocols to the system and is
                     81:  * described below.
                     82:  */
                     83:  
                     84: #ifndef        _SYS_PROTOSW_H_
                     85: #define _SYS_PROTOSW_H_
                     86: 
                     87: 
                     88: struct protosw {
                     89:        short   pr_type;                /* socket type used for */
                     90:        struct  domain *pr_domain;      /* domain protocol a member of */
                     91:        short   pr_protocol;            /* protocol number */
                     92:        short   pr_flags;               /* see below */
                     93: /* protocol-protocol hooks */
                     94:        void    (*pr_input)();          /* input to protocol (from below) */
                     95:        int     (*pr_output)();         /* output to protocol (from above) */
                     96:        void    (*pr_ctlinput)();       /* control input (from below) */
                     97:        int     (*pr_ctloutput)();      /* control output (from above) */
                     98: /* user-protocol hook */
                     99:        int     (*pr_usrreq)();         /* user request: see list below */
                    100: /* utility hooks */
                    101:        void    (*pr_init)();           /* initialization hook */
                    102:        void    (*pr_fasttimo)();       /* fast timeout (200ms) */
                    103:        void    (*pr_slowtimo)();       /* slow timeout (500ms) */
                    104:        void    (*pr_drain)();          /* flush any excess space possible */
                    105:        int     (*pr_sysctl)();         /* sysctl for protocol */
                    106: };
                    107: 
                    108: #define        PR_SLOWHZ       2               /* 2 slow timeouts per second */
                    109: #define        PR_FASTHZ       5               /* 5 fast timeouts per second */
                    110: 
                    111: /*
                    112:  * Values for pr_flags.
                    113:  * PR_ADDR requires PR_ATOMIC;
                    114:  * PR_ADDR and PR_CONNREQUIRED are mutually exclusive.
                    115:  */
                    116: #define        PR_ATOMIC       0x01            /* exchange atomic messages only */
                    117: #define        PR_ADDR         0x02            /* addresses given with messages */
                    118: #define        PR_CONNREQUIRED 0x04            /* connection required by protocol */
                    119: #define        PR_WANTRCVD     0x08            /* want PRU_RCVD calls */
                    120: #define        PR_RIGHTS       0x10            /* passes capabilities */
                    121: 
                    122: /*
                    123:  * The arguments to usrreq are:
                    124:  *     (*protosw[].pr_usrreq)(up, req, m, nam, opt);
                    125:  * where up is a (struct socket *), req is one of these requests,
                    126:  * m is a optional mbuf chain containing a message,
                    127:  * nam is an optional mbuf chain containing an address,
                    128:  * and opt is a pointer to a socketopt structure or nil.
                    129:  * The protocol is responsible for disposal of the mbuf chain m,
                    130:  * the caller is responsible for any space held by nam and opt.
                    131:  * A non-zero return from usrreq gives an
                    132:  * UNIX error number which should be passed to higher level software.
                    133:  */
                    134: #define        PRU_ATTACH              0       /* attach protocol to up */
                    135: #define        PRU_DETACH              1       /* detach protocol from up */
                    136: #define        PRU_BIND                2       /* bind socket to address */
                    137: #define        PRU_LISTEN              3       /* listen for connection */
                    138: #define        PRU_CONNECT             4       /* establish connection to peer */
                    139: #define        PRU_ACCEPT              5       /* accept connection from peer */
                    140: #define        PRU_DISCONNECT          6       /* disconnect from peer */
                    141: #define        PRU_SHUTDOWN            7       /* won't send any more data */
                    142: #define        PRU_RCVD                8       /* have taken data; more room now */
                    143: #define        PRU_SEND                9       /* send this data */
                    144: #define        PRU_ABORT               10      /* abort (fast DISCONNECT, DETATCH) */
                    145: #define        PRU_CONTROL             11      /* control operations on protocol */
                    146: #define        PRU_SENSE               12      /* return status into m */
                    147: #define        PRU_RCVOOB              13      /* retrieve out of band data */
                    148: #define        PRU_SENDOOB             14      /* send out of band data */
                    149: #define        PRU_SOCKADDR            15      /* fetch socket's address */
                    150: #define        PRU_PEERADDR            16      /* fetch peer's address */
                    151: #define        PRU_CONNECT2            17      /* connect two sockets */
                    152: /* begin for protocols internal use */
                    153: #define        PRU_FASTTIMO            18      /* 200ms timeout */
                    154: #define        PRU_SLOWTIMO            19      /* 500ms timeout */
                    155: #define        PRU_PROTORCV            20      /* receive from below */
                    156: #define        PRU_PROTOSEND           21      /* send to below */
                    157: 
                    158: #define        PRU_NREQ                21
                    159: 
                    160: #ifdef PRUREQUESTS
                    161: char *prurequests[] = {
                    162:        "ATTACH",       "DETACH",       "BIND",         "LISTEN",
                    163:        "CONNECT",      "ACCEPT",       "DISCONNECT",   "SHUTDOWN",
                    164:        "RCVD",         "SEND",         "ABORT",        "CONTROL",
                    165:        "SENSE",        "RCVOOB",       "SENDOOB",      "SOCKADDR",
                    166:        "PEERADDR",     "CONNECT2",     "FASTTIMO",     "SLOWTIMO",
                    167:        "PROTORCV",     "PROTOSEND",
                    168: };
                    169: #endif
                    170: 
                    171: /*
                    172:  * The arguments to the ctlinput routine are
                    173:  *     (*protosw[].pr_ctlinput)(cmd, sa, arg);
                    174:  * where cmd is one of the commands below, sa is a pointer to a sockaddr,
                    175:  * and arg is an optional caddr_t argument used within a protocol family.
                    176:  */
                    177: #define        PRC_IFDOWN              0       /* interface transition */
                    178: #define        PRC_ROUTEDEAD           1       /* select new route if possible ??? */
                    179: #define        PRC_QUENCH2             3       /* DEC congestion bit says slow down */
                    180: #define        PRC_QUENCH              4       /* some one said to slow down */
                    181: #define        PRC_MSGSIZE             5       /* message size forced drop */
                    182: #define        PRC_HOSTDEAD            6       /* host appears to be down */
                    183: #define        PRC_HOSTUNREACH         7       /* deprecated (use PRC_UNREACH_HOST) */
                    184: #define        PRC_UNREACH_NET         8       /* no route to network */
                    185: #define        PRC_UNREACH_HOST        9       /* no route to host */
                    186: #define        PRC_UNREACH_PROTOCOL    10      /* dst says bad protocol */
                    187: #define        PRC_UNREACH_PORT        11      /* bad port # */
                    188: /* was PRC_UNREACH_NEEDFRAG    12         (use PRC_MSGSIZE) */
                    189: #define        PRC_UNREACH_SRCFAIL     13      /* source route failed */
                    190: #define        PRC_REDIRECT_NET        14      /* net routing redirect */
                    191: #define        PRC_REDIRECT_HOST       15      /* host routing redirect */
                    192: #define        PRC_REDIRECT_TOSNET     16      /* redirect for type of service & net */
                    193: #define        PRC_REDIRECT_TOSHOST    17      /* redirect for tos & host */
                    194: #define        PRC_TIMXCEED_INTRANS    18      /* packet lifetime expired in transit */
                    195: #define        PRC_TIMXCEED_REASS      19      /* lifetime expired on reass q */
                    196: #define        PRC_PARAMPROB           20      /* header incorrect */
                    197: 
                    198: #define        PRC_NCMDS               21
                    199: 
                    200: #define        PRC_IS_REDIRECT(cmd)    \
                    201:        ((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST)
                    202: 
                    203: #ifdef PRCREQUESTS
                    204: char   *prcrequests[] = {
                    205:        "IFDOWN", "ROUTEDEAD", "#2", "DEC-BIT-QUENCH2",
                    206:        "QUENCH", "MSGSIZE", "HOSTDEAD", "#7",
                    207:        "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
                    208:        "#12", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
                    209:        "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
                    210:        "PARAMPROB"
                    211: };
                    212: #endif
                    213: 
                    214: /*
                    215:  * The arguments to ctloutput are:
                    216:  *     (*protosw[].pr_ctloutput)(req, so, level, optname, optval);
                    217:  * req is one of the actions listed below, so is a (struct socket *),
                    218:  * level is an indication of which protocol layer the option is intended.
                    219:  * optname is a protocol dependent socket option request,
                    220:  * optval is a pointer to a mbuf-chain pointer, for value-return results.
                    221:  * The protocol is responsible for disposal of the mbuf chain *optval
                    222:  * if supplied,
                    223:  * the caller is responsible for any space held by *optval, when returned.
                    224:  * A non-zero return from usrreq gives an
                    225:  * UNIX error number which should be passed to higher level software.
                    226:  */
                    227: #define        PRCO_GETOPT     0
                    228: #define        PRCO_SETOPT     1
                    229: 
                    230: #define        PRCO_NCMDS      2
                    231: 
                    232: #ifdef PRCOREQUESTS
                    233: char   *prcorequests[] = {
                    234:        "GETOPT", "SETOPT",
                    235: };
                    236: #endif
                    237: 
                    238: #ifdef _KERNEL
                    239: extern struct protosw *pffindproto(), *pffindtype();
                    240: #endif
                    241: #endif /* !_SYS_PROTOSW_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.