fix showmacs target
[sliver-openvswitch.git] / ofproto / pktbuf.c
index 23c01e0..902b19d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -120,7 +120,7 @@ pktbuf_save(struct pktbuf *pb, const void *buffer, size_t buffer_size,
         p->cookie = 0;
     }
     p->buffer = ofpbuf_clone_data_with_headroom(buffer, buffer_size,
-                                                sizeof(struct ofp_packet_in));
+                                                sizeof(struct ofp10_packet_in));
 
 
     p->timeout = time_msec() + OVERWRITE_MSECS;
@@ -165,7 +165,7 @@ pktbuf_get_null(void)
  *
  * 'in_port' may be NULL if the input port is not of interest.
  *
- * A returned packet will have at least sizeof(struct ofp_packet_in) bytes of
+ * A returned packet will have at least sizeof(struct ofp10_packet_in) bytes of
  * headroom.
  *
  * On failure, stores NULL in in '*bufferp' and UINT16_MAX in '*in_port'. */
@@ -232,3 +232,23 @@ pktbuf_discard(struct pktbuf *pb, uint32_t id)
         p->buffer = NULL;
     }
 }
+
+/* Returns the number of packets buffered in 'pb'.  Returns 0 if 'pb' is
+ * null. */
+unsigned int
+pktbuf_count_packets(const struct pktbuf *pb)
+{
+    int n = 0;
+
+    if (pb) {
+        int i;
+
+        for (i = 0; i < PKTBUF_CNT; i++) {
+            if (pb->packets[i].buffer) {
+                n++;
+            }
+        }
+    }
+
+    return n;
+}