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