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

Defined variables

prcorequests defined in line 180; never used
prcrequests defined in line 151; never used

Defined struct's

Defined macros

PRCO_GETOPT defined in line 174; used 1 times
PRCO_NCMDS defined in line 177; never used
PRC_HOSTDEAD defined in line 129; used 2 times
PRC_HOSTUNREACH defined in line 130; never used
PRC_IFDOWN defined in line 125; used 1 times
PRC_IS_REDIRECT defined in line 147; used 1 times
PRC_MSGSIZE defined in line 128; used 1 times
PRC_REDIRECT_HOST defined in line 138; used 1 times
PRC_REDIRECT_NET defined in line 137; used 2 times
PRC_REDIRECT_TOSHOST defined in line 140; used 1 times
PRC_REDIRECT_TOSNET defined in line 139; never used
PRC_ROUTEDEAD defined in line 126; never used
PRC_TIMXCEED_REASS defined in line 142; never used
PRC_UNREACH_HOST defined in line 132; never used
PRC_UNREACH_NEEDFRAG defined in line 135; never used
PRC_UNREACH_PORT defined in line 134; used 1 times
PRC_UNREACH_PROTOCOL defined in line 133; never used
PRC_UNREACH_SRCFAIL defined in line 136; never used
PRU_ABORT defined in line 92; used 1 times
PRU_ACCEPT defined in line 87; used 1 times
PRU_BIND defined in line 84; used 1 times
PRU_CONNECT defined in line 86; used 1 times
PRU_CONNECT2 defined in line 99; used 1 times
PRU_DETACH defined in line 83; used 1 times
PRU_DISCONNECT defined in line 88; used 1 times
PRU_FASTTIMO defined in line 101; used 1 times
PRU_LISTEN defined in line 85; used 1 times
PRU_NREQ defined in line 106; never used
PRU_PEERADDR defined in line 98; used 1 times
PRU_PROTORCV defined in line 103; never used
PRU_PROTOSEND defined in line 104; never used
PRU_RCVD defined in line 90; used 1 times
PRU_RCVOOB defined in line 95; used 1 times
PRU_SEND defined in line 91; used 2 times
PRU_SENDOOB defined in line 96; used 1 times
PRU_SENSE defined in line 94; used 1 times
PRU_SHUTDOWN defined in line 89; used 1 times
PRU_SOCKADDR defined in line 97; used 1 times
PR_FASTHZ defined in line 58; used 1 times

Usage of this include

protosw.h used 68 times
Last modified: 1995-10-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 180
Valid CSS Valid XHTML 1.0 Strict