Théophile Bastian
94f42d08c0
Clean up dramatically the codebase by assuming the server has only a single connection at any time.
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#pragma once
|
|
|
|
/** A peer of a bound (server) instance of UdpVpn */
|
|
|
|
#include <netinet/in.h>
|
|
#include "util.hpp"
|
|
#include "VpnPacket.hpp"
|
|
|
|
class UdpVpn;
|
|
|
|
class VpnPeer {
|
|
public:
|
|
class NetError : public MsgException {
|
|
public:
|
|
NetError(
|
|
const std::string& msg,
|
|
int code=0,
|
|
bool is_perror=false)
|
|
: MsgException(msg, code, is_perror) {}
|
|
};
|
|
|
|
VpnPeer(UdpVpn* vpn, const sockaddr_in6& ext_addr,
|
|
const in6_addr& int_addr);
|
|
|
|
const sockaddr_in6& get_ext_addr() const { return _ext_addr; }
|
|
const in6_addr& get_int_addr() const { return _int_addr; }
|
|
|
|
void set_int_addr(const in6_addr& int_addr);
|
|
|
|
size_t write(const char* data, size_t len);
|
|
size_t write(const VpnPacket& packet);
|
|
|
|
uint32_t peek_next_seqno() const { return _next_seqno; }
|
|
uint32_t next_seqno() { return _next_seqno++; }
|
|
|
|
private:
|
|
UdpVpn* _vpn;
|
|
sockaddr_in6 _ext_addr;
|
|
in6_addr _int_addr;
|
|
uint32_t _next_seqno;
|
|
};
|