Annotation of 42BSD/sys/h/protosw.h, revision 1.1

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

unix.superglobalmegacorp.com

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