struct ofproto *ofproto_lookup(const char *name);
struct ofport *ofproto_get_port(const struct ofproto *, uint16_t ofp_port);
+/* Assigns CLS to each classifier table, in turn, in OFPROTO.
+ *
+ * All parameters are evaluated multiple times. */
+#define OFPROTO_FOR_EACH_TABLE(CLS, OFPROTO) \
+ for ((CLS) = (OFPROTO)->tables; \
+ (CLS) < &(OFPROTO)->tables[(OFPROTO)->n_tables]; \
+ (CLS)++)
+
+
/* An OpenFlow port within a "struct ofproto".
*
* With few exceptions, ofproto implementations may look at these fields but
struct ofproto **ofprotop)
{
const struct ofproto_class *class;
+ struct classifier *table;
struct ofproto *ofproto;
int n_tables;
int error;
- int i;
*ofprotop = NULL;
assert(n_tables >= 1 && n_tables <= 255);
ofproto->n_tables = n_tables;
ofproto->tables = xmalloc(n_tables * sizeof *ofproto->tables);
- for (i = 0; i < n_tables; i++) {
- classifier_init(&ofproto->tables[i]);
+ OFPROTO_FOR_EACH_TABLE (table, ofproto) {
+ classifier_init(table);
}
ofproto->datapath_id = pick_datapath_id(ofproto);
}
group = ofopgroup_create(ofproto);
- for (table = ofproto->tables; table < &ofproto->tables[ofproto->n_tables];
- table++) {
+ OFPROTO_FOR_EACH_TABLE (table, ofproto) {
struct rule *rule, *next_rule;
struct cls_cursor cursor;
static void
ofproto_destroy__(struct ofproto *ofproto)
{
- size_t i;
+ struct classifier *table;
assert(list_is_empty(&ofproto->pending));
hmap_destroy(&ofproto->ports);
shash_destroy(&ofproto->port_by_name);
- for (i = 0; i < ofproto->n_tables; i++) {
- assert(classifier_is_empty(&ofproto->tables[i]));
- classifier_destroy(&ofproto->tables[i]);
+ OFPROTO_FOR_EACH_TABLE (table, ofproto) {
+ assert(classifier_is_empty(table));
+ classifier_destroy(table);
}
free(ofproto->tables);
{
struct classifier *cls;
- for (cls = &p->tables[0]; cls < &p->tables[p->n_tables]; cls++) {
+ OFPROTO_FOR_EACH_TABLE (cls, p) {
struct cls_cursor cursor;
struct rule *rule;