Some work on the slirp networking code.
- Added support for optional TFTP server name in builtin slirp and libslirp. - Added default domain name for libslirp.
This commit is contained in:
parent
55d7488be6
commit
5376f129ee
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user