* Send PPP control protocol packet. */
| 1405 | * Send PPP control protocol packet. |
| 1406 | */ |
| 1407 | static void |
| 1408 | sppp_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. |
no test coverage detected