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