/** * Determine whether the given value represents a zero short value or not. * * @param value A byte array that contains a short integer. * @return {@code true} only if the given value represents a zero. */ protected final boolean isZeroShort(byte[] value) { return (value == null || toShort(value) == 0); }
/** * Return the value of the specified field as a short integer. * * @param name The name of the field. * @return A short integer value. */ protected final short getShort(String name) { byte[] value = hdrFieldsMap.get(name); return (value == null) ? 0 : toShort(value); }
/** * Store the value of fields read from data stream. * * @param name The name of the header field. * @param value The value to be associated with the specified header * field. {@code null} cannot be specified. */ @Override protected final void setHeaderField(String name, byte[] value) { if (name.equals(ETHT)) { short etype = toShort(value); setPayloadClass(getPayloadClass(etype)); } super.setHeaderField(name, value); }
/** * {@inheritDoc} */ @Override public VtnSetIcmpTypeActionCase toVtnAction(Action act) throws RpcException { SetTpSrcActionCase ac = cast(SetTpSrcActionCase.class, act); SetTpSrcAction action = ac.getSetTpSrcAction(); if (action != null) { Integer t = ProtocolUtils.getPortNumber(action.getPort()); if (t != null) { return newVtnAction(NumberUtils.toShort(t)); } } String msg = getErrorMessage("No ICMP type", ac); throw RpcException.getMissingArgumentException(msg); }
/** * {@inheritDoc} */ @Override public VtnSetIcmpCodeActionCase toVtnAction(Action act) throws RpcException { SetTpDstActionCase ac = cast(SetTpDstActionCase.class, act); SetTpDstAction action = ac.getSetTpDstAction(); if (action != null) { Integer c = ProtocolUtils.getPortNumber(action.getPort()); if (c != null) { return newVtnAction(NumberUtils.toShort(c)); } } String msg = getErrorMessage("No ICMP code", ac); throw RpcException.getMissingArgumentException(msg); }