blob: 1024f14ded668c4e2c1d3617eb75cd326e3d9f19 [file] [log] [blame]
Jian Li0e09eaa2017-02-14 02:01:18 +09001/*
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 */
16package org.onosproject.mapping.addresses;
17
18import org.onlab.packet.IpPrefix;
19import org.onlab.packet.MacAddress;
Jian Li0f0d7482017-03-20 15:16:13 +090020import org.onosproject.net.DeviceId;
Jian Li0e09eaa2017-02-14 02:01:18 +090021
22/**
23 * Factory class for creating various mapping addresses.
24 */
25public 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 Li0f0d7482017-03-20 15:16:13 +090081
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 Lifc90a082017-03-31 23:36:14 +090093
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 Li0e09eaa2017-02-14 02:01:18 +0900104}