]> Zhao Yanbai Git Server - minix.git/commitdiff
Portability: POSIXize some of inet's error codes
authorDavid van Moolenbroek <david@minix3.org>
Sat, 28 Nov 2009 13:18:33 +0000 (13:18 +0000)
committerDavid van Moolenbroek <david@minix3.org>
Sat, 28 Nov 2009 13:18:33 +0000 (13:18 +0000)
13 files changed:
include/errno.h
lib/ansi/errlist.c
man/man2/intro.2
man/man4/ip.4
servers/inet/generic/arp.c
servers/inet/generic/ip_eth.c
servers/inet/generic/ip_ioctl.c
servers/inet/generic/ip_read.c
servers/inet/generic/ip_write.c
servers/inet/generic/ipr.c
servers/inet/generic/tcp.c
servers/inet/generic/tcp_int.h
servers/inet/generic/tcp_send.c

index 0339d2f48a1bdcfb4e839f8f851ef960145ba814..5c26cc7b43dbb203ef52a60affbfc225ad0f74bf 100644 (file)
@@ -79,12 +79,12 @@ extern int errno;             /* place where the error numbers go */
 
 /* The following errors relate to networking. */
 #define EPACKSIZE     (_SIGN 50)  /* invalid packet size for some protocol */
-#define EOUTOFBUFS    (_SIGN 51)  /* not enough buffers left */
+#define ENOBUFS       (_SIGN 51)  /* not enough buffers left */
 #define EBADIOCTL     (_SIGN 52)  /* illegal ioctl for device */
 #define EBADMODE      (_SIGN 53)  /* badmode in ioctl */
 #define EWOULDBLOCK   (_SIGN 54)  /* call would block on nonblocking socket */
-#define EBADDEST      (_SIGN 55)  /* not a valid destination address */
-#define EDSTNOTRCH    (_SIGN 56)  /* destination not reachable */
+#define ENETUNREACH   (_SIGN 55)  /* network unreachable */
+#define EHOSTUNREACH  (_SIGN 56)  /* host unreachable */
 #define EISCONN              (_SIGN 57)  /* already connected */
 #define EADDRINUSE    (_SIGN 58)  /* address in use */
 #define ECONNREFUSED  (_SIGN 59)  /* connection refused */
@@ -105,6 +105,7 @@ extern int errno;             /* place where the error numbers go */
 #define ENOTSOCK      (_SIGN 74)  /* Socket operation on non-socket */
 #define ENOPROTOOPT   (_SIGN 75)  /* Protocol not available */
 #define EOPNOTSUPP    (_SIGN 76)  /* Operation not supported */
+#define ENETDOWN      (_SIGN 77)  /* network is down */
 
 /* The following are not POSIX errors, but they can still happen. 
  * All of these are generated by the kernel and relate to message passing.
index 884654f43b4b037b9e6e9504f56b415e72638e0b..0d27a53b4343c89f72aba93dd7c52d4eaa43e442 100644 (file)
@@ -52,7 +52,7 @@ const char *_sys_errlist[] = {
        "Too many levels of symbolic links",    /* ELOOP */
        "Driver restarted",             /* ERESTART */
        unknown,                        /* 42 */
-       unknown,                        /* 43 */
+       "Identifier removed",           /* EIDRM */
        unknown,                        /* 44 */
        unknown,                        /* 45 */
        unknown,                        /* 46 */
@@ -60,12 +60,12 @@ const char *_sys_errlist[] = {
        unknown,                        /* 48 */
        unknown,                        /* 49 */
        "Invalid packet size",          /* EPACKSIZE */
-       "Not enough buffers left",      /* EOUTOFBUFS */
+       "Not enough buffers left",      /* ENOBUFS */
        "Illegal ioctl for device",     /* EBADIOCTL */
        "Bad mode for ioctl",           /* EBADMODE */
        "Would block",                  /* EWOULDBLOCK */
-       "Bad destination address",      /* EBADDEST */
-       "Destination not reachable",    /* EDSTNOTRCH */
+       "Network unreachable",          /* ENETUNREACH */
+       "Host unreachable",             /* EHOSTUNREACH */
        "Already connected",            /* EISCONN */
        "Address in use",               /* EADDRINUSE */
        "Connection refused",           /* ECONNREFUSED */
@@ -86,6 +86,7 @@ const char *_sys_errlist[] = {
        "Socket operation on non-socket", /* ENOTSOCK */
        "Protocol not available",       /* ENOPROTOOPT */
        "Operation not supported",      /* EOPNOTSUPP */
+       "Network is down",              /* ENETDOWN */
 };
 
 const int _sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]);
