slirp: Integrate debugging support with simh debug output.
simh debug integration is only done during simh builds, the original QEMU debug functionality is preserved. The slirp debug flags can be set by the environment variable SLIRP_DEBUG. Mask values 1 - CALL, 2 - MISC, 3 - ERROR.
This commit is contained in:
parent
6da2be7d7b
commit
79f50fa6bb
16 changed files with 105 additions and 81 deletions
|
@ -33,9 +33,9 @@ void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN])
|
|||
|
||||
DEBUG_CALL("arp_table_add");
|
||||
DEBUG_ARG("ip = 0x%x", ip_addr);
|
||||
DEBUG_ARGS((dfd, " hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
DEBUG_ARGS(" hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
ethaddr[0], ethaddr[1], ethaddr[2],
|
||||
ethaddr[3], ethaddr[4], ethaddr[5]));
|
||||
ethaddr[3], ethaddr[4], ethaddr[5]);
|
||||
|
||||
if (ip_addr == 0 || ip_addr == 0xffffffff || ip_addr == broadcast_addr) {
|
||||
/* Do not register broadcast addresses */
|
||||
|
@ -78,9 +78,9 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr,
|
|||
for (i = 0; i < ARP_TABLE_SIZE; i++) {
|
||||
if (arptbl->table[i].ar_sip == ip_addr) {
|
||||
memcpy(out_ethaddr, arptbl->table[i].ar_sha, ETH_ALEN);
|
||||
DEBUG_ARGS((dfd, " found hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
DEBUG_ARGS(" found hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
out_ethaddr[0], out_ethaddr[1], out_ethaddr[2],
|
||||
out_ethaddr[3], out_ethaddr[4], out_ethaddr[5]));
|
||||
out_ethaddr[3], out_ethaddr[4], out_ethaddr[5]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,6 @@
|
|||
|
||||
static const uint8_t rfc1533_cookie[] = { RFC1533_COOKIE };
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do if (slirp_debug & DBG_CALL) { fprintf(dfd, fmt, ## __VA_ARGS__); fflush(dfd); } while (0)
|
||||
#else
|
||||
#define DPRINTF(fmt, ...) do{}while(0)
|
||||
#endif
|
||||
|
||||
static BOOTPClient *get_new_addr(Slirp *slirp, struct in_addr *paddr,
|
||||
const uint8_t *macaddr)
|
||||
{
|
||||
|
@ -291,7 +284,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp)
|
|||
if (slirp->vdnssearch) {
|
||||
size_t spaceleft = sizeof(rbp->bp_vend) - (q - rbp->bp_vend);
|
||||
val = slirp->vdnssearch_len;
|
||||
if (val + 1 > spaceleft) {
|
||||
if ((size_t)val + 1 > spaceleft) {
|
||||
g_warning("DHCP packet size exceeded, "
|
||||
"omitting domain-search option.");
|
||||
} else {
|
||||
|
|
|
@ -123,8 +123,8 @@ int cksum(struct mbuf *m, int len)
|
|||
cont:
|
||||
#ifdef DEBUG
|
||||
if (len) {
|
||||
DEBUG_ERROR((dfd, "cksum: out of data\n"));
|
||||
DEBUG_ERROR((dfd, " len = %d\n", len));
|
||||
DEBUG_ERROR("cksum: out of data\n");
|
||||
DEBUG_ERROR(" len = %d\n", len);
|
||||
}
|
||||
#endif
|
||||
if (mlen == -1) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#ifndef SLIRP_DEBUG_H
|
||||
#define SLIRP_DEBUG_H
|
||||
/*
|
||||
* Copyright (c) 1995 Danny Gasparovski.
|
||||
*
|
||||
|
@ -5,30 +7,51 @@
|
|||
* terms and conditions of the copyright.
|
||||
*/
|
||||
|
||||
//#define DEBUG 1
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
#define DBG_CALL 0x1
|
||||
#define DBG_MISC 0x2
|
||||
#define DBG_ERROR 0x4
|
||||
|
||||
#define dfd stderr
|
||||
|
||||
extern int slirp_debug;
|
||||
|
||||
#define DEBUG_CALL(x) if (slirp_debug & DBG_CALL) { fprintf(dfd, "%s...\n", x); fflush(dfd); }
|
||||
#define DEBUG_ARG(x, y) if (slirp_debug & DBG_CALL) { fputc(' ', dfd); fprintf(dfd, x, y); fputc('\n', dfd); fflush(dfd); }
|
||||
#define DEBUG_ARGS(x) if (slirp_debug & DBG_CALL) { fprintf x ; fflush(dfd); }
|
||||
#define DEBUG_MISC(x) if (slirp_debug & DBG_MISC) { fprintf x ; fflush(dfd); }
|
||||
#define DEBUG_ERROR(x) if (slirp_debug & DBG_ERROR) {fprintf x ; fflush(dfd); }
|
||||
#if defined(HAVE_SLIRP_NETWORK) /* simh build indicator */
|
||||
#include <stdio.h>
|
||||
#define DEVICE void
|
||||
|
||||
extern void *slirp_dptr;
|
||||
extern int slirp_dbit;
|
||||
|
||||
extern void _sim_debug (int dbits, DEVICE* dptr, const char* fmt, ...);
|
||||
|
||||
#define DEBUG_CALL(x) do {if (slirp_debug & DBG_CALL) { _sim_debug (slirp_dbit, slirp_dptr, "%s...\n", x); };} while (0)
|
||||
#define DEBUG_ARG(x, y) do {if (slirp_debug & DBG_CALL) {_sim_debug (slirp_dbit, slirp_dptr, x, y); _sim_debug (slirp_dbit, slirp_dptr, "\n"); };} while (0)
|
||||
#define DEBUG_ARGS(...) do {if (slirp_debug & DBG_CALL) { _sim_debug (slirp_dbit, slirp_dptr, ## __VA_ARGS__); };} while (0)
|
||||
#define DEBUG_MISC(...) do {if (slirp_debug & DBG_MISC) { _sim_debug (slirp_dbit, slirp_dptr, ## __VA_ARGS__); };} while (0)
|
||||
#define DEBUG_ERROR(...) do {if (slirp_debug & DBG_ERROR) { _sim_debug (slirp_dbit, slirp_dptr, ## __VA_ARGS__); };} while (0)
|
||||
#define DPRINTF(fmt, ...) do {if (slirp_debug & DBG_CALL) { _sim_debug (slirp_dbit, slirp_dptr, fmt, ## __VA_ARGS__); };} while (0)
|
||||
|
||||
#else /* !defined(HAVE_SLIRP_NETWORK) */
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
#define dfd stderr
|
||||
|
||||
#define DEBUG_CALL(x) do {if (slirp_debug & DBG_CALL) { fprintf (dfd, "%s...\n", x); fflush(dfd); };} while (0)
|
||||
#define DEBUG_ARG(x, y) do {if (slirp_debug & DBG_CALL) { fprintf (dfd, x, y); _sim_debug (slirp_dbit, slirp_dptr, "\n"); fflush(dfd); };} while (0)
|
||||
#define DEBUG_ARGS(...) do {if (slirp_debug & DBG_CALL) { fprintf (dfd, ## __VA_ARGS__); fflush(dfd); };} while (0)
|
||||
#define DEBUG_MISC(...) do {if (slirp_debug & DBG_MISC) { fprintf (dfd, ## __VA_ARGS__); fflush(dfd); };} while (0)
|
||||
#define DEBUG_ERROR(...) do {if (slirp_debug & DBG_ERROR) { fprintf (dfd, ## __VA_ARGS__); fflush(dfd); };} while (0)
|
||||
#define DPRINTF(fmt, ...) do {if (slirp_debug & DBG_CALL) { fprintf (dfd, fmt, ## __VA_ARGS__); fflush(dfd);} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define DEBUG_CALL(x)
|
||||
#define DEBUG_ARG(x, y)
|
||||
#define DEBUG_ARGS(x)
|
||||
#define DEBUG_MISC(x)
|
||||
#define DEBUG_ERROR(x)
|
||||
#define DEBUG_ARGS(...)
|
||||
#define DEBUG_MISC(...)
|
||||
#define DEBUG_ERROR(...)
|
||||
#define DPRINTF(fmt, ...)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -98,8 +98,8 @@ static int icmp_send(struct socket *so, struct mbuf *m, int hlen)
|
|||
|
||||
if (sendto(so->s, m->m_data + hlen, m->m_len - hlen, 0,
|
||||
(struct sockaddr *)&addr, sizeof(addr)) == -1) {
|
||||
DEBUG_MISC((dfd, "icmp_input icmp sendto tx errno = %d-%s\n",
|
||||
errno, strerror(errno)));
|
||||
DEBUG_MISC("icmp_input icmp sendto tx errno = %d-%s\n",
|
||||
errno, strerror(errno));
|
||||
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, 0, strerror(errno));
|
||||
icmp_detach(so);
|
||||
}
|
||||
|
@ -163,8 +163,8 @@ icmp_input(struct mbuf *m, int hlen)
|
|||
return;
|
||||
}
|
||||
if(udp_attach(so) == -1) {
|
||||
DEBUG_MISC((dfd,"icmp_input udp_attach errno = %d-%s\n",
|
||||
errno,strerror(errno)));
|
||||
DEBUG_MISC("icmp_input udp_attach errno = %d-%s\n",
|
||||
errno,strerror(errno));
|
||||
sofree(so);
|
||||
m_free(m);
|
||||
goto end_error;
|
||||
|
@ -195,8 +195,8 @@ icmp_input(struct mbuf *m, int hlen)
|
|||
addr.sin_port = so->so_fport;
|
||||
if(sendto(so->s, icmp_ping_msg, strlen(icmp_ping_msg), 0,
|
||||
(struct sockaddr *)&addr, sizeof(addr)) == -1) {
|
||||
DEBUG_MISC((dfd,"icmp_input udp sendto tx errno = %d-%s\n",
|
||||
errno,strerror(errno)));
|
||||
DEBUG_MISC("icmp_input udp sendto tx errno = %d-%s\n",
|
||||
errno,strerror(errno));
|
||||
icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
|
||||
udp_detach(so);
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ icmp_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
|
|||
{ char bufa[20], bufb[20];
|
||||
strcpy(bufa, inet_ntoa(ip->ip_src));
|
||||
strcpy(bufb, inet_ntoa(ip->ip_dst));
|
||||
DEBUG_MISC((dfd, " %.16s to %.16s\n", bufa, bufb));
|
||||
DEBUG_MISC(" %.16s to %.16s\n", bufa, bufb);
|
||||
}
|
||||
#endif
|
||||
if(ip->ip_off & IP_OFFMASK) goto end_error; /* Only reply to fragment 0 */
|
||||
|
@ -439,8 +439,8 @@ void icmp_receive(struct socket *so)
|
|||
} else {
|
||||
error_code = ICMP_UNREACH_HOST;
|
||||
}
|
||||
DEBUG_MISC((dfd, " udp icmp rx errno = %d-%s\n", errno,
|
||||
strerror(errno)));
|
||||
DEBUG_MISC(" udp icmp rx errno = %d-%s\n", errno,
|
||||
strerror(errno));
|
||||
icmp_error(so->so_m, ICMP_UNREACH, error_code, 0, strerror(errno));
|
||||
} else {
|
||||
icmp_reflect(so->so_m);
|
||||
|
|
|
@ -235,7 +235,7 @@ dtom(Slirp *slirp, void *dat)
|
|||
}
|
||||
}
|
||||
|
||||
DEBUG_ERROR((dfd, "dtom failed"));
|
||||
DEBUG_ERROR("dtom failed");
|
||||
|
||||
return (struct mbuf *)0;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,11 @@
|
|||
#include "qemu/error-report.h"
|
||||
#include "qemu/main-loop.h"
|
||||
|
||||
int slirp_debug =
|
||||
#ifdef DEBUG
|
||||
int slirp_debug = DBG_CALL|DBG_MISC|DBG_ERROR;
|
||||
DBG_CALL|DBG_MISC|DBG_ERROR;
|
||||
#else
|
||||
0;
|
||||
#endif
|
||||
|
||||
struct quehead {
|
||||
|
@ -232,7 +235,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
|
|||
void slirp_connection_info(Slirp *slirp, Monitor *mon)
|
||||
{
|
||||
#if (TCPS_CLOSED != 0) || (TCPS_TIME_WAIT != 10)
|
||||
#error unexpected symbol values
|
||||
#error unexpected TCPS symbol values
|
||||
#endif
|
||||
const char * const tcpstates[] = {
|
||||
/* [TCPS_CLOSED] = */ "CLOSED",
|
||||
|
|
|
@ -19,13 +19,13 @@ sbfree(struct sbuf *sb)
|
|||
void
|
||||
sbdrop(struct sbuf *sb, int num)
|
||||
{
|
||||
int limit = sb->sb_datalen / 2;
|
||||
u_int limit = sb->sb_datalen / 2;
|
||||
|
||||
/*
|
||||
* We can only drop how much we have
|
||||
* This should never succeed
|
||||
*/
|
||||
if(num > sb->sb_cc)
|
||||
if((u_int)num > sb->sb_cc)
|
||||
num = sb->sb_cc;
|
||||
sb->sb_cc -= num;
|
||||
sb->sb_rptr += num;
|
||||
|
@ -173,7 +173,7 @@ sbcopy(struct sbuf *sb, int off, int len, char *to)
|
|||
from -= sb->sb_datalen;
|
||||
|
||||
if (from < sb->sb_wptr) {
|
||||
if (len > sb->sb_cc) len = sb->sb_cc;
|
||||
if ((u_int)len > sb->sb_cc) len = sb->sb_cc;
|
||||
memcpy(to,from,len);
|
||||
} else {
|
||||
/* re-use off */
|
||||
|
|
|
@ -112,32 +112,27 @@ void pstrcpy(char *buf, int buf_size, const char *str)
|
|||
|
||||
int qemu_socket(int domain, int type, int protocol)
|
||||
{
|
||||
fprintf (stderr, "qemu_socket()\r\n");
|
||||
return socket (domain, type, protocol);
|
||||
}
|
||||
|
||||
int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
{
|
||||
fprintf (stderr, "qemu_accept()\r\n");
|
||||
return accept (s, addr, addrlen);
|
||||
}
|
||||
|
||||
int qemu_setsockopt (int s, int level, int optname, void *optval, int optlen)
|
||||
{
|
||||
fprintf (stderr, "qemu_setsockopt()\r\n");
|
||||
return setsockopt ((SOCKET)s, level, optname, (char *)optval, optlen);
|
||||
}
|
||||
|
||||
int qemu_recv (int s, void *buf, size_t len, int flags)
|
||||
{
|
||||
fprintf (stderr, "qemu_recv()\r\n");
|
||||
return recv ((SOCKET)s, buf, len, flags);
|
||||
}
|
||||
|
||||
int socket_set_nodelay(int fd)
|
||||
{
|
||||
int v = 1;
|
||||
fprintf (stderr, "socket_set_nodelay()\r\n");
|
||||
return setsockopt((SOCKET)fd, IPPROTO_TCP, TCP_NODELAY, (char *)&v, sizeof(v));
|
||||
}
|
||||
|
||||
|
|
|
@ -148,6 +148,9 @@ struct sim_slirp {
|
|||
uint32 dbit;
|
||||
};
|
||||
|
||||
DEVICE *slirp_dptr;
|
||||
uint32 slirp_dbit;
|
||||
|
||||
SLIRP *sim_slirp_open (const char *args, void *opaque, packet_callback callback, DEVICE *dptr, uint32 dbit)
|
||||
{
|
||||
SLIRP *slirp = (SLIRP *)g_malloc0(sizeof(*slirp));
|
||||
|
@ -157,6 +160,8 @@ char *cptr;
|
|||
char tbuf[CBUFSIZE], gbuf[CBUFSIZE];
|
||||
int err;
|
||||
|
||||
slirp_dptr = dptr;
|
||||
slirp_dbit = dbit;
|
||||
slirp->args = (char *)g_malloc0(1 + strlen(args));
|
||||
strcpy (slirp->args, args);
|
||||
slirp->opaque = opaque;
|
||||
|
@ -454,7 +459,7 @@ for (i = 0; i < pollfds->len; i++) {
|
|||
FD_SET(fd, wfds);
|
||||
nfds = MAX(nfds, fd);
|
||||
}
|
||||
if (events & G_IO_PRI) {
|
||||
if (events & (G_IO_PRI | G_IO_HUP | G_IO_ERR)) {
|
||||
FD_SET(fd, xfds);
|
||||
nfds = MAX(nfds, fd);
|
||||
}
|
||||
|
|
|
@ -207,6 +207,11 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork,
|
|||
Slirp *slirp = g_malloc0(sizeof(Slirp));
|
||||
|
||||
slirp_init_once();
|
||||
|
||||
/* set debug flags (useful when compiled with DEBUG enabled)*/
|
||||
/* bitmask values (1 = CALL, 2 = MISC, 3 = ERROR) */
|
||||
if (getenv("SLIRP_DEBUG"))
|
||||
slirp_debug = atoi(getenv("SLIRP_DEBUG"));
|
||||
|
||||
slirp->restricted = restricted;
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ soread(struct socket *so)
|
|||
|
||||
#ifdef HAVE_READV
|
||||
nn = readv(so->s, (struct iovec *)iov, n);
|
||||
DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
|
||||
DEBUG_MISC(" ... read nn = %d bytes\n", nn);
|
||||
#else
|
||||
nn = qemu_recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
|
||||
#endif
|
||||
|
@ -173,7 +173,7 @@ soread(struct socket *so)
|
|||
if (nn < 0 && (errno == EINTR || errno == EAGAIN))
|
||||
return 0;
|
||||
else {
|
||||
DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno)));
|
||||
DEBUG_MISC(" --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno));
|
||||
sofcantrcvmore(so);
|
||||
tcp_sockclosed(sototcpcb(so));
|
||||
return -1;
|
||||
|
@ -197,7 +197,7 @@ soread(struct socket *so)
|
|||
nn += ret;
|
||||
}
|
||||
|
||||
DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
|
||||
DEBUG_MISC(" ... read nn = %d bytes\n", nn);
|
||||
#endif
|
||||
|
||||
/* Update fields */
|
||||
|
@ -304,7 +304,7 @@ sosendoob(struct socket *so)
|
|||
n = slirp_send(so, sb->sb_rptr, so->so_urgc, (MSG_OOB)); /* |MSG_DONTWAIT)); */
|
||||
so->so_urgc -= n;
|
||||
|
||||
DEBUG_MISC((dfd, " --- sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
|
||||
DEBUG_MISC(" --- sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc);
|
||||
} else {
|
||||
/*
|
||||
* Since there's no sendv or sendtov like writev,
|
||||
|
@ -325,9 +325,9 @@ sosendoob(struct socket *so)
|
|||
n = slirp_send(so, buff, len, (MSG_OOB)); /* |MSG_DONTWAIT)); */
|
||||
#ifdef DEBUG
|
||||
if (n != len)
|
||||
DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
|
||||
DEBUG_ERROR("Didn't send all data urgently XXXXX\n");
|
||||
#endif
|
||||
DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
|
||||
DEBUG_MISC(" ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc);
|
||||
}
|
||||
|
||||
sb->sb_cc -= n;
|
||||
|
@ -389,7 +389,7 @@ sowrite(struct socket *so)
|
|||
#ifdef HAVE_READV
|
||||
nn = writev(so->s, (const struct iovec *)iov, n);
|
||||
|
||||
DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn));
|
||||
DEBUG_MISC(" ... wrote nn = %d bytes\n", nn);
|
||||
#else
|
||||
nn = slirp_send(so, iov[0].iov_base, iov[0].iov_len,0);
|
||||
#endif
|
||||
|
@ -398,8 +398,8 @@ sowrite(struct socket *so)
|
|||
return 0;
|
||||
|
||||
if (nn <= 0) {
|
||||
DEBUG_MISC((dfd, " --- sowrite disconnected, so->so_state = %x, errno = %d\n",
|
||||
so->so_state, errno));
|
||||
DEBUG_MISC(" --- sowrite disconnected, so->so_state = %x, errno = %d\n",
|
||||
so->so_state, errno);
|
||||
sofcantsendmore(so);
|
||||
tcp_sockclosed(sototcpcb(so));
|
||||
return -1;
|
||||
|
@ -412,7 +412,7 @@ sowrite(struct socket *so)
|
|||
if (ret > 0)
|
||||
nn += ret;
|
||||
}
|
||||
DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn));
|
||||
DEBUG_MISC(" ... wrote nn = %d bytes\n", nn);
|
||||
#endif
|
||||
|
||||
/* Update sbuf */
|
||||
|
@ -457,8 +457,8 @@ sorecvfrom(struct socket *so)
|
|||
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
|
||||
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
|
||||
|
||||
DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
|
||||
errno,strerror(errno)));
|
||||
DEBUG_MISC(" udp icmp rx errno = %d-%s\n",
|
||||
errno,strerror(errno));
|
||||
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
|
||||
} else {
|
||||
icmp_reflect(so->so_m);
|
||||
|
@ -468,7 +468,7 @@ sorecvfrom(struct socket *so)
|
|||
udp_detach(so);
|
||||
} else { /* A "normal" UDP packet */
|
||||
struct mbuf *m;
|
||||
int len;
|
||||
u_int len;
|
||||
#ifdef _WIN32
|
||||
unsigned long n;
|
||||
#else
|
||||
|
@ -498,15 +498,15 @@ sorecvfrom(struct socket *so)
|
|||
|
||||
m->m_len = recvfrom(so->s, m->m_data, len, 0,
|
||||
(struct sockaddr *)&addr, &addrlen);
|
||||
DEBUG_MISC((dfd, " did recvfrom %d, errno = %d-%s\n",
|
||||
m->m_len, errno,strerror(errno)));
|
||||
DEBUG_MISC(" did recvfrom %d, errno = %d-%s\n",
|
||||
m->m_len, errno,strerror(errno));
|
||||
if(m->m_len<0) {
|
||||
u_char code=ICMP_UNREACH_PORT;
|
||||
|
||||
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
|
||||
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
|
||||
|
||||
DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
|
||||
DEBUG_MISC(" rx error, tx icmp ICMP_UNREACH:%i\n", code);
|
||||
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
|
||||
m_free(m);
|
||||
} else {
|
||||
|
@ -560,7 +560,7 @@ sosendto(struct socket *so, struct mbuf *m)
|
|||
addr.sin_addr = so->so_faddr;
|
||||
addr.sin_port = so->so_fport;
|
||||
|
||||
DEBUG_MISC((dfd, " sendto()ing, addr.sin_port=%d, addr.sin_addr.s_addr=%.16s\n", ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));
|
||||
DEBUG_MISC(" sendto()ing, addr.sin_port=%d, addr.sin_addr.s_addr=%.16s\n", ntohs(addr.sin_port), inet_ntoa(addr.sin_addr));
|
||||
|
||||
/* Don't care what port we get */
|
||||
ret = sendto(so->s, m->m_data, m->m_len, 0,
|
||||
|
|
|
@ -231,8 +231,8 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso)
|
|||
Slirp *slirp;
|
||||
|
||||
DEBUG_CALL("tcp_input");
|
||||
DEBUG_ARGS((dfd, " m = %8lx iphlen = %2d inso = %lx\n",
|
||||
(long )m, iphlen, (long )inso ));
|
||||
DEBUG_ARGS(" m = %8lx iphlen = %2d inso = %lx\n",
|
||||
(long )m, iphlen, (long )inso );
|
||||
|
||||
/*
|
||||
* If called with m == 0, then we're continuing the connect
|
||||
|
@ -592,8 +592,8 @@ findso:
|
|||
#endif
|
||||
) {
|
||||
u_char code=ICMP_UNREACH_NET;
|
||||
DEBUG_MISC((dfd, " tcp fconnect errno = %d-%s\n",
|
||||
errno,strerror(errno)));
|
||||
DEBUG_MISC(" tcp fconnect errno = %d-%s\n",
|
||||
errno,strerror(errno));
|
||||
if(errno == ECONNREFUSED) {
|
||||
/* ACK the SYN, send RST to refuse the connection */
|
||||
tcp_respond(tp, ti, m, ti->ti_seq+1, (tcp_seq)0,
|
||||
|
@ -923,8 +923,8 @@ trimthenstep6:
|
|||
|
||||
if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) {
|
||||
if (ti->ti_len == 0 && tiwin == tp->snd_wnd) {
|
||||
DEBUG_MISC((dfd, " dup ack m = %lx so = %lx\n",
|
||||
(long )m, (long )so));
|
||||
DEBUG_MISC(" dup ack m = %lx so = %lx\n",
|
||||
(long )m, (long )so);
|
||||
/*
|
||||
* If we have outstanding data (other than
|
||||
* a window probe), this is a completely
|
||||
|
@ -1302,7 +1302,7 @@ tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti)
|
|||
int opt, optlen;
|
||||
|
||||
DEBUG_CALL("tcp_dooptions");
|
||||
DEBUG_ARGS((dfd, " tp = %lx cnt=%i\n", (long)tp, cnt));
|
||||
DEBUG_ARGS(" tp = %lx cnt=%i\n", (long)tp, cnt);
|
||||
|
||||
for (; cnt > 0; cnt -= optlen, cp += optlen) {
|
||||
opt = cp[0];
|
||||
|
@ -1490,7 +1490,7 @@ tcp_mss(struct tcpcb *tp, u_int offer)
|
|||
(mss - (TCP_RCVSPACE % mss)) :
|
||||
0));
|
||||
|
||||
DEBUG_MISC((dfd, " returning mss = %d\n", mss));
|
||||
DEBUG_MISC(" returning mss = %d\n", mss);
|
||||
|
||||
return mss;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ again:
|
|||
|
||||
flags = tcp_outflags[tp->t_state];
|
||||
|
||||
DEBUG_MISC((dfd, " --- tcp_output flags = 0x%x\n",flags));
|
||||
DEBUG_MISC(" --- tcp_output flags = 0x%x\n",flags);
|
||||
|
||||
/*
|
||||
* If in persist timeout with window of 0, send 1 byte.
|
||||
|
|
|
@ -355,9 +355,9 @@ int tcp_fconnect(struct socket *so)
|
|||
addr.sin_addr = so->so_faddr;
|
||||
addr.sin_port = so->so_fport;
|
||||
|
||||
DEBUG_MISC((dfd, " connect()ing, addr.sin_port=%d, "
|
||||
DEBUG_MISC(" connect()ing, addr.sin_port=%d, "
|
||||
"addr.sin_addr.s_addr=%.16s\n",
|
||||
ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));
|
||||
ntohs(addr.sin_port), inet_ntoa(addr.sin_addr));
|
||||
/* We don't care what port we get */
|
||||
ret = connect(s,(struct sockaddr *)&addr,sizeof (addr));
|
||||
|
||||
|
@ -913,7 +913,7 @@ int tcp_ctl(struct socket *so)
|
|||
return 1;
|
||||
}
|
||||
do_pty = ex_ptr->ex_pty;
|
||||
DEBUG_MISC((dfd, " executing %s\n", ex_ptr->ex_exec));
|
||||
DEBUG_MISC(" executing %s\n", ex_ptr->ex_exec);
|
||||
return fork_exec(so, ex_ptr->ex_exec, do_pty);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,8 +181,8 @@ udp_input(register struct mbuf *m, int iphlen)
|
|||
goto bad;
|
||||
}
|
||||
if(udp_attach(so) == -1) {
|
||||
DEBUG_MISC((dfd," udp_attach errno = %d-%s\n",
|
||||
errno,strerror(errno)));
|
||||
DEBUG_MISC(" udp_attach errno = %d-%s\n",
|
||||
errno,strerror(errno));
|
||||
sofree(so);
|
||||
goto bad;
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ udp_input(register struct mbuf *m, int iphlen)
|
|||
m->m_len += iphlen;
|
||||
m->m_data -= iphlen;
|
||||
*ip=save_ip;
|
||||
DEBUG_MISC((dfd,"udp tx errno = %d-%s\n",errno,strerror(errno)));
|
||||
DEBUG_MISC("udp tx errno = %d-%s\n",errno,strerror(errno));
|
||||
icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue