Tabnine Logo
EthType
Code IndexAdd Tabnine to your IDE (free)

How to use
EthType
in
org.onlab.packet

Best Java code snippets using org.onlab.packet.EthType (Showing top 20 results out of 315)

origin: org.onosproject/onos-core-common

  @Override
  public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
    final EthTypeCriterion ethTypeCriterion =
        (EthTypeCriterion) criterion;
    return root.put(CriterionCodec.ETH_TYPE, "0x"
        + Integer.toHexString(ethTypeCriterion.ethType().toShort() & 0xffff));
  }
}
origin: org.onosproject/onlab-misc

/**
 * Constructs a new ethertype.
 *
 * @param ethType The actual ethertype
 * @param type it's textual representation
 * @param deserializer a parser for this ethertype
 */
EtherType(int ethType, String type, Deserializer<?> deserializer) {
  this.etherType = new EthType(ethType);
  this.type = type;
  this.deserializer = deserializer;
}
origin: org.onosproject/onlab-misc

public String toString() {
  EtherType ethType = lookup(this.etherType);
  return (ethType == null ? String.format("0x%04x", etherType) :
      ethType.toString());
}
origin: org.onosproject/onos-core-common

  final L2ModificationInstruction.ModVlanHeaderInstruction pushVlanInstruction =
      (L2ModificationInstruction.ModVlanHeaderInstruction) l2Instruction;
  result.put(InstructionCodec.ETHERNET_TYPE, pushVlanInstruction.ethernetType().toString());
  break;
case VLAN_POP:
      (L2ModificationInstruction.ModMplsHeaderInstruction) l2Instruction;
  result.put(InstructionCodec.ETHERNET_TYPE,
      pushHeaderInstructions.ethernetType().toShort());
  break;
case TUNNEL_ID:
      (L2ModificationInstruction.ModMplsHeaderInstruction) l2Instruction;
  result.put(InstructionCodec.ETHERNET_TYPE,
      toHexWithPrefix(popHeaderInstruction.ethernetType().toShort()));
  break;
case DEC_MPLS_TTL:
origin: org.onosproject/onos-core-common

@Override
public ObjectNode encode(Host host, CodecContext context) {
  checkNotNull(host, "Host cannot be null");
  final JsonCodec<HostLocation> locationCodec =
      context.codec(HostLocation.class);
  final ObjectNode result = context.mapper().createObjectNode()
      .put("id", host.id().toString())
      .put("mac", host.mac().toString())
      .put("vlan", host.vlan().toString())
      .put("innerVlan", host.innerVlan().toString())
      .put("outerTpid", host.tpid().toString())
      .put("configured", host.configured());
  final ArrayNode jsonIpAddresses = result.putArray("ipAddresses");
  for (final IpAddress ipAddress : host.ipAddresses()) {
    jsonIpAddresses.add(ipAddress.toString());
  }
  result.set("ipAddresses", jsonIpAddresses);
  final ArrayNode jsonLocations = result.putArray("locations");
  for (final HostLocation location : host.locations()) {
    jsonLocations.add(locationCodec.encode(location, context));
  }
  result.set("locations", jsonLocations);
  return annotate(result, host, context);
}
origin: org.onosproject/onos-drivers

if (ethType.ethType().equals(EthType.EtherType.EAPOL.ethType())) {
  provisionEapol(filter, ethType, output);
} else if (ethType.ethType().equals(EthType.EtherType.IPV4.ethType())) {
  IPProtocolCriterion ipProto = (IPProtocolCriterion)
      filterForCriterion(filter.conditions(), Criterion.Type.IP_PROTO);
origin: org.onosproject/onos-cli

  /**
   * Prints information about a host.
   *
   * @param host end-station host
   */
  protected void printHost(Host host) {
    if (shortOnly) {
      print(FMT_SHORT, host.id(), host.mac(),
         host.locations(),
         host.vlan(), host.ipAddresses());
    } else {
      print(FMT, host.id(), host.mac(),
         host.locations(),
         host.vlan(), host.ipAddresses(), annotations(host.annotations()),
         host.innerVlan(), host.tpid().toString(),
         host.providerId().scheme(), host.providerId().id(),
         host.configured());
    }
  }
}
origin: org.onosproject/onos-drivers

