version 1.1.1.4, 2021/03/17 00:39:23
|
version 1.1.1.4.2.1, 2023/09/27 11:08:00
|
Line 1374 L2tpServerEvent(int type, void *arg)
|
Line 1374 L2tpServerEvent(int type, void *arg)
|
struct ngm_mkpeer mkpeer; |
struct ngm_mkpeer mkpeer; |
struct sockaddr_storage peer_sas; |
struct sockaddr_storage peer_sas; |
struct sockaddr_storage sas; |
struct sockaddr_storage sas; |
|
struct u_addr server_addr; |
const size_t bufsize = 8192; |
const size_t bufsize = 8192; |
u_int16_t *buf = NULL; |
u_int16_t *buf = NULL; |
char hook[NG_HOOKSIZ]; |
char hook[NG_HOOKSIZ]; |
Line 1393 L2tpServerEvent(int type, void *arg)
|
Line 1394 L2tpServerEvent(int type, void *arg)
|
/* Allocate buffer */ |
/* Allocate buffer */ |
buf = Malloc(MB_PHYS, bufsize); |
buf = Malloc(MB_PHYS, bufsize); |
|
|
|
u_addrcopy(&s->self_addr, &server_addr); |
|
|
/* Read packet */ |
/* Read packet */ |
sas_len = sizeof(peer_sas); |
sas_len = sizeof(peer_sas); |
if ((len = recvfrom(s->sock, buf, bufsize, 0, | |
| if (u_addrempty(&s->self_addr)) { |
| if ((len = GetDataAddrs(s->sock, buf, bufsize, |
| &peer_sas, sas_len, &server_addr)) == -1) { |
| Perror("L2TP: GetDataAddrs"); |
| goto fail; |
| } |
| } else if ((len = recvfrom(s->sock, buf, bufsize, 0, |
(struct sockaddr *)&peer_sas, &sas_len)) == -1) { |
(struct sockaddr *)&peer_sas, &sas_len)) == -1) { |
Perror("L2TP: recvfrom"); |
Perror("L2TP: recvfrom"); |
goto fail; |
goto fail; |
Line 1415 L2tpServerEvent(int type, void *arg)
|
Line 1425 L2tpServerEvent(int type, void *arg)
|
tun->self_port = s->self_port; |
tun->self_port = s->self_port; |
tun->alive = 1; |
tun->alive = 1; |
|
|
Log(LG_PHYS, ("Incoming L2TP packet from %s %d", | if (u_addrempty(&tun->self_addr)) |
u_addrtoa(&tun->peer_addr, namebuf, sizeof(namebuf)), tun->peer_port)); | u_addrcopy(&server_addr, &tun->self_addr); |
|
|
|
if (u_addrempty(&tun->self_addr)) |
|
Log(LG_PHYS, ("Incoming L2TP packet from %s %d", |
|
u_addrtoa(&tun->peer_addr, namebuf, sizeof(namebuf)), |
|
tun->peer_port)); |
|
else { |
|
char buf3[INET_ADDRSTRLEN]; |
|
|
|
Log(LG_PHYS, ("Incoming L2TP packet from %s %d to %s %d", |
|
u_addrtoa(&tun->peer_addr, namebuf, sizeof(namebuf)), |
|
tun->peer_port, |
|
u_addrtoa(&tun->self_addr, buf3, sizeof(buf3)), |
|
tun->self_port)); |
|
} |
|
|
/* Examine all L2TP links to get best possible fit tunnel parameters. */ |
/* Examine all L2TP links to get best possible fit tunnel parameters. */ |
for (k = 0; k < gNumLinks; k++) { |
for (k = 0; k < gNumLinks; k++) { |
Link l2; |
Link l2; |
Line 1552 L2tpServerEvent(int type, void *arg)
|
Line 1576 L2tpServerEvent(int type, void *arg)
|
} |
} |
|
|
/* Bind socket to a new port */ |
/* Bind socket to a new port */ |
u_addrtosockaddr(&s->self_addr,s->self_port,&sas); | u_addrtosockaddr(&tun->self_addr,tun->self_port,&sas); |
if (NgSendMsg(csock, namebuf, NGM_KSOCKET_COOKIE, |
if (NgSendMsg(csock, namebuf, NGM_KSOCKET_COOKIE, |
NGM_KSOCKET_BIND, &sas, sas.ss_len) == -1) { |
NGM_KSOCKET_BIND, &sas, sas.ss_len) == -1) { |
Perror("L2TP: bind"); |
Perror("L2TP: bind"); |
Line 1632 L2tpListen(Link l)
|
Line 1656 L2tpListen(Link l)
|
|
|
/* Setup UDP socket that listens for new connections */ |
/* Setup UDP socket that listens for new connections */ |
if (s->self_addr.family==AF_INET6) { |
if (s->self_addr.family==AF_INET6) { |
s->sock = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); | s->sock = socket(PF_INET6, socktype(SOCK_DGRAM), IPPROTO_UDP); |
} else { |
} else { |
s->sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); | s->sock = socket(PF_INET, socktype(SOCK_DGRAM), IPPROTO_UDP); |
} |
} |
if (s->sock == -1) { |
if (s->sock == -1) { |
Perror("L2TP: socket"); |
Perror("L2TP: socket"); |
Line 1649 L2tpListen(Link l)
|
Line 1673 L2tpListen(Link l)
|
SO_REUSEPORT, &one, sizeof(one)) == -1) { |
SO_REUSEPORT, &one, sizeof(one)) == -1) { |
Perror("L2TP: setsockopt"); |
Perror("L2TP: setsockopt"); |
goto fail; |
goto fail; |
|
} |
|
if (u_addrempty(&s->self_addr)) { |
|
int on = 1; |
|
setsockopt(s->sock, IPPROTO_IP, IP_RECVDSTADDR, &on, sizeof(on)); |
} |
} |
u_addrtosockaddr(&s->self_addr, s->self_port, &sa); |
u_addrtosockaddr(&s->self_addr, s->self_port, &sa); |
if (bind(s->sock, (struct sockaddr *)&sa, sa.ss_len) == -1) { |
if (bind(s->sock, (struct sockaddr *)&sa, sa.ss_len) == -1) { |