Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

config.h

Go to the documentation of this file.
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: /nfs/jade/vint/CVSROOT/ns-2/config.h,v 1.52 2002/05/22 18:57:09 johnh 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         ns_addr_t& operator= (const ns_addr_t& n) {
00085                 addr_ = n.addr_;
00086                 port_ = n.port_;
00087                 return (*this);
00088         }
00089         int operator== (const ns_addr_t& n) {
00090                 return ((addr_ == n.addr_) && (port_ == n.port_));
00091         }
00092 #endif // __cplusplus
00093 };
00094 
00095 // 64-bit integer support
00096 #if defined(SIZEOF_LONG) && SIZEOF_LONG >= 8
00097 #define STRTOI64 strtol
00098 #define STRTOI64_FMTSTR "%ld"
00099 //#define STRTOI64(S) strtol((S), NULL, 0)
00100 
00101 #elif defined(HAVE_STRTOQ)
00102 #define STRTOI64 strtoq
00103 #define STRTOI64_FMTSTR "%qd"
00104 //#define STRTOI64(S) strtoq((S), NULL, 0)
00105 
00106 #elif defined(HAVE_STRTOLL)
00107 #define STRTOI64 strtoll
00108 #define STRTOI64_FMTSTR "%lld"
00109 //#define STRTOI64(S) strtoll((S), NULL, 0)
00110 #endif
00111 
00112 #define NS_ALIGN        (8)     /* byte alignment for structs (eg packet.cc) */
00113 
00114 
00115 /* some global definitions */
00116 #define TINY_LEN        8
00117 #define SMALL_LEN       32
00118 #define MID_LEN         256
00119 #define BIG_LEN         4096
00120 #define HUGE_LEN        65536
00121 #define TRUE            1
00122 #define FALSE           0
00123 
00124 /*
00125  * get defintions of bcopy and/or memcpy
00126  * Different systems put them in string.h or strings.h, so get both
00127  * (with autoconf help).
00128  */
00129 #ifdef HAVE_STRING_H
00130 #include <string.h>
00131 #endif /* HAVE_STRING_H */
00132 #ifdef HAVE_STRINGS_H
00133 #include <strings.h>
00134 #endif /* HAVE_STRINGS_H */
00135 
00136 #ifndef HAVE_BZERO
00137 #define bzero(dest,count) memset(dest,0,count)
00138 #endif
00139 #ifndef HAVE_BCOPY
00140 #define bcopy(src,dest,size) memcpy(dest,src,size)
00141 #endif
00142 
00143 #include <stdlib.h>
00144 
00145 #ifdef HAVE_UNISTD_H
00146 #include <unistd.h>
00147 #endif /* HAVE_UNISTD_H */
00148 
00149 #ifdef HAVE_TIME_H
00150 #include <time.h>
00151 #endif /* HAVE_TIME_H */
00152 
00153 #ifdef HAVE_ARPA_INET_H
00154 #include <arpa/inet.h>
00155 #endif /* HAVE_ARPA_INET_H */
00156 
00157 #if (defined(__hpux) || defined(_AIX)) && defined(__cplusplus)
00158 /* these definitions are perhaps vestigal */
00159 extern "C" {
00160 int strcasecmp(const char *, const char *);
00161 clock_t clock(void);
00162 #if !defined(__hpux)
00163 int gethostid(void);
00164 #endif
00165 time_t time(time_t *);
00166 char *ctime(const time_t *);
00167 }
00168 #endif
00169 
00170 #if defined(NEED_SUNOS_PROTOS) && defined(__cplusplus)
00171 extern "C" {
00172 struct timeval;
00173 struct timezone;
00174 int gettimeofday(struct timeval*, ...);
00175 int ioctl(int fd, int request, ...);
00176 int close(int);
00177 int strcasecmp(const char*, const char*);
00178 int srandom(int);       /* (int) for sunos, (unsigned) for solaris */
00179 int random();
00180 int socket(int, int, int);
00181 int setsockopt(int s, int level, int optname, void* optval, int optlen);
00182 struct sockaddr;
00183 int connect(int s, sockaddr*, int);
00184 int bind(int s, sockaddr*, int);
00185 struct msghdr;
00186 int send(int s, void*, int len, int flags);
00187 int sendmsg(int, msghdr*, int);
00188 int recv(int, void*, int len, int flags);
00189 int recvfrom(int, void*, int len, int flags, sockaddr*, int);
00190 int gethostid();
00191 int getpid();
00192 int gethostname(char*, int);
00193 void abort();
00194 }
00195 #endif
00196 
00197 #if defined(NEED_SUNOS_PROTOS) || defined(solaris)
00198 extern "C" {
00199 #if defined(NEED_SUNOS_PROTOS)
00200         caddr_t sbrk(int incr);
00201 #endif
00202         int getrusage(int who, struct rusage* rusage);
00203 }
00204 #endif
00205 
00206 
00207 
00208 #ifdef WIN32
00209 
00210 #include <windows.h>
00211 #include <winsock.h>
00212 #include <time.h>               /* For clock_t */
00213 
00214 #include <minmax.h>
00215 #define NOMINMAX
00216 #undef min
00217 #undef max
00218 #undef abs
00219 
00220 #define MAXHOSTNAMELEN  256
00221 
00222 #define _SYS_NMLN       9
00223 struct utsname {
00224         char sysname[_SYS_NMLN];
00225         char nodename[_SYS_NMLN];
00226         char release[_SYS_NMLN];
00227         char version[_SYS_NMLN];
00228         char machine[_SYS_NMLN];
00229 };
00230 
00231 typedef char *caddr_t;
00232 
00233 struct iovec {
00234         caddr_t iov_base;
00235         int     iov_len;
00236 };
00237 
00238 #ifndef TIMEZONE_DEFINED_
00239 #define TIMEZONE_DEFINED_
00240 struct timezone {
00241         int tz_minuteswest;
00242         int tz_dsttime;
00243 };
00244 #endif
00245 
00246 typedef int pid_t;
00247 typedef int uid_t;
00248 typedef int gid_t;
00249 
00250 #if defined(__cplusplus)
00251 extern "C" {
00252 #endif
00253 
00254 int uname(struct utsname *); 
00255 int getopt(int, char * const *, const char *);
00256 int strcasecmp(const char *, const char *);
00257 /* these shouldn't be used/needed, even on windows */
00258 /* #define srandom srand */
00259 /* #define random rand */
00260 int gettimeofday(struct timeval *p, struct timezone *z);
00261 int gethostid(void);
00262 int getuid(void);
00263 int getgid(void);
00264 int getpid(void);
00265 int nice(int);
00266 int sendmsg(int, struct msghdr*, int);
00267 /* Why this is here, inside a #ifdef WIN32 ??
00268 #ifndef WIN32
00269         time_t time(time_t *);
00270 #endif
00271 */
00272 #define strncasecmp _strnicmp
00273 #if defined(__cplusplus)
00274 }
00275 #endif
00276 
00277 #ifdef WSAECONNREFUSED
00278 #define ECONNREFUSED    WSAECONNREFUSED
00279 #define ENETUNREACH     WSAENETUNREACH
00280 #define EHOSTUNREACH    WSAEHOSTUNREACH
00281 #define EWOULDBLOCK     WSAEWOULDBLOCK
00282 #endif /* WSAECONNREFUSED */
00283 
00284 #ifndef M_PI
00285 #define M_PI            3.14159265358979323846
00286 #endif /* M_PI */
00287 
00288 #endif /* WIN32 */
00289 
00290 #ifdef sgi
00291 #include <math.h>
00292 #endif
00293 
00294 // Declare our implementation of snprintf() so that ns etc. can use it. 
00295 #ifndef HAVE_SNPRINTF
00296 #if defined(__cplusplus)
00297 extern "C" {
00298 #endif
00299         extern int snprintf(char *buf, int size, const char *fmt, ...);
00300 #if defined(__cplusplus)
00301 }
00302 #endif
00303 #endif
00304 
00305 /***** These values are no longer required to be hardcoded -- mask and shift values are 
00306         available from Class Address. *****/
00307 
00308 /* While changing these ensure that values are consistent with tcl/lib/ns-default.tcl */
00309 /* #define NODEMASK     0xffffff */
00310 /* #define NODESHIFT    8 */
00311 /* #define PORTMASK     0xff */
00312 
00313 #endif

Generated on Tue Apr 20 12:14:12 2004 for NS2.26SourcesOriginal by doxygen 1.3.3