Merge "Added support to update flows for induvidual security rule add/remove , after...
[ovsdb.git] / openstack / net-virt-sfc / impl / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / sfc / NshUtils.java
1 /*
2  * Copyright (c) 2015 Dell, Inc. 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
9 package org.opendaylight.ovsdb.openstack.netvirt.sfc;
10
11 import com.google.common.net.InetAddresses;
12
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
15
16 /**
17  * Open Vswitch DB OpenFlow 1.3 Networking Provider for Netvirt SFC Utilities.
18  * @author Arun Yerra
19  */
20 public class NshUtils {
21     private Ipv4Address nshTunIpDst;
22     private PortNumber nshTunUdpPort;
23     private long nshNsp;
24     private short nshNsi;
25     private long nshMetaC1;
26     private long nshMetaC2;
27
28     public NshUtils() {
29         super();
30     }
31
32     /**
33      * {@link NshUtils} constructor.
34      * @param nshTunIpDst Tunnel Destination IP
35      * @param nshTunUdpPort Tunnel Transport Port
36      * @param nshNsp Service Path Id
37      * @param nshNsi Service Path Index
38      * @param nshMetaC1 End point ID
39      * @param nshMetaC2 Tunnel Id.
40      */
41     public NshUtils(Ipv4Address nshTunIpDst, PortNumber nshTunUdpPort,
42             long nshNsp, short nshNsi, long nshMetaC1,
43             long nshMetaC2) {
44         super();
45         this.nshTunIpDst = nshTunIpDst;
46         this.nshTunUdpPort = nshTunUdpPort;
47         this.nshNsp = nshNsp;
48         this.nshNsi = nshNsi;
49         this.nshMetaC1 = nshMetaC1;
50         this.nshMetaC2 = nshMetaC2;
51     }
52
53     /*
54      * @return the nshTunIpDst
55      */
56     public Ipv4Address getNshTunIpDst() {
57         return nshTunIpDst;
58     }
59
60     /*
61      * @param nshTunIpDst the nshTunIpDst to set
62      */
63     public void setNshTunIpDst(Ipv4Address nshTunIpDst) {
64         this.nshTunIpDst = nshTunIpDst;
65     }
66
67     /*
68      * @return the nshTunUdpPort
69      */
70     public PortNumber getNshTunUdpPort() {
71         return nshTunUdpPort;
72     }
73
74     /*
75      * @param nshTunUdpPort the nshTunUdpPort to set
76      */
77     public void setNshTunUdpPort(PortNumber nshTunUdpPort) {
78         this.nshTunUdpPort = nshTunUdpPort;
79     }
80
81     /*
82      * @return the nshNsp
83      */
84     public long getNshNsp() {
85         return nshNsp;
86     }
87
88     /*
89      * @param nshNsp the nshNsp to set
90      */
91     public void setNshNsp(long nshNsp) {
92         this.nshNsp = nshNsp;
93     }
94
95     /*
96      * @return the nshNsi
97      */
98     public short getNshNsi() {
99         return nshNsi;
100     }
101
102     /*
103      * @param nshNsi the nshNsi to set
104      */
105     public void setNshNsi(short nshNsi) {
106         this.nshNsi = nshNsi;
107     }
108
109     /*
110      * @return the nshMetaC1
111      */
112     public long getNshMetaC1() {
113         return nshMetaC1;
114     }
115
116     /*
117      * @param nshMetaC1 the nshMetaC1 to set
118      */
119     public void setNshMetaC1(long nshMetaC1) {
120         this.nshMetaC1 = nshMetaC1;
121     }
122
123     /*
124      * @return the nshMetaC2
125      */
126     public long getNshMetaC2() {
127         return nshMetaC2;
128     }
129
130     /*
131      * @param nshMetaC2 the nshMetaC2 to set
132      */
133     public void setNshMetaC2(long nshMetaC2) {
134         this.nshMetaC2 = nshMetaC2;
135     }
136
137     public static Long convertIpAddressToLong(Ipv4Address ipv4Address) {
138         return (InetAddresses.coerceToInteger(InetAddresses.forString(ipv4Address.getValue()))) & 0xFFFFFFFFL;
139     }
140
141     /* (non-Javadoc)
142      * @see java.lang.Object#toString()
143      */
144     @Override
145     public String toString() {
146         return "NshUtils [nshTunIpDst=" + nshTunIpDst + ", nshTunUdpPort=" + nshTunUdpPort + ", nshNsp=" + nshNsp
147                 + ", nshNsi=" + nshNsi + ", nshMetaC1=" + nshMetaC1 + ", nshMetaC2=" + nshMetaC2 + "]";
148     }
149 }