blob: 71f773495ba62060389e26dbb656193075ac174d [file] [log] [blame]
Yi Tseng51301292017-07-28 13:02:59 -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 */
17
18package org.onosproject.dhcprelay.api;
19
20import org.onlab.packet.BasePacket;
21import org.onlab.packet.IpAddress;
22import org.onlab.packet.MacAddress;
23import org.onlab.packet.VlanId;
Yi Tsenge72fbb52017-08-02 15:03:31 -070024import org.onosproject.dhcprelay.config.DhcpServerConfig;
Yi Tseng7da339e2017-10-23 19:39:39 -070025import org.onosproject.dhcprelay.config.IgnoreDhcpConfig;
Yi Tseng51301292017-07-28 13:02:59 -070026import org.onosproject.net.ConnectPoint;
27import org.onosproject.net.packet.PacketContext;
28
Yi Tsenge72fbb52017-08-02 15:03:31 -070029import java.util.Collection;
Yi Tseng2fe8f3f2017-09-07 16:22:51 -070030import java.util.Collections;
31import java.util.List;
Yi Tseng51301292017-07-28 13:02:59 -070032import java.util.Optional;
33
34/**
35 * DHCP relay handler.
36 */
37public interface DhcpHandler {
38 /**
39 * Process the DHCP packet before sending to server or client.
40 *
41 * @param context the packet context
42 * @param dhcpPayload the DHCP payload
43 */
44 void processDhcpPacket(PacketContext context, BasePacket dhcpPayload);
45
46 /**
47 * Gets DHCP server IP.
48 *
49 * @return IP address of DHCP server; empty value if not exist
Yi Tsenge72fbb52017-08-02 15:03:31 -070050 * @deprecated 1.12 get the address from config service
Yi Tseng51301292017-07-28 13:02:59 -070051 */
Yi Tseng4ec727d2017-08-31 11:21:00 -070052 @Deprecated
Yi Tseng2fe8f3f2017-09-07 16:22:51 -070053 default Optional<IpAddress> getDhcpServerIp() {
54 throw new UnsupportedOperationException("Method deprecated");
55 }
Yi Tseng51301292017-07-28 13:02:59 -070056
57 /**
58 * Gets DHCP gateway IP.
59 *
60 * @return IP address of DHCP gateway; empty value if not exist
Yi Tsenge72fbb52017-08-02 15:03:31 -070061 * @deprecated 1.12 get the address from config service
Yi Tseng51301292017-07-28 13:02:59 -070062 */
Yi Tsenge72fbb52017-08-02 15:03:31 -070063 @Deprecated
Yi Tseng2fe8f3f2017-09-07 16:22:51 -070064 default Optional<IpAddress> getDhcpGatewayIp() {
65 throw new UnsupportedOperationException("Method deprecated");
66 }
Yi Tseng51301292017-07-28 13:02:59 -070067
68 /**
69 * Gets DHCP connect Mac address.
70 *
71 * @return the connect Mac address of server or gateway
Yi Tseng4ec727d2017-08-31 11:21:00 -070072 * @deprecated 1.12 get host mac from host service
Yi Tseng51301292017-07-28 13:02:59 -070073 */
Yi Tsenge72fbb52017-08-02 15:03:31 -070074 @Deprecated
Yi Tseng2fe8f3f2017-09-07 16:22:51 -070075 default Optional<MacAddress> getDhcpConnectMac() {
76 throw new UnsupportedOperationException("Method deprecated");
77 }
Yi Tseng51301292017-07-28 13:02:59 -070078
79 /**
80 * Sets DHCP gateway IP.
81 *
82 * @param dhcpGatewayIp the DHCP gateway IP
Yi Tsenge72fbb52017-08-02 15:03:31 -070083 * @deprecated 1.12 use setDefaultDhcpServerConfigs or setindirectDhcpServerConfigs
Yi Tseng51301292017-07-28 13:02:59 -070084 */
Yi Tsenge72fbb52017-08-02 15:03:31 -070085 @Deprecated
Yi Tseng2fe8f3f2017-09-07 16:22:51 -070086 default void setDhcpGatewayIp(IpAddress dhcpGatewayIp) {
87 throw new UnsupportedOperationException("Method deprecated");
88 }
Yi Tseng51301292017-07-28 13:02:59 -070089
90 /**
91 * Sets DHCP connect vlan.
92 *
93 * @param dhcpConnectVlan the DHCP connect vlan
Yi Tsenge72fbb52017-08-02 15:03:31 -070094 * @deprecated 1.12 use setDefaultDhcpServerConfigs or setindirectDhcpServerConfigs
Yi Tseng51301292017-07-28 13:02:59 -070095 */
Yi Tsenge72fbb52017-08-02 15:03:31 -070096 @Deprecated
Yi Tseng2fe8f3f2017-09-07 16:22:51 -070097 default void setDhcpConnectVlan(VlanId dhcpConnectVlan) {
98 throw new UnsupportedOperationException("Method deprecated");
99 }
Yi Tseng51301292017-07-28 13:02:59 -0700100
101 /**
102 * Sets DHCP connect Mac address.
103 *
104 * @param dhcpConnectMac the connect Mac address
Yi Tsenge72fbb52017-08-02 15:03:31 -0700105 * @deprecated 1.12 use setDefaultDhcpServerConfigs or setindirectDhcpServerConfigs
Yi Tseng51301292017-07-28 13:02:59 -0700106 */
Yi Tsenge72fbb52017-08-02 15:03:31 -0700107 @Deprecated
Yi Tseng2fe8f3f2017-09-07 16:22:51 -0700108 default void setDhcpConnectMac(MacAddress dhcpConnectMac) {
109 throw new UnsupportedOperationException("Method deprecated");
110 }
Yi Tseng51301292017-07-28 13:02:59 -0700111
112 /**
113 * Sets DHCP server connect point.
114 *
115 * @param dhcpServerConnectPoint the server connect point
Yi Tsenge72fbb52017-08-02 15:03:31 -0700116 * @deprecated 1.12 use setDefaultDhcpServerConfigs or setindirectDhcpServerConfigs
Yi Tseng51301292017-07-28 13:02:59 -0700117 */
Yi Tsenge72fbb52017-08-02 15:03:31 -0700118 @Deprecated
Yi Tseng2fe8f3f2017-09-07 16:22:51 -0700119 default void setDhcpServerConnectPoint(ConnectPoint dhcpServerConnectPoint) {
120 throw new UnsupportedOperationException("Method deprecated");
121 }
Yi Tseng51301292017-07-28 13:02:59 -0700122
123 /**
124 * Sets DHCP server IP.
125 *
126 * @param dhcpServerIp the DHCP server IP
Yi Tsenge72fbb52017-08-02 15:03:31 -0700127 * @deprecated 1.12 use setDefaultDhcpServerConfigs or setindirectDhcpServerConfigs
Yi Tseng51301292017-07-28 13:02:59 -0700128 */
Yi Tsenge72fbb52017-08-02 15:03:31 -0700129 @Deprecated
Yi Tseng2fe8f3f2017-09-07 16:22:51 -0700130 default void setDhcpServerIp(IpAddress dhcpServerIp) {
131 throw new UnsupportedOperationException("Method deprecated");
132 }
133
134 /**
135 * Gets list of default DHCP server information.
136 *
137 * @return list of default DHCP server information
138 */
139 default List<DhcpServerInfo> getDefaultDhcpServerInfoList() {
140 return Collections.emptyList();
141 }
142
143 /**
144 * Gets list of indirect DHCP server information.
145 *
146 * @return list of indirect DHCP server information
147 */
148 default List<DhcpServerInfo> getIndirectDhcpServerInfoList() {
149 return Collections.emptyList();
150 }
Yi Tsenge72fbb52017-08-02 15:03:31 -0700151
152 /**
153 * Sets DHCP server config for default case.
154 *
155 * @param configs the config
156 */
157 void setDefaultDhcpServerConfigs(Collection<DhcpServerConfig> configs);
158
159 /**
160 * Sets DHCP server config for indirect case.
161 *
162 * @param configs the config
163 */
164 void setIndirectDhcpServerConfigs(Collection<DhcpServerConfig> configs);
Yi Tseng7da339e2017-10-23 19:39:39 -0700165
166 /**
167 * Push IgnoreDhcpConfig to the handler.
168 *
169 * @param config the config
170 */
171 void updateIgnoreVlanConfig(IgnoreDhcpConfig config);
Saurav Dasba7eb1a2017-12-13 16:19:35 -0800172
173 /**
174 * Remove internal state for IgnoreDhcp.
175 *
176 * @param config the config
177 */
178 void removeIgnoreVlanState(IgnoreDhcpConfig config);
Yi Tseng51301292017-07-28 13:02:59 -0700179}