lishuai | 7e6b317 | 2015-11-20 15:42:28 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
lishuai | 7e6b317 | 2015-11-20 15:42:28 +0800 | [diff] [blame] | 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.vtn.table; |
| 17 | |
| 18 | import org.onlab.packet.IpAddress; |
Bob zhou | 59a2106 | 2016-05-12 19:40:05 +0800 | [diff] [blame] | 19 | import org.onlab.packet.IpPrefix; |
lishuai | 7e6b317 | 2015-11-20 15:42:28 +0800 | [diff] [blame] | 20 | import org.onlab.packet.MacAddress; |
| 21 | import org.onosproject.net.DeviceId; |
Bob zhou | 59a2106 | 2016-05-12 19:40:05 +0800 | [diff] [blame] | 22 | import org.onosproject.net.flow.TrafficSelector; |
| 23 | import org.onosproject.net.flow.TrafficTreatment; |
lishuai | 7e6b317 | 2015-11-20 15:42:28 +0800 | [diff] [blame] | 24 | import org.onosproject.net.flowobjective.Objective; |
| 25 | import org.onosproject.vtnrsc.SegmentationId; |
| 26 | |
| 27 | /** |
| 28 | * SnatService interface provides the rules in SNAT table which is Table(40) for ovs pipeline. |
| 29 | * SNAT means Source Network Address Translation, it is acronym for network terminology. |
| 30 | * Handle the upward flows. |
| 31 | */ |
| 32 | public interface SnatService { |
| 33 | |
| 34 | /** |
| 35 | * Assemble the SNAT table rules. |
Bob zhou | 59a2106 | 2016-05-12 19:40:05 +0800 | [diff] [blame] | 36 | * Match: ipv4 type, vnid, destination ip and source ip. |
| 37 | * Action: set eth_src, set eth_dst, set ip_src, set vnid and goto L2Forward Table(50). |
| 38 | * |
| 39 | * @param deviceId Device Id |
| 40 | * @param matchVni the vni of L3 network |
| 41 | * @param srcIP source ip |
| 42 | * @param dstIP destination ip |
| 43 | * @param ethDst external gateway mac |
| 44 | * @param ethSrc external port mac |
| 45 | * @param ipSrc floating ip |
| 46 | * @param actionVni external network VNI |
| 47 | * @param type the operation type of the flow rules |
| 48 | */ |
| 49 | void programSnatSameSegmentRules(DeviceId deviceId, SegmentationId matchVni, |
| 50 | IpAddress srcIP, IpAddress dstIP, MacAddress ethDst, |
| 51 | MacAddress ethSrc, IpAddress ipSrc, |
| 52 | SegmentationId actionVni, Objective.Operation type); |
| 53 | /** |
| 54 | * Assemble the SNAT table rules. |
lishuai | 7e6b317 | 2015-11-20 15:42:28 +0800 | [diff] [blame] | 55 | * Match: ipv4 type, vnid and source ip. |
| 56 | * Action: set eth_src, set eth_dst, set ip_src, set vnid and goto L2Forward Table(50). |
| 57 | * |
| 58 | * @param deviceId Device Id |
| 59 | * @param matchVni the vni of L3 network |
| 60 | * @param srcIP source ip |
| 61 | * @param ethDst external gateway mac |
| 62 | * @param ethSrc external port mac |
| 63 | * @param ipSrc floating ip |
| 64 | * @param actionVni external network VNI |
| 65 | * @param type the operation type of the flow rules |
| 66 | */ |
Bob zhou | 59a2106 | 2016-05-12 19:40:05 +0800 | [diff] [blame] | 67 | void programSnatDiffSegmentRules(DeviceId deviceId, SegmentationId matchVni, |
lishuai | 7e6b317 | 2015-11-20 15:42:28 +0800 | [diff] [blame] | 68 | IpAddress srcIP, MacAddress ethDst, |
| 69 | MacAddress ethSrc, IpAddress ipSrc, |
| 70 | SegmentationId actionVni, Objective.Operation type); |
Bob zhou | 59a2106 | 2016-05-12 19:40:05 +0800 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * Assemble the SNAT table rules. |
| 74 | * Match: ipv4 type, vnid, destination ip and source ip. |
| 75 | * Action: upload to controller. |
| 76 | * |
| 77 | * @param deviceId Device Id |
| 78 | * @param matchVni the vni of L3 network |
| 79 | * @param srcIP source ip |
| 80 | * @param dstIP destination ip |
Avantika-Huawei | 09a6a2e | 2016-05-16 19:14:30 +0530 | [diff] [blame] | 81 | * @param prefix prefix |
Bob zhou | 59a2106 | 2016-05-12 19:40:05 +0800 | [diff] [blame] | 82 | * @param type the operation type of the flow rules |
| 83 | */ |
| 84 | void programSnatSameSegmentUploadControllerRules(DeviceId deviceId, |
| 85 | SegmentationId matchVni, |
| 86 | IpAddress srcIP, |
| 87 | IpAddress dstIP, |
| 88 | IpPrefix prefix, |
| 89 | Objective.Operation type); |
| 90 | |
| 91 | /** |
| 92 | * Remove the SNAT table rules. |
| 93 | * |
| 94 | * @param deviceId Device Id |
| 95 | * @param selector selector of rules |
| 96 | * @param treatment treatment of rules |
| 97 | * @param priority priority of rules |
| 98 | * @param type the operation type of the flow rules |
| 99 | */ |
| 100 | void removeSnatRules(DeviceId deviceId, TrafficSelector selector, |
| 101 | TrafficTreatment treatment, int priority, |
| 102 | Objective.Operation type); |
lishuai | 7e6b317 | 2015-11-20 15:42:28 +0800 | [diff] [blame] | 103 | } |