case ICMP_ECHO:
icp->icmp_type = ICMP_ECHOREPLY;
ip->ip_len += hlen; /* since ip_input subtracts this */
- if (ip->ip_dst.s_addr == our_addr.s_addr ||
- (ip->ip_dst.s_addr == (special_addr.s_addr|htonl(CTL_ALIAS))) ) {
+ if (ip->ip_dst.s_addr == alias_addr.s_addr) {
icmp_reflect(m);
} else {
struct socket *so;
icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
udp_detach(so);
}
- } /* if ip->ip_dst.s_addr == our_addr.s_addr */
+ } /* if ip->ip_dst.s_addr == alias_addr.s_addr */
break;
case ICMP_UNREACH:
/* XXX? report error? close socket? */
ip->ip_ttl = MAXTTL;
ip->ip_p = IPPROTO_ICMP;
ip->ip_dst = ip->ip_src; /* ip adresses */
- ip->ip_src = our_addr;
+ ip->ip_src = alias_addr;
(void ) ip_output((struct socket *)NULL, m);
extern fd_set *global_readfds, *global_writefds, *global_xfds;
extern struct in_addr ctl_addr;
extern struct in_addr special_addr;
+extern struct in_addr alias_addr;
extern struct in_addr our_addr;
extern struct in_addr loopback_addr;
extern struct in_addr dns_addr;
he = gethostbyname(buff);
if (he)
our_addr = *(struct in_addr *)he->h_addr;
- /* If the host doesn't have a useful IP address then use the
- guest side address. */
- if (our_addr.s_addr == 0 || our_addr.s_addr == loopback_addr.s_addr)
- our_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
+ if (our_addr.s_addr == 0)
+ our_addr.s_addr = loopback_addr.s_addr;
}
#if SIZEOF_CHAR_P == 8
/* address for slirp virtual addresses */
struct in_addr special_addr;
+/* virtual address alias for host */
+struct in_addr alias_addr;
const uint8_t special_ethaddr[6] = {
0x52, 0x54, 0x00, 0x12, 0x35, 0x00
}
inet_aton(CTL_SPECIAL, &special_addr);
+ alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
getouraddr();
}
getsockname(s,(struct sockaddr *)&addr,&addrlen);
so->so_fport = addr.sin_port;
if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)
- so->so_faddr = our_addr;
+ so->so_faddr = alias_addr;
else
so->so_faddr = addr.sin_addr;
so->so_faddr = addr.sin_addr;
/* Translate connections from localhost to the real hostname */
if (so->so_faddr.s_addr == 0 || so->so_faddr.s_addr == loopback_addr.s_addr)
- so->so_faddr = our_addr;
+ so->so_faddr = alias_addr;
/* Close the accept() socket, set right state */
if (inso->so_state & SS_FACCEPTONCE) {
if (ns->so_faddr.s_addr == 0 ||
ns->so_faddr.s_addr == loopback_addr.s_addr)
- ns->so_faddr = our_addr;
+ ns->so_faddr = alias_addr;
ns->so_iptos = tcp_tos(ns);
tp = sototcpcb(ns);
getsockname(so->s,(struct sockaddr *)&addr,&addrlen);
so->so_fport = addr.sin_port;
if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)
- so->so_faddr = our_addr;
+ so->so_faddr = alias_addr;
else
so->so_faddr = addr.sin_addr;