ddp(3N) ddp(3N)NAME ddp_open, ddp_close - AppleTalk Datagram Delivery Protocol (DDP) interface SYNOPSIS #include <at/appletalk.h> #include <at/ddp.h> cc [flags] files -lat [libraries] int ddp_open(socket) at_socket *socket; int ddp_close(fd) int fd; DESCRIPTION The DDP interface provides applications with access to the AppleTalk DDP operations. The ddp_open routine opens a static or dynamic DDP socket and returns an AppleTalk socket file descriptor that can be used to read and write DDP datagrams. The parameters are socket A pointer to the DDP socket number to open. If the AppleTalk socket number is 0, or if socket is NULL, a DDP socket is dynamically assigned. If socket is non-NULL, the socket number is returned in socket. An error condition results if there are no more dynamic DDP sockets available, if the maximum number of open files has been exceeded at a process or sys- tem level, or if the network is offline. Only the superuser can open a static DDP socket. fd The AppleTalk file descriptor of the DDP socket to be closed by the ddp_close routine. Datagrams are always read and written with the long DDP header format, using standard A/UX read(2) and write(2) sys- tem calls. The long header DDP datagram is defined by this structure in <at/ddp.h>: typedef struct { u_short unused : 2, hopcount : 4, length : 10; u_short checksum; at_net dst_net; at_net src_net; at_node dst_node; at_node src_node; April, 1990 1
ddp(3N) ddp(3N)at_socket dst_socket; at_socket src_socket; u_char type; u_char data[DDP_DATA_SIZE]; } at_ddp_t; When a datagram is written, only the fields checksum, dst_net, dst_node, dst_socket, type, and data need to be set. The rest of the fields may be left uninitialized, be- cause DDP sets them. The length field is the DDP packet length. The checksum field contains the DDP checksum. When datagrams are sent, a checksum is computed only if this field is nonzero. Datagrams can be sent and received asynchronously using standard A/UX facilities: select(2N) or O_NDELAY fcntl(2). ERRORS All routines return -1 on error with detailed error code in errno: [EACCES] A nonsuperuser attempted to open a stat- ic AppleTalk socket. [EADDRINUSE] The static socket is in use, or all dynamic sockets are in use. [EINVAL] An attempt was made to open an invalid AppleTalk socket number. [EMSGSIZE] A datagram is too large or too small. [ENETDOWN] The network interface is down. [ENOBUFS] DDP is out of buffers. Routines also return any additional error codes returned by standard A/UX open(2), close(2), read(2), and write(2) sys- tem calls. FILES /dev/appletalk/ddp/* SEE ALSO close(2), fcntl(2), open(2), read(2), select(2N), write(2), atp(3N), ddp(3N), nbp(3N), pap(3N), rmtp(3N), fcntl(5), ter- mio(7), Inside AppleTalk; ``AppleTalk Programming Guide,'' in A/UX Network Applications Programming. 2 April, 1990