certi.hh

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 // CERTI - HLA RunTime Infrastructure
00003 // Copyright (C) 2002-2005  ONERA
00004 //
00005 // This program is free software ; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public License
00007 // as published by the Free Software Foundation ; either version 2 of
00008 // the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful, but
00011 // WITHOUT ANY WARRANTY ; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this program ; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00018 //
00019 // $Id: certi.hh,v 3.40 2009/04/02 19:58:11 erk Exp $
00020 // ----------------------------------------------------------------------------
00021 #include <vector>
00022 
00023 #ifndef CERTI_HH_INCLUDED
00024 #define CERTI_HH_INCLUDED
00025 #if defined(_WIN32)
00026     #include <windows.h>
00027     #include <algorithm>
00028     #include <process.h>
00029     #define sleep(a)          Sleep(a * 1000)
00030     #define usleep(a)         Sleep(a / 1000)
00031     typedef unsigned short        ushort;
00032     typedef int               pid_t;
00033     #define  strcasecmp           strcmp
00034     #define STAT_FUNCTION         _stat
00035     #define STAT_STRUCT           struct _stat
00036     /* TCP/IP related typedef and includes */
00037     #ifndef _WINSOCK2API_
00038         #ifndef _WINSOCKAPI_
00039        #include <winsock2.h>
00040     #endif
00041     #endif
00042     typedef u_long          in_addr_t;
00043     typedef unsigned short      in_port_t;
00044     #ifdef _MSC_VER
00045         typedef unsigned __int64        uint64_t;
00046         typedef __int64          int64_t;
00047         typedef unsigned __int32    uint32_t;
00048         typedef __int32          int32_t;
00049         typedef unsigned __int16    uint16_t;
00050         typedef __int16          int16_t;
00051         typedef unsigned __int8          uint8_t;
00052         typedef __int8            int8_t;
00053         #ifdef _M_X64
00054            #define  CERTI_INT64_CONSTANT(val)  (val##L)
00055            #define  CERTI_INT64_FORMAT         "l"
00056         #else
00057            #define  CERTI_INT64_CONSTANT(val)  (val##LL)
00058            #define  CERTI_INT64_FORMAT         "ll"
00059         #endif
00060         #ifndef __func__
00061         #define __func__ "<unknown>"
00062         #endif
00063     #else
00064        #include <inttypes.h>
00065        #ifdef __x86_64__
00066           #define  CERTI_INT64_CONSTANT(val)  (val##L)
00067           #define  CERTI_INT64_FORMAT         "l"
00068        #else
00069           #define  CERTI_INT64_CONSTANT(val)  (val##LL)
00070           #define  CERTI_INT64_FORMAT         "ll"
00071        #endif
00072     #endif
00073     #if defined(CERTI_EXPORTS)
00074         #define CERTI_EXPORT __declspec(dllexport)
00075     #else
00076         #define CERTI_EXPORT __declspec(dllimport)
00077     #endif
00078 #else
00079     #include <inttypes.h>
00080     #define  STAT_FUNCTION      stat
00081     #define  STAT_STRUCT        struct stat
00082     #ifdef __x86_64__
00083        #define  CERTI_INT64_CONSTANT(val)  (val##L)
00084        #define  CERTI_INT64_FORMAT         "l"
00085     #else
00086        #define  CERTI_INT64_CONSTANT(val)  (val##LL)
00087        #define  CERTI_INT64_FORMAT         "ll"
00088     #endif
00089     #define CERTI_EXPORT
00090 #endif
00091 
00092 #include "RTI.hh"
00093 
00100 // next used in RTIG::processIncomingMessage method
00101 #define BUFFER_EXCEPTION_REASON_SIZE 256
00102 
00103 namespace certi {
00104 
00105 typedef unsigned short UShort;
00106 typedef unsigned long ULong;
00107 typedef long Long;
00108 typedef ULong Handle;
00109 typedef Handle ObjectClassHandle;
00110 typedef Handle InteractionClassHandle;
00111 typedef ULong ExtentIndex;
00112 typedef Handle AttributeHandle;
00113 typedef Handle ParameterHandle;
00114 typedef Handle ObjectHandle;
00115 typedef Handle DimensionHandle;
00116 typedef Handle FederateHandle;
00117 typedef Handle OrderType;
00118 typedef Long SpaceHandle;
00119 typedef Handle TransportType;
00120 
00121 typedef RTI::EventRetractionHandle EventRetractionHandle;
00122 
00123 typedef UShort ObjectHandlecount ;
00124 typedef std::string ObjectName_t ;
00125 typedef std::string AttributeValue_t;
00126 typedef std::string ParameterValue_t;
00127 
00128 enum ObjectRemovalReason {
00129     OUT_OF_REGION = 1,
00130     OBJECT_DELETED,
00131     NO_LONGER_SUBSCRIBED
00132 };
00133 typedef Handle RegionHandle ;
00134 
00135 // Constants (former HLA constants)
00136 const TransportType RELIABLE = 1 ;
00137 const TransportType BEST_EFFORT = 2 ;
00138 const OrderType RECEIVE = 1 ;
00139 const OrderType TIMESTAMP = 2 ;
00140 
00141 // Constants
00142 const int MAX_BACKLOG = 256 ;
00143 
00144 } // namespace certi
00145 
00146 // Define this if you want the complete object and interaction tree to
00147 // be displayed as the FED file is read.
00148 // #define CREAD_DISPLAYS_ROOTOBJ
00149 
00150 // If you want statistics to be printed at the end of the execution,
00151 // uncomment the next line.
00152 #define RTI_PRINTS_STATISTICS
00153 
00154 // You can comment the next line out if you don't want to use Multicast.
00155 // #define FEDERATION_USES_MULTICAST
00156 
00157 // If this macro is defined, some messages will be sent on UDP sockets
00158 // by the RTIG to the RTIAs. Some messages types are NULL messages, and
00159 // all Reflect Attributes Values messages, and Receive Interaction messages,
00160 // even those with data asking for a "RELIABLE" service level.
00161 // #define HLA_USES_UDP
00162 
00163 // The next macro must contain the path name of the Audit File. It should
00164 // be an absolute path, but it may be a relative path for testing reasons.
00165 #define RTIG_AUDIT_FILENAME "RTIG.log"
00166 
00167 // Define the lower audit level you need, from AUDIT_MIN_LEVEL(0, all)
00168 // to AUDIT_MAX_LEVEL(10, min audit logging).
00169 // Level 0 : NULL messages(time synchronization)
00170 // Level 1 : Update Attribute Values messages
00171 // Level 2 : Send Interaction messages
00172 // Level 6 : Register / Delete Objects messages
00173 // Level 7 : Publish / Subscribe messages
00174 // Level 8 : Pause, Resume, Set Time regulating/constrained messages
00175 // Level 9 : Create/Join/Resign/Destroy Federation msgs, Connections.
00176 // Level 10: RTIG and Audit start/stop.
00177 #define AUDIT_CURRENT_LEVEL 5
00178 
00179 // ------------------------------
00180 // -- GSSAPI Security Services --
00181 // ------------------------------
00182 
00183 // Comment out HLA_USES_GSSAPI to choose NOT to use GSSAPI services.
00184 //#define HLA_USES_GSSAPI
00185 
00186 // Server Principal Name
00187 //(must be like "<rtip principal name>@<network machine name>")
00188 #define HLA_SERVER_PRINCIPAL_NAME "RTIG@server"
00189 
00190 // Expiration delay for GSSAPI sessions(must be greater then the longer
00191 // lifetime of a federate).[In seconds]
00192 #define HLA_GSS_SESSION_DURATION 3600
00193 
00194 // You can use GSSAPI at least to authenticate federates(needed to use
00195 // security levels), to sign all messages(source authentication), or
00196 // to sign AND encrypt message.[last option]
00197 // Just choose one of the three options below and affect it to the
00198 // RTI_GSSAPI_USAGE macro.
00199 #define RTI_GSS_NOTHING 0
00200 #define RTI_GSS_SIGN_ONLY 1
00201 #define RTI_GSS_ENCRYPT 2
00202 
00203 #define RTI_GSSAPI_USAGE RTI_GSS_NOTHING
00204 
00205 // Type of Security services needed : Can be any combination(OR) of the
00206 // following flags(see your GSSAPI documentation for further details) :
00207 //
00208 // GSS_C_DELEG_FLAG Credential delegation(not supported by HLA anyway)
00209 // GSS_C_MUTUAL_FLAG Mutual authentication
00210 // GSS_C_REPLAY_FLAG Replay detection
00211 // GSS_C_SEQUENCE_FLAG Out of sequence message detection.
00212 //
00213 // Note: Currently, no option is suppported by our default GSSAPI mechanism.
00214 #define HLA_GSS_FLAGS 0
00215 
00216 
00217 /*
00218  * Basic bit swapping functions
00219  */
00220 #define CERTI_UINT16_SWAP_BYTES(val)    ((uint16_t) ( \
00221     (((uint16_t) (val) & (uint16_t) 0x00ffU) << 8) |  \
00222     (((uint16_t) (val) & (uint16_t) 0xff00U) >> 8)))
00223 
00224 #define CERTI_UINT32_SWAP_BYTES(val)    ((uint32_t) (     \
00225     (((uint32_t) (val) & (uint32_t) 0x000000ffU) << 24) | \
00226     (((uint32_t) (val) & (uint32_t) 0x0000ff00U) <<  8) | \
00227     (((uint32_t) (val) & (uint32_t) 0x00ff0000U) >>  8) | \
00228     (((uint32_t) (val) & (uint32_t) 0xff000000U) >> 24)))
00229 
00230 #define CERTI_UINT64_SWAP_BYTES(val)    ((uint64_t) (                   \
00231       (((uint64_t) (val) &                      \
00232     (uint64_t) CERTI_INT64_CONSTANT(0x00000000000000ffU)) << 56) |  \
00233       (((uint64_t) (val) &                      \
00234     (uint64_t) CERTI_INT64_CONSTANT(0x000000000000ff00U)) << 40) |  \
00235       (((uint64_t) (val) &                      \
00236     (uint64_t) CERTI_INT64_CONSTANT(0x0000000000ff0000U)) << 24) |  \
00237       (((uint64_t) (val) &                      \
00238     (uint64_t) CERTI_INT64_CONSTANT(0x00000000ff000000U)) <<  8) |  \
00239       (((uint64_t) (val) &                      \
00240     (uint64_t) CERTI_INT64_CONSTANT(0x000000ff00000000U)) >>  8) |  \
00241       (((uint64_t) (val) &                      \
00242     (uint64_t) CERTI_INT64_CONSTANT(0x0000ff0000000000U)) >> 24) |  \
00243       (((uint64_t) (val) &                      \
00244     (uint64_t) CERTI_INT64_CONSTANT(0x00ff000000000000U)) >> 40) |  \
00245       (((uint64_t) (val) &                      \
00246     (uint64_t) CERTI_INT64_CONSTANT(0xff00000000000000U)) >> 56)))
00247 #endif // CERTI_HH_INCLUDED
00248 
00249 // $Id: certi.hh,v 3.40 2009/04/02 19:58:11 erk Exp $

Generated on Thu Apr 30 15:53:48 2009 for CERTIDeveloperDocumentation by doxygen 1.5.5