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;
}
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);
}
}
}
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));
}
}
}
}
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));
}
}
}
}
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));
}
}
}
}
Aggregations