Search in sources :

Example 6 with PacketInReason

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason in project openflowplugin by opendaylight.

the class GetAsyncReplyMessageFactoryTest method createPacketInMask.

private static List<PacketInMask> createPacketInMask() {
    final List<PacketInMask> masks = new ArrayList<>();
    PacketInMaskBuilder builder;
    // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
    builder = new PacketInMaskBuilder();
    List<PacketInReason> packetInReasonList = new ArrayList<>();
    packetInReasonList.add(PacketInReason.OFPRNOMATCH);
    packetInReasonList.add(PacketInReason.OFPRACTION);
    packetInReasonList.add(PacketInReason.OFPRINVALIDTTL);
    builder.setMask(packetInReasonList);
    masks.add(builder.build());
    // OFPCR_ROLE_SLAVE
    builder = new PacketInMaskBuilder();
    packetInReasonList = new ArrayList<>();
    builder.setMask(packetInReasonList);
    masks.add(builder.build());
    return masks;
}
Also used : PacketInMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask) PacketInReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason) PacketInMaskBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder) ArrayList(java.util.ArrayList)

Example 7 with PacketInReason

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason in project genius by opendaylight.

the class ArpUtilImpl method onPacketReceived.

@Override
public void onPacketReceived(PacketReceived packetReceived) {
    Class<? extends PacketInReason> pktInReason = packetReceived.getPacketInReason();
    LOG.trace("Packet Received {}", packetReceived);
    if (pktInReason == SendToController.class) {
        try {
            int tableId = packetReceived.getTableId().getValue();
            byte[] data = packetReceived.getPayload();
            Ethernet ethernet = new Ethernet();
            ethernet.deserialize(data, 0, data.length * NetUtils.NUM_BITS_IN_A_BYTE);
            if (ethernet.getEtherType() != ArpConstants.ETH_TYPE_ARP) {
                return;
            }
            Packet pkt = ethernet.getPayload();
            ARP arp = (ARP) pkt;
            InetAddress srcInetAddr = InetAddress.getByAddress(arp.getSenderProtocolAddress());
            InetAddress dstInetAddr = InetAddress.getByAddress(arp.getTargetProtocolAddress());
            byte[] srcMac = ethernet.getSourceMACAddress();
            byte[] dstMac = ethernet.getDestinationMACAddress();
            Metadata metadata = packetReceived.getMatch().getMetadata();
            String interfaceName = getInterfaceName(metadata);
            checkAndFireMacChangedNotification(interfaceName, srcInetAddr, srcMac);
            macsDB.put(interfaceName + "-" + srcInetAddr.getHostAddress(), NWUtil.toStringMacAddress(srcMac));
            if (arp.getOpCode() == ArpConstants.ARP_REQUEST_OP) {
                fireArpReqRecvdNotification(interfaceName, srcInetAddr, srcMac, dstInetAddr, tableId, metadata.getMetadata());
            } else {
                fireArpRespRecvdNotification(interfaceName, srcInetAddr, srcMac, tableId, metadata.getMetadata(), dstInetAddr, dstMac);
            }
            if (macAddrs.get(srcInetAddr.getHostAddress()) != null) {
                threadPool.execute(new MacResponderTask(arp));
            }
        } catch (PacketException | UnknownHostException | InterruptedException | ExecutionException e) {
            LOG.trace("Failed to decode packet", e);
        }
    }
}
Also used : Packet(org.opendaylight.openflowplugin.libraries.liblldp.Packet) UnknownHostException(java.net.UnknownHostException) Metadata(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) Ethernet(org.opendaylight.genius.mdsalutil.packet.Ethernet) ExecutionException(java.util.concurrent.ExecutionException) InetAddress(java.net.InetAddress) ARP(org.opendaylight.genius.mdsalutil.packet.ARP)

Example 8 with PacketInReason

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason in project openflowplugin by opendaylight.

the class GetAsyncReplyMessageFactory method serializePacketInMask.

