blob: 77eeed2b5907655a0e22e7622d36a441fefcb986 [file] [log] [blame]
Charles Chan6c624992017-08-18 17:11:34 -07001/*
2 * Copyright 2017-present Open Networking Foundation
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
17package org.onosproject.segmentrouting;
18
19import org.onlab.packet.IpPrefix;
20import org.onlab.packet.MacAddress;
21import org.onlab.packet.VlanId;
22import org.onosproject.net.DeviceId;
23import org.onosproject.net.PortNumber;
24
25import java.util.Map;
26
27/**
28 * Mock Routing Rule Populator.
29 */
30public class MockRoutingRulePopulator extends RoutingRulePopulator {
31 private Map<MockRoutingTableKey, MockRoutingTableValue> routingTable;
32
33 MockRoutingRulePopulator(SegmentRoutingManager srManager,
34 Map<MockRoutingTableKey, MockRoutingTableValue> routingTable) {
35 super(srManager);
36 this.routingTable = routingTable;
37 }
38
39 @Override
40 public void populateRoute(DeviceId deviceId, IpPrefix prefix,
Ruchi Sahota71bcb4e2019-01-28 01:08:18 +000041 MacAddress hostMac, VlanId hostVlanId, PortNumber outPort, boolean directHost) {
Charles Chan6c624992017-08-18 17:11:34 -070042 MockRoutingTableKey rtKey = new MockRoutingTableKey(deviceId, prefix);
43 MockRoutingTableValue rtValue = new MockRoutingTableValue(outPort, hostMac, hostVlanId);
44 routingTable.put(rtKey, rtValue);
45 }
46
47 @Override
48 public void revokeRoute(DeviceId deviceId, IpPrefix prefix,
Ruchi Sahota71bcb4e2019-01-28 01:08:18 +000049 MacAddress hostMac, VlanId hostVlanId, PortNumber outPort, boolean directHost) {
Charles Chan6c624992017-08-18 17:11:34 -070050 MockRoutingTableKey rtKey = new MockRoutingTableKey(deviceId, prefix);
51 MockRoutingTableValue rtValue = new MockRoutingTableValue(outPort, hostMac, hostVlanId);
52 routingTable.remove(rtKey, rtValue);
53 }
Ruchi Sahota71bcb4e2019-01-28 01:08:18 +000054}