Internet Datagram Protocol (IDP) is a simple, unreliable datagram protocol, which is used to support the SOCK_DGRAM abstraction for the Internet Protocol (IP) family. IDP sockets are connectionless and normally used with the sendto and recvfrom subroutines. The connect subroutine can also be used to fix the destination for future packets, in which case the recv or read subroutine and the send or write subroutine can be used.
Xerox protocols are built vertically on top of IDP. Thus, IDP address formats are identical to those used by the Sequenced Packet Protocol (SPP). The IDP port space is the same as the SPP port space; that is, an IDP port may be "connected" to an SPP port, with certain options enabled. In addition, broadcast packets may be sent (assuming the underlying network supports this) by using a reserved broadcast address. This address is network interface-dependent.
The following example illustrates how IDP uses the SOCK_DGRAM mechanism:
#include <sys/socket.h> #include <netns/ns.h> #include <netns/idp.h>
s = socket(AF_NS, SOCK_DGRAM, 0);
SO_HEADERS_ON_INPUT | When set, the first 30 bytes of any data returned from a read or recvfrom subroutine are the initial 30 bytes of the IDP packet, described as follows:
struct idp { u_short idp_sum; u_short idp_len; u_char idp_tc; u_char idp_pt; struct ns_addr idp_dna; struct ns_addr idp_sna; }; This allows the user to determine both the packet type and whether the packet was a multicast packet or directed specifically at the local host. When requested by the getsockopt subroutine, the SO_HEADERS_ON_INPUT option gives the current state of the option: NSP_RAWIN or 0. |
SO_HEADERS_ON_OUTPUT | When set, the first 30 bytes of any data sent are the initial 30 bytes of the IDP packet. This allows the user to determine both the packet type and whether the packet should be a multicast packet or directed specifically at the local host. You can also misrepresent the sender of the packet. When requested by the getsockopt subroutine, the SO_HEADERS_ON_OUTPUT option gives the current state of the option: NSP_RAWOUT or 0. |
SO_DEFAULT_HEADERS | The user provides the kernel an IDP header, from which the kernel determines the packet type. When the SO_DEFAULT_HEADERS option is requested by the getsockopt subroutine, the kernel provides an IDP header, showing the default packet type and the local and foreign addresses, if connected. |
SO_ALL_PACKETS | When set, this option disables automatic processing of both Error Protocol packets, and SPP packets. |
SO_SEQNO | When requested by the getsockopt subroutine, the S0_SEQNO option returns a sequence number that is not likely to be repeated. It is useful in constructing Packet Exchange Protocol (PEP) packets. |
The IDP protocol fails if one or more of the following are true: