24 lines
586 B
C++
24 lines
586 B
C++
|
#include "VpnPeer.hpp"
|
||
|
#include "UdpVpn.hpp"
|
||
|
|
||
|
#include <cstdint>
|
||
|
#include <cstring>
|
||
|
#include <functional>
|
||
|
|
||
|
VpnPeer::VpnPeer(UdpVpn* vpn, const sockaddr_in6& ext_addr,
|
||
|
const in6_addr int_addr)
|
||
|
: _vpn(vpn), _ext_addr(ext_addr), _int_addr(int_addr)
|
||
|
{}
|
||
|
|
||
|
|
||
|
size_t VpnPeer::write(const char* data, size_t len) {
|
||
|
ssize_t nsent;
|
||
|
|
||
|
nsent = sendto(_vpn->get_socket_fd(), data, len, MSG_CONFIRM,
|
||
|
(const struct sockaddr*) &_ext_addr, sizeof(_ext_addr));
|
||
|
if(nsent < 0)
|
||
|
throw NetError("Could not send UDP packet", errno, true);
|
||
|
|
||
|
return (size_t) nsent;
|
||
|
}
|