/* 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 */
#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.
"Too many levels of symbolic links", /* ELOOP */
"Driver restarted", /* ERESTART */
unknown, /* 42 */
- unknown, /* 43 */
+ "Identifier removed", /* EIDRM */
unknown, /* 44 */
unknown, /* 45 */
unknown, /* 46 */
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 */
"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]);
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
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
.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
.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
.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
return NW_OK;
}
if (ce->ac_state == ACS_UNREACHABLE)
- return EDSTNOTRCH;
+ return EHOSTUNREACH;
assert(ce->ac_state == ACS_INCOMPLETE);
return NW_SUSPEND;
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);
}
/* 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;
{
/* 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) );
{
/* 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) );
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);
/* 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);
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);
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"));
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)
{
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
{
continue;
}
- tcp_close_connection (tcp_conn, EOUTOFBUFS);
+ tcp_close_connection (tcp_conn, ENOBUFS);
}
}
{
continue;
}
- tcp_close_connection (tcp_conn, EOUTOFBUFS);
+ tcp_close_connection (tcp_conn, ENOBUFS);
}
}
}
}
#endif
-PUBLIC void tcp_notreach(tcp_conn)
+PUBLIC void tcp_notreach(tcp_conn, error)
tcp_conn_t *tcp_conn;
+int error;
{
int new_ttl;
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)
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 ));
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 ||