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.
This commit is contained in:
Volker Ruppert 2024-04-21 11:27:51 +02:00
parent fa5c5ebe88
commit f1259413fb
38 changed files with 154 additions and 263 deletions

View File

@ -36,11 +36,10 @@
#if BX_HAVE_LIBSLIRP #if BX_HAVE_LIBSLIRP
#include <slirp/libslirp.h> #include <slirp/libslirp.h>
#include <signal.h>
#else #else
#include "slirp/slirp.h"
#include "slirp/libslirp.h" #include "slirp/libslirp.h"
#endif #endif
#include <signal.h>
static unsigned int bx_slirp_instances = 0; static unsigned int bx_slirp_instances = 0;
@ -72,9 +71,7 @@ public:
virtual ~bx_slirp_pktmover_c(); virtual ~bx_slirp_pktmover_c();
void sendpkt(void *buf, unsigned io_len); void sendpkt(void *buf, unsigned io_len);
slirp_ssize_t receive(void *pkt, unsigned pkt_len); slirp_ssize_t receive(void *pkt, unsigned pkt_len);
#if BX_HAVE_LIBSLIRP void slirp_msg(bool error, const char *msg);
void slirp_msg(const char *msg);
#endif
private: private:
Slirp *slirp; Slirp *slirp;
unsigned netdev_speed; unsigned netdev_speed;
@ -86,9 +83,11 @@ private:
char *smb_export, *smb_tmpdir; char *smb_export, *smb_tmpdir;
struct in_addr smb_srv; struct in_addr smb_srv;
#endif #endif
bool slirp_logging;
char *pktlog_fn; char *pktlog_fn;
FILE *pktlog_txt; FILE *pktlog_txt;
bool slirp_logging;
logfunctions *slirplog;
bool parse_slirp_conf(const char *conf); bool parse_slirp_conf(const char *conf);
static void rx_timer_handler(void *); 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); return class_ptr->receive((void*)buf, len);
} }
#if BX_HAVE_LIBSLIRP
static void guest_error(const char *msg, void *opaque) static void guest_error(const char *msg, void *opaque)
{ {
char errmsg[512]; char errmsg[512];
sprintf(errmsg, "guest error: %s", msg); 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) 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) 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; struct timer *new_timer = new timer;
new_timer->id = id; new_timer->id = id;
new_timer->cb_opaque = cb_opaque; 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) 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 *timer1 = (timer*)_timer;
struct timer **t; 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) 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 *timer1 = (timer*)_timer;
struct timer **t; struct timer **t;
@ -210,9 +207,7 @@ static void notify(void *opaque)
static struct SlirpCb callbacks = { static struct SlirpCb callbacks = {
.send_packet = send_packet, .send_packet = send_packet,
#if BX_HAVE_LIBSLIRP
.guest_error = guest_error, .guest_error = guest_error,
#endif
.clock_get_ns = clock_get_ns, .clock_get_ns = clock_get_ns,
#if BX_HAVE_LIBSLIRP #if BX_HAVE_LIBSLIRP
.timer_free = timer_free, .timer_free = timer_free,
@ -231,10 +226,7 @@ bx_slirp_pktmover_c::bx_slirp_pktmover_c(const char *netif,
logfunctions *netdev, logfunctions *netdev,
const char *script) const char *script)
{ {
#if !BX_HAVE_LIBSLIRP
logfunctions *slirplog;
char prefix[10]; char prefix[10];
#endif
slirp = NULL; slirp = NULL;
pktlog_fn = NULL; pktlog_fn = NULL;
@ -266,9 +258,6 @@ bx_slirp_pktmover_c::bx_slirp_pktmover_c(const char *netif,
#if BX_HAVE_LIBSLIRP #if BX_HAVE_LIBSLIRP
BX_INFO(("slirp network driver (libslirp version %s)", slirp_version_string())); BX_INFO(("slirp network driver (libslirp version %s)", slirp_version_string()));
#else #else
if (sizeof(struct arphdr) != 28) {
BX_FATAL(("system error: invalid ARP header structure size"));
}
BX_INFO(("slirp network driver")); BX_INFO(("slirp network driver"));
#endif #endif
@ -302,14 +291,10 @@ bx_slirp_pktmover_c::bx_slirp_pktmover_c(const char *netif,
} }
#endif #endif
} }
#if BX_HAVE_LIBSLIRP
slirp = slirp_new(&config, &callbacks, this);
#else
slirplog = new logfunctions(); slirplog = new logfunctions();
sprintf(prefix, "SLIRP%d", bx_slirp_instances); sprintf(prefix, "SLIRP%d", bx_slirp_instances);
slirplog->put(prefix); slirplog->put(prefix);
slirp = slirp_new(&config, &callbacks, this, slirplog); slirp = slirp_new(&config, &callbacks, this);
#endif
if (n_hostfwd > 0) { if (n_hostfwd > 0) {
for (int i = 0; i < n_hostfwd; i++) { for (int i = 0; i < n_hostfwd; i++) {
slirp_hostfwd(slirp, hostfwd[i], 0); 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__) #if !defined(_WIN32) && !defined(__CYGWIN__)
#define CONFIG_SMBD_COMMAND "/usr/sbin/smbd" #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; 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 */ #endif /* if BX_NETWORKING && BX_NETMOD_SLIRP */

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: MIT */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* ARP table * ARP table
* *

View File

@ -1,8 +1,6 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: MIT */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* BOOTP/DHCP server (ported from Qemu) * QEMU BOOTP/DHCP server
* Bochs additions: parameter list and some other options * Bochs additions: parameter list and some other options
* *
* Copyright (c) 2004 Fabrice Bellard * 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); defsize = sizeof(struct bootp_t) - sizeof(struct ip) - sizeof(struct udphdr);
if (ntohs(maxsize) < defsize) { if (ntohs(maxsize) < defsize) {
sprintf(msg, "DHCP server: RFB2132_MAX_SIZE=%u not supported yet", ntohs(maxsize)); sprintf(msg, "DHCP server: RFB2132_MAX_SIZE=%u not supported yet", ntohs(maxsize));
slirp_warning(slirp, msg); slirp_warning(msg, slirp->opaque);
} }
} }
break; break;
default: default:
sprintf(msg, "DHCP server: option %d not supported yet", tag); sprintf(msg, "DHCP server: option %d not supported yet", tag);
slirp_warning(slirp, msg); slirp_warning(msg, slirp->opaque);
break; break;
} }
p += len; 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); spaceleft = sizeof(rbp->bp_vend) - (q - rbp->bp_vend);
val = strlen(slirp->vdomainname); val = strlen(slirp->vdomainname);
if (val + 1 > (int)spaceleft) { 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 { } else {
*q++ = RFC1533_DOMAINNAME; *q++ = RFC1533_DOMAINNAME;
*q++ = val; *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); spaceleft = sizeof(rbp->bp_vend) - (q - rbp->bp_vend);
val = strlen(slirp->tftp_server_name); val = strlen(slirp->tftp_server_name);
if (val + 1 > (int)spaceleft) { 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 { } else {
*q++ = RFC2132_TFTP_SERVER_NAME; *q++ = RFC2132_TFTP_SERVER_NAME;
*q++ = val; *q++ = val;
@ -434,7 +432,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp)
default: default:
sprintf(msg, "DHCP server: requested parameter %u not supported yet", sprintf(msg, "DHCP server: requested parameter %u not supported yet",
*(pp-1)); *(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); spaceleft = sizeof(rbp->bp_vend) - (q - rbp->bp_vend);
val = slirp->vdnssearch_len; val = slirp->vdnssearch_len;
if (val + 1 > (int)spaceleft) { 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 { } else {
memcpy(q, slirp->vdnssearch, val); memcpy(q, slirp->vdnssearch, val);
q += val; q += val;

View File

@ -1,7 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* bootp/dhcp defines */ /* bootp/dhcp defines */
#ifndef SLIRP_BOOTP_H #ifndef SLIRP_BOOTP_H
#define SLIRP_BOOTP_H 1 #define SLIRP_BOOTP_H 1

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1988, 1992, 1993 * Copyright (c) 1988, 1992, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.

View File

@ -1,13 +1,10 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1995 Danny Gasparovski. * 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 //#define DEBUG 1
#ifdef DEBUG #ifdef DEBUG
@ -35,3 +32,5 @@ extern int slirp_debug;
#define DEBUG_ERROR(x) #define DEBUG_ERROR(x)
#endif #endif
#endif

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: MIT */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Domain search option for DHCP (RFC 3397) * Domain search option for DHCP (RFC 3397)
* *
@ -159,7 +157,7 @@ static void domain_mklabels(Slirp *s, CompactDomain *cd, const char *input)
fail: fail:
sprintf(msg, "failed to parse domain name '%s'\n", input); sprintf(msg, "failed to parse domain name '%s'\n", input);
slirp_warning(s, msg); slirp_warning(msg, s->opaque);
cd->len = 0; cd->len = 0;
} }

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1995 Danny Gasparovski. * 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. * XXX Shouldn't need this, gotta change dtom() etc.
*/ */
if (ifm->m_flags & M_USEDLIST) { if (ifm->m_flags & M_USEDLIST) {
remque(ifm); slirp_remque(ifm);
ifm->m_flags &= ~M_USEDLIST; 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 */ /* Create a new doubly linked list for this session */
ifm->ifq_so = so; ifm->ifq_so = so;
ifs_init(ifm); ifs_init(ifm);
insque(ifm, ifq); slirp_insque(ifm, ifq);
diddit: diddit:
if (so) { if (so) {
@ -131,10 +129,10 @@ diddit:
(so->so_nqueued - so->so_queued) >= 3)) { (so->so_nqueued - so->so_queued) >= 3)) {
/* Remove from current queue... */ /* Remove from current queue... */
remque(ifm->ifs_next); slirp_remque(ifm->ifs_next);
/* ...And insert in the new. That'll teach ya! */ /* ...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 */ /* Remove it from the queue */
ifqt = ifm->ifq_prev; ifqt = ifm->ifq_prev;
remque(ifm); slirp_remque(ifm);
/* If there are more packets for this session, re-queue them */ /* If there are more packets for this session, re-queue them */
if (ifm->ifs_next != ifm) { if (ifm->ifs_next != ifm) {
struct mbuf *next = ifm->ifs_next; struct mbuf *next = ifm->ifs_next;
insque(next, ifqt); slirp_insque(next, ifqt);
ifs_remque(ifm); ifs_remque(ifm);
if (!from_batchq) { if (!from_batchq) {

View File

@ -1,15 +1,10 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1995 Danny Gasparovski. * Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/ */
#ifndef _IF_H_ #ifndef IF_H
#define _IF_H_ #define IF_H
#define IF_COMPRESS 0x01 /* We want compression */ #define IF_COMPRESS 0x01 /* We want compression */
#define IF_NOCOMPRESS 0x02 /* Do not do compression */ #define IF_NOCOMPRESS 0x02 /* Do not do compression */

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1993 * Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved. * 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 * ip.h,v 1.3 1994/08/21 05:27:30 paul Exp
*/ */
#ifndef _IP_H_ #ifndef IP_H
#define _IP_H_ #define IP_H
#ifndef BX_LITTLE_ENDIAN #ifndef BX_LITTLE_ENDIAN
# undef NTOHL # undef NTOHL

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1988, 1993 * Copyright (c) 1982, 1986, 1988, 1993
* The Regents of the University of California. All rights reserved. * 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_family = AF_INET;
addr.sin_addr = so->so_faddr; 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, if (sendto(so->s, m->m_data + hlen, m->m_len - hlen, 0,
(struct sockaddr *)&addr, sizeof(addr)) == -1) { (struct sockaddr *)&addr, sizeof(addr)) == -1) {

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1993 * Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1988, 1993 * Copyright (c) 1982, 1986, 1988, 1993
* The Regents of the University of California. All rights reserved. * 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; goto dropfrag;
} }
fp = mtod(t, struct ipq *); 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_ttl = IPFRAGTTL;
fp->ipq_p = ip->ip_p; fp->ipq_p = ip->ip_p;
fp->ipq_id = ip->ip_id; fp->ipq_id = ip->ip_id;
@ -370,7 +368,7 @@ insert:
ip->ip_tos &= ~1; ip->ip_tos &= ~1;
ip->ip_src = fp->ipq_src; ip->ip_src = fp->ipq_src;
ip->ip_dst = fp->ipq_dst; ip->ip_dst = fp->ipq_dst;
remque(&fp->ip_link); slirp_remque(&fp->ip_link);
(void) m_free(dtom(slirp, fp)); (void) m_free(dtom(slirp, fp));
m->m_len += (ip->ip_hl << 2); m->m_len += (ip->ip_hl << 2);
m->m_data -= (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); ip_deq(q);
m_free(dtom(slirp, q)); m_free(dtom(slirp, q));
} }
remque(&fp->ip_link); slirp_remque(&fp->ip_link);
(void) m_free(dtom(slirp, fp)); (void) m_free(dtom(slirp, fp));
} }
/* /*
* Put an ip fragment on a reassembly chain. * 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 static void
ip_enq(struct ipasfrag *p, struct ipasfrag *prev) 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 static void
ip_deq(struct ipasfrag *p) ip_deq(struct ipasfrag *p)

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1988, 1990, 1993 * Copyright (c) 1982, 1986, 1988, 1990, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.

View File

@ -2,13 +2,19 @@
#ifndef LIBSLIRP_H #ifndef LIBSLIRP_H
#define LIBSLIRP_H #define LIBSLIRP_H
#include <stdint.h>
#include "compat.h" #include "compat.h"
#ifdef _WIN32
#include <winsock2.h>
#else
#include <netinet/in.h>
#endif
typedef ssize_t slirp_ssize_t;
struct Slirp; struct Slirp;
typedef struct Slirp Slirp; typedef struct Slirp Slirp;
typedef ssize_t slirp_ssize_t;
/* Callback for application to send data to the guest */ /* Callback for application to send data to the guest */
typedef slirp_ssize_t (*SlirpWriteCb)(const void *buf, size_t len, void *opaque); 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. * <0 reports an IO error.
*/ */
SlirpWriteCb send_packet; 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 */ /* Return the virtual clock value in nanoseconds */
int64_t (*clock_get_ns)(void *opaque); int64_t (*clock_get_ns)(void *opaque);
} SlirpCb; } SlirpCb;
@ -45,9 +53,8 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork,
const char *vhostname, const char *tftp_path, const char *vhostname, const char *tftp_path,
const char *bootfile, struct in_addr vdhcp_start, const char *bootfile, struct in_addr vdhcp_start,
struct in_addr vnameserver, const char **vdnssearch, struct in_addr vnameserver, const char **vdnssearch,
const char *vdomainname, const SlirpCb *callbacks, void *opaque, const char *vdomainname, const SlirpCb *callbacks, void *opaque);
void *logfn); Slirp *slirp_new(SlirpConfig *cfg, SlirpCb *callbacks, void *opaque);
Slirp *slirp_new(SlirpConfig *cfg, SlirpCb *callbacks, void *opaque, void *logfn);
void slirp_cleanup(Slirp *slirp); void slirp_cleanup(Slirp *slirp);
void slirp_select_fill(int *pnfds, fd_set *readfds, fd_set *writefds, 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); void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len);
/* you must provide the following functions: */ /* you must provide the following functions: */
void slirp_warning(const char *, void *);
int slirp_add_hostfwd(Slirp *slirp, int is_udp, int slirp_add_hostfwd(Slirp *slirp, int is_udp,
struct in_addr host_addr, int host_port, struct in_addr host_addr, int host_port,
struct in_addr guest_addr, int guest_port); struct in_addr guest_addr, int guest_port);

