Merge "Cleanup and javadocs for SDN-IP code"
diff --git a/apps/optical/src/main/java/org/onlab/onos/optical/cfg/OpticalConfigProvider.java b/apps/optical/src/main/java/org/onlab/onos/optical/cfg/OpticalConfigProvider.java
index cfdeb1f..cba4e46 100644
--- a/apps/optical/src/main/java/org/onlab/onos/optical/cfg/OpticalConfigProvider.java
+++ b/apps/optical/src/main/java/org/onlab/onos/optical/cfg/OpticalConfigProvider.java
@@ -58,7 +58,7 @@
 
     // TODO: fix hard coded file path later.
     private static final String DEFAULT_CONFIG_FILE =
-            "/opt/onos/config/demo-3-roadm-2-ps.json";
+            "config/demo-3-roadm-2-ps.json";
     private String configFileName = DEFAULT_CONFIG_FILE;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -83,7 +83,8 @@
     protected OpticalNetworkConfig opticalNetworkConfig;
 
     public OpticalConfigProvider() {
-        super(new ProviderId("optical", "org.onlab.onos.provider.opticalConfig", true));
+        super(new ProviderId("optical", "org.onlab.onos.provider" +
+                ".opticalConfig"));
     }
 
     @Activate
diff --git a/apps/optical/src/main/resources/demo-3-roadm-2-ps.json b/apps/optical/src/main/resources/demo-3-roadm-2-ps.json
index 20b7db2..13e415d 100644
--- a/apps/optical/src/main/resources/demo-3-roadm-2-ps.json
+++ b/apps/optical/src/main/resources/demo-3-roadm-2-ps.json
@@ -47,7 +47,7 @@
                 "nodeName1": "ROADM1",
                 "nodeName2": "ROADM3",
                 "numWaves": 80,
-                "port1": 10,
+                "port1": 20,
                 "port2": 30
             },
             "type": "wdmLink"
@@ -91,7 +91,7 @@
                 "nodeName2": "ROADM2",
                 "numWaves": 80,
                 "port1": 31,
-                "port2": 20
+                "port2": 21
             },
             "type": "wdmLink"
         },
@@ -105,7 +105,7 @@
                 "nodeName2": "ROADM1",
                 "bandWidth": 100000,
                 "port1": 10,
-                "port2": 11
+                "port2": 10
             },
             "type": "pktOptLink"
         },
@@ -132,7 +132,7 @@
                 "nodeName2": "ROADM2",
                 "bandWidth": 100000,
                 "port1": 10,
-                "port2": 21
+                "port2": 11
             },
             "type": "pktOptLink"
         },
diff --git a/openflow/ctl/src/main/java/org/onlab/onos/openflow/drivers/impl/OFOpticalSwitchImplLINC13.java b/openflow/ctl/src/main/java/org/onlab/onos/openflow/drivers/impl/OFOpticalSwitchImplLINC13.java
index d65a15f..0d28a50 100644
--- a/openflow/ctl/src/main/java/org/onlab/onos/openflow/drivers/impl/OFOpticalSwitchImplLINC13.java
+++ b/openflow/ctl/src/main/java/org/onlab/onos/openflow/drivers/impl/OFOpticalSwitchImplLINC13.java
@@ -11,24 +11,12 @@
 import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest;
 import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
 import org.projectfloodlight.openflow.protocol.OFErrorMsg;
-import org.projectfloodlight.openflow.protocol.OFMatchV3;
 import org.projectfloodlight.openflow.protocol.OFMessage;
-import org.projectfloodlight.openflow.protocol.OFOxmList;
 import org.projectfloodlight.openflow.protocol.OFPortDesc;
 import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
 import org.projectfloodlight.openflow.protocol.OFPortOptical;
 import org.projectfloodlight.openflow.protocol.OFStatsReply;
 import org.projectfloodlight.openflow.protocol.OFStatsType;
-import org.projectfloodlight.openflow.protocol.action.OFAction;
-import org.projectfloodlight.openflow.protocol.action.OFActionCircuit;
-import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
-import org.projectfloodlight.openflow.protocol.oxm.OFOxmInPort;
-import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigid;
-import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic;
-import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigtype;
-import org.projectfloodlight.openflow.types.CircuitSignalID;
-import org.projectfloodlight.openflow.types.OFPort;
-import org.projectfloodlight.openflow.types.U8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -131,12 +119,6 @@
                             (OFCircuitPortsReply) m);
                     driverHandshakeComplete.set(true);
                 }