private boolean isSupportedEthTypeObjective(ForwardingObjective fwd) {
  TrafficSelector selector = fwd.selector();
  EthTypeCriterion ethType = (EthTypeCriterion) selector
      .getCriterion(Criterion.Type.ETH_TYPE);
  if ((ethType == null) ||
      ((ethType.ethType().toShort() != Ethernet.TYPE_IPV4) &&
          (ethType.ethType().toShort() != Ethernet.MPLS_UNICAST))) {
    return false;
  }
  return true;
}
origin: org.onosproject/onos-core-common

/**
 * Returns Ethernet type.
 *
 * @return ethernet type
 * @throws IllegalArgumentException if the JSON is invalid
 */
private EthType getEthType() {
  String ethTypeStr = nullIsIllegal(json.get(InstructionCodec.ETHERNET_TYPE),
       InstructionCodec.ETHERNET_TYPE + InstructionCodec.MISSING_MEMBER_MESSAGE).asText();
  Matcher matcher = ETHTYPE_PATTERN.matcher(ethTypeStr);
  if (!matcher.matches()) {
    throw new IllegalArgumentException("ETHERNET_TYPE must be a four digit hex string starting with 0x");
  }
  short ethernetType = (short) Integer.parseInt(matcher.group(1), 16);
  return new EthType(ethernetType);
}
origin: org.onosproject/onlab-misc

public static EtherType lookup(short etherType) {
  for (EtherType ethType : EtherType.values()) {
    if (ethType.ethType().toShort() == etherType) {
      return ethType;
    }
  }
  return UNKNOWN;
}
origin: org.onosproject/onos-of-provider-flow

case POP_MPLS:
  OFActionPopMpls popMpls = (OFActionPopMpls) act;
  builder.popMpls(new EthType(popMpls.getEthertype().getValue()));
  break;
case PUSH_MPLS:
origin: org.onosproject/onos-drivers

private boolean isSupportedEthTypeObjective(ForwardingObjective fwd) {
  TrafficSelector selector = fwd.selector();
  EthTypeCriterion ethType = (EthTypeCriterion) selector
      .getCriterion(Criterion.Type.ETH_TYPE);
  return !((ethType == null) ||
      ((ethType.ethType().toShort() != Ethernet.TYPE_IPV4) &&
          (ethType.ethType().toShort() != Ethernet.MPLS_UNICAST)));
}
origin: org.onosproject/onlab-misc

/**
 * Looks up the ethertype by it's numerical representation
 * and returns it's textual format.
 *
 * @param etherType the short value of the ethertype
 * @return a textual representation
 */
public EtherType lookup(short etherType) {
  for (EtherType ethType : EtherType.values()) {
    if (ethType.ethType().toShort() == etherType) {
      return ethType;
    }
  }
  return null;
}
origin: org.onosproject/onos-core-net

  @Override
  public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException {
    EthTypeCriterion c = (EthTypeCriterion) criterion;
    initAsExactMatch(copyFrom(c.ethType().toShort()), bitWidth);
  }
}
origin: org.onosproject/onos-drivers

