2 .\" Copyright 1994 Vrije Universiteit, The Netherlands.
3 .\" For full copyright and restrictions on use see the file COPYRIGHT in the
4 .\" top level of the Amoeba distribution.
7 Software: Philip Homburg, 1991
8 Document: Philip Homburg, Sept 3, 1991
9 Modified: Greg Sharp and Philip Homburg, March 1992
10 - merged with udp(L) and made a little more complete.
11 Greg Sharp, April 1992
12 - updated keywords for auto index generation
13 Modified: Kees J. Bot, June 1994
14 - changed to man(7) format for MINIX 3.
18 ip, eth, psip, udp, tcp \- Internet Protocol server devices and definitions
31 devices give access to the Internet Protocol (IP) services in MINIX 3.
32 There can be up to 16 different networks, with 4 network devices each
33 (a network has either an
40 in the device names is a decimal number, so one may see names from
44 A program scanning all networks must try all 16, and not stop if one in
45 between is missing. One network is the default network. Its devices are
46 linked to names without numbers.
52 devices give direct access to the network packets at the lowest level.
58 devices give access to IP, TCP, or UDP services.
60 Most programs that use TCP/IP use code like the following to access the
65 if ((tcp_device= getenv("TCP_DEVICE")) == NULL)
66 tcp_device= "/dev/tcp";
70 The low level networking programs such as
72 also have options to select the device they are working with. The
76 .BI ETH_DEVICE= device
80 Device to use as raw ethernet device instead of the default /dev/eth.
83 .BI PSIP_DEVICE= device
87 Pseudo IP device to use instead of
95 IP device to use instead of
99 .BI TCP_DEVICE= device
103 TCP device to use instead of
107 .BI UDP_DEVICE= device
111 UDP device to use instead of
116 Access to the IP services is provided using filedescriptors to open IP
117 devices. These open IP channels can be configured with
119 calls, and data can be transferred by calls to
123 .SS "Types (general)"
138 for use in prototypes).
140 .IP <net/gen/ether.h>
142 Defines struct ether_addr (\fBether_addr_t\fP) and
146 for use in prototypes.
147 .IP <net/gen/eth_io.h>
149 Defines struct nwio_ethopt (\fBnwio_ethopt_t\fP) and
150 struct nwio_ethstat (\fBnwio_ethstat_t\fP)
151 .IP <net/gen/eth_hdr.h>
153 Defines struct eth_hdr (\fBeth_hdr_t\fP)
155 .IP <net/gen/psip_hdr.h>
157 [[[No description available yet.]]]
158 .IP <net/gen/psip_io.h>
160 [[[No description available yet.]]]
167 and struct ip_hdropt (\fBip_hdropt_t\fP).
168 .IP <net/gen/ip_io.h>
170 Defines struct nwio_ipconf (\fBnwio_ipconf_t\fP) and
171 struct nwio_ipopt (\fBnwio_ipopt_t\fP)
172 .IP <net/gen/ip_hdr.h>
174 Defines struct ip_hdr (\fBip_hdr_t\fP)
175 .IP <net/gen/route.h>
177 Defines struct nwio_route (\fBnwio_route_t\fP)
185 for use in prototypes.
186 .IP <net/gen/tcp_io.h>
188 Defines struct nwio_tcpconf (\fBnwio_tcpconf_t\fP),
189 struct nwio_tcpcl (\fBnwio_tcpcl_t\fP),
190 struct nwio_tcpatt (\fBnwio_tcpatt_t\fP) and
191 struct nwio_tcpopt (\fBnwio_tcpopt_t\fP).
192 .IP <net/gen/tcp_hdr.h>
194 Defines struct tcp_hdr (\fBtcp_hdr_t\fP) and struct tcp_hdropt
195 (\fBtcp_hdropt_t\fP).
203 for use in prototypes.
204 .IP <net/gen/udp_io.h>
206 Defines struct nwio_udpopt (\fBnwio_udpopt_t\fP).
207 .IP <net/gen/udp_hdr.h>
209 Defines struct udp_hdr (\fBudp_hdr_t\fP) and struct udp_io_hdr
210 (\fBudp_io_hdr_t\fP).
211 .SS "Byte Order Conversion"
212 All 16-bit and 32-bit quantities in IP headers must be in network byte
213 order. The macros described in
215 can be used to convert these values to and from the byte order used by
217 .SS "The Internet Checksum"
222 is used to calculate the one's complement checksum needed for IP network
224 .SS "General Functions"
227 \fIfd\fP = open(\fItcpip_device\fP, O_RDWR)
230 This is how one normally obtains a filedescriptor for a new TCP/IP channel.
232 names one of the TCP/IP devices. The channel may be used both to send or to
236 \fIn\fP = read(\fIfd\fP, \fIbuf\fP, \fIsize\fP)
239 Receives one packet (low level devices) or a number of bytes (TCP stream).
240 Returns the the number of bytes placed into
242 or returns -1 with an error code placed into
246 \fIn\fP = write(\fIfd\fP, \fIbuf\fP, \fIsize\fP)
249 Sends one packet (low level devices) or a number of bytes (TCP stream).
252 or -1 with the error code placed into
258 functions behave like reads and writes on pipes when it comes to signals.
262 ioctl(\fIfd\fP, NWIOGETHSTAT, &struct nwio_ethstat)
268 returns the Ethernet address and some statistics of the Ethernet server of
271 The result is returned in the nwio_ethstat structure.
272 The \fBstruct nwio_ethstat\fP is defined in <net/gen/eth_io.h>:
277 typedef struct nwio_ethstat
279 ether_addr_t nwes_addr;
280 eth_stat_t nwes_stat;
283 typedef struct eth_stat
285 unsigned long ets_recvErr, /* # receive errors */
286 ets_sendErr, /* # send error */
287 ets_OVW, /* # buffer overwrite warnings,
288 (packets arrive faster than
290 ets_CRCerr, /* # crc errors of read */
291 ets_frameAll, /* # frames not aligned (# bits
292 not a multiple of 8) */
293 ets_missedP, /* # packets missed due to too
294 slow packet processing */
295 ets_packetR, /* # packets received */
296 ets_packetT, /* # packets transmitted */
297 ets_transDef, /* # transmission deferred (there
298 was a transmission of an
299 other station in progress */
300 ets_collision, /* # collisions */
301 ets_transAb, /* # transmissions aborted due
302 to excessive collisions */
303 ets_carrSense, /* # carrier sense lost */
304 ets_fifoUnder, /* # fifo underruns (processor
306 ets_fifoOver, /* # fifo overruns (processor is
308 ets_CDheartbeat, /* # times unable to transmit
310 ets_OWC; /* # times out of window
318 ioctl(\fIfd\fP, NWIOSETHOPT, &struct nwio_ethopt)
321 Before an Ethernet channel can be used to send or receive
322 Ethernet packets, it has to be configured using the
327 is defined in <net/gen/eth_io.h>:
332 typedef struct nwio_ethopt
335 ether_addr_t nweo_multi, nweo_rem;
336 ether_type_t nweo_type;
339 #define NWEO_NOFLAGS 0x0000L
340 #define NWEO_ACC_MASK 0x0003L
341 # define NWEO_EXCL 0x00000001L
342 # define NWEO_SHARED 0x00000002L
343 # define NWEO_COPY 0x00000003L
344 #define NWEO_LOC_MASK 0x0010L
345 # define NWEO_EN_LOC 0x00000010L
346 # define NWEO_DI_LOC 0x00100000L
347 #define NWEO_BROAD_MASK 0x0020L
348 # define NWEO_EN_BROAD 0x00000020L
349 # define NWEO_DI_BROAD 0x00200000L
350 #define NWEO_MULTI_MASK 0x0040L
351 # define NWEO_EN_MULTI 0x00000040L
352 # define NWEO_DI_MULTI 0x00400000L
353 #define NWEO_PROMISC_MASK 0x0080L
354 # define NWEO_EN_PROMISC 0x00000080L
355 # define NWEO_DI_PROMISC 0x00800000L
356 #define NWEO_REM_MASK 0x0100L
357 # define NWEO_REMSPEC 0x00000100L
358 # define NWEO_REMANY 0x01000000L
359 #define NWEO_TYPE_MASK 0x0200L
360 # define NWEO_TYPESPEC 0x00000200L
361 # define NWEO_TYPEANY 0x02000000L
362 #define NWEO_RW_MASK 0x1000L
363 # define NWEO_RWDATONLY 0x00001000L
364 # define NWEO_RWDATALL 0x10000000L
369 The configuration is divided in a number of section (covered by the xx_MASK
371 Options can be set in the
374 The first section (\fBNWEO_ACC_MASK\fP) controls the access to a certain
375 Ethernet packet type.
378 is selected then this is the only channel that can send or
379 receive Ethernet packets of the selected type.
382 is selected then multiple channels (which all have to
385 can use the same Ethernet type, they all can send
386 packets but incoming packets will be delivered to at most one of them.
389 is selected then multiple channels have access to the same
390 Ethernet type and all receive a copy of an incoming packet.
394 flags control the delivery of packets with a destination
395 address equal to the Ethernet address of the machine.
398 is selected then these packets will be delivered and with
400 they will be discarded.
402 .BR NWEO_BROAD_MASK ,
403 .BR NWEO_MULTI_MASK ,
406 do the same to broadcast packets,
407 multicast packets and promiscuous mode packets as
409 does for local packets.
410 Except that the precise multicast address is taken from the \fBnweo_multi\fP
415 flags control whether communication is restricted to
416 single destination or not.
418 restricts sending and receiving of packets to the single
419 remote computer specified in the \fBnweo_rem\fP field.
421 allows sending to and receiving from any remote computer.
424 restricts sending and receiving of packets to the type
425 specified in \fBnweo_type\fP.
426 The type has to be in network byte order (using
431 If the Ethernet header is completely specified by the
437 .BR NWEO_DI_PROMISC ,
444 can be used to send and receive only the data part of an Ethernet packet.
447 is specified then both Ethernet header and data are used.
450 [[[No description available yet.]]]
454 ioctl(\fIfd\fP, NWIOGIPCONF, &struct nwio_ipconf)
459 ioctl reports the Internet Address and the netmask.
460 For the \fInwio_ipconf\fP structure see the \fBNWIOSIPCONF\fP ioctl below.
463 ioctl(\fIfd\fP, NWIOGIPOROUTE, &struct nwio_route)
468 ioctl can be used to query an IP server about its routing table.
469 [[[NWIODIPOROUTE, NWIOGIPIROUTE, NWIODIPIROUTE?]]]
470 The structure \fBnwio_route\fP is defined in <net/gen/route.h>:
475 typedef struct nwio_route
480 ipaddr_t nwr_netmask;
481 ipaddr_t nwr_gateway;
494 The requested entry is taken from \fBnwr_ent_no\fP.
495 Entries are counted from 0, so the value 0 can be used for an initial query.
496 The size of the routing table is returned in \fBnwr_ent_count\fP.
497 The \fBnwr_flags\fP indicates if the entry is in use (\fBNWRF_INUSE\fP) and
498 if the entry was inserted manually (using \fBNWIOSIPOROUTE\fP) or generated
499 by the IP server itself.
500 The route is described by
507 \fBNwr_dest\fP and \fBnwr_netmask\fP select the destination addresses.
508 A value of 0.0.0.0 (0x0) in both \fBnwr_dest\fP and \fBnwr_netmask\fP means
510 A value of 255.255.255.255 (0xffffffff) in \fBnwr_netmask\fP means a single
512 Other values of \fBnwr_netmask\fP are netmasks for the network specified
514 \fBNwr_gateway\fP is gateway that should be used.
515 \fBNwr_dist\fP is a minimal distance.
516 Packets with a time to live smaller than \fBnwr_dist\fP will not reach the
518 If two routes have equal netmask and distance fields but different
519 gateways then the gateway with highest value in \fBnwr_pref\fP is used.
522 ioctl(\fIfd\fP, NWIOSIPCONF, &struct nwio_ipconf)
527 ioctl can be used to inform the IP server about its Internet Address
529 Normally an IP server will discover its Internet Address using the RARP
532 can be used in the case that the RARP failed, or the netmask has to be changed.
533 Note that higher level protocols (TCP and UDP) assume that the Internet Address
534 of an IP device does not change, therefore TCP and UDP stop functioning if
535 the Internet Address is changed.
537 The structure \fBnwio_ipconf\fP is defined in <net/gen/ip_io.h>:
542 typedef struct nwio_ipconf
545 ipaddr_t nwic_ipaddr;
546 ipaddr_t nwic_netmask;
549 #define NWIC_NOFLAGS 0x0
550 #define NWIC_FLAGS 0x3
551 # define NWIC_IPADDR_SET 0x1
552 # define NWIC_NETMASK_SET 0x2
557 The function of \fBnwio_ipconf\fP depends on the value of \fBnwic_flags\fP.
560 is set then the Internet Address will be set to
564 is set then the Internet Address will be set to
568 ioctl(\fIfd\fP, NWIOSIPOPT, &struct nwio_ipopt)
571 Before an IP channel can be used, it has to be configured using the
574 The structure \fBnwio_ipopt\fP is defined in <net/gen/ip_io.h>:
579 typedef struct nwio_ipopt
583 ip_hdropt_t nwio_hdropt;
587 ipproto_t nwio_proto;
590 #define NWIO_NOFLAGS 0x0000L
591 #define NWIO_ACC_MASK 0x0003L
592 # define NWIO_EXCL 0x00000001L
593 # define NWIO_SHARED 0x00000002L
594 # define NWIO_COPY 0x00000003L
595 #define NWIO_LOC_MASK 0x0010L
596 # define NWIO_EN_LOC 0x00000010L
597 # define NWIO_DI_LOC 0x00100000L
598 #define NWIO_BROAD_MASK 0x0020L
599 # define NWIO_EN_BROAD 0x00000020L
600 # define NWIO_DI_BROAD 0x00200000L
601 #define NWIO_REM_MASK 0x0100L
602 # define NWIO_REMSPEC 0x00000100L
603 # define NWIO_REMANY 0x01000000L
604 #define NWIO_PROTO_MASK 0x0200L
605 # define NWIO_PROTOSPEC 0x00000200L
606 # define NWIO_PROTOANY 0x02000000L
607 #define NWIO_HDR_O_MASK 0x0400L
608 # define NWIO_HDR_O_SPEC 0x00000400L
609 # define NWIO_HDR_O_ANY 0x04000000L
610 #define NWIO_RW_MASK 0x1000L
611 # define NWIO_RWDATONLY 0x00001000L
612 # define NWIO_RWDATALL 0x10000000L
617 The options are divided in several categories:
620 .BR NWIO_BROAD_MASK ,
622 .BR NWIO_PROTO_MASK ,
626 A channel is configured when one option of each category is set.
628 The options covered by
630 control the number of channels that
631 can use one IP protocol.
634 is specified then only that channel can use a certain IP protocol.
637 then multiple channels that all have to specify
639 can use the same IP protocol, but incoming packets will
640 be delivered to a most one channel.
642 does not impose any restrictions.
643 Every channel gets a copy of an incoming packet.
648 control the delivery of packets.
651 is specified then packets that are explicitly send to
652 the IP server are delivered.
655 is specified then broadcast packets are delivered.
656 Either one or both of them can be disabled with
662 can be used to restrict communication to one remote host.
663 This host is taken from the \fBnwio_rem\fP field.
664 If any remote host is to be allowed then
669 restricts communication to one IP protocol, specified
672 allows any protocol to be sent or received.
675 specifies all IP header options in advance.
676 The values are taken from
682 \fBNwio_hdropt\fP specifies the IP options that should be present in an
684 \fBIp_hdropt_t\fP is defined in <net/gen/in.h>:
689 typedef struct ip_hdropt
692 u8_t iho_data[IP_MAX_HDR_SIZE-IP_MIN_HDR_SIZE];
698 The bytes of size \fBiho_opt_siz\fP in \fBiho_data\fP are appended to the IP
700 \fBNwio_tos\fP specifies the value of the ``type of service'' bits,
701 \fBnwio_ttl\fP gives the value of the ``time to live'' field and \fBnwio_df\fP
702 specifies whether fragmentation is disallowed or not.
704 specifies that the header options should be specified at
708 specifies that the header should be omitted from a
710 This option can only be used when all header fields are specified in previous
717 .BR NWIO_HDR_O_SPEC .
718 A read operation will also only return the data part, so the IP options will
722 ioctl(\fIfd\fP, NWIOSIPOROUTE, &struct nwio_route)
727 ioctl adds a route to the routing table.
728 See \fBNWIOGIPOROUTE\fP above for a description of the \fBnwio_route\fP
730 The fields \fBnwr_ent_no\fP and \fBnwr_ent_count\fP are ignored.
734 ioctl(\fIfd\fP, NWIOTCPCONN, &struct nwio_tcpcl)
739 ioctl tries to setup a connection with a remote TCP/IP server.
740 The channel must be fully configured (see
742 and values for the local port, the remote port and the remote address have be
750 The struct nwio_tcpcl is defined in <net/gen/tcp_io.h> as:
755 typedef struct nwio_tcpcl
766 field to zero before the connect or listen call. [[[Further explanation of
770 ioctl(\fIfd\fP, NWIOGTCPCONF, &struct nwio_tcpconf)
773 This call reports the current configuration of a TCP channel.
776 field shows the status of the
784 contains the Internet address of the TCP/IP server.
786 contains the Internet address of the remote TCP/IP server when set with
788 or after a successful connect or listen (see
793 contains the local TCP/IP port set with
795 or the selected port set with
798 contains the TCP port of the remote TCP/IP server as set with
800 or after a successful connect or listen.
802 A value of 0 (zero) is reported for
807 when no value is set either explicitly or implicitly.
810 ioctl(\fIfd\fP, NWIOTCPLISTEN, &struct nwio_tcpcl)
815 ioctl waits until a remote TCP/IP server tries to connect to this channel.
816 The channel has to be configured (see
818 An additional restriction is that the local port
823 When a remote address is set only connections for that host are accepted, and
824 when a remote port is set only connections from that port are accepted.
825 After a successful listen
827 can be used to find out what the address and port of the other side are.
830 ioctl(\fIfd\fP, NWIOSTCPCONF, &struct nwio_tcpconf)
833 Before a TCP channel can be used it must configured using the
838 are the channel file descriptor and a
839 .B struct nwio_tcpconf
840 as defined in <net/gen/tcp_io.h>:
845 typedef struct nwio_tcpconf
848 ipaddr_t nwtc_locaddr;
849 ipaddr_t nwtc_remaddr;
850 tcpport_t nwtc_locport;
851 tcpport_t nwtc_remport;
854 #define NWTC_NOFLAGS 0x0000L
855 #define NWTC_ACC_MASK 0x0003L
856 # define NWTC_EXCL 0x00000001L
857 # define NWTC_SHARED 0x00000002L
858 # define NWTC_COPY 0x00000003L
859 #define NWTC_LOCPORT_MASK 0x0030L
860 # define NWTC_LP_UNSET 0x00000010L
861 # define NWTC_LP_SET 0x00000020L
862 # define NWTC_LP_SEL 0x00000030L
863 #define NWTC_REMADDR_MASK 0x0100L
864 # define NWTC_SET_RA 0x00000100L
865 # define NWTC_UNSET_RA 0x01000000L
866 #define NWTC_REMPORT_MASK 0x0200L
867 # define NWTC_SET_RP 0x00000200L
868 # define NWTC_UNSET_RP 0x02000000L
873 A tcp channel is considered configured when one flag in each category has
894 The acc flags control the access to a certain TCP port.
896 means exclusive access.
897 An attempt to configure a channel will be denied if the same port is specified
898 as that of a channel that requested exclusive access.
900 indicates that several channels use the same port but cooperate.
901 If the shared mode is specified for one channel than all other channel that
902 use the same port should also be configured with the
906 is specified when the programmer does not care about other channels.
909 The locport flags control which TCP port is used for communication.
911 indicates the absence of a local port.
916 field contains the local port to be used by TCP.
917 This value must be in network byte order (see
920 requests the TCP server to pick a port.
921 This port will be in the range from 32768 to 65535 and will be unique.
925 flags specify which hosts are acceptable for connections.
927 indicates that only connection to the host specified in
931 should be in network byte order (see
934 allows every host on the other side of a connection.
939 flags specify which remote ports are acceptable for connections.
941 indicates that only the port specified in
945 allows every port on the other side of a connection.
949 ioctl(\fIfd\fP, NWIOTCPSHUTDOWN)
954 tells the TCP/IP server that no more data will be sent over the channel
957 This command can be issued when the channel is connected to a remote TCP/IP
959 The TCP/IP server will tell the remote TCP/IP server and the client of the
960 remote TCP/IP server will receive an end-of-file indication.
963 ioctl(\fIfd\fP, NWIOGTCPOPT, &struct nwio_tcpopt)
965 ioctl(\fIfd\fP, NWIOSTCPOPT, &struct nwio_tcpopt)
968 The behaviour of a TCP channel may be changed by setting a number of
969 options. The TCP options can be obtained with the
971 ioctl and set with the
973 ioctl. The options are passed in a
974 .B struct nwio_tcpopt
975 as defined in <net/gen/tcp_io.h>:
980 typedef struct nwio_tcpopt
985 #define NWTO_NOFLAG 0x0000L
986 #define NWTO_SND_URG_MASK 0x0001L
987 # define NWTO_SND_URG 0x00000001L
988 # define NWTO_SND_NOTURG 0x00010000L
989 #define NWTO_RCV_URG_MASK 0x0002L
990 # define NWTO_RCV_URG 0x00000002L
991 # define NWTO_RCV_NOTURG 0x00020000L
992 #define NWTO_BSD_URG_MASK 0x0004L
993 # define NWTO_BSD_URG 0x00000004L
994 #define NWTO_DEL_RST_MASK 0x0008L
995 # define NWTO_DEL_RST 0x00000008L
1002 option causes bytes written to the channel to be send out as urgent data.
1007 option must be set to switch over to reading urgent data. When all urgent
1008 data has been read an
1011 indicating that the option must be cleared with
1012 .BR NWTO_RCV_NOTURG .
1013 Alas the BSD implementation of urgent data disagrees with the RFC's, so to
1014 be BSD compatible one must set the
1016 option beforehand on a channel that is to send or receive urgent data.
1017 Given that the BSD implementation is the regarded as the TCP/IP standard one
1018 should always use the BSD style. The
1020 option delays a failure response on a connect to the same port as the
1021 current open connection. Without this option a connect would fail if
1022 a server is not yet listening. With this option a connect will linger
1023 on until the server starts listening. This option is useful for a server
1024 that opens a connection, tells the remote end the local port number and
1025 then listens (FTP), or for a program that forks off servers for incoming
1026 connections (TELNET). A new connection may come in before a new listen
1027 can be started, so it is nice if the new connect doesn't fail. Use this
1028 option only when it is clearly needed.
1032 ioctl(\fIfd\fP, NWIOGUDPOPT, &struct nwio_udpopt)
1037 ioctl returns the current options that result from the default options
1038 and the options set with
1044 is selected the local port is returned in
1048 is selected the remote port is returned in
1050 The local address is always returned in
1054 is selected the remote address is returned in
1058 ioctl(\fIfd\fP, NWIOSUDPOPT, &struct nwio_udpopt)
1061 A UDP channel must be configured using the
1063 ioctl before any data can be read or written.
1065 takes two parameters, a file descriptor to an open UDP device and
1068 structure that describes the requested configuration.
1071 structure is defined in <net/gen/udp_io.h> as:
1076 typedef struct nwio_udpopt
1078 unsigned long nwuo_flags;
1079 udpport_t nwuo_locport;
1080 udpport_t nwuo_remport;
1081 ipaddr_t nwuo_locaddr;
1082 ipaddr_t nwuo_remaddr;
1085 #define NWUO_NOFLAGS 0x0000L
1086 #define NWUO_ACC_MASK 0x0003L
1087 #define NWUO_EXCL 0x00000001L
1088 #define NWUO_SHARED 0x00000002L
1089 #define NWUO_COPY 0x00000003L
1090 #define NWUO_LOCPORT_MASK 0x000CL
1091 #define NWUO_LP_SEL 0x00000004L
1092 #define NWUO_LP_SET 0x00000008L
1093 #define NWUO_LP_ANY 0x0000000CL
1094 #define NWUO_LOCADDR_MASK 0x0010L
1095 #define NWUO_EN_LOC 0x00000010L
1096 #define NWUO_DI_LOC 0x00100000L
1097 #define NWUO_BROAD_MASK 0x0020L
1098 #define NWUO_EN_BROAD 0x00000020L
1099 #define NWUO_DI_BROAD 0x00200000L
1100 #define NWUO_REMPORT_MASK 0x0100L
1101 #define NWUO_RP_SET 0x00000100L
1102 #define NWUO_RP_ANY 0x01000000L
1103 #define NWUO_REMADDR_MASK 0x0200L
1104 #define NWUO_RA_SET 0x00000200L
1105 #define NWUO_RA_ANY 0x02000000L
1106 #define NWUO_RW_MASK 0x1000L
1107 #define NWUO_RWDATONLY 0x00001000L
1108 #define NWUO_RWDATALL 0x10000000L
1109 #define NWUO_IPOPT_MASK 0x2000L
1110 #define NWUO_EN_IPOPT 0x00002000L
1111 #define NWUO_DI_IPOPT 0x20000000L
1116 A UDP channel is considered configured when one flag in each category has been
1145 .BR NWUO_RWDATONLY ,
1152 The acc flags control the access to a certain UDP port.
1154 means exclusive access:
1155 no other channel can use this port.
1157 means shared access:
1158 only channels that specify shared access can use this port
1159 and all packets that are received are handed to at most one channel.
1161 imposes no access restriction and all channels get a copy of every received
1162 packet for that port.
1166 flags control the selection of the UDP port for this channel.
1168 requests the server to pick a port.
1169 This port will be in the range from 32768 to 65535 and it will be unique.
1171 sets the local port to the value of the
1175 does not select a port.
1176 Reception of data is therefore not possible but it is
1177 possible to send data.
1181 flags control the reception of packets.
1183 enables the reception of packets with the local IP address as destination.
1185 disables the reception of packet for the local IP address.
1189 flags control the reception of broadcast packets.
1191 enables the reception of broadcast packets and
1193 disables the reception of broadcast packets.
1197 flags let the client to specify one specific remote UDP port or
1198 to allow any remote port.
1200 sets the remote UDP port to the value of
1202 Only packets with a matching remote port will be delivered
1203 and all packets will be sent to that port.
1205 allows reception of packets form any port and when transmitting packets the
1206 remote port has to be specified.
1210 flags control the remote IP address.
1212 sets the remote IP address the value of
1214 Only packets from that address will be delivered and all packets will be sent
1217 allows reception of packets from any host and when transmitting packets the
1218 remote host has to be specified.
1222 flags control the format of the data to be sent or received.
1225 only the data part of a UDP packet is sent to the server and only the data
1226 part is received from the server.
1229 mode presents the data part of a UDP packet with a header that contains
1230 the source and destination IP address, source and destination UDP ports,
1231 the IP options, etc.
1232 The server expects such a header in front of the data to be transmitted.
1233 .ig \" Some for Philip to explain properly:
1234 The header is defined in <net/gen/udp_hdr.h> and looks like this:
1239 typedef struct udp_io_hdr
1241 ipaddr_t uih_src_addr;
1242 ipaddr_t uih_dst_addr;
1243 udpport_t uih_src_port;
1244 udpport_t uih_dst_port;
1245 u16_t uih_ip_opt_len;
1252 The first four fields are the source and destination IP addresses and
1257 should equal the length of the packet data (packet lenght minus the
1263 flags control the delivery and transmission of IP options.
1266 is set IP, options will be delivered and sent.
1269 is set IP option will be stripped from received packets and no IP options will
1271 .ig \" MINIX 3 doesn't have this stuff (yet? ever?)
1272 .SS "UDP Library Functions"
1274 The following routines provide an somewhat easier to use interface to UDP than
1275 the routines described above (\fBtcpip_open\fP, \fBudp_ioc_setopt\fP,
1276 \fBtcpip_read\fP and \fBtcpip_write\fP).
1280 udp_connect(udp_cap, chan_cap, srcport, dstport, dstaddr, flags)
1281 capability *udp_cap;
1282 capability *chan_cap;
1288 .kW "\fIudp_connect\fP"
1289 \fIUdp_connect\fP combines the functionality of \fItcpip_open\fP and
1290 \fIudp_ioc_setopt\fP.
1291 A pointer to a UDP server capability should be passed in \fIudp_cap\fP, and
1292 the channel capability will be returned in the capability pointed to by
1294 If \fIsrcport\fP is 0 then an unused port will be selected, otherwise the local
1295 port will be set to \fIsrcport\fP.
1296 If \fIdstport\fP is non-zero then communication will be restricted to remote ports
1297 that equal to \fIdstport\fP, otherwise any data can be sent to or received from
1299 The same thing applies to \fIdstaddr\fP; if \fIdstaddr\fP is non-zero then
1300 only \fIdstaddr\fP can be reached.
1301 Currently no flags are defined so \fIflags\fP should be 0.
1307 udp_reconnect(chan_cap, srcport, dstport, dstaddr, flags)
1308 capability *chan_cap;
1314 .kW "\fIudp_reconnect\fP"
1315 \fIUdp_reconnect\fP is the same as \fIudp_connect\fP except that an existing
1316 channel capability is (re)used.
1322 udp_read_msg(chan_cap, msg, msglen, actlen, flags)
1323 capability *chan_cap;
1329 .kW "\fIudp_read_msg\fP"
1330 \fIUdp_read_msg\fP delivers a UDP packet.
1331 The data part of the UDP packet is
1332 prepended with an \fIudp_io_hdr\fP.
1333 The actual length of the possibly truncated packet is returned in \fIactlen\fP.
1334 No flags are defined so \fIflags\fP should be 0.
1340 udp_write_msg(chan_cap, msg, msglen, flags)
1341 capability *chan_cap;
1346 .kW "\fIudp_write_msg\fP"
1347 A UDP packet can be sent with \fIudp_write_msg\fP.
1348 \fIMsg\fP should point to a \fIudp_io_hdr\fP followed by the data part of the
1350 The \fIuih_dst_addr\fP and \fIuih_dst_port\fP fields of the \fIudp_io_hdr\fP
1351 should be filled in if no values are specified in the \fIudp_connect\fP,
1352 or \fIudp_reconnect\fP.
1358 udp_close(chan_cap, flags)
1359 capability *chan_cap;
1362 .kW "\fIudp_close\fP"
1363 \fIUdp_close\fP cleans up the administration kept by the UDP library but does
1364 not destroy the capability.
1365 The function should be used if the capability is passed to another process
1366 and should continue to exist.
1367 No flags are defined so \fIflags\fP should be 0.
1373 udp_destroy(chan_cap, flags)
1374 capability *chan_cap;
1377 .kW "\fIudp_destroy\fP"
1378 \fIUdp_destroy\fP not only cleans up the administration kept by the UDP library
1379 but also destroys the channel capability.
1382 .IP /dev/eth* \w'/dev/psip*mmm'u
1383 Raw ethernet. The numbers in the device names are decimal, so one may see
1390 First and second Pseudo IP network.
1392 IP devices for two ethernets and two Pseudo IP networks.
1394 TCP devices for same four networks.
1397 .IP "/dev/eth, /dev/psip, /dev/ip, /dev/tcp, /dev/udp"
1398 Devices for the default network, links to the devices above.
1400 is only present if ethernet is the default,
1409 Several errors may be returned by the TCP/IP server. The error code
1417 call returns -1. The TCP/IP error codes defined in <errno.h> are:
1419 This indicates an attempt to read or write with a buffer that is too
1422 The TCP/IP server has insufficient memory to execute the request.
1424 This indicates an attempt to execute a command the particular server
1425 does not understand.
1430 The request is refused because the channel is not fully configured, in the
1431 wrong state or the parameters are invalid.
1433 This indicates an illegal destination address for a packet.
1435 The destination is not reachable.
1437 The channel is already connected so a second request is refused.
1439 This address is in use.
1441 The connection is refused by the other side.
1443 The connection is reset (non-gracefully terminated) by the other side.
1445 The connection is terminated due to an expired timer.
1447 Urgent data is present and the current receive mode does not allow urgent data
1450 No urgent data is present and a request came for urgent data.
1452 The request requires a connected channel and the channel is not connected.
1454 The connection is shut down.
1457 has been executed so no more data can be transmitted.
1459 The connection does not exist.
1461 A generic error code for extremely weird cases.
1463 Philip Homburg (philip@cs.vu.nl)
1466 .\" $PchId: ip.4,v 1.4 2001/01/08 19:58:14 philip Exp $