NetWireInterface: redesign

This commit is contained in:
Gerd Hoffmann 2010-05-18 14:11:25 +02:00
parent a8419b00dc
commit 5b0bc279c9
4 changed files with 30 additions and 19 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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