Initial opendaylight infrastructure commit!!
[controller.git] / third-party / openflowj / src / main / java / org / openflow / protocol / action / OFActionEnqueue.java
1 /**
2  * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
3  */
4 package org.openflow.protocol.action;
5
6 import java.nio.ByteBuffer;
7
8 /**
9  * Represents an ofp_action_enqueue
10  * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
11  */
12 public class OFActionEnqueue extends OFAction {
13     public static int MINIMUM_LENGTH = 16;
14
15     protected short port;
16     protected int queueId;
17
18     public OFActionEnqueue() {
19         super.setType(OFActionType.OPAQUE_ENQUEUE);
20         super.setLength((short) MINIMUM_LENGTH);
21     }
22
23     /**
24      * Get the output port
25      * @return
26      */
27     public short getPort() {
28         return this.port;
29     }
30
31     /**
32      * Set the output port
33      * @param port
34      */
35     public void setPort(short port) {
36         this.port = port;
37     }
38
39     /**
40      * @return the queueId
41      */
42     public int getQueueId() {
43         return queueId;
44     }
45
46     /**
47      * @param queueId the queueId to set
48      */
49     public void setQueueId(int queueId) {
50         this.queueId = queueId;
51     }
52
53     @Override
54     public void readFrom(ByteBuffer data) {
55         super.readFrom(data);
56         this.port = data.getShort();
57         data.getShort();
58         data.getInt();
59         this.queueId = data.getInt();
60     }
61
62     @Override
63     public void writeTo(ByteBuffer data) {
64         super.writeTo(data);
65         data.putShort(this.port);
66         data.putShort((short) 0);
67         data.putInt(0);
68         data.putInt(this.queueId);
69     }
70
71     @Override
72     public int hashCode() {
73         final int prime = 349;
74         int result = super.hashCode();
75         result = prime * result + port;
76         result = prime * result + queueId;
77         return result;
78     }
79
80     @Override
81     public boolean equals(Object obj) {
82         if (this == obj) {
83             return true;
84         }
85         if (!super.equals(obj)) {
86             return false;
87         }
88         if (!(obj instanceof OFActionEnqueue)) {
89             return false;
90         }
91         OFActionEnqueue other = (OFActionEnqueue) obj;
92         if (port != other.port) {
93             return false;
94         }
95         if (queueId != other.queueId) {
96             return false;
97         }
98         return true;
99     }
100 }