View File

@ -1,14 +1,9 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1995 Danny Gasparovski. * Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/ */
#ifndef SLIRP_MAIN_H #ifndef SLIRP_MAIN_H
#define SLIRP_MAIN_H 1 #define SLIRP_MAIN_H
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
#include <sys/select.h> #include <sys/select.h>

View File

@ -1,11 +1,6 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1995 Danny Gasparovski * 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; m->slirp = slirp;
} else { } else {
m = slirp->m_freelist.m_next; m = slirp->m_freelist.m_next;
remque(m); slirp_remque(m);
} }
/* Insert it in the used list */ /* Insert it in the used list */
insque(m,&slirp->m_usedlist); slirp_insque(m,&slirp->m_usedlist);
m->m_flags = (flags | M_USEDLIST); m->m_flags = (flags | M_USEDLIST);
/* Initialise it */ /* Initialise it */
@ -113,7 +108,7 @@ m_free(struct mbuf *m)
if(m) { if(m) {
/* Remove from m_usedlist */ /* Remove from m_usedlist */
if (m->m_flags & M_USEDLIST) if (m->m_flags & M_USEDLIST)
remque(m); slirp_remque(m);
/* If it's M_EXT, free() it */ /* If it's M_EXT, free() it */
if (m->m_flags & M_EXT) if (m->m_flags & M_EXT)
@ -126,7 +121,7 @@ m_free(struct mbuf *m)
m->slirp->mbuf_alloced--; m->slirp->mbuf_alloced--;
free(m); free(m);
} else if ((m->m_flags & M_FREELIST) == 0) { } 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 */ m->m_flags = M_FREELIST; /* Clobber other flags */
} }
} /* if(m) */ } /* if(m) */

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1988, 1993 * Copyright (c) 1982, 1986, 1988, 1993
* The Regents of the University of California. All rights reserved. * 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 * mbuf.h,v 1.9 1994/11/14 13:54:20 bde Exp
*/ */
#ifndef _MBUF_H_ #ifndef MBUF_H
#define _MBUF_H_ #define MBUF_H
#define MINCSIZE 4096 /* Amount to increase mbuf if too small */ #define MINCSIZE 4096 /* Amount to increase mbuf if too small */

