use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project genius by opendaylight.
the class ArpUtilImpl method fireArpReqRecvdNotification.
private void fireArpReqRecvdNotification(String interfaceName, InetAddress srcInetAddr, byte[] srcMac, InetAddress dstInetAddr, int tableId, BigInteger metadata) throws InterruptedException {
arpReqRecvd.mark();
String macAddress = NWUtil.toStringMacAddress(srcMac);
ArpRequestReceivedBuilder builder = new ArpRequestReceivedBuilder();
builder.setInterface(interfaceName);
builder.setOfTableId((long) tableId);
builder.setSrcIpaddress(new IpAddress(srcInetAddr.getHostAddress().toCharArray()));
builder.setDstIpaddress(new IpAddress(dstInetAddr.getHostAddress().toCharArray()));
builder.setSrcMac(new PhysAddress(macAddress));
builder.setMetadata(metadata);
ListenableFuture<?> offerNotification = notificationPublishService.offerNotification(builder.build());
if (offerNotification != null && offerNotification.equals(NotificationPublishService.REJECTED)) {
arpReqRecvdNotificationRejected.mark();
} else {
arpReqRecvdNotification.mark();
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId 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.openflow.common.types.rev130731.TableId in project genius by opendaylight.
the class ActionLearn method buildAction.
@Override
public Action buildAction(int newActionKey) {
NxLearnBuilder learnBuilder = new NxLearnBuilder();
learnBuilder.setIdleTimeout(idleTimeout).setHardTimeout(hardTimeout).setPriority(priority).setCookie(cookie).setFlags(flags).setTableId(tableId).setFinIdleTimeout(finIdleTimeout).setFinHardTimeout(finHardTimeout);
learnBuilder.setFlowMods(this.flowMods.stream().map(FlowMod::buildFlowMod).collect(Collectors.toList()));
return new ActionBuilder().setKey(new ActionKey(newActionKey)).setAction(new NxActionLearnNodesNodeTableFlowApplyActionsCaseBuilder().setNxLearn(learnBuilder.build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project genius by opendaylight.
the class MDSALManager method batchedRemoveFlowInternal.
public void batchedRemoveFlowInternal(BigInteger dpId, Flow flow) {
FlowKey flowKey = new FlowKey(new FlowId(flow.getId()));
short tableId = flow.getTableId();
if (flowExists(dpId, tableId, flowKey)) {
InstanceIdentifier<Flow> flowInstanceId = buildFlowInstanceIdentifier(dpId, tableId, flowKey);
flowBatchingUtils.delete(flowInstanceId);
} else {
LOG.debug("Flow {} does not exist for dpn {}", flowKey, dpId);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project bgpcep by opendaylight.
the class LocRibWriter method init.
@SuppressWarnings("unchecked")
private synchronized void init() {
final WriteTransaction tx = this.chain.newWriteOnlyTransaction();
tx.merge(LogicalDatastoreType.OPERATIONAL, this.locRibTableIID.builder().child(Attributes.class).build(), new AttributesBuilder().setUptodate(true).build());
tx.submit();
final InstanceIdentifier<Tables> tableId = this.ribIId.builder().child(Peer.class).child(EffectiveRibIn.class).child(Tables.class, this.tk).build();
this.reg = this.dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, tableId), this);
}
Aggregations