From f1259413fb06527c44146ccdd3438e6a4a4dee74 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Sun, 21 Apr 2024 11:27:51 +0200 Subject: [PATCH] Continued work on builtin slirp networking support. - Modified info / error log message handling. - Renamed insque / remque functions using "slirp_" prefix. - Removed useless SVN ID from most file headers and add license specifier instead. --- bochs/iodev/network/eth_slirp.cc | 60 ++++++++++++------------- bochs/iodev/network/slirp/arp_table.cc | 4 +- bochs/iodev/network/slirp/bootp.cc | 18 ++++---- bochs/iodev/network/slirp/bootp.h | 5 +-- bochs/iodev/network/slirp/cksum.cc | 4 +- bochs/iodev/network/slirp/debug.h | 11 +++-- bochs/iodev/network/slirp/dnssearch.cc | 6 +-- bochs/iodev/network/slirp/if.cc | 16 +++---- bochs/iodev/network/slirp/if.h | 11 ++--- bochs/iodev/network/slirp/ip.h | 8 ++-- bochs/iodev/network/slirp/ip_icmp.cc | 6 +-- bochs/iodev/network/slirp/ip_icmp.h | 4 +- bochs/iodev/network/slirp/ip_input.cc | 14 +++--- bochs/iodev/network/slirp/ip_output.cc | 4 +- bochs/iodev/network/slirp/libslirp.h | 18 +++++--- bochs/iodev/network/slirp/main.h | 9 +--- bochs/iodev/network/slirp/mbuf.cc | 15 +++---- bochs/iodev/network/slirp/mbuf.h | 8 ++-- bochs/iodev/network/slirp/misc.cc | 13 ++---- bochs/iodev/network/slirp/misc.h | 11 ++--- bochs/iodev/network/slirp/sbuf.cc | 7 +-- bochs/iodev/network/slirp/sbuf.h | 11 ++--- bochs/iodev/network/slirp/slirp.cc | 24 +++------- bochs/iodev/network/slirp/slirp.h | 8 ---- bochs/iodev/network/slirp/socket.cc | 15 +++---- bochs/iodev/network/slirp/socket.h | 13 ++---- bochs/iodev/network/slirp/tcp.h | 8 ++-- bochs/iodev/network/slirp/tcp_input.cc | 10 ++--- bochs/iodev/network/slirp/tcp_output.cc | 4 +- bochs/iodev/network/slirp/tcp_subr.cc | 8 ++-- bochs/iodev/network/slirp/tcp_timer.cc | 4 +- bochs/iodev/network/slirp/tcp_timer.h | 8 ++-- bochs/iodev/network/slirp/tcp_var.h | 8 ++-- bochs/iodev/network/slirp/tcpip.h | 8 ++-- bochs/iodev/network/slirp/tftp.cc | 8 ++-- bochs/iodev/network/slirp/tftp.h | 12 +++-- bochs/iodev/network/slirp/udp.cc | 8 ++-- bochs/iodev/network/slirp/udp.h | 8 ++-- 38 files changed, 154 insertions(+), 263 deletions(-) diff --git a/bochs/iodev/network/eth_slirp.cc b/bochs/iodev/network/eth_slirp.cc index c7de86037..72210c980 100644 --- a/bochs/iodev/network/eth_slirp.cc +++ b/bochs/iodev/network/eth_slirp.cc @@ -36,11 +36,10 @@ #if BX_HAVE_LIBSLIRP #include -#include #else -#include "slirp/slirp.h" #include "slirp/libslirp.h" #endif +#include static unsigned int bx_slirp_instances = 0; @@ -72,9 +71,7 @@ public: virtual ~bx_slirp_pktmover_c(); void sendpkt(void *buf, unsigned io_len); slirp_ssize_t receive(void *pkt, unsigned pkt_len); -#if BX_HAVE_LIBSLIRP - void slirp_msg(const char *msg); -#endif + void slirp_msg(bool error, const char *msg); private: Slirp *slirp; unsigned netdev_speed; @@ -86,9 +83,11 @@ private: char *smb_export, *smb_tmpdir; struct in_addr smb_srv; #endif + bool slirp_logging; char *pktlog_fn; FILE *pktlog_txt; - bool slirp_logging; + + logfunctions *slirplog; bool parse_slirp_conf(const char *conf); static void rx_timer_handler(void *); @@ -121,15 +120,13 @@ static ssize_t send_packet(const void *buf, size_t len, void *opaque) return class_ptr->receive((void*)buf, len); } -#if BX_HAVE_LIBSLIRP static void guest_error(const char *msg, void *opaque) { char errmsg[512]; sprintf(errmsg, "guest error: %s", msg); - ((bx_slirp_pktmover_c*)opaque)->slirp_msg(errmsg); + ((bx_slirp_pktmover_c*)opaque)->slirp_msg(true, errmsg); } -#endif static int64_t clock_get_ns(void *opaque) { @@ -148,7 +145,7 @@ static struct timer *timer_queue; static void *timer_new_opaque(SlirpTimerId id, void *cb_opaque, void *opaque) { - ((bx_slirp_pktmover_c*)opaque)->slirp_msg("timer_new_opaque()"); + ((bx_slirp_pktmover_c*)opaque)->slirp_msg(false, "timer_new_opaque()"); struct timer *new_timer = new timer; new_timer->id = id; new_timer->cb_opaque = cb_opaque; @@ -158,7 +155,7 @@ static void *timer_new_opaque(SlirpTimerId id, void *cb_opaque, void *opaque) static void timer_free(void *_timer, void *opaque) { - ((bx_slirp_pktmover_c*)opaque)->slirp_msg("timer_free()"); + ((bx_slirp_pktmover_c*)opaque)->slirp_msg(false, "timer_free()"); struct timer *timer1 = (timer*)_timer; struct timer **t; @@ -175,7 +172,7 @@ static void timer_free(void *_timer, void *opaque) static void timer_mod(void *_timer, int64_t expire_time, void *opaque) { - ((bx_slirp_pktmover_c*)opaque)->slirp_msg("timer_mod()"); + ((bx_slirp_pktmover_c*)opaque)->slirp_msg(false, "timer_mod()"); struct timer *timer1 = (timer*)_timer; struct timer **t; @@ -210,9 +207,7 @@ static void notify(void *opaque) static struct SlirpCb callbacks = { .send_packet = send_packet, -#if BX_HAVE_LIBSLIRP .guest_error = guest_error, -#endif .clock_get_ns = clock_get_ns, #if BX_HAVE_LIBSLIRP .timer_free = timer_free, @@ -231,10 +226,7 @@ bx_slirp_pktmover_c::bx_slirp_pktmover_c(const char *netif, logfunctions *netdev, const char *script) { -#if !BX_HAVE_LIBSLIRP - logfunctions *slirplog; char prefix[10]; -#endif slirp = NULL; pktlog_fn = NULL; @@ -266,9 +258,6 @@ bx_slirp_pktmover_c::bx_slirp_pktmover_c(const char *netif, #if BX_HAVE_LIBSLIRP BX_INFO(("slirp network driver (libslirp version %s)", slirp_version_string())); #else - if (sizeof(struct arphdr) != 28) { - BX_FATAL(("system error: invalid ARP header structure size")); - } BX_INFO(("slirp network driver")); #endif @@ -302,14 +291,10 @@ bx_slirp_pktmover_c::bx_slirp_pktmover_c(const char *netif, } #endif } -#if BX_HAVE_LIBSLIRP - slirp = slirp_new(&config, &callbacks, this); -#else slirplog = new logfunctions(); sprintf(prefix, "SLIRP%d", bx_slirp_instances); slirplog->put(prefix); - slirp = slirp_new(&config, &callbacks, this, slirplog); -#endif + slirp = slirp_new(&config, &callbacks, this); if (n_hostfwd > 0) { for (int i = 0; i < n_hostfwd; i++) { slirp_hostfwd(slirp, hostfwd[i], 0); @@ -639,13 +624,6 @@ slirp_ssize_t bx_slirp_pktmover_c::receive(void *pkt, unsigned pkt_len) } } -#if BX_HAVE_LIBSLIRP -void bx_slirp_pktmover_c::slirp_msg(const char *msg) -{ - BX_INFO(("%s", msg)); -} -#endif - #if !defined(_WIN32) && !defined(__CYGWIN__) #define CONFIG_SMBD_COMMAND "/usr/sbin/smbd" @@ -856,4 +834,22 @@ int bx_slirp_pktmover_c::slirp_hostfwd(Slirp *s, const char *redir_str, int lega return -1; } +#undef LOG_THIS +#define LOG_THIS slirplog-> + +void bx_slirp_pktmover_c::slirp_msg(bool error, const char *msg) +{ + if (error) + BX_ERROR(("%s", msg)); + else + BX_INFO(("%s", msg)); +} + +#if !BX_HAVE_LIBSLIRP +void slirp_warning(const char *msg, void *opaque) +{ + ((bx_slirp_pktmover_c*)opaque)->slirp_msg(true, msg); +} +#endif + #endif /* if BX_NETWORKING && BX_NETMOD_SLIRP */ diff --git a/bochs/iodev/network/slirp/arp_table.cc b/bochs/iodev/network/slirp/arp_table.cc index ae52b7ffd..7fe8d38f4 100644 --- a/bochs/iodev/network/slirp/arp_table.cc +++ b/bochs/iodev/network/slirp/arp_table.cc @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: MIT */ /* * ARP table * diff --git a/bochs/iodev/network/slirp/bootp.cc b/bochs/iodev/network/slirp/bootp.cc index cc0d203b5..cc8dbc31e 100644 --- a/bochs/iodev/network/slirp/bootp.cc +++ b/bochs/iodev/network/slirp/bootp.cc @@ -1,8 +1,6 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: MIT */ /* - * BOOTP/DHCP server (ported from Qemu) + * QEMU BOOTP/DHCP server * Bochs additions: parameter list and some other options * * Copyright (c) 2004 Fabrice Bellard @@ -177,13 +175,13 @@ static void dhcp_decode(Slirp *slirp, const struct bootp_t *bp, dhcp_options_t * defsize = sizeof(struct bootp_t) - sizeof(struct ip) - sizeof(struct udphdr); if (ntohs(maxsize) < defsize) { sprintf(msg, "DHCP server: RFB2132_MAX_SIZE=%u not supported yet", ntohs(maxsize)); - slirp_warning(slirp, msg); + slirp_warning(msg, slirp->opaque); } } break; default: sprintf(msg, "DHCP server: option %d not supported yet", tag); - slirp_warning(slirp, msg); + slirp_warning(msg, slirp->opaque); break; } p += len; @@ -383,7 +381,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp) spaceleft = sizeof(rbp->bp_vend) - (q - rbp->bp_vend); val = strlen(slirp->vdomainname); if (val + 1 > (int)spaceleft) { - slirp_warning(slirp, "DHCP packet size exceeded, omitting domain name option."); + slirp_warning("DHCP packet size exceeded, omitting domain name option.", slirp->opaque); } else { *q++ = RFC1533_DOMAINNAME; *q++ = val; @@ -418,7 +416,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp) spaceleft = sizeof(rbp->bp_vend) - (q - rbp->bp_vend); val = strlen(slirp->tftp_server_name); if (val + 1 > (int)spaceleft) { - slirp_warning(slirp, "DHCP packet size exceeded, omitting tftp-server-name option."); + slirp_warning("DHCP packet size exceeded, omitting tftp-server-name option.", slirp->opaque); } else { *q++ = RFC2132_TFTP_SERVER_NAME; *q++ = val; @@ -434,7 +432,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp) default: sprintf(msg, "DHCP server: requested parameter %u not supported yet", *(pp-1)); - slirp_warning(slirp, msg); + slirp_warning(msg, slirp->opaque); } } @@ -442,7 +440,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp) spaceleft = sizeof(rbp->bp_vend) - (q - rbp->bp_vend); val = slirp->vdnssearch_len; if (val + 1 > (int)spaceleft) { - slirp_warning(slirp, "DHCP packet size exceeded, omitting domain-search option."); + slirp_warning("DHCP packet size exceeded, omitting domain-search option.", slirp->opaque); } else { memcpy(q, slirp->vdnssearch, val); q += val; diff --git a/bochs/iodev/network/slirp/bootp.h b/bochs/iodev/network/slirp/bootp.h index b69aa1be7..0f0af61ab 100644 --- a/bochs/iodev/network/slirp/bootp.h +++ b/bochs/iodev/network/slirp/bootp.h @@ -1,7 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// - +/* SPDX-License-Identifier: BSD-3-Clause */ /* bootp/dhcp defines */ #ifndef SLIRP_BOOTP_H #define SLIRP_BOOTP_H 1 diff --git a/bochs/iodev/network/slirp/cksum.cc b/bochs/iodev/network/slirp/cksum.cc index 8ba8c5a08..b8087d705 100644 --- a/bochs/iodev/network/slirp/cksum.cc +++ b/bochs/iodev/network/slirp/cksum.cc @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1988, 1992, 1993 * The Regents of the University of California. All rights reserved. diff --git a/bochs/iodev/network/slirp/debug.h b/bochs/iodev/network/slirp/debug.h index 9050bd2f8..6d4c9aa43 100644 --- a/bochs/iodev/network/slirp/debug.h +++ b/bochs/iodev/network/slirp/debug.h @@ -1,13 +1,10 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1995 Danny Gasparovski. - * - * Please read the file COPYRIGHT for the - * terms and conditions of the copyright. */ +#ifndef DEBUG_H_ +#define DEBUG_H_ //#define DEBUG 1 #ifdef DEBUG @@ -35,3 +32,5 @@ extern int slirp_debug; #define DEBUG_ERROR(x) #endif + +#endif diff --git a/bochs/iodev/network/slirp/dnssearch.cc b/bochs/iodev/network/slirp/dnssearch.cc index d8f418d2f..8cb323290 100644 --- a/bochs/iodev/network/slirp/dnssearch.cc +++ b/bochs/iodev/network/slirp/dnssearch.cc @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: MIT */ /* * Domain search option for DHCP (RFC 3397) * @@ -159,7 +157,7 @@ static void domain_mklabels(Slirp *s, CompactDomain *cd, const char *input) fail: sprintf(msg, "failed to parse domain name '%s'\n", input); - slirp_warning(s, msg); + slirp_warning(msg, s->opaque); cd->len = 0; } diff --git a/bochs/iodev/network/slirp/if.cc b/bochs/iodev/network/slirp/if.cc index 49742d5d7..73e9f8f0c 100644 --- a/bochs/iodev/network/slirp/if.cc +++ b/bochs/iodev/network/slirp/if.cc @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1995 Danny Gasparovski. * @@ -68,7 +66,7 @@ if_output(struct socket *so, struct mbuf *ifm) * XXX Shouldn't need this, gotta change dtom() etc. */ if (ifm->m_flags & M_USEDLIST) { - remque(ifm); + slirp_remque(ifm); ifm->m_flags &= ~M_USEDLIST; } @@ -113,7 +111,7 @@ if_output(struct socket *so, struct mbuf *ifm) /* Create a new doubly linked list for this session */ ifm->ifq_so = so; ifs_init(ifm); - insque(ifm, ifq); + slirp_insque(ifm, ifq); diddit: if (so) { @@ -131,10 +129,10 @@ diddit: (so->so_nqueued - so->so_queued) >= 3)) { /* Remove from current queue... */ - remque(ifm->ifs_next); + slirp_remque(ifm->ifs_next); /* ...And insert in the new. That'll teach ya! */ - insque(ifm->ifs_next, &slirp->if_batchq); + slirp_insque(ifm->ifs_next, &slirp->if_batchq); } } @@ -214,13 +212,13 @@ void if_start(Slirp *slirp) /* Remove it from the queue */ ifqt = ifm->ifq_prev; - remque(ifm); + slirp_remque(ifm); /* If there are more packets for this session, re-queue them */ if (ifm->ifs_next != ifm) { struct mbuf *next = ifm->ifs_next; - insque(next, ifqt); + slirp_insque(next, ifqt); ifs_remque(ifm); if (!from_batchq) { diff --git a/bochs/iodev/network/slirp/if.h b/bochs/iodev/network/slirp/if.h index 419afc10c..88dcf5491 100644 --- a/bochs/iodev/network/slirp/if.h +++ b/bochs/iodev/network/slirp/if.h @@ -1,15 +1,10 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1995 Danny Gasparovski. - * - * Please read the file COPYRIGHT for the - * terms and conditions of the copyright. */ -#ifndef _IF_H_ -#define _IF_H_ +#ifndef IF_H +#define IF_H #define IF_COMPRESS 0x01 /* We want compression */ #define IF_NOCOMPRESS 0x02 /* Do not do compression */ diff --git a/bochs/iodev/network/slirp/ip.h b/bochs/iodev/network/slirp/ip.h index eba661dd4..1a272609c 100644 --- a/bochs/iodev/network/slirp/ip.h +++ b/bochs/iodev/network/slirp/ip.h @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -33,8 +31,8 @@ * ip.h,v 1.3 1994/08/21 05:27:30 paul Exp */ -#ifndef _IP_H_ -#define _IP_H_ +#ifndef IP_H +#define IP_H #ifndef BX_LITTLE_ENDIAN # undef NTOHL diff --git a/bochs/iodev/network/slirp/ip_icmp.cc b/bochs/iodev/network/slirp/ip_icmp.cc index 4987ce3ea..f529eff8d 100644 --- a/bochs/iodev/network/slirp/ip_icmp.cc +++ b/bochs/iodev/network/slirp/ip_icmp.cc @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -99,7 +97,7 @@ static int icmp_send(struct socket *so, struct mbuf *m, int hlen) addr.sin_family = AF_INET; addr.sin_addr = so->so_faddr; - insque(so, &so->slirp->icmp); + slirp_insque(so, &so->slirp->icmp); if (sendto(so->s, m->m_data + hlen, m->m_len - hlen, 0, (struct sockaddr *)&addr, sizeof(addr)) == -1) { diff --git a/bochs/iodev/network/slirp/ip_icmp.h b/bochs/iodev/network/slirp/ip_icmp.h index fc9002bf0..f7ce50bcf 100644 --- a/bochs/iodev/network/slirp/ip_icmp.h +++ b/bochs/iodev/network/slirp/ip_icmp.h @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. diff --git a/bochs/iodev/network/slirp/ip_input.cc b/bochs/iodev/network/slirp/ip_input.cc index 6a4260a1b..d127ea4af 100644 --- a/bochs/iodev/network/slirp/ip_input.cc +++ b/bochs/iodev/network/slirp/ip_input.cc @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -262,7 +260,7 @@ ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp) goto dropfrag; } fp = mtod(t, struct ipq *); - insque(&fp->ip_link, &slirp->ipq.ip_link); + slirp_insque(&fp->ip_link, &slirp->ipq.ip_link); fp->ipq_ttl = IPFRAGTTL; fp->ipq_p = ip->ip_p; fp->ipq_id = ip->ip_id; @@ -370,7 +368,7 @@ insert: ip->ip_tos &= ~1; ip->ip_src = fp->ipq_src; ip->ip_dst = fp->ipq_dst; - remque(&fp->ip_link); + slirp_remque(&fp->ip_link); (void) m_free(dtom(slirp, fp)); m->m_len += (ip->ip_hl << 2); m->m_data -= (ip->ip_hl << 2); @@ -396,13 +394,13 @@ ip_freef(Slirp *slirp, struct ipq *fp) ip_deq(q); m_free(dtom(slirp, q)); } - remque(&fp->ip_link); + slirp_remque(&fp->ip_link); (void) m_free(dtom(slirp, fp)); } /* * Put an ip fragment on a reassembly chain. - * Like insque, but pointers in middle of structure. + * Like slirp_insque, but pointers in middle of structure. */ static void ip_enq(struct ipasfrag *p, struct ipasfrag *prev) @@ -416,7 +414,7 @@ ip_enq(struct ipasfrag *p, struct ipasfrag *prev) } /* - * To ip_enq as remque is to insque. + * To ip_enq as slirp_remque is to slirp_insque. */ static void ip_deq(struct ipasfrag *p) diff --git a/bochs/iodev/network/slirp/ip_output.cc b/bochs/iodev/network/slirp/ip_output.cc index a4510d3cc..cb6cc3273 100644 --- a/bochs/iodev/network/slirp/ip_output.cc +++ b/bochs/iodev/network/slirp/ip_output.cc @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1988, 1990, 1993 * The Regents of the University of California. All rights reserved. diff --git a/bochs/iodev/network/slirp/libslirp.h b/bochs/iodev/network/slirp/libslirp.h index 7de253085..5c036bb99 100644 --- a/bochs/iodev/network/slirp/libslirp.h +++ b/bochs/iodev/network/slirp/libslirp.h @@ -2,13 +2,19 @@ #ifndef LIBSLIRP_H #define LIBSLIRP_H +#include #include "compat.h" +#ifdef _WIN32 +#include +#else +#include +#endif +typedef ssize_t slirp_ssize_t; + struct Slirp; typedef struct Slirp Slirp; -typedef ssize_t slirp_ssize_t; - /* Callback for application to send data to the guest */ typedef slirp_ssize_t (*SlirpWriteCb)(const void *buf, size_t len, void *opaque); @@ -27,6 +33,8 @@ typedef struct SlirpCb { * <0 reports an IO error. */ SlirpWriteCb send_packet; + /* Print a message for an error due to guest misbehavior. */ + void (*guest_error)(const char *msg, void *opaque); /* Return the virtual clock value in nanoseconds */ int64_t (*clock_get_ns)(void *opaque); } SlirpCb; @@ -45,9 +53,8 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork, const char *vhostname, const char *tftp_path, const char *bootfile, struct in_addr vdhcp_start, struct in_addr vnameserver, const char **vdnssearch, - const char *vdomainname, const SlirpCb *callbacks, void *opaque, - void *logfn); -Slirp *slirp_new(SlirpConfig *cfg, SlirpCb *callbacks, void *opaque, void *logfn); + const char *vdomainname, const SlirpCb *callbacks, void *opaque); +Slirp *slirp_new(SlirpConfig *cfg, SlirpCb *callbacks, void *opaque); void slirp_cleanup(Slirp *slirp); void slirp_select_fill(int *pnfds, fd_set *readfds, fd_set *writefds, @@ -59,6 +66,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len); /* you must provide the following functions: */ +void slirp_warning(const char *, void *); int slirp_add_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr, int host_port, struct in_addr guest_addr, int guest_port); diff --git a/bochs/iodev/network/slirp/main.h b/bochs/iodev/network/slirp/main.h index 91f92552f..228e71b39 100644 --- a/bochs/iodev/network/slirp/main.h +++ b/bochs/iodev/network/slirp/main.h @@ -1,14 +1,9 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1995 Danny Gasparovski. - * - * Please read the file COPYRIGHT for the - * terms and conditions of the copyright. */ #ifndef SLIRP_MAIN_H -#define SLIRP_MAIN_H 1 +#define SLIRP_MAIN_H #ifdef HAVE_SYS_SELECT_H #include diff --git a/bochs/iodev/network/slirp/mbuf.cc b/bochs/iodev/network/slirp/mbuf.cc index d5553d1b1..306e7238c 100644 --- a/bochs/iodev/network/slirp/mbuf.cc +++ b/bochs/iodev/network/slirp/mbuf.cc @@ -1,11 +1,6 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1995 Danny Gasparovski - * - * Please read the file COPYRIGHT for the - * terms and conditions of the copyright. */ /* @@ -83,11 +78,11 @@ m_get(Slirp *slirp) m->slirp = slirp; } else { m = slirp->m_freelist.m_next; - remque(m); + slirp_remque(m); } /* Insert it in the used list */ - insque(m,&slirp->m_usedlist); + slirp_insque(m,&slirp->m_usedlist); m->m_flags = (flags | M_USEDLIST); /* Initialise it */ @@ -113,7 +108,7 @@ m_free(struct mbuf *m) if(m) { /* Remove from m_usedlist */ if (m->m_flags & M_USEDLIST) - remque(m); + slirp_remque(m); /* If it's M_EXT, free() it */ if (m->m_flags & M_EXT) @@ -126,7 +121,7 @@ m_free(struct mbuf *m) m->slirp->mbuf_alloced--; free(m); } else if ((m->m_flags & M_FREELIST) == 0) { - insque(m,&m->slirp->m_freelist); + slirp_insque(m,&m->slirp->m_freelist); m->m_flags = M_FREELIST; /* Clobber other flags */ } } /* if(m) */ diff --git a/bochs/iodev/network/slirp/mbuf.h b/bochs/iodev/network/slirp/mbuf.h index 921cfaaa7..36112a2f1 100644 --- a/bochs/iodev/network/slirp/mbuf.h +++ b/bochs/iodev/network/slirp/mbuf.h @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -33,8 +31,8 @@ * mbuf.h,v 1.9 1994/11/14 13:54:20 bde Exp */ -#ifndef _MBUF_H_ -#define _MBUF_H_ +#ifndef MBUF_H +#define MBUF_H #define MINCSIZE 4096 /* Amount to increase mbuf if too small */ diff --git a/bochs/iodev/network/slirp/misc.cc b/bochs/iodev/network/slirp/misc.cc index cb8b90a6a..73ef0174c 100644 --- a/bochs/iodev/network/slirp/misc.cc +++ b/bochs/iodev/network/slirp/misc.cc @@ -1,11 +1,6 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1995 Danny Gasparovski. - * - * Please read the file COPYRIGHT for the - * terms and conditions of the copyright. */ #include "slirp.h" @@ -26,7 +21,7 @@ struct quehead { struct quehead *qh_rlink; }; -void insque(void *a, void *b) +void slirp_insque(void *a, void *b) { struct quehead *element = (struct quehead *) a; struct quehead *head = (struct quehead *) b; @@ -37,7 +32,7 @@ void insque(void *a, void *b) = (struct quehead *)element; } -void remque(void *a) +void slirp_remque(void *a) { struct quehead *element = (struct quehead *) a; ((struct quehead *)(element->qh_link))->qh_rlink = element->qh_rlink; @@ -224,7 +219,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty) exit(1); default: - slirp_warning(so->slirp, "qemu_add_child_watch(pid) not implemented"); + slirp_warning("qemu_add_child_watch(pid) not implemented", so->slirp->opaque); /* * XXX this could block us... * XXX Should set a timer here, and if accept() doesn't diff --git a/bochs/iodev/network/slirp/misc.h b/bochs/iodev/network/slirp/misc.h index cd9bd54d4..e9410c070 100644 --- a/bochs/iodev/network/slirp/misc.h +++ b/bochs/iodev/network/slirp/misc.h @@ -1,15 +1,10 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1995 Danny Gasparovski. - * - * Please read the file COPYRIGHT for the - * terms and conditions of the copyright. */ -#ifndef _MISC_H_ -#define _MISC_H_ +#ifndef MISC_H +#define MISC_H struct ex_list { int ex_pty; /* Do we want a pty? */ diff --git a/bochs/iodev/network/slirp/sbuf.cc b/bochs/iodev/network/slirp/sbuf.cc index fb2f53fe7..e9cec2d22 100644 --- a/bochs/iodev/network/slirp/sbuf.cc +++ b/bochs/iodev/network/slirp/sbuf.cc @@ -1,11 +1,6 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1995 Danny Gasparovski. - * - * Please read the file COPYRIGHT for the - * terms and conditions of the copyright. */ #include "slirp.h" diff --git a/bochs/iodev/network/slirp/sbuf.h b/bochs/iodev/network/slirp/sbuf.h index 479b5b360..ac9861713 100644 --- a/bochs/iodev/network/slirp/sbuf.h +++ b/bochs/iodev/network/slirp/sbuf.h @@ -1,15 +1,10 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1995 Danny Gasparovski. - * - * Please read the file COPYRIGHT for the - * terms and conditions of the copyright. */ -#ifndef _SBUF_H_ -#define _SBUF_H_ +#ifndef SBUF_H +#define SBUF_H #define sbflush(sb) sbdrop((sb),(sb)->sb_cc) #define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc) diff --git a/bochs/iodev/network/slirp/slirp.cc b/bochs/iodev/network/slirp/slirp.cc index 63996e826..a89948b27 100644 --- a/bochs/iodev/network/slirp/slirp.cc +++ b/bochs/iodev/network/slirp/slirp.cc @@ -25,12 +25,9 @@ #define BX_PLUGGABLE #include "slirp.h" -#include "iodev.h" #if BX_NETWORKING && BX_NETMOD_SLIRP -#define LOG_THIS ((logfunctions*)slirp->logfn)-> - /* host loopback address */ struct in_addr loopback_addr; /* host loopback network mask */ @@ -208,7 +205,7 @@ static void slirp_init_once(void) loopback_mask = htonl(IN_CLASSA_NET); } -Slirp *slirp_new(SlirpConfig *cfg, SlirpCb *callbacks, void *opaque, void *logfn) +Slirp *slirp_new(SlirpConfig *cfg, SlirpCb *callbacks, void *opaque) { Slirp *slirp = (Slirp*)malloc(sizeof(Slirp)); memset(slirp, 0, sizeof(Slirp)); @@ -251,7 +248,6 @@ Slirp *slirp_new(SlirpConfig *cfg, SlirpCb *callbacks, void *opaque, void *logfn slirp->cb = callbacks; slirp->opaque = opaque; - slirp->logfn = logfn; QTAILQ_INSERT_TAIL(&slirp_instances, slirp, entry); @@ -263,8 +259,7 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork, const char *vhostname, const char *tftp_path, const char *bootfile, struct in_addr vdhcp_start, struct in_addr vnameserver, const char **vdnssearch, - const char *vdomainname, SlirpCb *callbacks, void *opaque, - void *logfn) + const char *vdomainname, SlirpCb *callbacks, void *opaque) { SlirpConfig cfg; memset(&cfg, 0, sizeof(cfg)); @@ -279,7 +274,7 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork, cfg.vnameserver = vnameserver; cfg.vdnssearch = vdnssearch; cfg.vdomainname = vdomainname; - return slirp_new(&cfg, callbacks, opaque, logfn); + return slirp_new(&cfg, callbacks, opaque); } void slirp_cleanup(Slirp *slirp) @@ -779,7 +774,7 @@ void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) if (proto == ETH_P_IP) { ip_input(m); } else { - BX_ERROR(("IPv6 packet not supported yet")); + slirp_warning("IPv6 packet not supported yet", slirp->opaque); } break; default: @@ -914,7 +909,7 @@ ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags) { if (so->s == -1 && so->extra) { Slirp *slirp = so->slirp; - BX_ERROR(("slirp_send(): so->extra not supported")); + slirp_warning("slirp_send(): so->extra not supported", slirp->opaque); return len; } @@ -969,19 +964,14 @@ void slirp_socket_recv(Slirp *slirp, struct in_addr guest_addr, int guest_port, tcp_output(sototcpcb(so)); } -void slirp_warning(Slirp *slirp, const char *msg) -{ - BX_ERROR(("%s",msg)); -} - void slirp_send_packet_all(Slirp *slirp, const void *buf, size_t len) { slirp_ssize_t ret = slirp->cb->send_packet(buf, len, slirp->opaque); if (ret < 0) { - slirp_warning(slirp, "Failed to send packet"); + slirp_warning("Failed to send packet", slirp->opaque); } else if ((size_t)ret < len) { - slirp_warning(slirp, "send_packet() didn't send all data"); + slirp_warning("send_packet() didn't send all data", slirp->opaque); } } diff --git a/bochs/iodev/network/slirp/slirp.h b/bochs/iodev/network/slirp/slirp.h index 07207d1b5..0d6d65391 100644 --- a/bochs/iodev/network/slirp/slirp.h +++ b/bochs/iodev/network/slirp/slirp.h @@ -148,11 +148,6 @@ void free(void *ptr); #include -/* Avoid conflicting with the libc insque() and remque(), which - have different prototypes. */ -#define insque slirp_insque -#define remque slirp_remque - #ifdef HAVE_SYS_STROPTS_H #include #endif @@ -296,7 +291,6 @@ struct Slirp { SlirpCb *cb; void *opaque; - void *logfn; }; extern Slirp *slirp_instance; @@ -323,8 +317,6 @@ void if_start(struct ttys *); long gethostid(void); #endif -void slirp_warning(Slirp *, const char *); - #ifndef _WIN32 #include #endif diff --git a/bochs/iodev/network/slirp/socket.cc b/bochs/iodev/network/slirp/socket.cc index 777afd2f0..61851e7a6 100644 --- a/bochs/iodev/network/slirp/socket.cc +++ b/bochs/iodev/network/slirp/socket.cc @@ -1,11 +1,6 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1995 Danny Gasparovski. - * - * Please read the file COPYRIGHT for the - * terms and conditions of the copyright. */ #include "slirp.h" @@ -43,7 +38,7 @@ solookup(struct socket *head, struct in_addr laddr, u_int lport, /* * Create a new socket, initialise the fields * It is the responsibility of the caller to - * insque() it into the correct linked-list + * slirp_insque() it into the correct linked-list */ struct socket * socreate(Slirp *slirp) @@ -61,7 +56,7 @@ socreate(Slirp *slirp) } /* - * remque and free a socket, clobber cache + * slirp_remque and free a socket, clobber cache */ void sofree(struct socket *so) @@ -82,7 +77,7 @@ sofree(struct socket *so) m_free(so->so_m); if(so->so_next && so->so_prev) - remque(so); /* crashes if so is not in a queue */ + slirp_remque(so); /* crashes if so is not in a queue */ free(so); } @@ -613,7 +608,7 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, free(so); return NULL; } - insque(so, &slirp->tcb); + slirp_insque(so, &slirp->tcb); /* * SS_FACCEPTONCE sockets must time out. diff --git a/bochs/iodev/network/slirp/socket.h b/bochs/iodev/network/slirp/socket.h index aab6cc968..6ef1f8ba5 100644 --- a/bochs/iodev/network/slirp/socket.h +++ b/bochs/iodev/network/slirp/socket.h @@ -1,15 +1,10 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1995 Danny Gasparovski. - * - * Please read the file COPYRIGHT for the - * terms and conditions of the copyright. */ -#ifndef _SLIRP_SOCKET_H_ -#define _SLIRP_SOCKET_H_ +#ifndef SLIRP_SOCKET_H +#define SLIRP_SOCKET_H #define SO_EXPIRE 240000 #define SO_EXPIREFAST 10000 @@ -95,4 +90,4 @@ struct iovec; /* For win32 */ size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np); int soreadbuf(struct socket *so, const char *buf, int size); -#endif /* _SOCKET_H_ */ +#endif /* SLIRP_SOCKET_H */ diff --git a/bochs/iodev/network/slirp/tcp.h b/bochs/iodev/network/slirp/tcp.h index a8e498ff8..7eb27f1f1 100644 --- a/bochs/iodev/network/slirp/tcp.h +++ b/bochs/iodev/network/slirp/tcp.h @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -33,8 +31,8 @@ * tcp.h,v 1.3 1994/08/21 05:27:34 paul Exp */ -#ifndef _TCP_H_ -#define _TCP_H_ +#ifndef TCP_H +#define TCP_H typedef uint32_t tcp_seq; diff --git a/bochs/iodev/network/slirp/tcp_input.cc b/bochs/iodev/network/slirp/tcp_input.cc index 38582fba6..8b3b950d4 100644 --- a/bochs/iodev/network/slirp/tcp_input.cc +++ b/bochs/iodev/network/slirp/tcp_input.cc @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -174,14 +172,14 @@ tcp_reass(struct tcpcb *tp, struct tcpiphdr *ti, } q = tcpiphdr_next(q); m = tcpiphdr_prev(q)->ti_mbuf; - remque(tcpiphdr2qlink(tcpiphdr_prev(q))); + slirp_remque(tcpiphdr2qlink(tcpiphdr_prev(q))); m_free(m); } /* * Stick new segment in its place. */ - insque(tcpiphdr2qlink(ti), tcpiphdr2qlink(tcpiphdr_prev(q))); + slirp_insque(tcpiphdr2qlink(ti), tcpiphdr2qlink(tcpiphdr_prev(q))); present: /* @@ -198,7 +196,7 @@ present: do { tp->rcv_nxt += ti->ti_len; flags = ti->ti_flags & TH_FIN; - remque(tcpiphdr2qlink(ti)); + slirp_remque(tcpiphdr2qlink(ti)); m = ti->ti_mbuf; ti = tcpiphdr_next(ti); if (so->so_state & SS_FCANTSENDMORE) diff --git a/bochs/iodev/network/slirp/tcp_output.cc b/bochs/iodev/network/slirp/tcp_output.cc index 6d963b5a1..35a16bb73 100644 --- a/bochs/iodev/network/slirp/tcp_output.cc +++ b/bochs/iodev/network/slirp/tcp_output.cc @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1988, 1990, 1993 * The Regents of the University of California. All rights reserved. diff --git a/bochs/iodev/network/slirp/tcp_subr.cc b/bochs/iodev/network/slirp/tcp_subr.cc index efbccbfd2..09a3c6974 100644 --- a/bochs/iodev/network/slirp/tcp_subr.cc +++ b/bochs/iodev/network/slirp/tcp_subr.cc @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1988, 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -261,7 +259,7 @@ tcp_close(struct tcpcb *tp) while (!tcpfrag_list_end(t, tp)) { t = tcpiphdr_next(t); m = tcpiphdr_prev(t)->ti_mbuf; - remque(tcpiphdr2qlink(tcpiphdr_prev(t))); + slirp_remque(tcpiphdr2qlink(tcpiphdr_prev(t))); m_free(m); } free(tp); @@ -478,7 +476,7 @@ tcp_attach(struct socket *so) if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL) return -1; - insque(so, &so->slirp->tcb); + slirp_insque(so, &so->slirp->tcb); return 0; } diff --git a/bochs/iodev/network/slirp/tcp_timer.cc b/bochs/iodev/network/slirp/tcp_timer.cc index 9311c56a8..4b53fb8a9 100644 --- a/bochs/iodev/network/slirp/tcp_timer.cc +++ b/bochs/iodev/network/slirp/tcp_timer.cc @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1988, 1990, 1993 * The Regents of the University of California. All rights reserved. diff --git a/bochs/iodev/network/slirp/tcp_timer.h b/bochs/iodev/network/slirp/tcp_timer.h index ad64f1518..709f63987 100644 --- a/bochs/iodev/network/slirp/tcp_timer.h +++ b/bochs/iodev/network/slirp/tcp_timer.h @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -33,8 +31,8 @@ * tcp_timer.h,v 1.4 1994/08/21 05:27:38 paul Exp */ -#ifndef _TCP_TIMER_H_ -#define _TCP_TIMER_H_ +#ifndef TCP_TIMER_H +#define TCP_TIMER_H /* * Definitions of the TCP timers. These timers are counted diff --git a/bochs/iodev/network/slirp/tcp_var.h b/bochs/iodev/network/slirp/tcp_var.h index a09f6adfc..1a3ce45ce 100644 --- a/bochs/iodev/network/slirp/tcp_var.h +++ b/bochs/iodev/network/slirp/tcp_var.h @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -33,8 +31,8 @@ * tcp_var.h,v 1.3 1994/08/21 05:27:39 paul Exp */ -#ifndef _TCP_VAR_H_ -#define _TCP_VAR_H_ +#ifndef TCP_VAR_H +#define TCP_VAR_H #include "tcpip.h" #include "tcp_timer.h" diff --git a/bochs/iodev/network/slirp/tcpip.h b/bochs/iodev/network/slirp/tcpip.h index 1ef703aea..8bcd212dd 100644 --- a/bochs/iodev/network/slirp/tcpip.h +++ b/bochs/iodev/network/slirp/tcpip.h @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -33,8 +31,8 @@ * tcpip.h,v 1.3 1994/08/21 05:27:40 paul Exp */ -#ifndef _TCPIP_H_ -#define _TCPIP_H_ +#ifndef TCPIP_H +#define TCPIP_H /* * Tcp+ip header, after ip options removed. diff --git a/bochs/iodev/network/slirp/tftp.cc b/bochs/iodev/network/slirp/tftp.cc index 8edea1121..8818a2bbb 100644 --- a/bochs/iodev/network/slirp/tftp.cc +++ b/bochs/iodev/network/slirp/tftp.cc @@ -1,11 +1,9 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: MIT */ /* - * A simple TFTP server (ported from Qemu) + * tftp.c - a simple, read-only tftp server for qemu * Bochs additions: write support, 'blksize' and 'timeout' options * - * Copyright (C) 2004 Magnus Damm + * Copyright (C) 2004 Magnus Damm * Copyright (C) 2014-2024 The Bochs Project * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/bochs/iodev/network/slirp/tftp.h b/bochs/iodev/network/slirp/tftp.h index b3713fd7f..ebda17b9b 100644 --- a/bochs/iodev/network/slirp/tftp.h +++ b/bochs/iodev/network/slirp/tftp.h @@ -1,12 +1,10 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// - +/* SPDX-License-Identifier: BSD-3-Clause */ /* tftp defines */ -#ifndef SLIRP_TFTP_H -#define SLIRP_TFTP_H 1 -#define TFTP_SESSIONS_MAX 3 +#ifndef SLIRP_TFTP_H +#define SLIRP_TFTP_H + +#define TFTP_SESSIONS_MAX 20 #define TFTP_SERVER 69 diff --git a/bochs/iodev/network/slirp/udp.cc b/bochs/iodev/network/slirp/udp.cc index bfb6d994c..9241aa3f5 100644 --- a/bochs/iodev/network/slirp/udp.cc +++ b/bochs/iodev/network/slirp/udp.cc @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1988, 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -319,7 +317,7 @@ udp_attach(struct socket *so) { if((so->s = qemu_socket(AF_INET,SOCK_DGRAM,0)) != -1) { so->so_expire = curtime + SO_EXPIRE; - insque(so, &so->slirp->udb); + slirp_insque(so, &so->slirp->udb); } return(so->s); } @@ -367,7 +365,7 @@ udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, } so->s = qemu_socket(AF_INET,SOCK_DGRAM,0); so->so_expire = curtime + SO_EXPIRE; - insque(so, &slirp->udb); + slirp_insque(so, &slirp->udb); addr.sin_family = AF_INET; addr.sin_addr.s_addr = haddr; diff --git a/bochs/iodev/network/slirp/udp.h b/bochs/iodev/network/slirp/udp.h index 3a5c625cd..2663c81d3 100644 --- a/bochs/iodev/network/slirp/udp.h +++ b/bochs/iodev/network/slirp/udp.h @@ -1,6 +1,4 @@ -///////////////////////////////////////////////////////////////////////// -// $Id$ -///////////////////////////////////////////////////////////////////////// +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -33,8 +31,8 @@ * udp.h,v 1.3 1994/08/21 05:27:41 paul Exp */ -#ifndef _UDP_H_ -#define _UDP_H_ +#ifndef UDP_H +#define UDP_H #define UDP_TTL 0x60 #define UDP_UDPDATALEN 16192