Completing Tomoyo policies for irrigation benchmark
[iot2.git] / iotjava / iotruntime / master / IoTMaster.java
index ed199d044f39c0be957207eb82eed6a9d6d3a809..568c939a9b2448a1cc323db7a1e60729be5eb900 100644 (file)
@@ -138,6 +138,7 @@ public class IoTMaster {
        private static final String STR_MAC_POL_PATH = "tomoyo/";
 
        private static int INT_SIZE = 4;        // send length in the size of integer (4 bytes)
+       private static final int INT_DNS_PORT = 53;
 
        /**
         * Runtime class name constants - not to be configured by users
@@ -730,6 +731,8 @@ public class IoTMaster {
                                routerConfig.configureHostMainPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveObjectHostAdd, strDeviceAddress, STR_TCP_PROTOCOL, iDestDeviceDriverPort);
                                routerConfig.configureRouterHTTPPolicies(STR_ROUTER_ADD, strIoTSlaveObjectHostAdd, strDeviceAddress);
                                routerConfig.configureHostHTTPPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveObjectHostAdd, strDeviceAddress);
+                               // Configure MAC policies
+                               processJailConfig.configureProcessJailGWDevicePolicies(strIoTSlaveObjectHostAdd, STR_ROUTER_ADD, INT_DNS_PORT);
                        } else {
                                // Other port numbers...
                                commHan.addDevicePort(iDestDeviceDriverPort);
@@ -753,7 +756,7 @@ public class IoTMaster {
         * @return  void
         */
        private void setRouterPolicyIoTSetAddress(String strFieldIdentifier, Map.Entry<String,Object> map, 
-               String strHostAddress) {
+               String strHostAddress, String strControllerName) {
 
                // Get information from the set
                SetInstrumenter setInstrumenter = (SetInstrumenter) map.getValue();
@@ -766,6 +769,11 @@ public class IoTMaster {
                        // Get device address
                        String strAddress = (String) arrFieldValues[0];
                        // Setting up router policies for HTTP/HTTPs
+                       if (strControllerName != null) {
+                               processJailConfig.configureProcessJailInetAddressPolicies(strControllerName, strAddress);
+                       } else {
+                               processJailConfig.configureProcessJailInetAddressPolicies(strHostAddress, strAddress);
+                       }
                        routerConfig.configureRouterHTTPPolicies(STR_ROUTER_ADD, strHostAddress, strAddress);
                        routerConfig.configureHostHTTPPolicies(strHostAddress, strHostAddress, strAddress);
                }
@@ -820,7 +828,7 @@ public class IoTMaster {
                                        setRouterPolicyIoTSetDevice(strFieldIdentifier, map, strIoTSlaveObjectHostAdd);
                                } else if(setInstrumenter.getObjTableName().equals(STR_IOT_ADD_CLS)) { 
                                // Instrument the IoTAddress
-                                       setRouterPolicyIoTSetAddress(strFieldIdentifier, map, strIoTSlaveObjectHostAdd);
+                                       setRouterPolicyIoTSetAddress(strFieldIdentifier, map, strIoTSlaveObjectHostAdd, null);
                                } else if(setInstrumenter.getObjTableName().equals(STR_IOT_ZB_ADD_CLS)) { 
                                // Instrument the IoTZigbeeAddress - special feature for Zigbee device support
                                        RuntimeOutput.print("IoTMaster: IoTZigbeeAddress found! No router policy is set here..", 
@@ -2101,7 +2109,7 @@ public class IoTMaster {
                                                        throw new Error(strErrMsg);
                                                } else if(setInstrumenter.getObjTableName().equals(STR_IOT_ADD_CLS)) { 
                                                // Instrument the IoTAddress
-                                                       setRouterPolicyIoTSetAddress(strFieldName, map, strIoTSlaveControllerHostAdd);
+                                                       setRouterPolicyIoTSetAddress(strFieldName, map, strIoTSlaveControllerHostAdd, strObjControllerName);
                                                        instrumentIoTSetAddress(strFieldName, strFieldName, inStream, outStream, STR_LANGUAGE_CONTROLLER);
                                                } else {
                                                // Any other cases
@@ -2184,6 +2192,7 @@ public class IoTMaster {
                                serverSocket.close();
                                commHan.printLists();
                                lbIoT.printHostInfo();
+                               // TODO: Uncomment this - just for experiments!
                                createMACPolicyThreads(setAddresses);
                        }