blob: e82bc40249b11935b59aa25ac7d65a21c7bb865c [file] [log] [blame]
Yotam Harchol6fccde62013-08-15 12:04:52 -07001package org.openflow.types;
2
3import org.jboss.netty.buffer.ChannelBuffer;
4
Andreas Wundsam880a2a82013-08-22 07:55:14 -07005public class OFMetadata implements OFValueType<OFMetadata> {
6
Yotam Harchol6fccde62013-08-15 12:04:52 -07007 private static int LENGTH = 8;
8
Andreas Wundsam880a2a82013-08-22 07:55:14 -07009 private final U64 u64;
Yotam Harcholc2813602013-08-20 12:14:22 -070010
Andreas Wundsam880a2a82013-08-22 07:55:14 -070011 public static final OFMetadata NO_MASK = OFMetadata.of(U64.ofRaw(0xFFFFFFFFFFFFFFFFl));
12 public static final OFMetadata FULL_MASK = OFMetadata.of(U64.ofRaw(0x0));
13
14 public OFMetadata(U64 ofRaw) {
15 u64 = ofRaw;
Yotam Harchol6fccde62013-08-15 12:04:52 -070016 }
17
Andreas Wundsam880a2a82013-08-22 07:55:14 -070018 public static OFMetadata of(U64 u64) {
19 return new OFMetadata(u64);
Yotam Harchol6fccde62013-08-15 12:04:52 -070020 }
Andreas Wundsam880a2a82013-08-22 07:55:14 -070021
22 public static OFMetadata ofRaw(long raw) {
23 return new OFMetadata(U64.ofRaw(raw));
24 }
25
Yotam Harchol6fccde62013-08-15 12:04:52 -070026 public static OFMetadata read8Bytes(ChannelBuffer cb) {
Andreas Wundsam880a2a82013-08-22 07:55:14 -070027 return OFMetadata.ofRaw(cb.readLong());
Yotam Harchol6fccde62013-08-15 12:04:52 -070028 }
Andreas Wundsam880a2a82013-08-22 07:55:14 -070029
Yotam Harchol6fccde62013-08-15 12:04:52 -070030 public void write8Bytes(ChannelBuffer cb) {
Andreas Wundsam880a2a82013-08-22 07:55:14 -070031 u64.writeTo(cb);
Yotam Harchol6fccde62013-08-15 12:04:52 -070032 }
33
34 @Override
35 public int getLength() {
Andreas Wundsam880a2a82013-08-22 07:55:14 -070036 return u64.getLength();
Yotam Harchol6fccde62013-08-15 12:04:52 -070037 }
38
39 @Override
40 public OFMetadata applyMask(OFMetadata mask) {
Andreas Wundsam880a2a82013-08-22 07:55:14 -070041 return OFMetadata.of(this.u64.applyMask(mask.u64));
Yotam Harchol6fccde62013-08-15 12:04:52 -070042 }
Andreas Wundsam880a2a82013-08-22 07:55:14 -070043
Yotam Harchol6fccde62013-08-15 12:04:52 -070044}