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

Function sppp_pap_input

freebsd/net/if_spppsubr.c:4367–4505  ·  view source on GitHub ↗

* Handle incoming PAP packets. */

Source from the content-addressed store, hash-verified

4365/*
4366 * Handle incoming PAP packets. */
4367static void
4368sppp_pap_input(struct sppp *sp, struct mbuf *m)
4369{
4370 STDDCL;
4371 struct lcp_header *h;
4372 int len;
4373 u_char *name, *passwd, mlen;
4374 int name_len, passwd_len;
4375
4376 len = m->m_pkthdr.len;
4377 if (len < 5) {
4378 if (debug)
4379 log(LOG_DEBUG,
4380 SPP_FMT "pap invalid packet length: %d bytes\n",
4381 SPP_ARGS(ifp), len);
4382 return;
4383 }
4384 h = mtod (m, struct lcp_header*);
4385 if (len > ntohs (h->len))
4386 len = ntohs (h->len);
4387 switch (h->type) {
4388 /* PAP request is my authproto */
4389 case PAP_REQ:
4390 name = 1 + (u_char*)(h+1);
4391 name_len = name[-1];
4392 passwd = name + name_len + 1;
4393 if (name_len > len - 6 ||
4394 (passwd_len = passwd[-1]) > len - 6 - name_len) {
4395 if (debug) {
4396 log(LOG_DEBUG, SPP_FMT "pap corrupted input "
4397 "<%s id=0x%x len=%d",
4398 SPP_ARGS(ifp),
4399 sppp_auth_type_name(PPP_PAP, h->type),
4400 h->ident, ntohs(h->len));
4401 sppp_print_bytes((u_char*)(h+1), len-4);
4402 log(-1, ">\n");
4403 }
4404 break;
4405 }
4406 if (debug) {
4407 log(LOG_DEBUG, SPP_FMT "pap input(%s) "
4408 "<%s id=0x%x len=%d name=",
4409 SPP_ARGS(ifp),
4410 sppp_state_name(sp->state[IDX_PAP]),
4411 sppp_auth_type_name(PPP_PAP, h->type),
4412 h->ident, ntohs(h->len));
4413 sppp_print_string((char*)name, name_len);
4414 log(-1, " passwd=");
4415 sppp_print_string((char*)passwd, passwd_len);
4416 log(-1, ">\n");
4417 }
4418 if (name_len != sppp_strnlen(sp->hisauth.name, AUTHNAMELEN) ||
4419 passwd_len != sppp_strnlen(sp->hisauth.secret, AUTHKEYLEN) ||
4420 bcmp(name, sp->hisauth.name, name_len) != 0 ||
4421 bcmp(passwd, sp->hisauth.secret, passwd_len) != 0) {
4422 /* action scn, tld */
4423 mlen = sizeof(FAILMSG) - 1;
4424 sppp_auth_send(&pap, sp, PAP_NAK, h->ident,

Callers 1

sppp_inputFunction · 0.85

Calls 9

sppp_auth_type_nameFunction · 0.85
sppp_print_bytesFunction · 0.85
sppp_state_nameFunction · 0.85
sppp_print_stringFunction · 0.85
sppp_strnlenFunction · 0.85
sppp_auth_sendFunction · 0.85
sppp_cp_change_stateFunction · 0.85
sppp_phase_networkFunction · 0.85
logFunction · 0.50

Tested by

no test coverage detected