⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ip.4

📁 操作系统设计与实现源码
💻 4
📖 第 1 页 / 共 3 页
字号:
     set with the NWIOSTCPOPT ioctl.  The  options  are  passed  in  a  struct
     nwio_tcpopt as defined in <net/gen/tcp_io.h>:

          typedef struct nwio_tcpopt
          {
                  u32_t nwto_flags;
          } nwio_tcpconf_t;

          #define NWTO_NOFLAG     0x0000L
          #define NWTO_SND_URG_MASK       0x0001L
          #       define NWTO_SND_URG     0x00000001L
          #       define NWTO_SND_NOTURG  0x00010000L
          #define NWTO_RCV_URG_MASK       0x0002L
          #       define NWTO_RCV_URG     0x00000002L
          #       define NWTO_RCV_NOTURG  0x00020000L


                                                                            11



IP(4)                     Minix Programmer's Manual                      IP(4)


          #define NWTO_BSD_URG_MASK       0x0004L
          #       define NWTO_BSD_URG     0x00000004L
          #define NWTO_DEL_RST_MASK       0x0008L
          #       define NWTO_DEL_RST     0x00000008L

     The NWTO_SND_URG option causes bytes written to the channel  to  be  send
     out  as  urgent data.  On receiving an EURG error the NWTO_RCV_URG option
     must be set to switch over to reading urgent data.  When all urgent  data
     has  been  read  an  ENOURG error will follow, indicating that the option
     must be cleared with NWTO_RCV_NOTURG.  Alas  the  BSD  implementation  of
     urgent  data  disagrees  with the RFC's, so to be BSD compatible one must
     set the NWTO_BSD_URG option beforehand on a channel that is  to  send  or
     receive  urgent  data.  Given that the BSD implementation is the regarded
     as the TCP/IP  standard  one  should  always  use  the  BSD  style.   The
     NWTO_DEL_RST  option  delays  a failure response on a connect to the same
     port as the current open connection.  Without this option a connect would
     fail  if  a server is not yet listening.  With this option a connect will
     linger on until the server starts listening.  This option is useful for a
     server  that  opens  a  connection,  tells  the remote end the local port
     number and then listens (FTP), or for a program that  forks  off  servers
     for incoming connections (TELNET).  A new connection may come in before a
     new listen can be started, so it is nice if the new connect doesn't fail.
     Use this option only when it is clearly needed.

  UDP Functions

     ioctl(fd, NWIOGUDPOPT, &struct nwio_udpopt)

     The NWIOGUDPOPT ioctl returns the current options that  result  from  the
     default  options  and the options set with NWIOSUDPOPT.  When NWUO_LP_SEL
     or NWUO_LP_SET is selected the local port is  returned  in  nwuo_locport.
     When NWUO_RP_SET is selected the remote port is returned in nwuo_remport.
     The  local  address  is  always  returned  in  nwuo_locaddr,   and   when
     NWUO_RA_SET is selected the remote address is returned in nwuo_remaddr.

     ioctl(fd, NWIOSUDPOPT, &struct nwio_udpopt)

     A UDP channel must be configured using the NWIOSUDPOPT ioctl  before  any
     data  can  be  read or written.  NWIOSUDPOPT takes two parameters, a file
     descriptor to an open UDP device and pointer to a  nwio_udpopt  structure
     that describes the requested configuration.  The nwio_udpopt structure is
     defined in <net/gen/udp_io.h> as:

          typedef struct nwio_udpopt
          {
                  unsigned long nwuo_flags;
                  udpport_t nwuo_locport;
                  udpport_t nwuo_remport;
                  ipaddr_t nwuo_locaddr;
                  ipaddr_t nwuo_remaddr;


                                                                            12



IP(4)                     Minix Programmer's Manual                      IP(4)


          } nwio_udpopt_t;

          #define NWUO_NOFLAGS            0x0000L
          #define NWUO_ACC_MASK           0x0003L
          #define         NWUO_EXCL               0x00000001L
          #define         NWUO_SHARED             0x00000002L
          #define         NWUO_COPY               0x00000003L
          #define NWUO_LOCPORT_MASK       0x000CL
          #define         NWUO_LP_SEL             0x00000004L
          #define         NWUO_LP_SET             0x00000008L
          #define         NWUO_LP_ANY             0x0000000CL
          #define NWUO_LOCADDR_MASK       0x0010L
          #define         NWUO_EN_LOC             0x00000010L
          #define         NWUO_DI_LOC             0x00100000L
          #define NWUO_BROAD_MASK         0x0020L
          #define         NWUO_EN_BROAD           0x00000020L
          #define         NWUO_DI_BROAD           0x00200000L
          #define NWUO_REMPORT_MASK       0x0100L
          #define         NWUO_RP_SET             0x00000100L
          #define         NWUO_RP_ANY             0x01000000L
          #define NWUO_REMADDR_MASK       0x0200L
          #define         NWUO_RA_SET             0x00000200L
          #define         NWUO_RA_ANY             0x02000000L
          #define NWUO_RW_MASK            0x1000L
          #define         NWUO_RWDATONLY          0x00001000L
          #define         NWUO_RWDATALL           0x10000000L
          #define NWUO_IPOPT_MASK         0x2000L
          #define         NWUO_EN_IPOPT           0x00002000L
          #define         NWUO_DI_IPOPT           0x20000000L

     A UDP channel is considered configured when one flag in each category has
     been  selected.   Thus one of NWUO_EXCL, NWUO_SHARED or NWUO_COPY, one of
     NWUO_LP_SEL,  NWUO_LP_SET  or  NWUO_LP_ANY,   one   of   NWUO_EN_LOC   or
     NWUO_DI_LOC,  one of NWUO_EN_BROAD, or NWUO_DI_BROAD, one of NWUO_RP_SET,
     or  NWUO_RP_ANY,   one   of   NWUO_RA_SET,   or   NWUO_RA_ANY,   one   of
     NWUO_RWDATONLY,   or   NWUO_RWDATALL,   and   one  of  NWUO_EN_IPOPT,  or
     NWUO_DI_IPOPT.  The acc flags control the access to a certain  UDP  port.
     NWUO_EXCL  means  exclusive  access:  no other channel can use this port.
     NWUO_SHARED means shared  access:   only  channels  that  specify  shared
     access  can use this port and all packets that are received are handed to
     at most one channel.  NWUO_COPY imposes no  access  restriction  and  all
     channels get a copy of every received packet for that port.

     The locport flags control the selection of the UDP port for this channel.
     NWUO_LP_SEL requests the server to pick a port.  This port will be in the
     range from 32768 to 65535 and it will be unique.   NWUO_LP_SET  sets  the
     local  port to the value of the nwuo_locport field.  NWUO_LP_ANY does not
     select a port.  Reception of data is therefore not  possible  but  it  is
     possible to send data.  (See tcpip_read, and tcpip_write above).



                                                                            13



