Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame^] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
Jonathan Hart | 2da1e60 | 2015-02-18 19:09:24 -0800 | [diff] [blame] | 16 | package org.onosproject.routing.config.impl; |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 17 | |
| 18 | import com.fasterxml.jackson.annotation.JsonProperty; |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 19 | |
Pingping Lin | c9e16bf | 2015-04-10 14:42:41 -0700 | [diff] [blame] | 20 | import org.onlab.packet.MacAddress; |
Jonathan Hart | 2da1e60 | 2015-02-18 19:09:24 -0800 | [diff] [blame] | 21 | import org.onosproject.routing.config.BgpPeer; |
| 22 | import org.onosproject.routing.config.BgpSpeaker; |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 23 | import org.onosproject.routing.config.LocalIpPrefixEntry; |
Jonathan Hart | bac07a0 | 2014-10-13 21:29:54 -0700 | [diff] [blame] | 24 | |
| 25 | import java.util.Collections; |
| 26 | import java.util.List; |
| 27 | |
Jonathan Hart | bac07a0 | 2014-10-13 21:29:54 -0700 | [diff] [blame] | 28 | /** |
| 29 | * Contains the configuration data for SDN-IP that has been read from a |
| 30 | * JSON-formatted configuration file. |
| 31 | */ |
| 32 | public class Configuration { |
| 33 | // We call the BGP routers in our SDN network the BGP speakers, and call |
| 34 | // the BGP routers outside our SDN network the BGP peers. |
| 35 | private List<BgpSpeaker> bgpSpeakers; |
| 36 | private List<BgpPeer> peers; |
Pingping Lin | c9e16bf | 2015-04-10 14:42:41 -0700 | [diff] [blame] | 37 | private MacAddress virtualGatewayMacAddress; |
Jonathan Hart | bac07a0 | 2014-10-13 21:29:54 -0700 | [diff] [blame] | 38 | |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 39 | // All IP prefixes from the configuration are local |
| 40 | private List<LocalIpPrefixEntry> localIp4PrefixEntries = |
| 41 | Collections.emptyList(); |
| 42 | private List<LocalIpPrefixEntry> localIp6PrefixEntries = |
| 43 | Collections.emptyList(); |
| 44 | |
Jonathan Hart | bac07a0 | 2014-10-13 21:29:54 -0700 | [diff] [blame] | 45 | /** |
| 46 | * Default constructor. |
| 47 | */ |
| 48 | public Configuration() { |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Gets a list of bgpSpeakers in the system, represented by |
| 53 | * {@link BgpSpeaker} objects. |
| 54 | * |
| 55 | * @return the list of BGP speakers |
| 56 | */ |
| 57 | public List<BgpSpeaker> getBgpSpeakers() { |
| 58 | return Collections.unmodifiableList(bgpSpeakers); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Sets a list of bgpSpeakers in the system. |
| 63 | * |
| 64 | * @param bgpSpeakers the list of BGP speakers |
| 65 | */ |
| 66 | @JsonProperty("bgpSpeakers") |
| 67 | public void setBgpSpeakers(List<BgpSpeaker> bgpSpeakers) { |
| 68 | this.bgpSpeakers = bgpSpeakers; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Gets a list of BGP peers we are configured to peer with. Peers are |
| 73 | * represented by {@link BgpPeer} objects. |
| 74 | * |
| 75 | * @return the list of BGP peers |
| 76 | */ |
| 77 | public List<BgpPeer> getPeers() { |
| 78 | return Collections.unmodifiableList(peers); |
| 79 | } |
| 80 | |
| 81 | /** |
Pingping Lin | c9e16bf | 2015-04-10 14:42:41 -0700 | [diff] [blame] | 82 | * Sets a list of BGP peers we configured to peer with. |
Jonathan Hart | bac07a0 | 2014-10-13 21:29:54 -0700 | [diff] [blame] | 83 | * |
| 84 | * @param peers the list of BGP peers |
| 85 | */ |
| 86 | @JsonProperty("bgpPeers") |
| 87 | public void setPeers(List<BgpPeer> peers) { |
| 88 | this.peers = peers; |
| 89 | } |
| 90 | |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 91 | /** |
Pingping Lin | c9e16bf | 2015-04-10 14:42:41 -0700 | [diff] [blame] | 92 | * Gets the MAC address we configured for virtual gateway |
| 93 | * in SDN network. |
| 94 | * |
| 95 | * @return the MAC address of virtual gateway |
| 96 | */ |
| 97 | public MacAddress getVirtualGatewayMacAddress() { |
| 98 | return virtualGatewayMacAddress; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Sets the MAC address for virtual gateway in SDN network. |
| 103 | * |
| 104 | * @param virtualGatewayMacAddress the MAC address of virtual gateway |
| 105 | */ |
| 106 | @JsonProperty("virtualGatewayMacAddress") |
| 107 | public void setVirtualGatewayMacAddress(MacAddress virtualGatewayMacAddress) { |
| 108 | this.virtualGatewayMacAddress = virtualGatewayMacAddress; |
| 109 | } |
| 110 | |
| 111 | /** |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 112 | * Gets a list of local IPv4 prefix entries configured for local |
| 113 | * SDN network. |
| 114 | * <p> |
| 115 | * IP prefix entries are represented by {@link LocalIpPrefixEntry} |
| 116 | * objects. |
| 117 | * </p> |
| 118 | * |
| 119 | * @return the list of local IPv4 prefix entries |
| 120 | */ |
| 121 | public List<LocalIpPrefixEntry> getLocalIp4PrefixEntries() { |
| 122 | return Collections.unmodifiableList(localIp4PrefixEntries); |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Sets a list of IPv4 prefix entries configured for local SDN network. |
| 127 | * |
| 128 | * @param ip4PrefixEntries the list of Ipv4 prefix entries |
| 129 | */ |
| 130 | @JsonProperty("ip4LocalPrefixes") |
| 131 | public void setLocalIp4PrefixEntries(List<LocalIpPrefixEntry> ip4PrefixEntries) { |
| 132 | this.localIp4PrefixEntries = ip4PrefixEntries; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Gets a list of IPv6 prefix entries configured for local SDN network. |
| 137 | * <p> |
| 138 | * IP prefix entries are represented by {@link LocalIpPrefixEntry} |
| 139 | * objects. |
| 140 | * </p> |
| 141 | * |
| 142 | * @return the list of IPv6 prefix entries |
| 143 | */ |
| 144 | public List<LocalIpPrefixEntry> getLocalIp6PrefixEntries() { |
| 145 | return Collections.unmodifiableList(localIp6PrefixEntries); |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Sets a list of IPv6 prefix entries configured for local SDN network. |
| 150 | * |
| 151 | * @param ip6PrefixEntries the list of Ipv6 prefix entries |
| 152 | */ |
| 153 | @JsonProperty("ip6LocalPrefixes") |
| 154 | public void setLocalIp6PrefixEntries(List<LocalIpPrefixEntry> ip6PrefixEntries) { |
| 155 | this.localIp6PrefixEntries = ip6PrefixEntries; |
| 156 | } |
| 157 | |
Jonathan Hart | bac07a0 | 2014-10-13 21:29:54 -0700 | [diff] [blame] | 158 | } |