View File

@ -1,11 +1,6 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1995 Danny Gasparovski. * Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/ */
#include "slirp.h" #include "slirp.h"
@ -26,7 +21,7 @@ struct quehead {
struct quehead *qh_rlink; 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 *element = (struct quehead *) a;
struct quehead *head = (struct quehead *) b; struct quehead *head = (struct quehead *) b;
@ -37,7 +32,7 @@ void insque(void *a, void *b)
= (struct quehead *)element; = (struct quehead *)element;
} }
void remque(void *a) void slirp_remque(void *a)
{ {
struct quehead *element = (struct quehead *) a; struct quehead *element = (struct quehead *) a;
((struct quehead *)(element->qh_link))->qh_rlink = element->qh_rlink; ((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); exit(1);
default: 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 this could block us...
* XXX Should set a timer here, and if accept() doesn't * XXX Should set a timer here, and if accept() doesn't

View File

@ -1,15 +1,10 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1995 Danny Gasparovski. * Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/ */
#ifndef _MISC_H_ #ifndef MISC_H
#define _MISC_H_ #define MISC_H
struct ex_list { struct ex_list {
int ex_pty; /* Do we want a pty? */ int ex_pty; /* Do we want a pty? */

View File

@ -1,11 +1,6 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1995 Danny Gasparovski. * Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/ */
#include "slirp.h" #include "slirp.h"

View File

@ -1,15 +1,10 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1995 Danny Gasparovski. * Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/ */
#ifndef _SBUF_H_ #ifndef SBUF_H
#define _SBUF_H_ #define SBUF_H
#define sbflush(sb) sbdrop((sb),(sb)->sb_cc) #define sbflush(sb) sbdrop((sb),(sb)->sb_cc)
#define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc) #define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc)

View File

@ -25,12 +25,9 @@
#define BX_PLUGGABLE #define BX_PLUGGABLE
#include "slirp.h" #include "slirp.h"
#include "iodev.h"
#if BX_NETWORKING && BX_NETMOD_SLIRP #if BX_NETWORKING && BX_NETMOD_SLIRP
#define LOG_THIS ((logfunctions*)slirp->logfn)->
/* host loopback address */ /* host loopback address */
struct in_addr loopback_addr; struct in_addr loopback_addr;
/* host loopback network mask */ /* host loopback network mask */
@ -208,7 +205,7 @@ static void slirp_init_once(void)
loopback_mask = htonl(IN_CLASSA_NET); 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)); Slirp *slirp = (Slirp*)malloc(sizeof(Slirp));
memset(slirp, 0, 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->cb = callbacks;
slirp->opaque = opaque; slirp->opaque = opaque;
slirp->logfn = logfn;
QTAILQ_INSERT_TAIL(&slirp_instances, slirp, entry); 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 *vhostname, const char *tftp_path,
const char *bootfile, struct in_addr vdhcp_start, const char *bootfile, struct in_addr vdhcp_start,
struct in_addr vnameserver, const char **vdnssearch, struct in_addr vnameserver, const char **vdnssearch,
const char *vdomainname, SlirpCb *callbacks, void *opaque, const char *vdomainname, SlirpCb *callbacks, void *opaque)
void *logfn)
{ {
SlirpConfig cfg; SlirpConfig cfg;
memset(&cfg, 0, sizeof(cfg)); memset(&cfg, 0, sizeof(cfg));
@ -279,7 +274,7 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork,
cfg.vnameserver = vnameserver; cfg.vnameserver = vnameserver;
cfg.vdnssearch = vdnssearch; cfg.vdnssearch = vdnssearch;
cfg.vdomainname = vdomainname; cfg.vdomainname = vdomainname;
return slirp_new(&cfg, callbacks, opaque, logfn); return slirp_new(&cfg, callbacks, opaque);
} }
void slirp_cleanup(Slirp *slirp) 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) { if (proto == ETH_P_IP) {
ip_input(m); ip_input(m);
} else { } else {
BX_ERROR(("IPv6 packet not supported yet")); slirp_warning("IPv6 packet not supported yet", slirp->opaque);
} }
break; break;
default: 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) { if (so->s == -1 && so->extra) {
Slirp *slirp = so->slirp; Slirp *slirp = so->slirp;
BX_ERROR(("slirp_send(): so->extra not supported")); slirp_warning("slirp_send(): so->extra not supported", slirp->opaque);
return len; return len;
} }
@ -969,19 +964,14 @@ void slirp_socket_recv(Slirp *slirp, struct in_addr guest_addr, int guest_port,
tcp_output(sototcpcb(so)); 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) 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); slirp_ssize_t ret = slirp->cb->send_packet(buf, len, slirp->opaque);
if (ret < 0) { if (ret < 0) {
slirp_warning(slirp, "Failed to send packet"); slirp_warning("Failed to send packet", slirp->opaque);
} else if ((size_t)ret < len) { } 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);
} }
} }

