l2tp: Add PAP auth information in ICCN

To support proxy auth.
This commit is contained in:
Samuel Thibault 2025-03-23 03:17:41 +01:00
parent e701644d37
commit 40796d2adb
4 changed files with 37 additions and 0 deletions

View file

@ -4862,6 +4862,9 @@ void processudp(uint8_t *buf, int len, struct sockaddr_in *addr, uint16_t indexu
session[s].ppp.lcp = Starting; session[s].ppp.lcp = Starting;
sess_local[s].lcp_last_received_confreq_n = 0; sess_local[s].lcp_last_received_confreq_n = 0;
sess_local[s].lcp_last_sent_confreq_n = 0; sess_local[s].lcp_last_sent_confreq_n = 0;
sess_local[s].auth_type = 0;
sess_local[s].auth_name[0] = 0;
sess_local[s].auth_resp[0] = 0;
STAT(session_created); STAT(session_created);
break; break;
@ -4912,6 +4915,20 @@ void processudp(uint8_t *buf, int len, struct sockaddr_in *addr, uint16_t indexu
controlb(c, 28, sess_local[fs].lcp_last_received_confreq, controlb(c, 28, sess_local[fs].lcp_last_received_confreq,
sess_local[fs].lcp_last_received_confreq_n, 0); sess_local[fs].lcp_last_received_confreq_n, 0);
if (sess_local[fs].auth_type == 3) // PAP
{
// Proxy Authentication Type
control16(c, 29, sess_local[fs].auth_type, 0);
// Proxy Authentication Name
controlb(c, 30, sess_local[fs].auth_name,
strlen((const char*) sess_local[fs].auth_name), 0);
// Proxy Authentication Id
control16(c, 32, sess_local[fs].auth_id, 0);
// Proxy Authentication Response
controlb(c, 33, sess_local[fs].auth_resp,
strlen((const char*) sess_local[fs].auth_resp), 0);
}
controladd(c, asession, t); // send the message controladd(c, asession, t); // send the message
LOG(3, s, t, "Sending ICCN\n"); LOG(3, s, t, "Sending ICCN\n");
} }

View file

@ -425,6 +425,14 @@ typedef struct
// Last Sent LCP ConfReq and its length // Last Sent LCP ConfReq and its length
uint8_t lcp_last_sent_confreq[MAXLCPLENGTH]; uint8_t lcp_last_sent_confreq[MAXLCPLENGTH];
int lcp_last_sent_confreq_n; int lcp_last_sent_confreq_n;
// Negotiated authentication type
uint16_t auth_type;
// Negotiated authentication ID
uint16_t auth_id;
// Negotiated authentication name
uint8_t auth_name[64];
// Negotiated authentication response
uint8_t auth_resp[64];
// our MRU // our MRU
uint16_t ppp_mru; uint16_t ppp_mru;

6
ppp.c
View file

@ -155,6 +155,9 @@ void processpap(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
strncpy(session[s].user, packet.username, sizeof(session[s].user) - 1); strncpy(session[s].user, packet.username, sizeof(session[s].user) - 1);
strncpy(radius[r].pass, packet.password, sizeof(radius[r].pass) - 1); strncpy(radius[r].pass, packet.password, sizeof(radius[r].pass) - 1);
strncpy((char *) sess_local[s].auth_name, packet.username, sizeof(sess_local[s].auth_name) - 1);
strncpy((char *) sess_local[s].auth_resp, packet.password, sizeof(sess_local[s].auth_resp) - 1);
free(packet.username); free(packet.username);
free(packet.password); free(packet.password);
@ -427,6 +430,9 @@ void lcp_restart(sessionidt s)
session[s].ppp.phase = Establish; session[s].ppp.phase = Establish;
sess_local[s].lcp_last_received_confreq_n = 0; sess_local[s].lcp_last_received_confreq_n = 0;
sess_local[s].lcp_last_sent_confreq_n = 0; sess_local[s].lcp_last_sent_confreq_n = 0;
sess_local[s].auth_type = 0;
sess_local[s].auth_name[0] = 0;
sess_local[s].auth_resp[0] = 0;
// This-Layer-Down // This-Layer-Down
change_state(s, ipcp, Initial); change_state(s, ipcp, Initial);
change_state(s, ipv6cp, Initial); change_state(s, ipv6cp, Initial);

View file

@ -1046,6 +1046,12 @@ void processrad(uint8_t *buf, int len, char socket_index)
LOG(3, s, session[s].tunnel, "Select Tunnel Remote LNS for assignment_id == %s\n", assignment_id); LOG(3, s, session[s].tunnel, "Select Tunnel Remote LNS for assignment_id == %s\n", assignment_id);
if (!radius[r].chap)
{
sess_local[s].auth_type = 3; // PAP
sess_local[s].auth_id = radius[r].id;
}
if (lac_rad_forwardtoremotelns(s, assignment_id, session[s].user)) if (lac_rad_forwardtoremotelns(s, assignment_id, session[s].user))
{ {
int ro; int ro;