Mass replace CRLF->LF
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / serialization / match / OxmIpv6ExtHdrSerializer.java
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowjava.protocol.impl.serialization.match;
9
10 import io.netty.buffer.ByteBuf;
11
12 import org.opendaylight.openflowjava.util.ByteBufUtils;
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.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
18
19 /**
20  * @author michal.polkorab
21  *
22  */
23 public class OxmIpv6ExtHdrSerializer extends AbstractOxmMatchEntrySerializer {
24
25     @Override
26     public void serialize(final MatchEntries entry, final ByteBuf outBuffer) {
27         super.serialize(entry, outBuffer);
28         Ipv6ExthdrFlags pseudoField = entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField();
29         int bitmap = ByteBufUtils.fillBitMask(0,
30                 pseudoField.isNonext(),
31                 pseudoField.isEsp(),
32                 pseudoField.isAuth(),
33                 pseudoField.isDest(),
34                 pseudoField.isFrag(),
35                 pseudoField.isRouter(),
36                 pseudoField.isHop(),
37                 pseudoField.isUnrep(),
38                 pseudoField.isUnseq());
39         outBuffer.writeShort(bitmap);
40         writeMask(entry, outBuffer, getValueLength());
41     }
42
43     @Override
44     protected int getOxmClassCode() {
45         return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
46     }
47
48     @Override
49     protected int getOxmFieldCode() {
50         return OxmMatchConstants.IPV6_EXTHDR;
51     }
52
53     @Override
54     protected int getValueLength() {
55         return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
56     }
57 }