Change the passing of callbacks to a struct in case this needs to be extended in the future.

This commit is contained in:
Andrew Thompson 2007-03-09 19:34:55 +00:00
parent 031fcf925c
commit e5bda9fb3a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=167379
3 changed files with 14 additions and 6 deletions

View File

@ -2087,8 +2087,7 @@ DECLARE_MODULE(bridgestp, bstp_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
MODULE_VERSION(bridgestp, 1);
void
bstp_attach(struct bstp_state *bs, bstp_state_cb_t state_callback,
bstp_rtage_cb_t rtage_callback)
bstp_attach(struct bstp_state *bs, struct bstp_cb_ops *cb)
{
BSTP_LOCK_INIT(bs);
callout_init_mtx(&bs->bs_bstpcallout, &bs->bs_mtx, 0);
@ -2102,8 +2101,8 @@ bstp_attach(struct bstp_state *bs, bstp_state_cb_t state_callback,
bs->bs_migration_delay = BSTP_DEFAULT_MIGRATE_DELAY;
bs->bs_txholdcount = BSTP_DEFAULT_HOLD_COUNT;
bs->bs_protover = BSTP_PROTO_RSTP;
bs->bs_state_cb = state_callback;
bs->bs_rtage_cb = rtage_callback;
bs->bs_state_cb = cb->bcb_state;
bs->bs_rtage_cb = cb->bcb_rtage;
getmicrotime(&bs->bs_last_tc_time);

View File

@ -185,6 +185,10 @@
*/
typedef void (*bstp_state_cb_t)(struct ifnet *, int);
typedef void (*bstp_rtage_cb_t)(struct ifnet *, int);
struct bstp_cb_ops {
bstp_state_cb_t bcb_state;
bstp_rtage_cb_t bcb_rtage;
};
/*
* Because BPDU's do not make nicely aligned structures, two different
@ -365,7 +369,7 @@ extern const uint8_t bstp_etheraddr[];
extern void (*bstp_linkstate_p)(struct ifnet *ifp, int state);
void bstp_attach(struct bstp_state *, bstp_state_cb_t, bstp_rtage_cb_t);
void bstp_attach(struct bstp_state *, struct bstp_cb_ops *);
void bstp_detach(struct bstp_state *);
void bstp_init(struct bstp_state *);
void bstp_stop(struct bstp_state *);

View File

@ -318,6 +318,11 @@ static int bridge_ip6_checkbasic(struct mbuf **mp);
static int bridge_fragment(struct ifnet *, struct mbuf *,
struct ether_header *, int, struct llc *);
static struct bstp_cb_ops bridge_ops = {
.bcb_state = bridge_state_change,
.bcb_rtage = bridge_rtable_expire
};
SYSCTL_DECL(_net_link);
SYSCTL_NODE(_net_link, IFT_BRIDGE, bridge, CTLFLAG_RW, 0, "Bridge");
@ -583,7 +588,7 @@ bridge_clone_create(struct if_clone *ifc, int unit, caddr_t params)
mtx_unlock(&bridge_list_mtx);
}
bstp_attach(&sc->sc_stp, bridge_state_change, bridge_rtable_expire);
bstp_attach(&sc->sc_stp, &bridge_ops);
ether_ifattach(ifp, eaddr);
/* Now undo some of the damage... */
ifp->if_baudrate = 0;