2 * Copyright (c) 2013 Cisco Systems, Inc. and others. 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.droptest;
10 import com.google.common.base.Preconditions;
11 import com.google.common.primitives.UnsignedBytes;
13 public class DropTestUtils {
14 private static final char[] HEX = "0123456789ABCDEF".toCharArray();
16 private static final void appendByte(final StringBuilder sb, final byte b) {
17 int v = UnsignedBytes.toInt(b);
18 sb.append(HEX[v >> 4]);
19 sb.append(HEX[v & 15]);
22 public static String macToString(final byte[] mac) {
23 Preconditions.checkArgument(mac.length == 6);
25 final StringBuilder sb = new StringBuilder(17);
26 appendByte(sb, mac[0]);
28 for (int i = 1; i < mac.length; i++) {
30 appendByte(sb, mac[i]);