blob: 2afd50ab9c9cce0be3ef8ff56e07f161b5052088 [file] [log] [blame]
Charles Chan64c2dfd2018-07-24 11:58:08 -07001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onlab.packet.lacp;
18
19import org.onlab.packet.Deserializer;
20
21import java.nio.ByteBuffer;
22
23import static com.google.common.base.MoreObjects.toStringHelper;
24import static org.onlab.packet.PacketUtils.checkInput;
25
26/**
27 * Represents LACP terminator information.
28 */
29public class LacpTerminatorTlv extends LacpTlv {
30 public static final byte LENGTH = 0;
31 static final byte PADDING_LENGTH = 50;
32 private static final byte[] PADDING = new byte[PADDING_LENGTH];
33
34 /**
35 * Deserializer function for LacpTerminatorTlv packets.
36 *
37 * @return deserializer function
38 */
39 public static Deserializer<LacpTerminatorTlv> deserializer() {
40 return (data, offset, length) -> {
41 checkInput(data, offset, length, LENGTH);
42
43 return new LacpTerminatorTlv();
44 };
45 }
46
47 @Override
48 public byte[] serialize() {
49 final byte[] data = new byte[LENGTH + PADDING_LENGTH];
50
51 final ByteBuffer bb = ByteBuffer.wrap(data);
52 bb.put(PADDING);
53
54 return data;
55 }
56
57 @Override
58 public String toString() {
59 return toStringHelper(getClass()).toString();
60 }
61}