@Override public void handleMessage(Dpid dpid, OFMessage msg) { switch (msg.getType()) { case STATS_REPLY: pushMeterStats(dpid, (OFStatsReply) msg); break; case ERROR: OFErrorMsg error = (OFErrorMsg) msg; if (error.getErrType() == OFErrorType.METER_MOD_FAILED) { MeterOperation op = pendingOperations.getIfPresent(error.getXid()); pendingOperations.invalidate(error.getXid()); if (op == null) { log.warn("Unknown Meter operation failed {}", error); } else { OFMeterModFailedErrorMsg meterError = (OFMeterModFailedErrorMsg) error; signalMeterError(meterError, op); } } break; default: break; } }
private void meterModError(OFMeterMod meterMod, OFMeterModFailedCode code, Channel channel) { OFMeterModFailedErrorMsg errorMsg = FACTORY.errorMsgs() .buildMeterModFailedErrorMsg() .setXid(meterMod.getXid()) .setCode(code) .build(); channel.writeAndFlush(Collections.singletonList(errorMsg)); log.debug("Sent meterMod error {}", code); }
private void signalMeterError(OFMeterModFailedErrorMsg meterError, MeterOperation op) { switch (meterError.getCode()) { case UNKNOWN: providerService.meterOperationFailed(op, MeterFailReason.UNKNOWN_DEVICE); break; case METER_EXISTS: providerService.meterOperationFailed(op, MeterFailReason.EXISTING_METER); break; case INVALID_METER: providerService.meterOperationFailed(op, MeterFailReason.INVALID_METER); break; case UNKNOWN_METER: providerService.meterOperationFailed(op, MeterFailReason.UNKNOWN); break; case BAD_COMMAND: providerService.meterOperationFailed(op, MeterFailReason.UNKNOWN_COMMAND); break; case BAD_FLAGS: providerService.meterOperationFailed(op, MeterFailReason.UNKNOWN_FLAGS); break; case BAD_RATE: providerService.meterOperationFailed(op, MeterFailReason.BAD_RATE); break; case BAD_BURST: providerService.meterOperationFailed(op, MeterFailReason.BAD_BURST); break; case BAD_BAND: providerService.meterOperationFailed(op, MeterFailReason.BAD_BAND); break; case BAD_BAND_VALUE: providerService.meterOperationFailed(op, MeterFailReason.BAD_BAND_VALUE); break; case OUT_OF_METERS: providerService.meterOperationFailed(op, MeterFailReason.OUT_OF_METERS); break; case OUT_OF_BANDS: providerService.meterOperationFailed(op, MeterFailReason.OUT_OF_BANDS); break; default: providerService.meterOperationFailed(op, MeterFailReason.UNKNOWN); } }