/* Virginia Tech Cognitive Radio Open Source Systems * Virginia Tech, 2009 * * LICENSE INFORMATION GOES HERE */ /* DESCRIPTION OF FILE. */ #include #include #include #include "vtcross/common.h" #include "vtcross/components.h" #include "vtcross/containers.h" #include "vtcross/debug.h" #include "vtcross/error.h" #include "vtcross/socketcomm.h" ServiceManagementLayer::ServiceManagementLayer() { LOG("Creating Service Management Layer.\n"); shellSocketFD = -1; LoadConfiguration(); } ServiceManagementLayer::~ServiceManagementLayer() { } ServiceManagementLayer::ServiceManagementLayer(const char* serverName, \ const char* serverPort) { LOG("Creating Service Management Layer.\n"); ConnectToShell(serverName, serverPort); LoadConfiguration(); } void ServiceManagementLayer::SendComponentType() { SendMessage(shellSocketFD, "response_sml"); LOG("SML responded to GetRemoteComponentType query.\n"); } void ServiceManagementLayer::ConnectToShell(const char* serverName, \ const char* serverPort) { shellSocketFD = ClientSocket(serverName, serverPort); RegisterComponent(); } void ServiceManagementLayer::WaitForSignal() { char buffer[256]; while(true) { memset(buffer, 0, 256); ReadMessage(shellSocketFD, buffer); // TODO // If we send integer op codes rather than strings, this process will be // MUCH faster since instead of donig string compares we can simply // switch on the integer value... if(strcmp(buffer, "register_service") == 0) { if(strcmp(buffer, "policy_geo") == 0) { } else if(strcmp(buffer, "policy_time") == 0) { } else if(strcmp(buffer, "policy_spectrum") == 0) { } else if(strcmp(buffer, "policy_spacial") == 0) { } } else if(strcmp(buffer, "deregister_service") == 0) { if(strcmp(buffer, "policy_geo") == 0) { } else if(strcmp(buffer, "policy_time") == 0) { } else if(strcmp(buffer, "policy_spectrum") == 0) { } else if(strcmp(buffer, "policy_spacial") == 0) { } } else if(strcmp(buffer, "query_component_type") == 0) { SendComponentType(); } else if(strcmp(buffer, "reset_sml") == 0) { Reset(); } else if(strcmp(buffer, "shutdown_sml") == 0) { Shutdown(); } } } void ServiceManagementLayer::Shutdown() { DeregisterComponent(); } void ServiceManagementLayer::Reset() { DeregisterComponent(); LoadConfiguration(); } void ServiceManagementLayer::RegisterComponent() { SendMessage(shellSocketFD, "register_sml"); LOG("ServiceManagementLayer:: Registration message sent.\n"); } void ServiceManagementLayer::DeregisterComponent() { SendMessage(shellSocketFD, "deregister_sml"); LOG("ServiceManagementLayer:: Deregistration message sent.\n"); shutdown(shellSocketFD, 2); close(shellSocketFD); shellSocketFD = -1; LOG("ServiceManagementLayer:: Shell socket closed.\n"); } void ServiceManagementLayer::TransferRadioConfiguration() { } void ServiceManagementLayer::TransferExperience() { } void ServiceManagementLayer::ReceiveServices() { } void ServiceManagementLayer::SetActiveMission() { } void ServiceManagementLayer::ListServices() { } void ServiceManagementLayer::ReloadConfiguration() { LOG("ServiceManagementLayer:: Reloading Configuration.\n"); } void ServiceManagementLayer::LoadConfiguration() { LOG("ServiceManagementLayer:: Loading Configuration.\n"); }