import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
PacketProcessingService, //
OpendaylightGroupStatisticsService, //
OpendaylightMeterStatisticsService, //
+ OpendaylightFlowStatisticsService, //
Identifiable<InstanceIdentifier<Node>> {
CompositeObjectRegistration<ModelDrivenSwitch> register(ProviderContext ctx);
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
addMessageTranslator(MultipartReplyMessage.class,OF13,new MultiPartReplyPortToNodeConnectorUpdatedTranslator());
addMessageTranslator(MultipartReplyMessage.class,OF13, new MultiPartMessageDescToNodeUpdatedTranslator());
addMessageTranslator(ExperimenterMessage.class, OF10, new ExperimenterTranslator());
+ addMessageTranslator(MultipartReplyMessage.class,OF10, new MultipartReplyTranslator());
addMessageTranslator(MultipartReplyMessage.class,OF13, new MultipartReplyTranslator());
addMessageTranslator(MultipartReplyMessage.class,OF13,new MultipartReplyTableFeaturesToTableUpdatedTranslator());
addMessagePopListener(SwitchFlowRemoved.class, notificationPopListener);
addMessagePopListener(TableUpdated.class, notificationPopListener);
+ //Notification registration for flow statistics
+ addMessagePopListener(FlowsStatisticsUpdate.class, notificationPopListener);
+ addMessagePopListener(AggregateFlowStatisticsUpdate.class, notificationPopListener);
//Notification registrations for group-statistics
addMessagePopListener(GroupStatisticsUpdated.class, notificationPopListener);
addMessagePopListener(GroupFeaturesUpdated.class, notificationPopListener);
import org.opendaylight.openflowplugin.openflow.md.ModelDrivenSwitch;
import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
private RoutedRpcRegistration<SalMeterService> meterRegistration;
private RoutedRpcRegistration<PacketProcessingService> packetRegistration;
+
+ private RoutedRpcRegistration<OpendaylightFlowStatisticsService> flowStatisticsRegistration;
private RoutedRpcRegistration<OpendaylightGroupStatisticsService> groupStatisticsRegistration;
packetRegistration = ctx.addRoutedRpcImplementation(PacketProcessingService.class, this);
packetRegistration.registerPath(NodeContext.class, getIdentifier());
builder.add(packetRegistration);
-
+
+ flowStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowStatisticsService.class, this);
+ flowStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
+ builder.add(flowStatisticsRegistration);
+
groupStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightGroupStatisticsService.class, this);
groupStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
builder.add(groupStatisticsRegistration);
import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MatchConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.OpenflowEnumConstant;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.session.IMessageDispatchService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllNodeConnectorStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllNodeConnectorStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowTableStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowTableStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Group;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Meter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures;
+//import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features.TableFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.GetPortOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
}
- @Override
- public Future<RpcResult<GetPortOutput>> getPort() {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public Future<RpcResult<GetPortOutput>> getPort() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
- @Override
- public Future<RpcResult<UpdatePortOutput>> updatePort(UpdatePortInput input) {
- PortModInput ofPortModInput = null ;
- RpcResult<UpdatePortOutput> rpcResultFromOFLib = null ;
+ @Override
+ public Future<RpcResult<UpdatePortOutput>> updatePort(UpdatePortInput input) {
+ PortModInput ofPortModInput = null ;
+ RpcResult<UpdatePortOutput> rpcResultFromOFLib = null ;
- // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
+ // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
// the request can be routed through any connection to the switch
SwitchConnectionDistinguisher cookie = null ;
- // NSF sends a list of port and the ModelDrivenSwitch will
+ // NSF sends a list of port and the ModelDrivenSwitch will
// send one port at a time towards the switch ( mutiple RPCs calls)
- List<Port> inputPorts = input.getUpdatedPort().getPort().getPort() ;
+ List<Port> inputPorts = input.getUpdatedPort().getPort().getPort() ;
- // Get the Xid. The same Xid has to be sent in all the RPCs
- Long Xid = sessionContext.getNextXid();
+ // Get the Xid. The same Xid has to be sent in all the RPCs
+ Long Xid = sessionContext.getNextXid();
- for( Port inputPort : inputPorts) {
+ for( Port inputPort : inputPorts) {
- // Convert the UpdateGroupInput to GroupModInput
- ofPortModInput = PortConvertor.toPortModInput(inputPort, version) ;
+ // Convert the UpdateGroupInput to GroupModInput
+ ofPortModInput = PortConvertor.toPortModInput(inputPort, version) ;
- // Insert the Xid ( transaction Id) before calling the RPC on the OFLibrary
-
- PortModInputBuilder mdInput = new PortModInputBuilder();
- mdInput.setXid(Xid);
- mdInput.setVersion(ofPortModInput.getVersion()) ;
- mdInput.setPortNo(ofPortModInput.getPortNo()) ;
- mdInput.setMaskV10(ofPortModInput.getMaskV10()) ;
- mdInput.setMask(ofPortModInput.getMask()) ;
- mdInput.setHwAddress(ofPortModInput.getHwAddress());
- mdInput.setConfigV10(ofPortModInput.getConfigV10()) ;
- mdInput.setConfig(ofPortModInput.getConfig()) ;
- mdInput.setAdvertiseV10(ofPortModInput.getAdvertiseV10()) ;
- mdInput.setAdvertise(ofPortModInput.getAdvertise()) ;
-
- LOG.debug("Calling the PortMod RPC method on MessageDispatchService");
- Future<RpcResult<UpdatePortOutput>> resultFromOFLib = messageService.portMod(ofPortModInput, cookie) ;
-
- try {
- rpcResultFromOFLib = resultFromOFLib.get();
- } catch( Exception ex ) {
- LOG.error( " Error while getting result for updatePort RPC" + ex.getMessage());
- }
+ // Insert the Xid ( transaction Id) before calling the RPC on the OFLibrary
- // The Future response value for all the RPCs except the last one is ignored
-
- }
-
- //Extract the Xid only from the Future for the last RPC and
- // send it back to the NSF
- UpdatePortOutput updatePortOutputOFLib = rpcResultFromOFLib.getResult() ;
-
- UpdatePortOutputBuilder updatePortOutput = new UpdatePortOutputBuilder() ;
- updatePortOutput.setTransactionId(updatePortOutputOFLib.getTransactionId()) ;
- UpdatePortOutput result = updatePortOutput.build();
-
- Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
- RpcResult<UpdatePortOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
-
- LOG.debug("Returning the Update Group RPC result to MD-SAL");
- return Futures.immediateFuture(rpcResult);
-
+ PortModInputBuilder mdInput = new PortModInputBuilder();
+ mdInput.setXid(Xid);
+ mdInput.setVersion(ofPortModInput.getVersion()) ;
+ mdInput.setPortNo(ofPortModInput.getPortNo()) ;
+ mdInput.setMaskV10(ofPortModInput.getMaskV10()) ;
+ mdInput.setMask(ofPortModInput.getMask()) ;
+ mdInput.setHwAddress(ofPortModInput.getHwAddress());
+ mdInput.setConfigV10(ofPortModInput.getConfigV10()) ;
+ mdInput.setConfig(ofPortModInput.getConfig()) ;
+ mdInput.setAdvertiseV10(ofPortModInput.getAdvertiseV10()) ;
+ mdInput.setAdvertise(ofPortModInput.getAdvertise()) ;
+
+ LOG.debug("Calling the PortMod RPC method on MessageDispatchService");
+ Future<RpcResult<UpdatePortOutput>> resultFromOFLib = messageService.portMod(ofPortModInput, cookie) ;
+
+ try {
+ rpcResultFromOFLib = resultFromOFLib.get();
+ } catch( Exception ex ) {
+ LOG.error( " Error while getting result for updatePort RPC" + ex.getMessage());
+ }
+
+ // The Future response value for all the RPCs except the last one is ignored
+
}
- @Override
- public Future<RpcResult<UpdateTableOutput>> updateTable(
+ //Extract the Xid only from the Future for the last RPC and
+ // send it back to the NSF
+ UpdatePortOutput updatePortOutputOFLib = rpcResultFromOFLib.getResult() ;
+
+ UpdatePortOutputBuilder updatePortOutput = new UpdatePortOutputBuilder() ;
+ updatePortOutput.setTransactionId(updatePortOutputOFLib.getTransactionId()) ;
+ UpdatePortOutput result = updatePortOutput.build();
+
+ Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
+ RpcResult<UpdatePortOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
+
+ LOG.debug("Returning the Update Group RPC result to MD-SAL");
+ return Futures.immediateFuture(rpcResult);
+
+ }
+
+ @Override
+ public Future<RpcResult<UpdateTableOutput>> updateTable(
UpdateTableInput input) {
- // Get the Xid. The same Xid has to be sent in all the Multipart requests
+ // Get the Xid. The same Xid has to be sent in all the Multipart requests
Long xid = this.getSessionContext().getNextXid();
LOG.debug("Prepare the Multipart Table Mod requests for Transaction Id {} ",xid);
MultipartRequestTableFeaturesCaseBuilder caseRequest = new MultipartRequestTableFeaturesCaseBuilder();
MultipartRequestTableFeaturesBuilder tableFeaturesRequest = new MultipartRequestTableFeaturesBuilder();
- // Slice the multipart request based on the configuration parameter, which is the no. of TableFeatureList element
+ // Slice the multipart request based on the configuration parameter, which is the no. of TableFeatureList element
// to be put in one multipart message. Default is 5
// This parameter must be set based on switch's Buffer capacity
index += noOfEntriesInMPR ;
tmpOfTableFeatureList = null ; // To avoid any corrupt data
}
- //Extract the Xid only from the Future for the last RPC and
- // send it back to the NSF
+
+ //Extract the Xid only from the Future for the last RPC and
+ // send it back to the NSF
LOG.debug("Returning the result and transaction id to NSF");
LOG.debug("Return results and transaction id back to caller");
UpdateTableOutputBuilder output = new UpdateTableOutputBuilder();
RpcResult<UpdateTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
return Futures.immediateFuture(rpcResult);
- }
+ }
+
+ @Override
+ public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
+ GetAllFlowStatisticsFromFlowTableInput arg0) {
+
+ //Generate xid to associate it with the request
+ Long xid = this.getSessionContext().getNextXid();
+
+ LOG.debug("Prepare statistics request to get flow stats for switch tables {} - Transaction id - {}"
+ ,arg0.getTableId().getValue(),xid);
+
+ // Create multipart request header
+ MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
+ mprInput.setType(MultipartType.OFPMPFLOW);
+ mprInput.setVersion(version);
+ mprInput.setXid(xid);
+ mprInput.setFlags(new MultipartRequestFlags(false));
+
+ // Create multipart request body for fetch all the group stats
+ MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder ();
+ MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+ mprFlowRequestBuilder.setTableId(arg0.getTableId().getValue());
+ mprFlowRequestBuilder.setOutPort(OpenflowEnumConstant.OFPP_ANY);
+ mprFlowRequestBuilder.setOutGroup(OpenflowEnumConstant.OFPG_ANY);
+ mprFlowRequestBuilder.setCookie(OpenflowEnumConstant.DEFAULT_COOKIE);
+ mprFlowRequestBuilder.setCookieMask(OpenflowEnumConstant.DEFAULT_COOKIE_MASK);
+ if(version == OpenflowEnumConstant.OPENFLOW_V10){
+ LOG.info("Target node is running openflow version 1.0");
+ FlowWildcardsV10 wildCard = new FlowWildcardsV10(true,false,false,false,false,false,false,false,false,false,false);
+ mprFlowRequestBuilder.setMatchV10(new MatchV10Builder().setWildcards(wildCard).build());
+ }
+ if(version == OpenflowEnumConstant.OPENFLOW_V13){
+ LOG.info("Target node is running openflow version 1.3+");
+ mprFlowRequestBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
+ }
+
+
+ //Set request body to main multipart request
+ multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+ mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
+
+ //Send the request, no cookies associated, use any connection
+ LOG.debug("Send flow statistics request to the switch :{}",mprFlowRequestBuilder);
+ this.messageService.multipartRequest(mprInput.build(), null);
+
+ // Prepare rpc return output. Set xid and send it back.
+ LOG.debug("Return results and transaction id back to caller");
+ GetAllFlowStatisticsFromFlowTableOutputBuilder output =
+ new GetAllFlowStatisticsFromFlowTableOutputBuilder();
+ output.setTransactionId(generateTransactionId(xid));
+ output.setFlowAndStatisticsMapList(null);
+
+ Collection<RpcError> errors = Collections.emptyList();
+ RpcResult<GetAllFlowStatisticsFromFlowTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ @Override
+ public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
+ GetAllFlowsStatisticsFromAllFlowTablesInput arg0) {
+
+ //Generate xid to associate it with the request
+ Long xid = this.getSessionContext().getNextXid();
+
+ LOG.info("Prepare statistics request to get flow stats of all switch tables - Transaction id - {}",xid);
+
+ // Create multipart request header
+ MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
+ mprInput.setType(MultipartType.OFPMPFLOW);
+ mprInput.setVersion(version);
+ mprInput.setXid(xid);
+ mprInput.setFlags(new MultipartRequestFlags(false));
+
+ // Create multipart request body for fetch all the group stats
+ MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
+ MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+ mprFlowRequestBuilder.setTableId(OpenflowEnumConstant.OFPTT_ALL);
+ mprFlowRequestBuilder.setOutPort(OpenflowEnumConstant.OFPP_ANY);
+ mprFlowRequestBuilder.setOutGroup(OpenflowEnumConstant.OFPG_ANY);
+ mprFlowRequestBuilder.setCookie(OpenflowEnumConstant.DEFAULT_COOKIE);
+ mprFlowRequestBuilder.setCookieMask(OpenflowEnumConstant.DEFAULT_COOKIE_MASK);
+ mprFlowRequestBuilder.setCookieMask(OpenflowEnumConstant.DEFAULT_COOKIE_MASK);
+
+ if(version == OpenflowEnumConstant.OPENFLOW_V10){
+ FlowWildcardsV10 wildCard = new FlowWildcardsV10(true,false,false,false,false,false,false,false,false,false,false);
+ mprFlowRequestBuilder.setMatchV10(new MatchV10Builder().setWildcards(wildCard).build());
+ }
+ if(version == OpenflowEnumConstant.OPENFLOW_V13){
+ mprFlowRequestBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
+ }
+ //Set request body to main multipart request
+ multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+ mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
+
+ //Send the request, no cookies associated, use any connection
+ LOG.debug("Send flow statistics request to the switch :{}",mprFlowRequestBuilder);
+ this.messageService.multipartRequest(mprInput.build(), null);
+
+ // Prepare rpc return output. Set xid and send it back.
+ GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder output =
+ new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder();
+ output.setTransactionId(generateTransactionId(xid));
+ output.setFlowAndStatisticsMapList(null);
+
+ Collection<RpcError> errors = Collections.emptyList();
+ RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
+ return Futures.immediateFuture(rpcResult);
+
+ }
+
+ @Override
+ public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
+ GetFlowStatisticsFromFlowTableInput arg0) {
+ //Generate xid to associate it with the request
+ Long xid = this.getSessionContext().getNextXid();
+
+ LOG.debug("Prepare statistics request to get stats for flow {} for switch tables {} - Transaction id - {}"
+ ,arg0.getMatch().toString(),arg0.getTableId(),xid);
+
+ // Create multipart request header
+ MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
+ mprInput.setType(MultipartType.OFPMPFLOW);
+ mprInput.setVersion(version);
+ mprInput.setXid(xid);
+ mprInput.setFlags(new MultipartRequestFlags(false));
+
+ // Create multipart request body for fetch all the group stats
+ MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
+ MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+ mprFlowRequestBuilder.setTableId(arg0.getTableId());
+ mprFlowRequestBuilder.setOutPort(arg0.getOutPort().longValue());
+ mprFlowRequestBuilder.setOutGroup(OpenflowEnumConstant.OFPG_ANY);
+ mprFlowRequestBuilder.setCookie(OpenflowEnumConstant.DEFAULT_COOKIE);
+ mprFlowRequestBuilder.setCookieMask(OpenflowEnumConstant.DEFAULT_COOKIE_MASK);
+
+
+ if(version == OpenflowEnumConstant.OPENFLOW_V10){
+ mprFlowRequestBuilder.setMatchV10(MatchConvertor.toMatchV10(arg0.getMatch()));
+ }
+ if(version == OpenflowEnumConstant.OPENFLOW_V13){
+ MatchBuilder matchBuilder = new MatchBuilder();
+ matchBuilder.setMatchEntries(MatchConvertor.toMatch(arg0.getMatch()));
+ matchBuilder.setType(OxmMatchType.class);
+ mprFlowRequestBuilder.setMatch(matchBuilder.build());
+
+ mprFlowRequestBuilder.setCookie(arg0.getCookie());
+ mprFlowRequestBuilder.setCookieMask(arg0.getCookieMask());
+ mprFlowRequestBuilder.setOutGroup(arg0.getOutGroup());
+ }
+
+ //Set request body to main multipart request
+ multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+ mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
+
+ //Send the request, no cookies associated, use any connection
+ LOG.debug("Send flow statistics request to the switch :{}",mprFlowRequestBuilder);
+ this.messageService.multipartRequest(mprInput.build(), null);
+
+ // Prepare rpc return output. Set xid and send it back.
+ GetFlowStatisticsFromFlowTableOutputBuilder output =
+ new GetFlowStatisticsFromFlowTableOutputBuilder();
+ output.setTransactionId(generateTransactionId(xid));
+ output.setFlowAndStatisticsMapList(null);
+
+ Collection<RpcError> errors = Collections.emptyList();
+ RpcResult<GetFlowStatisticsFromFlowTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ @Override
+ public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
+ GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput arg0) {
+ //Generate xid to associate it with the request
+ Long xid = this.getSessionContext().getNextXid();
+
+ LOG.debug("Prepare aggregate flow statistics request to get aggregate flow stats for all the flow installed on switch table {} - Transaction id - {}"
+ ,arg0.getTableId().getValue(),xid);
+
+ // Create multipart request header
+ MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
+ mprInput.setType(MultipartType.OFPMPAGGREGATE);
+ mprInput.setVersion(version);
+ mprInput.setXid(xid);
+ mprInput.setFlags(new MultipartRequestFlags(false));
+
+ // Create multipart request body for fetch all the group stats
+ MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder ();
+ MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
+ mprAggregateRequestBuilder.setTableId(arg0.getTableId().getValue());
+ mprAggregateRequestBuilder.setOutPort(OpenflowEnumConstant.OFPP_ANY);
+ mprAggregateRequestBuilder.setOutGroup(OpenflowEnumConstant.OFPG_ANY);
+ mprAggregateRequestBuilder.setCookie(OpenflowEnumConstant.DEFAULT_COOKIE);
+ mprAggregateRequestBuilder.setCookieMask(OpenflowEnumConstant.DEFAULT_COOKIE_MASK);
+ if(version == OpenflowEnumConstant.OPENFLOW_V10){
+ FlowWildcardsV10 wildCard = new FlowWildcardsV10(true,false,false,false,false,false,false,false,false,false,false);
+ mprAggregateRequestBuilder.setMatchV10(new MatchV10Builder().setWildcards(wildCard).build());
+ }
+ if(version == OpenflowEnumConstant.OPENFLOW_V13){
+ mprAggregateRequestBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
+ }
+
+
+ //Set request body to main multipart request
+ multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
+ mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
+
+ //Send the request, no cookies associated, use any connection
+ LOG.debug("Send request to the switch :{}",multipartRequestAggregateCaseBuilder.build().toString());
+ this.messageService.multipartRequest(mprInput.build(), null);
+
+ // Prepare rpc return output. Set xid and send it back.
+ GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder output =
+ new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder();
+ output.setTransactionId(generateTransactionId(xid));
+
+ Collection<RpcError> errors = Collections.emptyList();
+ RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ @Override
+ public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
+ GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput arg0) {
+
+ //Generate xid to associate it with the request
+ Long xid = this.getSessionContext().getNextXid();
+
+ LOG.debug("Prepare agregate statistics request to get aggregate stats for flows matching {} and installed in flow tables {} - Transaction id - {}"
+ ,arg0.getMatch().toString(),arg0.getTableId(),xid);
+
+ // Create multipart request header
+ MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
+ mprInput.setType(MultipartType.OFPMPAGGREGATE);
+ mprInput.setVersion(version);
+ mprInput.setXid(xid);
+ mprInput.setFlags(new MultipartRequestFlags(false));
+
+ // Create multipart request body for fetch all the group stats
+ MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder ();
+ MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
+ mprAggregateRequestBuilder.setTableId(arg0.getTableId());
+ mprAggregateRequestBuilder.setOutPort(arg0.getOutPort().longValue());
+ mprAggregateRequestBuilder.setOutGroup(OpenflowEnumConstant.OFPG_ANY);
+ mprAggregateRequestBuilder.setCookie(OpenflowEnumConstant.DEFAULT_COOKIE);
+ mprAggregateRequestBuilder.setCookieMask(OpenflowEnumConstant.DEFAULT_COOKIE_MASK);
+
+
+ if(version == OpenflowEnumConstant.OPENFLOW_V10){
+ mprAggregateRequestBuilder.setMatchV10(MatchConvertor.toMatchV10(arg0.getMatch()));
+ }
+ if(version == OpenflowEnumConstant.OPENFLOW_V13){
+ MatchBuilder matchBuilder = new MatchBuilder();
+ matchBuilder.setMatchEntries(MatchConvertor.toMatch(arg0.getMatch()));
+ matchBuilder.setType(OxmMatchType.class);
+ mprAggregateRequestBuilder.setMatch(matchBuilder.build());
+
+ mprAggregateRequestBuilder.setCookie(arg0.getCookie());
+ mprAggregateRequestBuilder.setCookieMask(arg0.getCookieMask());
+ mprAggregateRequestBuilder.setOutGroup(arg0.getOutGroup());
+ }
+
+ //Set request body to main multipart request
+ multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
+ mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
+
+ //Send the request, no cookies associated, use any connection
+ LOG.debug("Send request for to the switch :{}",multipartRequestAggregateCaseBuilder.build().toString());
+ this.messageService.multipartRequest(mprInput.build(), null);
+
+ // Prepare rpc return output. Set xid and send it back.
+ GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder output =
+ new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
+ output.setTransactionId(generateTransactionId(xid));
+
+ Collection<RpcError> errors = Collections.emptyList();
+ RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ @Override
+ public Future<RpcResult<GetAllFlowStatisticsOutput>> getAllFlowStatistics(GetAllFlowStatisticsInput arg0) {
+ //TODO: Depricated, need to clean it up. Sal-Compatibility layes is dependent on it.
+ // Once sal-compatibility layer is fixed this rpc call can be removed from yang file
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<GetAllNodeConnectorStatisticsOutput>> getAllNodeConnectorStatistics(
+ GetAllNodeConnectorStatisticsInput arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<GetFlowStatisticsOutput>> getFlowStatistics(GetFlowStatisticsInput arg0) {
+ //TODO: Depricated, need to clean it up. Sal-Compatibility layes is dependent on it.
+ // Once sal-compatibility layer is fixed this rpc call can be removed from yang file
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<GetFlowTableStatisticsOutput>> getFlowTableStatistics(GetFlowTableStatisticsInput arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
+ GetNodeConnectorStatisticsInput arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
--- /dev/null
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.generic.statistics.DurationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
+
+/**
+ * Class is an utility class for converting flow related statistics messages coming from openflow
+ * switch to MD-SAL messages.
+ * @author avishnoi@in.ibm.com
+ *
+ */
+public class FlowStatsResponseConvertor {
+
+ /**
+ * Method returns the list of MD-SAL format flow statistics, converted flow Openflow
+ * specific flow statistics.
+ * @param allFlowStats
+ * @return
+ */
+ public List<FlowAndStatisticsMapList> toSALFlowStatsList(List<FlowStats> allFlowStats){
+
+ List<FlowAndStatisticsMapList> convertedSALFlowStats = new ArrayList<FlowAndStatisticsMapList>();
+
+ for(FlowStats flowStats : allFlowStats){
+ convertedSALFlowStats.add(toSALFlowStats(flowStats));
+ }
+
+ return convertedSALFlowStats;
+ }
+
+ /**
+ * Method convert Openflow switch specific flow statistics to the MD-SAL format
+ * flow statistics.
+ * @param flowStats
+ * @return
+ */
+ public FlowAndStatisticsMapList toSALFlowStats(FlowStats flowStats){
+ FlowAndStatisticsMapListBuilder salFlowStatsBuilder = new FlowAndStatisticsMapListBuilder();
+ salFlowStatsBuilder.setByteCount(new Counter64(flowStats.getByteCount()));
+ salFlowStatsBuilder.setCookie(flowStats.getCookie());
+
+ DurationBuilder time = new DurationBuilder();
+ time.setSecond(new Counter64(new BigInteger(flowStats.getDurationSec().toString())));
+ time.setNanosecond(new Counter64(new BigInteger(flowStats.getDurationNsec().toString())));
+ salFlowStatsBuilder.setDuration(time.build());
+
+ salFlowStatsBuilder.setFlags(
+ new FlowModFlags(flowStats.getFlags().isOFPFFCHECKOVERLAP(),
+ flowStats.getFlags().isOFPFFRESETCOUNTS(),
+ flowStats.getFlags().isOFPFFNOPKTCOUNTS(),
+ flowStats.getFlags().isOFPFFNOBYTCOUNTS(),
+ flowStats.getFlags().isOFPFFSENDFLOWREM()));
+
+ salFlowStatsBuilder.setHardTimeout(flowStats.getHardTimeout());
+ salFlowStatsBuilder.setIdleTimeout(flowStats.getIdleTimeout());
+ salFlowStatsBuilder.setPacketCount(new Counter64(flowStats.getPacketCount()));
+ salFlowStatsBuilder.setPriority(flowStats.getPriority());
+ salFlowStatsBuilder.setTableId(flowStats.getTableId());
+ if(flowStats.getMatchV10() != null){
+ salFlowStatsBuilder.setMatch(MatchConvertor.fromOFMatchV10ToSALMatch(flowStats.getMatchV10()));
+ }
+ if(flowStats.getMatch() != null){
+ salFlowStatsBuilder.setMatch(MatchConvertor.fromOFMatchToSALMatch(flowStats.getMatch()));
+ }
+ if(flowStats.getInstructions()!= null){
+ salFlowStatsBuilder.setInstructions(toSALInstruction(flowStats.getInstructions()));
+ }
+
+ return salFlowStatsBuilder.build();
+
+ }
+
+ /**
+ * Method convert Openflow 1.3+ specific instructions to MD-SAL format
+ * flow instruction
+ * Note: MD-SAL won't augment this data directly to the data store,
+ * so key setting is not required. If user wants to augment this data
+ * directly to the data store, key setting is required for each instructions.
+ * @param instructions
+ * @return
+ */
+ public Instructions toSALInstruction(
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions> instructions) {
+
+ InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
+
+ List<Instruction> salInstructionList = new ArrayList<Instruction>();
+
+ for(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions switchInst : instructions){
+ if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions){
+ InstructionBuilder instBuilder = new InstructionBuilder();
+ instBuilder.setInstruction(new ApplyActionsCaseBuilder().build());
+ salInstructionList.add(instBuilder.build());
+ }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions){
+ InstructionBuilder instBuilder = new InstructionBuilder();
+ instBuilder.setInstruction(new ClearActionsCaseBuilder().build());
+ salInstructionList.add(instBuilder.build());
+ }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable){
+ InstructionBuilder instBuilder = new InstructionBuilder();
+ instBuilder.setInstruction(new GoToTableCaseBuilder().build());
+ salInstructionList.add(instBuilder.build());
+ }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions){
+ InstructionBuilder instBuilder = new InstructionBuilder();
+ instBuilder.setInstruction(new WriteActionsCaseBuilder().build());
+ salInstructionList.add(instBuilder.build());
+ }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata){
+ InstructionBuilder instBuilder = new InstructionBuilder();
+ instBuilder.setInstruction(new WriteMetadataCaseBuilder().build());
+ salInstructionList.add(instBuilder.build());
+ }
+ }
+ instructionsBuilder.setInstruction(salInstructionList);
+ return instructionsBuilder.build();
+ }
+}
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
import java.math.BigInteger;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetField;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6Label;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.Pbb;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntriesBuilder;
import org.slf4j.Logger;
public class MatchConvertor {
private static final Logger logger = LoggerFactory.getLogger(MatchConvertor.class);
private static final String PREFIX_SEPARATOR = "/";
+
+ private static final short PROTO_TCP = 6;
+ private static final short PROTO_UDP = 17;
public static List<MatchEntries> toMatch(
org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match) {
return matchEntriesList;
}
+
+ /**
+ * Method builds openflow 1.0 specific match (MatchV10) from MD-SAL match.
+ * @param match MD-SAL match
+ * @return
+ * @author avishnoi@in.ibm.com
+ */
+ public static MatchV10 toMatchV10(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match) {
+
+ MatchV10Builder matchv10Builder = new MatchV10Builder();
+ if(match.getEthernetMatch()!= null){
+ matchv10Builder.setDlDst(match.getEthernetMatch().getEthernetDestination().getAddress());
+ matchv10Builder.setDlSrc(match.getEthernetMatch().getEthernetSource().getAddress());
+ matchv10Builder.setDlType(match.getEthernetMatch().getEthernetType().getType().getValue().intValue());
+ }
+ if(match.getVlanMatch()!= null){
+ matchv10Builder.setDlVlan(match.getVlanMatch().getVlanId().getVlanId().getValue());
+ matchv10Builder.setDlVlanPcp(match.getVlanMatch().getVlanPcp().getValue());
+ }
+ if(match.getInPort()!=null){
+ matchv10Builder.setInPort(match.getInPort().intValue());
+ }
+ Layer3Match l3Match = match.getLayer3Match();
+ if(l3Match != null){
+ if(l3Match instanceof Ipv4Match){
+ Ipv4Match ipv4 = (Ipv4Match)l3Match;
+ Ipv4Address ipv4Address = null;
+ String[] addressParts;
+ Integer prefix;
+ if(ipv4.getIpv4Source()!=null){
+ addressParts = ipv4.getIpv4Source().getValue().split(PREFIX_SEPARATOR);
+ prefix = null;
+ if (addressParts.length < 2) {
+ prefix = 0;
+ } else {
+ prefix = Integer.parseInt(addressParts[1]);
+ }
+
+ ipv4Address = new Ipv4Address(addressParts[0]);
+ matchv10Builder.setNwSrc(ipv4Address);
+ matchv10Builder.setNwSrcMask(prefix.shortValue());
+ }
+
+ if(ipv4.getIpv4Destination()!=null){
+ addressParts = ipv4.getIpv4Destination().getValue().split("/");
+ prefix = null;
+ if (addressParts.length < 2) {
+ prefix = 0;
+ } else {
+ prefix = Integer.parseInt(addressParts[1]);
+ }
+
+ ipv4Address = new Ipv4Address(addressParts[0]);
+ matchv10Builder.setNwDst(ipv4Address);
+ matchv10Builder.setNwDstMask(prefix.shortValue());
+ }
+ }
+ }
+ IpMatch ipMatch = match.getIpMatch();
+ if(ipMatch!=null){
+ matchv10Builder.setNwProto(ipMatch.getIpProtocol());
+ matchv10Builder.setNwTos(ipMatch.getIpDscp().getValue());
+ }
+
+ Layer4Match layer4Match = match.getLayer4Match();
+ if (layer4Match != null) {
+ if (layer4Match instanceof TcpMatch) {
+ TcpMatch tcpMatch = (TcpMatch) layer4Match;
+ if (tcpMatch.getTcpSourcePort() != null) {
+ matchv10Builder.setTpSrc(tcpMatch.getTcpSourcePort().getValue());
+ }
+
+ if (tcpMatch.getTcpDestinationPort() != null) {
+ matchv10Builder.setTpDst(tcpMatch.getTcpDestinationPort().getValue());
+ }
+ } else if (layer4Match instanceof UdpMatch) {
+ UdpMatch udpMatch = (UdpMatch) layer4Match;
+ if (udpMatch.getUdpSourcePort() != null) {
+ matchv10Builder.setTpSrc(udpMatch.getUdpSourcePort().getValue());
+ }
+
+ if (udpMatch.getUdpDestinationPort() != null) {
+ matchv10Builder.setTpDst(udpMatch.getUdpDestinationPort().getValue());
+ }
+ }
+ }
+ matchv10Builder.setWildcards(new FlowWildcardsV10(true,
+ matchv10Builder.getDlDst()!=null?true:false,
+ matchv10Builder.getDlSrc()!=null?true:false,
+ matchv10Builder.getDlType()!=null?true:false,
+ matchv10Builder.getDlVlan()!=null?true:false,
+ matchv10Builder.getDlVlanPcp()!=null?true:false,
+ matchv10Builder.getInPort()!=null?true:false,
+ matchv10Builder.getNwProto()!=null?true:false,
+ matchv10Builder.getNwTos()!=null?true:false,
+ matchv10Builder.getTpDst()!=null?true:false,
+ matchv10Builder.getTpSrc()!=null?true:false));
+
+ return matchv10Builder.build();
+ }
+
+ /**
+ * Method convert Openflow 1.0 specific flow match to MD-SAL format
+ * flow match
+ * @param match
+ * @return
+ * @author avishnoi@in.ibm.com
+ */
+ public static Match fromOFMatchV10ToSALMatch(MatchV10 swMatch){
+ MatchBuilder matchBuilder = new MatchBuilder();
+ EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
+ VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
+ Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
+ IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
+
+ if(swMatch.getInPort() != null){
+ matchBuilder.setInPort((long)swMatch.getInPort());
+ }
+
+ if(swMatch.getDlSrc()!= null){
+ EthernetSourceBuilder ethSrcBuilder = new EthernetSourceBuilder();
+ ethSrcBuilder.setAddress(swMatch.getDlSrc());
+ ethMatchBuilder.setEthernetSource(ethSrcBuilder.build());
+ matchBuilder.setEthernetMatch(ethMatchBuilder.build());
+ }
+ if(swMatch.getDlDst()!= null){
+ EthernetDestinationBuilder ethDstBuilder = new EthernetDestinationBuilder();
+ ethDstBuilder.setAddress(swMatch.getDlDst());
+ ethMatchBuilder.setEthernetDestination(ethDstBuilder.build());
+ matchBuilder.setEthernetMatch(ethMatchBuilder.build());
+ }
+ if(swMatch.getDlType()!= null){
+ EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ ethTypeBuilder.setType(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType((long)swMatch.getDlType()));
+ ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
+ matchBuilder.setEthernetMatch(ethMatchBuilder.build());
+ }
+ if(swMatch.getDlVlan()!=null){
+ VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
+ vlanIdBuilder.setVlanId(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId(swMatch.getDlVlan()));
+ vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
+ matchBuilder.setVlanMatch(vlanMatchBuilder.build());
+ }
+ if(swMatch.getDlVlanPcp()!= null){
+ vlanMatchBuilder.setVlanPcp(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp(swMatch.getDlVlanPcp()));
+ matchBuilder.setVlanMatch(vlanMatchBuilder.build());
+ }
+ if(swMatch.getNwSrc() !=null){
+ String ipv4PrefixStr = swMatch.getNwSrc().getValue();
+ if(swMatch.getNwSrcMask()!= null){
+ ipv4PrefixStr +=PREFIX_SEPARATOR+swMatch.getNwSrcMask();
+ }
+ ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix(ipv4PrefixStr));
+ matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
+ }
+ if(swMatch.getNwDst() !=null){
+ String ipv4PrefixStr = swMatch.getNwDst().getValue();
+ if(swMatch.getNwDstMask()!= null){
+ ipv4PrefixStr +=PREFIX_SEPARATOR+swMatch.getNwDstMask();
+ }
+ ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix(ipv4PrefixStr));
+ matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
+ }
+ if(swMatch.getNwProto()!= null ){
+ ipMatchBuilder.setIpProtocol(swMatch.getNwProto());
+ matchBuilder.setIpMatch(ipMatchBuilder.build());
+ }
+ if(swMatch.getNwProto() == PROTO_TCP){
+ TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
+ if(swMatch.getTpSrc()!= null)
+ tcpMatchBuilder.setTcpSourcePort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(swMatch.getTpSrc()));
+ if(swMatch.getTpDst()!= null)
+ tcpMatchBuilder.setTcpDestinationPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(swMatch.getTpDst()));
+ matchBuilder.setLayer4Match(tcpMatchBuilder.build());
+ }
+ if(swMatch.getNwProto() == PROTO_UDP){
+ UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
+ if(swMatch.getTpSrc()!= null)
+ udpMatchBuilder.setUdpSourcePort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(swMatch.getTpSrc()));
+ if(swMatch.getTpDst()!= null)
+ udpMatchBuilder.setUdpDestinationPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(swMatch.getTpDst()));
+ matchBuilder.setLayer4Match(udpMatchBuilder.build());
+ }
+ if(swMatch.getNwTos()!=null){
+ ipMatchBuilder.setIpDscp(new Dscp(swMatch.getNwTos()));
+ matchBuilder.setIpMatch(ipMatchBuilder.build());
+ }
+
+ return matchBuilder.build();
+ }
+
+ /**
+ * Method converts Openflow 1.3+ specific flow match to MD-SAL format
+ * flow match
+ * @param match
+ * @return
+ * @author avishnoi@in.ibm.com
+ */
+ public static Match fromOFMatchToSALMatch(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match swMatch) {
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
+ VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
+ IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
+ TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
+ UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
+ SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
+ Icmpv4MatchBuilder icmpv4MatchBuilder = new Icmpv4MatchBuilder();
+ Icmpv6MatchBuilder icmpv6MatchBuilder = new Icmpv6MatchBuilder();
+ Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
+ ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
+ Ipv6MatchBuilder ipv6MatchBuilder = new Ipv6MatchBuilder();
+ ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = new ProtocolMatchFieldsBuilder();
+
+ List<MatchEntries> swMatchList = swMatch.getMatchEntries();
+
+ for(MatchEntries ofMatch : swMatchList){
+
+ if(ofMatch.getOxmMatchField().equals(InPort.class)){
+ PortNumberMatchEntry portNumber = ofMatch.getAugmentation(PortNumberMatchEntry.class);
+ matchBuilder.setInPort(portNumber.getPortNumber().getValue());
+ }else if (ofMatch.getOxmMatchField().equals(InPhyPort.class)){
+ PortNumberMatchEntry portNumber = ofMatch.getAugmentation(PortNumberMatchEntry.class);
+ matchBuilder.setInPhyPort(portNumber.getPortNumber().getValue());
+ }else if(ofMatch.getOxmMatchField().equals(Metadata.class)){
+ MetadataBuilder metadataBuilder = new MetadataBuilder();
+ MetadataMatchEntry metadataMatchEntry = ofMatch.getAugmentation(MetadataMatchEntry.class);
+ if(metadataMatchEntry != null){
+ metadataBuilder.setMetadata(new BigInteger(metadataMatchEntry.getMetadata()));
+ MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
+ if(maskMatchEntry != null){
+ metadataBuilder.setMetadataMask(maskMatchEntry.getMask());
+ }
+ matchBuilder.setMetadata(metadataBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(EthSrc.class)){
+ MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
+ if(macAddressMatchEntry != null){
+ EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
+ ethSourceBuilder.setAddress(macAddressMatchEntry.getMacAddress());
+ ethMatchBuilder.setEthernetSource(ethSourceBuilder.build());
+ matchBuilder.setEthernetMatch(ethMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(EthDst.class)){
+ MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
+ if(macAddressMatchEntry != null){
+ EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder();
+ ethDestinationBuilder.setAddress(macAddressMatchEntry.getMacAddress());
+ ethMatchBuilder.setEthernetDestination(ethDestinationBuilder.build());
+ matchBuilder.setEthernetMatch(ethMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(EthType.class)){
+ EthTypeMatchEntry ethTypeMatchEntry = ofMatch.getAugmentation(EthTypeMatchEntry.class);
+ if(ethTypeMatchEntry != null){
+ EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ ethTypeBuilder.setType(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType((long)ethTypeMatchEntry.getEthType().getValue()));
+ ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
+ matchBuilder.setEthernetMatch(ethMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(VlanVid.class)){
+ VlanVidMatchEntry vlanVidMatchEntry = ofMatch.getAugmentation(VlanVidMatchEntry.class);
+ if(vlanVidMatchEntry != null){
+ VlanIdBuilder vlanBuilder = new VlanIdBuilder();
+ vlanBuilder.setVlanId(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId(vlanVidMatchEntry.getVlanVid()));
+ MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
+ if(maskMatchEntry != null){
+ vlanBuilder.setMask(maskMatchEntry.getMask());
+ }
+ vlanMatchBuilder.setVlanId(vlanBuilder.build());
+ matchBuilder.setVlanMatch(vlanMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(VlanPcp.class)){
+ VlanPcpMatchEntry vlanPcpMatchEntry = ofMatch.getAugmentation(VlanPcpMatchEntry.class);
+ if(vlanPcpMatchEntry != null){
+ vlanMatchBuilder.setVlanPcp(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp(vlanPcpMatchEntry.getVlanPcp()));
+ matchBuilder.setVlanMatch(vlanMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(IpDscp.class)){
+ DscpMatchEntry dscpMatchEntry = ofMatch.getAugmentation(DscpMatchEntry.class);
+ if(dscpMatchEntry != null){
+ ipMatchBuilder.setIpDscp(new Dscp(dscpMatchEntry.getDscp().getValue()));
+ matchBuilder.setIpMatch(ipMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(IpEcn.class)){
+ EcnMatchEntry ecnMatchEntry = ofMatch.getAugmentation(EcnMatchEntry.class);
+ if(ecnMatchEntry != null){
+ ipMatchBuilder.setIpEcn(ecnMatchEntry.getEcn());
+ matchBuilder.setIpMatch(ipMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(IpProto.class)){
+ ProtocolNumberMatchEntry protocolNumberMatchEntry = ofMatch.getAugmentation(ProtocolNumberMatchEntry.class);
+ if(protocolNumberMatchEntry != null){
+ ipMatchBuilder.setIpProtocol(protocolNumberMatchEntry.getProtocolNumber());
+ matchBuilder.setIpMatch(ipMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(TcpSrc.class)){
+ PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
+ if(portMatchEntry != null){
+ tcpMatchBuilder.setTcpSourcePort(portMatchEntry.getPort());
+ matchBuilder.setLayer4Match(tcpMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(TcpDst.class)){
+ PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
+ if(portMatchEntry != null){
+ tcpMatchBuilder.setTcpDestinationPort(portMatchEntry.getPort());
+ matchBuilder.setLayer4Match(tcpMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(UdpSrc.class)){
+ PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
+ if(portMatchEntry != null){
+ udpMatchBuilder.setUdpSourcePort(portMatchEntry.getPort());
+ matchBuilder.setLayer4Match(udpMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(UdpDst.class)){
+ PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
+ if(portMatchEntry != null){
+ udpMatchBuilder.setUdpDestinationPort(portMatchEntry.getPort());
+ matchBuilder.setLayer4Match(udpMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(SctpSrc.class)){
+ PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
+ if(portMatchEntry != null){
+ sctpMatchBuilder.setSctpSourcePort(portMatchEntry.getPort());
+ matchBuilder.setLayer4Match(sctpMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(SctpDst.class)){
+ PortMatchEntry portMatchEntry = ofMatch.getAugmentation(PortMatchEntry.class);
+ if(portMatchEntry != null){
+ sctpMatchBuilder.setSctpDestinationPort(portMatchEntry.getPort());
+ matchBuilder.setLayer4Match(sctpMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(Icmpv4Type.class)){
+ Icmpv4TypeMatchEntry icmpv4TypeMatchEntry = ofMatch.getAugmentation(Icmpv4TypeMatchEntry.class);
+ if(icmpv4TypeMatchEntry != null){
+ icmpv4MatchBuilder.setIcmpv4Type(icmpv4TypeMatchEntry.getIcmpv4Type());
+ matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(Icmpv4Code.class)){
+ Icmpv4CodeMatchEntry icmpv4CodeMatchEntry = ofMatch.getAugmentation(Icmpv4CodeMatchEntry.class);
+ if(icmpv4CodeMatchEntry != null){
+ icmpv4MatchBuilder.setIcmpv4Code(icmpv4CodeMatchEntry.getIcmpv4Code());
+ matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(Icmpv6Type.class)){
+ Icmpv6TypeMatchEntry icmpv6TypeMatchEntry = ofMatch.getAugmentation(Icmpv6TypeMatchEntry.class);
+ if(icmpv6TypeMatchEntry != null){
+ icmpv6MatchBuilder.setIcmpv6Type(icmpv6TypeMatchEntry.getIcmpv6Type());
+ matchBuilder.setIcmpv6Match(icmpv6MatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(Icmpv6Code.class)){
+ Icmpv6CodeMatchEntry icmpv6CodeMatchEntry = ofMatch.getAugmentation(Icmpv6CodeMatchEntry.class);
+ if(icmpv6CodeMatchEntry != null){
+ icmpv6MatchBuilder.setIcmpv6Code(icmpv6CodeMatchEntry.getIcmpv6Code());
+ matchBuilder.setIcmpv6Match(icmpv6MatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(Ipv4Src.class) ||
+ ofMatch.getOxmMatchField().equals(Ipv4Dst.class)){
+ Ipv4AddressMatchEntry ipv4AddressMatchEntry = ofMatch.getAugmentation(Ipv4AddressMatchEntry.class);
+ if(ipv4AddressMatchEntry != null){
+ String ipv4PrefixStr = ipv4AddressMatchEntry.getIpv4Address().getValue();
+ MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
+ if(maskMatchEntry != null){
+ ipv4PrefixStr +=PREFIX_SEPARATOR+ ByteBuffer.wrap(maskMatchEntry.getMask()).getInt();
+ }
+ if(ofMatch.getOxmMatchField().equals(Ipv4Src.class)){
+ ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix(ipv4PrefixStr));
+ }
+ if(ofMatch.getOxmMatchField().equals(Ipv4Dst.class)){
+ ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix(ipv4PrefixStr));
+ }
+ matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(ArpOp.class)){
+ OpCodeMatchEntry opCodeMatchEntry = ofMatch.getAugmentation(OpCodeMatchEntry.class);
+ if(opCodeMatchEntry != null){
+ arpMatchBuilder.setArpOp(opCodeMatchEntry.getOpCode());
+ matchBuilder.setLayer3Match(arpMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(ArpSpa.class) ||
+ ofMatch.getOxmMatchField().equals(ArpTpa.class)){
+ Ipv4AddressMatchEntry ipv4AddressMatchEntry = ofMatch.getAugmentation(Ipv4AddressMatchEntry.class);
+ if(ipv4AddressMatchEntry != null){
+ String ipv4PrefixStr = ipv4AddressMatchEntry.getIpv4Address().getValue();
+ MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
+ if(maskMatchEntry != null){
+ ipv4PrefixStr +=PREFIX_SEPARATOR+ ByteBuffer.wrap(maskMatchEntry.getMask()).getInt();
+ }
+ if(ofMatch.getOxmMatchField().equals(ArpSpa.class)){
+ arpMatchBuilder.setArpSourceTransportAddress(new Ipv4Prefix(ipv4PrefixStr));
+ }
+ if(ofMatch.getOxmMatchField().equals(ArpTpa.class)){
+ arpMatchBuilder.setArpTargetTransportAddress(new Ipv4Prefix(ipv4PrefixStr));
+ }
+ matchBuilder.setLayer3Match(arpMatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(ArpSha.class) ||
+ ofMatch.getOxmMatchField().equals(ArpTha.class)){
+ MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
+ if(macAddressMatchEntry !=null){
+ if(ofMatch.getOxmMatchField().equals(ArpSha.class)){
+ ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new ArpSourceHardwareAddressBuilder();
+ arpSourceHardwareAddressBuilder.setAddress(macAddressMatchEntry.getMacAddress());
+ MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
+ if(maskMatchEntry != null){
+ arpSourceHardwareAddressBuilder.setMask(maskMatchEntry.getMask());
+ }
+ arpMatchBuilder.setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder.build());
+ matchBuilder.setLayer3Match(arpMatchBuilder.build());
+ }
+ if(ofMatch.getOxmMatchField().equals(ArpTha.class)){
+ ArpTargetHardwareAddressBuilder arpTargetHardwareAddressBuilder = new ArpTargetHardwareAddressBuilder();
+ arpTargetHardwareAddressBuilder.setAddress(macAddressMatchEntry.getMacAddress());
+ MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
+ if(maskMatchEntry != null){
+ arpTargetHardwareAddressBuilder.setMask(maskMatchEntry.getMask());
+ }
+ arpMatchBuilder.setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder.build());
+ matchBuilder.setLayer3Match(arpMatchBuilder.build());
+ }
+ }
+ }else if(ofMatch.getOxmMatchField().equals(Ipv6Src.class) ||
+ ofMatch.getOxmMatchField().equals(Ipv6Dst.class)){
+ Ipv6AddressMatchEntry ipv6AddressMatchEntry = ofMatch.getAugmentation(Ipv6AddressMatchEntry.class);
+ if(ipv6AddressMatchEntry != null){
+ String ipv6PrefixStr = ipv6AddressMatchEntry.getIpv6Address().getValue();
+ MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
+ if(maskMatchEntry != null){
+ ipv6PrefixStr +=PREFIX_SEPARATOR+ ByteBuffer.wrap(maskMatchEntry.getMask()).getInt();
+ }
+ if(ofMatch.getOxmMatchField().equals(Ipv6Src.class)){
+ ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix(ipv6PrefixStr));
+ }
+ if(ofMatch.getOxmMatchField().equals(Ipv6Dst.class)){
+ ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix(ipv6PrefixStr));
+ }
+ matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(Ipv6Flabel.class)){
+ Ipv6FlabelMatchEntry ipv6FlabelMatchEntry = ofMatch.getAugmentation(Ipv6FlabelMatchEntry.class);
+ if(ipv6FlabelMatchEntry != null){
+ Ipv6LabelBuilder ipv6LabelBuilder = new Ipv6LabelBuilder();
+ ipv6LabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(ipv6FlabelMatchEntry.getIpv6Flabel()));
+ MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
+ if(maskMatchEntry != null){
+ ipv6LabelBuilder.setFlabelMask(maskMatchEntry.getMask());
+ }
+ ipv6MatchBuilder.setIpv6Label(ipv6LabelBuilder.build());
+ matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(Ipv6NdTarget.class)){
+ Ipv6AddressMatchEntry ipv6AddressMatchEntry = ofMatch.getAugmentation(Ipv6AddressMatchEntry.class);
+ if(ipv6AddressMatchEntry != null){
+ ipv6MatchBuilder.setIpv6NdTarget(ipv6AddressMatchEntry.getIpv6Address());
+ matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(Ipv6NdSll.class)){
+ MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
+ if(macAddressMatchEntry != null){
+ ipv6MatchBuilder.setIpv6NdSll(macAddressMatchEntry.getMacAddress());
+ matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(Ipv6NdTll.class)){
+ MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
+ if(macAddressMatchEntry != null){
+ ipv6MatchBuilder.setIpv6NdTll(macAddressMatchEntry.getMacAddress());
+ matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(Ipv6Exthdr.class)){
+ PseudoFieldMatchEntry pseudoFieldMatchEntry = ofMatch.getAugmentation(PseudoFieldMatchEntry.class);
+ if(pseudoFieldMatchEntry != null){
+ Ipv6ExtHeaderBuilder ipv6ExtHeaderBuilder = new Ipv6ExtHeaderBuilder();
+
+ PseudoField pField = pseudoFieldMatchEntry.getPseudoField();
+ Integer bitmap = 0;
+ bitmap |= pField.isNonext()?(1 << 0): ~(1 << 0);
+ bitmap |= pField.isEsp()?(1 << 1): ~(1 << 1);
+ bitmap |= pField.isAuth()?(1 << 2): ~(1 << 2);
+ bitmap |= pField.isDest()?(1 << 3): ~(1 << 3);
+ bitmap |= pField.isFrag()?(1 << 4): ~(1 << 4);
+ bitmap |= pField.isRouter()?(1 << 5): ~(1 << 5);
+ bitmap |= pField.isHop()?(1 << 6): ~(1 << 6);
+ bitmap |= pField.isUnrep()?(1 << 7): ~(1 << 7);
+ bitmap |= pField.isUnseq()?(1 << 8): ~(1 << 8);
+
+ ipv6ExtHeaderBuilder.setIpv6Exthdr(bitmap);
+ MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
+ if(maskMatchEntry != null){
+ ipv6ExtHeaderBuilder.setIpv6ExthdrMask(maskMatchEntry.getMask());
+ }
+ ipv6MatchBuilder.setIpv6ExtHeader(ipv6ExtHeaderBuilder.build());
+ matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(MplsLabel.class)){
+ MplsLabelMatchEntry mplsLabelMatchEntry = ofMatch.getAugmentation(MplsLabelMatchEntry.class);
+ if(mplsLabelMatchEntry != null){
+ protocolMatchFieldsBuilder.setMplsLabel(mplsLabelMatchEntry.getMplsLabel());
+ matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(MplsBos.class)){
+ BosMatchEntry bosMatchEntry = ofMatch.getAugmentation(BosMatchEntry.class);
+ if(bosMatchEntry != null){
+ protocolMatchFieldsBuilder.setMplsBos(bosMatchEntry.isBos()?(short)1:(short)0);
+ matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(MplsTc.class)){
+ TcMatchEntry tcMatchEntry = ofMatch.getAugmentation(TcMatchEntry.class);
+ if(tcMatchEntry != null){
+ protocolMatchFieldsBuilder.setMplsTc(tcMatchEntry.getTc());
+ matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(PbbIsid.class)){
+ IsidMatchEntry isidMatchEntry = ofMatch.getAugmentation(IsidMatchEntry.class);
+ if(isidMatchEntry != null){
+ PbbBuilder pbbBuilder = new PbbBuilder();
+ pbbBuilder.setPbbIsid(isidMatchEntry.getIsid());
+ MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
+ if(maskMatchEntry != null){
+ pbbBuilder.setPbbMask(maskMatchEntry.getMask());
+ }
+ protocolMatchFieldsBuilder.setPbb(pbbBuilder.build());
+ matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
+ }
+ }else if(ofMatch.getOxmMatchField().equals(TunnelId.class)){
+ TunnelBuilder tunnelBuilder = new TunnelBuilder();
+ MetadataMatchEntry metadataMatchEntry = ofMatch.getAugmentation(MetadataMatchEntry.class);
+ if(metadataMatchEntry != null){
+ tunnelBuilder.setTunnelId(new BigInteger(metadataMatchEntry.getMetadata()));
+ MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
+ if(maskMatchEntry != null){
+ tunnelBuilder.setTunnelMask(maskMatchEntry.getMask());
+ }
+ matchBuilder.setTunnel(tunnelBuilder.build());
+ }
+ }
+ }
+ return matchBuilder.build();
+ }
+
private static MatchEntries toOfMplsPbb(Pbb pbb) {
MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
boolean hasmask = false;
--- /dev/null
+/*
+ * Copyright IBM Corporation, 2013. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+
+import java.math.BigInteger;
+
+
+/**
+ * Class holds Openflow enum contant.
+ * @author avishnoi@in.ibm.com
+ *
+ */
+public class OpenflowEnumConstant {
+
+ public static final Short OFPTT_ALL = 0xff;
+ public static final Long ANY = Long.parseLong("ffffffff", 16);
+ public static final Long OFPP_ANY = ANY;
+ public static final Long OFPG_ANY = ANY;
+ public static final BigInteger DEFAULT_COOKIE = BigInteger.ZERO;
+ public static final BigInteger DEFAULT_COOKIE_MASK = BigInteger.ZERO;
+ public static short OPENFLOW_V10 = 0x01;
+ public static short OPENFLOW_V13 = 0x04;
+
+
+}
+/*
+ * Copyright IBM Corporation, 2013. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.openflowplugin.openflow.md.core.translator;
import java.math.BigInteger;
import org.opendaylight.openflowplugin.openflow.md.core.IMDMessageTranslator;
import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowStatsResponseConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupStatsResponseConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterStatsResponseConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdatedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdatedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures;
protected static final Logger logger = LoggerFactory
.getLogger(MultipartReplyTranslator.class);
+ private static FlowStatsResponseConvertor flowStatsConvertor = new FlowStatsResponseConvertor();
private static GroupStatsResponseConvertor groupStatsConvertor = new GroupStatsResponseConvertor();
private static MeterStatsResponseConvertor meterStatsConvertor = new MeterStatsResponseConvertor();
MultipartReplyMessage mpReply = (MultipartReplyMessage)msg;
NodeId node = this.nodeIdFromDatapathId(sc.getFeatures().getDatapathId());
switch (mpReply.getType()){
+ case OFPMPFLOW: {
+ logger.info("Received flow statistics reponse from openflow {} switch",msg.getVersion()==1?"1.0":"1.3+");
+ FlowsStatisticsUpdateBuilder message = new FlowsStatisticsUpdateBuilder();
+ message.setId(node);
+ message.setMoreReplies(mpReply.getFlags().isOFPMPFREQMORE());
+ message.setTransactionId(generateTransactionId(mpReply.getXid()));
+ MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase)mpReply.getMultipartReplyBody();
+ MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
+ message.setFlowAndStatisticsMapList(flowStatsConvertor.toSALFlowStatsList(replyBody.getFlowStats()));
+
+ logger.info("Converted flow statistics : {}",message.build().toString());
+ listDataObject.add(message.build());
+ return listDataObject;
+ }
+ case OFPMPAGGREGATE: {
+ logger.info("Received aggregate flow statistics reponse from openflow {} switch",msg.getVersion()==1?"1.0":"1.3+");
+ AggregateFlowStatisticsUpdateBuilder message = new AggregateFlowStatisticsUpdateBuilder();
+ message.setId(node);
+ message.setMoreReplies(mpReply.getFlags().isOFPMPFREQMORE());
+ message.setTransactionId(generateTransactionId(mpReply.getXid()));
+
+ MultipartReplyAggregateCase caseBody = (MultipartReplyAggregateCase)mpReply.getMultipartReplyBody();
+ MultipartReplyAggregate replyBody = caseBody.getMultipartReplyAggregate();
+ message.setByteCount(new Counter64(replyBody.getByteCount()));
+ message.setPacketCount(new Counter64(replyBody.getPacketCount()));
+ message.setFlowCount(new Counter32(replyBody.getFlowCount()));
+
+ logger.info("Converted aggregate flow statistics : {}",message.build().toString());
+ listDataObject.add(message.build());
+ return listDataObject;
+
+ }
case OFPMPGROUP:{
logger.info("Received group statistics multipart reponse");
GroupStatisticsUpdatedBuilder message = new GroupStatisticsUpdatedBuilder();
MultipartReplyGroupCase caseBody = (MultipartReplyGroupCase)mpReply.getMultipartReplyBody();
MultipartReplyGroup replyBody = caseBody.getMultipartReplyGroup();
message.setGroupStats(groupStatsConvertor.toSALGroupStatsList(replyBody.getGroupStats()));
+
logger.debug("Converted group statistics : {}",message.toString());
listDataObject.add(message.build());
return listDataObject;
message.setTransactionId(generateTransactionId(mpReply.getXid()));
MultipartReplyGroupDescCase caseBody = (MultipartReplyGroupDescCase)mpReply.getMultipartReplyBody();
MultipartReplyGroupDesc replyBody = caseBody.getMultipartReplyGroupDesc();
+
message.setGroupDescStats(groupStatsConvertor.toSALGroupDescStatsList(replyBody.getGroupDesc()));
+
logger.debug("Converted group statistics : {}",message.toString());
listDataObject.add(message.build());
return listDataObject;
MultipartReplyMeterConfigCase caseBody = (MultipartReplyMeterConfigCase)mpReply.getMultipartReplyBody();
MultipartReplyMeterConfig replyBody = caseBody.getMultipartReplyMeterConfig();
message.setMeterConfigStats(meterStatsConvertor.toSALMeterConfigList(replyBody.getMeterConfig()));
+
listDataObject.add(message.build());
return listDataObject;
}
return listDataObject;
}
default:
- logger.info(" Type : {}, not handled yet",mpReply.getType().name() );
return listDataObject;
}
}