A Discrete-Event Network Simulator
API
creator-utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) University of Washington
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */
17 
18 #ifndef CREATOR_UTILS_H
19 #define CREATOR_UTILS_H
20 
21 #include <cstring>
22 #include <errno.h>
23 #include <iomanip>
24 #include <iostream>
25 #include <sstream>
26 #include <stdlib.h>
27 #include <string>
28 #include <sys/socket.h>
29 #include <unistd.h>
30 
31 namespace ns3
32 {
33 
34 extern bool gVerbose;
35 
36 #define LOG(msg) \
37  if (gVerbose) \
38  { \
39  std::cout << __FUNCTION__ << "(): " << msg << std::endl; \
40  }
41 
42 #define ABORT(msg, printErrno) \
43  std::cout << __FILE__ << ": fatal error at line " << __LINE__ << ": " << __FUNCTION__ \
44  << "(): " << 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 */
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.
bool gVerbose
Flag to enable / disable verbose log mode.