#include "base.h"
#include "stpm.h"
#include "stp_vectors.h"
#define STATES { \
CHOOSE(DISABLED), \
CHOOSE(DETECTED), \
CHOOSE(DELAYED), \
CHOOSE(RESOLVED) \
}
#define GET_STATE_NAME STP_edge_get_state_name
#include "choose.h"
#define DEFAULT_LINK_DELAY 3
void
STP_edge_enter_state (STATE_MACH_T *s)
{
register PORT_T *port = s->owner.port;
switch (s->State) {
case BEGIN:
break;
case DISABLED:
port->operEdge = port->adminEdge;
port->wasInitBpdu = False;
port->lnkWhile = 0;
port->portEnabled = False;
break;
case DETECTED:
port->portEnabled = True;
port->lnkWhile = port->LinkDelay;
port->operEdge = False;
break;
case DELAYED:
break;
case RESOLVED:
if (! port->wasInitBpdu) {
port->operEdge = port->adminEdge;
}
break;
}
}
Bool
STP_edge_check_conditions (STATE_MACH_T *s)
{
register PORT_T *port = s->owner.port;
if (!port->adminEnable) {
if (s->State == DISABLED)
return False;
else
return STP_hop_2_state (s, DISABLED);
}
switch (s->State) {
case BEGIN:
return STP_hop_2_state (s, DISABLED);
case DISABLED:
if (port->adminEnable) {
return STP_hop_2_state (s, DETECTED);
}
break;
case DETECTED:
return STP_hop_2_state (s, DELAYED);
case DELAYED:
if (port->wasInitBpdu) {
#ifdef STP_DBG
if (s->debug)
stp_trace ("port %s 'edge' resolved by BPDU", port->port_name);
#endif
return STP_hop_2_state (s, RESOLVED);
}
if (! port->lnkWhile) {
#ifdef STP_DBG
if (s->debug)
stp_trace ("port %s 'edge' resolved by timer", port->port_name);
#endif
return STP_hop_2_state (s, RESOLVED);
}
break;
case RESOLVED:
break;
}
return False;
}