A Discrete-Event Network Simulator
API
tap-device-creator.cc File Reference
#include <arpa/inet.h>
#include <unistd.h>
#include <stdint.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <net/if.h>
#include <linux/if_tun.h>
#include <net/route.h>
#include <netinet/in.h>
#include "creator-utils.h"
+ Include dependency graph for tap-device-creator.cc:

Go to the source code of this file.

Classes

struct  in6_ifreq
 Struct holding IPv6 address data. More...
 

Macros

#define ASCII_a   (0x41)
 
#define ASCII_A   (0x61)
 
#define ASCII_COLON   (0x3a)
 
#define ASCII_DOT   (0x2e)
 
#define ASCII_z   (0x5a)
 
#define ASCII_Z   (0x7a)
 
#define ASCII_ZERO   (0x30)
 
#define ASCII_ZERO   (0x30)
 
#define TAP_MAGIC   95549
 

Functions

char AsciiToLowCase (char c)
 
void AsciiToMac48 (const char *str, uint8_t addr[6])
 
int CreateTap (char *deviceName, const char *mac, const int ifftap, const int iffpi, const char *ip4, const char *netmask, const char *ip6, const int netprefix)
 
void SetIpv4 (const char *deviceName, const char *ip, const char *netmask)
 
void SetIpv6 (const char *deviceName, const char *ip, int netprefix)
 
void SetMacAddress (int fd, const char *mac)
 
void SetUp (char *deviceName)
 

Macro Definition Documentation

◆ ASCII_a

#define ASCII_a   (0x41)

Definition at line 47 of file tap-device-creator.cc.

◆ ASCII_A

#define ASCII_A   (0x61)

Definition at line 49 of file tap-device-creator.cc.

◆ ASCII_COLON

#define ASCII_COLON   (0x3a)

Definition at line 51 of file tap-device-creator.cc.

◆ ASCII_DOT

#define ASCII_DOT   (0x2e)

Definition at line 45 of file tap-device-creator.cc.

◆ ASCII_z

#define ASCII_z   (0x5a)

Definition at line 48 of file tap-device-creator.cc.

◆ ASCII_Z

#define ASCII_Z   (0x7a)

Definition at line 50 of file tap-device-creator.cc.

◆ ASCII_ZERO [1/2]

#define ASCII_ZERO   (0x30)

Definition at line 52 of file tap-device-creator.cc.

◆ ASCII_ZERO [2/2]

#define ASCII_ZERO   (0x30)

Definition at line 52 of file tap-device-creator.cc.

◆ TAP_MAGIC

#define TAP_MAGIC   95549

Definition at line 40 of file tap-device-creator.cc.

Function Documentation

◆ AsciiToLowCase()

char AsciiToLowCase ( char  c)

Definition at line 66 of file tap-device-creator.cc.

References ASCII_a, ASCII_A, ASCII_z, and ASCII_Z.

◆ AsciiToMac48()

void AsciiToMac48 ( const char *  str,
uint8_t  addr[6] 
)

Definition at line 83 of file tap-device-creator.cc.

References ASCII_a, ASCII_COLON, ASCII_ZERO, and ns3::AsciiToLowCase().

Referenced by SetMacAddress().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateTap()

int CreateTap ( char *  deviceName,
const char *  mac,
const int  ifftap,
const int  iffpi,
const char *  ip4,
const char *  netmask,
const char *  ip6,
const int  netprefix 
)

Definition at line 224 of file tap-device-creator.cc.

References ABORT_IF, LOG, third::mac, SetIpv4(), SetIpv6(), SetMacAddress(), and SetUp().

+ Here is the call graph for this function:

◆ SetIpv4()

void SetIpv4 ( const char *  deviceName,
const char *  ip,
const char *  netmask 
)

Definition at line 114 of file tap-device-creator.cc.

References ABORT_IF, and LOG.

Referenced by CreateTap().

+ Here is the caller graph for this function:

◆ SetIpv6()

void SetIpv6 ( const char *  deviceName,
const char *  ip,
int  netprefix 
)

Definition at line 154 of file tap-device-creator.cc.

References ABORT_IF, in6_ifreq::ifr6_addr, in6_ifreq::ifr6_ifindex, in6_ifreq::ifr6_prefixlen, and LOG.

Referenced by CreateTap().

+ Here is the caller graph for this function:

◆ SetMacAddress()

void SetMacAddress ( int  fd,
const char *  mac 
)

Definition at line 191 of file tap-device-creator.cc.

References ABORT_IF, AsciiToMac48(), LOG, and third::mac.

Referenced by CreateTap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetUp()

void SetUp ( char *  deviceName)

Definition at line 203 of file tap-device-creator.cc.

References ABORT_IF, and LOG.

Referenced by CreateTap(), and Ipv4DynamicGlobalRoutingTestCase::DoRun().

+ Here is the caller graph for this function: