++*idxp;
return next(pa, idxp);
}
+
+/* Returns the number of non-null elements of 'pa'. */
+unsigned int
+port_array_count(const struct port_array *pa)
+{
+ unsigned int l1_idx, l2_idx, l3_idx;
+ unsigned int count;
+
+ count = 0;
+ for (l1_idx = 0; l1_idx < PORT_ARRAY_L1_SIZE; l1_idx++) {
+ struct port_array_l2 *l2 = pa->l1[l1_idx];
+ if (l2 != &l2_sentinel) {
+ for (l2_idx = 0; l2_idx < PORT_ARRAY_L2_SIZE; l2_idx++) {
+ struct port_array_l3 *l3 = l2->l2[l2_idx];
+ if (l3 != &l3_sentinel) {
+ for (l3_idx = 0; l3_idx < PORT_ARRAY_L3_SIZE; l3_idx++) {
+ if (l3->l3[l3_idx]) {
+ count++;
+ }
+ }
+ }
+ }
+ }
+ }
+ return count;
+}
-/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford
+/* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford
* Junior University
*
* We are making the OpenFlow specification and associated documentation
void port_array_set(struct port_array *, uint16_t idx, void *);
void *port_array_first(const struct port_array *, unsigned int *);
void *port_array_next(const struct port_array *, unsigned int *);
+unsigned int port_array_count(const struct port_array *);
#endif /* port-array.h */