Java Code Examples for org.onlab.packet.Ethernet#TYPE_VLAN

The following examples show how to use org.onlab.packet.Ethernet#TYPE_VLAN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractCorsaPipeline.java    From onos with Apache License 2.0 6 votes vote down vote up
private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
    log.debug("Processing specific forwarding objective");
    TrafficSelector selector = fwd.selector();
    EthTypeCriterion ethTypeCriterion =
            (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
    VlanIdCriterion vlanIdCriterion =
            (VlanIdCriterion) selector.getCriterion(Criterion.Type.VLAN_VID);
    if (ethTypeCriterion != null) {
        short et = ethTypeCriterion.ethType().toShort();
        if (et == Ethernet.TYPE_IPV4) {
            return processSpecificRoute(fwd);
        } else if (et == Ethernet.TYPE_VLAN) {
            /* The ForwardingObjective must specify VLAN ethtype in order to use the Transit Circuit */
            return processSpecificSwitch(fwd);
        }
    } else if (vlanIdCriterion != null) {
        return processSpecificSwitch(fwd);
    }

    fail(fwd, ObjectiveError.UNSUPPORTED);
    return ImmutableSet.of();
}
 
Example 2
Source File: PacketStatistics.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public void process(PacketContext context) {
    InboundPacket pkt = context.inPacket();
    Ethernet ethPkt = pkt.parsed();

    //Indicates whether this is an ARP Packet
    if (ethPkt.getEtherType() == Ethernet.TYPE_ARP) {
        arpCounter.inc();

    } else if (ethPkt.getEtherType() == Ethernet.TYPE_LLDP) {
        lldpCounter.inc();

    } else if (ethPkt.getEtherType() == Ethernet.TYPE_VLAN) {
        vlanCounter.inc();

    } else if (ethPkt.getEtherType() == Ethernet.TYPE_BSN) {
        bsnCounter.inc();

    } else if (ethPkt.getEtherType() == Ethernet.TYPE_RARP) {
        rarpCounter.inc();

    } else if (ethPkt.getEtherType() == Ethernet.MPLS_UNICAST
            || ethPkt.getEtherType() == Ethernet.MPLS_MULTICAST) {
        mplsCounter.inc();

    } else if (ethPkt.getEtherType() == Ethernet.TYPE_IPV4) {
        IPv4 ipv4Packet = (IPv4) ethPkt.getPayload();
        //Indicates whether this is a TCP Packet
        if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_TCP) {
            tcpCounter.inc();

        } else if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_ICMP) {
            icmpCounter.inc();

        } else if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_IGMP) {
            igmpCounter.inc();

        } else if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_PIM) {
            pimCounter.inc();

        } else if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_UDP) {
            UDP udpPacket = (UDP) ipv4Packet.getPayload();
                //Indicates whether this packet is a DHCP Packet
                if (udpPacket.getSourcePort() == UDP.DHCP_CLIENT_PORT
                        || udpPacket.getSourcePort() == UDP.DHCP_SERVER_PORT) {
                    dhcpCounter.inc();
                }
            }
    } else if (ethPkt.getEtherType() == Ethernet.TYPE_IPV6) {
           IPv6 ipv6Pkt = (IPv6) ethPkt.getPayload();
           if (ipv6Pkt.getNextHeader() == IPv6.PROTOCOL_ICMP6) {
               icmp6Counter.inc();
               ICMP6 icmpv6 = (ICMP6) ipv6Pkt.getPayload();
               if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_SOLICITATION) {
                  nbrSolicitCounter.inc();
               } else if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_ADVERTISEMENT) {
                  nbrAdvertCounter.inc();
               }
           }
    } else {
            log.debug("Packet is unknown.");
            unknownCounter.inc();
    }
}