Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 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 | package com.android.server.hdmi; |
| 18 | |
Jungshik Jang | 61f4fbd | 2014-08-06 19:21:12 +0900 | [diff] [blame] | 19 | import android.hardware.hdmi.HdmiDeviceInfo; |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 20 | import android.util.SparseArray; |
| 21 | |
| 22 | /** |
| 23 | * A helper class to validates {@link HdmiCecMessage}. |
| 24 | */ |
| 25 | public final class HdmiCecMessageValidator { |
| 26 | private static final String TAG = "HdmiCecMessageValidator"; |
| 27 | |
Yuncheol Heo | 4c21289 | 2014-09-12 14:32:46 +0900 | [diff] [blame^] | 28 | static final int OK = 0; |
| 29 | static final int ERROR_SOURCE = 1; |
| 30 | static final int ERROR_DESTINATION = 2; |
| 31 | static final int ERROR_PARAMETER = 3; |
| 32 | |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 33 | private final HdmiControlService mService; |
| 34 | |
| 35 | interface ParameterValidator { |
| 36 | boolean isValid(byte[] params); |
| 37 | } |
| 38 | |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 39 | // Only the direct addressing is allowed. |
| 40 | private static final int DEST_DIRECT = 1 << 0; |
| 41 | // Only the broadcast addressing is allowed. |
| 42 | private static final int DEST_BROADCAST = 1 << 1; |
| 43 | // Both the direct and the broadcast addressing are allowed. |
| 44 | private static final int DEST_ALL = DEST_DIRECT | DEST_BROADCAST; |
| 45 | // True if the messages from address 15 (unregistered) are allowed. |
| 46 | private static final int SRC_UNREGISTERED = 1 << 2; |
| 47 | |
| 48 | private static class ValidationInfo { |
| 49 | public final ParameterValidator parameterValidator; |
| 50 | public final int addressType; |
| 51 | |
| 52 | public ValidationInfo(ParameterValidator validator, int type) { |
| 53 | parameterValidator = validator; |
| 54 | addressType = type; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | final SparseArray<ValidationInfo> mValidationInfo = new SparseArray<>(); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 59 | |
| 60 | public HdmiCecMessageValidator(HdmiControlService service) { |
| 61 | mService = service; |
| 62 | |
| 63 | // Messages related to the physical address. |
| 64 | PhysicalAddressValidator physicalAddressValidator = new PhysicalAddressValidator(); |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 65 | addValidationInfo(Constants.MESSAGE_ACTIVE_SOURCE, |
| 66 | physicalAddressValidator, DEST_BROADCAST | SRC_UNREGISTERED); |
| 67 | addValidationInfo(Constants.MESSAGE_INACTIVE_SOURCE, physicalAddressValidator, DEST_DIRECT); |
| 68 | addValidationInfo(Constants.MESSAGE_REPORT_PHYSICAL_ADDRESS, |
| 69 | new ReportPhysicalAddressValidator(), DEST_BROADCAST | SRC_UNREGISTERED); |
| 70 | addValidationInfo(Constants.MESSAGE_ROUTING_CHANGE, |
| 71 | new RoutingChangeValidator(), DEST_BROADCAST | SRC_UNREGISTERED); |
| 72 | addValidationInfo(Constants.MESSAGE_ROUTING_INFORMATION, |
| 73 | physicalAddressValidator, DEST_BROADCAST | SRC_UNREGISTERED); |
| 74 | addValidationInfo(Constants.MESSAGE_SET_STREAM_PATH, |
| 75 | physicalAddressValidator, DEST_BROADCAST); |
| 76 | addValidationInfo(Constants.MESSAGE_SYSTEM_AUDIO_MODE_REQUEST, |
| 77 | physicalAddressValidator, DEST_DIRECT); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 78 | |
| 79 | // Messages have no parameter. |
| 80 | FixedLengthValidator noneValidator = new FixedLengthValidator(0); |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 81 | addValidationInfo(Constants.MESSAGE_ABORT, noneValidator, DEST_DIRECT); |
| 82 | addValidationInfo(Constants.MESSAGE_GET_CEC_VERSION, noneValidator, DEST_DIRECT); |
| 83 | addValidationInfo(Constants.MESSAGE_GET_MENU_LANGUAGE, |
| 84 | noneValidator, DEST_DIRECT | SRC_UNREGISTERED); |
| 85 | addValidationInfo(Constants.MESSAGE_GIVE_AUDIO_STATUS, noneValidator, DEST_DIRECT); |
| 86 | addValidationInfo(Constants.MESSAGE_GIVE_DEVICE_POWER_STATUS, noneValidator, DEST_DIRECT); |
| 87 | addValidationInfo(Constants.MESSAGE_GIVE_DEVICE_VENDOR_ID, |
| 88 | noneValidator, DEST_DIRECT | SRC_UNREGISTERED); |
| 89 | addValidationInfo(Constants.MESSAGE_GIVE_OSD_NAME, noneValidator, DEST_DIRECT); |
| 90 | addValidationInfo(Constants.MESSAGE_GIVE_PHYSICAL_ADDRESS, |
| 91 | noneValidator, DEST_DIRECT | SRC_UNREGISTERED); |
| 92 | addValidationInfo(Constants.MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS, |
| 93 | noneValidator, DEST_DIRECT); |
| 94 | addValidationInfo(Constants.MESSAGE_IMAGE_VIEW_ON, noneValidator, DEST_DIRECT); |
| 95 | addValidationInfo(Constants.MESSAGE_INITIATE_ARC, noneValidator, DEST_DIRECT); |
| 96 | addValidationInfo(Constants.MESSAGE_RECORD_OFF, noneValidator, DEST_DIRECT); |
| 97 | addValidationInfo(Constants.MESSAGE_RECORD_TV_SCREEN, noneValidator, DEST_DIRECT); |
| 98 | addValidationInfo(Constants.MESSAGE_REPORT_ARC_INITIATED, noneValidator, DEST_DIRECT); |
| 99 | addValidationInfo(Constants.MESSAGE_REPORT_ARC_TERMINATED, noneValidator, DEST_DIRECT); |
| 100 | addValidationInfo(Constants.MESSAGE_REQUEST_ARC_INITIATION, noneValidator, DEST_DIRECT); |
| 101 | addValidationInfo(Constants.MESSAGE_REQUEST_ARC_TERMINATION, noneValidator, DEST_DIRECT); |
| 102 | addValidationInfo(Constants.MESSAGE_REQUEST_ACTIVE_SOURCE, |
| 103 | noneValidator, DEST_BROADCAST | SRC_UNREGISTERED); |
| 104 | addValidationInfo(Constants.MESSAGE_STANDBY, noneValidator, DEST_ALL | SRC_UNREGISTERED); |
| 105 | addValidationInfo(Constants.MESSAGE_TERMINATE_ARC, noneValidator, DEST_DIRECT); |
| 106 | addValidationInfo(Constants.MESSAGE_TEXT_VIEW_ON, noneValidator, DEST_DIRECT); |
| 107 | addValidationInfo(Constants.MESSAGE_TUNER_STEP_DECREMENT, noneValidator, DEST_DIRECT); |
| 108 | addValidationInfo(Constants.MESSAGE_TUNER_STEP_INCREMENT, noneValidator, DEST_DIRECT); |
| 109 | addValidationInfo(Constants.MESSAGE_USER_CONTROL_RELEASED, noneValidator, DEST_DIRECT); |
| 110 | addValidationInfo(Constants.MESSAGE_VENDOR_REMOTE_BUTTON_UP, noneValidator, DEST_ALL); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 111 | |
| 112 | // TODO: Validate more than length for the following messages. |
| 113 | |
| 114 | // Messages for the One Touch Record. |
| 115 | FixedLengthValidator oneByteValidator = new FixedLengthValidator(1); |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 116 | addValidationInfo(Constants.MESSAGE_RECORD_ON, |
| 117 | new VariableLengthValidator(1, 8), DEST_DIRECT); |
| 118 | addValidationInfo(Constants.MESSAGE_RECORD_STATUS, oneByteValidator, DEST_DIRECT); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 119 | |
| 120 | // TODO: Handle messages for the Timer Programming. |
| 121 | |
| 122 | // Messages for the System Information. |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 123 | addValidationInfo(Constants.MESSAGE_CEC_VERSION, oneByteValidator, DEST_DIRECT); |
| 124 | addValidationInfo(Constants.MESSAGE_SET_MENU_LANGUAGE, |
| 125 | new FixedLengthValidator(3), DEST_BROADCAST); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 126 | |
| 127 | // TODO: Handle messages for the Deck Control. |
| 128 | |
| 129 | // TODO: Handle messages for the Tuner Control. |
| 130 | |
| 131 | // Messages for the Vendor Specific Commands. |
| 132 | VariableLengthValidator maxLengthValidator = new VariableLengthValidator(0, 14); |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 133 | addValidationInfo(Constants.MESSAGE_DEVICE_VENDOR_ID, |
| 134 | new FixedLengthValidator(3), DEST_BROADCAST); |
| 135 | // Allow unregistered source for all vendor specific commands, because we don't know |
| 136 | // how to use the commands at this moment. |
| 137 | addValidationInfo(Constants.MESSAGE_VENDOR_COMMAND, |
| 138 | maxLengthValidator, DEST_DIRECT | SRC_UNREGISTERED); |
| 139 | addValidationInfo(Constants.MESSAGE_VENDOR_COMMAND_WITH_ID, |
| 140 | maxLengthValidator, DEST_ALL | SRC_UNREGISTERED); |
| 141 | addValidationInfo(Constants.MESSAGE_VENDOR_REMOTE_BUTTON_DOWN, |
| 142 | maxLengthValidator, DEST_ALL | SRC_UNREGISTERED); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 143 | |
| 144 | // Messages for the OSD. |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 145 | addValidationInfo(Constants.MESSAGE_SET_OSD_STRING, maxLengthValidator, DEST_DIRECT); |
| 146 | addValidationInfo(Constants.MESSAGE_SET_OSD_NAME, maxLengthValidator, DEST_DIRECT); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 147 | |
| 148 | // TODO: Handle messages for the Device Menu Control. |
| 149 | |
| 150 | // Messages for the Remote Control Passthrough. |
| 151 | // TODO: Parse the first parameter and determine if it can have the next parameter. |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 152 | addValidationInfo(Constants.MESSAGE_USER_CONTROL_PRESSED, |
| 153 | new VariableLengthValidator(1, 2), DEST_DIRECT); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 154 | |
| 155 | // Messages for the Power Status. |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 156 | addValidationInfo(Constants.MESSAGE_REPORT_POWER_STATUS, oneByteValidator, DEST_DIRECT); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 157 | |
| 158 | // Messages for the General Protocol. |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 159 | addValidationInfo(Constants.MESSAGE_FEATURE_ABORT, |
| 160 | new FixedLengthValidator(2), DEST_DIRECT); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 161 | |
| 162 | // Messages for the System Audio Control. |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 163 | addValidationInfo(Constants.MESSAGE_REPORT_AUDIO_STATUS, oneByteValidator, DEST_DIRECT); |
| 164 | addValidationInfo(Constants.MESSAGE_REPORT_SHORT_AUDIO_DESCRIPTOR, |
| 165 | new FixedLengthValidator(3), DEST_DIRECT); |
| 166 | addValidationInfo(Constants.MESSAGE_REQUEST_SHORT_AUDIO_DESCRIPTOR, |
| 167 | oneByteValidator, DEST_DIRECT); |
| 168 | addValidationInfo(Constants.MESSAGE_SET_SYSTEM_AUDIO_MODE, oneByteValidator, DEST_ALL); |
| 169 | addValidationInfo(Constants.MESSAGE_SYSTEM_AUDIO_MODE_STATUS, |
| 170 | oneByteValidator, DEST_DIRECT); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 171 | |
| 172 | // Messages for the Audio Rate Control. |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 173 | addValidationInfo(Constants.MESSAGE_SET_AUDIO_RATE, oneByteValidator, DEST_DIRECT); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 174 | |
| 175 | // All Messages for the ARC have no parameters. |
| 176 | |
| 177 | // Messages for the Capability Discovery and Control. |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 178 | addValidationInfo(Constants.MESSAGE_CDC_MESSAGE, maxLengthValidator, |
| 179 | DEST_BROADCAST | SRC_UNREGISTERED); |
| 180 | } |
| 181 | |
| 182 | private void addValidationInfo(int opcode, ParameterValidator validator, int addrType) { |
| 183 | mValidationInfo.append(opcode, new ValidationInfo(validator, addrType)); |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 184 | } |
| 185 | |
Yuncheol Heo | 4c21289 | 2014-09-12 14:32:46 +0900 | [diff] [blame^] | 186 | int isValid(HdmiCecMessage message) { |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 187 | int opcode = message.getOpcode(); |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 188 | ValidationInfo info = mValidationInfo.get(opcode); |
| 189 | if (info == null) { |
Jungshik Jang | 2e8f1b6 | 2014-09-03 08:28:02 +0900 | [diff] [blame] | 190 | HdmiLogger.warning("No validation information for the message: " + message); |
Yuncheol Heo | 4c21289 | 2014-09-12 14:32:46 +0900 | [diff] [blame^] | 191 | return OK; |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 192 | } |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 193 | |
| 194 | // Check the source field. |
| 195 | if (message.getSource() == Constants.ADDR_UNREGISTERED && |
| 196 | (info.addressType & SRC_UNREGISTERED) == 0) { |
Jungshik Jang | 2e8f1b6 | 2014-09-03 08:28:02 +0900 | [diff] [blame] | 197 | HdmiLogger.warning("Unexpected source: " + message); |
Yuncheol Heo | 4c21289 | 2014-09-12 14:32:46 +0900 | [diff] [blame^] | 198 | return ERROR_SOURCE; |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 199 | } |
| 200 | // Check the destination field. |
| 201 | if (message.getDestination() == Constants.ADDR_BROADCAST) { |
| 202 | if ((info.addressType & DEST_BROADCAST) == 0) { |
Jungshik Jang | 2e8f1b6 | 2014-09-03 08:28:02 +0900 | [diff] [blame] | 203 | HdmiLogger.warning("Unexpected broadcast message: " + message); |
Yuncheol Heo | 4c21289 | 2014-09-12 14:32:46 +0900 | [diff] [blame^] | 204 | return ERROR_DESTINATION; |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 205 | } |
| 206 | } else { // Direct addressing. |
| 207 | if ((info.addressType & DEST_DIRECT) == 0) { |
Jungshik Jang | 2e8f1b6 | 2014-09-03 08:28:02 +0900 | [diff] [blame] | 208 | HdmiLogger.warning("Unexpected direct message: " + message); |
Yuncheol Heo | 4c21289 | 2014-09-12 14:32:46 +0900 | [diff] [blame^] | 209 | return ERROR_DESTINATION; |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 210 | } |
| 211 | } |
| 212 | |
| 213 | // Check the parameter type. |
| 214 | if (!info.parameterValidator.isValid(message.getParams())) { |
Jungshik Jang | 2e8f1b6 | 2014-09-03 08:28:02 +0900 | [diff] [blame] | 215 | HdmiLogger.warning("Unexpected parameters: " + message); |
Yuncheol Heo | 4c21289 | 2014-09-12 14:32:46 +0900 | [diff] [blame^] | 216 | return ERROR_PARAMETER; |
Yuncheol Heo | e9b9b1e | 2014-07-10 18:52:28 +0900 | [diff] [blame] | 217 | } |
Yuncheol Heo | 4c21289 | 2014-09-12 14:32:46 +0900 | [diff] [blame^] | 218 | return OK; |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | private static class FixedLengthValidator implements ParameterValidator { |
| 222 | private final int mLength; |
| 223 | |
| 224 | public FixedLengthValidator(int length) { |
| 225 | mLength = length; |
| 226 | } |
| 227 | |
| 228 | @Override |
| 229 | public boolean isValid(byte[] params) { |
| 230 | return params.length == mLength; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | private static class VariableLengthValidator implements ParameterValidator { |
| 235 | private final int mMinLength; |
| 236 | private final int mMaxLength; |
| 237 | |
| 238 | public VariableLengthValidator(int minLength, int maxLength) { |
| 239 | mMinLength = minLength; |
| 240 | mMaxLength = maxLength; |
| 241 | } |
| 242 | |
| 243 | @Override |
| 244 | public boolean isValid(byte[] params) { |
| 245 | return params.length >= mMinLength && params.length <= mMaxLength; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | private boolean isValidPhysicalAddress(byte[] params, int offset) { |
Yuncheol Heo | e946ed8 | 2014-07-25 14:05:19 +0900 | [diff] [blame] | 250 | // TODO: Add more logic like validating 1.0.1.0. |
| 251 | |
| 252 | if (!mService.isTvDevice()) { |
| 253 | // If the device is not TV, we can't convert path to port-id, so stop here. |
| 254 | return true; |
| 255 | } |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 256 | int path = HdmiUtils.twoBytesToInt(params, offset); |
Yuncheol Heo | 7dea98f | 2014-08-07 17:58:59 +0900 | [diff] [blame] | 257 | if (path != Constants.INVALID_PHYSICAL_ADDRESS && path == mService.getPhysicalAddress()) { |
| 258 | return true; |
| 259 | } |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 260 | int portId = mService.pathToPortId(path); |
| 261 | if (portId == Constants.INVALID_PORT_ID) { |
| 262 | return false; |
| 263 | } |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 264 | return true; |
| 265 | } |
| 266 | |
| 267 | /** |
Jungshik Jang | 8e93c84 | 2014-08-06 15:48:33 +0900 | [diff] [blame] | 268 | * Check if the given type is valid. A valid type is one of the actual logical device types |
Yuncheol Heo | 7dea98f | 2014-08-07 17:58:59 +0900 | [diff] [blame] | 269 | * defined in the standard ({@link HdmiDeviceInfo#DEVICE_TV}, |
| 270 | * {@link HdmiDeviceInfo#DEVICE_PLAYBACK}, {@link HdmiDeviceInfo#DEVICE_TUNER}, |
| 271 | * {@link HdmiDeviceInfo#DEVICE_RECORDER}, and |
| 272 | * {@link HdmiDeviceInfo#DEVICE_AUDIO_SYSTEM}). |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 273 | * |
| 274 | * @param type device type |
| 275 | * @return true if the given type is valid |
| 276 | */ |
| 277 | static boolean isValidType(int type) { |
Jungshik Jang | 61f4fbd | 2014-08-06 19:21:12 +0900 | [diff] [blame] | 278 | return (HdmiDeviceInfo.DEVICE_TV <= type |
| 279 | && type <= HdmiDeviceInfo.DEVICE_VIDEO_PROCESSOR) |
| 280 | && type != HdmiDeviceInfo.DEVICE_RESERVED; |
Yuncheol Heo | 75a77e7 | 2014-07-09 18:27:53 +0900 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | private class PhysicalAddressValidator implements ParameterValidator { |
| 284 | @Override |
| 285 | public boolean isValid(byte[] params) { |
| 286 | if (params.length != 2) { |
| 287 | return false; |
| 288 | } |
| 289 | return isValidPhysicalAddress(params, 0); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | private class ReportPhysicalAddressValidator implements ParameterValidator { |
| 294 | @Override |
| 295 | public boolean isValid(byte[] params) { |
| 296 | if (params.length != 3) { |
| 297 | return false; |
| 298 | } |
| 299 | return isValidPhysicalAddress(params, 0) && isValidType(params[2]); |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | private class RoutingChangeValidator implements ParameterValidator { |
| 304 | @Override |
| 305 | public boolean isValid(byte[] params) { |
| 306 | if (params.length != 4) { |
| 307 | return false; |
| 308 | } |
| 309 | return isValidPhysicalAddress(params, 0) && isValidPhysicalAddress(params, 2); |
| 310 | } |
| 311 | } |
| 312 | } |