IP(4)                     Minix Programmer's Manual                      IP(4)


     The locaddr flags control the reception of packets.  NWUO_EN_LOC  enables
     the  reception  of  packets  with  the  local  IP address as destination.
     NWUO_DI_LOC disables the reception of packet for the local IP address.

     The  broad  flags   control   the   reception   of   broadcast   packets.
     NWUO_EN_BROAD   enables   the   reception   of   broadcast   packets  and
     NWUO_DI_BROAD disables the reception of broadcast packets.

     The remport flags let the client to specify one specific remote UDP  port
     or to allow any remote port.  NWUO_RP_SET sets the remote UDP port to the
     value of nwuo_remport.  Only packets with a matching remote port will  be
     delivered  and all packets will be sent to that port.  NWUO_RP_ANY allows
     reception of packets form any port  and  when  transmitting  packets  the
     remote port has to be specified.

     The remaddr flags control the remote IP address.   NWUO_RA_SET  sets  the
     remote  IP  address  the  value  of nwuo_remaddr.  Only packets from that
     address will be delivered and all packets will be sent to  that  address.
     NWUO_RA_ANY   allows   reception  of  packets  from  any  host  and  when
     transmitting packets the remote host has to be specified.

     The rw flags control the format of the data to be sent or received.  With
     NWUO_RWDATONLY  only  the data part of a UDP packet is sent to the server
     and only the data part is received from the  server.   The  NWUO_RWDATALL
     mode  presents  the data part of a UDP packet with a header that contains
     the source and destination IP address, source and destination UDP  ports,
     the  IP  options,  etc.  The server expects such a header in front of the
     data to be transmitted.

     The ipopt flags control the delivery  and  transmission  of  IP  options.
     When  NWUO_EN_IPOPT  is set IP, options will be delivered and sent.  When
     NWUO_DI_IPOPT is set IP option will be stripped from received packets and
     no IP options will be sent.

FILES

     /dev/eth[01]      First and second raw ethernet.

     /dev/psip[01]     First and second Pseudo IP network.

     /dev/ip[0123]     IP  devices  for  two  ethernets  and  two  Pseudo   IP
                       networks.

     /dev/tcp[0123]    TCP devices for same four networks.

     /dev/udp[0123]    UDP devices.

     /dev/eth, /dev/psip, /dev/ip, /dev/tcp, /dev/udp
                       Devices for the default network, links to  the  devices
                       above.  Eth is only present if ethernet is the default,


                                                                            14



IP(4)                     Minix Programmer's Manual                      IP(4)


                       psip only for pseudo IP.

SEE ALSO
     hton(3), oneC_sum(3), set_net_default(8), boot(8).

DIAGNOSTICS
     Several errors may be returned by the TCP/IP server.  The error  code  is
     found in the errno variable if the read, write, or ioctl call returns -1.
     The TCP/IP error codes defined in <errno.h> are:

     EPACKSIZE              This indicates an attempt to read or write with  a
                            buffer that is too large or too small.

     EOUTOFBUFS             The  TCP/IP  server  has  insufficient  memory  to
                            execute the request.

     EBADIOCTL              This indicates an attempt to execute a command the
                            particular   server   does  not  understand.   For
                            example, a NWIOGTCPCONF on an ETH channel.

     EBADMODE               The request is refused because the channel is  not
                            fully  configured,  in  the  wrong  state  or  the
                            parameters are invalid.

     EBADDEST               This indicates an illegal destination address  for
                            a packet.

     EDSTNORCH              The destination is not reachable.

     EISCONN                The channel  is  already  connected  so  a  second
                            request is refused.

     EADDRINUSE             This address is in use.

     ECONNREFUSED           The connection is refused by the other side.

     ECONNRESET             The   connection    is    reset    (non-gracefully
                            terminated) by the other side.

     ETIMEDOUT              The connection is terminated  due  to  an  expired
                            timer.

     EURG                   Urgent data is present  and  the  current  receive
                            mode does not allow urgent data to be transferred.

     ENOURG                 No urgent data is present and a request  came  for
                            urgent data.





                                                                            15



IP(4)                     Minix Programmer's Manual                      IP(4)


     ENOTCONN               The request requires a connected channel  and  the
                            channel is not connected.

     ESHUTDOWN              The  connection  is  shut  down.    That   is,   a
                            NWIOTCPSHUTDOWN  has been executed so no more data
                            can be transmitted.

     ENOCONN                The connection does not exist.

     EGENERIC               A generic error code for extremely weird cases.

AUTHOR
     Philip Homburg (philip@cs.vu.nl)







































                                                                            16

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -