I did not found any examples how to implement L2TPv3 over IP
I found only a couple of open source implementations of L2TP which are:
- openL2TP: https://github.com/breed/openl2tp which does not support L2TPv3 and use UDP
- tunneldigger: https://github.com/wlanslovenija/tunneldigger supports L2TPv3 but uses UDP also
L2TPv3 rfc says nothing how it is implemented in Linux which is obvious
kernel documentation: https://github.com/torvalds/linux/blob/master/Documentation/networking/l2tp.txt says we must use netlink + standard sockets which tells us something. But I do not understand why we must use netlink along with standard sockets?
kernel header file: https://github.com/torvalds/linux/blob/master/include/uapi/linux/l2tp.h it has tons of enums and commands for netlink + l2tpip structure for . I am confused of how to use them properly.
And final part of L2TPv3 control exchange establishment (SCCRQ, SCCRP, SCCCN). Having read kernel documentation I have only own understanding which might not be right but here it is.
server side:
Prepare tunnel 0 socket
Create genl socket for l2tp
Create standard socket filling l2tpip structure (socket create + bind) where tunnel_id is 0
Using genl socket create tunnel 0
Wait for SCCRQ (As I understand header will have control connection id equals zero)
On received SCCRQ on tunnel 0 socket
From received SCCRQ grab AVL's Assigned Control Connection ID which is received_tunnel_id on other side
Generate local_tunnel_id for our side
Create standard socket filling l2tpip structure (socket create + bind) where tunnel_id is local_tunnel_id
Using genl socket create tunnel with local_tunnel_id
Send SCCRP which has header's Control Connection ID equal to received_tunnel_id and AVL Assigned Control Connection ID equal to local_tunnel_id
Wait for SCCN on that socket
client side
- I do not know how it is done on that side
As I understand further communication will be over second standard socket and tunnel id zero is receiving ONLY SCCRQ
It would be great to get clarification on these details