Search in sources :

Example 41 with Metadata

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata 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 42 with Metadata

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata in project cxf by apache.

the class AbstractSTSClient method configureViaEPR.

public void configureViaEPR(EndpointReferenceType ref, boolean useEPRWSAAddrAsMEXLocation) {
    if (client != null) {
        return;
    }
    location = EndpointReferenceUtils.getAddress(ref);
    if (location != null) {
        location = location.trim();
    }
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("EPR address: " + location);
    }
    final QName sName = EndpointReferenceUtils.getServiceName(ref, bus);
    if (sName != null) {
        serviceName = sName;
        final QName epName = EndpointReferenceUtils.getPortQName(ref, bus);
        if (epName != null) {
            endpointName = epName;
        }
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("EPR endpoint: " + serviceName + " " + endpointName);
        }
    }
    final String wsdlLoc = EndpointReferenceUtils.getWSDLLocation(ref);
    if (wsdlLoc != null) {
        wsdlLocation = wsdlLoc;
    }
    String mexLoc = findMEXLocation(ref, useEPRWSAAddrAsMEXLocation);
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("WS-MEX location: " + mexLoc);
    }
    if (mexLoc != null) {
        try {
            JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
            proxyFac.setBindingId(soapVersion);
            proxyFac.setAddress(mexLoc);
            MetadataExchange exc = proxyFac.create(MetadataExchange.class);
            Metadata metadata = exc.get2004();
            Definition definition = null;
            List<Schema> schemas = new ArrayList<>();
            // Parse the MetadataSections into WSDL definition + associated schemas
            for (MetadataSection s : metadata.getMetadataSection()) {
                if ("http://schemas.xmlsoap.org/wsdl/".equals(s.getDialect())) {
                    definition = bus.getExtension(WSDLManager.class).getDefinition((Element) s.getAny());
                } else if ("http://www.w3.org/2001/XMLSchema".equals(s.getDialect())) {
                    Element schemaElement = (Element) s.getAny();
                    if (schemaElement == null) {
                        String schemaLocation = s.getLocation();
                        LOG.info("XSD schema location: " + schemaLocation);
                        schemaElement = downloadSchema(schemaLocation);
                    }
                    QName schemaName = new QName(schemaElement.getNamespaceURI(), schemaElement.getLocalName());
                    WSDLManager wsdlManager = bus.getExtension(WSDLManager.class);
                    ExtensibilityElement exElement = wsdlManager.getExtensionRegistry().createExtension(Types.class, schemaName);
                    ((Schema) exElement).setElement(schemaElement);
                    schemas.add((Schema) exElement);
                }
            }
            if (definition != null) {
                // Add any extra schemas to the WSDL definition
                for (Schema schema : schemas) {
                    definition.getTypes().addExtensibilityElement(schema);
                }
                WSDLServiceFactory factory = new WSDLServiceFactory(bus, definition);
                SourceDataBinding dataBinding = new SourceDataBinding();
                factory.setDataBinding(dataBinding);
                Service service = factory.create();
                service.setDataBinding(dataBinding);
                // Get the endpoint + service names by matching the 'location' to the
                // address in the WSDL. If the 'location' is 'anonymous' then just fall
                // back to the first service + endpoint name in the WSDL, if the endpoint
                // name is not defined in the Metadata
                List<ServiceInfo> services = service.getServiceInfos();
                String anonymousAddress = "http://www.w3.org/2005/08/addressing/anonymous";
                if (!anonymousAddress.equals(location)) {
                    for (ServiceInfo serv : services) {
                        for (EndpointInfo ei : serv.getEndpoints()) {
                            if (ei.getAddress().equals(location)) {
                                endpointName = ei.getName();
                                serviceName = serv.getName();
                                LOG.fine("Matched endpoint to location");
                            }
                        }
                    }
                }
                EndpointInfo ei = service.getEndpointInfo(endpointName);
                if (ei == null && anonymousAddress.equals(location) && !services.isEmpty() && !services.get(0).getEndpoints().isEmpty()) {
                    LOG.fine("Anonymous location so taking first endpoint");
                    serviceName = services.get(0).getName();
                    endpointName = services.get(0).getEndpoints().iterator().next().getName();
                    ei = service.getEndpointInfo(endpointName);
                }
                if (ei == null) {
                    throw new TrustException(LOG, "ADDRESS_NOT_MATCHED", location);
                }
                if (location != null && !anonymousAddress.equals(location)) {
                    ei.setAddress(location);
                }
                Endpoint endpoint = new EndpointImpl(bus, service, ei);
                client = new ClientImpl(bus, endpoint);
            }
        } catch (Exception ex) {
            throw new TrustException("WS_MEX_ERROR", ex, LOG);
        }
    }
}
Also used : Types(javax.wsdl.Types) MetadataSection(org.apache.cxf.ws.mex.model._2004_09.MetadataSection) Schema(javax.wsdl.extensions.schema.Schema) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Element(org.w3c.dom.Element) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Metadata(org.apache.cxf.ws.mex.model._2004_09.Metadata) ArrayList(java.util.ArrayList) ModCountCopyOnWriteArrayList(org.apache.cxf.common.util.ModCountCopyOnWriteArrayList) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) MetadataExchange(org.apache.cxf.ws.mex.MetadataExchange) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) QName(javax.xml.namespace.QName) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) Definition(javax.wsdl.Definition) Service(org.apache.cxf.service.Service) ClientImpl(org.apache.cxf.endpoint.ClientImpl) WSSecurityException(org.apache.wss4j.common.ext.WSSecurityException) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) Base64DecodingException(org.apache.xml.security.exceptions.Base64DecodingException) EndpointException(org.apache.cxf.endpoint.EndpointException) BusException(org.apache.cxf.BusException) WSDLManager(org.apache.cxf.wsdl.WSDLManager)

