| 1 | .nr H2 1 |
| 2 | .ds RH "Protocol/protocol interface |
| 3 | .NH |
| 4 | \s+2Protocol/protocol interface\s0 |
| 5 | .PP |
| 6 | The interface between protocol modules is through the \fIpr_usrreq\fP, |
| 7 | \fIpr_input\fP, \fIpr_output\fP, \fIpr_ctlinput\fP, and |
| 8 | \fIpr_ctloutput\fP routines. The calling conventions for all |
| 9 | but the \fIpr_usrreq\fP routine are expected to be specific to |
| 10 | the protocol |
| 11 | modules and are not guaranteed to be consistent across protocol |
| 12 | families. We |
| 13 | will examine the conventions used for some of the Internet |
| 14 | protocols in this section as an example. |
| 15 | .NH 2 |
| 16 | pr_output |
| 17 | .PP |
| 18 | The Internet protocol UDP uses the convention, |
| 19 | .DS |
| 20 | error = udp_output(inp, m); |
| 21 | int error; struct inpcb *inp; struct mbuf *m; |
| 22 | .DE |
| 23 | where the \fIinp\fP, ``\fIin\fPternet |
| 24 | \fIp\fProtocol \fIc\fPontrol \fIb\fPlock'', |
| 25 | passed between modules conveys per connection state information, and |
| 26 | the mbuf chain contains the data to be sent. UDP |
| 27 | performs consistency checks, appends its header, calculates a |
| 28 | checksum, etc. before passing the packet on to the IP module: |
| 29 | .DS |
| 30 | error = ip_output(m, opt, ro, allowbroadcast); |
| 31 | int error; struct mbuf *m, *opt; struct route *ro; int allowbroadcast; |
| 32 | .DE |
| 33 | .PP |
| 34 | The call to IP's output routine is more complicated than that for |
| 35 | UDP, as befits the additional work the IP module must do. |
| 36 | The \fIm\fP parameter is the data to be sent, and the \fIopt\fP |
| 37 | parameter is an optional list of IP options which should |
| 38 | be placed in the IP packet header. The \fIro\fP parameter is |
| 39 | is used in making routing decisions (and passing them back to the |
| 40 | caller). The |
| 41 | final parameter, \fIallowbroadcast\fP is a flag indicating if the |
| 42 | user is allowed to transmit a broadcast packet. This may |
| 43 | be inconsequential if the underlying hardware does not support the |
| 44 | notion of broadcasting. |
| 45 | .PP |
| 46 | All output routines return 0 on success and a UNIX error number |
| 47 | if a failure occured which could be immediately detected |
| 48 | (no buffer space available, no route to destination, etc.). |
| 49 | .NH 2 |
| 50 | pr_input |
| 51 | .PP |
| 52 | Both UDP and TCP use the following calling convention, |
| 53 | .DS |
| 54 | (void) (*protosw[].pr_input)(m); |
| 55 | struct mbuf *m; |
| 56 | .DE |
| 57 | Each mbuf list passed is a single packet to be processed by |
| 58 | the protocol module. |
| 59 | .PP |
| 60 | The IP input routine is a VAX software interrupt level routine, |
| 61 | and so is not called with any parameters. It instead communicates |
| 62 | with network interfaces through a queue, \fIipintrq\fP, which is |
| 63 | identical in structure to the queues used by the network interfaces |
| 64 | for storing packets awaiting transmission. |
| 65 | .NH 2 |
| 66 | pr_ctlinput |
| 67 | .PP |
| 68 | This routine is used to convey ``control'' information to a |
| 69 | protocol module (i.e. information which might be passed to the |
| 70 | user, but is not data). This routine, and the \fIpr_ctloutput\fP |
| 71 | routine, have not been extensively developed, and thus suffer |
| 72 | from a ``clumsiness'' that can only be improved as more demands |
| 73 | are placed on it. |
| 74 | .PP |
| 75 | The common calling convention for this routine is, |
| 76 | .DS |
| 77 | (void) (*protosw[].pr_ctlinput)(req, info); |
| 78 | int req; caddr_t info; |
| 79 | .DE |
| 80 | The \fIreq\fP parameter is one of the following, |
| 81 | .DS |
| 82 | .if t .ta .6i 2.6i 3.1i |
| 83 | .if n .ta .84i 3.1i 3.80i |
| 84 | #define PRC_IFDOWN 0 /* interface transition */ |
| 85 | #define PRC_ROUTEDEAD 1 /* select new route if possible */ |
| 86 | #define PRC_QUENCH 4 /* some said to slow down */ |
| 87 | #define PRC_HOSTDEAD 6 /* normally from IMP */ |
| 88 | #define PRC_HOSTUNREACH 7 /* ditto */ |
| 89 | #define PRC_UNREACH_NET 8 /* no route to network */ |
| 90 | #define PRC_UNREACH_HOST 9 /* no route to host */ |
| 91 | #define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */ |
| 92 | #define PRC_UNREACH_PORT 11 /* bad port # */ |
| 93 | #define PRC_MSGSIZE 12 /* message size forced drop */ |
| 94 | #define PRC_REDIRECT_NET 13 /* net routing redirect */ |
| 95 | #define PRC_REDIRECT_HOST 14 /* host routing redirect */ |
| 96 | #define PRC_TIMXCEED_INTRANS 17 /* packet lifetime expired in transit */ |
| 97 | #define PRC_TIMXCEED_REASS 18 /* lifetime expired on reass q */ |
| 98 | #define PRC_PARAMPROB 19 /* header incorrect */ |
| 99 | .DE |
| 100 | while the \fIinfo\fP parameter is a ``catchall'' value which |
| 101 | is request dependent. Many of the requests have obviously been |
| 102 | derived from ICMP (the Internet Control Message Protocol), |
| 103 | and from error messages defined in the 1822 host/IMP convention |
| 104 | [BBN78]. Mapping tables exist to convert |
| 105 | control requests to UNIX error codes which are delivered |
| 106 | to a user. |
| 107 | .NH 2 |
| 108 | pr_ctloutput |
| 109 | .PP |
| 110 | This routine is not currently used by any protocol modules. |
| 111 | .ds RH "Protocol/network-interface |
| 112 | .bp |