if (ethType.ethType().toShort() == Ethernet.TYPE_ARP) {
  if (filters.isEmpty()) {
    pendingVersatiles.add(fwd);
origin: org.onosproject/onos-drivers

private Collection<FlowRule> processVersatile(ForwardingObjective forwardingObjective) {
  log.debug("Processing versatile forwarding objective");
  FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
      .forDevice(deviceId)
      .withSelector(forwardingObjective.selector())
      .withTreatment(forwardingObjective.treatment())
      .withPriority(forwardingObjective.priority())
      .fromApp(forwardingObjective.appId());
  if (forwardingObjective.permanent()) {
    ruleBuilder.makePermanent();
  } else {
    ruleBuilder.makeTemporary(TIME_OUT);
  }
  //ARP & DHCP Rule
  EthTypeCriterion ethCriterion =
      (EthTypeCriterion) forwardingObjective.selector().getCriterion(Criterion.Type.ETH_TYPE);
  UdpPortCriterion udpPortCriterion = (UdpPortCriterion) forwardingObjective
      .selector().getCriterion(Criterion.Type.UDP_DST);
  if (ethCriterion != null) {
    if (ethCriterion.ethType().toShort() == Ethernet.TYPE_ARP ||
        ethCriterion.ethType().toShort() == Ethernet.TYPE_LLDP) {
      ruleBuilder.forTable(VNI_TABLE);
      return Collections.singletonList(ruleBuilder.build());
    } else if (udpPortCriterion != null && udpPortCriterion.udpPort().toInt() == DHCP_SERVER_PORT) {
      ruleBuilder.forTable(VNI_TABLE);
      return Collections.singletonList(ruleBuilder.build());
    }
  }
  return Collections.emptySet();
}
origin: org.onosproject/onos-app-vtn-mgr

@Override
public void programArpClassifierRules(DeviceId deviceId, PortNumber inPort,
                   IpAddress dstIp,
                   SegmentationId actionVni,
                   Objective.Operation type) {
  TrafficSelector selector = DefaultTrafficSelector.builder()
      .matchInPort(inPort).matchEthType(ETH_TYPE.ethType().toShort())
      .matchArpTpa(Ip4Address.valueOf(dstIp.toString())).build();
  TrafficTreatment treatment = DefaultTrafficTreatment.builder()
      .setTunnelId(Long.parseLong(actionVni.segmentationId()))
      .build();
  ForwardingObjective.Builder objective = DefaultForwardingObjective
      .builder().withTreatment(treatment).withSelector(selector)
      .fromApp(appId).withFlag(Flag.SPECIFIC)
      .withPriority(ARP_CLASSIFIER_PRIORITY);
  if (type.equals(Objective.Operation.ADD)) {
    log.debug("ArpClassifierRules-->ADD");
    flowObjectiveService.forward(deviceId, objective.add());
  } else {
    log.debug("ArpClassifierRules-->REMOVE");
    flowObjectiveService.forward(deviceId, objective.remove());
  }
}
origin: org.onosproject/onos-app-routing

private ForwardingObjective.Builder createPeerObjBuilder(
    int nextId, IpPrefix ipAddresses) {
  TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
  sbuilder.matchEthType(EthType.EtherType.IPV4.ethType().toShort());
  sbuilder.matchIPDst(ipAddresses);
  DefaultForwardingObjective.Builder builder =
      DefaultForwardingObjective.builder()
      .withSelector(sbuilder.build())
      .fromApp(appId)
      .withPriority(getPriorityFromPrefix(ipAddresses))
      .withFlag(ForwardingObjective.Flag.SPECIFIC);
  if (nextId != -1) {
    builder.nextStep(nextId);
  }
  return builder;
}
origin: org.onosproject/onos-app-vtn-mgr

@Override
public void programArpClassifierRules(DeviceId deviceId, IpAddress dstIp,
                   SegmentationId actionVni,
                   Objective.Operation type) {
  TrafficSelector selector = DefaultTrafficSelector.builder()
      .matchEthType(ETH_TYPE.ethType().toShort())
      .matchArpTpa(Ip4Address.valueOf(dstIp.toString()))
      .build();
  TrafficTreatment treatment = DefaultTrafficTreatment.builder()
      .setTunnelId(Long.parseLong(actionVni.segmentationId()))
      .build();
  ForwardingObjective.Builder objective = DefaultForwardingObjective
      .builder().withTreatment(treatment).withSelector(selector)
      .fromApp(appId).withFlag(Flag.SPECIFIC)
      .withPriority(ARP_CLASSIFIER_PRIORITY);
  if (type.equals(Objective.Operation.ADD)) {
    log.debug("ArpClassifierRules-->ADD");
    flowObjectiveService.forward(deviceId, objective.add());
  } else {
    log.debug("ArpClassifierRules-->REMOVE");
    flowObjectiveService.forward(deviceId, objective.remove());
  }
}
origin: org.onosproject/onos-drivers

EthTypeCriterion ethType =
    (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) {
  fail(fwd, ObjectiveError.UNSUPPORTED);
  return Collections.emptySet();
org.onlab.packetEthType

Javadoc

Representation of an Ethertype.

Most used methods

  • toShort
    Returns the short value for this ethtype.
  • <init>
    Builds the EthType.
  • toString
  • equals
  • lookup
    Looks up the ethertype by it's numerical representation and returns it's textual format.

Popular in Java

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • addToBackStack (FragmentTransaction)
  • getSystemService (Context)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • JComboBox (javax.swing)
  • JFrame (javax.swing)
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now