Codota Logo
TranslateUtils
Code IndexAdd Codota to your IDE (free)

How to use
TranslateUtils
in
io.fd.honeycomb.translate.v3po.util

Best Java code snippets using io.fd.honeycomb.translate.v3po.util.TranslateUtils (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: io.fd.honeycomb.v3po/v3po2vpp

private static Optional<IpAddressDetailsReplyDump> dumpAddressFromOperationalData(
  @Nonnull final FutureJVppCore futureJVppCore, @Nonnull final InstanceIdentifier<?> id, final int interfaceIndex)
  throws VppBaseCallException, ReadTimeoutException {
  LOG.debug("Dumping Ipv4 addresses for interface id={}", interfaceIndex);
  final IpAddressDump dumpRequest = new IpAddressDump();
  dumpRequest.isIpv6 = 0;
  dumpRequest.swIfIndex = interfaceIndex;
  return Optional.fromNullable(
    TranslateUtils.getReplyForRead(futureJVppCore.ipAddressDump(dumpRequest).toCompletableFuture(), id));
}
origin: io.fd.honeycomb.v3po/v3po2vpp

private void createClassifySession(@Nonnull final InstanceIdentifier<?> id,
                  @Nonnull final ClassifyAddDelSession request)
  throws VppBaseCallException, WriteTimeoutException {
  final CompletionStage<ClassifyAddDelSessionReply> cs = futureJVppCore.classifyAddDelSession(request);
  TranslateUtils.getReplyForWrite(cs.toCompletableFuture(), id);
}
origin: io.fd.honeycomb.v3po/v3po2vpp

@Nonnull static <T extends Identifier> List<T> getAllIpv4AddressIds(
  final Optional<IpAddressDetailsReplyDump> dumpOptional,
  @Nonnull final Function<Ipv4AddressNoZone, T> keyConstructor) {
  if (dumpOptional.isPresent() && dumpOptional.get().ipAddressDetails != null) {
    return dumpOptional.get().ipAddressDetails.stream()
      .map(detail -> keyConstructor.apply(TranslateUtils.arrayToIpv4AddressNoZone(detail.ip)))
      .collect(Collectors.toList());
  } else {
    return Collections.emptyList();
  }
}
origin: io.fd.honeycomb.vpp/vpp-translate-utils

  public static IpAddress reverseAddress(@Nonnull final IpAddress address) {
    //arrayToIpAdddress internaly reverts order
    return arrayToIpAddress(isIpv6(address), ipAddressToArray(address));
  }
}
origin: io.fd.honeycomb.vpp/vpp-translate-utils

public static <REP extends JVppReply<?>> REP getReplyForRead(@Nonnull Future<REP> future,
                               @Nonnull final InstanceIdentifier<?> replyType,
                               @Nonnegative final int timeoutInSeconds)
    throws VppBaseCallException, ReadTimeoutException {
  try {
    return getReply(future, timeoutInSeconds);
  } catch (TimeoutException e) {
    throw new ReadTimeoutException(replyType, e);
  }
}
origin: io.fd.honeycomb.vpp/vpp-translate-utils

public static <REP extends JVppReply<?>> REP getReplyForWrite(@Nonnull Future<REP> future,
                               @Nonnull final InstanceIdentifier<?> replyType,
                               @Nonnegative final int timeoutInSeconds)
    throws VppBaseCallException, WriteTimeoutException {
  try {
    return getReply(future, timeoutInSeconds);
  } catch (TimeoutException e) {
    throw new WriteTimeoutException(replyType, e);
  }
}
origin: io.fd.honeycomb.v3po/v3po2vpp

  private void addDelNeighbourAndReply(InstanceIdentifier<Neighbor> id, boolean add, int parentInterfaceIndex,
                     Neighbor data)
      throws VppBaseCallException, WriteTimeoutException {

    IpNeighborAddDel request = new IpNeighborAddDel();

    request.isAdd = TranslateUtils.booleanToByte(add);
    request.isIpv6 = 0;
    request.isStatic = 1;
    request.dstAddress = TranslateUtils.ipv4AddressNoZoneToArray(data.getIp());
    request.macAddress = TranslateUtils.parseMac(data.getLinkLayerAddress().getValue());
    request.swIfIndex = parentInterfaceIndex;

    //TODO if it is necessary for future use ,make adjustments to be able to set vrfid
    //request.vrfId
    TranslateUtils.getReplyForWrite(getFutureJVpp().ipNeighborAddDel(request).toCompletableFuture(), id);
  }
}
origin: io.fd.honeycomb.v3po/v3po2vpp

static void addDelAddress(@Nonnull final FutureJVppCore futureJVppCore, final boolean add, final InstanceIdentifier<?> id,
             @Nonnegative final int ifaceId,
             @Nonnull final Ipv4AddressNoZone address, @Nonnegative final byte prefixLength)
  throws VppBaseCallException, WriteTimeoutException {
  checkArgument(prefixLength > 0, "Invalid prefix length");
  checkNotNull(address, "address should not be null");
  final byte[] addressBytes = TranslateUtils.ipv4AddressNoZoneToArray(address);
  final CompletionStage<SwInterfaceAddDelAddressReply> swInterfaceAddDelAddressReplyCompletionStage =
    futureJVppCore.swInterfaceAddDelAddress(
      getSwInterfaceAddDelAddressRequest(ifaceId, TranslateUtils.booleanToByte(add) /* isAdd */,
        (byte) 0 /* isIpv6 */, (byte) 0 /* delAll */, prefixLength, addressBytes));
  TranslateUtils.getReplyForWrite(swInterfaceAddDelAddressReplyCompletionStage.toCompletableFuture(), id);
}
origin: io.fd.honeycomb.v3po/v3po2vpp

private BridgeDomainAddDelReply addOrUpdateBridgeDomain(@Nonnull final InstanceIdentifier<BridgeDomain> id,
                            final int bdId, @Nonnull final BridgeDomain bd)
  throws VppBaseCallException, WriteTimeoutException {
  final BridgeDomainAddDelReply reply;
  final BridgeDomainAddDel request = new BridgeDomainAddDel();
  request.bdId = bdId;
  request.flood = booleanToByte(bd.isFlood());
  request.forward = booleanToByte(bd.isForward());
  request.learn = booleanToByte(bd.isLearn());
  request.uuFlood = booleanToByte(bd.isUnknownUnicastFlood());
  request.arpTerm = booleanToByte(bd.isArpTermination());
  request.isAdd = ADD_OR_UPDATE_BD;
  reply = TranslateUtils.getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id);
  LOG.debug("Bridge domain {} (id={}) add/update successful", bd.getName(), bdId);
  return reply;
}
origin: io.fd.honeycomb.v3po/v3po2vpp

@Override
public void readCurrentAttributes(@Nonnull InstanceIdentifier<Version> id, @Nonnull final VersionBuilder builder,
                 @Nonnull final ReadContext context) throws ReadFailedException {
  try {
    // Execute with timeout
    final CompletionStage<ShowVersionReply> showVersionFuture = getFutureJVpp().showVersion(new ShowVersion());
    final ShowVersionReply reply = TranslateUtils.getReplyForRead(showVersionFuture.toCompletableFuture(), id);
    builder.setBranch(TranslateUtils.toString(reply.version));
    builder.setName(TranslateUtils.toString(reply.program));
    builder.setBuildDate(TranslateUtils.toString(reply.buildDate));
    builder.setBuildDirectory(TranslateUtils.toString(reply.buildDirectory));
  } catch (VppBaseCallException e) {
    throw new ReadFailedException(id, e);
  }
}
origin: io.fd.honeycomb.v3po/v3po2vpp

private L2FibAddDel createL2FibRequest(final L2FibEntry entry, final int bdId, final int swIfIndex, boolean isAdd) {
  final L2FibAddDel request = new L2FibAddDel();
  request.mac = macToLong(entry.getPhysAddress().getValue());
  request.bdId = bdId;
  request.swIfIndex = swIfIndex;
  request.isAdd = booleanToByte(isAdd);
  if (isAdd) {
    request.staticMac = booleanToByte(entry.isStaticConfig());
    request.filterMac = booleanToByte(L2FibFilter.class == entry.getAction());
  }
  return request;
}
origin: io.fd.honeycomb.v3po/v3po2vpp

  private BdIpMacAddDel createRequest(final ArpTerminationTableEntry entry, final int bdId, boolean isAdd) {
    final BdIpMacAddDel request = new BdIpMacAddDel();
    request.bdId = bdId;
    request.isAdd = booleanToByte(isAdd);
    request.macAddress = TranslateUtils.parseMac(entry.getPhysAddress().getValue());

    final IpAddress ipAddress = entry.getIpAddress();
    if (ipAddress.getIpv6Address() != null) {
      // FIXME: vpp does not support ipv6 in arp-termination table (based on analysis of l2_bd.c)
      throw new UnsupportedOperationException("IPv6 address for ARP termination table is not supported yet");
    }

    request.ipAddress = TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(ipAddress.getIpv4Address()));
    return request;
  }
}
origin: io.fd.honeycomb.vpp/vpp-translate-utils

public static final byte[] ipAddressToArray(IpAddress address) {
  checkNotNull(address, "Cannot resolve null adddress");
  if (isIpv6(address)) {
    return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(address.getIpv6Address()));
  } else {
    return ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(address.getIpv4Address()));
  }
}
origin: io.fd.honeycomb.vpp/vpp-translate-utils

/**
 * Converts array bytes to {@link IpAddress}
 */
@Nonnull
public static IpAddress arrayToIpAddress(boolean isIpv6, byte[] ip) {
  if (isIpv6) {
    return new IpAddress(arrayToIpv6AddressNoZone(ip));
  } else {
    return new IpAddress(arrayToIpv4AddressNoZone(ip));
  }
}
origin: io.fd.honeycomb.vpp/vpp-translate-utils

/**
 * Converts {@link IpAddress} to array representing {@link Ipv4Address} or {@link Ipv6Address}
 */
public static byte[] ipAddressToArray(boolean isIpv6, @Nonnull IpAddress address) {
  checkNotNull(address, "Cannot convert null Address");
  if (isIpv6) {
    return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(address.getIpv6Address()));
  } else {
    return ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(address.getIpv4Address()));
  }
}
origin: io.fd.honeycomb.vpp/vpp-translate-utils

/**
 * Transform Ipv4 address to a byte array acceptable by VPP. VPP expects incoming byte array to be in the same order
 * as the address.
 *
 * @return byte array with address bytes
 */
public static byte[] ipv4AddressNoZoneToArray(final Ipv4AddressNoZone ipv4Addr) {
  return ipv4AddressNoZoneToArray(ipv4Addr.getValue());
}
origin: io.fd.honeycomb.vpp/vpp-translate-utils

public static <REP extends JVppReply<?>> REP getReply(@Nonnull Future<REP> future,
                           @Nonnegative final int timeoutInSeconds)
    throws TimeoutException, VppBaseCallException {
  try {
    checkArgument(timeoutInSeconds > 0, "Timeout cannot be < 0");
    return future.get(timeoutInSeconds, TimeUnit.SECONDS);
  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
    throw new IllegalStateException("Interrupted", e);
  } catch (ExecutionException e) {
    // Execution exception could generally contains any exception
    // when using exceptions instead of return codes just rethrow it for processing on corresponding place
    if (e instanceof ExecutionException && (e.getCause() instanceof VppBaseCallException)) {
      throw (VppBaseCallException) (e.getCause());
    }
    throw new IllegalStateException(e);
  }
}
origin: io.fd.honeycomb.v3po/v3po2vpp

