1*47675Scael.\" Copyright (c) 1985, 1991 The Regents of the University of California. 236752Sbostic.\" All rights reserved. 324107Ssklower.\" 443581Strent.\" %sccs.include.redist.man% 524107Ssklower.\" 6*47675Scael.\" @(#)spp.4 1.5 (Berkeley) 03/28/91 736752Sbostic.\" 8*47675Scael.Dd 9*47675Scael.Dt SPP 4 10*47675Scael.Os BSD 4.3 11*47675Scael.Sh NAME 12*47675Scael.Nm spp 13*47675Scael.Nd Xerox Sequenced Packet Protocol 14*47675Scael.Sh SYNOPSIS 15*47675Scael.Fd #include <sys/socket.h> 16*47675Scael.Fd #include <netns/ns.h> 17*47675Scael.Fd #include <netns/sp.h> 18*47675Scael.Ft int 19*47675Scael.Fn socket AF_NS SOCK_STREAM 0 20*47675Scael.Ft int 21*47675Scael.Fn socket AF_NS SOCK_SEQPACKET 0 22*47675Scael.Sh DESCRIPTION 23*47675ScaelThe 24*47675Scael.Tn SPP 25*47675Scaelprotocol provides reliable, flow-controlled, two-way 2624107Ssklowertransmission of data. It is a byte-stream protocol used to 27*47675Scaelsupport the 28*47675Scael.Dv SOCK_STREAM 29*47675Scaelabstraction. 30*47675Scael.Tn SPP 31*47675Scaeluses the standard 32*47675Scael.Tn NS Ns (tm) 33*47675Scaeladdress formats. 34*47675Scael.Pp 35*47675ScaelSockets utilizing the 36*47675Scael.Tn SPP 37*47675Scaelprotocol are either 38*47675Scael.Dq active 39*47675Scaelor 40*47675Scael.Dq passive . 41*47675ScaelActive sockets initiate connections to passive 42*47675Scaelsockets. By default 43*47675Scael.Tn SPP 44*47675Scaelsockets are created active; to create a 4524107Ssklowerpassive socket the 46*47675Scael.Xr listen 2 4724107Ssklowersystem call must be used 4824107Ssklowerafter binding the socket with the 49*47675Scael.Xr bind 2 5024107Ssklowersystem call. Only 5124107Ssklowerpassive sockets may use the 52*47675Scael.Xr accept 2 5324107Ssklowercall to accept incoming connections. Only active sockets may 5424107Sskloweruse the 55*47675Scael.Xr connect 2 5624107Ssklowercall to initiate connections. 57*47675Scael.Pp 58*47675ScaelPassive sockets may 59*47675Scael.Dq underspecify 60*47675Scaeltheir location to match 6124107Ssklowerincoming connection requests from multiple networks. This 62*47675Scaeltechnique, termed 63*47675Scael.Dq wildcard addressing , 64*47675Scaelallows a single 6524107Ssklowerserver to provide service to clients on multiple networks. 66*47675ScaelTo create a socket which listens on all networks, the 67*47675Scael.Tn NS 6824107Sskloweraddress of all zeroes must be bound. 69*47675ScaelThe 70*47675Scael.Tn SPP 71*47675Scaelport may still be specified 7224107Ssklowerat this time; if the port is not specified the system will assign one. 7324107SsklowerOnce a connection has been established the socket's address is 7424107Ssklowerfixed by the peer entity's location. The address assigned the 7524107Ssklowersocket is the address associated with the network interface 7624107Ssklowerthrough which packets are being transmitted and received. Normally 7724107Ssklowerthis address corresponds to the peer entity's network. 78*47675Scael.Pp 79*47675ScaelIf the 80*47675Scael.Dv SOCK_SEQPACKET 81*47675Scaelsocket type is specified, 8224107Ssklowereach packet received has the actual 12 byte sequenced packet header 8324107Ssklowerleft for the user to inspect: 84*47675Scael.Bd -literal -offset indent 8524107Ssklowerstruct sphdr { 86*47675Scael u_char sp_cc; /* connection control */ 87*47675Scael#define SP_EM 0x10 /* end of message */ 88*47675Scael u_char sp_dt; /* datastream type */ 8924107Ssklower u_short sp_sid; 9024107Ssklower u_short sp_did; 9124107Ssklower u_short sp_seq; 9224107Ssklower u_short sp_ack; 9324107Ssklower u_short sp_alo; 9424107Ssklower}; 95*47675Scael.Ed 96*47675Scael.Pp 9724107SsklowerThis facilitates the implementation of higher level Xerox protocols 9824107Ssklowerwhich make use of the data stream type field and the end of message bit. 9924107SsklowerConversely, the user is required to supply a 12 byte header, 10024107Ssklowerthe only part of which inspected is the data stream type and end of message 10124107Ssklowerfields. 102*47675Scael.Pp 10324107SsklowerFor either socket type, 10424107Ssklowerpackets received with the Attention bit sent are interpreted as 105*47675Scaelout of band data. Data sent with 106*47675Scael.Dq send(..., ..., ..., Dv MSG_OOB ) 10724107Ssklowercause the attention bit to be set. 108*47675Scael.Sh DIAGNOSTICS 10924107SsklowerA socket operation may fail with one of the following errors returned: 110*47675Scael.Bl -tag -width [EADDRNOTAVAIL] 111*47675Scael.It Bq Er EISCONN 11224107Ssklowerwhen trying to establish a connection on a socket which 11324107Sskloweralready has one; 114*47675Scael.It Bq Er ENOBUFS 11524107Ssklowerwhen the system runs out of memory for 11624107Sskloweran internal data structure; 117*47675Scael.It Bq Er ETIMEDOUT 11824107Ssklowerwhen a connection was dropped 11924107Ssklowerdue to excessive retransmissions; 120*47675Scael.It Bq Er ECONNRESET 12124107Ssklowerwhen the remote peer 12224107Ssklowerforces the connection to be closed; 123*47675Scael.It Bq Er ECONNREFUSED 12424107Ssklowerwhen the remote 12524107Ssklowerpeer actively refuses connection establishment (usually because 12624107Ssklowerno process is listening to the port); 127*47675Scael.It Bq Er EADDRINUSE 12824107Ssklowerwhen an attempt 12924107Sskloweris made to create a socket with a port which has already been 13024107Ssklowerallocated; 131*47675Scael.It Bq Er EADDRNOTAVAIL 13224107Ssklowerwhen an attempt is made to create a 13324107Ssklowersocket with a network address for which no network interface 13424107Ssklowerexists. 135*47675Scael.El 136*47675Scael.Sh SOCKET OPTIONS 137*47675Scael.Bl -tag -width SO_DEFAULT_HEADERS 138*47675Scael.It Dv SO_DEFAULT_HEADERS 13924107Ssklowerwhen set, this determines the data stream type and whether 14024107Ssklowerthe end of message bit is to be set on every ensuing packet. 141*47675Scael.It Dv SO_MTU 14224864SsklowerThis specifies the maximum ammount of user data in a single packet. 14324864SsklowerThe default is 576 bytes - sizeof(struct spidp). This quantity 144*47675Scaelaffects windowing \- increasing it without increasing the amount 14524864Ssklowerof buffering in the socket will lower the number of unread packets 14624864Sskloweraccepted. Anything larger than the default will not be forwarded 147*47675Scaelby a bona fide 148*47675Scael.Tn XEROX 149*47675Scaelproduct internetwork router. 15024864SsklowerThe data argument for the setsockopt call must be 15124864Sskloweran unsigned short. 152*47675Scael.El 153*47675Scael.Sh SEE ALSO 154*47675Scael.Xr intro 4 , 155*47675Scael.Xr ns 4 156*47675Scael.Sh HISTORY 157*47675ScaelThe 158*47675Scael.Nm 159*47675Scaelprotocol appeared in 160*47675Scael.Bx 4.3 . 161*47675Scael.Sh BUGS 16224107SsklowerThere should be some way to reflect record boundaries in 16324107Ssklowera stream. 16424107SsklowerFor stream mode, there should be an option to get the data stream type of 16524107Ssklowerthe record the user process is about to receive. 166