+
+ while (x > 2)
+ {
+ int type = o[0];
+ int length = o[1];
+
+ if (length == 0 || type == 0 || x < length) break;
+ switch (type)
+ {
+ case 1: // Maximum-Receive-Unit
+ session[s].mru = ntohs(*(uint16_t *)(o + 2));
+ LOG(3, s, t, " Remote requested MRU of %u\n", session[s].mru);
+ break;
+
+ case 3: // Authentication-Protocol
+ if (authtype)
+ break;
+
+ {
+ int proto = ntohs(*(uint16_t *)(o + 2));
+ if (proto == PPPPAP)
+ {
+ authtype = config->radius_authtypes & AUTHPAP;
+ LOG(3, s, t, " Remote requested PAP authentication...%sing\n",
+ authtype ? "accept" : "reject");
+ }
+ else if (proto == PPPCHAP && *(o + 4) == 5)
+ {
+ authtype = config->radius_authtypes & AUTHCHAP;
+ LOG(3, s, t, " Remote requested CHAP authentication...%sing\n",
+ authtype ? "accept" : "reject");
+ }
+ else
+ {
+ LOG(3, s, t, " Rejecting unsupported authentication %#4x\n",
+ proto);
+ }
+ }
+
+ if (!authtype)
+ {
+ sessionshutdown(s, "Unsupported authentication.", 3, 0);
+ return;
+ }
+
+ break;
+
+ default:
+ LOG(2, s, t, " Remote NAKed LCP type %u?\n", type);
+ break;
+ }
+ }
+
+ if (!authtype)
+ authtype = config->radius_authprefer;
+
+ sendlcp(t, s, authtype);