BUG-2218: Keep existing link augmentations during discovery process
[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 java.nio.ByteBuffer;
13
14 import org.openflow.protocol.statistics.OFVendorStatistics;
15
16
17 /**
18  * This Class creates the OpenFlow Vendor Extension IPv6 Flow Stats Request
19  * messages and also reads the Reply of a stats request message.
20  *
21  */
22
23 public class V6StatsRequest extends OFVendorStatistics {
24     private static final long serialVersionUID = 1L;
25     protected int msgsubtype;
26     protected short outPort;
27     protected short match_len;
28     protected byte tableId;
29
30     public static final int NICIRA_VENDOR_ID = 0x00002320; //Nicira ID
31     private static final int NXST_FLOW = 0x0; //Nicira Flow Stats Request Id
32
33     public V6StatsRequest() {
34         this.vendor = NICIRA_VENDOR_ID;
35         this.msgsubtype = NXST_FLOW;
36         this.match_len = 0;
37     }
38
39     /**
40      * @param None. Being set with local variable (TBD).
41      */
42     public void setVendorId() {
43         this.vendor = NICIRA_VENDOR_ID;
44     }
45
46     /**
47      * @return vendor id
48      */
49     public int getVendorId() {
50         return vendor;
51     }
52
53     /**
54      * @param None. Being set with local variable (TBD).
55      */
56     public void setMsgtype() {
57         this.msgsubtype = NXST_FLOW;
58     }
59
60     /**
61      * @return vendor_msgtype
62      */
63     public int getMsgtype() {
64         return msgsubtype;
65     }
66
67     /**
68      * @param outPort the outPort to set
69      */
70     public void setOutPort(short outPort) {
71         this.outPort = outPort;
72     }
73
74     /**
75      * @return the outPort
76      */
77     public short getOutPort() {
78         return outPort;
79     }
80
81     /**
82      * @param match_len the match_len to set
83      */
84     public void setMatchLen(short match_len) {
85         this.match_len = match_len;
86     }
87
88     /**
89      * @return the match_len
90      */
91     public short getMatchLen() {
92         return match_len;
93     }
94
95     /**
96      * @param tableId the tableId to set
97      */
98     public void setTableId(byte tableId) {
99         this.tableId = tableId;
100     }
101
102     /**
103      * @return the tableId
104      */
105     public byte getTableId() {
106         return tableId;
107     }
108
109     @Override
110     public int getLength() {
111         return 20;// 4(vendor)+4(msgsubtype)+4(pad)+2(outPort)+2(match_len)+1(tableid)+3(pad)
112     }
113
114     @Override
115     public void readFrom(ByteBuffer data) {
116         this.vendor = data.getInt();
117         this.msgsubtype = data.getInt();
118         data.getInt();//pad 4 bytes
119         this.outPort = data.getShort();
120         this.match_len = data.getShort();
121         this.tableId = data.get();
122         for (int i = 0; i < 3; i++) {
123             data.get();//pad byte
124         }
125
126     }
127
128     @Override
129     public void writeTo(ByteBuffer data) {
130         data.putInt(this.vendor);
131         data.putInt(this.msgsubtype);
132         data.putInt((int) 0x0);//pad0
133         data.putShort(this.outPort);
134         data.putShort(this.match_len);
135         data.put(this.tableId);
136         for (int i = 0; i < 3; i++)  {
137             data.put((byte) 0x0);//pad byte
138         }
139     }
140
141     @Override
142     public int hashCode() {
143         final int prime = 31;
144         int result = super.hashCode();
145         result = prime * result + match_len;
146         result = prime * result + msgsubtype;
147         result = prime * result + outPort;
148         result = prime * result + tableId;
149         return result;
150     }
151
152     @Override
153     public String toString() {
154         return "V6StatsRequest [msgsubtype=" + msgsubtype + ", outPort="
155                 + outPort + ", match_len=" + match_len + ", tableId=" + tableId
156                 + "]";
157     }
158
159     @Override
160     public boolean equals(Object obj) {
161         if (this == obj)
162             return true;
163         if (!super.equals(obj))
164             return false;
165         if (getClass() != obj.getClass())
166             return false;
167         V6StatsRequest other = (V6StatsRequest) obj;
168         if (match_len != other.match_len)
169             return false;
170         if (msgsubtype != other.msgsubtype)
171             return false;
172         if (outPort != other.outPort)
173             return false;
174         if (tableId != other.tableId)
175             return false;
176         return true;
177     }
178 }