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.


Fix to NE2000, now it is offcically working
[palacios-OLD.git] / palacios / include / palacios / vmm_ethernet.h
index f7405fc..f5e9822 100644 (file)
 
 #include <palacios/vmm.h>
 
+
+struct nic_statistics {
+    uint64_t tx_pkts;
+    uint64_t tx_bytes;
+    uint64_t tx_dropped;
+       
+    uint64_t rx_pkts;
+    uint64_t rx_bytes;
+    uint64_t rx_dropped;
+
+    uint32_t interrupts;
+};
+    
 static inline int is_multicast_ethaddr(const uint8_t * addr)
 {
     V3_ASSERT(ETH_ALEN == 6);
@@ -66,6 +79,37 @@ static inline int compare_ether_hdr(const uint8_t * hdr1, const uint8_t * hdr2)
              (a32[1] ^ b32[1]) | (a32[2] ^ b32[2]);
 }
 
+/* AA:BB:CC:DD:EE:FF */
+static inline int str2mac(char * macstr, uint8_t * mac){
+    char hex[2], *s = macstr;
+    int i = 0;
+
+    while(s){
+       memcpy(hex, s, 2);
+       mac[i++] = (char)atox(hex);     
+       if (i == ETH_ALEN) return 0;
+       s=strchr(s, ':');
+       if(s) s++;
+    }
+
+    return -1;
+}
+
+
+/* generate random ethernet address */
+static inline void random_ethaddr(uint8_t * addr)
+{
+    uint64_t val;
+
+    /* using current rdtsc as random number */
+    rdtscll(val);
+    *(uint64_t *)addr = val;
+       
+    addr [0] &= 0xfe;  /* clear multicast bit */
+    addr [0] |= 0x02;  /* set local assignment bit (IEEE802) */
+}
+
+
 #endif
 
 #endif