2 * Copyright (c) 2014, 2015 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.openflowjava.nx.codec.match;
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
12 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
14 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxArpSha;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.ArpShaCaseValue;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.ArpShaCaseValueBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.arp.sha.grouping.ArpShaValuesBuilder;
26 public class ArpShaCodec extends AbstractMatchCodec {
27 private static final int VALUE_LENGTH = 6;
28 private static final int NXM_FIELD_CODE = 17;
29 public static final MatchEntrySerializerKey<Nxm1Class, NxmNxArpSha> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
30 EncodeConstants.OF_VERSION_1_3, Nxm1Class.VALUE, NxmNxArpSha.VALUE);
31 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
32 EncodeConstants.OF_VERSION_1_3, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
35 public void serialize(final MatchEntry input, final ByteBuf outBuffer) {
36 serializeHeader(input, outBuffer);
37 ArpShaCaseValue value = (ArpShaCaseValue) input.getMatchEntryValue();
38 outBuffer.writeBytes(IetfYangUtil.macAddressBytes(value.getArpShaValues().getMacAddress()));
42 public MatchEntry deserialize(final ByteBuf message) {
43 MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message);
44 byte[] address = new byte[VALUE_LENGTH];
45 message.readBytes(address);
46 ArpShaCaseValueBuilder caseBuilder = new ArpShaCaseValueBuilder();
47 caseBuilder.setArpShaValues(new ArpShaValuesBuilder()
48 .setMacAddress(IetfYangUtil.macAddressFor(address))
50 matchEntriesBuilder.setMatchEntryValue(caseBuilder.build());
51 return matchEntriesBuilder.build();
55 public int getNxmFieldCode() {
56 return NXM_FIELD_CODE;
60 public int getOxmClassCode() {
61 return OxmMatchConstants.NXM_1_CLASS;
65 public int getValueLength() {
70 public MatchField getNxmField() {
71 return NxmNxArpSha.VALUE;
75 public OxmClassBase getOxmClass() {
76 return Nxm1Class.VALUE;