Index: /vtcross/trunk/src/include/vtcross/components.h
===================================================================
--- /vtcross/trunk/src/include/vtcross/components.h	(revision 193)
+++ /vtcross/trunk/src/include/vtcross/components.h	(revision 194)
@@ -49,4 +49,20 @@
         }
 
+        
+        /* Send an indentfying string for this object's component type in
+         * response to a GetRemoteComponentType query.
+         */
+        virtual void SendComponentType() = 0;
+
+
+        /* Connect to the remote control component, which will always be either
+         * the VTCROSS shell or SML.  Based on the status of the SML_present
+         * bool, this function will also register the component or services.
+         *
+         * TODO I feel like the name of this function could be changed to be a
+         * little more descriptive?
+         */
+        virtual void ConnectToRemoteComponent(const char* serverName, \
+                const char* serverPort) = 0;
 
         /* Wait for a command signal containing task instructions.
@@ -99,4 +115,7 @@
         ~ServiceManagementLayer();
 
+        void SendComponentType();
+        void ConnectToRemoteComponent(const char* serverName, \
+                const char* serverPort);
         void WaitForSignal();
         void Shutdown();
@@ -164,4 +183,7 @@
                 const bool SML);
 
+        void SendComponentType();
+        void ConnectToRemoteComponent(const char* serverName, \
+                const char* serverPort);
         void WaitForSignal();
         void Shutdown();
@@ -189,6 +211,5 @@
         /* Validate a set of transmission parameters received from the radio.
          */
-        void ValidateParameters(struct Parameter pList[], \
-                struct CE_Info *ce_info, int decision_array[]);
+        void ValidateParameters();
 
 
@@ -212,4 +233,7 @@
         ~CognitiveEngine();
 
+        void SendComponentType();
+        void ConnectToRemoteComponent(const char* serverName, \
+                const char* serverPort);
         void WaitForSignal();
         void Shutdown();
Index: /vtcross/trunk/src/policy_engines/PolicyEngine.cpp
===================================================================
--- /vtcross/trunk/src/policy_engines/PolicyEngine.cpp	(revision 193)
+++ /vtcross/trunk/src/policy_engines/PolicyEngine.cpp	(revision 194)
@@ -40,5 +40,23 @@
 
     SML_present = SML;
-
+    
+    ConnectToRemoteComponent(serverName, serverPort);
+
+    LoadPolicies();
+}
+
+
+void
+PolicyEngine::SendComponentType()
+{
+    SendMessage(commandSocketFD, "response_engine_policy");
+    LOG("Policy Engine responded to GetRemoteComponentType query.\n");
+}
+
+
+void
+PolicyEngine::ConnectToRemoteComponent(const char* serverName, \
+        const char* serverPort)
+{
     commandSocketFD = ClientSocket(serverName, serverPort);
 
@@ -51,6 +69,4 @@
         LOG("Policy Engine connected to shell at %s.\n", serverName);
     }
-
-    LoadPolicies();
 }
 
