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

Function sppp_cp_send

freebsd/net/if_spppsubr.c:1407–1447  ·  view source on GitHub ↗

* Send PPP control protocol packet. */

Source from the content-addressed store, hash-verified

1405 * Send PPP control protocol packet.
1406 */
1407static void
1408sppp_cp_send(struct sppp *sp, u_short proto, u_char type,
1409 u_char ident, u_short len, void *data)
1410{
1411 STDDCL;
1412 struct ppp_header *h;
1413 struct lcp_header *lh;
1414 struct mbuf *m;
1415
1416 if (len > MHLEN - PPP_HEADER_LEN - LCP_HEADER_LEN)
1417 len = MHLEN - PPP_HEADER_LEN - LCP_HEADER_LEN;
1418 MGETHDR (m, M_NOWAIT, MT_DATA);
1419 if (! m)
1420 return;
1421 m->m_pkthdr.len = m->m_len = PPP_HEADER_LEN + LCP_HEADER_LEN + len;
1422 m->m_pkthdr.rcvif = 0;
1423
1424 h = mtod (m, struct ppp_header*);
1425 h->address = PPP_ALLSTATIONS; /* broadcast address */
1426 h->control = PPP_UI; /* Unnumbered Info */
1427 h->protocol = htons (proto); /* Link Control Protocol */
1428
1429 lh = (struct lcp_header*) (h + 1);
1430 lh->type = type;
1431 lh->ident = ident;
1432 lh->len = htons (LCP_HEADER_LEN + len);
1433 if (len)
1434 bcopy (data, lh+1, len);
1435
1436 if (debug) {
1437 log(LOG_DEBUG, SPP_FMT "%s output <%s id=0x%x len=%d",
1438 SPP_ARGS(ifp),
1439 sppp_proto_name(proto),
1440 sppp_cp_type_name (lh->type), lh->ident,
1441 ntohs (lh->len));
1442 sppp_print_bytes ((u_char*) (lh+1), len);
1443 log(-1, ">\n");
1444 }
1445 if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3))
1446 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
1447}
1448
1449/*
1450 * Handle incoming PPP control protocol packets.

Callers 11

sppp_inputFunction · 0.85
sppp_cp_inputFunction · 0.85
sppp_close_eventFunction · 0.85
sppp_to_eventFunction · 0.85
sppp_lcp_RCRFunction · 0.85
sppp_lcp_scrFunction · 0.85
sppp_ipcp_RCRFunction · 0.85
sppp_ipcp_scrFunction · 0.85
sppp_ipv6cp_RCRFunction · 0.85
sppp_ipv6cp_scrFunction · 0.85
sppp_keepaliveFunction · 0.85

Calls 5

sppp_proto_nameFunction · 0.85
sppp_cp_type_nameFunction · 0.85
sppp_print_bytesFunction · 0.85
if_inc_counterFunction · 0.85
logFunction · 0.50

Tested by

no test coverage detected