Search in sources :

Example 41 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project openflowplugin by opendaylight.

the class GroupFeaturesService method transformToNotification.

@Override
public GroupFeaturesUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
    final int mpSize = result.size();
    Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
    GroupFeaturesUpdatedBuilder notification = new GroupFeaturesUpdatedBuilder();
    notification.setId(getDeviceInfo().getNodeId());
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    MultipartReplyGroupFeaturesCase caseBody = (MultipartReplyGroupFeaturesCase) result.get(0).getMultipartReplyBody();
    MultipartReplyGroupFeatures replyBody = caseBody.getMultipartReplyGroupFeatures();
    notification.setGroupTypesSupported(extractSupportedGroupTypes(replyBody.getTypes()));
    notification.setMaxGroups(replyBody.getMaxGroups());
    notification.setGroupCapabilitiesSupported(extractSupportedCapabilities(replyBody.getCapabilities()));
    notification.setActions(GroupUtil.extractGroupActionsSupportBitmap(replyBody.getActionsBitmap()));
    return notification.build();
}
Also used : MultipartReplyGroupFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase) GroupFeaturesUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdatedBuilder) MultipartReplyGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures)

Example 42 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project openflowplugin by opendaylight.

the class LLDPDiscoveryUtils method lldpToNodeConnectorRef.

/**
 * Returns the encoded in custom TLV for the given lldp.
 *
 * @param payload lldp payload
 * @param useExtraAuthenticatorCheck make it more secure (CVE-2015-1611 CVE-2015-1612)
 * @return nodeConnectorId - encoded in custom TLV of given lldp
 */
@SuppressWarnings("checkstyle:IllegalCatch")
public static NodeConnectorRef lldpToNodeConnectorRef(byte[] payload, boolean useExtraAuthenticatorCheck) {
    NodeConnectorRef nodeConnectorRef = null;
    if (isLLDP(payload)) {
        Ethernet ethPkt = new Ethernet();
        try {
            ethPkt.deserialize(payload, 0, payload.length * NetUtils.NUM_BITS_IN_A_BYTE);
        } catch (PacketException e) {
            LOG.warn("Failed to decode LLDP packet {}", e);
            return nodeConnectorRef;
        }
        LLDP lldp = (LLDP) ethPkt.getPayload();
        try {
            NodeId srcNodeId = null;
            NodeConnectorId srcNodeConnectorId = null;
            final LLDPTLV systemIdTLV = lldp.getSystemNameId();
            if (systemIdTLV != null) {
                String srcNodeIdString = new String(systemIdTLV.getValue(), Charset.defaultCharset());
                srcNodeId = new NodeId(srcNodeIdString);
            } else {
                throw new Exception("Node id wasn't specified via systemNameId in LLDP packet.");
            }
            final LLDPTLV nodeConnectorIdLldptlv = lldp.getCustomTLV(LLDPTLV.createPortSubTypeCustomTLVKey());
            if (nodeConnectorIdLldptlv != null) {
                srcNodeConnectorId = new NodeConnectorId(LLDPTLV.getCustomString(nodeConnectorIdLldptlv.getValue(), nodeConnectorIdLldptlv.getLength()));
            } else {
                throw new Exception("Node connector wasn't specified via Custom TLV in LLDP packet.");
            }
            if (useExtraAuthenticatorCheck) {
                boolean secure = checkExtraAuthenticator(lldp, srcNodeConnectorId);
                if (!secure) {
                    LOG.warn("SECURITY ALERT: there is probably a LLDP spoofing attack in progress.");
                    throw new Exception("Attack. LLDP packet with inconsistent extra authenticator field was received.");
                }
            }
            InstanceIdentifier<NodeConnector> srcInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(srcNodeId)).child(NodeConnector.class, new NodeConnectorKey(srcNodeConnectorId)).toInstance();
            nodeConnectorRef = new NodeConnectorRef(srcInstanceId);
        } catch (Exception e) {
            LOG.debug("Caught exception while parsing out lldp optional and custom fields", e);
        }
    }
    return nodeConnectorRef;
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) BufferException(org.opendaylight.openflowplugin.libraries.liblldp.BufferException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) LLDP(org.opendaylight.openflowplugin.libraries.liblldp.LLDP) Ethernet(org.opendaylight.openflowplugin.libraries.liblldp.Ethernet) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) LLDPTLV(org.opendaylight.openflowplugin.libraries.liblldp.LLDPTLV)

Example 43 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project lispflowmapping by opendaylight.

the class AuthenticationKeyDataListener method onDataTreeChanged.

