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;
12 * OF-action related utilities
14 public final class ActionUtil {
16 /** http://en.wikipedia.org/wiki/IPv4#Packet_structure (end of octet number 1, bit 14.+15.) */
17 public static final int ENC_FIELD_BIT_SIZE = 2;
19 private ActionUtil() {
20 throw new AssertionError("ActionUtil is not expected to be instantiated.");
24 * @param tosValue TypeOfService value
27 public static Short tosToDscp(short tosValue) {
28 return (short) (tosValue >>> ActionUtil.ENC_FIELD_BIT_SIZE);
32 * @param dscpValue TypeOfService value
35 public static Short dscpToTos(short dscpValue) {
36 return (short) (dscpValue << ActionUtil.ENC_FIELD_BIT_SIZE);