use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project netvirt by opendaylight.
the class ConfigureBgpCli method addNeighbor.
protected void addNeighbor() {
if (!validateAsNumber(asNumber)) {
printAddNeighborHelp();
return;
}
boolean validIp = validateIp(ip);
if (!validIp) {
session.getConsole().println("invalid neighbor ip");
printAddNeighborHelp();
return;
}
TcpMd5SignaturePasswordType md5secret = null;
if (md5passwordOption != null) {
try {
md5secret = new TcpMd5SignaturePasswordType(md5passwordOption);
} catch (IllegalArgumentException e) {
session.getConsole().println(new StringBuilder("invalid MD5 password: ").append(e.getMessage()).toString());
printAddNeighborHelp();
return;
}
}
if (sourceIp != null) {
validIp = validateIp(sourceIp);
if (!validIp) {
session.getConsole().println("invalid source ip");
printAddNeighborHelp();
return;
}
}
if (ebgpMultihops != null) {
try {
long val = Long.parseLong(ebgpMultihops);
if (val < 1 || val > 255) {
session.getConsole().println("invalid ebgpMultihops number , valid range [1,255] ");
printAddNeighborHelp();
return;
}
} catch (NumberFormatException e) {
session.getConsole().println("invalid ebgpMultihops number, valid range [1-255]");
printAddNeighborHelp();
return;
}
}
if (addressFamily != null) {
try {
af_safi.valueOf(addressFamily);
} catch (IllegalArgumentException e) {
session.getConsole().println("invalid addressFamily valid values SAFI_IPV4_LABELED_UNICAST | SAFI_MPLS_VPN");
printAddNeighborHelp();
return;
}
}
if (getAsNumber(ip) != -1) {
session.getConsole().println("neighbor with ip " + ip + " already exists");
return;
}
bgpManager.addNeighbor(ip, Long.parseLong(asNumber), md5secret);
if (addressFamily != null) {
bgpManager.addAddressFamily(ip, af_afi.AFI_IP, af_safi.valueOf(addressFamily));
}
if (ebgpMultihops != null) {
bgpManager.addEbgpMultihop(ip, Integer.parseInt(ebgpMultihops));
}
if (sourceIp != null) {
bgpManager.addUpdateSource(ip, sourceIp);
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project netvirt by opendaylight.
the class BgpAlarms method init.
public void init() {
alarmAgent.registerMbean();
if (bgpMgr.getConfig() != null) {
List<Neighbors> nbrs = bgpMgr.getConfig().getNeighbors();
if (nbrs != null) {
for (Neighbors nbr : nbrs) {
LOG.trace("Clearing Neighbor DOWN alarm at the startup for Neighbor {}", nbr.getAddress().getValue());
clearBgpNbrDownAlarm(nbr.getAddress().getValue());
}
}
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project netvirt by opendaylight.
the class Ipv6PktHandlerTest method testonPacketReceivedNeighborSolicitationWithInvalidPayload.
@Test
public void testonPacketReceivedNeighborSolicitationWithInvalidPayload() throws Exception {
// incorrect checksum
pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
"33 33 FF F5 00 00", // Source MAC
"00 01 02 03 04 05", // IPv6
"86 DD", // Version 6, traffic class E0, no flowlabel
"6E 00 00 00", // Payload length
"00 18", // Next header is ICMPv6
"3A", // Hop limit
"FF", // Source IP
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 neighbor solicitation
"87", // Code
"00", // Checksum (invalid, should be 67 3C)
"67 3E", // ICMPv6 message body
"00 00 00 00", // Target
"FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).build());
// wait on this thread until the async job is completed in the packet handler.
waitForPacketProcessing();
verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
// unavailable ip
when(ifMgrInstance.obtainV6Interface(any())).thenReturn(null);
counter = pktHandler.getPacketProcessedCounter();
pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
"33 33 FF F5 00 00", // Source MAC
"00 01 02 03 04 05", // IPv6
"86 DD", // Version 6, traffic class E0, no flowlabel
"6E 00 00 00", // Payload length
"00 18", // Next header is ICMPv6
"3A", // Hop limit
"FF", // Source IP
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 neighbor solicitation
"87", // Code
"00", // Checksum (valid)
"67 3C", // ICMPv6 message body
"00 00 00 00", // Target
"FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).build());
// wait on this thread until the async job is completed in the packet handler.
waitForPacketProcessing();
verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project netvirt by opendaylight.
the class Ipv6NeighborSolicitation method transmitNeighborSolicitation.
public boolean transmitNeighborSolicitation(BigInteger dpnId, NodeConnectorRef nodeRef, MacAddress srcMacAddress, Ipv6Address srcIpv6Address, Ipv6Address targetIpv6Address) {
byte[] txPayload = frameNeighborSolicitationRequest(srcMacAddress, srcIpv6Address, targetIpv6Address);
NodeConnectorRef nodeConnectorRef = MDSALUtil.getNodeConnRef(dpnId, "0xfffffffd");
TransmitPacketInput input = new TransmitPacketInputBuilder().setPayload(txPayload).setNode(new NodeRef(InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId))).toInstance())).setEgress(nodeRef).setIngress(nodeConnectorRef).build();
// Tx the packet out of the controller.
LOG.debug("Transmitting the Neighbor Solicitation packet out on {}", dpnId);
JdkFutures.addErrorLogging(packetService.transmitPacket(input), LOG, "transmitPacket");
return true;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project bgpcep by opendaylight.
the class NeighborStateCliUtilsTest method testFullNeighborStateCli.
@Test
public void testFullNeighborStateCli() throws IOException {
final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder builder = new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder();
builder.addAugmentation(NeighborAfiSafiStateAugmentation.class, new NeighborAfiSafiStateAugmentationBuilder().setActive(true).setPrefixes(new PrefixesBuilder().setInstalled(1L).setReceived(1L).setSent(2L).build()).build());
final AfiSafi afiSafi = new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).setState(builder.build()).build();
final StateBuilder stateBuilder = new StateBuilder();
stateBuilder.addAugmentation(NeighborStateAugmentation.class, new NeighborStateAugmentationBuilder().setSupportedCapabilities(Collections.singletonList(ADDPATHS.class)).setSessionState(BgpNeighborState.SessionState.ACTIVE).build());
final Received received = new ReceivedBuilder().setNOTIFICATION(BigInteger.ONE).setUPDATE(BigInteger.TEN).build();
final Sent sent = new SentBuilder().setNOTIFICATION(BigInteger.TEN).setUPDATE(BigInteger.ONE).build();
stateBuilder.addAugmentation(BgpNeighborStateAugmentation.class, new BgpNeighborStateAugmentationBuilder().setMessages(new MessagesBuilder().setReceived(received).setSent(sent).build()).build());
final Transport transport = new TransportBuilder().setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.StateBuilder().addAugmentation(NeighborTransportStateAugmentation.class, new NeighborTransportStateAugmentationBuilder().setRemoteAddress(NEIGHBOR_IP_ADDRESS).setLocalPort(new PortNumber(1234)).setRemotePort(new PortNumber(4321)).build()).build()).build();
final Timers timers = new TimersBuilder().setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers.StateBuilder().addAugmentation(NeighborTimersStateAugmentation.class, new NeighborTimersStateAugmentationBuilder().setNegotiatedHoldTime(BigDecimal.TEN).setUptime(new Timeticks(600L)).build()).build()).build();
final Neighbor neighbor = new NeighborBuilder().setState(stateBuilder.build()).setAfiSafis(new AfiSafisBuilder().setAfiSafi(Collections.singletonList(afiSafi)).build()).setTransport(transport).setTimers(timers).build();
NeighborStateCliUtils.displayNeighborOperationalState(NEIGHBOR_ADDRESS, neighbor, this.stream);
final String expected = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("neighbor.txt"), UTF8);
assertEquals(expected, this.output.toString());
}
Aggregations