--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisherBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.Peer.PeerDistinguisher;
+
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+public final class PeerPeerDistinguisherBuilder {
+
+ public static PeerDistinguisher getDefaultInstance(final String defaultValue) {
+ try {
+ final RouteDistinguisher rd = RouteDistinguisherBuilder.getDefaultInstance(defaultValue);
+ return new PeerDistinguisher(rd);
+ } catch (final IllegalArgumentException e) {
+ return new PeerDistinguisher(defaultValue.getBytes());
+ }
+ }
+
+}
import bgp-multiprotocol { prefix bgp-mp; revision-date 2013-09-19; }
import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
import ietf-yang-types { prefix yang; revision-date 2010-09-24; }
+ import bgp-types { prefix bgp-t; revision-date 2013-09-19; }
organization "Cisco Systems, Inc.";
contact "Milos Fabian <milfabia@cisco.com>";
description
"This module contains the base data model of a BMP messages.
- It rolls up the definitions contained in draft-ietf-grow-bmp-07.
+ It rolls up the definitions contained in RFC7854.
Copyright (c)2015 Cisco Systems, Inc. All rights reserved.
http://www.eclipse.org/legal/epl-v10.html";
reference
- "https://tools.ietf.org/html/draft-ietf-grow-bmp-07";
+ "https://tools.ietf.org/html/rfc7854";
revision "2015-05-12" {
description
"Redundant connection. The router has determined
that this connection is redundant with another one.";
}
+ enum permanently-closed {
+ value 4;
+ description
+ "Session permanently administratively closed,
+ will not be re-initiated. Monitoring station should reduce
+ (potentially to 0) the rate at which it attempts
+ reconnection to the monitored router.";
+ }
}
}
}
enum l3vpn {
value 1;
- description "L3 VPN Instance Peer.";
+ description "RD Instance Peer.";
+ }
+ enum local {
+ value 2;
+ description "Local Instance Peer";
}
}
}
value 2;
}
}
+ status deprecated;
}
typedef mirror-information-code {
If the peer is a L3VPN Instance Peer, it is set to the
route distinguisher of the particular L3VPN instance that the peer
belongs to.";
+ status deprecated;
+ }
+ leaf peer-distinguisher {
+ type union {
+ type bgp-t:route-distinguisher;
+ type binary {
+ length 8;
+ }
+ }
+ description
+ "This field is present to distinguish peers that
+ belong to one address domain from the other.";
}
leaf address {
type inet:ip-address;
The rest of the data in a BMP message is dependent on the Message
Type field in the common header.";
reference
- "https://tools.ietf.org/html/draft-ietf-grow-bmp-07#section-4.2";
+ "https://tools.ietf.org/html/rfc7854#section-4.2";
}
grouping stat {
"The initiation message provides a means for the monitored router to
inform the monitoring station of its vendor, software version, and so on.";
reference
- "https://tools.ietf.org/html/draft-ietf-grow-bmp-07#section-4.3";
+ "https://tools.ietf.org/html/rfc7854#section-4.3";
}
notification termination-message {
"The termination message provides a way for a monitored router to
indicate why it is terminating a session.";
reference
- "https://tools.ietf.org/html/draft-ietf-grow-bmp-07#section-4.4";
+ "https://tools.ietf.org/html/rfc7854#section-4.5";
}
notification route-monitoring-message {
ADJ-RIBs-In. They are also used for ongoing monitoring of received
advertisements and withdraws.";
reference
- "https://tools.ietf.org/html/draft-ietf-grow-bmp-07#section-4.5";
+ "https://tools.ietf.org/html/rfc7854#section-4.6";
}
notification route-mirroring-message {
"Route Mirroring messages are used for verbatim duplication of
messages as received.";
reference
- "https://tools.ietf.org/html/draft-ietf-grow-bmp-15#section-4.7";
+ "https://tools.ietf.org/html/rfc7854#section-4.7";
}
notification stats-reports-message {
monitoring station to observe interesting events that occur on the
router.";
reference
- "https://tools.ietf.org/html/draft-ietf-grow-bmp-07#section-4.6";
+ "https://tools.ietf.org/html/rfc7854#section-4.8";
}
notification peer-down-notification {
"This message is used to indicate that a peering session was
terminated.";
reference
- "https://tools.ietf.org/html/draft-ietf-grow-bmp-07#section-4.7";
+ "https://tools.ietf.org/html/rfc7854#section-4.9";
}
notification peer-up-notification {
"The Peer Up message is used to indicate that a peering session has
come up (i.e., has transitioned into ESTABLISHED state).";
reference
- "https://tools.ietf.org/html/draft-ietf-grow-bmp-07#section-4.8";
+ "https://tools.ietf.org/html/rfc7854#section-4.10";
}
}
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
+import org.opendaylight.bgp.concepts.RouteDistinguisherUtil;
import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.protocol.util.Ipv4Util;
import org.opendaylight.protocol.util.Ipv6Util;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Timestamp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.AdjRibInType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.Peer.PeerDistinguisher;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.PeerType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.peer.header.PeerHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.peer.header.PeerHeaderBuilder;
protected final PeerHeader parsePerPeerHeader(final ByteBuf bytes) {
Preconditions.checkArgument(bytes.readableBytes() >= PER_PEER_HEADER_SIZE);
final PeerHeaderBuilder phBuilder = new PeerHeaderBuilder();
- phBuilder.setType(PeerType.forValue(bytes.readByte()));
+ final PeerType peerType = PeerType.forValue(bytes.readByte());
+ phBuilder.setType(peerType);
final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
phBuilder.setAdjRibInType(AdjRibInType.forValue(flags.get(L_FLAG_POS) ? 1 : 0));
phBuilder.setIpv4(!flags.get(V_FLAG_POS));
- if (phBuilder.getType().equals(PeerType.L3vpn)) {
- phBuilder.setDistinguisher(PeerDistinguisherUtil.parsePeerDistingisher(bytes));
- } else {
+ switch (peerType) {
+ case L3vpn:
+ phBuilder.setDistinguisher(PeerDistinguisherUtil.parsePeerDistingisher(bytes.slice()));
+ phBuilder.setPeerDistinguisher(new PeerDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(bytes)));
+ break;
+ case Local:
+ phBuilder.setPeerDistinguisher(new PeerDistinguisher(ByteArray.readBytes(bytes, PEER_DISTINGUISHER_SIZE)));
+ break;
+ case Global:
+ default:
bytes.skipBytes(PEER_DISTINGUISHER_SIZE);
+ break;
}
if (phBuilder.isIpv4()) {
bytes.skipBytes(Ipv6Util.IPV6_LENGTH - Ipv4Util.IP4_LENGTH);
protected void serializePerPeerHeader(final PeerHeader peerHeader, final ByteBuf output) {
Preconditions.checkArgument(peerHeader != null, "Per-peer header cannot be null.");
- output.writeByte(peerHeader.getType().getIntValue());
+ final PeerType peerType = peerHeader.getType();
+ output.writeByte(peerType.getIntValue());
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(L_FLAG_POS, peerHeader.getAdjRibInType().getIntValue() == 0 ? false : true);
flags.set(V_FLAG_POS, !peerHeader.isIpv4());
flags.toByteBuf(output);
- if (peerHeader.getType().equals(PeerType.L3vpn)) {
- PeerDistinguisherUtil.serializePeerDistinguisher(peerHeader.getDistinguisher(), output);
- } else {
+ final PeerDistinguisher peerDistinguisher = peerHeader.getPeerDistinguisher();
+ switch (peerType) {
+ case L3vpn:
+ if (peerDistinguisher.getRouteDistinguisher() != null) {
+ RouteDistinguisherUtil.serializeRouteDistinquisher(peerDistinguisher.getRouteDistinguisher(), output);
+ } else {
+ PeerDistinguisherUtil.serializePeerDistinguisher(peerHeader.getDistinguisher(), output);
+ }
+ break;
+ case Local:
+ output.writeBytes(peerDistinguisher.getBinary());
+ break;
+ case Global:
+ default:
output.writeZero(PEER_DISTINGUISHER_SIZE);
+ break;
}
if (peerHeader.isIpv4()) {
output.writeZero(Ipv6Util.IPV6_LENGTH - Ipv4Util.IP4_LENGTH);
* @see <a href="https://tools.ietf.org/html/rfc4364#section-4.2">https://tools.ietf.org/html/rfc4364#section-4.2</a>
*
*/
+@Deprecated
public final class PeerDistinguisherUtil {
private static final class PeerDistinguisher {
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.Before;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Timestamp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RdTwoOctetAs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.AdjRibInType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.DistinguisherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.Peer.PeerDistinguisher;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.PeerType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.PeerUpNotification;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.PeerUpNotificationBuilder;
* Created by cgasparini on 18.5.2015.
*/
public class AbstractBmpPerPeerMessageParserTest {
+ private static final String RD = "5:3";
protected BGPExtensionProviderContext ctx;
private AbstractBmpPerPeerMessageParser<?> parser;
final byte[] ipv6MsgWithDistinguishergBytes = {
final PeerHeaderBuilder phBuilder = new PeerHeaderBuilder();
phBuilder.setType(PeerType.L3vpn);
- final Distinguisher dist = new DistinguisherBuilder().setDistinguisher("5:3").setDistinguisherType(DistinguisherType.Type0).build();
+ final Distinguisher dist = new DistinguisherBuilder().setDistinguisher(RD).setDistinguisherType(DistinguisherType.Type0).build();
phBuilder.setDistinguisher(dist);
+ 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.setTimestampSec(new Timestamp(0L));
phBuilder.setTimestampMicro(new Timestamp(0L));
- assertEquals(perHeader, phBuilder.build());
+ assertEquals(phBuilder.build(), perHeader);
final ByteBuf aggregator = Unpooled.buffer();
phBuilder.setTimestampSec(null);