[9] | 1 | .\"
|
---|
| 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.
|
---|
| 5 | .\"
|
---|
| 6 | .ig
|
---|
| 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.
|
---|
| 15 | ..
|
---|
| 16 | .TH IP 4
|
---|
| 17 | .SH NAME
|
---|
| 18 | ip, eth, psip, udp, tcp \- Internet Protocol server devices and definitions
|
---|
| 19 | .SH DESCRIPTION
|
---|
| 20 | .de SP
|
---|
| 21 | .if t .sp 0.4
|
---|
| 22 | .if n .sp
|
---|
| 23 | ..
|
---|
| 24 | The
|
---|
| 25 | .BR ip* ,
|
---|
| 26 | .BR eth* ,
|
---|
| 27 | .BR psip* ,
|
---|
| 28 | .BR tcp* ,
|
---|
| 29 | and
|
---|
| 30 | .B udp*
|
---|
| 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
|
---|
| 34 | .B eth*
|
---|
| 35 | or a
|
---|
| 36 | .B psip*
|
---|
| 37 | device, not both.)
|
---|
| 38 | The
|
---|
| 39 | .B *
|
---|
| 40 | in the device names is a decimal number, so one may see names from
|
---|
| 41 | .B ip0
|
---|
| 42 | to
|
---|
| 43 | .BR ip15 .
|
---|
| 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.
|
---|
| 47 | .PP
|
---|
| 48 | The
|
---|
| 49 | .B eth*
|
---|
| 50 | and
|
---|
| 51 | .B psip*
|
---|
| 52 | devices give direct access to the network packets at the lowest level.
|
---|
| 53 | The
|
---|
| 54 | .BR ip* ,
|
---|
| 55 | .BR tcp* ,
|
---|
| 56 | and
|
---|
| 57 | .B udp*
|
---|
| 58 | devices give access to IP, TCP, or UDP services.
|
---|
| 59 | .PP
|
---|
| 60 | Most programs that use TCP/IP use code like the following to access the
|
---|
| 61 | proper devices:
|
---|
| 62 | .PP
|
---|
| 63 | .RS
|
---|
| 64 | .nf
|
---|
| 65 | if ((tcp_device= getenv("TCP_DEVICE")) == NULL)
|
---|
| 66 | tcp_device= "/dev/tcp";
|
---|
| 67 | .fi
|
---|
| 68 | .RE
|
---|
| 69 | .PP
|
---|
| 70 | The low level networking programs such as
|
---|
| 71 | .BR ifconfig (8)
|
---|
| 72 | also have options to select the device they are working with. The
|
---|
| 73 | convention is:
|
---|
| 74 | .PP
|
---|
| 75 | .RS
|
---|
| 76 | .BI ETH_DEVICE= device
|
---|
| 77 | .br
|
---|
| 78 | .BI -E " device"
|
---|
| 79 | .RS
|
---|
| 80 | Device to use as raw ethernet device instead of the default /dev/eth.
|
---|
| 81 | .RE
|
---|
| 82 | .SP
|
---|
| 83 | .BI PSIP_DEVICE= device
|
---|
| 84 | .br
|
---|
| 85 | .BI -P " device"
|
---|
| 86 | .RS
|
---|
| 87 | Pseudo IP device to use instead of
|
---|
| 88 | .BR /dev/psip .
|
---|
| 89 | .RE
|
---|
| 90 | .SP
|
---|
| 91 | .BI IP_DEVICE= device
|
---|
| 92 | .br
|
---|
| 93 | .BI -I " device"
|
---|
| 94 | .RS
|
---|
| 95 | IP device to use instead of
|
---|
| 96 | .BR /dev/ip .
|
---|
| 97 | .RE
|
---|
| 98 | .SP
|
---|
| 99 | .BI TCP_DEVICE= device
|
---|
| 100 | .br
|
---|
| 101 | .BI -T " device"
|
---|
| 102 | .RS
|
---|
| 103 | TCP device to use instead of
|
---|
| 104 | .BR /dev/tcp .
|
---|
| 105 | .RE
|
---|
| 106 | .SP
|
---|
| 107 | .BI UDP_DEVICE= device
|
---|
| 108 | .br
|
---|
| 109 | .BI -U " device"
|
---|
| 110 | .RS
|
---|
| 111 | UDP device to use instead of
|
---|
| 112 | .BR /dev/udp .
|
---|
| 113 | .RE
|
---|
| 114 | .RE
|
---|
| 115 | .SS Programming
|
---|
| 116 | Access to the IP services is provided using filedescriptors to open IP
|
---|
| 117 | devices. These open IP channels can be configured with
|
---|
| 118 | .BR ioctl (2)
|
---|
| 119 | calls, and data can be transferred by calls to
|
---|
| 120 | .BR read (2),
|
---|
| 121 | and
|
---|
| 122 | .BR write (2).
|
---|
| 123 | .SS "Types (general)"
|
---|
| 124 | .IP <sys/types.h>
|
---|
| 125 | .br
|
---|
| 126 | Defines
|
---|
| 127 | .BR u8_t ,
|
---|
| 128 | .BR u16_t ,
|
---|
| 129 | .B u32_t
|
---|
| 130 | and
|
---|
| 131 | .B i32_t
|
---|
| 132 | (and
|
---|
| 133 | .BR U8_t ,
|
---|
| 134 | .BR U16_t ,
|
---|
| 135 | .B U32_t
|
---|
| 136 | and
|
---|
| 137 | .B I32_t
|
---|
| 138 | for use in prototypes).
|
---|
| 139 | .SS "Types (eth)"
|
---|
| 140 | .IP <net/gen/ether.h>
|
---|
| 141 | .br
|
---|
| 142 | Defines struct ether_addr (\fBether_addr_t\fP) and
|
---|
| 143 | .B ether_type_t
|
---|
| 144 | and
|
---|
| 145 | .B Ether_type_t
|
---|
| 146 | for use in prototypes.
|
---|
| 147 | .IP <net/gen/eth_io.h>
|
---|
| 148 | .br
|
---|
| 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>
|
---|
| 152 | .br
|
---|
| 153 | Defines struct eth_hdr (\fBeth_hdr_t\fP)
|
---|
| 154 | .SS "Types (psip)"
|
---|
| 155 | .IP <net/gen/psip_hdr.h>
|
---|
| 156 | .br
|
---|
| 157 | [[[No description available yet.]]]
|
---|
| 158 | .IP <net/gen/psip_io.h>
|
---|
| 159 | .br
|
---|
| 160 | [[[No description available yet.]]]
|
---|
| 161 | .SS "Types (ip)"
|
---|
| 162 | .IP <net/gen/in.h>
|
---|
| 163 | .br
|
---|
| 164 | Defines
|
---|
| 165 | .BR ipaddr_t ,
|
---|
| 166 | .BR ipproto_t
|
---|
| 167 | and struct ip_hdropt (\fBip_hdropt_t\fP).
|
---|
| 168 | .IP <net/gen/ip_io.h>
|
---|
| 169 | .br
|
---|
| 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>
|
---|
| 173 | .br
|
---|
| 174 | Defines struct ip_hdr (\fBip_hdr_t\fP)
|
---|
| 175 | .IP <net/gen/route.h>
|
---|
| 176 | .br
|
---|
| 177 | Defines struct nwio_route (\fBnwio_route_t\fP)
|
---|
| 178 | .SS "Types (tcp)"
|
---|
| 179 | .IP <net/gen/tcp.h>
|
---|
| 180 | .br
|
---|
| 181 | Defines
|
---|
| 182 | .B tcpport_t
|
---|
| 183 | and
|
---|
| 184 | .B Tcpport_t
|
---|
| 185 | for use in prototypes.
|
---|
| 186 | .IP <net/gen/tcp_io.h>
|
---|
| 187 | .br
|
---|
| 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>
|
---|
| 193 | .br
|
---|
| 194 | Defines struct tcp_hdr (\fBtcp_hdr_t\fP) and struct tcp_hdropt
|
---|
| 195 | (\fBtcp_hdropt_t\fP).
|
---|
| 196 | .SS "Types (udp)"
|
---|
| 197 | .IP <net/gen/udp.h>
|
---|
| 198 | .br
|
---|
| 199 | Defines
|
---|
| 200 | .B udpport_t
|
---|
| 201 | and
|
---|
| 202 | .B Udpport_t
|
---|
| 203 | for use in prototypes.
|
---|
| 204 | .IP <net/gen/udp_io.h>
|
---|
| 205 | .br
|
---|
| 206 | Defines struct nwio_udpopt (\fBnwio_udpopt_t\fP).
|
---|
| 207 | .IP <net/gen/udp_hdr.h>
|
---|
| 208 | .br
|
---|
| 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
|
---|
| 214 | .BR hton (3)
|
---|
| 215 | can be used to convert these values to and from the byte order used by
|
---|
| 216 | the host machine.
|
---|
| 217 | .SS "The Internet Checksum"
|
---|
| 218 | The
|
---|
| 219 | .B oneC_sum
|
---|
| 220 | function (see
|
---|
| 221 | .BR oneC_sum (3))
|
---|
| 222 | is used to calculate the one's complement checksum needed for IP network
|
---|
| 223 | packets.
|
---|
| 224 | .SS "General Functions"
|
---|
| 225 | .PP
|
---|
| 226 | .ft B
|
---|
| 227 | \fIfd\fP = open(\fItcpip_device\fP, O_RDWR)
|
---|
| 228 | .ft R
|
---|
| 229 | .PP
|
---|
| 230 | This is how one normally obtains a filedescriptor for a new TCP/IP channel.
|
---|
| 231 | .I tcpip_device
|
---|
| 232 | names one of the TCP/IP devices. The channel may be used both to send or to
|
---|
| 233 | receive data.
|
---|
| 234 | .PP
|
---|
| 235 | .ft B
|
---|
| 236 | \fIn\fP = read(\fIfd\fP, \fIbuf\fP, \fIsize\fP)
|
---|
| 237 | .ft R
|
---|
| 238 | .PP
|
---|
| 239 | Receives one packet (low level devices) or a number of bytes (TCP stream).
|
---|
| 240 | Returns the the number of bytes placed into
|
---|
| 241 | .IR buf ,
|
---|
| 242 | or returns -1 with an error code placed into
|
---|
| 243 | .BR errno .
|
---|
| 244 | .PP
|
---|
| 245 | .ft B
|
---|
| 246 | \fIn\fP = write(\fIfd\fP, \fIbuf\fP, \fIsize\fP)
|
---|
| 247 | .ft R
|
---|
| 248 | .PP
|
---|
| 249 | Sends one packet (low level devices) or a number of bytes (TCP stream).
|
---|
| 250 | Returns
|
---|
| 251 | .I size
|
---|
| 252 | or -1 with the error code placed into
|
---|
| 253 | .BR errno .
|
---|
| 254 | The TCP/IP
|
---|
| 255 | .B read
|
---|
| 256 | and
|
---|
| 257 | .B write
|
---|
| 258 | functions behave like reads and writes on pipes when it comes to signals.
|
---|
| 259 | .SS "ETH Functions"
|
---|
| 260 | .PP
|
---|
| 261 | .ft B
|
---|
| 262 | ioctl(\fIfd\fP, NWIOGETHSTAT, &struct nwio_ethstat)
|
---|
| 263 | .ft R
|
---|
| 264 | .PP
|
---|
| 265 | The
|
---|
| 266 | .B NWIOGETHSTAT
|
---|
| 267 | ioctl
|
---|
| 268 | returns the Ethernet address and some statistics of the Ethernet server of
|
---|
| 269 | the channel
|
---|
| 270 | .IR fd .
|
---|
| 271 | The result is returned in the nwio_ethstat structure.
|
---|
| 272 | The \fBstruct nwio_ethstat\fP is defined in <net/gen/eth_io.h>:
|
---|
| 273 | .PP
|
---|
| 274 | .RS
|
---|
| 275 | .nf
|
---|
| 276 | .if t .ft C
|
---|
| 277 | typedef struct nwio_ethstat
|
---|
| 278 | {
|
---|
| 279 | ether_addr_t nwes_addr;
|
---|
| 280 | eth_stat_t nwes_stat;
|
---|
| 281 | } nwio_ethstat_t;
|
---|
| 282 | .SP
|
---|
| 283 | typedef struct eth_stat
|
---|
| 284 | {
|
---|
| 285 | unsigned long ets_recvErr, /* # receive errors */
|
---|
| 286 | ets_sendErr, /* # send error */
|
---|
| 287 | ets_OVW, /* # buffer overwrite warnings,
|
---|
| 288 | (packets arrive faster than
|
---|
| 289 | can be processed) */
|
---|
| 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
|
---|
| 305 | is too busy) */
|
---|
| 306 | ets_fifoOver, /* # fifo overruns (processor is
|
---|
| 307 | too busy) */
|
---|
| 308 | ets_CDheartbeat, /* # times unable to transmit
|
---|
| 309 | collision signal */
|
---|
| 310 | ets_OWC; /* # times out of window
|
---|
| 311 | collision */
|
---|
| 312 | } eth_stat_t;
|
---|
| 313 | .if t .ft R
|
---|
| 314 | .fi
|
---|
| 315 | .RE
|
---|
| 316 | .PP
|
---|
| 317 | .ft B
|
---|
| 318 | ioctl(\fIfd\fP, NWIOSETHOPT, &struct nwio_ethopt)
|
---|
| 319 | .ft R
|
---|
| 320 | .PP
|
---|
| 321 | Before an Ethernet channel can be used to send or receive
|
---|
| 322 | Ethernet packets, it has to be configured using the
|
---|
| 323 | .B NWIOSETHOPT
|
---|
| 324 | ioctl.
|
---|
| 325 | The structure
|
---|
| 326 | .B nwio_ethopt
|
---|
| 327 | is defined in <net/gen/eth_io.h>:
|
---|
| 328 | .PP
|
---|
| 329 | .RS
|
---|
| 330 | .nf
|
---|
| 331 | .if t .ft C
|
---|
| 332 | typedef struct nwio_ethopt
|
---|
| 333 | {
|
---|
| 334 | u32_t nweo_flags;
|
---|
| 335 | ether_addr_t nweo_multi, nweo_rem;
|
---|
| 336 | ether_type_t nweo_type;
|
---|
| 337 | } nwio_ethopt_t;
|
---|
| 338 | .SP
|
---|
| 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
|
---|
| 365 | .if t .ft R
|
---|
| 366 | .fi
|
---|
| 367 | .RE
|
---|
| 368 | .PP
|
---|
| 369 | The configuration is divided in a number of section (covered by the xx_MASK
|
---|
| 370 | macros).
|
---|
| 371 | Options can be set in the
|
---|
| 372 | .B nweo_flags
|
---|
| 373 | field.
|
---|
| 374 | The first section (\fBNWEO_ACC_MASK\fP) controls the access to a certain
|
---|
| 375 | Ethernet packet type.
|
---|
| 376 | If
|
---|
| 377 | .B NWEO_EXCL
|
---|
| 378 | is selected then this is the only channel that can send or
|
---|
| 379 | receive Ethernet packets of the selected type.
|
---|
| 380 | If
|
---|
| 381 | .B NWEO_SHARED
|
---|
| 382 | is selected then multiple channels (which all have to
|
---|
| 383 | select
|
---|
| 384 | .BR NWEO_SHARED )
|
---|
| 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.
|
---|
| 387 | If
|
---|
| 388 | .B NWEO_COPY
|
---|
| 389 | is selected then multiple channels have access to the same
|
---|
| 390 | Ethernet type and all receive a copy of an incoming packet.
|
---|
| 391 | .LP
|
---|
| 392 | The
|
---|
| 393 | .B NWEO_LOC_MASK
|
---|
| 394 | flags control the delivery of packets with a destination
|
---|
| 395 | address equal to the Ethernet address of the machine.
|
---|
| 396 | If
|
---|
| 397 | .B NWEO_EN_LOC
|
---|
| 398 | is selected then these packets will be delivered and with
|
---|
| 399 | .B NWEO_DI_LOC
|
---|
| 400 | they will be discarded.
|
---|
| 401 | .PP
|
---|
| 402 | .BR NWEO_BROAD_MASK ,
|
---|
| 403 | .BR NWEO_MULTI_MASK ,
|
---|
| 404 | and
|
---|
| 405 | .B NWEO_PROMISC_MASK
|
---|
| 406 | do the same to broadcast packets,
|
---|
| 407 | multicast packets and promiscuous mode packets as
|
---|
| 408 | .B NWEO_LOC_MASK
|
---|
| 409 | does for local packets.
|
---|
| 410 | Except that the precise multicast address is taken from the \fBnweo_multi\fP
|
---|
| 411 | field.
|
---|
| 412 | .LP
|
---|
| 413 | The
|
---|
| 414 | .B NWEO_REM_MASK
|
---|
| 415 | flags control whether communication is restricted to
|
---|
| 416 | single destination or not.
|
---|
| 417 | .B NWEO_REMSPEC
|
---|
| 418 | restricts sending and receiving of packets to the single
|
---|
| 419 | remote computer specified in the \fBnweo_rem\fP field.
|
---|
| 420 | .B NWEO_REMANY
|
---|
| 421 | allows sending to and receiving from any remote computer.
|
---|
| 422 | .PP
|
---|
| 423 | .B NWEO_TYPESPEC
|
---|
| 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
|
---|
| 427 | .BR hton (3)).
|
---|
| 428 | .B NWEO_TYPEANY
|
---|
| 429 | allows any type.
|
---|
| 430 | .PP
|
---|
| 431 | If the Ethernet header is completely specified by the
|
---|
| 432 | .B nweo_flags
|
---|
| 433 | i.e., all of
|
---|
| 434 | .BR NWEO_EN_LOC ,
|
---|
| 435 | .BR NWEO_DI_BROAD ,
|
---|
| 436 | .BR NWEO_DI_MULTI ,
|
---|
| 437 | .BR NWEO_DI_PROMISC ,
|
---|
| 438 | .BR NWEO_REMSPEC
|
---|
| 439 | and
|
---|
| 440 | .B NWEO_TYPESPEC
|
---|
| 441 | are
|
---|
| 442 | specified, then
|
---|
| 443 | .B NWEO_RWDATONLY
|
---|
| 444 | can be used to send and receive only the data part of an Ethernet packet.
|
---|
| 445 | If
|
---|
| 446 | .B NWEO_RWDATALL
|
---|
| 447 | is specified then both Ethernet header and data are used.
|
---|
| 448 | .SS "PSIP Functions"
|
---|
| 449 | .PP
|
---|
| 450 | [[[No description available yet.]]]
|
---|
| 451 | .SS "IP Functions"
|
---|
| 452 | .PP
|
---|
| 453 | .ft B
|
---|
| 454 | ioctl(\fIfd\fP, NWIOGIPCONF, &struct nwio_ipconf)
|
---|
| 455 | .ft R
|
---|
| 456 | .PP
|
---|
| 457 | The
|
---|
| 458 | .B NWIOGIPCONF
|
---|
| 459 | ioctl reports the Internet Address and the netmask.
|
---|
| 460 | For the \fInwio_ipconf\fP structure see the \fBNWIOSIPCONF\fP ioctl below.
|
---|
| 461 | .PP
|
---|
| 462 | .ft B
|
---|
| 463 | ioctl(\fIfd\fP, NWIOGIPOROUTE, &struct nwio_route)
|
---|
| 464 | .ft R
|
---|
| 465 | .PP
|
---|
| 466 | The
|
---|
| 467 | .B NWIOGIPOROUTE
|
---|
| 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>:
|
---|
| 471 | .PP
|
---|
| 472 | .RS
|
---|
| 473 | .nf
|
---|
| 474 | .if t .ft C
|
---|
| 475 | typedef struct nwio_route
|
---|
| 476 | {
|
---|
| 477 | u32_t nwr_ent_no;
|
---|
| 478 | u32_t nwr_ent_count;
|
---|
| 479 | ipaddr_t nwr_dest;
|
---|
| 480 | ipaddr_t nwr_netmask;
|
---|
| 481 | ipaddr_t nwr_gateway;
|
---|
| 482 | u32_t nwr_dist;
|
---|
| 483 | u32_t nwr_flags;
|
---|
| 484 | u32_t nwr_pref;
|
---|
| 485 | } nwio_route_t;
|
---|
| 486 | .SP
|
---|
| 487 | #define NWRF_EMPTY 0
|
---|
| 488 | #define NWRF_INUSE 1
|
---|
| 489 | #define NWRF_FIXED 2
|
---|
| 490 | .if t .ft R
|
---|
| 491 | .fi
|
---|
| 492 | .RE
|
---|
| 493 | .PP
|
---|
| 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
|
---|
| 501 | .BR nwr_dest ,
|
---|
| 502 | .BR nwr_netmask ,
|
---|
| 503 | .BR nwr_gateway ,
|
---|
| 504 | .BR nwr_dist ,
|
---|
| 505 | and
|
---|
| 506 | .BR nwr_pref .
|
---|
| 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
|
---|
| 509 | every host.
|
---|
| 510 | A value of 255.255.255.255 (0xffffffff) in \fBnwr_netmask\fP means a single
|
---|
| 511 | host.
|
---|
| 512 | Other values of \fBnwr_netmask\fP are netmasks for the network specified
|
---|
| 513 | by \fBnwr_dest\fP.
|
---|
| 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
|
---|
| 517 | destination.
|
---|
| 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.
|
---|
| 520 | .PP
|
---|
| 521 | .ft B
|
---|
| 522 | ioctl(\fIfd\fP, NWIOSIPCONF, &struct nwio_ipconf)
|
---|
| 523 | .ft R
|
---|
| 524 | .PP
|
---|
| 525 | The
|
---|
| 526 | .B NWIOSIPCONF
|
---|
| 527 | ioctl can be used to inform the IP server about its Internet Address
|
---|
| 528 | and/or its netmask.
|
---|
| 529 | Normally an IP server will discover its Internet Address using the RARP
|
---|
| 530 | protocol.
|
---|
| 531 | .B NWIOSIPCONF
|
---|
| 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.
|
---|
| 536 | .PP
|
---|
| 537 | The structure \fBnwio_ipconf\fP is defined in <net/gen/ip_io.h>:
|
---|
| 538 | .PP
|
---|
| 539 | .RS
|
---|
| 540 | .nf
|
---|
| 541 | .if t .ft C
|
---|
| 542 | typedef struct nwio_ipconf
|
---|
| 543 | {
|
---|
| 544 | u32_t nwic_flags;
|
---|
| 545 | ipaddr_t nwic_ipaddr;
|
---|
| 546 | ipaddr_t nwic_netmask;
|
---|
| 547 | } nwio_ipconf_t;
|
---|
| 548 | .SP
|
---|
| 549 | #define NWIC_NOFLAGS 0x0
|
---|
| 550 | #define NWIC_FLAGS 0x3
|
---|
| 551 | # define NWIC_IPADDR_SET 0x1
|
---|
| 552 | # define NWIC_NETMASK_SET 0x2
|
---|
| 553 | .if t .ft R
|
---|
| 554 | .fi
|
---|
| 555 | .RE
|
---|
| 556 | .PP
|
---|
| 557 | The function of \fBnwio_ipconf\fP depends on the value of \fBnwic_flags\fP.
|
---|
| 558 | If
|
---|
| 559 | .B NWIC_IPADDR_SET
|
---|
| 560 | is set then the Internet Address will be set to
|
---|
| 561 | \fBnwic_ipaddr\fP.
|
---|
| 562 | If
|
---|
| 563 | .B NWIC_NETMASK_SET
|
---|
| 564 | is set then the Internet Address will be set to
|
---|
| 565 | \fBnwic_netmask\fP.
|
---|
| 566 | .PP
|
---|
| 567 | .ft B
|
---|
| 568 | ioctl(\fIfd\fP, NWIOSIPOPT, &struct nwio_ipopt)
|
---|
| 569 | .ft R
|
---|
| 570 | .PP
|
---|
| 571 | Before an IP channel can be used, it has to be configured using the
|
---|
| 572 | .B NWIOSIPOPT
|
---|
| 573 | ioctl.
|
---|
| 574 | The structure \fBnwio_ipopt\fP is defined in <net/gen/ip_io.h>:
|
---|
| 575 | .PP
|
---|
| 576 | .RS
|
---|
| 577 | .nf
|
---|
| 578 | .if t .ft C
|
---|
| 579 | typedef struct nwio_ipopt
|
---|
| 580 | {
|
---|
| 581 | u32_t nwio_flags;
|
---|
| 582 | ipaddr_t nwio_rem;
|
---|
| 583 | ip_hdropt_t nwio_hdropt;
|
---|
| 584 | u8_t nwio_tos;
|
---|
| 585 | u8_t nwio_ttl;
|
---|
| 586 | u8_t nwio_df;
|
---|
| 587 | ipproto_t nwio_proto;
|
---|
| 588 | } nwio_ipopt_t;
|
---|
| 589 | .SP
|
---|
| 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
|
---|
| 613 | .if t .ft R
|
---|
| 614 | .fi
|
---|
| 615 | .RE
|
---|
| 616 | .PP
|
---|
| 617 | The options are divided in several categories:
|
---|
| 618 | .BR NWIO_ACC_MASK ,
|
---|
| 619 | .BR NWIO_LOC_MASK ,
|
---|
| 620 | .BR NWIO_BROAD_MASK ,
|
---|
| 621 | .BR NWIO_REM_MASK ,
|
---|
| 622 | .BR NWIO_PROTO_MASK ,
|
---|
| 623 | .B NWIO_HDR_O_MASK
|
---|
| 624 | and
|
---|
| 625 | .BR NWIO_RW_MASK .
|
---|
| 626 | A channel is configured when one option of each category is set.
|
---|
| 627 | .PP
|
---|
| 628 | The options covered by
|
---|
| 629 | .B NWIO_ACC_MASK
|
---|
| 630 | control the number of channels that
|
---|
| 631 | can use one IP protocol.
|
---|
| 632 | If
|
---|
| 633 | .B NWIO_EXCL
|
---|
| 634 | is specified then only that channel can use a certain IP protocol.
|
---|
| 635 | If
|
---|
| 636 | .B NWIO_SHARED
|
---|
| 637 | then multiple channels that all have to specify
|
---|
| 638 | .B NWIO_SHARED
|
---|
| 639 | can use the same IP protocol, but incoming packets will
|
---|
| 640 | be delivered to a most one channel.
|
---|
| 641 | .B NWIO_COPY
|
---|
| 642 | does not impose any restrictions.
|
---|
| 643 | Every channel gets a copy of an incoming packet.
|
---|
| 644 | .PP
|
---|
| 645 | .B NWIO_LOC_MASK
|
---|
| 646 | and
|
---|
| 647 | .B NWIO_BROAD_MASK
|
---|
| 648 | control the delivery of packets.
|
---|
| 649 | If
|
---|
| 650 | .B NWIO_EN_LOC
|
---|
| 651 | is specified then packets that are explicitly send to
|
---|
| 652 | the IP server are delivered.
|
---|
| 653 | If
|
---|
| 654 | .B NWIO_EN_BROAD
|
---|
| 655 | is specified then broadcast packets are delivered.
|
---|
| 656 | Either one or both of them can be disabled with
|
---|
| 657 | .B NWIO_DI_LOC
|
---|
| 658 | and
|
---|
| 659 | .BR NWIO_DI_BROAD .
|
---|
| 660 | .PP
|
---|
| 661 | .B NWIO_REMSPEC
|
---|
| 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
|
---|
| 665 | .B NWIO_REMANY
|
---|
| 666 | can be used.
|
---|
| 667 | .PP
|
---|
| 668 | .B NWIO_PROTOSPEC
|
---|
| 669 | restricts communication to one IP protocol, specified
|
---|
| 670 | in \fBnwio_proto\fP.
|
---|
| 671 | .B NWIO_PROTOANY
|
---|
| 672 | allows any protocol to be sent or received.
|
---|
| 673 | .PP
|
---|
| 674 | .B NWIO_HDR_O_SPEC
|
---|
| 675 | specifies all IP header options in advance.
|
---|
| 676 | The values are taken from
|
---|
| 677 | .BR nwio_hdropt ,
|
---|
| 678 | .BR nwio_tos ,
|
---|
| 679 | .BR nwio_ttl ,
|
---|
| 680 | and
|
---|
| 681 | .BR nwio_df .
|
---|
| 682 | \fBNwio_hdropt\fP specifies the IP options that should be present in an
|
---|
| 683 | outgoing packet.
|
---|
| 684 | \fBIp_hdropt_t\fP is defined in <net/gen/in.h>:
|
---|
| 685 | .PP
|
---|
| 686 | .RS
|
---|
| 687 | .nf
|
---|
| 688 | .if t .ft C
|
---|
| 689 | typedef struct ip_hdropt
|
---|
| 690 | {
|
---|
| 691 | u8_t iho_opt_siz;
|
---|
| 692 | u8_t iho_data[IP_MAX_HDR_SIZE-IP_MIN_HDR_SIZE];
|
---|
| 693 | } ip_hdropt_t;
|
---|
| 694 | .if t .ft R
|
---|
| 695 | .fi
|
---|
| 696 | .RE
|
---|
| 697 | .PP
|
---|
| 698 | The bytes of size \fBiho_opt_siz\fP in \fBiho_data\fP are appended to the IP
|
---|
| 699 | header.
|
---|
| 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.
|
---|
| 703 | .B NWIO_HDR_O_ANY
|
---|
| 704 | specifies that the header options should be specified at
|
---|
| 705 | each write request.
|
---|
| 706 | .PP
|
---|
| 707 | .B NWIO_RWDATONLY
|
---|
| 708 | specifies that the header should be omitted from a
|
---|
| 709 | write request.
|
---|
| 710 | This option can only be used when all header fields are specified in previous
|
---|
| 711 | options:
|
---|
| 712 | .BR NWIO_EN_LOC ,
|
---|
| 713 | .BR NWIO_DI_BROAD ,
|
---|
| 714 | .BR NWIO_REMSPEC ,
|
---|
| 715 | .B NWIO_PROTOSPEC
|
---|
| 716 | and
|
---|
| 717 | .BR NWIO_HDR_O_SPEC .
|
---|
| 718 | A read operation will also only return the data part, so the IP options will
|
---|
| 719 | be lost.
|
---|
| 720 | .PP
|
---|
| 721 | .ft B
|
---|
| 722 | ioctl(\fIfd\fP, NWIOSIPOROUTE, &struct nwio_route)
|
---|
| 723 | .ft R
|
---|
| 724 | .PP
|
---|
| 725 | The
|
---|
| 726 | .B NWIOSIPOROUTE
|
---|
| 727 | ioctl adds a route to the routing table.
|
---|
| 728 | See \fBNWIOGIPOROUTE\fP above for a description of the \fBnwio_route\fP
|
---|
| 729 | structure.
|
---|
| 730 | The fields \fBnwr_ent_no\fP and \fBnwr_ent_count\fP are ignored.
|
---|
| 731 | .SS "TCP Functions"
|
---|
| 732 | .PP
|
---|
| 733 | .ft B
|
---|
| 734 | ioctl(\fIfd\fP, NWIOTCPCONN, &struct nwio_tcpcl)
|
---|
| 735 | .ft R
|
---|
| 736 | .PP
|
---|
| 737 | The
|
---|
| 738 | .B NWIOTCPCONN
|
---|
| 739 | ioctl tries to setup a connection with a remote TCP/IP server.
|
---|
| 740 | The channel must be fully configured (see
|
---|
| 741 | .BR NWIOSTCPCONF )
|
---|
| 742 | and values for the local port, the remote port and the remote address have be
|
---|
| 743 | specified using
|
---|
| 744 | .B NWTC_LP_SET
|
---|
| 745 | or
|
---|
| 746 | .BR NWTC_LP_SEL ,
|
---|
| 747 | .B NWTC_SET_RA
|
---|
| 748 | and
|
---|
| 749 | .BR NWTC_SET_RP .
|
---|
| 750 | The struct nwio_tcpcl is defined in <net/gen/tcp_io.h> as:
|
---|
| 751 | .PP
|
---|
| 752 | .RS
|
---|
| 753 | .nf
|
---|
| 754 | .if t .ft C
|
---|
| 755 | typedef struct nwio_tcpcl
|
---|
| 756 | {
|
---|
| 757 | long nwtcl_flags;
|
---|
| 758 | long nwtcl_ttl;
|
---|
| 759 | } nwio_tcpcl_t;
|
---|
| 760 | .if t .ft R
|
---|
| 761 | .fi
|
---|
| 762 | .RE
|
---|
| 763 | .PP
|
---|
| 764 | Set the
|
---|
| 765 | .B nwtcl_flags
|
---|
| 766 | field to zero before the connect or listen call. [[[Further explanation of
|
---|
| 767 | nwio_tcpcl?]]]
|
---|
| 768 | .PP
|
---|
| 769 | .ft B
|
---|
| 770 | ioctl(\fIfd\fP, NWIOGTCPCONF, &struct nwio_tcpconf)
|
---|
| 771 | .ft R
|
---|
| 772 | .PP
|
---|
| 773 | This call reports the current configuration of a TCP channel.
|
---|
| 774 | The
|
---|
| 775 | .B nwtc_flags
|
---|
| 776 | field shows the status of the
|
---|
| 777 | .BR access ,
|
---|
| 778 | .BR locport ,
|
---|
| 779 | .B remaddr
|
---|
| 780 | and
|
---|
| 781 | .B remport
|
---|
| 782 | fields.
|
---|
| 783 | .B Nwtc_locaddr
|
---|
| 784 | contains the Internet address of the TCP/IP server.
|
---|
| 785 | .B Remaddr
|
---|
| 786 | contains the Internet address of the remote TCP/IP server when set with
|
---|
| 787 | .B NWTC_SET_RA
|
---|
| 788 | or after a successful connect or listen (see
|
---|
| 789 | .B NWIOTCPCONN
|
---|
| 790 | or
|
---|
| 791 | .BR NWIOTCPLISTEN ).
|
---|
| 792 | .B Nwio_locport
|
---|
| 793 | contains the local TCP/IP port set with
|
---|
| 794 | .B NWTC_LP_SET
|
---|
| 795 | or the selected port set with
|
---|
| 796 | .BR NWTC_LP_SEL .
|
---|
| 797 | .B Nwtc_remport
|
---|
| 798 | contains the TCP port of the remote TCP/IP server as set with
|
---|
| 799 | .B NWIO_SET_RP
|
---|
| 800 | or after a successful connect or listen.
|
---|
| 801 | .PP
|
---|
| 802 | A value of 0 (zero) is reported for
|
---|
| 803 | .BR nwtc_remaddr ,
|
---|
| 804 | .B nwtc_locport
|
---|
| 805 | or
|
---|
| 806 | .B nwtc_remport
|
---|
| 807 | when no value is set either explicitly or implicitly.
|
---|
| 808 | .PP
|
---|
| 809 | .ft B
|
---|
| 810 | ioctl(\fIfd\fP, NWIOTCPLISTEN, &struct nwio_tcpcl)
|
---|
| 811 | .ft R
|
---|
| 812 | .PP
|
---|
| 813 | The
|
---|
| 814 | .B NWIOTCPLISTEN
|
---|
| 815 | ioctl waits until a remote TCP/IP server tries to connect to this channel.
|
---|
| 816 | The channel has to be configured (see
|
---|
| 817 | .BR NWIOSTCPCONF ).
|
---|
| 818 | An additional restriction is that the local port
|
---|
| 819 | must be set (with
|
---|
| 820 | .BR NWTC_LP_SET )
|
---|
| 821 | or selected (with
|
---|
| 822 | .BR NWTC_LP_SEL ).
|
---|
| 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
|
---|
| 826 | .B NWIOGTCPCONF
|
---|
| 827 | can be used to find out what the address and port of the other side are.
|
---|
| 828 | .PP
|
---|
| 829 | .ft B
|
---|
| 830 | ioctl(\fIfd\fP, NWIOSTCPCONF, &struct nwio_tcpconf)
|
---|
| 831 | .ft R
|
---|
| 832 | .PP
|
---|
| 833 | Before a TCP channel can be used it must configured using the
|
---|
| 834 | .B NWIOSTCPCONF
|
---|
| 835 | ioctl.
|
---|
| 836 | The parameters to
|
---|
| 837 | .B NWIOSTCPCONF
|
---|
| 838 | are the channel file descriptor and a
|
---|
| 839 | .B struct nwio_tcpconf
|
---|
| 840 | as defined in <net/gen/tcp_io.h>:
|
---|
| 841 | .PP
|
---|
| 842 | .RS
|
---|
| 843 | .nf
|
---|
| 844 | .if t .ft C
|
---|
| 845 | typedef struct nwio_tcpconf
|
---|
| 846 | {
|
---|
| 847 | u32_t nwtc_flags;
|
---|
| 848 | ipaddr_t nwtc_locaddr;
|
---|
| 849 | ipaddr_t nwtc_remaddr;
|
---|
| 850 | tcpport_t nwtc_locport;
|
---|
| 851 | tcpport_t nwtc_remport;
|
---|
| 852 | } nwio_tcpconf_t;
|
---|
| 853 | .SP
|
---|
| 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
|
---|
| 869 | .if t .ft R
|
---|
| 870 | .fi
|
---|
| 871 | .RE
|
---|
| 872 | .PP
|
---|
| 873 | A tcp channel is considered configured when one flag in each category has
|
---|
| 874 | been selected.
|
---|
| 875 | Thus one of
|
---|
| 876 | .BR NWTC_EXCL ,
|
---|
| 877 | .B NWTC_SHARED
|
---|
| 878 | or
|
---|
| 879 | .BR NWTC_COPY ,
|
---|
| 880 | one of
|
---|
| 881 | .BR NWTC_LP_UNSET ,
|
---|
| 882 | .B NWTC_LP_SET
|
---|
| 883 | or
|
---|
| 884 | .BR NWTC_LP_SEL ,
|
---|
| 885 | one of
|
---|
| 886 | .B NWTC_SET_RA
|
---|
| 887 | or
|
---|
| 888 | .BR NWTC_UNSET_RA ,
|
---|
| 889 | and one of
|
---|
| 890 | .B NWTC_SET_RP
|
---|
| 891 | or
|
---|
| 892 | .BR NWTC_UNSET_RP .
|
---|
| 893 | .PP
|
---|
| 894 | The acc flags control the access to a certain TCP port.
|
---|
| 895 | .B NWTC_EXCL
|
---|
| 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.
|
---|
| 899 | .B NWTC_SHARED
|
---|
| 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
|
---|
| 903 | .B NWTC_SHARED
|
---|
| 904 | flag.
|
---|
| 905 | .B NWTC_COPY
|
---|
| 906 | is specified when the programmer does not care about other channels.
|
---|
| 907 | This is the default.
|
---|
| 908 | .PP
|
---|
| 909 | The locport flags control which TCP port is used for communication.
|
---|
| 910 | .B NWTC_LP_UNSET
|
---|
| 911 | indicates the absence of a local port.
|
---|
| 912 | This is the default.
|
---|
| 913 | .B NWTC_LP_SET
|
---|
| 914 | means that the
|
---|
| 915 | .B nwtc_locport
|
---|
| 916 | field contains the local port to be used by TCP.
|
---|
| 917 | This value must be in network byte order (see
|
---|
| 918 | .BR hton (3).)
|
---|
| 919 | .B NWTC_LP_SEL
|
---|
| 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.
|
---|
| 922 | .LP
|
---|
| 923 | The
|
---|
| 924 | .B remaddr
|
---|
| 925 | flags specify which hosts are acceptable for connections.
|
---|
| 926 | .B NWTC_SET_RA
|
---|
| 927 | indicates that only connection to the host specified in
|
---|
| 928 | .B nwtc_remaddr
|
---|
| 929 | are acceptable.
|
---|
| 930 | .B Nwtc_remaddr
|
---|
| 931 | should be in network byte order (see
|
---|
| 932 | .BR hton (3).)
|
---|
| 933 | .B NWTC_UNSET_RA
|
---|
| 934 | allows every host on the other side of a connection.
|
---|
| 935 | This is the default.
|
---|
| 936 | .PP
|
---|
| 937 | The
|
---|
| 938 | .B remport
|
---|
| 939 | flags specify which remote ports are acceptable for connections.
|
---|
| 940 | .B NWTC_SET_RP
|
---|
| 941 | indicates that only the port specified in
|
---|
| 942 | .B nwtc_remport
|
---|
| 943 | is acceptable.
|
---|
| 944 | .B NWTC_UNSET_RP
|
---|
| 945 | allows every port on the other side of a connection.
|
---|
| 946 | This is the default.
|
---|
| 947 | .PP
|
---|
| 948 | .ft B
|
---|
| 949 | ioctl(\fIfd\fP, NWIOTCPSHUTDOWN)
|
---|
| 950 | .ft R
|
---|
| 951 | .PP
|
---|
| 952 | The
|
---|
| 953 | .B NWIOTCPSHUTDOWN
|
---|
| 954 | tells the TCP/IP server that no more data will be sent over the channel
|
---|
| 955 | specified by
|
---|
| 956 | .IR fd .
|
---|
| 957 | This command can be issued when the channel is connected to a remote TCP/IP
|
---|
| 958 | server.
|
---|
| 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.
|
---|
| 961 | .PP
|
---|
| 962 | .ft B
|
---|
| 963 | ioctl(\fIfd\fP, NWIOGTCPOPT, &struct nwio_tcpopt)
|
---|
| 964 | .br
|
---|
| 965 | ioctl(\fIfd\fP, NWIOSTCPOPT, &struct nwio_tcpopt)
|
---|
| 966 | .ft R
|
---|
| 967 | .PP
|
---|
| 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
|
---|
| 970 | .B NWIOGTCPOPT
|
---|
| 971 | ioctl and set with the
|
---|
| 972 | .B NWIOSTCPOPT
|
---|
| 973 | ioctl. The options are passed in a
|
---|
| 974 | .B struct nwio_tcpopt
|
---|
| 975 | as defined in <net/gen/tcp_io.h>:
|
---|
| 976 | .PP
|
---|
| 977 | .RS
|
---|
| 978 | .nf
|
---|
| 979 | .if t .ft C
|
---|
| 980 | typedef struct nwio_tcpopt
|
---|
| 981 | {
|
---|
| 982 | u32_t nwto_flags;
|
---|
| 983 | } nwio_tcpopt_t;
|
---|
| 984 | .SP
|
---|
| 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
|
---|
| 996 | .if t .ft R
|
---|
| 997 | .fi
|
---|
| 998 | .RE
|
---|
| 999 | .PP
|
---|
| 1000 | The
|
---|
| 1001 | .B NWTO_SND_URG
|
---|
| 1002 | option causes bytes written to the channel to be send out as urgent data.
|
---|
| 1003 | On receiving an
|
---|
| 1004 | .B EURG
|
---|
| 1005 | error the
|
---|
| 1006 | .B NWTO_RCV_URG
|
---|
| 1007 | option must be set to switch over to reading urgent data. When all urgent
|
---|
| 1008 | data has been read an
|
---|
| 1009 | .B ENOURG
|
---|
| 1010 | error will follow,
|
---|
| 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
|
---|
| 1015 | .B NWTO_BSD_URG
|
---|
| 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
|
---|
| 1019 | .B NWTO_DEL_RST
|
---|
| 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.
|
---|
| 1029 | .SS "UDP Functions"
|
---|
| 1030 | .PP
|
---|
| 1031 | .ft B
|
---|
| 1032 | ioctl(\fIfd\fP, NWIOGUDPOPT, &struct nwio_udpopt)
|
---|
| 1033 | .ft R
|
---|
| 1034 | .PP
|
---|
| 1035 | The
|
---|
| 1036 | .B NWIOGUDPOPT
|
---|
| 1037 | ioctl returns the current options that result from the default options
|
---|
| 1038 | and the options set with
|
---|
| 1039 | .BR NWIOSUDPOPT .
|
---|
| 1040 | When
|
---|
| 1041 | .B NWUO_LP_SEL
|
---|
| 1042 | or
|
---|
| 1043 | .B NWUO_LP_SET
|
---|
| 1044 | is selected the local port is returned in
|
---|
| 1045 | .BR nwuo_locport .
|
---|
| 1046 | When
|
---|
| 1047 | .B NWUO_RP_SET
|
---|
| 1048 | is selected the remote port is returned in
|
---|
| 1049 | .BR nwuo_remport .
|
---|
| 1050 | The local address is always returned in
|
---|
| 1051 | .BR nwuo_locaddr ,
|
---|
| 1052 | and when
|
---|
| 1053 | .B NWUO_RA_SET
|
---|
| 1054 | is selected the remote address is returned in
|
---|
| 1055 | .BR nwuo_remaddr .
|
---|
| 1056 | .PP
|
---|
| 1057 | .ft B
|
---|
| 1058 | ioctl(\fIfd\fP, NWIOSUDPOPT, &struct nwio_udpopt)
|
---|
| 1059 | .ft R
|
---|
| 1060 | .PP
|
---|
| 1061 | A UDP channel must be configured using the
|
---|
| 1062 | .B NWIOSUDPOPT
|
---|
| 1063 | ioctl before any data can be read or written.
|
---|
| 1064 | .B NWIOSUDPOPT
|
---|
| 1065 | takes two parameters, a file descriptor to an open UDP device and
|
---|
| 1066 | pointer to a
|
---|
| 1067 | .B nwio_udpopt
|
---|
| 1068 | structure that describes the requested configuration.
|
---|
| 1069 | The
|
---|
| 1070 | .B nwio_udpopt
|
---|
| 1071 | structure is defined in <net/gen/udp_io.h> as:
|
---|
| 1072 | .PP
|
---|
| 1073 | .RS
|
---|
| 1074 | .nf
|
---|
| 1075 | .if t .ft C
|
---|
| 1076 | typedef struct nwio_udpopt
|
---|
| 1077 | {
|
---|
| 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;
|
---|
| 1083 | } nwio_udpopt_t;
|
---|
| 1084 | .SP
|
---|
| 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
|
---|
| 1112 | .if t .ft R
|
---|
| 1113 | .fi
|
---|
| 1114 | .RE
|
---|
| 1115 | .PP
|
---|
| 1116 | A UDP channel is considered configured when one flag in each category has been
|
---|
| 1117 | selected.
|
---|
| 1118 | Thus one of
|
---|
| 1119 | .BR NWUO_EXCL ,
|
---|
| 1120 | .B NWUO_SHARED
|
---|
| 1121 | or
|
---|
| 1122 | .BR NWUO_COPY ,
|
---|
| 1123 | one of
|
---|
| 1124 | .BR NWUO_LP_SEL ,
|
---|
| 1125 | .B NWUO_LP_SET
|
---|
| 1126 | or
|
---|
| 1127 | .BR NWUO_LP_ANY ,
|
---|
| 1128 | one of
|
---|
| 1129 | .B NWUO_EN_LOC
|
---|
| 1130 | or
|
---|
| 1131 | .BR NWUO_DI_LOC ,
|
---|
| 1132 | one of
|
---|
| 1133 | .BR NWUO_EN_BROAD ,
|
---|
| 1134 | or
|
---|
| 1135 | .BR NWUO_DI_BROAD ,
|
---|
| 1136 | one of
|
---|
| 1137 | .BR NWUO_RP_SET ,
|
---|
| 1138 | or
|
---|
| 1139 | .BR NWUO_RP_ANY ,
|
---|
| 1140 | one of
|
---|
| 1141 | .BR NWUO_RA_SET ,
|
---|
| 1142 | or
|
---|
| 1143 | .BR NWUO_RA_ANY ,
|
---|
| 1144 | one of
|
---|
| 1145 | .BR NWUO_RWDATONLY ,
|
---|
| 1146 | or
|
---|
| 1147 | .BR NWUO_RWDATALL ,
|
---|
| 1148 | and one of
|
---|
| 1149 | .BR NWUO_EN_IPOPT ,
|
---|
| 1150 | or
|
---|
| 1151 | .BR NWUO_DI_IPOPT .
|
---|
| 1152 | The acc flags control the access to a certain UDP port.
|
---|
| 1153 | .B NWUO_EXCL
|
---|
| 1154 | means exclusive access:
|
---|
| 1155 | no other channel can use this port.
|
---|
| 1156 | .B NWUO_SHARED
|
---|
| 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.
|
---|
| 1160 | .B NWUO_COPY
|
---|
| 1161 | imposes no access restriction and all channels get a copy of every received
|
---|
| 1162 | packet for that port.
|
---|
| 1163 | .PP
|
---|
| 1164 | The
|
---|
| 1165 | .B locport
|
---|
| 1166 | flags control the selection of the UDP port for this channel.
|
---|
| 1167 | .B NWUO_LP_SEL
|
---|
| 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.
|
---|
| 1170 | .B NWUO_LP_SET
|
---|
| 1171 | sets the local port to the value of the
|
---|
| 1172 | .B nwuo_locport
|
---|
| 1173 | field.
|
---|
| 1174 | .B NWUO_LP_ANY
|
---|
| 1175 | does not select a port.
|
---|
| 1176 | Reception of data is therefore not possible but it is
|
---|
| 1177 | possible to send data.
|
---|
| 1178 | .PP
|
---|
| 1179 | The
|
---|
| 1180 | .B locaddr
|
---|
| 1181 | flags control the reception of packets.
|
---|
| 1182 | .B NWUO_EN_LOC
|
---|
| 1183 | enables the reception of packets with the local IP address as destination.
|
---|
| 1184 | .B NWUO_DI_LOC
|
---|
| 1185 | disables the reception of packet for the local IP address.
|
---|
| 1186 | .PP
|
---|
| 1187 | The
|
---|
| 1188 | .B broad
|
---|
| 1189 | flags control the reception of broadcast packets.
|
---|
| 1190 | .B NWUO_EN_BROAD
|
---|
| 1191 | enables the reception of broadcast packets and
|
---|
| 1192 | .B NWUO_DI_BROAD
|
---|
| 1193 | disables the reception of broadcast packets.
|
---|
| 1194 | .PP
|
---|
| 1195 | The
|
---|
| 1196 | .B remport
|
---|
| 1197 | flags let the client to specify one specific remote UDP port or
|
---|
| 1198 | to allow any remote port.
|
---|
| 1199 | .B NWUO_RP_SET
|
---|
| 1200 | sets the remote UDP port to the value of
|
---|
| 1201 | .BR nwuo_remport .
|
---|
| 1202 | Only packets with a matching remote port will be delivered
|
---|
| 1203 | and all packets will be sent to that port.
|
---|
| 1204 | .B NWUO_RP_ANY
|
---|
| 1205 | allows reception of packets form any port and when transmitting packets the
|
---|
| 1206 | remote port has to be specified.
|
---|
| 1207 | .PP
|
---|
| 1208 | The
|
---|
| 1209 | .B remaddr
|
---|
| 1210 | flags control the remote IP address.
|
---|
| 1211 | .B NWUO_RA_SET
|
---|
| 1212 | sets the remote IP address the value of
|
---|
| 1213 | .BR nwuo_remaddr .
|
---|
| 1214 | Only packets from that address will be delivered and all packets will be sent
|
---|
| 1215 | to that address.
|
---|
| 1216 | .B NWUO_RA_ANY
|
---|
| 1217 | allows reception of packets from any host and when transmitting packets the
|
---|
| 1218 | remote host has to be specified.
|
---|
| 1219 | .PP
|
---|
| 1220 | The
|
---|
| 1221 | .B rw
|
---|
| 1222 | flags control the format of the data to be sent or received.
|
---|
| 1223 | With
|
---|
| 1224 | .B NWUO_RWDATONLY
|
---|
| 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.
|
---|
| 1227 | The
|
---|
| 1228 | .B NWUO_RWDATALL
|
---|
| 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:
|
---|
| 1235 | .PP
|
---|
| 1236 | .RS
|
---|
| 1237 | .nf
|
---|
| 1238 | .if t .ft C
|
---|
| 1239 | typedef struct udp_io_hdr
|
---|
| 1240 | {
|
---|
| 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;
|
---|
| 1246 | u16_t uih_data_len;
|
---|
| 1247 | } udp_io_hdr_t;
|
---|
| 1248 | .if t .ft R
|
---|
| 1249 | .fi
|
---|
| 1250 | .RE
|
---|
| 1251 | .PP
|
---|
| 1252 | The first four fields are the source and destination IP addresses and
|
---|
| 1253 | ports.
|
---|
| 1254 | .B Uih_ip_opt_len
|
---|
| 1255 | is ???.
|
---|
| 1256 | .B Uih_data_len
|
---|
| 1257 | should equal the length of the packet data (packet lenght minus the
|
---|
| 1258 | header.) ???
|
---|
| 1259 | ..
|
---|
| 1260 | .PP
|
---|
| 1261 | The
|
---|
| 1262 | .B ipopt
|
---|
| 1263 | flags control the delivery and transmission of IP options.
|
---|
| 1264 | When
|
---|
| 1265 | .B NWUO_EN_IPOPT
|
---|
| 1266 | is set IP, options will be delivered and sent.
|
---|
| 1267 | When
|
---|
| 1268 | .B NWUO_DI_IPOPT
|
---|
| 1269 | is set IP option will be stripped from received packets and no IP options will
|
---|
| 1270 | be sent.
|
---|
| 1271 | .ig \" MINIX 3 doesn't have this stuff (yet? ever?)
|
---|
| 1272 | .SS "UDP Library Functions"
|
---|
| 1273 | .PP
|
---|
| 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).
|
---|
| 1277 | .LP
|
---|
| 1278 | .sC
|
---|
| 1279 | errstat
|
---|
| 1280 | udp_connect(udp_cap, chan_cap, srcport, dstport, dstaddr, flags)
|
---|
| 1281 | capability *udp_cap;
|
---|
| 1282 | capability *chan_cap;
|
---|
| 1283 | udpport_t srcport;
|
---|
| 1284 | udpport_t dstport;
|
---|
| 1285 | ipaddr_t dstaddr;
|
---|
| 1286 | int flags;
|
---|
| 1287 | .eC
|
---|
| 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
|
---|
| 1293 | \fIchan_cap\fP.
|
---|
| 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
|
---|
| 1298 | any remote port.
|
---|
| 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.
|
---|
| 1302 | .sH
|
---|
| 1303 | udp_reconnect
|
---|
| 1304 | .LP
|
---|
| 1305 | .sC
|
---|
| 1306 | errstat
|
---|
| 1307 | udp_reconnect(chan_cap, srcport, dstport, dstaddr, flags)
|
---|
| 1308 | capability *chan_cap;
|
---|
| 1309 | udpport_t srcport;
|
---|
| 1310 | udpport_t dstport;
|
---|
| 1311 | ipaddr_t dstaddr;
|
---|
| 1312 | int flags;
|
---|
| 1313 | .eC
|
---|
| 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.
|
---|
| 1317 | .sH
|
---|
| 1318 | udp_read_msg
|
---|
| 1319 | .LP
|
---|
| 1320 | .sC
|
---|
| 1321 | errstat
|
---|
| 1322 | udp_read_msg(chan_cap, msg, msglen, actlen, flags)
|
---|
| 1323 | capability *chan_cap;
|
---|
| 1324 | char *msg;
|
---|
| 1325 | int msglen;
|
---|
| 1326 | int *actlen;
|
---|
| 1327 | int flags;
|
---|
| 1328 | .eC
|
---|
| 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.
|
---|
| 1335 | .sH
|
---|
| 1336 | udp_write_msg
|
---|
| 1337 | .LP
|
---|
| 1338 | .sC
|
---|
| 1339 | errstat
|
---|
| 1340 | udp_write_msg(chan_cap, msg, msglen, flags)
|
---|
| 1341 | capability *chan_cap;
|
---|
| 1342 | char *msg;
|
---|
| 1343 | int msglen;
|
---|
| 1344 | int flags;
|
---|
| 1345 | .eC
|
---|
| 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
|
---|
| 1349 | UDP packet.
|
---|
| 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.
|
---|
| 1353 | .sH
|
---|
| 1354 | udp_close
|
---|
| 1355 | .LP
|
---|
| 1356 | .sC
|
---|
| 1357 | errstat
|
---|
| 1358 | udp_close(chan_cap, flags)
|
---|
| 1359 | capability *chan_cap;
|
---|
| 1360 | int flags;
|
---|
| 1361 | .eC
|
---|
| 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.
|
---|
| 1368 | .sH
|
---|
| 1369 | udp_destroy
|
---|
| 1370 | .LP
|
---|
| 1371 | .sC
|
---|
| 1372 | errstat
|
---|
| 1373 | udp_destroy(chan_cap, flags)
|
---|
| 1374 | capability *chan_cap;
|
---|
| 1375 | int flags;
|
---|
| 1376 | .eC
|
---|
| 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.
|
---|
| 1380 | ..
|
---|
| 1381 | .SH FILES
|
---|
| 1382 | .IP /dev/eth* \w'/dev/psip*mmm'u
|
---|
| 1383 | Raw ethernet. The numbers in the device names are decimal, so one may see
|
---|
| 1384 | names from
|
---|
| 1385 | .B eth0
|
---|
| 1386 | to
|
---|
| 1387 | .BR eth15 .
|
---|
| 1388 |
|
---|
| 1389 | .IP /dev/psip*
|
---|
| 1390 | First and second Pseudo IP network.
|
---|
| 1391 | .IP /dev/ip*
|
---|
| 1392 | IP devices for two ethernets and two Pseudo IP networks.
|
---|
| 1393 | .IP /dev/tcp*
|
---|
| 1394 | TCP devices for same four networks.
|
---|
| 1395 | .IP /dev/udp*
|
---|
| 1396 | UDP devices.
|
---|
| 1397 | .IP "/dev/eth, /dev/psip, /dev/ip, /dev/tcp, /dev/udp"
|
---|
| 1398 | Devices for the default network, links to the devices above.
|
---|
| 1399 | .B Eth
|
---|
| 1400 | is only present if ethernet is the default,
|
---|
| 1401 | .B psip
|
---|
| 1402 | only for pseudo IP.
|
---|
| 1403 | .SH "SEE ALSO"
|
---|
| 1404 | .BR hton (3),
|
---|
| 1405 | .BR oneC_sum (3),
|
---|
| 1406 | .BR inet (8),
|
---|
| 1407 | .BR boot (8).
|
---|
| 1408 | .SH DIAGNOSTICS
|
---|
| 1409 | Several errors may be returned by the TCP/IP server. The error code
|
---|
| 1410 | is found in the
|
---|
| 1411 | .B errno
|
---|
| 1412 | variable if the
|
---|
| 1413 | .BR read ,
|
---|
| 1414 | .BR write ,
|
---|
| 1415 | or
|
---|
| 1416 | .B ioctl
|
---|
| 1417 | call returns -1. The TCP/IP error codes defined in <errno.h> are:
|
---|
| 1418 | .IP EPACKSIZE 5c
|
---|
| 1419 | This indicates an attempt to read or write with a buffer that is too
|
---|
| 1420 | large or too small.
|
---|
| 1421 | .IP EOUTOFBUFS
|
---|
| 1422 | The TCP/IP server has insufficient memory to execute the request.
|
---|
| 1423 | .IP EBADIOCTL
|
---|
| 1424 | This indicates an attempt to execute a command the particular server
|
---|
| 1425 | does not understand.
|
---|
| 1426 | For example, a
|
---|
| 1427 | .B NWIOGTCPCONF
|
---|
| 1428 | on an ETH channel.
|
---|
| 1429 | .IP EBADMODE
|
---|
| 1430 | The request is refused because the channel is not fully configured, in the
|
---|
| 1431 | wrong state or the parameters are invalid.
|
---|
| 1432 | .IP EBADDEST
|
---|
| 1433 | This indicates an illegal destination address for a packet.
|
---|
| 1434 | .IP EDSTNORCH
|
---|
| 1435 | The destination is not reachable.
|
---|
| 1436 | .IP EISCONN
|
---|
| 1437 | The channel is already connected so a second request is refused.
|
---|
| 1438 | .IP EADDRINUSE
|
---|
| 1439 | This address is in use.
|
---|
| 1440 | .IP ECONNREFUSED
|
---|
| 1441 | The connection is refused by the other side.
|
---|
| 1442 | .IP ECONNRESET
|
---|
| 1443 | The connection is reset (non-gracefully terminated) by the other side.
|
---|
| 1444 | .IP ETIMEDOUT
|
---|
| 1445 | The connection is terminated due to an expired timer.
|
---|
| 1446 | .IP EURG
|
---|
| 1447 | Urgent data is present and the current receive mode does not allow urgent data
|
---|
| 1448 | to be transferred.
|
---|
| 1449 | .IP ENOURG
|
---|
| 1450 | No urgent data is present and a request came for urgent data.
|
---|
| 1451 | .IP ENOTCONN
|
---|
| 1452 | The request requires a connected channel and the channel is not connected.
|
---|
| 1453 | .IP ESHUTDOWN
|
---|
| 1454 | The connection is shut down.
|
---|
| 1455 | That is, a
|
---|
| 1456 | .B NWIOTCPSHUTDOWN
|
---|
| 1457 | has been executed so no more data can be transmitted.
|
---|
| 1458 | .IP ENOCONN
|
---|
| 1459 | The connection does not exist.
|
---|
| 1460 | .IP EGENERIC
|
---|
| 1461 | A generic error code for extremely weird cases.
|
---|
| 1462 | .SH AUTHOR
|
---|
| 1463 | Philip Homburg (philip@cs.vu.nl)
|
---|
| 1464 |
|
---|
| 1465 | .\"
|
---|
| 1466 | .\" $PchId: ip.4,v 1.4 2001/01/08 19:58:14 philip Exp $
|
---|