A Discrete-Event Network Simulator
API
Classes | Macros | Functions
tap-device-creator.cc File Reference
#include <arpa/inet.h>
#include <unistd.h>
#include <stdint.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#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"

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 46 of file tap-device-creator.cc.

Referenced by AsciiToLowCase(), and AsciiToMac48().

◆ ASCII_A

#define ASCII_A   (0x61)

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

Referenced by AsciiToLowCase().

◆ ASCII_COLON

#define ASCII_COLON   (0x3a)

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

Referenced by AsciiToMac48().

◆ ASCII_DOT

#define ASCII_DOT   (0x2e)

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

◆ ASCII_z

#define ASCII_z   (0x5a)

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

Referenced by AsciiToLowCase().

◆ ASCII_Z

#define ASCII_Z   (0x7a)

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

Referenced by AsciiToLowCase().

◆ ASCII_ZERO [1/2]

#define ASCII_ZERO   (0x30)

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

Referenced by AsciiToMac48().

◆ ASCII_ZERO [2/2]

#define ASCII_ZERO   (0x30)

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

◆ TAP_MAGIC

#define TAP_MAGIC   95549

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

Function Documentation

◆ AsciiToLowCase()

char AsciiToLowCase ( char  c)

Definition at line 65 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 82 of file tap-device-creator.cc.

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

Referenced by SetMacAddress().

◆ 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 223 of file tap-device-creator.cc.

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

◆ SetIpv4()

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

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

References ABORT_IF, and LOG.

Referenced by CreateTap().

◆ SetIpv6()

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

◆ SetMacAddress()

void SetMacAddress ( int  fd,
const char *  mac 
)

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

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

Referenced by CreateTap().

◆ SetUp()

void SetUp ( char *  deviceName)

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

References ABORT_IF, and LOG.

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