networkmessage.hh
来自「certi-SHM-3.0.tar 不错的开源的分布式方针软件 大家多多支持 他」· HH 代码 · 共 187 行
HH
187 行
// -*- mode:C++ ; tab-width:4 ; c-basic-offset:4 ; indent-tabs-mode:nil -*-// ----------------------------------------------------------------------------// CERTI - HLA RunTime Infrastructure// Copyright (C) 2002, 2003 ONERA//// This file is part of CERTI-libCERTI//// CERTI-libCERTI is free software ; you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public License// as published by the Free Software Foundation ; either version 2 of// the License, or (at your option) Any later version.//// CERTI-libCERTI is distributed in the hope that it will be useful, but// WITHOUT ANY WARRANTY ; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU// Lesser General Public License for more details.//// You should have received a copy of the GNU Lesser General Public// License along with this program ; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307// USA//// $Id: NetworkMessage.hh,v 3.4 2003/03/21 15:06:46 breholee Exp $// ----------------------------------------------------------------------------#ifndef _CERTI_NETWORK_MESSAGE#define _CERTI_NETWORK_MESSAGE#include <cstdio>#include <cstring>#include <sched.h>#include <unistd.h>#include "baseTypes.hh"#include "RTItypes.hh"#include "Exception.hh"#include "PrettyDebug.hh"#include "Socket.hh"#include "MessageBody.hh"#ifdef FEDERATION_USES_MULTICAST#define MC_PORT 60123#define ADRESSE_MULTICAST "224.0.0.251"#endif // FEDERATION_USES_MULTICAST#define PORT_TCP_RTIG "60400"#define PORT_UDP_RTIG "60500"// Taille de la chaine de caract鑢es du message#define TAILLE_MESSAGE 256// Constantes full and empty#define FULL '1'#define EMPTY '0'// Nombre max de clients#define MAX_CLIENTS 100#define MAX_EXCEPTION_REASON_LENGTH 100namespace certi {typedef enum { m_NOT_TYPED = 0, // Not used. m_CLOSE_CONNEXION, m_MESSAGE_NULL, m_CREATE_FEDERATION_EXECUTION, m_DESTROY_FEDERATION_EXECUTION, m_JOIN_FEDERATION_EXECUTION, m_RESIGN_FEDERATION_EXECUTION, m_SET_TIME_REGULATING, m_SET_TIME_CONSTRAINED, m_REGISTER_FEDERATION_SYNCHRONIZATION_POINT, m_SYNCHRONIZATION_POINT_REGISTRATION_SUCCEEDED, // RTIG to RTIA m_ANNOUNCE_SYNCHRONIZATION_POINT, // RTIG to RTIA m_SYNCHRONIZATION_POINT_ACHIEVED, m_FEDERATION_SYNCHRONIZED, // RTIG to RTIA m_PUBLISH_OBJECT_CLASS, m_UNPUBLISH_OBJECT_CLASS, m_PUBLISH_INTERACTION_CLASS, m_UNPUBLISH_INTERACTION_CLASS, m_SUBSCRIBE_OBJECT_CLASS, m_UNSUBSCRIBE_OBJECT_CLASS, m_SUBSCRIBE_INTERACTION_CLASS, m_UNSUBSCRIBE_INTERACTION_CLASS, m_TURN_INTERACTIONS_ON, // Uniquement RTIG->RTIA m_TURN_INTERACTIONS_OFF, // Uniquement RTIG->RTIA m_REQUEST_ID, m_REGISTER_OBJECT, m_DISCOVER_OBJECT, // Uniquement RTIG->RTIA m_UPDATE_ATTRIBUTE_VALUES, m_REFLECT_ATTRIBUTE_VALUES, // Uniquement RTIG->RTIA m_SEND_INTERACTION, m_RECEIVE_INTERACTION, // Uniquement RTIG->RTIA m_DELETE_OBJECT, m_REMOVE_OBJECT, // Uniquement RTIG->RTIA m_CHANGE_ATTRIBUTE_TRANSPORT_TYPE, m_CHANGE_ATTRIBUTE_ORDER_TYPE, m_CHANGE_INTERACTION_TRANSPORT_TYPE, m_CHANGE_INTERACTION_ORDER_TYPE, m_REQUEST_CLASS_ATTRIBUTE_VALUE_UPDATE, m_REQUEST_OBJECT_ATTRIBUTE_VALUE_UPDATE, m_IS_ATTRIBUTE_OWNED_BY_FEDERATE, m_QUERY_ATTRIBUTE_OWNERSHIP, m_ATTRIBUTE_IS_NOT_OWNED, m_INFORM_ATTRIBUTE_OWNERSHIP, m_NEGOTIATED_ATTRIBUTE_OWNERSHIP_DIVESTITURE, m_ATTRIBUTE_OWNERSHIP_ACQUISITION_NOTIFICATION, m_ATTRIBUTE_OWNERSHIP_DIVESTITURE_NOTIFICATION, m_REQUEST_ATTRIBUTE_OWNERSHIP_ASSUMPTION, m_ATTRIBUTE_OWNERSHIP_UNAVAILABLE, m_ATTRIBUTE_OWNERSHIP_ACQUISITION_IF_AVAILABLE, m_UNCONDITIONAL_ATTRIBUTE_OWNERSHIP_DIVESTITURE, m_ATTRIBUTE_OWNERSHIP_ACQUISITION, m_REQUEST_ATTRIBUTE_OWNERSHIP_RELEASE, m_CANCEL_NEGOTIATED_ATTRIBUTE_OWNERSHIP_DIVESTITURE, m_ATTRIBUTE_OWNERSHIP_RELEASE_RESPONSE, m_CANCEL_ATTRIBUTE_OWNERSHIP_ACQUISITION, m_CONFIRM_ATTRIBUTE_OWNERSHIP_ACQUISITION_CANCELLATION} TypeNetworkMessage ;typedef struct { FederationTime date ; // Date, Logical Time Boolean R_or_C ; // IsRegulator or IsConstrained} TimeStruct ;typedef struct { ObjectHandlecount count ; ObjectHandle first ; ObjectHandle last ;} ReqIDStruct ;typedef struct { ObjectClassHandle handle ; UShort handleArraySize ; TransportType transport ; OrderType order ;} T_O_Struct ;typedef struct { int NbReg ; unsigned long AdrMC ; unsigned long Addr ; unsigned int peer ;} JoinStruct ;typedef struct { ObjectClassHandle handle ; UShort size ; FederationTime date ;} O_I_Struct ;typedef union { TimeStruct time ; // Les noms des variables n'ont pas d'importance ReqIDStruct ReqID ; // mais ils doivent etre presents. T_O_Struct T_O ; JoinStruct Join ; O_I_Struct O_I ;} HeaderUnion ;typedef struct { TypeNetworkMessage type ; TypeException exception ; FederationHandle federation ; FederateHandle federate ; UShort bodySize ; HeaderUnion VP ; // Variable Part} HeaderStruct ; // Shared Memory de communication entre client et serveurtypedef struct { char qui ; // char de synchronisation HeaderStruct Header ; MessageBody Body ;} SharedMemory ;typedef struct { SharedMemory S_C ; // Zone serveur vers client SharedMemory C_S ; // Zone client vers serveur} SHM ; // Segment M閙oire pour la communication des id's de m閙oires partag閑s typedef struct { long num_client_propose ; // num閞o de client = nom du f閐閞
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?