|
|
1.1 root 1: .\" Copyright (c) 1983, 1986 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
4: .\" Redistribution and use in source and binary forms are permitted
5: .\" provided that the above copyright notice and this paragraph are
6: .\" duplicated in all such forms and that any documentation,
7: .\" advertising materials, and other materials related to such
8: .\" distribution and use acknowledge that the software was developed
9: .\" by the University of California, Berkeley. The name of the
10: .\" University may not be used to endorse or promote products derived
11: .\" from this software without specific prior written permission.
12: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13: .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14: .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15: .\"
16: .\" @(#)8.t 6.5 (Berkeley) 3/7/89
17: .\"
18: .nr H2 1
19: .\".ds RH "Protocol/protocol interface
20: .br
21: .ne 2i
22: .NH
23: \s+2Protocol/protocol interface\s0
24: .PP
25: The interface between protocol modules is through the \fIpr_usrreq\fP,
26: \fIpr_input\fP, \fIpr_output\fP, \fIpr_ctlinput\fP, and
27: \fIpr_ctloutput\fP routines. The calling conventions for all
28: but the \fIpr_usrreq\fP routine are expected to be specific to
29: the protocol
30: modules and are not guaranteed to be consistent across protocol
31: families. We
32: will examine the conventions used for some of the Internet
33: protocols in this section as an example.
34: .NH 2
35: pr_output
36: .PP
37: The Internet protocol UDP uses the convention,
38: .DS
39: error = udp_output(inp, m);
40: int error; struct inpcb *inp; struct mbuf *m;
41: .DE
42: where the \fIinp\fP, ``\fIin\fP\^ternet
43: \fIp\fP\^rotocol \fIc\fP\^ontrol \fIb\fP\^lock'',
44: passed between modules conveys per connection state information, and
45: the mbuf chain contains the data to be sent. UDP
46: performs consistency checks, appends its header, calculates a
47: checksum, etc. before passing the packet on.
48: UDP is based on the Internet Protocol, IP [Postel81a], as its transport.
49: UDP passes a packet to the IP module for output as follows:
50: .DS
51: error = ip_output(m, opt, ro, flags);
52: int error; struct mbuf *m, *opt; struct route *ro; int flags;
53: .DE
54: .PP
55: The call to IP's output routine is more complicated than that for
56: UDP, as befits the additional work the IP module must do.
57: The \fIm\fP parameter is the data to be sent, and the \fIopt\fP
58: parameter is an optional list of IP options which should
59: be placed in the IP packet header. The \fIro\fP parameter is
60: is used in making routing decisions (and passing them back to the
61: caller for use in subsequent calls). The
62: final parameter, \fIflags\fP contains flags indicating whether the
63: user is allowed to transmit a broadcast packet
64: and if routing is to be performed. The broadcast flag may
65: be inconsequential if the underlying hardware does not support the
66: notion of broadcasting.
67: .PP
68: All output routines return 0 on success and a UNIX error number
69: if a failure occurred which could be detected immediately
70: (no buffer space available, no route to destination, etc.).
71: .NH 2
72: pr_input
73: .PP
74: Both UDP and TCP use the following calling convention,
75: .DS
76: (void) (*protosw[].pr_input)(m, ifp);
77: struct mbuf *m; struct ifnet *ifp;
78: .DE
79: Each mbuf list passed is a single packet to be processed by
80: the protocol module.
81: The interface from which the packet was received is passed as the second
82: parameter.
83: .PP
84: The IP input routine is a VAX software interrupt level routine,
85: and so is not called with any parameters. It instead communicates
86: with network interfaces through a queue, \fIipintrq\fP, which is
87: identical in structure to the queues used by the network interfaces
88: for storing packets awaiting transmission.
89: The software interrupt is enabled by the network interfaces
90: when they place input data on the input queue.
91: .NH 2
92: pr_ctlinput
93: .PP
94: This routine is used to convey ``control'' information to a
95: protocol module (i.e. information which might be passed to the
96: user, but is not data).
97: .PP
98: The common calling convention for this routine is,
99: .DS
100: (void) (*protosw[].pr_ctlinput)(req, addr);
101: int req; struct sockaddr *addr;
102: .DE
103: The \fIreq\fP parameter is one of the following,
104: .DS
105: .ta \w'#define 'u +\w'PRC_UNREACH_NEEDFRAG 'u +8n
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_MSGSIZE 5 /* message size forced drop */
110: #define PRC_HOSTDEAD 6 /* normally from IMP */
111: #define PRC_HOSTUNREACH 7 /* ditto */
112: #define PRC_UNREACH_NET 8 /* no route to network */
113: #define PRC_UNREACH_HOST 9 /* no route to host */
114: #define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */
115: #define PRC_UNREACH_PORT 11 /* bad port # */
116: #define PRC_UNREACH_NEEDFRAG 12 /* IP_DF caused drop */
117: #define PRC_UNREACH_SRCFAIL 13 /* source route failed */
118: #define PRC_REDIRECT_NET 14 /* net routing redirect */
119: #define PRC_REDIRECT_HOST 15 /* host routing redirect */
120: #define PRC_REDIRECT_TOSNET 14 /* redirect for type of service & net */
121: #define PRC_REDIRECT_TOSHOST 15 /* redirect for tos & host */
122: #define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */
123: #define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */
124: #define PRC_PARAMPROB 20 /* header incorrect */
125: .DE
126: while the \fIaddr\fP parameter is the address to which the condition applies.
127: Many of the requests have obviously been
128: derived from ICMP (the Internet Control Message Protocol [Postel81c]),
129: and from error messages defined in the 1822 host/IMP convention
130: [BBN78]. Mapping tables exist to convert
131: control requests to UNIX error codes which are delivered
132: to a user.
133: .NH 2
134: pr_ctloutput
135: .PP
136: This is the routine that implements per-socket options at the protocol
137: level for \fIgetsockopt\fP and \fIsetsockopt\fP.
138: The calling convention is,
139: .DS
140: error = (*protosw[].pr_ctloutput)(op, so, level, optname, mp);
141: int op; struct socket *so; int level, optname; struct mbuf **mp;
142: .DE
143: where \fIop\fP is one of PRCO_SETOPT or PRCO_GETOPT,
144: \fIso\fP is the socket from whence the call originated,
145: and \fIlevel\fP and \fIoptname\fP are the protocol level and option name
146: supplied by the user.
147: The results of a PRCO_GETOPT call are returned in an mbuf whose address
148: is placed in \fImp\fP before return.
149: On a PRCO_SETOPT call, \fImp\fP contains the address of an mbuf
150: containing the option data; the mbuf should be freed before return.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.