index 238e770aa196b912659157eb08ddbf2816dbf076..f9cbeb58835da2a04273401b7e3e546c88381373 100644 (file)
@@ -32,7 +32,7 @@ variable \fBerrno\fP, which is not cleared
 on successful calls.
 Thus \fBerrno\fP should be tested only after an error has occurred.
 .PP
-The following is a complete list of the errors and their
+The following is a list of the errors and their
 names as given in
 .RI < sys/errno.h >:
 .en 0 OK "Error 0
@@ -228,16 +228,16 @@ system.
 A directory with entries other than \*(lq.\*(rq and \*(lq..\*(rq
 was supplied to a remove directory or rename call.
 .en 40 ELOOP "Too many symbolic links"
-A path name lookup involved more than SYMLOOP symbolic links.  SYMLOOP
-equals 8 as distributed.
-(Minix-vmd)
+A path name lookup involved too many symbolic links.
+.en 41 ERESTART "Device driver restarted
+.en 43 EIDRM "Identifier removed
 .en 50 EPACKSIZE "Invalid packet size
-.en 51 EOUTOFBUFS "Not enough buffers left
+.en 51 ENOBUFS "Not enough buffers left
 .en 52 EBADIOCTL "Illegal ioctl for device
 .en 53 EBADMODE "Bad mode in ioctl
 .en 54 EWOULDBLOCK "Would block
-.en 55 EBADDEST "Bad destination address
-.en 56 EDSTNOTRCH "Destination not reachable
+.en 55 ENETUNREACH "Network unreachable
+.en 56 EHOSTUNREACH "Host unreachable
 .en 57 EISCONN "Already connected
 .en 58 EADDRINUSE "Address in use
 .en 59 ECONNREFUSED "Connection refused
@@ -248,8 +248,17 @@ equals 8 as distributed.
 .en 64 ENOTCONN "No connection
 .en 65 ESHUTDOWN "Already shutdown
 .en 66 ENOCONN "No such connection
-.en 67 EINPROGRESS "Operation now in progress
-.en 68 EALREADY "Operation already in progress
+.en 67 EAFNOSUPPORT "Address family not supported
+.en 68 EPROTONOSUPPORT "Protocol not supported by AF
+.en 69 EPROTOTYPE "Protocol wrong type for socket
+.en 70 EINPROGRESS "Operation now in progress
+.en 71 EADDRNOTAVAIL "Can't assign requested address
+.en 72 EALREADY "Operation already in progress
+.en 73 EMSGSIZE "Message too long
+.en 74 ENOTSOCK "Socket operation on non-socket
+.en 75 ENOPROTOOPT "Protocol not available
+.en 76 EOPNOTSUPP "Operation not supported
+.en 77 ENETDOWN "Network is down
 .ig
 .en XXX EDQUOT "Disc quota exceeded"
 A 
index a8dd39dade3f924cbfcd3cc0460f791d9194ff96..c7b8d7e5c145ded9cd8f72e6c70a18aa9e84646e 100644 (file)
@@ -1414,11 +1414,11 @@ variable if the
 .BR write ,
 or
 .B ioctl
-call returns -1.  The TCP/IP error codes defined in <errno.h> are:
+call returns -1.  The TCP/IP error codes defined in <errno.h> are, among others:
 .IP EPACKSIZE 5c
 This indicates an attempt to read or write with a buffer that is too
 large or too small.
-.IP EOUTOFBUFS
+.IP ENOBUFS
 The TCP/IP server has insufficient memory to execute the request.
 .IP EBADIOCTL
 This indicates an attempt to execute a command the particular server
@@ -1429,10 +1429,10 @@ on an ETH channel.
 .IP EBADMODE
 The request is refused because the channel is not fully configured, in the
 wrong state or the parameters are invalid.
-.IP EBADDEST
-This indicates an illegal destination address for a packet.
-.IP EDSTNORCH
-The destination is not reachable.
+.IP ENETUNREACH
+The destination network is not reachable.
+.IP EHOSTUNREACH
+The destination host is not reachable.
 .IP EISCONN
 The channel is already connected so a second request is refused.
 .IP EADDRINUSE
index 536d58ef0cecfbde02d802b42bf57f99d17a13f4..6d9b85b8c741587b1cff4e43a09b25982b154bb1 100644 (file)
@@ -920,7 +920,7 @@ ether_addr_t *ethaddr;
                        return NW_OK;
                }
                if (ce->ac_state == ACS_UNREACHABLE)
-                       return EDSTNOTRCH;
+                       return EHOSTUNREACH;
                assert(ce->ac_state == ACS_INCOMPLETE);
 
                return NW_SUSPEND;
index b94633f148ba499817c07bf6c9cd81fc0a006450..aa0b51212dbf69b230836963534089d5d329736c 100644 (file)
@@ -346,10 +346,10 @@ int type;
                        ip_port->ip_dl.dl_eth.de_arp_tail= eth_pack;
                        return NW_OK;
                }
-               if (r == EDSTNOTRCH)
+               if (r == EHOSTUNREACH)
                {
                        bf_afree(eth_pack);
-                       return EDSTNOTRCH;
+                       return r;
                }
                assert(r == NW_OK);
        }
@@ -599,7 +599,7 @@ ether_addr_t *eth_addr;
                /* Dequeue the packet */
                ip_port->ip_dl.dl_eth.de_arp_head= eth_pack->acc_ext_link;
 
-               if (r == EDSTNOTRCH)
+               if (r == EHOSTUNREACH)
                {
                        bf_afree(eth_pack);
                        continue;
index d726d7738128aa1b4fc60c2286d3ce4e3b17f64e..1920b9feb52fde9513a27b98249f2a91d480f4d9 100644 (file)
@@ -299,7 +299,7 @@ ioreq_t req;
                {
                        /* Interface is down, no changes allowed */
                        return (*ip_fd->if_put_userdata)(ip_fd->if_srfd,
-                               EINVAL, NULL, TRUE);
+                               ENETDOWN, NULL, TRUE);
                }
 
                data= bf_packIffLess (data, sizeof(nwio_route_t) );
@@ -375,7 +375,7 @@ ioreq_t req;
                {
                        /* Interface is down, no changes allowed */
                        return (*ip_fd->if_put_userdata)(ip_fd->if_srfd,
-                               EINVAL, NULL, TRUE);
+                               ENETDOWN, NULL, TRUE);
                }
 
                data= bf_packIffLess (data, sizeof(nwio_route_t) );
