blob: 8d8ad78e7ea2819f322534b119f59bb1a0fa4b8a [file] [log] [blame]
Jonathan Hart5af5f142016-01-28 18:45:27 -08001/*
2 * Copyright 2016 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
17package org.onosproject.pim.impl;
18
19import org.onosproject.net.ConnectPoint;
20import org.onosproject.net.config.Config;
21
22import java.util.Optional;
23
24/**
25 * Configuration for a PIM interface.
26 */
27public class PimInterfaceConfig extends Config<ConnectPoint> {
28
29 private static final String INTERFACE_NAME = "interfaceName";
30 private static final String ENABLED = "enabled";
31 private static final String HOLD_TIME = "holdTime";
32 private static final String PRIORITY = "priority";
33 private static final String PROPAGATION_DELAY = "propagationDelay";
34 private static final String OVERRIDE_INTERVAL = "overrideInterval";
35
36 /**
37 * Gets the name of the interface. This links the PIM configuration with
38 * an existing ONOS interface.
39 *
40 * @return interface name
41 */
42 public String getInterfaceName() {
43 return node.path(INTERFACE_NAME).asText();
44 }
45
46 /**
47 * Returns whether PIM is enabled on the interface or not.
48 *
49 * @return true if PIM is enabled, otherwise false
50 */
51 public boolean isEnabled() {
52 return node.path(ENABLED).asBoolean(false);
53 }
54
55 /**
56 * Gets the HELLO hold time of the interface.
57 *
58 * @return hold time
59 */
60 public Optional<Short> getHoldTime() {
61 if (node.path(HOLD_TIME).isMissingNode()) {
62 return Optional.empty();
63 }
64 return Optional.of(Short.parseShort(node.path(HOLD_TIME).asText()));
65 }
66
67 /**
68 * Gets the priority of the interface.
69 *
70 * @return priority
71 */
72 public Optional<Integer> getPriority() {
73 if (node.path(PRIORITY).isMissingNode()) {
74 return Optional.empty();
75 }
76 return Optional.of(node.path(PRIORITY).asInt());
77 }
78
79 /**
80 * Gets the propagation delay of the interface.
81 *
82 * @return propagation delay
83 */
84 public Optional<Short> getPropagationDelay() {
85 if (node.path(PROPAGATION_DELAY).isMissingNode()) {
86 return Optional.empty();
87 }
88 return Optional.of(Short.parseShort(node.path(PROPAGATION_DELAY).asText()));
89 }
90
91 /**
92 * Gets the override interval of the interface.
93 *
94 * @return override interval
95 */
96 public Optional<Short> getOverrideInterval() {
97 if (node.path(OVERRIDE_INTERVAL).isMissingNode()) {
98 return Optional.empty();
99 }
100 return Optional.of(Short.parseShort(node.path(OVERRIDE_INTERVAL).asText()));
101 }
102}