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

Function sppp_chap_input

freebsd/net/if_spppsubr.c:3970–4188  ·  view source on GitHub ↗

* Handle incoming CHAP packets. */

Source from the content-addressed store, hash-verified

3968 * Handle incoming CHAP packets.
3969 */
3970static void
3971sppp_chap_input(struct sppp *sp, struct mbuf *m)
3972{
3973 STDDCL;
3974 struct lcp_header *h;
3975 int len;
3976 u_char *value, *name, digest[AUTHKEYLEN], dsize;
3977 int value_len, name_len;
3978 MD5_CTX ctx;
3979
3980 len = m->m_pkthdr.len;
3981 if (len < 4) {
3982 if (debug)
3983 log(LOG_DEBUG,
3984 SPP_FMT "chap invalid packet length: %d bytes\n",
3985 SPP_ARGS(ifp), len);
3986 return;
3987 }
3988 h = mtod (m, struct lcp_header*);
3989 if (len > ntohs (h->len))
3990 len = ntohs (h->len);
3991
3992 switch (h->type) {
3993 /* challenge, failure and success are his authproto */
3994 case CHAP_CHALLENGE:
3995 value = 1 + (u_char*)(h+1);
3996 value_len = value[-1];
3997 name = value + value_len;
3998 name_len = len - value_len - 5;
3999 if (name_len < 0) {
4000 if (debug) {
4001 log(LOG_DEBUG,
4002 SPP_FMT "chap corrupted challenge "
4003 "<%s id=0x%x len=%d",
4004 SPP_ARGS(ifp),
4005 sppp_auth_type_name(PPP_CHAP, h->type),
4006 h->ident, ntohs(h->len));
4007 sppp_print_bytes((u_char*) (h+1), len-4);
4008 log(-1, ">\n");
4009 }
4010 break;
4011 }
4012
4013 if (debug) {
4014 log(LOG_DEBUG,
4015 SPP_FMT "chap input <%s id=0x%x len=%d name=",
4016 SPP_ARGS(ifp),
4017 sppp_auth_type_name(PPP_CHAP, h->type), h->ident,
4018 ntohs(h->len));
4019 sppp_print_string((char*) name, name_len);
4020 log(-1, " value-size=%d value=", value_len);
4021 sppp_print_bytes(value, value_len);
4022 log(-1, ">\n");
4023 }
4024
4025 /* Compute reply value. */
4026 MD5Init(&ctx);
4027 MD5Update(&ctx, &h->ident, 1);

Callers 1

sppp_inputFunction · 0.85

Calls 12

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

Tested by

no test coverage detected