[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/10] net: Refactor net_client_types
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH 08/10] net: Refactor net_client_types |
Date: |
Wed, 20 Jul 2011 12:20:20 +0200 |
Position entries of net_client_types according to the corresponding
values of NET_CLIENT_TYPE_*. The array size is now defined by
NET_CLIENT_TYPE_MAX. This will allow to obtain entries based on type
value in later patches.
At this chance rename NET_CLIENT_TYPE_SLIRP to NET_CLIENT_TYPE_USER for
the sake of consistency.
CC: Markus Armbruster <address@hidden>
Signed-off-by: Jan Kiszka <address@hidden>
---
net.c | 30 ++++++++++++++++++------------
net.h | 6 ++++--
net/slirp.c | 2 +-
3 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/net.c b/net.c
index 43627ad..05fc685 100644
--- a/net.c
+++ b/net.c
@@ -830,14 +830,15 @@ static const struct {
const char *type;
net_client_init_func init;
QemuOptDesc desc[NET_MAX_DESC];
-} net_client_types[] = {
- {
+} net_client_types[NET_CLIENT_TYPE_MAX] = {
+ [NET_CLIENT_TYPE_NONE] = {
.type = "none",
.desc = {
NET_COMMON_PARAMS_DESC,
{ /* end of list */ }
},
- }, {
+ },
+ [NET_CLIENT_TYPE_NIC] = {
.type = "nic",
.init = net_init_nic,
.desc = {
@@ -866,8 +867,9 @@ static const struct {
},
{ /* end of list */ }
},
+ },
#ifdef CONFIG_SLIRP
- }, {
+ [NET_CLIENT_TYPE_USER] = {
.type = "user",
.init = net_init_slirp,
.desc = {
@@ -927,8 +929,9 @@ static const struct {
},
{ /* end of list */ }
},
+ },
#endif
- }, {
+ [NET_CLIENT_TYPE_TAP] = {
.type = "tap",
.init = net_init_tap,
.desc = {
@@ -975,7 +978,8 @@ static const struct {
#endif /* _WIN32 */
{ /* end of list */ }
},
- }, {
+ },
+ [NET_CLIENT_TYPE_SOCKET] = {
.type = "socket",
.init = net_init_socket,
.desc = {
@@ -1003,8 +1007,9 @@ static const struct {
},
{ /* end of list */ }
},
+ },
#ifdef CONFIG_VDE
- }, {
+ [NET_CLIENT_TYPE_VDE] = {
.type = "vde",
.init = net_init_vde,
.desc = {
@@ -1028,8 +1033,9 @@ static const struct {
},
{ /* end of list */ }
},
+ },
#endif
- }, {
+ [NET_CLIENT_TYPE_DUMP] = {
.type = "dump",
.init = net_init_dump,
.desc = {
@@ -1046,7 +1052,6 @@ static const struct {
{ /* end of list */ }
},
},
- { /* end of list */ }
};
int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
@@ -1094,8 +1099,9 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int
is_netdev)
name = qemu_opt_get(opts, "name");
}
- for (i = 0; net_client_types[i].type != NULL; i++) {
- if (!strcmp(net_client_types[i].type, type)) {
+ for (i = 0; i < NET_CLIENT_TYPE_MAX; i++) {
+ if (net_client_types[i].type != NULL &&
+ !strcmp(net_client_types[i].type, type)) {
VLANState *vlan = NULL;
int ret;
@@ -1330,7 +1336,7 @@ void net_check_clients(void)
case NET_CLIENT_TYPE_NIC:
has_nic = 1;
break;
- case NET_CLIENT_TYPE_SLIRP:
+ case NET_CLIENT_TYPE_USER:
case NET_CLIENT_TYPE_TAP:
case NET_CLIENT_TYPE_SOCKET:
case NET_CLIENT_TYPE_VDE:
diff --git a/net.h b/net.h
index 5b883a9..4fdd942 100644
--- a/net.h
+++ b/net.h
@@ -31,11 +31,13 @@ typedef struct NICConf {
typedef enum {
NET_CLIENT_TYPE_NONE,
NET_CLIENT_TYPE_NIC,
- NET_CLIENT_TYPE_SLIRP,
+ NET_CLIENT_TYPE_USER,
NET_CLIENT_TYPE_TAP,
NET_CLIENT_TYPE_SOCKET,
NET_CLIENT_TYPE_VDE,
- NET_CLIENT_TYPE_DUMP
+ NET_CLIENT_TYPE_DUMP,
+
+ NET_CLIENT_TYPE_MAX
} net_client_type;
typedef void (NetPoll)(VLANClientState *, bool enable);
diff --git a/net/slirp.c b/net/slirp.c
index 71e2577..157b80a 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -128,7 +128,7 @@ static void net_slirp_cleanup(VLANClientState *nc)
}
static NetClientInfo net_slirp_info = {
- .type = NET_CLIENT_TYPE_SLIRP,
+ .type = NET_CLIENT_TYPE_USER,
.size = sizeof(SlirpState),
.receive = net_slirp_receive,
.cleanup = net_slirp_cleanup,
--
1.7.3.4
- [Qemu-devel] [PATCH 00/10] [RESEND] Various net and slirp fixes & enhancements, Jan Kiszka, 2011/07/20
- [Qemu-devel] [PATCH 01/10] slirp: Fix restricted mode, Jan Kiszka, 2011/07/20
- [Qemu-devel] [PATCH 02/10] slirp: Canonicalize restrict syntax, Jan Kiszka, 2011/07/20
- [Qemu-devel] [PATCH 05/10] slirp: Put forked exec into separate process group, Jan Kiszka, 2011/07/20
- [Qemu-devel] [PATCH 04/10] slirp: Replace m_freem with m_free, Jan Kiszka, 2011/07/20
- [Qemu-devel] [PATCH 07/10] net: Improve layout of 'info network', Jan Kiszka, 2011/07/20
- [Qemu-devel] [PATCH 08/10] net: Refactor net_client_types,
Jan Kiszka <=
- [Qemu-devel] [PATCH 09/10] net: Dump client type 'info network', Jan Kiszka, 2011/07/20
- [Qemu-devel] [PATCH 03/10] slirp: Strictly associate DHCP/BOOTP and TFTP with virtual host, Jan Kiszka, 2011/07/20
- [Qemu-devel] [PATCH 06/10] slirp: Forward ICMP echo requests via unprivileged sockets, Jan Kiszka, 2011/07/20
- [Qemu-devel] [PATCH 10/10] net: Consistently use qemu_macaddr_default_if_unset, Jan Kiszka, 2011/07/20
- Re: [Qemu-devel] [PATCH 00/10] [RESEND] Various net and slirp fixes & enhancements, Markus Armbruster, 2011/07/22
- Re: [Qemu-devel] [PATCH 00/10] [RESEND] Various net and slirp fixes & enhancements, Anthony Liguori, 2011/07/23