Changeset 186
- Timestamp:
- 03/22/09 23:35:05 (15 years ago)
- Location:
- vtcross/trunk/src
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/src/include/vtcross/components.h
r185 r186 78 78 virtual void RegisterServices(int32_t socketFD) = 0; 79 79 virtual void DeregisterServices(int32_t socketFD) = 0; 80 81 82 /* The RemoteComponent struct represents either the VTCROSS shell or the 83 * VTCROSS SML. If 'SML_present' is false, it is the former. Otherwise, 84 * it is the latter. 85 */ 86 bool SML_present; 87 struct RemoteComponent *control; 80 88 }; 81 89 … … 144 152 145 153 146 /* Overloaded constructor that creates a policy engine object with SML 147 * information pre-defined. 148 */ 149 PolicyEngine(const char* serverName, const char* portNumber); 154 /* Overloaded constructor that creates a policy engine object and 155 * connects it to either the shell or an SML, depening on the SML bool. 156 */ 157 PolicyEngine(const char* serverName, const char* portNumber, \ 158 const bool SML); 150 159 151 160 void GetRemoteComponentType(int32_t socketFD); … … 177 186 void ValidateParameters(struct Parameter pList[], \ 178 187 struct CE_Info *ce_info, int decision_array[]); 179 180 181 /* The RemoteComponent struct represents either the VTCROSS shell or the182 * VTCROSS SML. If 'SML_present' is false, it is the former. Otherwise,183 * it is the latter.184 */185 bool SML_present;186 struct RemoteComponent *control;187 188 }; 188 189 … … 244 245 */ 245 246 struct SML_Info *SML; 246 247 248 /* The RemoteComponent struct represents either the VTCROSS shell or the249 * VTCROSS SML. If 'SML_present' is false, it is the former. Otherwise,250 * it is the latter.251 */252 bool SML_present;253 struct RemoteComponent *control;254 255 247 }; 256 248 -
vtcross/trunk/src/include/vtcross/containers.h
r184 r186 86 86 */ 87 87 struct RemoteComponent { 88 struct hostent *server;89 88 std::string serverName; 90 89 int32_t serverPort; -
vtcross/trunk/src/lib/socketcomm/socketcomm.cpp
r184 r186 78 78 79 79 /* TODO see notes in socketcomm.h. This function, and the RemoteComponent 80 * struct, need a code review. 80 * struct, need a code review to make sure it is ready to be used rather 81 * than ClientSocket() 81 82 */ 82 83 void … … 90 91 ERROR(1, "No server found by that hostname."); 91 92 92 memcpy(serverInfo, server, sizeof(struct hostent));93 94 93 serverInfo->socketFD = socket(AF_INET, SOCK_STREAM, 0); 95 94 if(serverInfo->socketFD < 0) … … 232 231 int32_t clientSocket = accept(serverSock, NULL, NULL); 233 232 if(clientSocket < 0) 234 ERROR(1, "Could establish connection with client socket.\n");233 ERROR(1, "Could not establish connection with client socket.\n"); 235 234 236 235 LOG("Handling client %s\n", inet_ntoa(echoClientAddr.sin_addr)); -
vtcross/trunk/src/policy_engines/PolicyEngine.cpp
r185 r186 36 36 37 37 38 PolicyEngine::PolicyEngine(const char* serverName, const char* portNumber) 38 PolicyEngine::PolicyEngine(const char* serverName, const char* portNumber, \ 39 const bool SML) 39 40 { 40 41 LOG("Creating Policy Engine.\n"); 41 42 42 SML_present = true;43 SML_present = SML; 43 44 control = new RemoteComponent; 44 45 control->serverName = std::string(serverName); … … 46 47 47 48 control->socketFD = ClientSocket(serverName, portNumber); 48 RegisterServices(control->socketFD);49 49 50 LOG("Policy Engine connected to SML at %s.\n", serverName); 50 if(SML_present) { 51 RegisterServices(control->socketFD); 52 LOG("Policy Engine connected to SML at %s.\n", serverName); 53 } 54 else { 55 RegisterComponent(control->socketFD); 56 LOG("Policy Engine connected to shell at %s.\n", serverName); 57 } 51 58 52 59 LoadPolicies(); … … 85 92 if(SML_present) 86 93 DeregisterServices(control->socketFD); 87 // TODO otherwise, deregister from shell 94 else 95 DeregisterComponent(control->socketFD); 88 96 } 89 97 … … 92 100 PolicyEngine::Reset() 93 101 { 102 LOG("Resetting Policy Engine.\n"); 103 SML_present = false; 104 control = new RemoteComponent; 105 LoadPolicies(); 94 106 } 95 107 -
vtcross/trunk/src/policy_engines/policy_demo.cpp
r161 r186 31 31 ERROR(1, "Usage: %s hostname port\n", argv[0]); 32 32 33 LOG("Opening the client socket.\n"); 34 int32_t socketFD = ClientSocket(argv[1], argv[2]); 35 36 PolicyEngine policyEngine; 37 policyEngine.RegisterComponent(socketFD); 33 PolicyEngine policyEngine(argv[1], argv[2], false); 38 34 39 35 LOG("Waiting for signal...\n"); 40 36 while(1) { 41 policyEngine.WaitForSignal( socketFD);37 policyEngine.WaitForSignal(policyEngine.control->socketFD); 42 38 } 43 39