]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/doc/smm/18.net/8.t
MFV r318946: 8021 ARC buf data scatter-ization
[FreeBSD/FreeBSD.git] / share / doc / smm / 18.net / 8.t
1 .\" Copyright (c) 1983, 1986, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)8.t 8.1 (Berkeley) 6/8/93
29 .\"
30 .nr H2 1
31 .\".ds RH "Protocol/protocol interface
32 .br
33 .ne 2i
34 .NH
35 \s+2Protocol/protocol interface\s0
36 .PP
37 The interface between protocol modules is through the \fIpr_usrreq\fP,
38 \fIpr_input\fP, \fIpr_output\fP, \fIpr_ctlinput\fP, and
39 \fIpr_ctloutput\fP routines.  The calling conventions for all
40 but the \fIpr_usrreq\fP routine are expected to be specific to
41 the protocol
42 modules and are not guaranteed to be consistent across protocol
43 families.  We
44 will examine the conventions used for some of the Internet
45 protocols in this section as an example.
46 .NH 2
47 pr_output
48 .PP
49 The Internet protocol UDP uses the convention,
50 .DS
51 error = udp_output(inp, m);
52 int error; struct inpcb *inp; struct mbuf *m;
53 .DE
54 where the \fIinp\fP, ``\fIin\fP\^ternet
55 \fIp\fP\^rotocol \fIc\fP\^ontrol \fIb\fP\^lock'',
56 passed between modules conveys per connection state information, and
57 the mbuf chain contains the data to be sent.  UDP
58 performs consistency checks, appends its header, calculates a
59 checksum, etc. before passing the packet on.
60 UDP is based on the Internet Protocol, IP [Postel81a], as its transport.
61 UDP passes a packet to the IP module for output as follows:
62 .DS
63 error = ip_output(m, opt, ro, flags);
64 int error; struct mbuf *m, *opt; struct route *ro; int flags;
65 .DE
66 .PP
67 The call to IP's output routine is more complicated than that for
68 UDP, as befits the additional work the IP module must do.
69 The \fIm\fP parameter is the data to be sent, and the \fIopt\fP
70 parameter is an optional list of IP options which should
71 be placed in the IP packet header.  The \fIro\fP parameter is
72 is used in making routing decisions (and passing them back to the
73 caller for use in subsequent calls).  The
74 final parameter, \fIflags\fP contains flags indicating whether the
75 user is allowed to transmit a broadcast packet
76 and if routing is to be performed.  The broadcast flag may
77 be inconsequential if the underlying hardware does not support the
78 notion of broadcasting.
79 .PP
80 All output routines return 0 on success and a UNIX error number
81 if a failure occurred which could be detected immediately
82 (no buffer space available, no route to destination, etc.).
83 .NH 2
84 pr_input
85 .PP
86 Both UDP and TCP use the following calling convention,
87 .DS
88 (void) (*protosw[].pr_input)(m, ifp);
89 struct mbuf *m; struct ifnet *ifp;
90 .DE
91 Each mbuf list passed is a single packet to be processed by
92 the protocol module.
93 The interface from which the packet was received is passed as the second
94 parameter.
95 .PP
96 The IP input routine is a VAX software interrupt level routine,
97 and so is not called with any parameters.  It instead communicates
98 with network interfaces through a queue, \fIipintrq\fP, which is
99 identical in structure to the queues used by the network interfaces
100 for storing packets awaiting transmission.
101 The software interrupt is enabled by the network interfaces
102 when they place input data on the input queue.
103 .NH 2
104 pr_ctlinput
105 .PP
106 This routine is used to convey ``control'' information to a
107 protocol module (i.e. information which might be passed to the
108 user, but is not data).
109 .PP
110 The common calling convention for this routine is,
111 .DS
112 (void) (*protosw[].pr_ctlinput)(req, addr);
113 int req; struct sockaddr *addr;
114 .DE
115 The \fIreq\fP parameter is one of the following,
116 .DS
117 .ta \w'#define  'u +\w'PRC_UNREACH_NEEDFRAG   'u +8n
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     14      /* redirect for type of service & net */
133 #define PRC_REDIRECT_TOSHOST    15      /* 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 .DE
138 while the \fIaddr\fP parameter is the address to which the condition applies.
139 Many of the requests have obviously been
140 derived from ICMP (the Internet Control Message Protocol [Postel81c]),
141 and from error messages defined in the 1822 host/IMP convention
142 [BBN78].  Mapping tables exist to convert
143 control requests to UNIX error codes which are delivered
144 to a user.
145 .NH 2
146 pr_ctloutput
147 .PP
148 This is the routine that implements per-socket options at the protocol
149 level for \fIgetsockopt\fP and \fIsetsockopt\fP.
150 The calling convention is,
151 .DS
152 error = (*protosw[].pr_ctloutput)(op, so, level, optname, mp);
153 int op; struct socket *so; int level, optname; struct mbuf **mp;
154 .DE
155 where \fIop\fP is one of PRCO_SETOPT or PRCO_GETOPT,
156 \fIso\fP is the socket from whence the call originated,
157 and \fIlevel\fP and \fIoptname\fP are the protocol level and option name
158 supplied by the user.
159 The results of a PRCO_GETOPT call are returned in an mbuf whose address
160 is placed in \fImp\fP before return.
161 On a PRCO_SETOPT call, \fImp\fP contains the address of an mbuf
162 containing the option data; the mbuf should be freed before return.