index ab4bb9add78711b4da43fc268d5a72590e599eba..fb21d22921f4eead7b96778a4cd5a3357d9d5daf 100644 (file)
@@ -822,7 +822,7 @@ ev_arg_t ev_arg;
                                r= next_port->ip_dev_send(next_port,
                                        iroute->irt_gateway,
                                        pack, IP_LT_NORMAL);
-                               if (r == EDSTNOTRCH)
+                               if (r == EHOSTUNREACH)
                                {
                                        printf("ip[%d]: gw ",
                                                ip_port-ip_port_table);
@@ -894,7 +894,7 @@ ev_arg_t ev_arg;
                        /* Just send the packet to it's destination */
                        pack->acc_linkC++; /* Extra ref for ICMP */
                        r= next_port->ip_dev_send(next_port, dest, pack, type);
-                       if (r == EDSTNOTRCH)
+                       if (r == EHOSTUNREACH)
                        {
                                DBLOCK(1, printf("ip[%d]: next hop ",
                                        ip_port-ip_port_table);
index 5438837ab9241f70416edcc7dfbd5cfa1c76acd1..75028ae3aa299a5b139cc5fd5ef9141e72afdd4e 100644 (file)
@@ -78,11 +78,9 @@ size_t data_len;
 
        if (!(ip_fd->if_port->ip_flags & IPF_IPADDRSET))
        {
-               /* Interface is down. What kind of error do we want? For
-                * the moment, we return OK.
-                */
+               /* Interface is down. */
                bf_afree(data);
-               return NW_OK;
+               return ENETDOWN;
        }
 
        data_len= bf_bufsize(data);
@@ -198,17 +196,17 @@ size_t data_len;
        else if ((hostrep_dst & 0xe0000000l) == 0xe0000000l)
                ;       /* OK, Multicast */
        else if ((hostrep_dst & 0xf0000000l) == 0xf0000000l)
-               r= EBADDEST;    /* Bad class */
+               r= EAFNOSUPPORT;        /* Bad class */
        else if ((dstaddr ^ my_ipaddr) & netmask)
                ;       /* OK, remote destination */
        else if (!(dstaddr & ~netmask) &&
                (ip_port->ip_flags & IPF_SUBNET_BCAST))
        {
-               r= EBADDEST;    /* Zero host part */
+               r= EAFNOSUPPORT;        /* Zero host part */
        }
        if (r<0)
        {
-               DIFBLOCK(1, r == EBADDEST,
+               DIFBLOCK(1, r == EAFNOSUPPORT,
                        printf("bad destination: ");
                        writeIpAddr(ip_hdr->ih_dst);
                        printf("\n"));
index f9137caef381cea5b0d04aa3adcfb311ad4aca6d..6a3013a1579db0bbc7d758ad52dbb250ee30c5b3 100644 (file)
@@ -195,7 +195,7 @@ ipaddr_t *nexthop;
 
        oroute= oroute_find_ent(port_nr, dest);
        if (!oroute || oroute->ort_dist > ttl)
-               return EDSTNOTRCH;
+               return ENETUNREACH;
        if (msgsize && oroute->ort_mtu && 
                oroute->ort_mtu < msgsize)
        {
index eb45d6e4d5820128561da2011c38126b274c62b6..f03ddc6b189fc139d809fb185c35d2533bd082bd 100644 (file)
@@ -392,12 +392,14 @@ assert (count == sizeof(struct nwio_ipopt));
                        result= (int)offset;
                        if (result<0)
                        {
-                               if (result == EDSTNOTRCH)
+                               if (result == EHOSTUNREACH ||
+                                       result == ENETUNREACH ||
+                                       result == ENETDOWN)
                                {
                                        if (tcp_port->tp_snd_head)
                                        {
                                                tcp_notreach(tcp_port->
-                                                       tp_snd_head);
+                                                       tp_snd_head, result);
                                        }
                                }
                                else
@@ -2414,7 +2416,7 @@ int priority;
                        {
                                continue;
                        }
-                       tcp_close_connection (tcp_conn, EOUTOFBUFS);
+                       tcp_close_connection (tcp_conn, ENOBUFS);
                }
        }
 
@@ -2434,7 +2436,7 @@ int priority;
                        {
                                continue;
                        }
-                       tcp_close_connection (tcp_conn, EOUTOFBUFS);
+                       tcp_close_connection (tcp_conn, ENOBUFS);
                }
        }
 }
@@ -2470,8 +2472,9 @@ PRIVATE void tcp_bufcheck()
 }
 #endif
 
