Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Restructure of direct host network bridge.
[palacios.git] / palacios / src / interfaces / vmm_packet.c
index 10bdbda..b46325e 100644 (file)
@@ -16,7 +16,6 @@
  * This is free software.  You are permitted to use,
  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
  */
-
 #include <palacios/vmm.h>
 #include <palacios/vmm_debug.h>
 #include <palacios/vmm_types.h>
 
 static struct v3_packet_hooks * packet_hooks = 0;
 
-int V3_send_raw(const char * pkt, uint32_t len) {
-    if(packet_hooks != NULL && packet_hooks->send != NULL){
-       return packet_hooks->send(pkt, len, NULL);
-    }
+void V3_Init_Packet(struct v3_packet_hooks * hooks) {
+    packet_hooks = hooks;
+    PrintDebug("V3 raw packet interface inited\n");
 
-    return -1;
+    return;
 }
 
+struct v3_packet * v3_packet_connect(struct v3_vm_info * vm, 
+                                    const char * host_nic, 
+                                    const char * vm_mac,
+                                    int (*input)(struct v3_packet * packet, uint8_t * buf, uint32_t len),
+                                    void * guest_packet_data) {
+    struct v3_packet * packet = NULL;
 
-int V3_packet_add_recver(const char * mac, struct v3_vm_info * vm){
-    if(packet_hooks != NULL && packet_hooks->add_recver != NULL){
-        return packet_hooks->add_recver(mac, vm);
-    }
-
-    return -1;
-}
+    V3_ASSERT(packet_hooks != NULL);
+    V3_ASSERT(packet_hooks->connect != NULL);
 
+    packet = V3_Malloc(sizeof(struct v3_packet));
 
-int V3_packet_del_recver(const char * mac, struct v3_vm_info * vm){
-    if(packet_hooks != NULL && packet_hooks->del_recver != NULL){
-        return packet_hooks->del_recver(mac, vm);
+    memcpy(packet->dev_mac, vm_mac, ETH_ALEN);
+    packet->input = input;
+    packet->guest_packet_data = guest_packet_data;
+    if(packet_hooks->connect(packet, host_nic, vm->host_priv_data) != 0){
+       V3_Free(packet);
+       return NULL;
     }
 
-    return -1;
+    return packet;
 }
 
-void V3_Init_Packet(struct v3_packet_hooks * hooks) {
-    packet_hooks = hooks;
-    PrintDebug("V3 raw packet interface inited\n");
+int v3_packet_send(struct v3_packet * packet, uint8_t * buf, uint32_t len) {
+    V3_ASSERT(packet_hooks != NULL);
+    V3_ASSERT(packet_hooks->send != NULL);
+    
+    return packet_hooks->send(packet, buf, len);
+}
 
-    return;
+void v3_packet_close(struct v3_packet * packet) {
+    V3_ASSERT(packet_hooks != NULL);
+    V3_ASSERT(packet_hooks->close != NULL);
+    
+    packet_hooks->close(packet);
+    V3_Free(packet);
 }
+
+