diff --git a/bochs/iodev/network/eth_slirp.cc b/bochs/iodev/network/eth_slirp.cc index e2942c30d..9cad5e896 100644 --- a/bochs/iodev/network/eth_slirp.cc +++ b/bochs/iodev/network/eth_slirp.cc @@ -242,7 +242,7 @@ bx_slirp_pktmover_c::bx_slirp_pktmover_c(const char *netif, config.disable_host_loopback = false; config.enable_emu = false; config.disable_dns = false; - config.tftp_server_name = "tftp"; + config.vdomainname = "local"; #endif config.restricted = false; config.vnetwork.s_addr = htonl(0x0a000200); /* 10.0.2.0 */ @@ -355,6 +355,7 @@ bx_slirp_pktmover_c::~bx_slirp_pktmover_c() #endif if (config.bootfile != NULL) free((void*)config.bootfile); if (config.vhostname != NULL) free((void*)config.vhostname); + if (config.tftp_server_name != NULL) free((void*)config.tftp_server_name); if (config.vdnssearch != NULL) { size_t i = 0; while (config.vdnssearch[i] != NULL) { @@ -531,6 +532,13 @@ bool bx_slirp_pktmover_c::parse_slirp_conf(const char *conf) } else if (!stricmp(param, "ipv6_enabled")) { config.in6_enabled = (atoi(val) != 0); #endif + } else if (!stricmp(param, "tftp_srvname")) { + if (len2 < 33) { + config.tftp_server_name = (char*)malloc(len2+1); + strcpy((char*)config.tftp_server_name, val); + } else { + BX_ERROR(("slirp: wrong format for 'tftp_srvname'")); + } } else { BX_ERROR(("slirp: unknown option '%s'", line)); } diff --git a/bochs/iodev/network/slirp/bootp.cc b/bochs/iodev/network/slirp/bootp.cc index 22b989f29..2c591b829 100644 --- a/bochs/iodev/network/slirp/bootp.cc +++ b/bochs/iodev/network/slirp/bootp.cc @@ -406,6 +406,18 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp) } } + if (slirp->tftp_server_name) { + 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."); + } else { + *q++ = RFC2132_TFTP_SERVER_NAME; + *q++ = val; + memcpy(q, slirp->tftp_server_name, val); + q += val; + } + } if (slirp->vdnssearch) { spaceleft = sizeof(rbp->bp_vend) - (q - rbp->bp_vend); val = slirp->vdnssearch_len; diff --git a/bochs/iodev/network/slirp/bootp.h b/bochs/iodev/network/slirp/bootp.h index dc421d99a..b69aa1be7 100644 --- a/bochs/iodev/network/slirp/bootp.h +++ b/bochs/iodev/network/slirp/bootp.h @@ -73,6 +73,7 @@ #define RFC2132_MAX_SIZE 57 #define RFC2132_RENEWAL_TIME 58 #define RFC2132_REBIND_TIME 59 +#define RFC2132_TFTP_SERVER_NAME 66 #define DHCPDISCOVER 1 #define DHCPOFFER 2 diff --git a/bochs/iodev/network/slirp/libslirp.h b/bochs/iodev/network/slirp/libslirp.h index 96340bf67..55f208a49 100644 --- a/bochs/iodev/network/slirp/libslirp.h +++ b/bochs/iodev/network/slirp/libslirp.h @@ -13,7 +13,7 @@ typedef struct Slirp Slirp; typedef struct SlirpConfig { int restricted; struct in_addr vnetwork, vnetmask, vhost, vdhcp_start, vnameserver; - const char *bootfile, *vhostname, **vdnssearch, *tftp_path; + const char *bootfile, *vhostname, **vdnssearch, *tftp_path, *tftp_server_name; } SlirpConfig; int get_dns_addr(struct in_addr *pdns_addr); diff --git a/bochs/iodev/network/slirp/slirp.cc b/bochs/iodev/network/slirp/slirp.cc index b8b903f02..07e73370d 100644 --- a/bochs/iodev/network/slirp/slirp.cc +++ b/bochs/iodev/network/slirp/slirp.cc @@ -232,6 +232,9 @@ Slirp *slirp_new(SlirpConfig *cfg, void *opaque, void *logfn) pstrcpy(slirp->client_hostname, sizeof(slirp->client_hostname), cfg->vhostname); } + if (cfg->tftp_server_name) { + slirp->tftp_server_name = strdup(cfg->tftp_server_name); + } if (cfg->tftp_path) { slirp->tftp_prefix = strdup(cfg->tftp_path); } diff --git a/bochs/iodev/network/slirp/slirp.h b/bochs/iodev/network/slirp/slirp.h index 031cb298a..8315481d5 100644 --- a/bochs/iodev/network/slirp/slirp.h +++ b/bochs/iodev/network/slirp/slirp.h @@ -290,6 +290,7 @@ struct Slirp { struct socket *icmp_last_so; /* tftp states */ + char *tftp_server_name; char *tftp_prefix; struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX]; diff --git a/bochs/misc/slirp.conf b/bochs/misc/slirp.conf index e0ffa8049..013cacb22 100644 --- a/bochs/misc/slirp.conf +++ b/bochs/misc/slirp.conf @@ -3,19 +3,21 @@ # Supported options: # -# RESTRICTED if set to 1, only built-in services are available -# NET base IP address of the virtual network -# MASK netmask of the virtual network -# HOST IP address of the DHCP and TFTP server -# HOSTNAME DHCP client hostname -# DHCPSTART start address of DHCP pool -# DNS IP address of the virtual DNS server -# BOOTFILE boot filename returned by DHCP -# DNSSEARCH comma-separated list of DNS suffixes to search (DHCP extension) -# SMB_EXPORT absolute path to the shared folder (non-Windows SMB support) -# SMB_SRV alternative IP address of the SMB server (default is 10.0.2.4) -# HOSTFWD map guest port to host port for host-to-guest access -# (format: protocol:hostaddr:hostport-guestaddr:guestport) +# RESTRICTED if set to 1, only built-in services are available +# NET base IP address of the virtual network +# MASK netmask of the virtual network +# HOST IP address of the DHCP and TFTP server +# HOSTNAME DHCP client hostname +# DHCPSTART start address of DHCP pool +# DNS IP address of the virtual DNS server +# BOOTFILE boot filename returned by DHCP +# TFTP_SRVNAME optional TFTP server name reported by DHCP +# DNSSEARCH comma-separated list of DNS suffixes to search (DHCP extension) +# SMB_EXPORT absolute path to the shared folder (non-Windows SMB support) +# SMB_SRV alternative IP address of the SMB server (default is 10.0.2.4) +# HOSTFWD map guest port to host port for host-to-guest access +# (format: protocol:hostaddr:hostport-guestaddr:guestport) +# PKTLOG enable packet logging in text format (similar to vnet) # This is the default (classic slirp) setup # restricted = 0 @@ -37,8 +39,8 @@ # Host forwarding example (access guest SSH server from host port 12345) # hostfwd = tcp::12345-:22 +# Packet logging example +# pktlog = slirp-pktlog.txt + # Enable IPv6 support (libslirp only / using default Qemu setup) # ipv6_enabled = 1 - -# Enable packet logging in text format (similar to vnet) -# pktlog = slirp-pktlog.txt