forked from ravinet/mahimahi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnetdevice.hh
42 lines (32 loc) · 1015 Bytes
/
netdevice.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* -*-mode:c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#ifndef NETDEVICE_HH
#define NETDEVICE_HH
#include <string>
#include <functional>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <linux/if.h>
#include "file_descriptor.hh"
#include "address.hh"
/* general helpers */
void interface_ioctl( FileDescriptor & fd, const int request,
const std::string & name,
std::function<void( ifreq &ifr )> ifr_adjustment);
void assign_address( const std::string & device_name, const Address & addr, const Address & peer );
class TunDevice
{
private:
FileDescriptor fd_;
public:
TunDevice( const std::string & name, const Address & addr, const Address & peer );
FileDescriptor & fd( void ) { return fd_; }
};
class VirtualEthernetPair
{
private:
std::string name;
public:
VirtualEthernetPair( const std::string & s_outside_name, const std::string & s_inside_name );
~VirtualEthernetPair();
};
#endif /* NETDEVICE_HH */