blob: 57f6e8bd06419a8882988a71ee0d765a8a58994f [file] [log] [blame]
samueljcc4a527ed2015-12-03 13:59:49 +08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
samueljcc4a527ed2015-12-03 13:59:49 +08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.driver.extensions;
17
18import org.onosproject.net.flow.instructions.ExtensionTreatment;
19import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
20
21/**
22 * The factory of move treatment.
23 */
24public final class NiciraMoveTreatmentFactory {
25
26 /**
27 * Public constructor is prohibited.
28 */
29 private NiciraMoveTreatmentFactory() {
30
31 }
32
33 /**
34 * Creates a move treatment that move arp sha to tha.
35 *
36 * @return ExtensionTreatment
37 */
38 public static ExtensionTreatment createNiciraMovArpShaToTha() {
39 int srcOfs = 0;
40 int dstOfs = 0;
41 int nBits = 48;
42 int srcSha = 0x00012206;
43 int dstTha = 0x00012406;
44 return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcSha,
45 dstTha,
46 ExtensionTreatmentType.ExtensionTreatmentTypes
47 .NICIRA_MOV_ARP_SHA_TO_THA.type());
48 }
49
50 /**
51 * Creates a move treatment that move arp spa to tpa.
52 *
53 * @return ExtensionTreatment
54 */
55 public static ExtensionTreatment createNiciraMovArpSpaToTpa() {
56 int srcOfs = 0;
57 int dstOfs = 0;
58 int nBits = 32;
59 int srcSpa = 0x00002004;
60 int dstTpa = 0x00002204;
61 return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcSpa,
62 dstTpa,
63 ExtensionTreatmentType.ExtensionTreatmentTypes
64 .NICIRA_MOV_ARP_SPA_TO_TPA.type());
65 }
66
67 /**
68 * Creates a move treatment that move eth src to dst.
69 *
70 * @return ExtensionTreatment
71 */
72 public static ExtensionTreatment createNiciraMovEthSrcToDst() {
73 int srcOfs = 0;
74 int dstOfs = 0;
75 int nBits = 48;
76 int srcEth = 0x00000406;
77 int dstEth = 0x00000206;
78 return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcEth,
79 dstEth,
80 ExtensionTreatmentType.ExtensionTreatmentTypes
81 .NICIRA_MOV_ETH_SRC_TO_DST.type());
82 }
83
84 /**
85 * Creates a move treatment that move ip src to dst.
86 *
87 * @return ExtensionTreatment
88 */
89 public static ExtensionTreatment createNiciraMovIpSrcToDst() {
90 int srcOfs = 0;
91 int dstOfs = 0;
92 int nBits = 32;
93 int srcIp = 0x00000e04;
samueljcc4f4d25a2015-12-07 10:52:28 +080094 int dstIp = 0x00001004;
samueljcc4a527ed2015-12-03 13:59:49 +080095 return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcIp,
96 dstIp,
97 ExtensionTreatmentType.ExtensionTreatmentTypes
98 .NICIRA_MOV_IP_SRC_TO_DST.type());
99 }
Phaneendra Manda8db7d092016-06-04 00:17:24 +0530100
101 public static ExtensionTreatment createNiciraMovNshC1ToC1() {
102 int srcOfs = 0;
103 int dstOfs = 0;
104 int nBits = 32;
105 int srcC1 = 0x0001e604;
106 int dstC1 = 0x0001e604;
107 return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcC1,
108 dstC1,
109 ExtensionTreatmentType.ExtensionTreatmentTypes
110 .NICIRA_MOV_NSH_C1_TO_C1.type());
111 }
112
113 public static ExtensionTreatment createNiciraMovNshC2ToC2() {
114 int srcOfs = 0;
115 int dstOfs = 0;
116 int nBits = 32;
117 int srcC2 = 0x0001e804;
118 int dstC2 = 0x0001e804;
119 return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcC2,
120 dstC2,
121 ExtensionTreatmentType.ExtensionTreatmentTypes
122 .NICIRA_MOV_NSH_C2_TO_C2.type());
123 }
124
125 public static ExtensionTreatment createNiciraMovNshC3ToC3() {
126 int srcOfs = 0;
127 int dstOfs = 0;
128 int nBits = 32;
129 int srcC3 = 0x0001ea04;
130 int dstC3 = 0x0001ea04;
131 return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcC3,
132 dstC3,
133 ExtensionTreatmentType.ExtensionTreatmentTypes
134 .NICIRA_MOV_NSH_C3_TO_C3.type());
135 }
136
137 public static ExtensionTreatment createNiciraMovNshC4ToC4() {
138 int srcOfs = 0;
139 int dstOfs = 0;
140 int nBits = 32;
141 int srcC4 = 0x0001ec04;
142 int dstC4 = 0x0001ec04;
143 return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcC4,
144 dstC4,
145 ExtensionTreatmentType.ExtensionTreatmentTypes
146 .NICIRA_MOV_NSH_C4_TO_C4.type());
147 }
148
149 public static ExtensionTreatment createNiciraMovTunDstToTunDst() {
150 int srcOfs = 0;
151 int dstOfs = 0;
152 int nBits = 32;
153 int srcTunIpv4Dst = 0x00014004;
154 int dstTunIpv4Dst = 0x00014004;
155 return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcTunIpv4Dst,
156 dstTunIpv4Dst,
157 ExtensionTreatmentType.ExtensionTreatmentTypes
158 .NICIRA_MOV_TUN_IPV4_DST_TO_TUN_IPV4_DST.type());
159 }
160
161 public static ExtensionTreatment createNiciraMovTunIdToTunId() {
162 int srcOfs = 0;
163 int dstOfs = 0;
164 int nBits = 64;
165 int srcTunId = 0x12008;
166 int dstTunId = 0x12008; // 0x80004c08;
167 return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcTunId,
168 dstTunId,
169 ExtensionTreatmentType.ExtensionTreatmentTypes
170 .NICIRA_MOV_TUN_ID_TO_TUN_ID.type());
171 }
172
173 public static ExtensionTreatment createNiciraMovNshC2ToTunId() {
174 int srcOfs = 0;
175 int dstOfs = 0;
176 int nBits = 32;
177 int srcC2 = 0x0001e804;
178 int dstTunId = 0x80004c08;
179 return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcC2,
180 dstTunId,
181 ExtensionTreatmentType.ExtensionTreatmentTypes
182 .NICIRA_MOV_NSH_C2_TO_TUN_ID.type());
183 }
samueljcc4a527ed2015-12-03 13:59:49 +0800184}