Jian Li | 0e09eaa | 2017-02-14 02:01:18 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present 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.mapping.addresses; |
| 17 | |
| 18 | import org.onlab.packet.IpPrefix; |
| 19 | import org.onlab.packet.MacAddress; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.flow.criteria.ExtensionSelector; |
| 22 | |
| 23 | /** |
| 24 | * Factory class for creating various mapping addresses. |
| 25 | */ |
| 26 | public final class MappingAddresses { |
| 27 | |
| 28 | /** |
| 29 | * Prevents instantiation from external. |
| 30 | */ |
| 31 | private MappingAddresses() {} |
| 32 | |
| 33 | /** |
| 34 | * Creates an ASMappingAddress using the specified value. |
| 35 | * |
| 36 | * @param asn Autonomous System Number |
| 37 | * @return mapping address |
| 38 | */ |
| 39 | public static ASMappingAddress asMappingAddress(String asn) { |
| 40 | return new ASMappingAddress(asn); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Creates a DNMappingAddress using the specified value. |
| 45 | * |
| 46 | * @param dn Distinguished Name |
| 47 | * @return mapping address |
| 48 | */ |
| 49 | public static DNMappingAddress dnMappingAddress(String dn) { |
| 50 | return new DNMappingAddress(dn); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Creates an EthMappingAddress using the specified value. |
| 55 | * |
| 56 | * @param mac MAC address |
| 57 | * @return mapping address |
| 58 | */ |
| 59 | public static EthMappingAddress ethMappingAddress(MacAddress mac) { |
| 60 | return new EthMappingAddress(mac); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Creates an IPv4MappingAddress using the specified value. |
| 65 | * |
| 66 | * @param ip IP address |
| 67 | * @return mapping address |
| 68 | */ |
| 69 | public static IPMappingAddress ipv4MappingAddress(IpPrefix ip) { |
| 70 | return new IPMappingAddress(ip, MappingAddress.Type.IPV4); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Creates an IPv6MappingAddress using the specified value. |
| 75 | * |
| 76 | * @param ip IP address |
| 77 | * @return mapping address |
| 78 | */ |
| 79 | public static IPMappingAddress ipv6MappingAddress(IpPrefix ip) { |
| 80 | return new IPMappingAddress(ip, MappingAddress.Type.IPV6); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Creates an ExtensionMappingAddress using the specified value. |
| 85 | * |
| 86 | * @param selector extension selector |
| 87 | * @param deviceId device identifier |
| 88 | * @return mapping address |
| 89 | */ |
| 90 | public static ExtensionMappingAddress extension(ExtensionSelector selector, |
| 91 | DeviceId deviceId) { |
| 92 | return new ExtensionMappingAddress(selector, deviceId); |
| 93 | } |
| 94 | } |