Completing Tomoyo policies for irrigation benchmark
authorrtrimana <rtrimana@uci.edu>
Mon, 24 Apr 2017 20:54:56 +0000 (13:54 -0700)
committerrtrimana <rtrimana@uci.edu>
Mon, 24 Apr 2017 20:54:56 +0000 (13:54 -0700)
iotjava/iotruntime/master/IoTMaster.java
iotjava/iotruntime/master/ProcessJailConfig.java
localconfig/tomoyo/Java.tomoyo.pol

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);
                        }
 
index 7b080fdec1bf4ff680967fd83467816377f6d31b..4781fbd38753c2462e7807bbf251fd386210c3b4 100644 (file)
@@ -316,6 +316,42 @@ public final class ProcessJailConfig {
        }
 
 
+       /**
+        * configureProcessJailDevicePolicies() method configures the device MAC policies
+        * <p>
+        * This method configures the device policies between device driver and device
+        *
+        * @param   strConfigHost                       String hostname to be configured
+        * @param   strRouterAddress            String router address
+        * @param   iPort                                       Integer port
+        * @return  void
+        */
+       public void configureProcessJailGWDevicePolicies(String strConfigHost, String strRouterAddress, int iPort) {
+
+               PrintWriter pwConfig = getPrintWriter(strConfigHost);
+               pwConfig.println("file read /home/iotuser/iot2/iotjava/iotruntime/\\*.jks");
+               pwConfig.println("file read /etc/resolv.conf");
+               pwConfig.println("file read /etc/hosts");
+               pwConfig.println("network inet dgram send " + strRouterAddress + " " + String.valueOf(iPort));
+       }
+
+
+       /**
+        * configureProcessJailDeviceDriverInetAddressPolicies() method configures the device MAC policies
+        * <p>
+        *
+        * @param   strConfigHost       String hostname to be configured
+        * @param   strAddress          String device IP address
+        * @return  void
+        */
+       public void configureProcessJailInetAddressPolicies(String strConfigHost, String strAddress) {
+
+               PrintWriter pwConfig = getPrintWriter(strConfigHost);
+               //System.out.println("\n\nDEBUG: Writing the config host address setup!!!\n\n");
+               pwConfig.println("network inet stream connect ::ffff:" + strAddress + " " + String.valueOf(80));        // HTTP access for this address
+       }
+
+
        /**
         * configureProcessJailControllerPolicies() method configures the main MAC policies for controller
         *
index 083348b3ba541c7c673e73a85bdbaa9c9bef6614..efcc432f200f326917954af0466acc052f1360fc 100644 (file)
@@ -43,6 +43,8 @@ file read /home/iotuser/iot2/iotjava/iotruntime/\*.config
 network inet stream connect ::ffff:<master-ip-address> <master-com-port>
 file read /home/iotuser/iot2/iotjava/iotruntime/master/\*.class
 file read /home/iotuser/iot2/iotjava/iotruntime/messages/\*.class
+file read /home/iotuser/iot2/iotjava/iotruntime/zigbee/\*.class
+file read /home/iotuser/iot2/iotjava/iotruntime/resources/\*.csv
 file read /dev/random
 file read /dev/urandom
 file create /home/iotuser/iot2/iotjava/iotruntime/<object-class-name>.jar 0666