MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bstp_send_bpdu

Function bstp_send_bpdu

freebsd/net/bridgestp.c:340–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338}
339
340static void
341bstp_send_bpdu(struct bstp_state *bs, struct bstp_port *bp,
342 struct bstp_cbpdu *bpdu)
343{
344 struct ifnet *ifp;
345 struct mbuf *m;
346 struct ether_header *eh;
347
348 BSTP_LOCK_ASSERT(bs);
349
350 ifp = bp->bp_ifp;
351
352 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
353 return;
354
355 m = m_gethdr(M_NOWAIT, MT_DATA);
356 if (m == NULL)
357 return;
358
359 eh = mtod(m, struct ether_header *);
360
361 bpdu->cbu_ssap = bpdu->cbu_dsap = LLC_8021D_LSAP;
362 bpdu->cbu_ctl = LLC_UI;
363 bpdu->cbu_protoid = htons(BSTP_PROTO_ID);
364
365 memcpy(eh->ether_shost, IF_LLADDR(ifp), ETHER_ADDR_LEN);
366 memcpy(eh->ether_dhost, bstp_etheraddr, ETHER_ADDR_LEN);
367
368 switch (bpdu->cbu_bpdutype) {
369 case BSTP_MSGTYPE_CFG:
370 bpdu->cbu_protover = BSTP_PROTO_STP;
371 m->m_pkthdr.len = sizeof(*eh) + BSTP_BPDU_STP_LEN;
372 eh->ether_type = htons(BSTP_BPDU_STP_LEN);
373 memcpy(mtod(m, caddr_t) + sizeof(*eh), bpdu,
374 BSTP_BPDU_STP_LEN);
375 break;
376
377 case BSTP_MSGTYPE_RSTP:
378 bpdu->cbu_protover = BSTP_PROTO_RSTP;
379 bpdu->cbu_versionlen = htons(0);
380 m->m_pkthdr.len = sizeof(*eh) + BSTP_BPDU_RSTP_LEN;
381 eh->ether_type = htons(BSTP_BPDU_RSTP_LEN);
382 memcpy(mtod(m, caddr_t) + sizeof(*eh), bpdu,
383 BSTP_BPDU_RSTP_LEN);
384 break;
385
386 default:
387 panic("not implemented");
388 }
389 m->m_pkthdr.rcvif = ifp;
390 m->m_len = m->m_pkthdr.len;
391
392 bp->bp_txcount++;
393 ifp->if_transmit(ifp, m);
394}
395
396static int
397bstp_pdu_flags(struct bstp_port *bp)

Callers 1

bstp_transmit_bpduFunction · 0.85

Calls 3

m_gethdrFunction · 0.50
memcpyFunction · 0.50
panicFunction · 0.50

Tested by

no test coverage detected