Annotation of 43BSDTahoe/sys/h/protosw.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1982, 1986 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted
                      6:  * provided that the above copyright notice and this paragraph are
                      7:  * duplicated in all such forms and that any documentation,
                      8:  * advertising materials, and other materials related to such
                      9:  * distribution and use acknowledge that the software was developed
                     10:  * by the University of California, Berkeley.  The name of the
                     11:  * University may not be used to endorse or promote products derived
                     12:  * from this software without specific prior written permission.
                     13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     16:  *
                     17:  *     @(#)protosw.h   7.3 (Berkeley) 6/27/88
                     18:  */
                     19: 
                     20: /*
                     21:  * Protocol switch table.
                     22:  *
                     23:  * Each protocol has a handle initializing one of these structures,
                     24:  * which is used for protocol-protocol and system-protocol communication.
                     25:  *
                     26:  * A protocol is called through the pr_init entry before any other.
                     27:  * Thereafter it is called every 200ms through the pr_fasttimo entry and
                     28:  * every 500ms through the pr_slowtimo for timer based actions.
                     29:  * The system will call the pr_drain entry if it is low on space and
                     30:  * this should throw away any non-critical data.
                     31:  *
                     32:  * Protocols pass data between themselves as chains of mbufs using
                     33:  * the pr_input and pr_output hooks.  Pr_input passes data up (towards
                     34:  * UNIX) and pr_output passes it down (towards the imps); control
                     35:  * information passes up and down on pr_ctlinput and pr_ctloutput.
                     36:  * The protocol is responsible for the space occupied by any the
                     37:  * arguments to these entries and must dispose it.
                     38:  *
                     39:  * The userreq routine interfaces protocols to the system and is
                     40:  * described below.
                     41:  */
                     42: struct protosw {
                     43:        short   pr_type;                /* socket type used for */
                     44:        struct  domain *pr_domain;      /* domain protocol a member of */
                     45:        short   pr_protocol;            /* protocol number */
                     46:        short   pr_flags;               /* see below */
                     47: /* protocol-protocol hooks */
                     48:        int     (*pr_input)();          /* input to protocol (from below) */
                     49:        int     (*pr_output)();         /* output to protocol (from above) */
                     50:        int     (*pr_ctlinput)();       /* control input (from below) */
                     51:        int     (*pr_ctloutput)();      /* control output (from above) */
                     52: /* user-protocol hook */
                     53:        int     (*pr_usrreq)();         /* user request: see list below */
                     54: /* utility hooks */
                     55:        int     (*pr_init)();           /* initialization hook */
                     56:        int     (*pr_fasttimo)();       /* fast timeout (200ms) */
                     57:        int     (*pr_slowtimo)();       /* slow timeout (500ms) */
                     58:        int     (*pr_drain)();          /* flush any excess space possible */
                     59: };
                     60: 
                     61: #define        PR_SLOWHZ       2               /* 2 slow timeouts per second */
                     62: #define        PR_FASTHZ       5               /* 5 fast timeouts per second */
                     63: 
                     64: /*
                     65:  * Values for pr_flags
                     66:  */
                     67: #define        PR_ATOMIC       0x01            /* exchange atomic messages only */
                     68: #define        PR_ADDR         0x02            /* addresses given with messages */
                     69: /* in the current implementation, PR_ADDR needs PR_ATOMIC to work */
                     70: #define        PR_CONNREQUIRED 0x04            /* connection required by protocol */
                     71: #define        PR_WANTRCVD     0x08            /* want PRU_RCVD calls */
                     72: #define        PR_RIGHTS       0x10            /* passes capabilities */
                     73: 
                     74: /*
                     75:  * The arguments to usrreq are:
                     76:  *     (*protosw[].pr_usrreq)(up, req, m, nam, opt);
                     77:  * where up is a (struct socket *), req is one of these requests,
                     78:  * m is a optional mbuf chain containing a message,
                     79:  * nam is an optional mbuf chain containing an address,
                     80:  * and opt is a pointer to a socketopt structure or nil.
                     81:  * The protocol is responsible for disposal of the mbuf chain m,
                     82:  * the caller is responsible for any space held by nam and opt.
                     83:  * A non-zero return from usrreq gives an
                     84:  * UNIX error number which should be passed to higher level software.
                     85:  */
                     86: #define        PRU_ATTACH              0       /* attach protocol to up */
                     87: #define        PRU_DETACH              1       /* detach protocol from up */
                     88: #define        PRU_BIND                2       /* bind socket to address */
                     89: #define        PRU_LISTEN              3       /* listen for connection */
                     90: #define        PRU_CONNECT             4       /* establish connection to peer */
                     91: #define        PRU_ACCEPT              5       /* accept connection from peer */
                     92: #define        PRU_DISCONNECT          6       /* disconnect from peer */
                     93: #define        PRU_SHUTDOWN            7       /* won't send any more data */
                     94: #define        PRU_RCVD                8       /* have taken data; more room now */
                     95: #define        PRU_SEND                9       /* send this data */
                     96: #define        PRU_ABORT               10      /* abort (fast DISCONNECT, DETATCH) */
                     97: #define        PRU_CONTROL             11      /* control operations on protocol */
                     98: #define        PRU_SENSE               12      /* return status into m */
                     99: #define        PRU_RCVOOB              13      /* retrieve out of band data */
                    100: #define        PRU_SENDOOB             14      /* send out of band data */
                    101: #define        PRU_SOCKADDR            15      /* fetch socket's address */
                    102: #define        PRU_PEERADDR            16      /* fetch peer's address */
                    103: #define        PRU_CONNECT2            17      /* connect two sockets */
                    104: /* begin for protocols internal use */
                    105: #define        PRU_FASTTIMO            18      /* 200ms timeout */
                    106: #define        PRU_SLOWTIMO            19      /* 500ms timeout */
                    107: #define        PRU_PROTORCV            20      /* receive from below */
                    108: #define        PRU_PROTOSEND           21      /* send to below */
                    109: 
                    110: #define        PRU_NREQ                21
                    111: 
                    112: #ifdef PRUREQUESTS
                    113: char *prurequests[] = {
                    114:        "ATTACH",       "DETACH",       "BIND",         "LISTEN",
                    115:        "CONNECT",      "ACCEPT",       "DISCONNECT",   "SHUTDOWN",
                    116:        "RCVD",         "SEND",         "ABORT",        "CONTROL",
                    117:        "SENSE",        "RCVOOB",       "SENDOOB",      "SOCKADDR",
                    118:        "PEERADDR",     "CONNECT2",     "FASTTIMO",     "SLOWTIMO",
                    119:        "PROTORCV",     "PROTOSEND",
                    120: };
                    121: #endif
                    122: 
                    123: /*
                    124:  * The arguments to the ctlinput routine are
                    125:  *     (*protosw[].pr_ctlinput)(cmd, arg);
                    126:  * where cmd is one of the commands below, and arg is
                    127:  * an optional argument (caddr_t).
                    128:  *
                    129:  * N.B. The IMP code, in particular, pressumes the values
                    130:  *      of some of the commands; change with extreme care.
                    131:  * TODO:
                    132:  *     spread out codes so new ICMP codes can be
                    133:  *     accomodated more easily
                    134:  */
                    135: #define        PRC_IFDOWN              0       /* interface transition */
                    136: #define        PRC_ROUTEDEAD           1       /* select new route if possible */
                    137: #define        PRC_QUENCH              4       /* some said to slow down */
                    138: #define        PRC_MSGSIZE             5       /* message size forced drop */
                    139: #define        PRC_HOSTDEAD            6       /* normally from IMP */
                    140: #define        PRC_HOSTUNREACH         7       /* ditto */
                    141: #define        PRC_UNREACH_NET         8       /* no route to network */
                    142: #define        PRC_UNREACH_HOST        9       /* no route to host */
                    143: #define        PRC_UNREACH_PROTOCOL    10      /* dst says bad protocol */
                    144: #define        PRC_UNREACH_PORT        11      /* bad port # */
                    145: #define        PRC_UNREACH_NEEDFRAG    12      /* IP_DF caused drop */
                    146: #define        PRC_UNREACH_SRCFAIL     13      /* source route failed */
                    147: #define        PRC_REDIRECT_NET        14      /* net routing redirect */
                    148: #define        PRC_REDIRECT_HOST       15      /* host routing redirect */
                    149: #define        PRC_REDIRECT_TOSNET     16      /* redirect for type of service & net */
                    150: #define        PRC_REDIRECT_TOSHOST    17      /* redirect for tos & host */
                    151: #define        PRC_TIMXCEED_INTRANS    18      /* packet lifetime expired in transit */
                    152: #define        PRC_TIMXCEED_REASS      19      /* lifetime expired on reass q */
                    153: #define        PRC_PARAMPROB           20      /* header incorrect */
                    154: 
                    155: #define        PRC_NCMDS               21
                    156: 
                    157: #ifdef PRCREQUESTS
                    158: char   *prcrequests[] = {
                    159:        "IFDOWN", "ROUTEDEAD", "#2", "#3",
                    160:        "QUENCH", "MSGSIZE", "HOSTDEAD", "HOSTUNREACH",
                    161:        "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
                    162:        "FRAG-UNREACH", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
                    163:        "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
                    164:        "PARAMPROB"
                    165: };
                    166: #endif
                    167: 
                    168: /*
                    169:  * The arguments to ctloutput are:
                    170:  *     (*protosw[].pr_ctloutput)(req, so, level, optname, optval);
                    171:  * req is one of the actions listed below, so is a (struct socket *),
                    172:  * level is an indication of which protocol layer the option is intended.
                    173:  * optname is a protocol dependent socket option request,
                    174:  * optval is a pointer to a mbuf-chain pointer, for value-return results.
                    175:  * The protocol is responsible for disposal of the mbuf chain *optval
                    176:  * if supplied,
                    177:  * the caller is responsible for any space held by *optval, when returned.
                    178:  * A non-zero return from usrreq gives an
                    179:  * UNIX error number which should be passed to higher level software.
                    180:  */
                    181: #define        PRCO_GETOPT     0
                    182: #define        PRCO_SETOPT     1
                    183: 
                    184: #define        PRCO_NCMDS      2
                    185: 
                    186: #ifdef PRCOREQUESTS
                    187: char   *prcorequests[] = {
                    188:        "GETOPT", "SETOPT",
                    189: };
                    190: #endif
                    191: 
                    192: #ifdef KERNEL
                    193: extern struct protosw *pffindproto(), *pffindtype();
                    194: #endif

unix.superglobalmegacorp.com

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