Signed-off-by: Miguel Di Ciurcio Filho <miguel.fi...@gmail.com> --- net/slirp.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/net/slirp.c b/net/slirp.c index b41c60a..9549711 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -32,6 +32,9 @@ #include "monitor.h" #include "sysemu.h" #include "qemu_socket.h" +#include "qdict.h" +#include "qbool.h" +#include "qstring.h" #include "slirp/libslirp.h" static int get_str_sep(char *buf, int buf_size, const char **pp, int sep) @@ -243,6 +246,26 @@ static int net_slirp_init(VLANState *vlan, const char *model, snprintf(nc->info_str, sizeof(nc->info_str), "net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n'); + nc->info_dict = qdict_new(); + qdict_put(nc->info_dict, "net", qstring_from_str(inet_ntoa(net))); + qdict_put(nc->info_dict, "host", qstring_from_str(inet_ntoa(host))); + qdict_put(nc->info_dict, "dns", qstring_from_str(inet_ntoa(dns))); + qdict_put(nc->info_dict, "dhcpstart", qstring_from_str(inet_ntoa(dhcp))); + qdict_put(nc->info_dict, "netmask", qstring_from_str(inet_ntoa(mask))); + qdict_put(nc->info_dict, "restrict", qbool_from_int(restricted)); + + if (vhostname) { + qdict_put(nc->info_dict, "hostname", qstring_from_str(vhostname)); + } + + if (tftp_export) { + qdict_put(nc->info_dict, "tftp", qstring_from_str(tftp_export)); + } + + if (bootfile) { + qdict_put(nc->info_dict, "bootfile", qstring_from_str(bootfile)); + } + s = DO_UPCAST(SlirpState, nc, nc); s->slirp = slirp_init(restricted, net, mask, host, vhostname, @@ -252,12 +275,20 @@ static int net_slirp_init(VLANState *vlan, const char *model, for (config = slirp_configs; config; config = config->next) { if (config->flags & SLIRP_CFG_HOSTFWD) { if (slirp_hostfwd(s, config->str, - config->flags & SLIRP_CFG_LEGACY) < 0) + config->flags & SLIRP_CFG_LEGACY) < 0) { goto error; + } else { + qdict_put(nc->info_dict, "hostfwd", + qstring_from_str(config->str)); + } } else { if (slirp_guestfwd(s, config->str, - config->flags & SLIRP_CFG_LEGACY) < 0) + config->flags & SLIRP_CFG_LEGACY) < 0) { goto error; + } else { + qdict_put(nc->info_dict, "guestfwd", + qstring_from_str(config->str)); + } } } #ifndef _WIN32 @@ -265,8 +296,13 @@ static int net_slirp_init(VLANState *vlan, const char *model, smb_export = legacy_smb_export; } if (smb_export) { - if (slirp_smb(s, smb_export, smbsrv) < 0) + if (slirp_smb(s, smb_export, smbsrv) < 0) { goto error; + } else { + qdict_put(nc->info_dict, "smb", qstring_from_str(smb_export)); + qdict_put(nc->info_dict, "smbserver", + qstring_from_str(inet_ntoa(smbsrv))); + } } #endif -- 1.7.1