@@ -59,17 +75,78 @@
 PolicyEngine::WaitForSignal()
 {
-    LOG("Policy Engine:: Waiting for Policy Check Request.\n");
-
-    int32_t decision_array[10];
-    struct Parameter pList[10];
-    struct CE_Info ce_info;
-
-    // TODO should this be a GetRequest call or something else?
-    if(GetRequest(commandSocketFD, pList, &ce_info)) {
-        LOG("Policy Engine:: Validating Transmission Parameters.\n");
-        ValidateParameters(pList, &ce_info, decision_array);    
-
-        LOG("Policy Engine:: Sending Policy decision to Server.\n");
-        SendPEDecision(pList, &ce_info, decision_array);
+    char buffer[256];
+
+    while(true) {
+        memset(buffer, 0, 256);
+       
+        ReadMessage(commandSocketFD, buffer);
+
+        // TODO this is ugly... is there a better way? Doesn't strcmp compare the
+        // whole string?  We only need to compare until we find a single different
+        // byte...
+        if(strcmp(buffer, "validate_parameters") == 0) {
+            ValidateParameters();
+        }
+        else if(strcmp(buffer, "query_component_type") == 0) {
+            SendComponentType();
+        }
+        else if(strcmp(buffer, "connect_sml") == 0) {
+            /* This command implies that we are disconnecting from the shell and
+             * connecting to a SML component. */
+            char serverName[256];
+            char serverPort[256];
+            // TODO is this going to end up being too slow?
+            memset(serverName, 0, 256);
+            memset(serverPort, 0, 256);
+
+            ReadMessage(commandSocketFD, serverName);
+            ReadMessage(commandSocketFD, serverPort);
+
+            /* Only continue if we are currently connected to a shell. */
+            if(!SML_present) {
+                DeregisterComponent();
+
+                shutdown(commandSocketFD, 2);
+                close(commandSocketFD);
+
+                SML_present = true;
+
+                ConnectToRemoteComponent(serverName, serverPort);
+            }
+        }
+        else if(strcmp(buffer, "disconnect_sml") == 0) {
+            /* This command implies that we are disconnecting from the SML and
+             * connecting to a shell component. */
+            char serverName[256];
+            char serverPort[256];
+            // TODO is this going to end up being too slow?
+            memset(serverName, 0, 256);
+            memset(serverPort, 0, 256);
+
+            ReadMessage(commandSocketFD, serverName);
+            ReadMessage(commandSocketFD, serverPort);
+
+            /* We only want to do this if we are actually connected to an SML
+             * currently. */
+            if(SML_present) {
+                DeregisterServices();
+
+                shutdown(commandSocketFD, 2);
+                close(commandSocketFD);
+
+                SML_present = false;
+
+                ConnectToRemoteComponent(serverName, serverPort);
+            }
+        }
+        else if(strcmp(buffer, "relead_engine_configs") == 0) {
+            ReloadPolicies();
+        }
+        else if(strcmp(buffer, "reset_engine_policy") == 0) {
+            Reset();
+        }
+        else if(strcmp(buffer, "shutdown_engine_policy") == 0) {
+            Shutdown();
+        }
     }
 }
@@ -83,4 +160,6 @@
     else
         DeregisterComponent();
+
+    // TODO should something else be happening here?
 }
 
@@ -100,5 +179,5 @@
 {
     SendMessage(commandSocketFD, "register_engine_policy");
-    LOG("Policy Engine:: Registration message sent.\n");
+    LOG("Policy Engine:: Registration message sent to shell.\n");
 
 }
@@ -109,5 +188,5 @@
 {
     SendMessage(commandSocketFD, "deregister_engine_policy");
-    LOG("Policy Engine:: Registration message sent.\n");
+    LOG("Policy Engine:: Deregistration message sent to shell.\n");
 }
 
@@ -163,10 +242,25 @@
 
 void 
-PolicyEngine::ValidateParameters(struct Parameter pList[], \
-        struct CE_Info *ce_info, int decision_array[])
-{
-    LOG("Policy Engine:: Policies Validated.\n");
-    for (size_t i = 0; i < ce_info->numParameters; i++)
-        decision_array[i] = 1;
-}
-
+PolicyEngine::ValidateParameters()
+{
+    LOG("Policy Engine:: Preparing to receive parameters for validation....\n");
+
+    int32_t decision_array[10];
+    struct Parameter pList[10];
+    struct CE_Info ce_info;
+
+    if(GetRequest(commandSocketFD, pList, &ce_info)) {
+        LOG("Policy Engine:: Validating Transmission Parameters.\n");
+        for (size_t i = 0; i < ce_info.numParameters; i++)
+            decision_array[i] = 1;
+
+        LOG("Policy Engine:: Sending Policy decision to Server.\n");
+        SendPEDecision(pList, &ce_info, decision_array);
+
+        LOG("Policy Engine:: Policies Validated.\n");
+    }
+    else
+        ERROR(1, "Call to GetRequest in ValidateParameters failed.\n");
+
+}
+
