| 4672 | */ |
| 4673 | |
| 4674 | static void |
| 4675 | sppp_auth_send(const struct cp *cp, struct sppp *sp, |
| 4676 | unsigned int type, unsigned int id, |
| 4677 | ...) |
| 4678 | { |
| 4679 | STDDCL; |
| 4680 | struct ppp_header *h; |
| 4681 | struct lcp_header *lh; |
| 4682 | struct mbuf *m; |
| 4683 | u_char *p; |
| 4684 | int len; |
| 4685 | unsigned int mlen; |
| 4686 | const char *msg; |
| 4687 | va_list ap; |
| 4688 | |
| 4689 | MGETHDR (m, M_NOWAIT, MT_DATA); |
| 4690 | if (! m) |
| 4691 | return; |
| 4692 | m->m_pkthdr.rcvif = 0; |
| 4693 | |
| 4694 | h = mtod (m, struct ppp_header*); |
| 4695 | h->address = PPP_ALLSTATIONS; /* broadcast address */ |
| 4696 | h->control = PPP_UI; /* Unnumbered Info */ |
| 4697 | h->protocol = htons(cp->proto); |
| 4698 | |
| 4699 | lh = (struct lcp_header*)(h + 1); |
| 4700 | lh->type = type; |
| 4701 | lh->ident = id; |
| 4702 | p = (u_char*) (lh+1); |
| 4703 | |
| 4704 | va_start(ap, id); |
| 4705 | len = 0; |
| 4706 | |
| 4707 | while ((mlen = (unsigned int)va_arg(ap, size_t)) != 0) { |
| 4708 | msg = va_arg(ap, const char *); |
| 4709 | len += mlen; |
| 4710 | if (len > MHLEN - PPP_HEADER_LEN - LCP_HEADER_LEN) { |
| 4711 | va_end(ap); |
| 4712 | m_freem(m); |
| 4713 | return; |
| 4714 | } |
| 4715 | |
| 4716 | bcopy(msg, p, mlen); |
| 4717 | p += mlen; |
| 4718 | } |
| 4719 | va_end(ap); |
| 4720 | |
| 4721 | m->m_pkthdr.len = m->m_len = PPP_HEADER_LEN + LCP_HEADER_LEN + len; |
| 4722 | lh->len = htons (LCP_HEADER_LEN + len); |
| 4723 | |
| 4724 | if (debug) { |
| 4725 | log(LOG_DEBUG, SPP_FMT "%s output <%s id=0x%x len=%d", |
| 4726 | SPP_ARGS(ifp), cp->name, |
| 4727 | sppp_auth_type_name(cp->proto, lh->type), |
| 4728 | lh->ident, ntohs(lh->len)); |
| 4729 | sppp_print_bytes((u_char*) (lh+1), len); |
| 4730 | log(-1, ">\n"); |
| 4731 | } |
no test coverage detected