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

📄 trans_serv.nr

📁 早期freebsd实现
💻 NR
📖 第 1 页 / 共 2 页
字号:
.NC "Transport Service Interface".sh 1 "General".ppIt is assumed that the reader is acquainted with theset of system calls and library routines thatcompose theBerkeleyUnix interprocess communication service (IPC).To every extent possible the ARGO transport service is provided by the same IPC mechanismsthat supportthe transport-level services included in theAOS distribution.In some instances, the interfaceprovided by AOS does not supportthe services required by ISO 8073,so system calls were added to support these services.It is felt that this is superior to modifyingexisting system calls, in order to avoid therecoding of existing Unix utilities. .ppWhat follows is a description of the system callsthat are used to provide the transport service.According to Unix custom,the return value of a system call is 0if the call succeeds and -1 ifthe call fails for any reason.In the latter case,the global variable\fIerrno\fR contains more informationabout the error that caused the failure.In the descriptions of all the system calls for whichthis custom is followed,the return value is named\fIstatus\fR..sh 1 "Connection establishment".ppEstablishing a TP connection is similar toestablishing a connection using any othertransport protocol supported by Unix.The same system calls are used, and the passive openis required.  Some of the parameters to the system calls differ. .ppThe following call creates a communication endpoint called a\fIsocket\fR.It returnsa positive integer called a\fIsocket descriptor\fR, whichwill be a parameter in all communication primitives..(b\fC.TStab(+);l s s s.s = socket( af, type, protocol ).T&l l l. +int+s,af,type,protocol;.TE\fR.)b.ppThe \fIaf\fR parameter describes the format of addressesused in this communication.Existing formats include AF_INET (DoD Internet addresses), AF_PUP (Xerox PUP-I Internet addresses), and AF_UNIX(addresses are Unix file names, for intra-machine IPC only).TP runs in either the Internet domain or the ISO domain (AF_ISO).When using the Internet domain, the network layer is the DoD Internet IP with Internet-style addresses. The ISO domain uses the ISOnetwork service and ISO-style addresses\**..(f\**ISO/DP 8348/DAD2 Addendum to the NetworkService Definition Covering Network Layer Addressing..)fRegardless of the address family used, an address takes thegeneral form,.(b\fC.TStab(+);l s s s.struct sockaddr {.T&l l l l. +u_char+sa_len;+/* length of sockaddr */ +u_char+sa_family;+/* address family */ +char+sa_data[14];+/* space for an address */}+.TE\fR.)b.lp.iA sockaddr is no longer required to be precisely 16 bytes long.The allocation of 14 bytes for sa_data is intended for backwardscompatibility..r.sp 1When viewed as an Internet address, it takes the form.(b\fC.TStab(+);l s s s.struct sockaddr_in {.T&l l l l. +u_char+sin_len;+/* address length */ +u_char+sin_family;+/* address family */ +u_short+sin_port;+/* internet port */ +struct in_addr+sin_addr;+/* network addr A.B.C.D */ +char+sin_zero[8];+/* unused */}.TE\fR.)b.sp 1When viewed as an ISO address, as supplied by theuniversity of wisconsin, it takes the form.(b\fC.TStab(+);l s s s.struct sockaddr_iso {.T&l l l l. +u_char+siso_len;+/* address length */ +u_char+siso_family;+/* address family */ +u_short+siso_tsuffix;+/* transport suffix */ +struct iso_addr+siso_addr;+/* ISO NSAP addr */ +char+siso_zero[2];+/* unused */}.TE\fR.)bThe address described by a \fIsockaddr_iso\fR structureis a TSAP-address (transport service access point address).It is made of an NSAP-address (network service access point address)and a TSAP selector (also called a transport suffix ortransport selector, hereafter called a TSEL).The structure \fIsockaddr_iso\fR contains a 2-byte TSEL.This is for compatibility with Internet addressing.ARGO supportsTSELs of length 1-64 bytes.TSELs of any length other than 2are called \*(lqextended TSELs\*(rq.They are described in detail in the section \fB\*(lqExtended TSELs\*(rq\fR.If extended TSELs are not requested, 2-byte TSELs are used by default..ppRefer to Chapter Five for more information about ISO NSAP-addresses..pp.iIt is our intent at Berkeley to revamp the sockaddr_isoto use a more natural and uniform model, for ISO addresses.We cannot guarantee this modification to be complete by thetime we are ready to have something for NIST to test.We hope to remove this notion of extended TSEL's as soon aspossible, certainly by formal beta testing of 4.4..rSince sockaddr can be 108 bytes long without breaking anythingin the current Berkeley kernel, we should be able to eliminateextended TSEL's entirely byproviding a sockaddr_iso along the lines of:.(b\fC.TStab(+);l s s s.struct sockaddr_iso {.T&l l l l. +u_char+siso_len;+/* address length */ +u_char+siso_family;+/* address family */ +u_char+siso_slen;+/* session suffix length */ +u_char+siso_tlen;+/* transport suffix length */ +u_char+siso_nlen;+/* nsap length */ +char+siso_data[22];+/* minimum nsap + tsel */}.TE\fR.)b.ppThe \fItype\fR parameter in the \fIsocket()\fR calldistinguishes datagram protocols, stream protocols, sequencedpacket protocols, reliable datagram protocols, and"raw" protocols (in other words, the absence of a transport protocol).Unix provides manifest named constants for each of these types.TP supports the sequenced packet protocol abstraction, to whichthe manifest constant SOCK_SEQPACKET applies..ppThe \fIprotocol\fRparameter is an integer that identifies the protocol to be used.Unix provides a database of protocol names  and their associatedprotocol numbers.Unix also provides user-level toolsfor searching the database.The tools take the form of library routines.A protocol number for TP has been chosenby the Internet NIC to allow TP to run in the Internet domain, and thishas been added to the Unix network protocol database.The standard Internet database tools that serve TCP userscanalso serve user of TPin the Internet domain, if the TP protocol number is added to theproper Internet database file, \fC/etc/protocols\fR.This change must be made for TP to run in either the Internet orin the ISO domain.The ARGO package contains a set of tools and a databasefor use with TP in the ISO domain.This set of tools is described in the manual pages\fIisodir(5)\fR and\fIisodir(3)\fR..ppWhen a socket is created, it is not given an address.Since a socket cannot be reached by a remote entity unless it has an address, the user must request that a socket be given an address byusing the \fIbind()\fR system call:.(b\fC.TStab(+);l s s s.status = bind( s, addr, addrlen ).T&l l l. +int+s; +struct sockaddr+*addr; +int+addrlen;.TE\fR.)b.ppThe address is expected to be in the format specified by the\fIaf\fR parameter to the \fIsocket()\fRcall that yielded the socket descriptor \fIs\fR.If the user passes an address parameter with a zero-valued transport suffix,the transport layer assigns an unused 2-byte transport selector.This is a 4.3 Unix convention; it is not part of any ISO standard..ppThe \fIconnect()\fR system call effects an active open.It is used to establish a connection with an entity that ispassively waiting for connection requests, and whosetransport address is known..(b\fC.TStab(+);l s s s.status = connect( s, addr, addrlen ).T&l l l. +int+s; +struct sockaddr+*addr; +int+addrlen;.TE\fR.)b.ppThe first parameter is a socket descriptor.The \fIaddr\fR parameter is a transport address in the formatspecified by the \fIaf\fR parameter to the \fIsocket()\fRcall that yielded the socket descriptor \fIs\fR..ppA passive open is accomplished with two system calls,\fIlisten()\fR followed by \fIaccept()\fR..(b\fC.TStab(+);l s s s.status = listen( s, queuelen ).T&l l l. +int+s; +int+queuelen;.TE\fR.)b.ppThe \fIqueuelen\fR argument specifies the maximumnumber of pending connectionrequests that will be queued for acceptance by this user.Connections are then accepted by thesystem call \fIaccept()\fR.  There is no way to refuse connections.The functional equivalent of connectionrefusal is accomplished by accepting a connection and immediatelydisconnecting..(b\fC.TStab(+);l s s s.new_s = accept( s, addr, addrlen ).T&l l l. +int+new_s, s; +struct sockaddr+*addr; +int+addrlen;.TE\fR.)b.ppThe \fIaccept()\fR call completes the connectionestablishment. If a connection request from a prospective peeris pending on the socket described by \fIs\fR, it is removed anda new socket is created for use with this connection.A socket descriptor for the new socket is returned by thesystem call.If no connection requests are pending, this call blocks.If the \fIaccept()\fR call fails, -1 is returned.The transport address of the entity requesting the connectionis returned in the \fIaddr\fR parameter, and the lengthof the address is returned in the \fIaddrlen\fR parameter.The address associated with the new socket is inheritedfrom the socket on which the \fIlisten()\fR and \fIaccept()\fR were performed..ppIt is possible for the \fIaccept()\fR call to be interruptedby an asynchronous event such as the arrival of expediteddata.When system calls are interrupted, Unix returns the value -1to the caller and puts the constantEINTR in the global variable \fIerrno\fR.This can create problems with the system call \fIaccept()\fR.In the case of incoming expedited data, the interruption doesnot indicate a problem, but the data may have arrived beforethe caller has received the new socket descriptor, which is thesocket descriptor on which the expedited data are to be received.In order to prevent this problem from occurring, the caller mustprevent the issuance of asynchronous indications until the\fIaccept()\fRcall has returned.Asynchronous indications are discussed below, in the section titled"Indications from the transport layer to the transport user"..ppIt is possible to discover the address bound to a socket with the \fIgetsockname()\fR system call.

⌨️ 快捷键说明

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