1 /* protosw.h 4.11 82/04/24 */ 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 56 /* 57 * The arguments to usrreq are: 58 * (*protosw[].pr_usrreq)(up, req, m, addr); 59 * where up is a (struct socket *), req is one of these requests, 60 * m is a optional mbuf chain, and addr is an optional meta-internetwork 61 * address representation. The protocol is responsible for 62 * disposal of the mbuf chain. A non-zero return from usrreq gives an 63 * UNIX error number which should be passed to higher level software. 64 */ 65 #define PRU_ATTACH 0 /* attach protocol to up */ 66 #define PRU_DETACH 1 /* detach protocol from up */ 67 #define PRU_CONNECT 2 /* establish connection to peer */ 68 #define PRU_ACCEPT 3 /* accept connection from peer */ 69 #define PRU_DISCONNECT 4 /* disconnect from peer */ 70 #define PRU_SHUTDOWN 5 /* won't send any more data */ 71 #define PRU_RCVD 6 /* have taken data; more room now */ 72 #define PRU_SEND 7 /* send this data */ 73 #define PRU_ABORT 8 /* abort (fast DISCONNECT, DETATCH) */ 74 #define PRU_CONTROL 9 /* control operations on protocol */ 75 #define PRU_SENSE 10 /* return status into m */ 76 #define PRU_RCVOOB 11 /* retrieve out of band data */ 77 #define PRU_SENDOOB 12 /* send out of band data */ 78 #define PRU_SOCKADDR 13 /* fetch socket's address */ 79 /* begin for protocols internal use */ 80 #define PRU_FASTTIMO 14 /* 200ms timeout */ 81 #define PRU_SLOWTIMO 15 /* 500ms timeout */ 82 #define PRU_PROTORCV 16 /* receive from below */ 83 #define PRU_PROTOSEND 17 /* send to below */ 84 85 #define PRU_NREQ 18 86 87 #ifdef PRUREQUESTS 88 char *prurequests[] = { 89 "ATTACH", "DETACH", "CONNECT", "ACCEPT", 90 "DISCONNECT", "SHUTDOWN", "RCVD", "SEND", 91 "ABORT", "CONTROL", "SENSE", "RCVOOB", 92 "SENDOOB", "SOCKADDR", "FASTTIMO", "SLOWTIMO", 93 "PROTORCV", "PROTOSEND", 94 }; 95 #endif 96 97 /* 98 * The arguments to the ctlinput routine are 99 * (*protosw[].pr_ctlinput)(cmd, arg); 100 * where cmd is one of the commands below, and arg is 101 * an optional argument (caddr_t). 102 * 103 * N.B. The IMP code, in particular, pressumes the values 104 * of some of the commands; change with extreme care. 105 */ 106 #define PRC_IFDOWN 0 /* interface transition */ 107 #define PRC_ROUTEDEAD 1 /* select new route if possible */ 108 #define PRC_QUENCH 4 /* some said to slow down */ 109 #define PRC_HOSTDEAD 6 /* normally from IMP */ 110 #define PRC_HOSTUNREACH 7 /* ditto */ 111 #define PRC_UNREACH_NET 8 /* no route to network */ 112 #define PRC_UNREACH_HOST 9 /* no route to host */ 113 #define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */ 114 #define PRC_UNREACH_PORT 11 /* bad port # */ 115 #define PRC_MSGSIZE 12 /* message size forced drop */ 116 #define PRC_REDIRECT_NET 13 /* net routing redirect */ 117 #define PRC_REDIRECT_HOST 14 /* host routing redirect */ 118 #define PRC_TIMXCEED_INTRANS 17 /* packet lifetime expired in transit */ 119 #define PRC_TIMXCEED_REASS 18 /* lifetime expired on reass q */ 120 #define PRC_PARAMPROB 19 /* header incorrect */ 121 122 #define PRC_NCMDS 20 123 124 #ifdef PRCREQUESTS 125 char *prcrequests[] = { 126 "IFDOWN", "ROUTEDEAD", "#2", "#3", 127 "QUNECH", "#5", "HOSTDEAD", "HOSTUNREACH", 128 "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH","PORT-UNREACH", 129 "MSGSIZE", "NET-REDIRECT", "HOST-REDIRECT","TX-INTRANS", 130 "TX-REASS", "PARAMPROB" 131 }; 132 #endif 133 134 #ifdef KERNEL 135 struct protosw protosw[], *protoswLAST; 136 extern struct protosw *pffindproto(), *pffindtype(); 137 #endif 138