Portability: POSIXize some of inet's error codes

This commit is contained in:
David van Moolenbroek
2009-11-28 13:18:33 +00:00
parent 709a739b52
commit c6cce1823d
13 changed files with 61 additions and 48 deletions

View 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;

View 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;

View 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) );

View 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);

View 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"));

View 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)
{

View 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)

View 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 ));

View 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 ||