Search in sources :

Example 76 with IpAddress

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project bgpcep by opendaylight.

the class FSExtendedCommunitiesTest method testRedirectIpv4NhParser.

@Test
public void testRedirectIpv4NhParser() throws BGPDocumentedException, BGPParsingException {
    final RedirectIpNhExtendedCommunityCase redirect = new RedirectIpNhExtendedCommunityCaseBuilder().setRedirectIpNhExtendedCommunity(new RedirectIpNhExtendedCommunityBuilder().setNextHopAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).setCopy(true).build()).build();
    final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
    final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_NH_IPV4));
    Assert.assertEquals(expected, parsed);
}
Also used : RedirectIpNhExtendedCommunityCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCaseBuilder) RedirectIpNhExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCase) ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ExtendedCommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder) RedirectIpNhExtendedCommunityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.redirect.ip.nh.extended.community.RedirectIpNhExtendedCommunityBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 77 with IpAddress

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project bgpcep by opendaylight.

the class AbstractBGPSessionNegotiator method handleOpen.

private synchronized void handleOpen(final Open openObj) {
    final IpAddress remoteIp = getRemoteIp();
    final BGPSessionPreferences preferences = this.registry.getPeerPreferences(remoteIp);
    try {
        final BGPSessionListener peer = this.registry.getPeer(remoteIp, getSourceId(openObj, preferences), getDestinationId(openObj, preferences), openObj);
        sendMessage(new KeepaliveBuilder().build());
        this.state = State.OPEN_CONFIRM;
        this.session = new BGPSessionImpl(peer, this.channel, openObj, preferences, this.registry);
        this.session.setChannelExtMsgCoder(openObj);
        LOG.debug("Channel {} moved to OPEN_CONFIRM state with remote proposal {}", this.channel, openObj);
    } catch (final BGPDocumentedException e) {
        LOG.warn("Channel {} negotiation failed", this.channel, e);
        negotiationFailed(e);
    }
}
Also used : BGPSessionListener(org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener) BGPSessionPreferences(org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) KeepaliveBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.KeepaliveBuilder)

Example 78 with IpAddress

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project bgpcep by opendaylight.

the class BmpMockUtil method createPeerUp.

static PeerUpNotification createPeerUp(final Ipv4Address peerIp, final InetAddress localAddress) {
    final PeerUpNotificationBuilder msgBuilder = new PeerUpNotificationBuilder();
    msgBuilder.setLocalAddress(new IpAddress(new Ipv4Address(localAddress.getHostAddress())));
    msgBuilder.setLocalPort(PEER_PORT);
    msgBuilder.setRemotePort(PEER_PORT);
    msgBuilder.setReceivedOpen(new ReceivedOpenBuilder(createOpen(peerIp)).build());
    msgBuilder.setSentOpen(new SentOpenBuilder(createOpen(new Ipv4Address(localAddress.getHostAddress()))).build());
    msgBuilder.setPeerHeader(createPeerHeader(peerIp, AdjRibInType.PrePolicy));
    return msgBuilder.build();
}
Also used : ReceivedOpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.up.ReceivedOpenBuilder) SentOpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.up.SentOpenBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PeerUpNotificationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerUpNotificationBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 79 with IpAddress

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project bgpcep by opendaylight.

the class PeerUpHandler method parseMessageBody.