private static void serializePacketInMask(List<PacketInMask> packetInMask, ByteBuf outBuffer) {
    if (packetInMask != null) {
        for (PacketInMask currentPacketMask : packetInMask) {
            List<PacketInReason> mask = currentPacketMask.getMask();
            if (mask != null) {
                Map<Integer, Boolean> packetInReasonMap = new HashMap<>();
                for (PacketInReason packetInReason : mask) {
                    if (PacketInReason.OFPRNOMATCH.equals(packetInReason)) {
                        packetInReasonMap.put(PacketInReason.OFPRNOMATCH.getIntValue(), true);
                    } else if (PacketInReason.OFPRACTION.equals(packetInReason)) {
                        packetInReasonMap.put(PacketInReason.OFPRACTION.getIntValue(), true);
                    } else if (PacketInReason.OFPRINVALIDTTL.equals(packetInReason)) {
                        packetInReasonMap.put(PacketInReason.OFPRINVALIDTTL.getIntValue(), true);
                    }
                }
                outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(packetInReasonMap));
            }
        }
    }
}
Also used : PacketInMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask) HashMap(java.util.HashMap) PacketInReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason)

Example 9 with PacketInReason

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason in project openflowplugin by opendaylight.

the class GetAsyncReplyMessageFactory method serializePortStatusMask.

private static void serializePortStatusMask(List<PortStatusMask> portStatusMask, ByteBuf outBuffer) {
    if (portStatusMask != null) {
        for (PortStatusMask currentPortStatusMask : portStatusMask) {
            List<PortReason> mask = currentPortStatusMask.getMask();
            if (mask != null) {
                Map<Integer, Boolean> portStatusReasonMap = new HashMap<>();
                for (PortReason packetInReason : mask) {
                    if (PortReason.OFPPRADD.equals(packetInReason)) {
                        portStatusReasonMap.put(PortReason.OFPPRADD.getIntValue(), true);
                    } else if (PortReason.OFPPRDELETE.equals(packetInReason)) {
                        portStatusReasonMap.put(PortReason.OFPPRDELETE.getIntValue(), true);
                    } else if (PortReason.OFPPRMODIFY.equals(packetInReason)) {
                        portStatusReasonMap.put(PortReason.OFPPRMODIFY.getIntValue(), true);
                    }
                }
                outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(portStatusReasonMap));
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) PortReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason) PortStatusMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask)

Example 10 with PacketInReason

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason in project openflowplugin by opendaylight.

the class GetAsyncReplyMessageFactory method serializeFlowRemovedMask.

private static void serializeFlowRemovedMask(List<FlowRemovedMask> flowRemovedMask, ByteBuf outBuffer) {
    if (flowRemovedMask != null) {
        for (FlowRemovedMask currentFlowRemovedMask : flowRemovedMask) {
            List<FlowRemovedReason> mask = currentFlowRemovedMask.getMask();
            if (mask != null) {
                Map<Integer, Boolean> flowRemovedReasonMap = new HashMap<>();
                for (FlowRemovedReason packetInReason : mask) {
                    if (FlowRemovedReason.OFPRRIDLETIMEOUT.equals(packetInReason)) {
                        flowRemovedReasonMap.put(FlowRemovedReason.OFPRRIDLETIMEOUT.getIntValue(), true);
                    } else if (FlowRemovedReason.OFPRRHARDTIMEOUT.equals(packetInReason)) {
                        flowRemovedReasonMap.put(FlowRemovedReason.OFPRRHARDTIMEOUT.getIntValue(), true);
                    } else if (FlowRemovedReason.OFPRRDELETE.equals(packetInReason)) {
                        flowRemovedReasonMap.put(FlowRemovedReason.OFPRRDELETE.getIntValue(), true);
                    } else if (FlowRemovedReason.OFPRRGROUPDELETE.equals(packetInReason)) {
                        flowRemovedReasonMap.put(FlowRemovedReason.OFPRRGROUPDELETE.getIntValue(), true);
                    }
                }
                outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(flowRemovedReasonMap));
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) FlowRemovedMask(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask) FlowRemovedReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason)

Aggregations

PacketInReason (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason)7 HashMap (java.util.HashMap)6 PacketInMask (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask)6 ArrayList (java.util.ArrayList)4 PacketInMaskBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder)4 Ethernet (org.opendaylight.genius.mdsalutil.packet.Ethernet)3 PacketException (org.opendaylight.openflowplugin.libraries.liblldp.PacketException)3 BigInteger (java.math.BigInteger)2 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)2 FlowRemovedReason (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason)2 PortReason (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason)2 FlowRemovedMask (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask)2 PortStatusMask (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask)2 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 ExecutionException (java.util.concurrent.ExecutionException)1 ARP (org.opendaylight.genius.mdsalutil.packet.ARP)1 DHCP (org.opendaylight.netvirt.dhcpservice.api.DHCP)1 Packet (org.opendaylight.openflowplugin.libraries.liblldp.Packet)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1