A Discrete-Event Network Simulator
API
creator-utils.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18 
19 #ifndef CREATOR_UTILS_H
20 #define CREATOR_UTILS_H
21 
22 #include <unistd.h>
23 #include <cstring>
24 #include <string>
25 #include <iostream>
26 #include <iomanip>
27 #include <sstream>
28 #include <stdlib.h>
29 #include <errno.h>
30 
31 #include <sys/socket.h>
32 
33 namespace ns3 {
34 
35 extern int gVerbose;
36 
37 #define LOG(msg) \
38  if (gVerbose) \
39  { \
40  std::cout << __FUNCTION__ << "(): " << msg << std::endl; \
41  }
42 
43 #define ABORT(msg, printErrno) \
44  std::cout << __FILE__ << ": fatal error at line " << __LINE__ << ": " << __FUNCTION__ << "(): " << msg << std::endl; \
45  if (printErrno) \
46  { \
47  std::cout << " errno = " << errno << " (" << strerror (errno) << ")" << std::endl; \
48  } \
49  exit (-1);
50 
51 #define ABORT_IF(cond, msg, printErrno) \
52  if (cond) \
53  { \
54  ABORT (msg, printErrno); \
55  }
56 
67 void SendSocket (const char *path, int fd, const int magic_number);
68 
69 } // namespace ns3
70 
71 #endif /* CREATOR_UTILS_DEVICE_H */
72 
void SendSocket(const char *path, int fd, const int magic_number)
Send the file descriptor back to the code that invoked the creation.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int gVerbose
Flag to enable / disable verbose log mode.