+ int proto = ntohs(*(uint16_t *)(o + 2));
+ char proto_name[] = "0x0000";
+ if (proto == PPPPAP)
+ break;
+
+ if (response && *response != ConfigNak) // rej already queued
+ break;
+
+ if (proto == PPPCHAP)
+ strcpy(proto_name, "CHAP");
+ else
+ sprintf(proto_name, "%#4.4x", proto);
+
+ LOG(2, s, t, " Remote requesting %s authentication. Rejecting.\n", proto_name);
+
+ if (!response)
+ {
+ q = response = makeppp(b, sizeof(b), p, 2, t, s, PPPLCP);
+ if (!q) break;
+ *q = ConfigNak;
+ q += 4;
+ }
+
+ if ((q - b + length) > sizeof(b))
+ {
+ LOG(2, s, t, "LCP overflow for %s ConfigNak.\n", proto_name);
+ break;
+ }
+
+ memcpy(q, o, length);
+ *(uint16_t *)(q += 2) = htons(PPPPAP); // NAK -> Use PAP instead
+ q += length;
+ *((uint16_t *) (response + 2)) = htons(q - response);