/*
- * Copyright (c) 2008, 2011 Nicira Networks.
+ * Copyright (c) 2008, 2011 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "compiler.h"
#include "util.h"
-struct ofpbuf;
-
-/* LLC field values used for STP frames. */
-#define STP_LLC_SSAP 0x42
-#define STP_LLC_DSAP 0x42
-#define STP_LLC_CNTL 0x03
+struct dp_packet;
/* Bridge and port priorities that should be used by default. */
#define STP_DEFAULT_BRIDGE_PRIORITY 32768
/* Basic STP functionality. */
#define STP_MAX_PORTS 255
+void stp_init(void);
struct stp *stp_create(const char *name, stp_identifier bridge_id,
- void (*send_bpdu)(struct ofpbuf *bpdu, int port_no,
+ void (*send_bpdu)(struct dp_packet *bpdu, int port_no,
void *aux),
void *aux);
-void stp_destroy(struct stp *);
+struct stp *stp_ref(const struct stp *);
+void stp_unref(struct stp *);
void stp_tick(struct stp *, int ms);
void stp_set_bridge_id(struct stp *, stp_identifier bridge_id);
void stp_set_bridge_priority(struct stp *, uint16_t new_priority);
int stp_get_hello_time(const struct stp *);
int stp_get_max_age(const struct stp *);
int stp_get_forward_delay(const struct stp *);
+bool stp_check_and_reset_fdb_flush(struct stp *);
/* Obtaining STP ports. */
struct stp_port *stp_get_port(struct stp *, int port_no);
* The following diagram describes the various states and what they are
* allowed to do in OVS:
*
- * FWD LRN TX_BPDU RX_BPDU
- * --- --- ------- -------
- * Disabled Y - - -
- * Blocking - - - Y
- * Listening - - Y Y
- * Learning - Y Y Y
- * Forwarding Y Y Y Y
+ * FWD LRN TX_BPDU RX_BPDU FWD_BPDU
+ * --- --- ------- ------- --------
+ * Disabled Y - - - Y
+ * Blocking - - - Y -
+ * Listening - - Y Y Y
+ * Learning - Y Y Y Y
+ * Forwarding Y Y Y Y Y
+ *
+ *
+ * FWD: the port should forward any incoming non-stp-BPDU
+ * packets.
+ *
+ * LRN: the port should conduct MAC learning on packets received.
+ *
+ * TX_BPDU/RX_BPDU: the port could generate/consume bpdus.
+ *
+ * FWD_BPDU: the port should should always forward the BPDUS,
+ * whether they are generated by the port or received
+ * as incoming packets.
*
* Once again, note that the disabled state forwards traffic, which is
* likely different than the spec would indicate.
const char *stp_state_name(enum stp_state);
bool stp_forward_in_state(enum stp_state);
bool stp_learn_in_state(enum stp_state);
+bool stp_should_forward_bpdu(enum stp_state);
/* Role of an STP port. */
enum stp_role {
void stp_received_bpdu(struct stp_port *, const void *bpdu, size_t bpdu_size);
struct stp *stp_port_get_stp(struct stp_port *);
+void stp_port_set_name(struct stp_port *, const char *);
void stp_port_set_aux(struct stp_port *, void *);
void *stp_port_get_aux(struct stp_port *);
int stp_port_no(const struct stp_port *);
int stp_port_get_id(const struct stp_port *);
enum stp_state stp_port_get_state(const struct stp_port *);
enum stp_role stp_port_get_role(const struct stp_port *);
+void stp_port_get_counts(const struct stp_port *,
+ int *tx_count, int *rx_count, int *error_count);
void stp_port_enable(struct stp_port *);
void stp_port_disable(struct stp_port *);
void stp_port_set_priority(struct stp_port *, uint8_t new_priority);