View File

@ -148,11 +148,6 @@ void free(void *ptr);
#include <sys/stat.h> #include <sys/stat.h>
/* 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 #ifdef HAVE_SYS_STROPTS_H
#include <sys/stropts.h> #include <sys/stropts.h>
#endif #endif
@ -296,7 +291,6 @@ struct Slirp {
SlirpCb *cb; SlirpCb *cb;
void *opaque; void *opaque;
void *logfn;
}; };
extern Slirp *slirp_instance; extern Slirp *slirp_instance;
@ -323,8 +317,6 @@ void if_start(struct ttys *);
long gethostid(void); long gethostid(void);
#endif #endif
void slirp_warning(Slirp *, const char *);
#ifndef _WIN32 #ifndef _WIN32
#include <netdb.h> #include <netdb.h>
#endif #endif

View File

@ -1,11 +1,6 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1995 Danny Gasparovski. * Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/ */
#include "slirp.h" #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 * Create a new socket, initialise the fields
* It is the responsibility of the caller to * 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 * struct socket *
socreate(Slirp *slirp) 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 void
sofree(struct socket *so) sofree(struct socket *so)
@ -82,7 +77,7 @@ sofree(struct socket *so)
m_free(so->so_m); m_free(so->so_m);
if(so->so_next && so->so_prev) 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); free(so);
} }
@ -613,7 +608,7 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
free(so); free(so);
return NULL; return NULL;
} }
insque(so, &slirp->tcb); slirp_insque(so, &slirp->tcb);
/* /*
* SS_FACCEPTONCE sockets must time out. * SS_FACCEPTONCE sockets must time out.

View File

@ -1,15 +1,10 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1995 Danny Gasparovski. * Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/ */
#ifndef _SLIRP_SOCKET_H_ #ifndef SLIRP_SOCKET_H
#define _SLIRP_SOCKET_H_ #define SLIRP_SOCKET_H
#define SO_EXPIRE 240000 #define SO_EXPIRE 240000
#define SO_EXPIREFAST 10000 #define SO_EXPIREFAST 10000
@ -95,4 +90,4 @@ struct iovec; /* For win32 */
size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np); size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np);
int soreadbuf(struct socket *so, const char *buf, int size); int soreadbuf(struct socket *so, const char *buf, int size);
#endif /* _SOCKET_H_ */ #endif /* SLIRP_SOCKET_H */

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1993 * Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved. * 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 * tcp.h,v 1.3 1994/08/21 05:27:34 paul Exp
*/ */
#ifndef _TCP_H_ #ifndef TCP_H
#define _TCP_H_ #define TCP_H
typedef uint32_t tcp_seq; typedef uint32_t tcp_seq;

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994
* The Regents of the University of California. All rights reserved. * 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); q = tcpiphdr_next(q);
m = tcpiphdr_prev(q)->ti_mbuf; m = tcpiphdr_prev(q)->ti_mbuf;
remque(tcpiphdr2qlink(tcpiphdr_prev(q))); slirp_remque(tcpiphdr2qlink(tcpiphdr_prev(q)));
m_free(m); m_free(m);
} }
/* /*
* Stick new segment in its place. * Stick new segment in its place.
*/ */
insque(tcpiphdr2qlink(ti), tcpiphdr2qlink(tcpiphdr_prev(q))); slirp_insque(tcpiphdr2qlink(ti), tcpiphdr2qlink(tcpiphdr_prev(q)));
present: present:
/* /*
@ -198,7 +196,7 @@ present:
do { do {
tp->rcv_nxt += ti->ti_len; tp->rcv_nxt += ti->ti_len;
flags = ti->ti_flags & TH_FIN; flags = ti->ti_flags & TH_FIN;
remque(tcpiphdr2qlink(ti)); slirp_remque(tcpiphdr2qlink(ti));
m = ti->ti_mbuf; m = ti->ti_mbuf;
ti = tcpiphdr_next(ti); ti = tcpiphdr_next(ti);
if (so->so_state & SS_FCANTSENDMORE) if (so->so_state & SS_FCANTSENDMORE)

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1988, 1990, 1993 * Copyright (c) 1982, 1986, 1988, 1990, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1988, 1990, 1993 * Copyright (c) 1982, 1986, 1988, 1990, 1993
* The Regents of the University of California. All rights reserved. * 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)) { while (!tcpfrag_list_end(t, tp)) {
t = tcpiphdr_next(t); t = tcpiphdr_next(t);
m = tcpiphdr_prev(t)->ti_mbuf; m = tcpiphdr_prev(t)->ti_mbuf;
remque(tcpiphdr2qlink(tcpiphdr_prev(t))); slirp_remque(tcpiphdr2qlink(tcpiphdr_prev(t)));
m_free(m); m_free(m);
} }
free(tp); free(tp);
@ -478,7 +476,7 @@ tcp_attach(struct socket *so)
if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL) if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL)
return -1; return -1;
insque(so, &so->slirp->tcb); slirp_insque(so, &so->slirp->tcb);
return 0; return 0;
} }

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1988, 1990, 1993 * Copyright (c) 1982, 1986, 1988, 1990, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1993 * Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved. * 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 * tcp_timer.h,v 1.4 1994/08/21 05:27:38 paul Exp
*/ */
#ifndef _TCP_TIMER_H_ #ifndef TCP_TIMER_H
#define _TCP_TIMER_H_ #define TCP_TIMER_H
/* /*
* Definitions of the TCP timers. These timers are counted * Definitions of the TCP timers. These timers are counted

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1993, 1994 * Copyright (c) 1982, 1986, 1993, 1994
* The Regents of the University of California. All rights reserved. * 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 * tcp_var.h,v 1.3 1994/08/21 05:27:39 paul Exp
*/ */
#ifndef _TCP_VAR_H_ #ifndef TCP_VAR_H
#define _TCP_VAR_H_ #define TCP_VAR_H
#include "tcpip.h" #include "tcpip.h"
#include "tcp_timer.h" #include "tcp_timer.h"

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1993 * Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved. * 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 * tcpip.h,v 1.3 1994/08/21 05:27:40 paul Exp
*/ */
#ifndef _TCPIP_H_ #ifndef TCPIP_H
#define _TCPIP_H_ #define TCPIP_H
/* /*
* Tcp+ip header, after ip options removed. * Tcp+ip header, after ip options removed.

View File

@ -1,11 +1,9 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: MIT */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* 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 * Bochs additions: write support, 'blksize' and 'timeout' options
* *
* Copyright (C) 2004 Magnus Damm <damm@opensource.se> * Copyright (C) 2004 Magnus Damm <damm@opensource.se>
* Copyright (C) 2014-2024 The Bochs Project * Copyright (C) 2014-2024 The Bochs Project
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy

