2 * Copyright IBM Corporation, 2013. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.openflow.md.util;
10 import org.opendaylight.openflowplugin.openflow.md.OFConstants;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.MatchBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
22 public class FlowCreatorUtil {
24 public static void setWildcardedFlowMatch(short version,MultipartRequestFlowBuilder flowBuilder){
25 if(version == OFConstants.OFP_VERSION_1_0){
26 flowBuilder.setMatchV10(createWildcardedMatchV10());
28 if(version == OFConstants.OFP_VERSION_1_3){
29 flowBuilder.setMatch(createWildcardedMatch());
33 public static void setWildcardedFlowMatch(short version,MultipartRequestAggregateBuilder flowBuilder){
34 if(version == OFConstants.OFP_VERSION_1_0){
35 flowBuilder.setMatchV10(createWildcardedMatchV10());
37 if(version == OFConstants.OFP_VERSION_1_3){
38 flowBuilder.setMatch(createWildcardedMatch());
43 * Method creates openflow 1.0 format match, that can match all the flow entries.
46 public static MatchV10 createWildcardedMatchV10() {
47 MatchV10Builder builder = new MatchV10Builder();
48 builder.setWildcards(new FlowWildcardsV10(true, true, true, true,
49 true, true, true, true, true, true));
50 builder.setNwSrcMask((short) 0);
51 builder.setNwDstMask((short) 0);
53 builder.setDlSrc(new MacAddress("00:00:00:00:00:00"));
54 builder.setDlDst(new MacAddress("00:00:00:00:00:00"));
56 builder.setDlVlanPcp((short) 0);
58 builder.setNwTos((short) 0);
59 builder.setNwProto((short) 0);
60 builder.setNwSrc(new Ipv4Address("0.0.0.0"));
61 builder.setNwDst(new Ipv4Address("0.0.0.0"));
65 return builder.build();
68 public static Match createWildcardedMatch(){
69 return new MatchBuilder().setType(OxmMatchType.class).build();