summaryrefslogtreecommitdiff
path: root/lib/rstp.h
diff options
context:
space:
mode:
authorJarno Rajahalme <jrajahalme@nicira.com>2014-08-22 09:01:35 -0700
committerJarno Rajahalme <jrajahalme@nicira.com>2014-09-09 11:45:44 -0700
commit8fb76a0b7b821a74cca8d43a262e714a4148fd0e (patch)
tree6672035f8c15cef9016e1b4213aff5449d5bc402 /lib/rstp.h
parentcc33c223e2576e3eccf2b7e659b8934f2c9ca9b0 (diff)
downloadopenvswitch-8fb76a0b7b821a74cca8d43a262e714a4148fd0e.tar.gz
lib/rstp: Inline trivial predicate functions.
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Daniele Venturino <daniele.venturino@m3s.it>
Diffstat (limited to 'lib/rstp.h')
-rw-r--r--lib/rstp.h42
1 files changed, 39 insertions, 3 deletions
diff --git a/lib/rstp.h b/lib/rstp.h
index 5d7c7f481..0e8d1010e 100644
--- a/lib/rstp.h
+++ b/lib/rstp.h
@@ -119,9 +119,9 @@ struct rstp_port;
struct ofproto_rstp_settings;
const char *rstp_state_name(enum rstp_state);
-bool rstp_forward_in_state(enum rstp_state);
-bool rstp_learn_in_state(enum rstp_state);
-bool rstp_should_manage_bpdu(enum rstp_state state);
+static inline bool rstp_forward_in_state(enum rstp_state);
+static inline bool rstp_learn_in_state(enum rstp_state);
+static inline bool rstp_should_manage_bpdu(enum rstp_state state);
const char *rstp_port_role_name(enum rstp_port_role);
void rstp_init(void);
@@ -198,4 +198,40 @@ enum rstp_port_role rstp_port_get_role(const struct rstp_port *);
void rstp_port_get_counts(const struct rstp_port *, int *tx_count,
int *rx_count, int *error_count, int *uptime);
void * rstp_port_get_aux(struct rstp_port *);
+
+/* Inline functions. */
+/* Returns true if 'state' is one in which BPDU packets should be received
+ * and transmitted on a port, false otherwise.
+ */
+static inline bool
+rstp_should_manage_bpdu(enum rstp_state state)
+{
+ return (state == RSTP_DISCARDING || state == RSTP_LEARNING ||
+ state == RSTP_FORWARDING);
+}
+
+/* Returns true if 'state' is one in which packets received on a port should
+ * be forwarded, false otherwise.
+ *
+ * Returns true if 'state' is RSTP_DISABLED, since presumably in that case the
+ * port should still work, just not have RSTP applied to it.
+ */
+static inline bool
+rstp_forward_in_state(enum rstp_state state)
+{
+ return (state == RSTP_DISABLED || state == RSTP_FORWARDING);
+}
+
+/* Returns true if 'state' is one in which MAC learning should be done on
+ * packets received on a port, false otherwise.
+ *
+ * Returns true if 'state' is RSTP_DISABLED, since presumably in that case the
+ * port should still work, just not have RSTP applied to it. */
+static inline bool
+rstp_learn_in_state(enum rstp_state state)
+{
+ return (state == RSTP_DISABLED || state == RSTP_LEARNING ||
+ state == RSTP_FORWARDING);
+}
+
#endif /* rstp.h */