X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ofproto%2Fpktbuf.c;h=71be34a61fa433539e456ca95c9befd21f1ba252;hb=bd2ccd1280b7b2b78e14abc78a4a07286a2f6c8d;hp=23c01e0326c6e3da01ce075da79e03bb60dfe002;hpb=90bf1e0732ac9b11dd51ca856b635cac1f0269c1;p=sliver-openvswitch.git diff --git a/ofproto/pktbuf.c b/ofproto/pktbuf.c index 23c01e032..71be34a61 100644 --- a/ofproto/pktbuf.c +++ b/ofproto/pktbuf.c @@ -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. @@ -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; +}