l2tp: Add Last Sent/Received LCP ConfReq in ICCN

To support proxy LCP negotiation.
This commit is contained in:
Samuel Thibault 2025-03-08 23:13:23 +01:00
parent ffcaf851ca
commit 6f04a5c390
3 changed files with 54 additions and 0 deletions

30
ppp.c
View file

@ -425,6 +425,8 @@ void lcp_open(sessionidt s, tunnelidt t)
void lcp_restart(sessionidt s)
{
session[s].ppp.phase = Establish;
sess_local[s].lcp_last_received_confreq_n = 0;
sess_local[s].lcp_last_sent_confreq_n = 0;
// This-Layer-Down
change_state(s, ipcp, Initial);
change_state(s, ipv6cp, Initial);
@ -851,6 +853,18 @@ void processlcp(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
LOG(3, s, t, "LCP: send %s\n", ppp_code(*response));
if (config->debug > 3) dumplcp(response, l);
if (*response == ConfigAck && l - 4 <= sizeof(sess_local[s].lcp_last_received_confreq))
{
memcpy(sess_local[s].lcp_last_received_confreq, p + 4, l - 4);
sess_local[s].lcp_last_received_confreq_n = l - 4;
}
else
{
LOG(3, s, t, "their LCP ConfigReq is too long for proxying\n");
dumplcp(p, l);
sess_local[s].lcp_last_received_confreq_n = 0;
}
tunnelsend(b, l + (response - b), t);
}
else if (*p == ConfigNak || *p == ConfigRej)
@ -859,6 +873,10 @@ void processlcp(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
uint8_t *o = (p + 4);
int authtype = -1;
// They didn't like our config
sess_local[s].lcp_last_sent_confreq_n = 0;
while (x > 2)
{
int type = o[0];
@ -2800,6 +2818,18 @@ void sendlcp(sessionidt s, tunnelidt t)
LOG_HEX(5, "PPPLCP", q, l - q);
if (config->debug > 3) dumplcp(q, l - q);
if (l - (q + 4) <= sizeof(sess_local[s].lcp_last_sent_confreq))
{
memcpy(sess_local[s].lcp_last_sent_confreq, q + 4, l - (q + 4));
sess_local[s].lcp_last_sent_confreq_n = l - (q + 4);
}
else
{
LOG(3, s, t, "our LCP ConfigReq is too long for proxying\n");
dumplcp(q, l - q);
sess_local[s].lcp_last_sent_confreq_n = 0;
}
tunnelsend(b, (l - b), t);
restart_timer(s, lcp);
}