[Spice-devel] [PATCH 36/39] NetWireInterface: redesign

Gerd Hoffmann kraxel at redhat.com
Tue May 18 08:43:13 PDT 2010


Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
---
 server/red_tunnel_worker.h |    2 +-
 server/reds.c              |   14 ++++++++------
 server/reds.h              |    4 ++++
 server/vd_interface.h      |   29 +++++++++++++++++------------
 4 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/server/red_tunnel_worker.h b/server/red_tunnel_worker.h
index 9f3a61c..d4bf4b7 100755
--- a/server/red_tunnel_worker.h
+++ b/server/red_tunnel_worker.h
@@ -24,6 +24,6 @@
 
 #include "vd_interface.h"
 
-void *red_tunnel_attach(SpiceCoreInterface *core_interface, NetWireInterface *vlan_interface);
+void *red_tunnel_attach(SpiceCoreInterface *core_interface, SpiceNetWireInstance *sin);
 
 #endif
diff --git a/server/reds.c b/server/reds.c
index 891cd74..4fc0392 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3521,20 +3521,22 @@ __visible__ int spice_server_add_interface(SpiceServer *s,
         }
         attach_to_red_agent(SPICE_CONTAINEROF(sin, SpiceVDIPortInstance, base));
 
-    } else if (strcmp(interface->type, VD_INTERFACE_NET_WIRE) == 0) {
+    } else if (strcmp(interface->type, SPICE_INTERFACE_NET_WIRE) == 0) {
 #ifdef HAVE_SLIRP
-        NetWireInterface * net_wire = (NetWireInterface *)interface;
-        red_printf("VD_INTERFACE_NET_WIRE");
+        SpiceNetWireInstance *net;
+        red_printf("SPICE_INTERFACE_NET_WIRE");
         if (red_tunnel) {
             red_printf("net wire already attached");
             return -1;
         }
-        if (interface->major_version != VD_INTERFACE_NET_WIRE_MAJOR ||
-            interface->minor_version < VD_INTERFACE_NET_WIRE_MINOR) {
+        if (interface->major_version != SPICE_INTERFACE_NET_WIRE_MAJOR ||
+            interface->minor_version < SPICE_INTERFACE_NET_WIRE_MINOR) {
             red_printf("unsuported net wire interface");
             return -1;
         }
-        red_tunnel = red_tunnel_attach(core, net_wire);
+        net = SPICE_CONTAINEROF(sin, SpiceNetWireInstance, base);
+        net->st = spice_new0(SpiceNetWireState, 1);
+        red_tunnel = red_tunnel_attach(core, net);
 #else
         red_printf("unsupported net wire interface");
         return -1;
diff --git a/server/reds.h b/server/reds.h
index 78581f8..b508283 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -75,6 +75,10 @@ struct QXLState {
     struct RedDispatcher  *dispatcher;
 };
 
+struct SpiceNetWireState {
+    int dummy;
+};
+
 void reds_desable_mm_timer();
 void reds_enable_mm_timer();
 void reds_update_mm_timer(uint32_t mm_time);
diff --git a/server/vd_interface.h b/server/vd_interface.h
index 5d50ee9..aaa1ca8 100644
--- a/server/vd_interface.h
+++ b/server/vd_interface.h
@@ -365,23 +365,28 @@ struct SpiceVDIPortInstance {
 
 void spice_server_vdi_port_wakeup(SpiceVDIPortInstance *sin);
 
-#define VD_INTERFACE_NET_WIRE "net_wire"
-#define VD_INTERFACE_NET_WIRE_MAJOR 1
-#define VD_INTERFACE_NET_WIRE_MINOR 1
-
-typedef struct NetWireInterface NetWireInterface;
-typedef void (*net_wire_packet_route_proc_t)(void *opaque, const uint8_t *pkt, int pkt_len);
+#define SPICE_INTERFACE_NET_WIRE "net_wire"
+#define SPICE_INTERFACE_NET_WIRE_MAJOR 1
+#define SPICE_INTERFACE_NET_WIRE_MINOR 1
+typedef struct SpiceNetWireInterface SpiceNetWireInterface;
+typedef struct SpiceNetWireInstance SpiceNetWireInstance;
+typedef struct SpiceNetWireState SpiceNetWireState;
 
 struct NetWireInterface {
     SpiceBaseInterface base;
 
-    struct in_addr (*get_ip)(NetWireInterface *vlan);
-    int (*can_send_packet)(NetWireInterface *vlan);
-    void (*send_packet)(NetWireInterface *vlan, const uint8_t *buf, int size);
-    VDObjectRef (*register_route_packet)(NetWireInterface *vlan, net_wire_packet_route_proc_t proc,
-                                         void *opaque);
-    void (*unregister_route_packet)(NetWireInterface *vlan, VDObjectRef proc);
+    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 SpiceNetWireInstance {
+    SpiceBaseInstance base;
+    SpiceNetWireState *st;
+};
+
+void spice_server_net_wire_recv_packet(SpiceNetWireInstance *sin,
+                                       const uint8_t *pkt, int len);
+
 #endif
 
-- 
1.6.6.1



More information about the Spice-devel mailing list