cc95a7bc2595df7cf7020387209fcec452023d16
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / match / MatchConvertorUtil.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
9
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
11
12 /**
13  * match related tools
14  */
15 public abstract class MatchConvertorUtil {
16
17     private static final String PREFIX_SEPARATOR = "/";
18
19     /**
20      * @param pField ipv6 external header flag
21      * @return integer containing lower 9 bits filled with corresponding flags
22      */
23     public static Integer ipv6ExthdrFlagsToInt(final Ipv6ExthdrFlags pField) {
24         Integer bitmap = 0;
25         bitmap |= pField.isNonext() ? (1 << 0) : 0;
26         bitmap |= pField.isEsp() ? (1 << 1) : 0;
27         bitmap |= pField.isAuth() ? (1 << 2) : 0;
28         bitmap |= pField.isDest() ? (1 << 3) : 0;
29         bitmap |= pField.isFrag() ? (1 << 4) : 0;
30         bitmap |= pField.isRouter() ? (1 << 5) : 0;
31         bitmap |= pField.isHop() ? (1 << 6) : 0;
32         bitmap |= pField.isUnrep() ? (1 << 7) : 0;
33         bitmap |= pField.isUnseq() ? (1 << 8) : 0;
34         return bitmap;
35     }
36
37 }