samueljcc | 4a527ed | 2015-12-03 13:59:49 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 3 | * |
| 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 | */ |
| 16 | package org.onosproject.driver.extensions; |
| 17 | |
| 18 | import org.onosproject.net.flow.instructions.ExtensionTreatment; |
| 19 | import org.onosproject.net.flow.instructions.ExtensionTreatmentType; |
| 20 | |
| 21 | /** |
| 22 | * The factory of move treatment. |
| 23 | */ |
| 24 | public 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; |
samueljcc | 4f4d25a | 2015-12-07 10:52:28 +0800 | [diff] [blame] | 94 | int dstIp = 0x00001004; |
samueljcc | 4a527ed | 2015-12-03 13:59:49 +0800 | [diff] [blame] | 95 | return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcIp, |
| 96 | dstIp, |
| 97 | ExtensionTreatmentType.ExtensionTreatmentTypes |
| 98 | .NICIRA_MOV_IP_SRC_TO_DST.type()); |
| 99 | } |
| 100 | } |