@Override
public Notification parseMessageBody(final ByteBuf bytes) throws BmpDeserializationException {
    final PeerUpNotificationBuilder peerUpNot = new PeerUpNotificationBuilder().setPeerHeader(parsePerPeerHeader(bytes));
    if (peerUpNot.getPeerHeader().isIpv4()) {
        bytes.skipBytes(Ipv6Util.IPV6_LENGTH - Ipv4Util.IP4_LENGTH);
        peerUpNot.setLocalAddress(new IpAddress(Ipv4Util.addressForByteBuf(bytes)));
    } else {
        peerUpNot.setLocalAddress(new IpAddress(Ipv6Util.addressForByteBuf(bytes)));
    }
    peerUpNot.setLocalPort(new PortNumber(bytes.readUnsignedShort()));
    peerUpNot.setRemotePort(new PortNumber(bytes.readUnsignedShort()));
    try {
        final Notification opSent = this.msgRegistry.parseMessage(bytes.readSlice(getBgpMessageLength(bytes)), null);
        requireNonNull(opSent, "Error on parse Sent OPEN Message, Sent OPEN Message is null");
        Preconditions.checkArgument(opSent instanceof OpenMessage, "An instance of OpenMessage notification is required");
        final OpenMessage sent = (OpenMessage) opSent;
        final Notification opRec = this.msgRegistry.parseMessage(bytes.readSlice(getBgpMessageLength(bytes)), null);
        requireNonNull(opRec, "Error on parse Received  OPEN Message, Received  OPEN Message is null");
        Preconditions.checkArgument(opRec instanceof OpenMessage, "An instance of OpenMessage notification is required");
        final OpenMessage received = (OpenMessage) opRec;
        peerUpNot.setSentOpen(new SentOpenBuilder(sent).build());
        peerUpNot.setReceivedOpen(new ReceivedOpenBuilder(received).build());
        final InformationBuilder infos = new InformationBuilder();
        if (bytes.isReadable()) {
            parseTlvs(infos, bytes);
            peerUpNot.setInformation(infos.build());
        }
    } catch (final BGPDocumentedException | BGPParsingException e) {
        throw new BmpDeserializationException("Error while parsing BGP Open Message.", e);
    }
    return peerUpNot.build();
}
Also used : ReceivedOpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.up.ReceivedOpenBuilder) StringInformationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.string.informations.StringInformationBuilder) InformationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.up.InformationBuilder) OpenMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenMessage) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) SentOpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.up.SentOpenBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) BGPParsingException(org.opendaylight.protocol.bgp.parser.BGPParsingException) BmpDeserializationException(org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) PeerUpNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerUpNotification) Notification(org.opendaylight.yangtools.yang.binding.Notification) PeerUpNotificationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerUpNotificationBuilder)

Example 80 with IpAddress

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.IpAddress in project bgpcep by opendaylight.

the class AbstractBmpPerPeerMessageParserTest method testPerPeerHeaderIpv6.

@Test
public void testPerPeerHeaderIpv6() {
    final PeerHeader perHeader = AbstractBmpPerPeerMessageParser.parsePerPeerHeader(Unpooled.wrappedBuffer(this.ipv6MsgWithDistinguishergBytes));
    final PeerHeaderBuilder phBuilder = new PeerHeaderBuilder();
    phBuilder.setType(PeerType.L3vpn);
    phBuilder.setPeerDistinguisher(new PeerDistinguisher(new RouteDistinguisher(new RdTwoOctetAs("0:" + RD))));
    phBuilder.setAdjRibInType(AdjRibInType.forValue(1));
    phBuilder.setIpv4(false);
    phBuilder.setAddress(new IpAddress(new Ipv6Address("2001::1")));
    phBuilder.setAs(new AsNumber(168L));
    phBuilder.setBgpId(new Ipv4Address("1.1.1.2"));
    phBuilder.setTimestampSec(new Timestamp(0L));
    phBuilder.setTimestampMicro(new Timestamp(0L));
    assertEquals(phBuilder.build(), perHeader);
    final ByteBuf aggregator = Unpooled.buffer();
    phBuilder.setTimestampSec(null);
    phBuilder.setTimestampMicro(null);
    this.parser.serializePerPeerHeader(phBuilder.build(), aggregator);
    assertArrayEquals(this.ipv6MsgWithDistinguishergBytes, ByteArray.getAllBytes(aggregator));
}
Also used : RdTwoOctetAs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RdTwoOctetAs) PeerHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.header.PeerHeader) RouteDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PeerHeaderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.header.PeerHeaderBuilder) ByteBuf(io.netty.buffer.ByteBuf) PeerDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Peer.PeerDistinguisher) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) Timestamp(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timestamp) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Aggregations

IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)232 ArrayList (java.util.ArrayList)71 Test (org.junit.Test)67 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)67 BigInteger (java.math.BigInteger)47 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)30 ByteBuf (io.netty.buffer.ByteBuf)28 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)27 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)22 InetAddress (java.net.InetAddress)19 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)19 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)19 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)18 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)18 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)17 List (java.util.List)14 ExecutionException (java.util.concurrent.ExecutionException)14 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)12 Inet6Address (java.net.Inet6Address)11 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)11