@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id,
                 @Nonnull final BridgeDomainBuilder builder, @Nonnull final ReadContext context)
  throws ReadFailedException {
  LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: id={}, builderbuilder={}, context={}",
    id, builder, context);
  final BridgeDomainKey key = id.firstKeyOf(id.getTargetType());
  LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: key={}", key);
  final int bdId = bdContext.getIndex(key.getName(), context.getMappingContext());
  LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: bdId={}", bdId);
  BridgeDomainDetailsReplyDump reply;
  BridgeDomainDetails bridgeDomainDetails;
  final BridgeDomainDump request = new BridgeDomainDump();
  request.bdId = bdContext.getIndex(key.getName(), context.getMappingContext());
  try {
    reply = getFutureJVpp().bridgeDomainDump(request).toCompletableFuture().get();
    bridgeDomainDetails = Iterables.getOnlyElement(reply.bridgeDomainDetails);
  } catch (Exception e) {
    LOG.debug("Unable to read bridge domain: {}", key.getName(), e);
    return;
  }
  logBridgeDomainDetails(bridgeDomainDetails);
  builder.setName(key.getName());
  builder.setArpTermination(byteToBoolean(bridgeDomainDetails.arpTerm));
  builder.setFlood(byteToBoolean(bridgeDomainDetails.flood));
  builder.setForward(byteToBoolean(bridgeDomainDetails.forward));
  builder.setLearn(byteToBoolean(bridgeDomainDetails.learn));
  builder.setUnknownUnicastFlood(byteToBoolean(bridgeDomainDetails.uuFlood));
}
origin: io.fd.honeycomb.vpp/vpp-translate-utils

/**
 * Converts byte array to {@link Ipv6Prefix} with specified prefixLength
 */
public static Ipv6Prefix arrayToIpv6Prefix(final byte[] address, byte prefixLength) {
  Ipv6AddressNoZone addressPart = arrayToIpv6AddressNoZone(address);
  return new Ipv6Prefix(addressPart.getValue().concat("/").concat(String.valueOf(prefixLength)));
}
origin: io.fd.honeycomb.v3po/v3po2vpp

private void createSubInterface(final InstanceIdentifier<SubInterface> id, @Nonnull final String superIfName,
                @Nonnull final SubInterface subInterface,
                final WriteContext writeContext) throws VppBaseCallException,
    WriteTimeoutException {
  final int superIfIndex = interfaceContext.getIndex(superIfName, writeContext.getMappingContext());
  final CompletionStage<CreateSubifReply> createSubifReplyCompletionStage =
    getFutureJVpp().createSubif(getCreateSubifRequest(subInterface, superIfIndex));
  final CreateSubifReply reply =
    TranslateUtils.getReplyForWrite(createSubifReplyCompletionStage.toCompletableFuture(), id);
  setInterfaceState(id, reply.swIfIndex, booleanToByte(subInterface.isEnabled()));
  interfaceContext.addName(reply.swIfIndex,
    getSubInterfaceName(superIfName, Math.toIntExact(subInterface.getIdentifier())),
    writeContext.getMappingContext());
  LOG.debug("Sub interface created successfully for: {}, subInterface: {}", superIfName, subInterface);
}
io.fd.honeycomb.translate.v3po.utilTranslateUtils

Most used methods

  • getReplyForRead
  • getReplyForWrite
  • arrayToIpv4AddressNoZone
    Parse byte array returned by VPP representing an Ipv4 address. Vpp returns IP byte arrays in reverse
  • booleanToByte
    Returns 0 if argument is null or false, 1 otherwise.
  • getReply
  • ipv4AddressNoZoneToArray
    Transform Ipv4 address to a byte array acceptable by VPP. VPP expects incoming byte array to be in t
  • arrayToIpAddress
    Converts array bytes to IpAddress
  • arrayToIpv6AddressNoZone
    Parse byte array returned by VPP representing an Ipv6 address. Vpp returns IP byte arrays in reverse
  • byteToBoolean
    Returns Boolean.TRUE if argument is 0, Boolean.FALSE otherwise.
  • ipAddressToArray
    Converts IpAddress to array representing Ipv4Address or Ipv6Address
  • ipv6AddressNoZoneToArray
    Transform Ipv6 address to a byte array acceptable by VPP. VPP expects incoming byte array to be in t
  • isIpv6
    Detects whether IpPrefix is ipv6
  • ipv6AddressNoZoneToArray,
  • isIpv6,
  • parseHexByte,
  • parseMac,
  • parseMacLikeString,
  • reverseBytes,
  • toString

Popular in Java

  • Creating JSON documents from java classes using gson
  • startActivity (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • getExternalFilesDir (Context)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • MessageFormat (java.text)
    MessageFormat provides a means to produce concatenated messages in language-neutral way. Use this to
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • JPanel (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now