View File

@ -1,12 +1,10 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* tftp defines */ /* 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 #define TFTP_SERVER 69

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1988, 1990, 1993 * Copyright (c) 1982, 1986, 1988, 1990, 1993
* The Regents of the University of California. All rights reserved. * 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) { if((so->s = qemu_socket(AF_INET,SOCK_DGRAM,0)) != -1) {
so->so_expire = curtime + SO_EXPIRE; so->so_expire = curtime + SO_EXPIRE;
insque(so, &so->slirp->udb); slirp_insque(so, &so->slirp->udb);
} }
return(so->s); 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->s = qemu_socket(AF_INET,SOCK_DGRAM,0);
so->so_expire = curtime + SO_EXPIRE; so->so_expire = curtime + SO_EXPIRE;
insque(so, &slirp->udb); slirp_insque(so, &slirp->udb);
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_addr.s_addr = haddr; addr.sin_addr.s_addr = haddr;

View File

@ -1,6 +1,4 @@
///////////////////////////////////////////////////////////////////////// /* SPDX-License-Identifier: BSD-3-Clause */
// $Id$
/////////////////////////////////////////////////////////////////////////
/* /*
* Copyright (c) 1982, 1986, 1993 * Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved. * 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 * udp.h,v 1.3 1994/08/21 05:27:41 paul Exp
*/ */
#ifndef _UDP_H_ #ifndef UDP_H
#define _UDP_H_ #define UDP_H
#define UDP_TTL 0x60 #define UDP_TTL 0x60
#define UDP_UDPDATALEN 16192 #define UDP_UDPDATALEN 16192