-                /*try {
-                    testMA();
-                    testReverseMA();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }*/
                 break;
             default:
                 log.warn("Received message {} during switch-driver " +
@@ -190,7 +172,6 @@
         this.write(Collections.<OFMessage>singletonList(circuitPortsRequest));
     }
 
-
     @Override
     public List<OFPortDesc> getPorts() {
         List<OFPortDesc> portEntries = new ArrayList<>();
@@ -201,358 +182,6 @@
         return Collections.unmodifiableList(portEntries);
     }
 
-
-    public static final U8 SIGNAL_TYPE = U8.of((short) 10);
-    private void testMA() throws IOException {
-        log.debug("LINC OE *** Testing MA ");
-        short lambda = 1;
-        if (getId() == 0x0000ffffffffff01L) {
-            final int inport = 10;
-            final int outport = 20;
-            //Circuit signal id
-            CircuitSignalID sigID = getSignalID(lambda);
-
-            OFOxmOchSigidBasic ofOxmOchSigidBasic =
-                    factory().oxms().ochSigidBasic(sigID);
-
-
-            //Match Port
-            OFOxmInPort fieldPort = factory().oxms()
-                                                .inPort(OFPort.of(inport));
-            OFMatchV3 matchPort =
-                    factory()
-                            .buildMatchV3().
-                            setOxmList(OFOxmList.of(fieldPort)).build();
-
-
-            // Set Action outport ,sigType and sigID
-            List<OFAction> actionList = new ArrayList<>();
-            OFAction actionOutPort =
-                    factory().actions().output(OFPort.of(outport),
-                                                  0xffff);
-
-            OFActionCircuit actionCircuit = factory()
-                    .actions()
-                    .circuit(ofOxmOchSigidBasic);
-
-            actionList.add(actionCircuit);
-            actionList.add(actionOutPort);
-
-            OFInstruction instructionAction =
-                    factory().instructions().buildApplyActions()
-                                .setActions(actionList)
-                                .build();
-            List<OFInstruction> instructions =
-                    Collections.singletonList(instructionAction);
-
-            OFMessage opticalFlowEntry =
-                    factory().buildFlowAdd()
-                                .setMatch(matchPort)
-                                .setPriority(100)
-                                .setInstructions(instructions)
-                                .setXid(getNextTransactionId())
-                                .build();
-            log.debug("Adding optical flow in sw {}", getStringId());
-            List<OFMessage> msglist = new ArrayList<>(1);
-            msglist.add(opticalFlowEntry);
-            write(msglist);
-            sendBarrier(true);
-        } else if (getId() == 0x0000ffffffffff03L) {
-            final int inport = 30;
-            final int outport = 31;
-            //Circuit signal id
-            CircuitSignalID sigID = getSignalID(lambda);
-
-            OFOxmOchSigid fieldSigIDMatch = factory().oxms().ochSigid(sigID);
-            OFOxmOchSigtype fieldSigType = factory()
-                    .oxms()
-                    .ochSigtype(SIGNAL_TYPE);
-
-            OFOxmOchSigidBasic ofOxmOchSigidBasic =
-                    factory().oxms().ochSigidBasic(sigID);
-
-            //Match Port,SigType,SigID
-            OFOxmInPort fieldPort = factory()
-                    .oxms()
-                    .inPort(OFPort.of(inport));
-            OFMatchV3 matchPort = factory()
-                    .buildMatchV3()
-                    .setOxmList(OFOxmList.of(fieldPort,
-                                             fieldSigIDMatch,
-                                             fieldSigType
-                    ))
-                    .build();
-
-            // Set Action outport ,SigType, sigID
-            List<OFAction> actionList = new ArrayList<>();
-            OFAction actionOutPort =
-                    factory().actions().output(OFPort.of(outport),
-                                                  0xffff);
-
-            OFActionCircuit actionCircuit = factory()
-                    .actions()
-                    .circuit(ofOxmOchSigidBasic);
-
-
-
-            //actionList.add(setActionSigType);
-            actionList.add(actionCircuit);
-            actionList.add(actionOutPort);
-
-            OFInstruction instructionAction =
-                    factory().instructions().buildApplyActions()
-                                .setActions(actionList)
-                                .build();
-            List<OFInstruction> instructions =
-                    Collections.singletonList(instructionAction);
-
-            OFMessage opticalFlowEntry =
-                    factory().buildFlowAdd()
-                                .setMatch(matchPort)
-                                .setPriority(100)
-                                .setInstructions(instructions)
-                                .setXid(getNextTransactionId())
-                                .build();
-            log.debug("Adding optical flow in sw {}", getStringId());
-            List<OFMessage> msglist = new ArrayList<>(1);
-            msglist.add(opticalFlowEntry);
-            write(msglist);
-            sendBarrier(true);
-
-        } else if (getId() == 0x0000ffffffffff02L) {
-            final int inport = 21;
-            final int outport = 11;
-            //Circuit signal id
-            CircuitSignalID sigID = getSignalID(lambda);
-
-            OFOxmOchSigid fieldSigIDMatch = factory().oxms().ochSigid(sigID);
-            OFOxmOchSigtype fieldSigType = factory()
-                    .oxms()
-                    .ochSigtype(SIGNAL_TYPE);
-
-
-            //Match Port, sig type and sig id
-            OFOxmInPort fieldPort = factory()
-                    .oxms()
-                    .inPort(OFPort.of(inport));
-            OFMatchV3 matchPort =
-                    factory().buildMatchV3()
-                                .setOxmList(OFOxmList.of(fieldPort,
-                                                         fieldSigIDMatch,
-                                                         fieldSigType
-                                ))
-                                .build();
-
-            // Set Action outport
-            List<OFAction> actionList = new ArrayList<>();
-            OFAction actionOutPort =
-                    factory().actions().output(OFPort.of(outport),
-                                                  0xffff);
-
-            actionList.add(actionOutPort);
-
-            OFInstruction instructionAction =
-                    factory().instructions().buildApplyActions()
-                                .setActions(actionList)
-                                .build();
-            List<OFInstruction> instructions =
-                    Collections.singletonList(instructionAction);
-
-            OFMessage opticalFlowEntry =
-                    factory().buildFlowAdd()
-                                .setMatch(matchPort)
-                                .setPriority(100)
-                                .setInstructions(instructions)
-                                .setXid(getNextTransactionId())
-                                .build();
-            log.debug("Adding optical flow in sw {}", getStringId());
-            List<OFMessage> msglist = new ArrayList<>(1);
-            msglist.add(opticalFlowEntry);
-            write(msglist);
-            sendBarrier(true);
-        }
-
-    }
-    private void testReverseMA() throws IOException {
-        log.debug("LINC OE *** Testing MA ");
-        short lambda = 1;
-        if (getId() == 0x0000ffffffffff02L) {
-            final int inport = 11;
-            final int outport = 21;
-            //Circuit signal id
-            CircuitSignalID sigID = getSignalID(lambda);
-
-            OFOxmOchSigidBasic ofOxmOchSigidBasic =
-                    factory().oxms().ochSigidBasic(sigID);
-
-            //Match Port
-            OFOxmInPort fieldPort = factory().oxms()
-                                                .inPort(OFPort.of(inport));
-            OFMatchV3 matchPort =
-                    factory()
-                            .buildMatchV3().
-                            setOxmList(OFOxmList.of(fieldPort)).build();
-
-
-            // Set Action outport ,sigType and sigID
-            List<OFAction> actionList = new ArrayList<>();
-            OFAction actionOutPort =
-                    factory().actions().output(OFPort.of(outport),
-                                                  0xffff);
-
-            OFActionCircuit actionCircuit = factory()
-                    .actions()
-                    .circuit(ofOxmOchSigidBasic);
-            actionList.add(actionCircuit);
-            actionList.add(actionOutPort);
-
-            OFInstruction instructionAction =
-                    factory().instructions().buildApplyActions()
-                                .setActions(actionList)
-                                .build();
-            List<OFInstruction> instructions =
-                    Collections.singletonList(instructionAction);
-
-            OFMessage opticalFlowEntry =
-                    factory().buildFlowAdd()
-                                .setMatch(matchPort)
-                                .setPriority(100)
-                                .setInstructions(instructions)
-                                .setXid(getNextTransactionId())
-                                .build();
-            log.debug("Adding optical flow in sw {}", getStringId());
-            List<OFMessage> msglist = new ArrayList<>(1);
-            msglist.add(opticalFlowEntry);
-            write(msglist);
-            sendBarrier(true);
-        } else if (getId() == 0x0000ffffffffff03L) {
-            final int inport = 31;
-            final int outport = 30;
-            //Circuit signal id
-            CircuitSignalID sigID = getSignalID(lambda);
-
-            OFOxmOchSigid fieldSigIDMatch = factory().oxms().ochSigid(sigID);
-            OFOxmOchSigtype fieldSigType = factory()
-                    .oxms()
-                    .ochSigtype(SIGNAL_TYPE);
-
-            OFOxmOchSigidBasic ofOxmOchSigidBasic =
-                    factory().oxms().ochSigidBasic(sigID);
-
-            //Match Port,SigType,SigID
-            OFOxmInPort fieldPort = factory()
-                    .oxms()
-                    .inPort(OFPort.of(inport));
-            OFMatchV3 matchPort = factory()
-                    .buildMatchV3()
-                    .setOxmList(OFOxmList.of(fieldPort,
-                                             fieldSigIDMatch,
-                                             fieldSigType
-                    ))
-                    .build();
-
-            // Set Action outport ,SigType, sigID
-            List<OFAction> actionList = new ArrayList<>();
-            OFAction actionOutPort =
-                    factory().actions().output(OFPort.of(outport),
-                                                  0xffff);
-            OFActionCircuit actionCircuit = factory()
-                    .actions()
-                    .circuit(ofOxmOchSigidBasic);
-
-            actionList.add(actionCircuit);
-            actionList.add(actionOutPort);
-
-            OFInstruction instructionAction =
-                    factory().instructions().buildApplyActions()
-                                .setActions(actionList)
-                                .build();
-            List<OFInstruction> instructions =
-                    Collections.singletonList(instructionAction);
-
-            OFMessage opticalFlowEntry =
-                    factory().buildFlowAdd()
-                                .setMatch(matchPort)
-                                .setPriority(100)
-                                .setInstructions(instructions)
-                                .setXid(getNextTransactionId())
-                                .build();
-            log.debug("Adding optical flow in sw {}", getStringId());
-            List<OFMessage> msglist = new ArrayList<>(1);
-            msglist.add(opticalFlowEntry);
-            write(msglist);
-            sendBarrier(true);
-
-        } else if (getId() == 0x0000ffffffffff01L) {
-            final int inport = 20;
-            final int outport = 10;
-            //Circuit signal id
-            CircuitSignalID sigID = getSignalID(lambda);
-
-            OFOxmOchSigid fieldSigIDMatch = factory().oxms().ochSigid(sigID);
-            OFOxmOchSigtype fieldSigType = factory()
-                    .oxms()
-                    .ochSigtype(SIGNAL_TYPE);
-
-
-            //Match Port, sig type and sig id
-            OFOxmInPort fieldPort = factory()
-                    .oxms()
-                    .inPort(OFPort.of(inport));
-            OFMatchV3 matchPort =
-                    factory().buildMatchV3()
-                                .setOxmList(OFOxmList.of(fieldPort,
-                                                         fieldSigIDMatch,
-                                                         fieldSigType
-                                ))
-                                .build();
-
-            // Set Action outport
-            List<OFAction> actionList = new ArrayList<>();
-            OFAction actionOutPort =
-                    factory().actions().output(OFPort.of(outport),
-                                                  0xffff);
-
-            actionList.add(actionOutPort);
-
-            OFInstruction instructionAction =
-                    factory().instructions().buildApplyActions()
-                                .setActions(actionList)
-                                .build();
-            List<OFInstruction> instructions =
-                    Collections.singletonList(instructionAction);
-
-            OFMessage opticalFlowEntry =
-                    factory().buildFlowAdd()
-                                .setMatch(matchPort)
-                                .setPriority(100)
-                                .setInstructions(instructions)
-                                .setXid(getNextTransactionId())
-                                .build();
-            log.debug("Adding optical flow in sw {}", getStringId());
-            List<OFMessage> msglist = new ArrayList<>(1);
-            msglist.add(opticalFlowEntry);
-            write(msglist);
-            sendBarrier(true);
-        }
-
-    }
-
-
-    // Todo remove - for testing purpose only
-    private static CircuitSignalID getSignalID(short lambda) {
-        byte myGrid = 1;
-        byte myCs = 2;
-        short myCn = lambda;
-        short mySw = 1;
-
-        CircuitSignalID signalID = new CircuitSignalID(myGrid,
-                                                       myCs,
-                                                       myCn,
-                                                       mySw);
-        return signalID;
-    }
-
     private void sendBarrier(boolean finalBarrier) throws IOException {
         int xid = getNextTransactionId();
         if (finalBarrier) {
diff --git a/web/gui/src/main/webapp/img/device.png b/web/gui/src/main/webapp/img/device.png
new file mode 100644
index 0000000..d608153
--- /dev/null
+++ b/web/gui/src/main/webapp/img/device.png
Binary files differ
diff --git a/web/gui/src/main/webapp/img/host.png b/web/gui/src/main/webapp/img/host.png
new file mode 100644
index 0000000..cacde17
--- /dev/null
+++ b/web/gui/src/main/webapp/img/host.png
Binary files differ
diff --git a/web/gui/src/main/webapp/img/onos-logo.png b/web/gui/src/main/webapp/img/onos-logo.png
new file mode 100644
index 0000000..afd87e1
--- /dev/null
+++ b/web/gui/src/main/webapp/img/onos-logo.png
Binary files differ
diff --git a/web/gui/src/main/webapp/img/opt.png b/web/gui/src/main/webapp/img/opt.png
new file mode 100644
index 0000000..2f2c88e
--- /dev/null
+++ b/web/gui/src/main/webapp/img/opt.png
Binary files differ
diff --git a/web/gui/src/main/webapp/img/pkt.png b/web/gui/src/main/webapp/img/pkt.png
new file mode 100644
index 0000000..1b1d5a3
--- /dev/null
+++ b/web/gui/src/main/webapp/img/pkt.png
Binary files differ
diff --git a/web/gui/src/main/webapp/index.html b/web/gui/src/main/webapp/index.html
index ebf25c5..19c9204 100644
--- a/web/gui/src/main/webapp/index.html
+++ b/web/gui/src/main/webapp/index.html
@@ -15,19 +15,18 @@
     <link rel="stylesheet" href="onos.css">
 
     <script src="geometry.js"></script>
-    <script src="onosui.js"></script>
+    <script src="onos.js"></script>
 
 </head>
 <body>
     <div id="frame">
         <div id="mast">
-            <span class="title">
-                ONOS Web UI
-            </span>
+            <img id="logo" src="img/onos-logo.png" width="60" height="38">
+            <span class="title">Open Network Operating System</span>
             <span class="right">
-                <span class="radio">[one]</span>
-                <span class="radio">[two]</span>
-                <span class="radio">[three]</span>
+                <span class="radio">[All Layers]</span>
+                <span class="radio">[Packet Only]</span>
+                <span class="radio">[Optical Only]</span>
             </span>
         </div>
         <div id="view"></div>
diff --git a/web/gui/src/main/webapp/network.js b/web/gui/src/main/webapp/network.js
index ef190e7..c5145ad 100644
--- a/web/gui/src/main/webapp/network.js
+++ b/web/gui/src/main/webapp/network.js
@@ -11,18 +11,17 @@
 
     var config = {
             options: {
-                layering: false,
+                layering: true,
                 collisionPrevention: true
             },
             jsonUrl: 'network.json',
             iconUrl: {
-                logo: 'img/onos-logo.tiff',
                 device: 'img/device.png',
                 host: 'img/host.png',
                 pkt: 'img/pkt.png',
                 opt: 'img/opt.png'
             },
-            mastHeight: 32,
+            mastHeight: 36,
             force: {
                 note: 'node.class or link.class is used to differentiate',
                 linkDistance: {
@@ -47,7 +46,7 @@
                 }
             },
             labels: {
-                imgPad: 22,
+                imgPad: 16,
                 padLR: 8,
                 padTB: 6,
                 marginLR: 3,
@@ -57,7 +56,7 @@
                 w: 32,
                 h: 32,
                 xoff: -12,
-                yoff: -10
+                yoff: -8
             },
             constraints: {
                 ypos: {
@@ -376,6 +375,7 @@
                 rect = node.select('rect'),
                 icon = iconUrl(d),
                 text = node.append('text')
+                    // TODO: add label cycle behavior
                     .text(d.id)
                     .attr('dy', '1.1em');
 
diff --git a/web/gui/src/main/webapp/onos.css b/web/gui/src/main/webapp/onos.css
index b2df75c..7f387eb 100644
--- a/web/gui/src/main/webapp/onos.css
+++ b/web/gui/src/main/webapp/onos.css
@@ -13,13 +13,15 @@
  */
 
 span.title {
-    color: darkblue;
-    font-size: 16pt;
+    color: #37b;
+    font-size: 14pt;
     font-style: italic;
+    vertical-align: 10px;
 }
 
 span.radio {
     color: darkslateblue;
+    font-size: 10pt;
 }
 
 span.right {
@@ -127,8 +129,8 @@
 }
 
 #mast {
-    height: 32px;
-    padding: 6px;
+    height: 36px;
+    padding: 4px;
     background-color: #ccc;
     vertical-align: baseline;
 }
diff --git a/web/gui/src/main/webapp/onosui.js b/web/gui/src/main/webapp/onos.js
similarity index 100%
rename from web/gui/src/main/webapp/onosui.js
rename to web/gui/src/main/webapp/onos.js