Portability: POSIXize some of inet's error codes
This commit is contained in:
parent
709a739b52
commit
c6cce1823d
13 changed files with 61 additions and 48 deletions
|
@ -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.
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) );
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 ));
|
||||
|
||||
|
|
|
@ -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 ||
|
||||
|
|
Loading…
Reference in a new issue