26d0065a45162ca493a5c15266d4b405ecc338ab
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / vendorextension / v6extension / V6StatsRequest.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension;
11
12 import org.apache.commons.lang3.builder.EqualsBuilder;
13 import org.apache.commons.lang3.builder.HashCodeBuilder;
14 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
15 import org.openflow.protocol.statistics.OFVendorStatistics;
16 import java.nio.ByteBuffer;
17
18
19 /**
20  * This Class creates the OpenFlow Vendor Extension IPv6 Flow Stats Request 
21  * messages and also reads the Reply of a stats request message.
22  * 
23  */
24
25 public class V6StatsRequest extends OFVendorStatistics {
26     private static final long serialVersionUID = 1L;
27     protected int msgsubtype;
28     protected short outPort;
29     protected short match_len;
30     protected byte tableId;
31
32     public static final int NICIRA_VENDOR_ID = 0x00002320; //Nicira ID
33     private static final int NXST_FLOW = 0x0; //Nicira Flow Stats Request Id
34
35     public V6StatsRequest() {
36         this.vendor = NICIRA_VENDOR_ID;
37         this.msgsubtype = NXST_FLOW;
38         this.match_len = 0;
39     }
40
41     /**
42      * @param None. Being set with local variable (TBD).
43      */
44     public void setVendorId() {
45         this.vendor = NICIRA_VENDOR_ID;
46     }
47
48     /**
49      * @return vendor id
50      */
51     public int getVendorId() {
52         return vendor;
53     }
54
55     /**
56      * @param None. Being set with local variable (TBD).
57      */
58     public void setMsgtype() {
59         this.msgsubtype = NXST_FLOW;
60     }
61
62     /**
63      * @return vendor_msgtype
64      */
65     public int getMsgtype() {
66         return msgsubtype;
67     }
68
69     /**
70      * @param outPort the outPort to set
71      */
72     public void setOutPort(short outPort) {
73         this.outPort = outPort;
74     }
75
76     /**
77      * @return the outPort
78      */
79     public short getOutPort() {
80         return outPort;
81     }
82
83     /**
84      * @param match_len the match_len to set
85      */
86     public void setMatchLen(short match_len) {
87         this.match_len = match_len;
88     }
89
90     /**
91      * @return the match_len
92      */
93     public short getMatchLen() {
94         return match_len;
95     }
96
97     /**
98      * @param tableId the tableId to set
99      */
100     public void setTableId(byte tableId) {
101         this.tableId = tableId;
102     }
103
104     /**
105      * @return the tableId
106      */
107     public byte getTableId() {
108         return tableId;
109     }
110
111     @Override
112     public int getLength() {
113         return 20;// 4(vendor)+4(msgsubtype)+4(pad)+2(outPort)+2(match_len)+1(tableid)+3(pad)
114     }
115
116     @Override
117     public void readFrom(ByteBuffer data) {
118         this.vendor = data.getInt();
119         this.msgsubtype = data.getInt();
120         data.getInt();//pad 4 bytes
121         this.outPort = data.getShort();
122         this.match_len = data.getShort();
123         this.tableId = data.get();
124         for (int i = 0; i < 3; i++)
125             data.get();//pad byte
126
127     }
128
129     @Override
130     public void writeTo(ByteBuffer data) {
131         data.putInt(this.vendor);
132         data.putInt(this.msgsubtype);
133         data.putInt((int) 0x0);//pad0
134         data.putShort(this.outPort);
135         data.putShort(this.match_len);
136         data.put(this.tableId);
137         for (int i = 0; i < 3; i++)
138             data.put((byte) 0x0);//pad byte
139     }
140
141     @Override
142     public int hashCode() {
143         return HashCodeBuilder.reflectionHashCode(this);
144     }
145
146     @Override
147     public String toString() {
148         return "V6StatsRequest[" + ReflectionToStringBuilder.toString(this)
149                 + "]";
150     }
151
152     @Override
153     public boolean equals(Object obj) {
154         return EqualsBuilder.reflectionEquals(this, obj);
155     }
156 }