-// Send initial LCP ConfigReq for preferred authentication type, set magic no and MRU
-void initlcp(tunnelidt t, sessionidt s)
+static uint8_t *add_lcp_auth(uint8_t *b, int size, int authtype)
+{
+ if ((authtype == AUTHCHAP && size < 5) || size < 4)
+ return 0;
+
+ *b++ = 3; // Authentication-Protocol
+ if (authtype == AUTHCHAP)
+ {
+ *b++ = 5; // length
+ *(uint16_t *) b = htons(PPPCHAP); b += 2;
+ *b++ = 5; // MD5
+ }
+ else if (authtype == AUTHPAP)
+ {
+ *b++ = 4; // length
+ *(uint16_t *) b = htons(PPPPAP); b += 2;
+ }
+ else
+ {
+ LOG(0, 0, 0, "add_lcp_auth called with unsupported auth type %d\n", authtype);
+ }
+
+ return b;
+}
+
+// Send initial LCP ConfigReq for MRU, authentication type and magic no
+void sendlcp(tunnelidt t, sessionidt s, int authtype)