2 * Copyright (c) 2016 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
8 package org.opendaylight.openflowjava.nx.codec.match;
10 import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
14 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
15 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
16 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfIpSrc;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.IpSrcCaseValue;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.IpSrcCaseValueBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.ip.src.grouping.IpSrcValuesBuilder;
27 * Codec for the IpSrc message.
29 * @author Josh Hershberg (jhershbe@redhat.com)
31 public class IpSrcCodec extends AbstractMatchCodec {
33 private static final int VALUE_LENGTH = 4;
34 private static final int NXM_FIELD_CODE = 7;
35 public static final MatchEntrySerializerKey<Nxm0Class, NxmOfIpSrc> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
36 EncodeConstants.OF_VERSION_1_3, Nxm0Class.VALUE, NxmOfIpSrc.VALUE);
37 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
38 EncodeConstants.OF_VERSION_1_3, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
42 public MatchEntry deserialize(final ByteBuf message) {
43 return deserializeHeaderToBuilder(message)
44 .setMatchEntryValue(new IpSrcCaseValueBuilder()
45 .setIpSrcValues(new IpSrcValuesBuilder().setValue(readUint32(message)).build())
51 public void serialize(final MatchEntry input, final ByteBuf outBuffer) {
52 serializeHeader(input, outBuffer);
53 IpSrcCaseValue ipSrcCase = (IpSrcCaseValue) input.getMatchEntryValue();
54 outBuffer.writeInt(ipSrcCase.getIpSrcValues().getValue().intValue());
58 public int getNxmFieldCode() {
59 return NXM_FIELD_CODE;
63 public int getOxmClassCode() {
64 return OxmMatchConstants.NXM_0_CLASS;
68 public int getValueLength() {
73 public MatchField getNxmField() {
74 return NxmOfIpSrc.VALUE;
78 public OxmClassBase getOxmClass() {
79 return Nxm0Class.VALUE;