Search in sources :

Example 1 with OpenMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenMessage in project bgpcep by opendaylight.

the class AbstractPCEPSessionNegotiator method startNegotiationWithOpen.

private void startNegotiationWithOpen() {
    this.localPrefs = getInitialProposal();
    final OpenMessage m = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder().setOpenMessage(new OpenMessageBuilder().setOpen(this.localPrefs).build()).build();
    this.sendMessage(m);
    this.state = State.OPEN_WAIT;
    scheduleFailTimer();
    LOG.info("PCEP session with {} started, sent proposal {}", this.channel, this.localPrefs);
}
Also used : OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder) OpenMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage) OpenMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessageBuilder)

Example 2 with OpenMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenMessage in project bgpcep by opendaylight.

the class PCEPSessionImpl method handleMessage.

/**
 * Handles incoming message. If the session is up, it notifies the user. The user is notified about every message
 * except KeepAlive.
 *
 * @param msg incoming message
 */
public synchronized void handleMessage(final Message msg) {
    if (this.closed.get()) {
        LOG.debug("PCEP Session {} is already closed, skip handling incoming message {}", this, msg);
        return;
    }
    // Update last reception time
    this.lastMessageReceivedAt = TICKER.read();
    this.sessionState.updateLastReceivedMsg();
    if (!(msg instanceof KeepaliveMessage)) {
        LOG.debug("PCEP message {} received.", msg);
    }
    // Internal message handling. The user does not see these messages
    if (msg instanceof KeepaliveMessage) {
    // Do nothing, the timer has been already reset
    } else if (msg instanceof OpenMessage) {
        this.sendErrorMessage(PCEPErrors.ATTEMPT_2ND_SESSION);
    } else if (msg instanceof CloseMessage) {
        /*
             * Session is up, we are reporting all messages to user. One notable
             * exception is CLOSE message, which needs to be converted into a
             * session DOWN event.
             */
        close();
        this.listener.onSessionTerminated(this, new PCEPCloseTermination(TerminationReason.forValue(((CloseMessage) msg).getCCloseMessage().getCClose().getReason())));
    } else {
        // This message needs to be handled by the user
        if (msg instanceof PcerrMessage) {
            this.sessionState.setLastReceivedError(msg);
        }
        this.listener.onMessage(this, msg);
    }
}
Also used : PCEPCloseTermination(org.opendaylight.protocol.pcep.PCEPCloseTermination) OpenMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage) PcerrMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage) CloseMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseMessage) KeepaliveMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage)

Example 3 with OpenMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenMessage in project bgpcep by opendaylight.

the class FiniteStateMachineTest method testErrorOneTwo.

/**
 * OpenWait timer expired.
 *
 * @throws InterruptedException exception
 */
@Test
public void testErrorOneTwo() throws Exception {
    this.serverSession.channelActive(null);
    assertEquals(1, this.msgsSend.size());
    assertTrue(this.msgsSend.get(0) instanceof OpenMessage);
    checkEquals(() -> {
        for (final Notification m : this.msgsSend) {
            if (m instanceof Pcerr) {
                final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0);
                assertEquals(new Short((short) 1), obj.getErrorObject().getType());
                assertEquals(new Short((short) 2), obj.getErrorObject().getValue());
            }
        }
    });
}
Also used : Errors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors) PCEPErrors(org.opendaylight.protocol.pcep.spi.PCEPErrors) OpenMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage) Pcerr(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcerr) Notification(org.opendaylight.yangtools.yang.binding.Notification) Test(org.junit.Test)

Example 4 with OpenMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenMessage 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 5 with OpenMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenMessage in project bgpcep by opendaylight.

the class BmpMockUtil method createOpen.

private static OpenMessage createOpen(final Ipv4Address address) {
    final OpenBuilder msgBuilder = new OpenBuilder();
    msgBuilder.setBgpIdentifier(address);
    msgBuilder.setHoldTimer(HOLD_TIMER);
    msgBuilder.setMyAsNumber(ASN.getValue().intValue());
    msgBuilder.setVersion(PROTOCOL_VERSION);
    return msgBuilder.build();
}
Also used : ReceivedOpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.up.ReceivedOpenBuilder) OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenBuilder) SentOpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.up.SentOpenBuilder)

Aggregations

OpenMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage)4 ReceivedOpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.up.ReceivedOpenBuilder)2 SentOpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.up.SentOpenBuilder)2 Notification (org.opendaylight.yangtools.yang.binding.Notification)2 Preconditions (com.google.common.base.Preconditions)1 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)1 BGPParsingException (org.opendaylight.protocol.bgp.parser.BGPParsingException)1 BmpDeserializationException (org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException)1 PCEPCloseTermination (org.opendaylight.protocol.pcep.PCEPCloseTermination)1 PCEPErrors (org.opendaylight.protocol.pcep.spi.PCEPErrors)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)1 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenBuilder)1 OpenMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenMessage)1 PeerUpNotification (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerUpNotification)1 PeerUpNotificationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerUpNotificationBuilder)1 InformationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.up.InformationBuilder)1 StringInformationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.string.informations.StringInformationBuilder)1