/*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
+ * 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.
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;
*
* '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'. */
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;
+}