use struct tun_pi in read/write to pltap
authorGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Sat, 6 Jul 2013 17:36:10 +0000 (19:36 +0200)
committerGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Sat, 6 Jul 2013 17:36:10 +0000 (19:36 +0200)
lib/netdev-pltap.c

index 26a8a05..0c49265 100644 (file)
@@ -456,9 +456,9 @@ static int
 netdev_rx_pltap_recv(struct netdev_rx *rx_, void *buffer, size_t size)
 {
     struct netdev_rx_pltap *rx = netdev_rx_pltap_cast(rx_);
-    char prefix[4];
+    struct tun_pi pi;
     struct iovec iov[2] = {
-        { .iov_base = prefix, .iov_len = 4 },
+        { .iov_base = &pi, .iov_len = sizeof(pi) },
        { .iov_base = buffer, .iov_len = size }
     };
     for (;;) {
@@ -496,9 +496,9 @@ netdev_pltap_send(struct netdev *netdev_, const void *buffer, size_t size)
 {
     struct netdev_pltap *dev = 
        netdev_pltap_cast(netdev_);
-    char prefix[4] = { 0, 0, 8, 6 };
+    struct tun_pi pi = { 0, 0x86 };
     struct iovec iov[2] = {
-        { .iov_base = prefix, .iov_len = 4 },
+        { .iov_base = &pi, .iov_len = sizeof(pi) },
        { .iov_base = (char*) buffer, .iov_len = size }
     };
     if (dev->fd < 0)