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.api.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.grouping.Match;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;
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 final class FlowCreatorUtil {
24 private FlowCreatorUtil() {
25 throw new AssertionError("FlowCreatorUtil is not expected to be instantiated.");
28 public static void setWildcardedFlowMatch(short version, MultipartRequestFlowBuilder flowBuilder) {
29 if (version == OFConstants.OFP_VERSION_1_0) {
30 flowBuilder.setMatchV10(createWildcardedMatchV10());
32 if (version == OFConstants.OFP_VERSION_1_3) {
33 flowBuilder.setMatch(createWildcardedMatch());
37 public static void setWildcardedFlowMatch(short version, MultipartRequestAggregateBuilder aggregateBuilder) {
38 if (version == OFConstants.OFP_VERSION_1_0) {
39 aggregateBuilder.setMatchV10(createWildcardedMatchV10());
41 if (version == OFConstants.OFP_VERSION_1_3) {
42 aggregateBuilder.setMatch(createWildcardedMatch());
47 * Method creates openflow 1.0 format match, that can match all the flow entries.
51 public static MatchV10 createWildcardedMatchV10() {
52 MatchV10Builder builder = new MatchV10Builder();
53 builder.setWildcards(new FlowWildcardsV10(true, true, true, true,
54 true, true, true, true, true, true));
55 builder.setNwSrcMask((short) 0);
56 builder.setNwDstMask((short) 0);
58 builder.setDlSrc(new MacAddress("00:00:00:00:00:00"));
59 builder.setDlDst(new MacAddress("00:00:00:00:00:00"));
61 builder.setDlVlanPcp((short) 0);
63 builder.setNwTos((short) 0);
64 builder.setNwProto((short) 0);
65 builder.setNwSrc(new Ipv4Address("0.0.0.0"));
66 builder.setNwDst(new Ipv4Address("0.0.0.0"));
69 return builder.build();
72 public static Match createWildcardedMatch() {
73 return new MatchBuilder().setType(OxmMatchType.class).build();