⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8.t

📁 早期freebsd实现
💻 T
字号:
.\" Copyright (c) 1983, 1986, 1993.\"	The Regents of the University of California.  All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"	@(#)8.t	8.1 (Berkeley) 6/8/93.\".nr H2 1.\".ds RH "Protocol/protocol interface.br.ne 2i.NH\s+2Protocol/protocol interface\s0.PPThe interface between protocol modules is through the \fIpr_usrreq\fP,\fIpr_input\fP, \fIpr_output\fP, \fIpr_ctlinput\fP, and\fIpr_ctloutput\fP routines.  The calling conventions for allbut the \fIpr_usrreq\fP routine are expected to be specific tothe protocolmodules and are not guaranteed to be consistent across protocolfamilies.  Wewill examine the conventions used for some of the Internetprotocols in this section as an example..NH 2pr_output.PPThe Internet protocol UDP uses the convention,.DSerror = udp_output(inp, m);int error; struct inpcb *inp; struct mbuf *m;.DEwhere the \fIinp\fP, ``\fIin\fP\^ternet\fIp\fP\^rotocol \fIc\fP\^ontrol \fIb\fP\^lock'',passed between modules conveys per connection state information, andthe mbuf chain contains the data to be sent.  UDPperforms consistency checks, appends its header, calculates achecksum, etc. before passing the packet on.UDP is based on the Internet Protocol, IP [Postel81a], as its transport.UDP passes a packet to the IP module for output as follows:.DSerror = ip_output(m, opt, ro, flags);int error; struct mbuf *m, *opt; struct route *ro; int flags;.DE.PPThe call to IP's output routine is more complicated than that forUDP, as befits the additional work the IP module must do.The \fIm\fP parameter is the data to be sent, and the \fIopt\fPparameter is an optional list of IP options which shouldbe placed in the IP packet header.  The \fIro\fP parameter isis used in making routing decisions (and passing them back to thecaller for use in subsequent calls).  Thefinal parameter, \fIflags\fP contains flags indicating whether theuser is allowed to transmit a broadcast packetand if routing is to be performed.  The broadcast flag maybe inconsequential if the underlying hardware does not support thenotion of broadcasting..PPAll output routines return 0 on success and a UNIX error numberif a failure occurred which could be detected immediately(no buffer space available, no route to destination, etc.)..NH 2pr_input.PPBoth UDP and TCP use the following calling convention,.DS(void) (*protosw[].pr_input)(m, ifp);struct mbuf *m; struct ifnet *ifp;.DEEach mbuf list passed is a single packet to be processed bythe protocol module.The interface from which the packet was received is passed as the secondparameter..PPThe IP input routine is a VAX software interrupt level routine,and so is not called with any parameters.  It instead communicateswith network interfaces through a queue, \fIipintrq\fP, which isidentical in structure to the queues used by the network interfacesfor storing packets awaiting transmission.The software interrupt is enabled by the network interfaceswhen they place input data on the input queue..NH 2pr_ctlinput.PPThis routine is used to convey ``control'' information to aprotocol module (i.e. information which might be passed to theuser, but is not data)..PPThe common calling convention for this routine is,.DS(void) (*protosw[].pr_ctlinput)(req, addr);int req; struct sockaddr *addr;.DEThe \fIreq\fP parameter is one of the following,.DS.ta \w'#define  'u +\w'PRC_UNREACH_NEEDFRAG   'u +8n#define	PRC_IFDOWN	0	/* interface transition */#define	PRC_ROUTEDEAD	1	/* select new route if possible */#define	PRC_QUENCH	4	/* some said to slow down */#define	PRC_MSGSIZE	5	/* message size forced drop */#define	PRC_HOSTDEAD	6	/* normally from IMP */#define	PRC_HOSTUNREACH	7	/* ditto */#define	PRC_UNREACH_NET	8	/* no route to network */#define	PRC_UNREACH_HOST	9	/* no route to host */#define	PRC_UNREACH_PROTOCOL	10	/* dst says bad protocol */#define	PRC_UNREACH_PORT	11	/* bad port # */#define	PRC_UNREACH_NEEDFRAG	12	/* IP_DF caused drop */#define	PRC_UNREACH_SRCFAIL	13	/* source route failed */#define	PRC_REDIRECT_NET	14	/* net routing redirect */#define	PRC_REDIRECT_HOST	15	/* host routing redirect */#define	PRC_REDIRECT_TOSNET	14	/* redirect for type of service & net */#define	PRC_REDIRECT_TOSHOST	15	/* redirect for tos & host */#define	PRC_TIMXCEED_INTRANS	18	/* packet lifetime expired in transit */#define	PRC_TIMXCEED_REASS	19	/* lifetime expired on reass q */#define	PRC_PARAMPROB	20	/* header incorrect */.DEwhile the \fIaddr\fP parameter is the address to which the condition applies.Many of the requests have obviously beenderived from ICMP (the Internet Control Message Protocol [Postel81c]),and from error messages defined in the 1822 host/IMP convention[BBN78].  Mapping tables exist to convertcontrol requests to UNIX error codes which are deliveredto a user..NH 2pr_ctloutput.PPThis is the routine that implements per-socket options at the protocollevel for \fIgetsockopt\fP and \fIsetsockopt\fP.The calling convention is,.DSerror = (*protosw[].pr_ctloutput)(op, so, level, optname, mp);int op; struct socket *so; int level, optname; struct mbuf **mp;.DEwhere \fIop\fP is one of PRCO_SETOPT or PRCO_GETOPT,\fIso\fP is the socket from whence the call originated,and \fIlevel\fP and \fIoptname\fP are the protocol level and option namesupplied by the user.The results of a PRCO_GETOPT call are returned in an mbuf whose addressis placed in \fImp\fP before return.On a PRCO_SETOPT call, \fImp\fP contains the address of an mbufcontaining the option data; the mbuf should be freed before return.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -