src/main/java/net/floodlightcontroller/myrouting/MyRouting.java
// Install routing rules on switches.
Install routing rules on switches.
Install routing rules on switches .
private void installRoute(List<NodePortTuple> path, OFMatch match) {
		OFMatch m = new OFMatch();
		m.setDataLayerType(Ethernet.TYPE_IPv4).setNetworkSource(match.getNetworkSource())
				.setNetworkDestination(match.getNetworkDestination());
		for (int i = 0; i <= path.size() - 1; i += 2) {
			short inport = path.get(i).getPortId();
			m.setInputPort(inport);
			List<OFAction> actions = new ArrayList<OFAction>();
			OFActionOutput outport = new OFActionOutput(path.get(i + 1).getPortId());
			actions.add(outport);
			OFFlowMod mod = (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
			mod.setCommand(OFFlowMod.OFPFC_ADD).setIdleTimeout((short) 0).setHardTimeout((short) 0).setMatch(m)
					.setPriority((short) 105).setActions(actions)
					.setLength((short) (OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH));
			flowPusher.addFlow("routeFlow" + uniqueFlow, mod, HexString.toHexString(path.get(i).getNodeId()));
			uniqueFlow++;
		}
	}
private void installRoute ( List < NodePortTuple > path , OFMatch match ) { OFMatch m = new OFMatch ( ) ; m . setDataLayerType ( Ethernet . TYPE_IPv4 ) . setNetworkSource ( match . getNetworkSource ( ) ) . setNetworkDestination ( match . getNetworkDestination ( ) ) ; for ( int i = 0 ; i <= path . size ( ) - 1 ; i += 2 ) { short inport = path . get ( i ) . getPortId ( ) ; m . setInputPort ( inport ) ; List < OFAction > actions = new ArrayList < OFAction > ( ) ; OFActionOutput outport = new OFActionOutput ( path . get ( i + 1 ) . getPortId ( ) ) ; actions . add ( outport ) ; OFFlowMod mod = ( OFFlowMod ) floodlightProvider . getOFMessageFactory ( ) . getMessage ( OFType . FLOW_MOD ) ; mod . setCommand ( OFFlowMod . OFPFC_ADD ) . setIdleTimeout ( ( short ) 0 ) . setHardTimeout ( ( short ) 0 ) . setMatch ( m ) . setPriority ( ( short ) 105 ) . setActions ( actions ) . setLength ( ( short ) ( OFFlowMod . MINIMUM_LENGTH + OFActionOutput . MINIMUM_LENGTH ) ) ; flowPusher . addFlow ( "routeFlow" + uniqueFlow , mod , HexString . toHexString ( path . get ( i ) . getNodeId ( ) ) ) ; uniqueFlow ++ ; } }
Install routing rules on switches.
Install routing rules on switches .