OpenVPN 3 Core Library
|
#include <genl.hpp>
Classes | |
struct | mcast_handler_args |
Public Types | |
typedef RCPtr< GeNL > | Ptr |
![]() | |
typedef RCPtr< RC > | Ptr |
Public Member Functions | |
GeNL (openvpn_io::io_context &io_context, unsigned int ifindex_arg, ReadHandler read_handler_arg) | |
void | new_peer (int peer_id, int fd, struct sockaddr *sa, socklen_t salen, IPv4::Addr vpn4, IPv6::Addr vpn6) |
void | new_key (unsigned int key_slot, const KoRekey::KeyConfig *kc) |
void | swap_keys (int peer_id) |
void | del_key (int peer_id, unsigned int key_slot) |
void | set_peer (int peer_id, unsigned int keepalive_interval, unsigned int keepalive_timeout) |
void | del_peer (int peer_id) |
void | get_peer (int peer_id, bool sync) |
void | stop () |
![]() | |
RC () noexcept=default | |
RC (const RC &)=delete | |
virtual | ~RC ()=default |
RC & | operator= (const RC &)=delete |
olong | use_count () const noexcept |
Delegates call to RCImpl and returns the result. | |
Static Public Member Functions | |
static bool | available () |
![]() | |
static constexpr bool | is_thread_safe () |
Delegates call to RCImpl and returns the result. | |
Private Types | |
typedef std::unique_ptr< nl_msg, decltype(&nlmsg_free)> | NlMsgPtr |
typedef std::unique_ptr< nl_sock, decltype(&nl_socket_free)> | NlSockPtr |
typedef std::unique_ptr< nl_cb, decltype(&nl_cb_put)> | NlCbPtr |
Private Member Functions | |
OPENVPN_EXCEPTION (netlink_error) | |
int | get_mcast_id () |
void | handle_read (const openvpn_io::error_code &error) |
void | queue_genl_read () |
NlMsgPtr | create_msg (enum ovpn_nl_commands cmd) |
void | read_netlink_message () |
void | reset_buffer () |
void | send_netlink_message (struct nl_msg *msg) |
Static Private Member Functions | |
static int | mcast_family_handler (struct nl_msg *msg, void *arg) |
static int | message_received (struct nl_msg *msg, void *arg) |
static int | ovpn_nl_cb_error (struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg) |
Private Attributes | |
NlSockPtr | sock_ptr |
NlCbPtr | cb_ptr |
struct nl_sock * | sock |
struct nl_cb * | cb |
int | ovpn_dco_id |
unsigned int | ifindex |
ReadHandler | read_handler |
bool | halt |
BufferAllocated | buf |
std::unique_ptr< openvpn_io::posix::stream_descriptor > | stream |
Static Private Attributes | |
static int | nl_status = 0 |
Implements asynchronous communication with ovpn-dco kernel module via generic netlink protocol.
Before using this class, caller should create ovpn-dco network device.
ReadHandler | class which implements tun_read_handler(BufferAllocated &buf) method. buf has following layout:
|
|
private |
|
private |
|
private |
typedef RCPtr<GeNL> openvpn::GeNL< ReadHandler >::Ptr |
|
inlineexplicit |
|
inlinestatic |
|
inlineprivate |
|
inline |
|
inline |
|
inlineprivate |
|
inline |
|
inlineprivate |
|
inlinestaticprivate |
This callback is called by libnl. Here we enumerate netlink multicast groups and find id of the one which name matches ovpn-dco multicast group.
msg | netlink message to be processed |
arg | arguments passed by nl_cb_set() call |
Definition at line 458 of file genl.hpp.
|
inlinestaticprivate |
|
inline |
|
inline |
Add peer information to kernel module
peer_id | Peer ID of the peer being created |
fd | socket to be used to communicate with the peer |
sa | sockaddr object representing the remote endpoint |
salen | length of sa (either sizeof(sockaddr_in) or sizeof(sockaddr_in6) |
vpn4 | IPv4 address associated with this peer in the tunnel |
vpn6 | IPv6 address associated with this peer in the tunnel |
netlink_error | thrown if error occurs during sending netlink message |
|
private |
|
inlinestaticprivate |
This is an error callback called by netlink for error message processing customization.
nla | netlink address of the peer (value not needed here) |
err | netlink error message being processed |
arg | argument passed by nl_cb_err() |
Definition at line 762 of file genl.hpp.
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
Set peer properties. Currently used for keepalive settings.
peer_id | ID of the peer whose properties have to be modified |
keepalive_interval | how often to send ping packet in absence of traffic |
keepalive_timeout | when to trigger keepalive_timeout in absence of traffic |
netlink_error | thrown if error occurs during sending netlink message |
|
inline |
|
inline |
Swap keys between primary and secondary slots. Called by client as part of rekeying logic to promote and demote keys.
peer_id | the ID of the peer whose keys have to be swapped |
netlink_error | thrown if error occurs during sending netlink message |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |