Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 18 | package org.onosproject.dhcprelay.api; |
| 19 | |
| 20 | import org.onlab.packet.BasePacket; |
| 21 | import org.onlab.packet.IpAddress; |
| 22 | import org.onlab.packet.MacAddress; |
| 23 | import org.onlab.packet.VlanId; |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 24 | import org.onosproject.dhcprelay.config.DhcpServerConfig; |
Yi Tseng | 7da339e | 2017-10-23 19:39:39 -0700 | [diff] [blame] | 25 | import org.onosproject.dhcprelay.config.IgnoreDhcpConfig; |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 26 | import org.onosproject.net.ConnectPoint; |
| 27 | import org.onosproject.net.packet.PacketContext; |
| 28 | |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 29 | import java.util.Collection; |
Yi Tseng | 2fe8f3f | 2017-09-07 16:22:51 -0700 | [diff] [blame] | 30 | import java.util.Collections; |
| 31 | import java.util.List; |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 32 | import java.util.Optional; |
| 33 | |
| 34 | /** |
| 35 | * DHCP relay handler. |
| 36 | */ |
| 37 | public 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 Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 50 | * @deprecated 1.12 get the address from config service |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 51 | */ |
Yi Tseng | 4ec727d | 2017-08-31 11:21:00 -0700 | [diff] [blame] | 52 | @Deprecated |
Yi Tseng | 2fe8f3f | 2017-09-07 16:22:51 -0700 | [diff] [blame] | 53 | default Optional<IpAddress> getDhcpServerIp() { |
| 54 | throw new UnsupportedOperationException("Method deprecated"); |
| 55 | } |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * Gets DHCP gateway IP. |
| 59 | * |
| 60 | * @return IP address of DHCP gateway; empty value if not exist |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 61 | * @deprecated 1.12 get the address from config service |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 62 | */ |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 63 | @Deprecated |
Yi Tseng | 2fe8f3f | 2017-09-07 16:22:51 -0700 | [diff] [blame] | 64 | default Optional<IpAddress> getDhcpGatewayIp() { |
| 65 | throw new UnsupportedOperationException("Method deprecated"); |
| 66 | } |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 67 | |
| 68 | /** |
| 69 | * Gets DHCP connect Mac address. |
| 70 | * |
| 71 | * @return the connect Mac address of server or gateway |
Yi Tseng | 4ec727d | 2017-08-31 11:21:00 -0700 | [diff] [blame] | 72 | * @deprecated 1.12 get host mac from host service |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 73 | */ |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 74 | @Deprecated |
Yi Tseng | 2fe8f3f | 2017-09-07 16:22:51 -0700 | [diff] [blame] | 75 | default Optional<MacAddress> getDhcpConnectMac() { |
| 76 | throw new UnsupportedOperationException("Method deprecated"); |
| 77 | } |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * Sets DHCP gateway IP. |
| 81 | * |
| 82 | * @param dhcpGatewayIp the DHCP gateway IP |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 83 | * @deprecated 1.12 use setDefaultDhcpServerConfigs or setindirectDhcpServerConfigs |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 84 | */ |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 85 | @Deprecated |
Yi Tseng | 2fe8f3f | 2017-09-07 16:22:51 -0700 | [diff] [blame] | 86 | default void setDhcpGatewayIp(IpAddress dhcpGatewayIp) { |
| 87 | throw new UnsupportedOperationException("Method deprecated"); |
| 88 | } |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * Sets DHCP connect vlan. |
| 92 | * |
| 93 | * @param dhcpConnectVlan the DHCP connect vlan |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 94 | * @deprecated 1.12 use setDefaultDhcpServerConfigs or setindirectDhcpServerConfigs |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 95 | */ |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 96 | @Deprecated |
Yi Tseng | 2fe8f3f | 2017-09-07 16:22:51 -0700 | [diff] [blame] | 97 | default void setDhcpConnectVlan(VlanId dhcpConnectVlan) { |
| 98 | throw new UnsupportedOperationException("Method deprecated"); |
| 99 | } |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 100 | |
| 101 | /** |
| 102 | * Sets DHCP connect Mac address. |
| 103 | * |
| 104 | * @param dhcpConnectMac the connect Mac address |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 105 | * @deprecated 1.12 use setDefaultDhcpServerConfigs or setindirectDhcpServerConfigs |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 106 | */ |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 107 | @Deprecated |
Yi Tseng | 2fe8f3f | 2017-09-07 16:22:51 -0700 | [diff] [blame] | 108 | default void setDhcpConnectMac(MacAddress dhcpConnectMac) { |
| 109 | throw new UnsupportedOperationException("Method deprecated"); |
| 110 | } |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * Sets DHCP server connect point. |
| 114 | * |
| 115 | * @param dhcpServerConnectPoint the server connect point |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 116 | * @deprecated 1.12 use setDefaultDhcpServerConfigs or setindirectDhcpServerConfigs |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 117 | */ |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 118 | @Deprecated |
Yi Tseng | 2fe8f3f | 2017-09-07 16:22:51 -0700 | [diff] [blame] | 119 | default void setDhcpServerConnectPoint(ConnectPoint dhcpServerConnectPoint) { |
| 120 | throw new UnsupportedOperationException("Method deprecated"); |
| 121 | } |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 122 | |
| 123 | /** |
| 124 | * Sets DHCP server IP. |
| 125 | * |
| 126 | * @param dhcpServerIp the DHCP server IP |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 127 | * @deprecated 1.12 use setDefaultDhcpServerConfigs or setindirectDhcpServerConfigs |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 128 | */ |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 129 | @Deprecated |
Yi Tseng | 2fe8f3f | 2017-09-07 16:22:51 -0700 | [diff] [blame] | 130 | 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 Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 151 | |
| 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 Tseng | 7da339e | 2017-10-23 19:39:39 -0700 | [diff] [blame] | 165 | |
| 166 | /** |
| 167 | * Push IgnoreDhcpConfig to the handler. |
| 168 | * |
| 169 | * @param config the config |
| 170 | */ |
| 171 | void updateIgnoreVlanConfig(IgnoreDhcpConfig config); |
Saurav Das | ba7eb1a | 2017-12-13 16:19:35 -0800 | [diff] [blame] | 172 | |
| 173 | /** |
| 174 | * Remove internal state for IgnoreDhcp. |
| 175 | * |
| 176 | * @param config the config |
| 177 | */ |
| 178 | void removeIgnoreVlanState(IgnoreDhcpConfig config); |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 179 | } |