blob: 948f4e5f962908c9e4a8ae191dd440769837f0dd [file] [log] [blame]
Pingping Linffa27d32015-04-30 14:41:03 -07001/*
2 * Copyright 2015 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.virtualbng;
17
18import com.fasterxml.jackson.annotation.JsonCreator;
19import com.fasterxml.jackson.annotation.JsonProperty;
Pingping Linffa27d32015-04-30 14:41:03 -070020import org.onlab.packet.IpAddress;
21import org.onlab.packet.IpPrefix;
Pingping Linbe126562015-05-06 17:57:10 -070022import org.onlab.packet.MacAddress;
Jonathan Hartbbc352f2015-10-27 19:24:36 -070023import org.onosproject.net.ConnectPoint;
24
25import java.util.Collections;
26import java.util.List;
27import java.util.Map;
28import java.util.stream.Collectors;
Pingping Linffa27d32015-04-30 14:41:03 -070029
30/**
31 * Contains the configuration data for virtual BNG that has been read from a
32 * JSON-formatted configuration file.
33 */
34public final class VbngConfiguration {
35
36 private final List<IpPrefix> localPublicIpPrefixes;
37 private final IpAddress nextHopIpAddress;
Pingping Linbe126562015-05-06 17:57:10 -070038 private final MacAddress publicFacingMac;
Pingping Line10ece02015-06-11 19:26:24 -070039 private final IpAddress xosIpAddress;
40 private final int xosRestPort;
Jonathan Hartbbc352f2015-10-27 19:24:36 -070041 private final Map<String, ConnectPointConfiguration> hosts;
Pingping Linffa27d32015-04-30 14:41:03 -070042
43 /**
44 * Default constructor.
45 */
46 private VbngConfiguration() {
47 localPublicIpPrefixes = null;
48 nextHopIpAddress = null;
Pingping Linbe126562015-05-06 17:57:10 -070049 publicFacingMac = null;
Pingping Line10ece02015-06-11 19:26:24 -070050 xosIpAddress = null;
51 xosRestPort = 0;
Jonathan Hartbbc352f2015-10-27 19:24:36 -070052 hosts = null;
Pingping Linffa27d32015-04-30 14:41:03 -070053 }
54
55 /**
56 * Constructor.
57 *
58 * @param nextHopIpAddress the IP address of the next hop
59 * @param prefixes the public IP prefix list for local SDN network
Pingping Linbe126562015-05-06 17:57:10 -070060 * @param publicFacingMac the MAC address configured for all local
61 * public IP addresses
Pingping Line10ece02015-06-11 19:26:24 -070062 * @param xosIpAddress the XOS server IP address
63 * @param xosRestPort the port of the XOS server for REST
Pingping Linffa27d32015-04-30 14:41:03 -070064 */
65 @JsonCreator
66 public VbngConfiguration(@JsonProperty("localPublicIpPrefixes")
67 List<IpPrefix> prefixes,
68 @JsonProperty("nextHopIpAddress")
Pingping Linbe126562015-05-06 17:57:10 -070069 IpAddress nextHopIpAddress,
70 @JsonProperty("publicFacingMac")
Pingping Line10ece02015-06-11 19:26:24 -070071 MacAddress publicFacingMac,
72 @JsonProperty("xosIpAddress")
73 IpAddress xosIpAddress,
74 @JsonProperty("xosRestPort")
Jonathan Hartbbc352f2015-10-27 19:24:36 -070075 int xosRestPort,
76 @JsonProperty("hosts")
77 Map<String, ConnectPointConfiguration> hosts) {
Pingping Linffa27d32015-04-30 14:41:03 -070078 localPublicIpPrefixes = prefixes;
79 this.nextHopIpAddress = nextHopIpAddress;
Pingping Linbe126562015-05-06 17:57:10 -070080 this.publicFacingMac = publicFacingMac;
Pingping Line10ece02015-06-11 19:26:24 -070081 this.xosIpAddress = xosIpAddress;
82 this.xosRestPort = xosRestPort;
Jonathan Hartbbc352f2015-10-27 19:24:36 -070083 this.hosts = hosts;
Pingping Linffa27d32015-04-30 14:41:03 -070084 }
85
86 /**
87 * Gets a list of public IP prefixes configured for local SDN network.
88 *
89 * @return the list of public IP prefixes
90 */
91 public List<IpPrefix> getLocalPublicIpPrefixes() {
92 return Collections.unmodifiableList(localPublicIpPrefixes);
93 }
94
95 /**
96 * Gets the IP address configured for the next hop (upstream gateway).
97 *
98 * @return the IP address of the next hop
99 */
100 public IpAddress getNextHopIpAddress() {
101 return nextHopIpAddress;
102 }
Pingping Linbe126562015-05-06 17:57:10 -0700103
104 /**
105 * Gets the MAC address configured for all the public IP addresses.
106 *
107 * @return the MAC address
108 */
109 public MacAddress getPublicFacingMac() {
110 return publicFacingMac;
111 }
Pingping Line10ece02015-06-11 19:26:24 -0700112
113 /**
114 * Gets the IP address configured for XOS server.
115 *
116 * @return the IP address configured for the XOS server
117 */
118 public IpAddress getXosIpAddress() {
119 return xosIpAddress;
120 }
121
122 /**
123 * Gets the REST communication port configured for XOS server.
124 *
125 * @return the REST communication port configured for XOS server
126 */
127 public int getXosRestPort() {
128 return xosRestPort;
129 }
Jonathan Hartbbc352f2015-10-27 19:24:36 -0700130
131 public Map<String, ConnectPoint> getHosts() {
132 return hosts.entrySet()
133 .stream()
134 .collect(Collectors.toMap(
135 e -> e.getKey(),
136 e -> e.getValue().connectPoint()
137 ));
138 }
Pingping Linffa27d32015-04-30 14:41:03 -0700139}