Create socket for PPPoE

This commit is contained in:
Tassilo Schweyer 2025-04-22 14:02:55 +02:00
parent 9425c725c9
commit ace7452145
2 changed files with 32 additions and 0 deletions

View file

@ -1023,6 +1023,10 @@ static int create_kernel_pppox(sessionidt s)
{ {
tunnelidt t = session[s].tunnel; tunnelidt t = session[s].tunnel;
if (t == TUNNEL_ID_PPPOE) {
return create_kernel_pppoe_socket(s);
}
if (tunn_local[t].l2tp_fd < 0) if (tunn_local[t].l2tp_fd < 0)
/* Tunnel not set up yet */ /* Tunnel not set up yet */
return -1; return -1;

28
pppoe.c
View file

@ -244,6 +244,34 @@ void init_pppoe(void)
STAT(tunnel_created); STAT(tunnel_created);
} }
// setup the PPPoE session socket
int create_kernel_pppoe_socket(const sessionidt s) {
tunnelidt t = TUNNEL_ID_PPPOE;
int pppox_fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OE);
if (pppox_fd < 0) {
LOG(2, s, t, "Can't create PPPoE socket: %s\n", strerror(errno));
return -1;
}
struct sockaddr_pppox sax;
memset(&sax, 0, sizeof(sax));
sax.sa_family = AF_PPPOX;
sax.sa_protocol = PX_PROTO_OE;
sax.sa_addr.pppoe.sid = s;
memcpy(sax.sa_addr.pppoe.dev, config->pppoe_if_to_bind, IFNAMSIZ);
memcpy(sax.sa_addr.pppoe.remote, session[s].src_hwaddr, ETH_ALEN);
int ret = connect(pppox_fd, (struct sockaddr *)&sax, sizeof(sax));
if (ret < 0) {
LOG(2, s, t, "Can't connect PPPoE: %s\n", strerror(errno));
close(pppox_fd);
return -1;
}
return ret;
}
char * get_string_codepad(uint8_t codepad) char * get_string_codepad(uint8_t codepad)
{ {
char * ptrch = NULL; char * ptrch = NULL;