1 .\" $NetBSD: 9.t,v 1.2 1998/01/09 06:55:47 perry Exp $
3 .\" Copyright (c) 1983, 1986, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)9.t 8.1 (Berkeley) 6/8/93
33 .\".ds RH "Protocol/network-interface
37 \s+2Protocol/network-interface interface\s0
39 The lowest layer in the set of protocols which comprise a
40 protocol family must interface itself to one or more network
41 interfaces in order to transmit and receive
42 packets. It is assumed that
43 any routing decisions have been made before handing a packet
44 to a network interface, in fact this is absolutely necessary
45 in order to locate any interface at all (unless, of course,
46 one uses a single ``hardwired'' interface). There are two
47 cases with which to be concerned, transmission of a packet
48 and receipt of a packet; each will be considered separately.
52 Assuming a protocol has a handle on an interface, \fIifp\fP,
54 it transmits a fully formatted packet with the following call,
56 error = (*ifp->if_output)(ifp, m, dst)
57 int error; struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst;
59 The output routine for the network interface transmits the packet
60 \fIm\fP to the \fIdst\fP address, or returns an error indication
61 (a UNIX error number). In reality transmission may
62 not be immediate or successful; normally the output
63 routine simply queues the packet on its send queue and primes
64 an interrupt driven routine to actually transmit the packet.
65 For unreliable media, such as the Ethernet, ``successful''
66 transmission simply means that the packet has been placed on the cable
67 without a collision. On the other hand, an 1822 interface guarantees
68 proper delivery or an error indication for each message transmitted.
69 The model employed in the networking system attaches no promises
70 of delivery to the packets handed to a network interface, and thus
71 corresponds more closely to the Ethernet. Errors returned by the
72 output routine are only those that can be detected immediately,
73 and are normally trivial in nature (no buffer space,
74 address format not handled, etc.).
75 No indication is received if errors are detected after the call has returned.
79 Each protocol family must have one or more ``lowest level'' protocols.
80 These protocols deal with internetwork addressing and are responsible
81 for the delivery of incoming packets to the proper protocol processing
82 modules. In the PUP model [Boggs78] these protocols are termed Level
84 in the ISO model, network layer protocols. In this system each such
85 protocol module has an input packet queue assigned to it. Incoming
86 packets received by a network interface are queued for the protocol
87 module, and a VAX software interrupt is posted to initiate processing.
89 Three macros are available for queuing and dequeuing packets:
90 .IP "IF_ENQUEUE(ifq, m)"
92 This places the packet \fIm\fP at the tail of the queue \fIifq\fP.
93 .IP "IF_DEQUEUE(ifq, m)"
95 This places a pointer to the packet at the head of queue \fIifq\fP
97 and removes the packet from the queue.
98 A zero value will be returned in \fIm\fP if the queue is empty.
99 .IP "IF_DEQUEUEIF(ifq, m, ifp)"
101 Like IF_DEQUEUE, this removes the next packet from the head of a queue
102 and returns it in \fIm\fP.
103 A pointer to the interface on which the packet was received
104 is placed in \fIifp\fP, a (struct ifnet\ *).
105 .IP "IF_PREPEND(ifq, m)"
107 This places the packet \fIm\fP at the head of the queue \fIifq\fP.
109 Each queue has a maximum length associated with it as a simple form
110 of congestion control. The macro IF_QFULL(ifq) returns 1 if the queue
111 is filled, in which case the macro IF_DROP(ifq) should be used to
112 increment the count of the number of packets dropped, and the offending
113 packet is dropped. For example, the following code fragment is commonly
114 found in a network interface's input routine,