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

Defined variables

prcorequests defined in line 176; never used
prcrequests defined in line 147; never used

Defined struct's

protosw defined in line 31; used 42 times

Defined macros

PRCO_GETOPT defined in line 170; used 1 times
PRCO_NCMDS defined in line 173; never used
PRC_HOSTDEAD defined in line 128; never used
PRC_HOSTUNREACH defined in line 129; never used
PRC_IFDOWN defined in line 124; used 1 times
PRC_MSGSIZE defined in line 127; used 1 times
PRC_QUENCH defined in line 126; used 2 times
PRC_REDIRECT_HOST defined in line 137; used 1 times
PRC_REDIRECT_NET defined in line 136; used 1 times
PRC_REDIRECT_TOSHOST defined in line 139; never used
PRC_REDIRECT_TOSNET defined in line 138; never used
PRC_ROUTEDEAD defined in line 125; never used
PRC_TIMXCEED_REASS defined in line 141; never used
PRC_UNREACH_HOST defined in line 131; never used
PRC_UNREACH_NEEDFRAG defined in line 134; never used
PRC_UNREACH_PORT defined in line 133; used 1 times
PRC_UNREACH_PROTOCOL defined in line 132; never used
PRC_UNREACH_SRCFAIL defined in line 135; never used
PRU_ABORT defined in line 85; used 1 times
PRU_ACCEPT defined in line 80; used 1 times
PRU_BIND defined in line 77; used 1 times
PRU_CONNECT defined in line 79; used 1 times
PRU_CONNECT2 defined in line 92; used 1 times
PRU_DETACH defined in line 76; used 1 times
PRU_DISCONNECT defined in line 81; used 1 times
PRU_FASTTIMO defined in line 94; never used
PRU_LISTEN defined in line 78; used 1 times
PRU_NREQ defined in line 99; never used
PRU_PEERADDR defined in line 91; used 1 times
PRU_PROTORCV defined in line 96; never used
PRU_PROTOSEND defined in line 97; never used
PRU_RCVD defined in line 83; used 1 times
PRU_RCVOOB defined in line 88; used 1 times
PRU_SEND defined in line 84; used 2 times
PRU_SENDOOB defined in line 89; used 1 times
PRU_SENSE defined in line 87; used 1 times
PRU_SHUTDOWN defined in line 82; used 1 times
PRU_SOCKADDR defined in line 90; used 1 times
PR_FASTHZ defined in line 51; never used

Usage of this include

protosw.h used 54 times
Last modified: 1986-06-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1668
Valid CSS Valid XHTML 1.0 Strict