+/* Number of implemented OpenFlow tables. */
+enum { N_TABLES = 255 };
+enum { TBL_INTERNAL = N_TABLES - 1 }; /* Used for internal hidden rules. */
+BUILD_ASSERT_DECL(N_TABLES >= 2 && N_TABLES <= 255);
+
+\f
+/* struct rule_dpif has struct rule as it's first member. */
+#define RULE_CAST(RULE) ((struct rule *)RULE)
+
+static inline void rule_dpif_ref(struct rule_dpif *rule)
+{
+ if (rule) {
+ ofproto_rule_ref(RULE_CAST(rule));
+ }
+}
+
+static inline void rule_dpif_unref(struct rule_dpif *rule)
+{
+ if (rule) {
+ ofproto_rule_unref(RULE_CAST(rule));
+ }
+}
+
+static inline bool rule_dpif_is_fail_open(const struct rule_dpif *rule)
+{
+ return is_fail_open_rule(RULE_CAST(rule));
+}
+
+static inline bool rule_dpif_is_table_miss(const struct rule_dpif *rule)
+{
+ return rule_is_table_miss(RULE_CAST(rule));
+}
+
+/* Returns true if 'rule' is an internal rule, false otherwise. */
+static inline bool rule_dpif_is_internal(const struct rule_dpif *rule)
+{
+ return RULE_CAST(rule)->table_id == TBL_INTERNAL;
+}
+
+#undef RULE_CAST
+