• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/config.h

00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
00002 /*
00003  * Copyright (c) 1995-1997 The Regents of the University of California.
00004  * All rights reserved.
00005  * 
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. All advertising materials mentioning features or use of this software
00015  *    must display the following acknowledgement:
00016  *      This product includes software developed by the Network Research
00017  *      Group at Lawrence Berkeley National Laboratory.
00018  * 4. Neither the name of the University nor of the Laboratory may be used
00019  *    to endorse or promote products derived from this software without
00020  *    specific prior written permission.
00021  * 
00022  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  * @(#) $Header: /cvsroot/nsnam/ns-2/config.h,v 1.58 2007/01/01 17:38:41 mweigle Exp $ (LBL)
00035  */
00036 
00037 #ifndef ns_config_h
00038 #define ns_config_h
00039 
00040 
00041 #define MEMDEBUG_SIMULATIONS
00042 
00043 /* pick up standard types */
00044 #include <sys/types.h>
00045 #if STDC_HEADERS
00046 #include <stdlib.h>
00047 #include <stddef.h>
00048 #endif
00049 
00050 /* get autoconf magic */
00051 #ifdef WIN32
00052 #include "autoconf-win32.h"
00053 #else
00054 #include "autoconf.h"
00055 #endif
00056 
00057 /* after autoconf (and HAVE_INT64) we can pick up tclcl.h */
00058 #ifndef stand_alone
00059 #ifdef __cplusplus
00060 #include <tclcl.h>
00061 #endif /* __cplusplus */
00062 #endif
00063 
00064 /* handle stl and namespaces */
00065 
00066 
00067 /*
00068  * add u_char and u_int
00069  * Note: do NOT use these expecting them to be 8 and 32 bits long...
00070  * use {,u_}int{8,16,32}_t if you care about size.
00071  */
00072 /* Removed typedef and included checks in the configure.in 
00073  typedef unsigned char u_char;
00074 typedef unsigned int u_int;
00075 */
00076 typedef int32_t nsaddr_t; 
00077 typedef int32_t nsmask_t; 
00078 
00079 /* 32-bit addressing support */
00080 struct ns_addr_t {
00081         int32_t addr_;
00082         int32_t port_;
00083 #ifdef __cplusplus
00084         bool isEqual (ns_addr_t const &o) {
00085                 return ((addr_ == o.addr_) && (port_ == o.port_))?true:false;
00086         }
00087 #endif /* __cplusplus */
00088 };
00089 
00090 /* 64-bit integer support */
00091 #ifndef STRTOI64
00092 #if defined(SIZEOF_LONG) && SIZEOF_LONG >= 8
00093 #define STRTOI64 strtol
00094 #define STRTOI64_FMTSTR "%ld"
00095 /*#define STRTOI64(S) strtol((S), NULL, 0) */
00096 
00097 #elif defined(HAVE_STRTOQ)
00098 #define STRTOI64 strtoq
00099 #define STRTOI64_FMTSTR "%lld"
00100 /* #define STRTOI64(S) strtoq((S), NULL, 0) */
00101 
00102 #elif defined(HAVE_STRTOLL)
00103 #define STRTOI64 strtoll
00104 #define STRTOI64_FMTSTR "%lld"
00105 /* #define STRTOI64(S) strtoll((S), NULL, 0) */
00106 #endif
00107 #endif
00108 
00109 #define NS_ALIGN        (8)     /* byte alignment for structs (eg packet.cc) */
00110 
00111 
00112 /* some global definitions */
00113 #define TINY_LEN        8
00114 #define SMALL_LEN       32
00115 #define MID_LEN         256
00116 #define BIG_LEN         4096
00117 #define HUGE_LEN        65536
00118 #define TRUE            1
00119 #define FALSE           0
00120 
00121 /*
00122  * get defintions of bcopy and/or memcpy
00123  * Different systems put them in string.h or strings.h, so get both
00124  * (with autoconf help).
00125  */
00126 #ifdef HAVE_STRING_H
00127 #include <string.h>
00128 #endif /* HAVE_STRING_H */
00129 #ifdef HAVE_STRINGS_H
00130 #include <strings.h>
00131 #endif /* HAVE_STRINGS_H */
00132 
00133 #ifndef HAVE_BZERO
00134 #define bzero(dest,count) memset(dest,0,count)
00135 #endif
00136 #ifndef HAVE_BCOPY
00137 #define bcopy(src,dest,size) memcpy(dest,src,size)
00138 #endif
00139 
00140 #include <stdlib.h>
00141 
00142 #ifdef HAVE_UNISTD_H
00143 #include <unistd.h>
00144 #endif /* HAVE_UNISTD_H */
00145 
00146 #ifdef HAVE_TIME_H
00147 #include <time.h>
00148 #endif /* HAVE_TIME_H */
00149 
00150 #ifdef HAVE_ARPA_INET_H
00151 #include <arpa/inet.h>
00152 #endif /* HAVE_ARPA_INET_H */
00153 
00154 #if (defined(__hpux) || defined(_AIX)) && defined(__cplusplus)
00155 /* these definitions are perhaps vestigal */
00156 extern "C" {
00157 int strcasecmp(const char *, const char *);
00158 clock_t clock(void);
00159 #if !defined(__hpux)
00160 int gethostid(void);
00161 #endif
00162 time_t time(time_t *);
00163 char *ctime(const time_t *);
00164 }
00165 #endif
00166 
00167 #if defined(NEED_SUNOS_PROTOS) && defined(__cplusplus)
00168 extern "C" {
00169 struct timeval;
00170 struct timezone;
00171 int gettimeofday(struct timeval*, ...);
00172 int ioctl(int fd, int request, ...);
00173 int close(int);
00174 int strcasecmp(const char*, const char*);
00175 int srandom(int);       /* (int) for sunos, (unsigned) for solaris */
00176 int random();
00177 int socket(int, int, int);
00178 int setsockopt(int s, int level, int optname, void* optval, int optlen);
00179 struct sockaddr;
00180 int connect(int s, sockaddr*, int);
00181 int bind(int s, sockaddr*, int);
00182 struct msghdr;
00183 int send(int s, void*, int len, int flags);
00184 int sendmsg(int, msghdr*, int);
00185 int recv(int, void*, int len, int flags);
00186 int recvfrom(int, void*, int len, int flags, sockaddr*, int);
00187 int gethostid();
00188 int getpid();
00189 int gethostname(char*, int);
00190 void abort();
00191 }
00192 #endif
00193 
00194 #if defined(SOLARIS_MIN_MAX)
00195 /* Macros for min/max. */
00196 #ifndef MIN
00197 #define MIN(a,b) (((a)<(b))?(a):(b))
00198 #endif /* MIN */
00199 #ifndef MAX
00200 #define MAX(a,b) (((a)>(b))?(a):(b))
00201 #endif  /* MAX */
00202 #endif
00203 
00204 #if defined(NEED_SUNOS_PROTOS) || defined(solaris)
00205 extern "C" {
00206 #if defined(NEED_SUNOS_PROTOS)
00207         caddr_t sbrk(int incr);
00208 #endif
00209         int getrusage(int who, struct rusage* rusage);
00210 }
00211 #endif
00212 
00213 #if defined(__SUNPRO_CC)
00214 #include <cmath>
00215 
00216 static double log(const int x)
00217 { return log((double)x); }
00218 
00219 static double log10(const int x)
00220 { return log10((double)x); }
00221 
00222 static double pow(const int x, const int y)
00223 { return std::pow((double)x,(double)y); }
00224 
00225 static double pow(const int x, const double y)
00226 { return std::pow((double)x,y); }
00227 #endif
00228 
00229 
00230 #ifdef WIN32
00231 
00232 #include <windows.h>
00233 #include <winsock.h>
00234 #include <time.h>               /* For clock_t */
00235 
00236 #include <minmax.h>
00237 #define NOMINMAX
00238 #undef min
00239 #undef max
00240 #undef abs
00241 
00242 #define MAXHOSTNAMELEN  256
00243 
00244 #define _SYS_NMLN       9
00245 struct utsname {
00246         char sysname[_SYS_NMLN];
00247         char nodename[_SYS_NMLN];
00248         char release[_SYS_NMLN];
00249         char version[_SYS_NMLN];
00250         char machine[_SYS_NMLN];
00251 };
00252 
00253 typedef char *caddr_t;
00254 
00255 struct iovec {
00256         caddr_t iov_base;
00257         int     iov_len;
00258 };
00259 
00260 #ifndef TIMEZONE_DEFINED_
00261 #define TIMEZONE_DEFINED_
00262 struct timezone {
00263         int tz_minuteswest;
00264         int tz_dsttime;
00265 };
00266 #endif
00267 
00268 typedef int pid_t;
00269 typedef int uid_t;
00270 typedef int gid_t;
00271 
00272 #if defined(__cplusplus)
00273 extern "C" {
00274 #endif
00275 
00276 int uname(struct utsname *); 
00277 int getopt(int, char * const *, const char *);
00278 int strcasecmp(const char *, const char *);
00279 /* these shouldn't be used/needed, even on windows */
00280 /* #define srandom srand */
00281 /* #define random rand */
00282 int gettimeofday(struct timeval *p, struct timezone *z);
00283 int gethostid(void);
00284 int getuid(void);
00285 int getgid(void);
00286 int getpid(void);
00287 int nice(int);
00288 int sendmsg(int, struct msghdr*, int);
00289 /* Why this is here, inside a #ifdef WIN32 ??
00290 #ifndef WIN32
00291         time_t time(time_t *);
00292 #endif
00293 */
00294 #define strncasecmp _strnicmp
00295 #if defined(__cplusplus)
00296 }
00297 #endif
00298 
00299 #ifdef WSAECONNREFUSED
00300 #define ECONNREFUSED    WSAECONNREFUSED
00301 #define ENETUNREACH     WSAENETUNREACH
00302 #define EHOSTUNREACH    WSAEHOSTUNREACH
00303 #define EWOULDBLOCK     WSAEWOULDBLOCK
00304 #endif /* WSAECONNREFUSED */
00305 
00306 #ifndef M_PI
00307 #define M_PI            3.14159265358979323846
00308 #endif /* M_PI */
00309 
00310 #endif /* WIN32 */
00311 
00312 #ifdef sgi
00313 #include <math.h>
00314 #endif
00315 
00316 /* Declare our implementation of snprintf() so that ns etc. can use it. */
00317 #ifndef HAVE_SNPRINTF
00318 #if defined(__cplusplus)
00319 extern "C" {
00320 #endif
00321         extern int snprintf(char *buf, int size, const char *fmt, ...);
00322 #if defined(__cplusplus)
00323 }
00324 #endif
00325 #endif
00326 
00327 /***** These values are no longer required to be hardcoded -- mask and shift values are 
00328         available from Class Address. *****/
00329 
00330 /* While changing these ensure that values are consistent with tcl/lib/ns-default.tcl */
00331 /* #define NODEMASK     0xffffff */
00332 /* #define NODESHIFT    8 */
00333 /* #define PORTMASK     0xff */
00334 
00335 #endif

Generated on Tue Aug 10 2010 16:16:06 for ns-2.33 by  doxygen 1.7.1