diff options
-rw-r--r-- | bootp.c | 12 | ||||
-rw-r--r-- | if.c | 4 | ||||
-rw-r--r-- | ip_icmp.c | 4 | ||||
-rw-r--r-- | ip_input.c | 10 | ||||
-rw-r--r-- | ip_output.c | 4 | ||||
-rw-r--r-- | mbuf.c | 6 | ||||
-rw-r--r-- | misc.c | 6 | ||||
-rw-r--r-- | sbuf.c | 4 | ||||
-rw-r--r-- | socket.c | 18 | ||||
-rw-r--r-- | tcp_input.c | 12 | ||||
-rw-r--r-- | tcp_output.c | 2 | ||||
-rw-r--r-- | tcp_subr.c | 16 | ||||
-rw-r--r-- | udp.c | 6 |
13 files changed, 54 insertions, 50 deletions
@@ -23,6 +23,12 @@ */ #include <slirp.h> +#if defined(_WIN32) +/* Windows ntohl() returns an u_long value. + * Add a type cast to match the format strings. */ +#define ntohl(n) ((uint32_t)ntohl(n)) +#endif + /* XXX: only DHCP is supported */ #define LEASE_TIME (24 * 3600) @@ -161,7 +167,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp) dhcp_decode(bp, &dhcp_msg_type, &preq_addr); DPRINTF("bootp packet op=%d msgtype=%d", bp->bp_op, dhcp_msg_type); if (preq_addr.s_addr != htonl(0L)) - DPRINTF(" req_addr=%08x\n", ntohl(preq_addr.s_addr)); + DPRINTF(" req_addr=%08" PRIx32 "\n", ntohl(preq_addr.s_addr)); else DPRINTF("\n"); @@ -239,7 +245,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp) q += 4; if (bc) { - DPRINTF("%s addr=%08x\n", + DPRINTF("%s addr=%08" PRIx32 "\n", (dhcp_msg_type == DHCPDISCOVER) ? "offered" : "ack'ed", ntohl(daddr.sin_addr.s_addr)); @@ -307,7 +313,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp) } else { static const char nak_msg[] = "requested address not available"; - DPRINTF("nak'ed addr=%08x\n", ntohl(preq_addr.s_addr)); + DPRINTF("nak'ed addr=%08" PRIx32 "\n", ntohl(preq_addr.s_addr)); *q++ = RFC2132_MSG_TYPE; *q++ = 1; @@ -49,8 +49,8 @@ void if_output(struct socket *so, struct mbuf *ifm) int on_fastq = 1; DEBUG_CALL("if_output"); - DEBUG_ARG("so = %lx", (long)so); - DEBUG_ARG("ifm = %lx", (long)ifm); + DEBUG_ARG("so = %p", so); + DEBUG_ARG("ifm = %p", ifm); /* * First remove the mbuf from m_usedlist, @@ -126,7 +126,7 @@ void icmp_input(struct mbuf *m, int hlen) Slirp *slirp = m->slirp; DEBUG_CALL("icmp_input"); - DEBUG_ARG("m = %lx", (long)m); + DEBUG_ARG("m = %p", m); DEBUG_ARG("m_len = %d", m->m_len); /* @@ -253,7 +253,7 @@ void icmp_error(struct mbuf *msrc, u_char type, u_char code, int minsize, register struct mbuf *m; DEBUG_CALL("icmp_error"); - DEBUG_ARG("msrc = %lx", (long)msrc); + DEBUG_ARG("msrc = %p", msrc); DEBUG_ARG("msrc_len = %d", msrc->m_len); if (type != ICMP_UNREACH && type != ICMP_TIMXCEED) @@ -77,7 +77,7 @@ void ip_input(struct mbuf *m) int hlen; DEBUG_CALL("ip_input"); - DEBUG_ARG("m = %lx", (long)m); + DEBUG_ARG("m = %p", m); DEBUG_ARG("m_len = %d", m->m_len); if (m->m_len < sizeof(struct ip)) { @@ -227,9 +227,9 @@ static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp) int i, next; DEBUG_CALL("ip_reass"); - DEBUG_ARG("ip = %lx", (long)ip); - DEBUG_ARG("fp = %lx", (long)fp); - DEBUG_ARG("m = %lx", (long)m); + DEBUG_ARG("ip = %p", ip); + DEBUG_ARG("fp = %p", fp); + DEBUG_ARG("m = %p", m); /* * Presence of header sizes in mbufs @@ -394,7 +394,7 @@ static void ip_freef(Slirp *slirp, struct ipq *fp) static void ip_enq(register struct ipasfrag *p, register struct ipasfrag *prev) { DEBUG_CALL("ip_enq"); - DEBUG_ARG("prev = %lx", (long)prev); + DEBUG_ARG("prev = %p", prev); p->ipf_prev = prev; p->ipf_next = prev->ipf_next; ((struct ipasfrag *)(prev->ipf_next))->ipf_prev = p; diff --git a/ip_output.c b/ip_output.c index 10348b6..346e142 100644 --- a/ip_output.c +++ b/ip_output.c @@ -59,8 +59,8 @@ int ip_output(struct socket *so, struct mbuf *m0) int len, off, error = 0; DEBUG_CALL("ip_output"); - DEBUG_ARG("so = %lx", (long)so); - DEBUG_ARG("m0 = %lx", (long)m0); + DEBUG_ARG("so = %p", so); + DEBUG_ARG("m0 = %p", m0); ip = mtod(m, struct ip *); /* @@ -93,14 +93,14 @@ struct mbuf *m_get(Slirp *slirp) m->arp_requested = false; m->expiration_date = (uint64_t)-1; end_error: - DEBUG_ARG("m = %lx", (long)m); + DEBUG_ARG("m = %p", m); return m; } void m_free(struct mbuf *m) { DEBUG_CALL("m_free"); - DEBUG_ARG("m = %lx", (long)m); + DEBUG_ARG("m = %p", m); if (m) { /* Remove from m_usedlist */ @@ -212,7 +212,7 @@ struct mbuf *dtom(Slirp *slirp, void *dat) struct mbuf *m; DEBUG_CALL("dtom"); - DEBUG_ARG("dat = %lx", (long)dat); + DEBUG_ARG("dat = %p", dat); /* bug corrected for M_EXT buffers */ for (m = slirp->m_usedlist.m_next; m != &slirp->m_usedlist; m = m->m_next) { @@ -116,9 +116,9 @@ int fork_exec(struct socket *so, const char *ex, int do_pty) pid_t pid; DEBUG_CALL("fork_exec"); - DEBUG_ARG("so = %lx", (long)so); - DEBUG_ARG("ex = %lx", (long)ex); - DEBUG_ARG("do_pty = %lx", (long)do_pty); + DEBUG_ARG("so = %p", so); + DEBUG_ARG("ex = %p", ex); + DEBUG_ARG("do_pty = %x", do_pty); if (do_pty == 2) { return 0; @@ -69,8 +69,8 @@ void sbappend(struct socket *so, struct mbuf *m) int ret = 0; DEBUG_CALL("sbappend"); - DEBUG_ARG("so = %lx", (long)so); - DEBUG_ARG("m = %lx", (long)m); + DEBUG_ARG("so = %p", so); + DEBUG_ARG("m = %p", m); DEBUG_ARG("m->m_len = %d", m->m_len); /* Shouldn't happen, but... e.g. foreign host closes connection */ @@ -85,7 +85,7 @@ size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np) int mss = so->so_tcpcb->t_maxseg; DEBUG_CALL("sopreprbuf"); - DEBUG_ARG("so = %lx", (long)so); + DEBUG_ARG("so = %p", so); if (len <= 0) return 0; @@ -149,7 +149,7 @@ int soread(struct socket *so) struct iovec iov[2]; DEBUG_CALL("soread"); - DEBUG_ARG("so = %lx", (long)so); + DEBUG_ARG("so = %p", so); /* * No need to check if there's enough room to read. @@ -211,7 +211,7 @@ int soreadbuf(struct socket *so, const char *buf, int size) struct iovec iov[2]; DEBUG_CALL("soreadbuf"); - DEBUG_ARG("so = %lx", (long)so); + DEBUG_ARG("so = %p", so); /* * No need to check if there's enough room to read. @@ -258,7 +258,7 @@ void sorecvoob(struct socket *so) struct tcpcb *tp = sototcpcb(so); DEBUG_CALL("sorecvoob"); - DEBUG_ARG("so = %lx", (long)so); + DEBUG_ARG("so = %p", so); /* * We take a guess at how much urgent data has arrived. @@ -287,7 +287,7 @@ int sosendoob(struct socket *so) int n, len; DEBUG_CALL("sosendoob"); - DEBUG_ARG("so = %lx", (long)so); + DEBUG_ARG("so = %p", so); DEBUG_ARG("sb->sb_cc = %d", sb->sb_cc); if (so->so_urgc > 2048) @@ -351,7 +351,7 @@ int sowrite(struct socket *so) struct iovec iov[2]; DEBUG_CALL("sowrite"); - DEBUG_ARG("so = %lx", (long)so); + DEBUG_ARG("so = %p", so); if (so->so_urgc) { sosendoob(so); @@ -444,7 +444,7 @@ void sorecvfrom(struct socket *so) socklen_t addrlen = sizeof(struct sockaddr_in); DEBUG_CALL("sorecvfrom"); - DEBUG_ARG("so = %lx", (long)so); + DEBUG_ARG("so = %p", so); if (so->so_type == IPPROTO_ICMP) { /* This is a "ping" reply */ char buff[256]; @@ -548,8 +548,8 @@ int sosendto(struct socket *so, struct mbuf *m) struct sockaddr_in addr; DEBUG_CALL("sosendto"); - DEBUG_ARG("so = %lx", (long)so); - DEBUG_ARG("m = %lx", (long)m); + DEBUG_ARG("so = %p", so); + DEBUG_ARG("m = %p", m); addr.sin_family = AF_INET; if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) == diff --git a/tcp_input.c b/tcp_input.c index af46e36..a21b17a 100644 --- a/tcp_input.c +++ b/tcp_input.c @@ -232,8 +232,7 @@ void 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((dfd, " m = %p iphlen = %2d inso = %p\n", m, iphlen, inso)); /* * If called with m == 0, then we're continuing the connect @@ -920,8 +919,7 @@ findso: 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((dfd, " dup ack m = %p so = %p\n", m, so)); /* * If we have outstanding data (other than * a window probe), this is a completely @@ -1295,7 +1293,7 @@ static void tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, int opt, optlen; DEBUG_CALL("tcp_dooptions"); - DEBUG_ARGS((dfd, " tp = %lx cnt=%i\n", (long)tp, cnt)); + DEBUG_ARGS((dfd, " tp = %p cnt=%i\n", tp, cnt)); for (; cnt > 0; cnt -= optlen, cp += optlen) { opt = cp[0]; @@ -1372,7 +1370,7 @@ static void tcp_xmit_timer(register struct tcpcb *tp, int rtt) register short delta; DEBUG_CALL("tcp_xmit_timer"); - DEBUG_ARG("tp = %lx", (long)tp); + DEBUG_ARG("tp = %p", tp); DEBUG_ARG("rtt = %d", rtt); if (tp->t_srtt != 0) { @@ -1459,7 +1457,7 @@ int tcp_mss(struct tcpcb *tp, u_int offer) int mss; DEBUG_CALL("tcp_mss"); - DEBUG_ARG("tp = %lx", (long)tp); + DEBUG_ARG("tp = %p", tp); DEBUG_ARG("offer = %d", offer); mss = min(IF_MTU, IF_MRU) - sizeof(struct tcpiphdr); diff --git a/tcp_output.c b/tcp_output.c index 1fe77da..35c00e3 100644 --- a/tcp_output.c +++ b/tcp_output.c @@ -65,7 +65,7 @@ int tcp_output(struct tcpcb *tp) int idle, sendalot; DEBUG_CALL("tcp_output"); - DEBUG_ARG("tp = %lx", (long)tp); + DEBUG_ARG("tp = %p", tp); /* * Determine length of data that should be transmitted, @@ -226,7 +226,7 @@ struct tcpcb *tcp_newtcpcb(struct socket *so) struct tcpcb *tcp_drop(struct tcpcb *tp, int err) { DEBUG_CALL("tcp_drop"); - DEBUG_ARG("tp = %lx", (long)tp); + DEBUG_ARG("tp = %p", tp); DEBUG_ARG("errno = %d", errno); if (TCPS_HAVERCVDSYN(tp->t_state)) { @@ -250,7 +250,7 @@ struct tcpcb *tcp_close(struct tcpcb *tp) register struct mbuf *m; DEBUG_CALL("tcp_close"); - DEBUG_ARG("tp = %lx", (long)tp); + DEBUG_ARG("tp = %p", tp); /* free the reassembly queue, if any */ t = tcpfrag_list_first(tp); @@ -289,7 +289,7 @@ struct tcpcb *tcp_close(struct tcpcb *tp) void tcp_sockclosed(struct tcpcb *tp) { DEBUG_CALL("tcp_sockclosed"); - DEBUG_ARG("tp = %lx", (long)tp); + DEBUG_ARG("tp = %p", tp); switch (tp->t_state) { case TCPS_CLOSED: @@ -328,7 +328,7 @@ int tcp_fconnect(struct socket *so) int ret = 0; DEBUG_CALL("tcp_fconnect"); - DEBUG_ARG("so = %lx", (long)so); + DEBUG_ARG("so = %p", so); if ((ret = so->s = qemu_socket(AF_INET, SOCK_STREAM, 0)) >= 0) { int opt, s = so->s; @@ -392,7 +392,7 @@ void tcp_connect(struct socket *inso) int s, opt; DEBUG_CALL("tcp_connect"); - DEBUG_ARG("inso = %lx", (long)inso); + DEBUG_ARG("inso = %p", inso); /* * If it's an SS_ACCEPTONCE socket, no need to socreate() @@ -560,8 +560,8 @@ int tcp_emu(struct socket *so, struct mbuf *m) char *bptr; DEBUG_CALL("tcp_emu"); - DEBUG_ARG("so = %lx", (long)so); - DEBUG_ARG("m = %lx", (long)m); + DEBUG_ARG("so = %p", so); + DEBUG_ARG("m = %p", m); switch (so->so_emu) { int x, i; @@ -892,7 +892,7 @@ int tcp_ctl(struct socket *so) int do_pty; DEBUG_CALL("tcp_ctl"); - DEBUG_ARG("so = %lx", (long)so); + DEBUG_ARG("so = %p", so); if (so->so_faddr.s_addr != slirp->vhost_addr.s_addr) { /* Check if it's pty_exec */ @@ -70,7 +70,7 @@ void udp_input(register struct mbuf *m, int iphlen) struct socket *so; DEBUG_CALL("udp_input"); - DEBUG_ARG("m = %lx", (long)m); + DEBUG_ARG("m = %p", m); DEBUG_ARG("iphlen = %d", iphlen); /* @@ -237,8 +237,8 @@ int udp_output2(struct socket *so, struct mbuf *m, struct sockaddr_in *saddr, int error = 0; DEBUG_CALL("udp_output"); - DEBUG_ARG("so = %lx", (long)so); - DEBUG_ARG("m = %lx", (long)m); + DEBUG_ARG("so = %p", so); + DEBUG_ARG("m = %p", m); DEBUG_ARG("saddr = %lx", (long)saddr->sin_addr.s_addr); DEBUG_ARG("daddr = %lx", (long)daddr->sin_addr.s_addr); |