summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2010-05-19 11:44:40 +0200
committerGerd Hoffmann <kraxel@redhat.com>2010-05-19 11:44:40 +0200
commitf67b2e74880ff17592acf739b91097be3cec9903 (patch)
tree662ef9abdb174ea17e35b7d9eb8edbb8e5159b37
parent9204a5903ab7a2cc39f1c078ce503d337a815be0 (diff)
downloadspice-f67b2e74880ff17592acf739b91097be3cec9903.tar.gz
spice-f67b2e74880ff17592acf739b91097be3cec9903.tar.xz
spice-f67b2e74880ff17592acf739b91097be3cec9903.zip
complete NetWireInterface redesign, make red_tunnel_worker.c build.
-rw-r--r--server/red_tunnel_worker.c25
-rw-r--r--server/reds.h3
-rw-r--r--server/spice-experimental.h8
3 files changed, 20 insertions, 16 deletions
diff --git a/server/red_tunnel_worker.c b/server/red_tunnel_worker.c
index d4da0b3b..210de9d3 100644
--- a/server/red_tunnel_worker.c
+++ b/server/red_tunnel_worker.c
@@ -28,6 +28,8 @@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
+#include "spice.h"
+#include "spice-experimental.h"
#include "red_tunnel_worker.h"
#include "red_common.h"
#include <spice/protocol.h>
@@ -535,7 +537,8 @@ struct TunnelWorker {
TunnelChannel *channel;
SpiceCoreInterface *core_interface;
- NetWireInterface *vlan_interface;
+ SpiceNetWireInstance *sin;
+ SpiceNetWireInterface *sif;
RedSlirpNetworkInterface tunnel_interface;
RedSlirpNetworkInterface null_interface;
@@ -958,9 +961,10 @@ static TunneledBufferProcessQueue *tunnel_socket_alloc_simple_print_reply_proces
PROCESS_DIRECTION_TYPE_REPLY);
}
-static void tunnel_send_packet(void *opaque_tunnel, const uint8_t *pkt, int pkt_len)
+__visible__ void spice_server_net_wire_recv_packet(SpiceNetWireInstance *sin,
+ const uint8_t *pkt, int pkt_len)
{
- TunnelWorker *worker = (TunnelWorker *)opaque_tunnel;
+ TunnelWorker *worker = sin->st->worker;
ASSERT(worker);
if (worker->channel && worker->channel->base.migrate) {
@@ -971,12 +975,14 @@ static void tunnel_send_packet(void *opaque_tunnel, const uint8_t *pkt, int pkt_
}
void *red_tunnel_attach(SpiceCoreInterface *core_interface,
- NetWireInterface *vlan_interface)
+ SpiceNetWireInstance *sin)
{
TunnelWorker *worker = spice_new0(TunnelWorker, 1);
worker->core_interface = core_interface;
- worker->vlan_interface = vlan_interface;
+ worker->sin = sin;
+ worker->sin->st->worker = worker;
+ worker->sif = SPICE_CONTAINEROF(sin->base.sif, SpiceNetWireInterface, base);
worker->tunnel_interface.base.slirp_can_output = qemu_can_output;
worker->tunnel_interface.base.slirp_output = qemu_output;
@@ -1014,12 +1020,9 @@ void *red_tunnel_attach(SpiceCoreInterface *core_interface,
ring_init(&worker->services);
reds_register_channel(&worker->channel_interface);
- net_slirp_init(worker->vlan_interface->get_ip(worker->vlan_interface),
+ net_slirp_init(worker->sif->get_ip(worker->sin),
TRUE,
&worker->null_interface.base);
- if (!vlan_interface->register_route_packet(vlan_interface, tunnel_send_packet, worker)) {
- red_error("register route packet failed");
- }
return worker;
}
@@ -2892,13 +2895,13 @@ static void tunnel_channel_release_pipe_item(RedChannel *channel, PipeItem *item
static int qemu_can_output(SlirpUsrNetworkInterface *usr_interface)
{
TunnelWorker *worker = ((RedSlirpNetworkInterface *)usr_interface)->worker;
- return worker->vlan_interface->can_send_packet(worker->vlan_interface);
+ return worker->sif->can_send_packet(worker->sin);
}
static void qemu_output(SlirpUsrNetworkInterface *usr_interface, const uint8_t *pkt, int pkt_len)
{
TunnelWorker *worker = ((RedSlirpNetworkInterface *)usr_interface)->worker;
- worker->vlan_interface->send_packet(worker->vlan_interface, pkt, pkt_len);
+ worker->sif->send_packet(worker->sin, pkt, pkt_len);
}
static int null_tunnel_socket_connect(SlirpUsrNetworkInterface *usr_interface,
diff --git a/server/reds.h b/server/reds.h
index b508283a..b9d53365 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -75,8 +75,9 @@ struct QXLState {
struct RedDispatcher *dispatcher;
};
+struct TunnelWorker;
struct SpiceNetWireState {
- int dummy;
+ struct TunnelWorker *worker;
};
void reds_desable_mm_timer();
diff --git a/server/spice-experimental.h b/server/spice-experimental.h
index 0b732bc8..aede4ce1 100644
--- a/server/spice-experimental.h
+++ b/server/spice-experimental.h
@@ -31,12 +31,12 @@ typedef struct SpiceNetWireInterface SpiceNetWireInterface;
typedef struct SpiceNetWireInstance SpiceNetWireInstance;
typedef struct SpiceNetWireState SpiceNetWireState;
-struct NetWireInterface {
+struct SpiceNetWireInterface {
SpiceBaseInterface base;
- struct in_addr (*get_ip)(SpiceNetWireInterface *sin);
- int (*can_send_packet)(SpiceNetWireInterface *sin);
- void (*send_packet)(SpiceNetWireInterface *sin, const uint8_t *pkt, int len);
+ struct in_addr (*get_ip)(SpiceNetWireInstance *sin);
+ int (*can_send_packet)(SpiceNetWireInstance *sin);
+ void (*send_packet)(SpiceNetWireInstance *sin, const uint8_t *pkt, int len);
};
struct SpiceNetWireInstance {