2 * Copyright (c) 2017 Red Hat, 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
9 package org.opendaylight.netvirt.ipv6service;
11 import java.util.ArrayList;
12 import java.util.List;
14 public class Ipv6TestUtils {
16 public byte[] buildPacket(String... contents) {
17 List<String[]> splitContents = new ArrayList<>();
19 for (String content : contents) {
20 String[] split = content.split(" ");
21 packetLength += split.length;
22 splitContents.add(split);
24 byte[] packet = new byte[packetLength];
26 for (String[] split : splitContents) {
27 for (String component : split) {
28 // We can't use Byte.parseByte() here, it refuses anything > 7F
29 packet[index] = (byte) Integer.parseInt(component, 16);