+/* Returns the role of port 'p'. */
+enum stp_role
+stp_port_get_role(const struct stp_port *p)
+{
+ struct stp_port *root_port = stp_get_root_port(p->stp);
+
+ if (root_port && root_port->port_id == p->port_id) {
+ return STP_ROLE_ROOT;
+ } else if (stp_is_designated_port(p)) {
+ return STP_ROLE_DESIGNATED;
+ } else if (p->state == STP_DISABLED) {
+ return STP_ROLE_DISABLED;
+ } else {
+ return STP_ROLE_ALTERNATE;
+ }
+}
+
+/* Retrieves BPDU transmit and receive counts for 'p'. */
+void stp_port_get_counts(const struct stp_port *p,
+ int *tx_count, int *rx_count, int *error_count)
+{
+ *tx_count = p->tx_count;
+ *rx_count = p->rx_count;
+ *error_count = p->error_count;
+}
+