A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tap-creator.cc File Reference
#include "tap-encode-decode.h"
#include "ns3/mac48-address.h"
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <fcntl.h>
#include <iomanip>
#include <iostream>
#include <linux/if_tun.h>
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
#include <sstream>
#include <stdint.h>
#include <string>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
+ Include dependency graph for tap-creator.cc:

Go to the source code of this file.

Macros

#define ABORT(msg, printErrno)
 
#define ABORT_IF(cond, msg, printErrno)
 
#define LOG(msg)
 
#define TAP_MAGIC   95549
 

Functions

static sockaddr CreateInetAddress (uint32_t networkOrder)
 
static int CreateTap (const char *dev, const char *gw, const char *ip, const char *mac, const char *mode, const char *netmask)
 
static void SendSocket (const char *path, int fd)
 

Variables

static bool gVerbose = false
 

Macro Definition Documentation

◆ ABORT

#define ABORT ( msg,
printErrno )
Value:
std::cout << __FILE__ << ": fatal error at line " << __LINE__ << ": " << __FUNCTION__ \
<< "(): " << msg << std::endl; \
if (printErrno) \
{ \
std::cout << " errno = " << errno << " (" << std::strerror(errno) << ")" << std::endl; \
} \
std::exit(-1);

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

◆ ABORT_IF

#define ABORT_IF ( cond,
msg,
printErrno )
Value:
if (cond) \
{ \
ABORT(msg, printErrno); \
}

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

Referenced by CreateTap(), and SendSocket().

◆ LOG

#define LOG ( msg)
Value:
if (gVerbose) \
{ \
std::cout << __FUNCTION__ << "(): " << msg << std::endl; \
}
static bool gVerbose

Definition at line 34 of file tap-creator.cc.

Referenced by CreateTap(), and SendSocket().

◆ TAP_MAGIC

#define TAP_MAGIC   95549

Definition at line 30 of file tap-creator.cc.

Referenced by SendSocket().

Function Documentation

◆ CreateInetAddress()

static sockaddr CreateInetAddress ( uint32_t networkOrder)
static

Definition at line 56 of file tap-creator.cc.

Referenced by CreateTap().

+ Here is the caller graph for this function:

◆ CreateTap()

static int CreateTap ( const char * dev,
const char * gw,
const char * ip,
const char * mac,
const char * mode,
const char * netmask )
static

Definition at line 192 of file tap-creator.cc.

References ABORT_IF, ns3::Mac48Address::CopyTo(), CreateInetAddress(), and LOG.

+ Here is the call graph for this function:

◆ SendSocket()

static void SendSocket ( const char * path,
int fd )
static

Definition at line 70 of file tap-creator.cc.

References ABORT_IF, LOG, TAP_MAGIC, and ns3::TapStringToBuffer().

+ Here is the call graph for this function:

Variable Documentation

◆ gVerbose

bool gVerbose = false
static

Definition at line 32 of file tap-creator.cc.