From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42039 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ORS4X-00038t-GI for qemu-devel@nongnu.org; Wed, 23 Jun 2010 11:41:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ORS4V-0006fj-Gd for qemu-devel@nongnu.org; Wed, 23 Jun 2010 11:41:05 -0400 Received: from mail-iw0-f173.google.com ([209.85.214.173]:43600) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ORS4V-0006aC-CT for qemu-devel@nongnu.org; Wed, 23 Jun 2010 11:41:03 -0400 Received: by mail-iw0-f173.google.com with SMTP id 10so3530042iwn.4 for ; Wed, 23 Jun 2010 08:41:03 -0700 (PDT) From: Miguel Di Ciurcio Filho Date: Wed, 23 Jun 2010 12:40:02 -0300 Message-Id: <1277307603-28960-7-git-send-email-miguel.filho@gmail.com> In-Reply-To: <1277307603-28960-1-git-send-email-miguel.filho@gmail.com> References: <1277307603-28960-1-git-send-email-miguel.filho@gmail.com> Subject: [Qemu-devel] [PATCH 6/7] net: slirp: introduce info_dict List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: avi@redhat.com, Miguel Di Ciurcio Filho , armbru@redhat.com, lcapitulino@redhat.com Signed-off-by: Miguel Di Ciurcio Filho --- 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