-PUBLIC void tcp_notreach(tcp_conn)
+PUBLIC void tcp_notreach(tcp_conn, error)
 tcp_conn_t *tcp_conn;
+int error;
 {
        int new_ttl;
 
@@ -2479,7 +2482,7 @@ tcp_conn_t *tcp_conn;
        if (new_ttl == IP_MAX_TTL)
        {
                if (tcp_conn->tc_state == TCS_SYN_SENT)
-                       tcp_close_connection(tcp_conn, EDSTNOTRCH);
+                       tcp_close_connection(tcp_conn, error);
                return;
        }
        else if (new_ttl < TCP_DEF_TTL_NEXT)
index a56159d1f805dc89f75931d3aa52c77c4a3b2234..9c5b17c1745607e3bbbdf4f6f163f6e1012b28ef 100644 (file)
@@ -243,7 +243,7 @@ int tcp_su4listen ARGS(( tcp_fd_t *tcp_fd, tcp_conn_t *tcp_conn,
 void tcp_reply_ioctl ARGS(( tcp_fd_t *tcp_fd, int reply ));
 void tcp_reply_write ARGS(( tcp_fd_t *tcp_fd, size_t reply ));
 void tcp_reply_read ARGS(( tcp_fd_t *tcp_fd, size_t reply ));
-void tcp_notreach ARGS(( tcp_conn_t *tcp_conn ));
+void tcp_notreach ARGS(( tcp_conn_t *tcp_conn, int error ));
 void tcp_mtu_exceeded ARGS(( tcp_conn_t *tcp_conn ));
 void tcp_mtu_incr ARGS(( tcp_conn_t *tcp_conn ));
 
index 7541ef819f4cfb9529e44d6589313c2e0aa881a9..3d0be8b310799ed3f8ca4209b3cec33f936113e4 100644 (file)
@@ -121,12 +121,13 @@ tcp_port_t *tcp_port;
                                        tcp_mtu_exceeded(tcp_conn);
                                        continue;
                                }
-                               if (r == EDSTNOTRCH)
+                               if (r == EHOSTUNREACH || r == ENETUNREACH ||
+                                       r == ENETDOWN)
                                {
-                                       tcp_notreach(tcp_conn);
+                                       tcp_notreach(tcp_conn, r);
                                        continue;
                                }
-                               if (r == EBADDEST)
+                               if (r == EAFNOSUPPORT)
                                        continue;
                        }
                        assert(r == NW_OK ||