Example 43 with Metadata

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata in project cxf by apache.

the class MEXTest method testGet.

@Test
public void testGet() {
    // Create the client
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setBus(getStaticBus());
    proxyFac.setAddress("http://localhost:" + PORT + "/jaxws/addmex");
    proxyFac.getFeatures().add(new LoggingFeature());
    MetadataExchange exc = proxyFac.create(MetadataExchange.class);
    Metadata metadata = exc.get2004();
    assertNotNull(metadata);
    assertEquals(2, metadata.getMetadataSection().size());
    assertEquals("http://schemas.xmlsoap.org/wsdl/", metadata.getMetadataSection().get(0).getDialect());
    assertEquals("http://apache.org/cxf/systest/ws/addr_feature/", metadata.getMetadataSection().get(0).getIdentifier());
    assertEquals("http://www.w3.org/2001/XMLSchema", metadata.getMetadataSection().get(1).getDialect());
    GetMetadata body = new GetMetadata();
    body.setDialect("http://www.w3.org/2001/XMLSchema");
    metadata = exc.getMetadata(body);
    assertEquals(1, metadata.getMetadataSection().size());
    assertEquals("http://www.w3.org/2001/XMLSchema", metadata.getMetadataSection().get(0).getDialect());
}
Also used : GetMetadata(org.apache.cxf.ws.mex.model._2004_09.GetMetadata) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Metadata(org.apache.cxf.ws.mex.model._2004_09.Metadata) GetMetadata(org.apache.cxf.ws.mex.model._2004_09.GetMetadata) MetadataExchange(org.apache.cxf.ws.mex.MetadataExchange) Test(org.junit.Test)

Example 44 with Metadata

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata in project bgpcep by opendaylight.

the class AbstractTopologySessionListener method stateSynchronizationAchieved.

/**
 * Indicate that the peer has completed state synchronization.
 *
 * @param ctx Message context
 */
protected final synchronized void stateSynchronizationAchieved(final MessageContext ctx) {
    if (this.synced.getAndSet(true)) {
        LOG.debug("State synchronization achieved while synchronizing, not updating state");
        return;
    }
    if (this.triggeredResyncInProcess) {
        this.triggeredResyncInProcess = false;
    }
    updatePccNode(ctx, new PathComputationClientBuilder().setStateSync(PccSyncState.Synchronized).build());
    // The node has completed synchronization, cleanup metadata no longer reported back
    this.nodeState.cleanupExcept(this.lsps.values());
    LOG.debug("Session {} achieved synchronized state", this.session);
}
Also used : PathComputationClientBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.PathComputationClientBuilder)

Example 45 with Metadata

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata in project netvirt by opendaylight.

the class ElanUtils method buildKnownSmacFlow.

public FlowEntity buildKnownSmacFlow(ElanInstance elanInfo, InterfaceInfo interfaceInfo, long macTimeout, String macAddress) {
    int lportTag = interfaceInfo.getInterfaceTag();
    // Matching metadata and eth_src fields
    List<MatchInfo> mkMatches = new ArrayList<>();
    mkMatches.add(new MatchMetadata(ElanHelper.getElanMetadataLabel(elanInfo.getElanTag(), lportTag), ElanHelper.getElanMetadataMask()));
    mkMatches.add(new MatchEthernetSource(new MacAddress(macAddress)));
    List<InstructionInfo> mkInstructions = new ArrayList<>();
    mkInstructions.add(new InstructionGotoTable(NwConstants.ELAN_DMAC_TABLE));
    BigInteger dpId = interfaceInfo.getDpId();
    long elanTag = getElanTag(elanInfo, interfaceInfo);
    return new FlowEntityBuilder().setDpnId(dpId).setTableId(NwConstants.ELAN_SMAC_TABLE).setFlowId(getKnownDynamicmacFlowRef(NwConstants.ELAN_SMAC_TABLE, dpId, lportTag, macAddress, elanTag)).setPriority(20).setFlowName(elanInfo.getDescription()).setIdleTimeOut((int) macTimeout).setHardTimeOut(0).setCookie(ElanConstants.COOKIE_ELAN_KNOWN_SMAC.add(BigInteger.valueOf(elanTag))).setMatchInfoList(mkMatches).setInstructionInfoList(mkInstructions).setStrictFlag(true).setSendFlowRemFlag(macTimeout != 0).build();
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) FlowEntityBuilder(org.opendaylight.genius.mdsalutil.FlowEntityBuilder) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) MatchEthernetSource(org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource) ArrayList(java.util.ArrayList) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) BigInteger(java.math.BigInteger)

Aggregations

BigInteger (java.math.BigInteger)44 ArrayList (java.util.ArrayList)35 Test (org.junit.Test)25 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)14 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)13 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)13 ByteBuf (io.netty.buffer.ByteBuf)10 MetadataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder)10 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)8 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)7 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)7 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)7 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)7 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)7 MatchTunnelId (org.opendaylight.genius.mdsalutil.matches.MatchTunnelId)6 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)6 Metadata (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata)6 WriteMetadataCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder)6 InstructionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder)6 List (java.util.List)5