use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType in project openflowplugin by opendaylight.
the class OpenflowPluginBulkTransactionProvider method createL3IPv6Match.
private static MatchBuilder createL3IPv6Match() {
MatchBuilder match = new MatchBuilder();
EthernetMatchBuilder eth = new EthernetMatchBuilder();
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x86ddL));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
nextheader.setIpv6Exthdr(58);
Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
ipv6label.setIpv6Flabel(label);
// ipv6label.setFlabelMask(new byte[] { 0, 1, -1, -1 });
// icmpv6
Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
// match
icmpv6match.setIcmpv6Type((short) 135);
icmpv6match.setIcmpv6Code((short) 0);
match.setIcmpv6Match(icmpv6match.build());
Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
// ipv6match.setIpv6Source(srcip6);
// ipv6match.setIpv6Destination(dstip6);
// ipv6match.setIpv6ExtHeader(nextheader.build());
ipv6match.setIpv6NdSll(new MacAddress("c2:00:54:f5:00:00"));
ipv6match.setIpv6NdTll(new MacAddress("00:0c:29:0e:4c:67"));
// ipv6match.setIpv6NdTarget(ndtarget);
ipv6match.setIpv6Label(ipv6label.build());
match.setLayer3Match(ipv6match.build());
return match;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType in project openflowplugin by opendaylight.
the class LearningSwitchHandlerSimpleImpl method onPacketReceived.
@Override
public void onPacketReceived(PacketReceived notification) {
if (!isLearning) {
// ignoring packets - this should not happen
return;
}
LOG.debug("Received packet via match: {}", notification.getMatch());
// detect and compare node - we support one switch
if (!nodePath.contains(notification.getIngress().getValue())) {
return;
}
// read src MAC and dst MAC
byte[] dstMacRaw = PacketUtils.extractDstMac(notification.getPayload());
byte[] srcMacRaw = PacketUtils.extractSrcMac(notification.getPayload());
byte[] etherType = PacketUtils.extractEtherType(notification.getPayload());
MacAddress dstMac = PacketUtils.rawMacToMac(dstMacRaw);
MacAddress srcMac = PacketUtils.rawMacToMac(srcMacRaw);
NodeConnectorKey ingressKey = InstanceIdentifierUtils.getNodeConnectorKey(notification.getIngress().getValue());
LOG.debug("Received packet from MAC match: {}, ingress: {}", srcMac, ingressKey.getId());
LOG.debug("Received packet to MAC match: {}", dstMac);
LOG.debug("Ethertype: {}", Integer.toHexString(0x0000ffff & ByteBuffer.wrap(etherType).getShort()));
// learn by IPv4 traffic only
if (Arrays.equals(ETH_TYPE_IPV4, etherType)) {
NodeConnectorRef previousPort = mac2portMapping.put(srcMac, notification.getIngress());
if (previousPort != null && !notification.getIngress().equals(previousPort)) {
NodeConnectorKey previousPortKey = InstanceIdentifierUtils.getNodeConnectorKey(previousPort.getValue());
LOG.debug("mac2port mapping changed by mac {}: {} -> {}", srcMac, previousPortKey, ingressKey.getId());
}
// if dst MAC mapped:
NodeConnectorRef destNodeConnector = mac2portMapping.get(dstMac);
if (destNodeConnector != null) {
synchronized (coveredMacPaths) {
if (!destNodeConnector.equals(notification.getIngress())) {
// add flow
addBridgeFlow(srcMac, dstMac, destNodeConnector);
addBridgeFlow(dstMac, srcMac, notification.getIngress());
} else {
LOG.debug("useless rule ignoring - both MACs are behind the same port");
}
}
LOG.debug("packetIn-directing.. to {}", InstanceIdentifierUtils.getNodeConnectorKey(destNodeConnector.getValue()).getId());
sendPacketOut(notification.getPayload(), notification.getIngress(), destNodeConnector);
} else {
// flood
LOG.debug("packetIn-still flooding.. ");
flood(notification.getPayload(), notification.getIngress());
}
} else {
// non IPv4 package
flood(notification.getPayload(), notification.getIngress());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType in project openflowplugin by opendaylight.
the class OpenflowPluginBulkTransactionProvider method createMatch1000.
private static MatchBuilder createMatch1000() {
MatchBuilder match = new MatchBuilder();
Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
Ipv4Prefix prefix = new Ipv4Prefix("10.1.1.1/24");
ipv4Match.setIpv4Destination(prefix);
Ipv4Match i4m = ipv4Match.build();
match.setLayer3Match(i4m);
EthernetMatchBuilder eth = new EthernetMatchBuilder();
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
return match;
}
Aggregations