@Override
public synchronized void onDataTreeChanged(Collection<DataTreeModification<AuthenticationKey>> changes) {
    for (DataTreeModification<AuthenticationKey> change : changes) {
        final DataObjectModification<AuthenticationKey> mod = change.getRootNode();
        if (ModificationType.DELETE == mod.getModificationType()) {
            final AuthenticationKey authKey = mod.getDataBefore();
            LOG.trace("Received deleted data");
            LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
            LOG.trace("Value: {}", authKey);
            final AuthenticationKey convertedAuthKey = convertToBinaryIfNecessary(authKey);
            akdb.removeAuthenticationKey(convertedAuthKey.getEid());
            updatedEntries.put(convertedAuthKey.getEid(), System.currentTimeMillis());
        } else if (ModificationType.WRITE == mod.getModificationType() || ModificationType.SUBTREE_MODIFIED == mod.getModificationType()) {
            if (ModificationType.WRITE == mod.getModificationType()) {
                LOG.trace("Received created data");
            } else {
                LOG.trace("Received updated data");
            }
            // Process newly created or updated authentication keys
            final AuthenticationKey authKey = mod.getDataAfter();
            LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
            LOG.trace("Value: {}", authKey);
            final AuthenticationKey convertedAuthKey = convertToBinaryIfNecessary(authKey);
            akdb.addAuthenticationKey(convertedAuthKey.getEid(), convertedAuthKey.getMappingAuthkey());
            updatedEntries.put(convertedAuthKey.getEid(), System.currentTimeMillis());
        } else {
            LOG.warn("Ignoring unhandled modification type {}", mod.getModificationType());
        }
    }
}
Also used : AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey)

Example 44 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTestUtil method getDefaultMapRequestBuilder.

/*
     * PACKETS CREATION METHODS
     *
     * In general we return "Builders" so that the caller can customize the fields, but that means it also needs to
     * call .build() on the received objects.
     */
/* Map-Request */
/**
 * Create a default MapRequestBuilder object.
 *
 * @param eid the requested EID
 * @return the MapRequestBuilder object
 */
static MapRequestBuilder getDefaultMapRequestBuilder(Eid eid) {
    MapRequestBuilder mrBuilder = new MapRequestBuilder().setAuthoritative(false).setEidItem(new ArrayList<>()).setItrRloc(new ArrayList<>()).setMapDataPresent(true).setNonce((long) 4).setPitr(false).setProbe(false).setSmr(false).setSmrInvoked(false).setSourceEid(new SourceEidBuilder().setEid(DEFAULT_IPV4_EID).build()).setItrRloc(getDefaultItrRlocList(DEFAULT_IPV4_ITR_RLOC));
    mrBuilder.getEidItem().add(new EidItemBuilder().setEid(eid).build());
    return mrBuilder;
}
Also used : SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) ArrayList(java.util.ArrayList) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder) EidItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)

Example 45 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTestUtil method getDefaultMappingRecordBuilder.

/**
 * Create a default MappingRecordBuilder object.
 *
 * @param eid EID for the mapping record, if null, a default will be added
 * @param rlocs RLOCs for the mapping record, if null, no locator record will be added
 * @return the MappingRecordBuilder object
 */
static MappingRecordBuilder getDefaultMappingRecordBuilder(Eid eid, List<Rloc> rlocs) {
    if (eid == null) {
        eid = DEFAULT_IPV4_EID_PREFIX;
        LOG.warn("getDefaultMappingRecordBuilder(): null EID received, using the default {}", DEFAULT_IPV4_EID_STRING);
    }
    MappingRecordBuilder mrb = new MappingRecordBuilder().setEid(eid).setAction(MappingRecord.Action.NoAction).setAuthoritative(false).setLocatorRecord(new ArrayList<>()).setMapVersion((short) 0).setRecordTtl(60).setSiteId(DEFAULT_SITE_ID).setXtrId(DEFAULT_XTR_ID).setTimestamp(System.currentTimeMillis());
    // We want to allow for empty locator records, so we only add one if rloc is not null
    if (rlocs != null) {
        for (Rloc rloc : rlocs) {
            mrb.getLocatorRecord().add(getDefaultLocatorBuilder(rloc).build());
        }
    }
    return mrb;
}
Also used : MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) ArrayList(java.util.ArrayList) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)

Aggregations

BigInteger (java.math.BigInteger)26 ArrayList (java.util.ArrayList)20 ExecutionException (java.util.concurrent.ExecutionException)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)13 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)13 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)10 List (java.util.List)10 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)10 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)9 UnknownHostException (java.net.UnknownHostException)8 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)8 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)8 Optional (com.google.common.base.Optional)7 Test (org.junit.Test)7 PacketException (org.opendaylight.openflowplugin.libraries.liblldp.PacketException)7 Collections (java.util.Collections)6 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)6 FutureCallback (com.google.common.util.concurrent.FutureCallback)5 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)5 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)5