|
Mixe for Privacy and Anonymity in the Internet
|
00001 /* 00002 Copyright (c) The JAP-Team, JonDos GmbH 00003 00004 All rights reserved. 00005 00006 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 00007 00008 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 00009 * Redistributions in binary form must reproduce the above copyright notice, 00010 this list of conditions and the following disclaimer in the documentation and/or 00011 other materials provided with the distribution. 00012 * Neither the name of the University of Technology Dresden, Germany, nor the name of 00013 the JonDos GmbH, nor the names of their contributors may be used to endorse or 00014 promote products derived from this software without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00017 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00018 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00019 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 00020 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00021 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00022 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00023 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00024 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00025 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00026 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 */ 00028 #ifndef CASTATUSMANAGER_HPP_ 00029 #define CASTATUSMANAGER_HPP_ 00030 00038 #include "StdAfx.h" 00039 00040 #ifdef SERVER_MONITORING 00041 00042 #include "CASocket.hpp" 00043 #include "CAThread.hpp" 00044 #include "CASocketAddrINet.hpp" 00045 /* This contains the whole state machine 00046 * definitions including typedefs 00047 */ 00048 #include "monitoringDefs.h" 00049 00050 struct dom_state_info 00051 { 00052 DOMElement *dsi_stateType; 00053 DOMElement *dsi_stateLevel; 00054 DOMElement *dsi_stateDesc; 00055 }; 00056 00057 typedef struct dom_state_info dom_state_info_t; 00058 00065 THREAD_RETURN serveMonitoringRequests(void* param); 00066 00067 class CAStatusManager 00068 { 00069 00070 public: 00071 00072 static void init(); 00073 static void cleanup(); 00074 /* Function to be called when an event occured, 00075 * may cause changing of current state 00076 */ 00077 static SINT32 fireEvent(event_type_t e_type, status_type_t s_type); 00078 00079 private: 00080 /* current states for each status type */ 00081 state_t **m_pCurrentStates; 00082 /* Keeps references to the nodes of the DOM tree 00083 * where the current Status informations are set 00084 */ 00085 dom_state_info_t *m_pCurrentStatesInfo; 00086 /* synchronized access to all fields */ 00087 CAMutex *m_pStatusLock; 00088 /* ServerSocket to listen for monitoring requests */ 00089 CASocket *m_pStatusSocket; 00090 CASocketAddrINet *m_pListenAddr; 00091 volatile bool m_bTryListen; 00092 /* Thread to answer monitoring requests */ 00093 CAThread *m_pMonitoringThread; 00094 /* the DOM structure to create the XML status message */ 00095 XERCES_CPP_NAMESPACE::DOMDocument* m_pPreparedStatusMessage; 00096 00097 /* StatusManger singleton */ 00098 static CAStatusManager *ms_pStatusManager; 00099 /* holds the references of all defined states 00100 * accessed by [status_type][state_type] 00101 */ 00102 static state_t ***ms_pAllStates; 00103 /* holds the references of all defined events 00104 * accessed by [status_type][event_type] 00105 */ 00106 static event_t ***ms_pAllEvents; 00107 00108 CAStatusManager(); 00109 virtual ~CAStatusManager(); 00110 00111 SINT32 initSocket(); 00112 00113 static void initStates(); 00114 static void initEvents(); 00115 00116 static void deleteStates(); 00117 static void deleteEvents(); 00118 00119 /* changes state (only called by fireEvent) */ 00120 SINT32 transition(event_type_t e_type, status_type_t s_type); 00121 SINT32 initStatusMessage(); 00122 00123 /* monitoring server routine */ 00124 friend THREAD_RETURN serveMonitoringRequests(void* param); 00125 }; 00126 00127 #define MONITORING_FIRE_NET_EVENT(e_type) \ 00128 MONITORING_FIRE_EVENT(e_type, stat_networking) 00129 #define MONITORING_FIRE_PAY_EVENT(e_type) \ 00130 MONITORING_FIRE_EVENT(e_type, stat_payment) 00131 #define MONITORING_FIRE_SYS_EVENT(e_type) \ 00132 MONITORING_FIRE_EVENT(e_type, stat_system) 00133 00134 #define MONITORING_FIRE_EVENT(e_type, s_type) \ 00135 CAStatusManager::fireEvent(e_type, s_type) 00136 00137 #else /* SERVER_MONITORING */ 00138 00139 #define MONITORING_FIRE_NET_EVENT(e_type) 00140 #define MONITORING_FIRE_PAY_EVENT(e_type) 00141 #define MONITORING_FIRE_SYS_EVENT(e_type) 00142 00143 #define MONITORING_FIRE_EVENT(e_type, s_type) 00144 00145 #endif /* SERVER_MONITORING */ 00146 00147 #endif /*CASTATUSMANAGER_HPP_*/
1.7.6.1