public static OFMeterModFailedCode readFrom(ChannelBuffer bb) throws OFParseError { try { return ofWireValue(bb.readShort()); } catch (IllegalArgumentException e) { throw new OFParseError(e); } }
public static OFMeterModFailedCode ofWireValue(short val) { switch(val) { case UNKNOWN_VAL: return OFMeterModFailedCode.UNKNOWN; case METER_EXISTS_VAL: return OFMeterModFailedCode.METER_EXISTS; case INVALID_METER_VAL: return OFMeterModFailedCode.INVALID_METER; case UNKNOWN_METER_VAL: return OFMeterModFailedCode.UNKNOWN_METER; case BAD_COMMAND_VAL: return OFMeterModFailedCode.BAD_COMMAND; case BAD_FLAGS_VAL: return OFMeterModFailedCode.BAD_FLAGS; case BAD_RATE_VAL: return OFMeterModFailedCode.BAD_RATE; case BAD_BURST_VAL: return OFMeterModFailedCode.BAD_BURST; case BAD_BAND_VAL: return OFMeterModFailedCode.BAD_BAND; case BAD_BAND_VALUE_VAL: return OFMeterModFailedCode.BAD_BAND_VALUE; case OUT_OF_METERS_VAL: return OFMeterModFailedCode.OUT_OF_METERS; case OUT_OF_BANDS_VAL: return OFMeterModFailedCode.OUT_OF_BANDS; default: throw new IllegalArgumentException("Illegal wire value for type OFMeterModFailedCode in version 1.3: " + val); } }
public static short toWireValue(OFMeterModFailedCode e) { switch(e) { case UNKNOWN: return UNKNOWN_VAL; case METER_EXISTS: return METER_EXISTS_VAL; case INVALID_METER: return INVALID_METER_VAL; case UNKNOWN_METER: return UNKNOWN_METER_VAL; case BAD_COMMAND: return BAD_COMMAND_VAL; case BAD_FLAGS: return BAD_FLAGS_VAL; case BAD_RATE: return BAD_RATE_VAL; case BAD_BURST: return BAD_BURST_VAL; case BAD_BAND: return BAD_BAND_VAL; case BAD_BAND_VALUE: return BAD_BAND_VALUE_VAL; case OUT_OF_METERS: return OUT_OF_METERS_VAL; case OUT_OF_BANDS: return OUT_OF_BANDS_VAL; default: throw new IllegalArgumentException("Illegal enum value for type OFMeterModFailedCode in version 1.3: " + e); } }
public static OFMeterModFailedCode ofWireValue(short val) { switch(val) { case UNKNOWN_VAL: return OFMeterModFailedCode.UNKNOWN; case METER_EXISTS_VAL: return OFMeterModFailedCode.METER_EXISTS; case INVALID_METER_VAL: return OFMeterModFailedCode.INVALID_METER; case UNKNOWN_METER_VAL: return OFMeterModFailedCode.UNKNOWN_METER; case BAD_COMMAND_VAL: return OFMeterModFailedCode.BAD_COMMAND; case BAD_FLAGS_VAL: return OFMeterModFailedCode.BAD_FLAGS; case BAD_RATE_VAL: return OFMeterModFailedCode.BAD_RATE; case BAD_BURST_VAL: return OFMeterModFailedCode.BAD_BURST; case BAD_BAND_VAL: return OFMeterModFailedCode.BAD_BAND; case BAD_BAND_VALUE_VAL: return OFMeterModFailedCode.BAD_BAND_VALUE; case OUT_OF_METERS_VAL: return OFMeterModFailedCode.OUT_OF_METERS; case OUT_OF_BANDS_VAL: return OFMeterModFailedCode.OUT_OF_BANDS; default: throw new IllegalArgumentException("Illegal wire value for type OFMeterModFailedCode in version 1.4: " + val); } }
public static short toWireValue(OFMeterModFailedCode e) { switch(e) { case UNKNOWN: return UNKNOWN_VAL; case METER_EXISTS: return METER_EXISTS_VAL; case INVALID_METER: return INVALID_METER_VAL; case UNKNOWN_METER: return UNKNOWN_METER_VAL; case BAD_COMMAND: return BAD_COMMAND_VAL; case BAD_FLAGS: return BAD_FLAGS_VAL; case BAD_RATE: return BAD_RATE_VAL; case BAD_BURST: return BAD_BURST_VAL; case BAD_BAND: return BAD_BAND_VAL; case BAD_BAND_VALUE: return BAD_BAND_VALUE_VAL; case OUT_OF_METERS: return OUT_OF_METERS_VAL; case OUT_OF_BANDS: return OUT_OF_BANDS_VAL; default: throw new IllegalArgumentException("Illegal enum value for type OFMeterModFailedCode in version 1.4: " + e); } }
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 processMeterMod(OFMeterMod meterMod, Channel channel) { log.debug("processing METER_MOD {} message", meterMod.getCommand()); long meterModId = meterMod.getMeterId(); Meter existingMeter = meterService.getMeter(deviceId, MeterId.meterId(meterModId)); MeterRequest meterRequest = null; switch (meterMod.getCommand()) { case ADD: if (existingMeter != null) { meterModError(meterMod, OFMeterModFailedCode.METER_EXISTS, channel); return; } meterRequest = meterRequestBuilder(meterMod).add(); break; case MODIFY: if (existingMeter == null) { meterModError(meterMod, OFMeterModFailedCode.UNKNOWN_METER, channel); return; } meterRequest = meterRequestBuilder(meterMod).add(); break; case DELETE: // non-existing meter id will not result in OFMeterModFailedErrorMsg // being sent to the controller meterRequest = meterRequestBuilder(meterMod).remove(); break; default: log.warn("Unexpected message {} received for switch {}", meterMod.getCommand(), this); return; } meterService.submit(meterRequest); }
public static OFMeterModFailedCode readFrom(ByteBuf bb) throws OFParseError { try { return ofWireValue(bb.readShort()); } catch (IllegalArgumentException e) { throw new OFParseError(e); } }
public static OFMeterModFailedCode ofWireValue(short val) { switch(val) { case UNKNOWN_VAL: return OFMeterModFailedCode.UNKNOWN; case METER_EXISTS_VAL: return OFMeterModFailedCode.METER_EXISTS; case INVALID_METER_VAL: return OFMeterModFailedCode.INVALID_METER; case UNKNOWN_METER_VAL: return OFMeterModFailedCode.UNKNOWN_METER; case BAD_COMMAND_VAL: return OFMeterModFailedCode.BAD_COMMAND; case BAD_FLAGS_VAL: return OFMeterModFailedCode.BAD_FLAGS; case BAD_RATE_VAL: return OFMeterModFailedCode.BAD_RATE; case BAD_BURST_VAL: return OFMeterModFailedCode.BAD_BURST; case BAD_BAND_VAL: return OFMeterModFailedCode.BAD_BAND; case BAD_BAND_VALUE_VAL: return OFMeterModFailedCode.BAD_BAND_VALUE; case OUT_OF_METERS_VAL: return OFMeterModFailedCode.OUT_OF_METERS; case OUT_OF_BANDS_VAL: return OFMeterModFailedCode.OUT_OF_BANDS; default: throw new IllegalArgumentException("Illegal wire value for type OFMeterModFailedCode in version 1.5: " + val); } }
public static short toWireValue(OFMeterModFailedCode e) { switch(e) { case UNKNOWN: return UNKNOWN_VAL; case METER_EXISTS: return METER_EXISTS_VAL; case INVALID_METER: return INVALID_METER_VAL; case UNKNOWN_METER: return UNKNOWN_METER_VAL; case BAD_COMMAND: return BAD_COMMAND_VAL; case BAD_FLAGS: return BAD_FLAGS_VAL; case BAD_RATE: return BAD_RATE_VAL; case BAD_BURST: return BAD_BURST_VAL; case BAD_BAND: return BAD_BAND_VAL; case BAD_BAND_VALUE: return BAD_BAND_VALUE_VAL; case OUT_OF_METERS: return OUT_OF_METERS_VAL; case OUT_OF_BANDS: return OUT_OF_BANDS_VAL; default: throw new IllegalArgumentException("Illegal enum value for type OFMeterModFailedCode in version 1.5: " + e); } }
public static void writeTo(ChannelBuffer bb, OFMeterModFailedCode e) { bb.writeShort(toWireValue(e)); }
public static void putTo(OFMeterModFailedCode e, PrimitiveSink sink) { sink.putShort(toWireValue(e)); }
public static void writeTo(ByteBuf bb, OFMeterModFailedCode e) { bb.writeShort(toWireValue(e)); }