Java Code Examples for org.onlab.packet.IpAddress#valueOf()
The following examples show how to use
org.onlab.packet.IpAddress#valueOf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FpmWebResource.java From onos with Apache License 2.0 | 6 votes |
private ObjectNode getFpmPeerAcceptFlagInfoJsonOutput(String address) { FpmInfoService fpmService = get(FpmInfoService.class); ObjectNode fpmNode = mapper().createObjectNode(); Map<FpmPeer, FpmPeerInfo> fpmPeers = fpmService.peers(); IpAddress peerAddress = IpAddress.valueOf(address); fpmPeers.entrySet().stream() .filter(peer -> peer.getKey().address().equals(peerAddress)) .map(Map.Entry::getValue) .forEach(fpmPeerInfo -> { fpmPeerInfo.connections().forEach(connection -> { fpmNode.put(ACCEPT_ROUTES, connection.isAcceptRoutes()); }); }); return fpmNode; }
Example 2
Source File: MulticastRouteWebResource.java From onos with Apache License 2.0 | 6 votes |
/** * Create a sink for a multicast route. * Creates a new sink for an existing multicast route. * * @onos.rsModel McastSinkPost * @param group group IP address * @param source source IP address * @param stream sink JSON * @return status of the request - CREATED if the JSON is correct, * BAD_REQUEST if the JSON is invalid */ @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("sinks/{group}/{source}") public Response addSinks(@PathParam("group") String group, @PathParam("source") String source, InputStream stream) { MulticastRouteService service = get(MulticastRouteService.class); try { McastRoute route = new McastRoute(IpAddress.valueOf(source), IpAddress.valueOf(group), McastRoute.Type.STATIC); ObjectNode jsonTree = readTreeFromStream(mapper(), stream); jsonTree.path("sinks").forEach(node -> { ConnectPoint sink = ConnectPoint.deviceConnectPoint(node.asText()); service.addSink(route, sink); }); } catch (IOException ex) { throw new IllegalArgumentException(ex); } return Response .created(URI.create("")) .build(); }
Example 3
Source File: PIMAddrUnicast.java From onos with Apache License 2.0 | 6 votes |
public PIMAddrUnicast deserialize(ByteBuffer bb) throws DeserializationException { // Assume IPv4 for check length until we read the encoded family. checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_UNICAST_IPV4_BYTE_LENGTH); this.family = bb.get(); // If we have IPv6 we need to ensure we have adequate buffer space. if (this.family != PIM.ADDRESS_FAMILY_IP4 && this.family != PIM.ADDRESS_FAMILY_IP6) { throw new DeserializationException("Invalid address family: " + this.family); } else if (this.family == PIM.ADDRESS_FAMILY_IP6) { // Subtract -1 from ENC_UNICAST_IPv6 BYTE_LENGTH because we read one byte for family previously. checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_UNICAST_IPV6_BYTE_LENGTH - 1); } this.encType = bb.get(); if (this.family == PIM.ADDRESS_FAMILY_IP4) { this.addr = IpAddress.valueOf(bb.getInt()); } else if (this.family == PIM.ADDRESS_FAMILY_IP6) { this.addr = Ip6Address.valueOf(bb.array(), 2); } return this; }
Example 4
Source File: Ovs.java From onos with Apache License 2.0 | 5 votes |
@Override public void process(WorkflowContext context) throws WorkflowException { IpAddress mgmtIp = IpAddress.valueOf(strMgmtIp); TpPort ovsdbPort = TpPort.tpPort(intOvsdbPort); OvsdbController ovsdbController = context.getService(OvsdbController.class); context.waitCompletion(DeviceEvent.class, OVSDB_DEVICE_PREFIX.concat(strMgmtIp), () -> ovsdbController.connect(mgmtIp, ovsdbPort), TIMEOUT_DEVICE_CREATION_MS ); }
Example 5
Source File: AddPeerCommand.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { peerAddress = IpAddress.valueOf(ip); NetworkConfigService configService = get(NetworkConfigService.class); CoreService coreService = get(CoreService.class); ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID); BgpConfig config = configService.getConfig(appId, BgpConfig.class); if (config == null || config.bgpSpeakers().isEmpty()) { print(NO_CONFIGURATION); return; } BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name); if (speaker == null) { print(SPEAKER_NOT_FOUND, name); return; } else { if (speaker.isConnectedToPeer(peerAddress)) { return; // Peering already exists. } } InterfaceService interfaceService = get(InterfaceService.class); if (interfaceService.getMatchingInterface(peerAddress) == null) { print(NO_INTERFACE, ip); return; } addPeerToSpeakerConf(config); configService.applyConfig(appId, BgpConfig.class, config.node()); print(PEER_ADD_SUCCESS); }
Example 6
Source File: LispAppDataLcafAddressTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void testConstruction() { LispAppDataLcafAddress appDataLcafAddress = address1; LispAfiAddress ipv4Address = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); assertThat(appDataLcafAddress.getProtocol(), is((byte) 0x01)); assertThat(appDataLcafAddress.getIpTos(), is(10)); assertThat(appDataLcafAddress.getLocalPortLow(), is((short) 1)); assertThat(appDataLcafAddress.getLocalPortHigh(), is((short) 255)); assertThat(appDataLcafAddress.getRemotePortLow(), is((short) 2)); assertThat(appDataLcafAddress.getRemotePortHigh(), is((short) 254)); assertThat(appDataLcafAddress.getAddress(), is(ipv4Address)); }
Example 7
Source File: PIMAddrGroup.java From onos with Apache License 2.0 | 5 votes |
/** * Deserialze from a ByteBuffer. * * @param bb the ByteBuffer * @return an encoded PIM group address * @throws DeserializationException if unable to deserialize the packet data */ public PIMAddrGroup deserialize(ByteBuffer bb) throws DeserializationException { /* * We need to verify that we have enough buffer space. First we'll assume that * we are decoding an IPv4 address. After we read the first by (address family), * we'll determine if we actually need more buffer space for an IPv6 address. */ checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_GROUP_IPV4_BYTE_LENGTH); this.family = bb.get(); if (family != PIM.ADDRESS_FAMILY_IP4 && family != PIM.ADDRESS_FAMILY_IP6) { throw new DeserializationException("Illegal IP version number: " + family + "\n"); } else if (family == PIM.ADDRESS_FAMILY_IP6) { // Check for one less by since we have already read the first byte of the packet. checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_GROUP_IPV6_BYTE_LENGTH - 1); } this.encType = bb.get(); this.reserved = bb.get(); if ((this.reserved & 0x80) != 0) { this.bBit = true; } if ((this.reserved & 0x01) != 0) { this.zBit = true; } // Remove the z and b bits from reserved this.reserved |= 0x7d; this.masklen = bb.get(); if (this.family == PIM.ADDRESS_FAMILY_IP4) { this.addr = IpAddress.valueOf(bb.getInt()); } else if (this.family == PIM.ADDRESS_FAMILY_IP6) { this.addr = Ip6Address.valueOf(bb.array(), 2); } return this; }
Example 8
Source File: DeviceSetControllersCommand.java From onos with Apache License 2.0 | 5 votes |
private ControllerInfo getControllerInfo(Annotations annotation, String s) { String[] data = s.split(":"); if (data.length != 3) { print("Wrong format of the controller %s, should be in the format <protocol>:<ip>:<port>", s); return null; } String type = data[0]; IpAddress ip = IpAddress.valueOf(data[1]); int port = Integer.parseInt(data[2]); if (annotation != null) { return new ControllerInfo(ip, port, type, annotation); } return new ControllerInfo(ip, port, type); }
Example 9
Source File: McastForwarding.java From onos with Apache License 2.0 | 5 votes |
public static McastRoute createStaticRoute(String source, String group) { checkNotNull(source, "Must provide a source"); checkNotNull(group, "Must provide a group"); IpAddress ipSource = IpAddress.valueOf(source); IpAddress ipGroup = IpAddress.valueOf(group); return createStaticcreateRoute(ipSource, ipGroup); }
Example 10
Source File: McastSourceDeleteCommand.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { MulticastRouteService mcastRouteManager = get(MulticastRouteService.class); // Clear all routes if ("*".equals(sAddr) && "*".equals(gAddr)) { mcastRouteManager.getRoutes().forEach(mcastRouteManager::remove); return; } // Removing/updating a specific entry IpAddress sAddrIp = null; // If the source Ip is * we want ASM so we leave it as null and the route will have it as an optional.empty() if (!sAddr.equals("*")) { sAddrIp = IpAddress.valueOf(sAddr); } McastRoute mRoute = new McastRoute(sAddrIp, IpAddress.valueOf(gAddr), McastRoute.Type.STATIC); // No specific connect points, we have to remove everything if (sourceList == null) { mcastRouteManager.remove(mRoute); printMcastRoute(D_FORMAT_MAPPING, mRoute); return; } // Otherwise we need to remove specific connect points if (!mcastRouteManager.getRoutes().contains(mRoute)) { print("Route is not present, store it first"); return; } for (String hostId : sourceList) { mcastRouteManager.removeSource(mRoute, HostId.hostId(hostId)); } printMcastRoute(U_FORMAT_MAPPING, mRoute); }
Example 11
Source File: OvsdbMirroringConfig.java From onos with Apache License 2.0 | 5 votes |
/** * OvsdbNodeId(IP) is used in the adaptor while DeviceId(ovsdb:IP) * is used in the core. So DeviceId need be changed to OvsdbNodeId. * * @param deviceId the device id in ovsdb:ip format * @return the ovsdb node id */ private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) { String[] splits = deviceId.toString().split(":"); if (splits == null || splits.length < 1) { return null; } IpAddress ipAddress = IpAddress.valueOf(splits[1]); return new OvsdbNodeId(ipAddress, 0); }
Example 12
Source File: McastShowHostCommand.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { // Get the service MulticastRouteService mcastService = get(MulticastRouteService.class); // Get the routes Set<McastRoute> routes = mcastService.getRoutes(); // Verify mcast group if (!isNullOrEmpty(gAddr)) { // Let's find the group IpAddress mcastGroup = IpAddress.valueOf(gAddr); McastRoute mcastRoute = routes.stream() .filter(route -> route.group().equals(mcastGroup)) .findAny().orElse(null); // If it exists if (mcastRoute != null) { prepareResult(mcastService, mcastRoute); } } else { routes.stream() .filter(mcastRoute -> mcastRoute.group().isIp4()) .sorted(Comparator.comparing(McastRoute::group)) .forEach(route -> { prepareResult(mcastService, route); }); routes.stream() .filter(mcastRoute -> mcastRoute.group().isIp6()) .sorted(Comparator.comparing(McastRoute::group)) .forEach(route -> { prepareResult(mcastService, route); }); } if (outputJson()) { print("%s", routesNode); } else { print("%s", routesBuilder.toString()); } }
Example 13
Source File: PcepClientImpl.java From onos with Apache License 2.0 | 5 votes |
@Override public final void setChannel(Channel channel) { this.channel = channel; final SocketAddress address = channel.getRemoteAddress(); if (address instanceof InetSocketAddress) { final InetSocketAddress inetAddress = (InetSocketAddress) address; final IpAddress ipAddress = IpAddress.valueOf(inetAddress.getAddress()); if (ipAddress.isIp4()) { channelId = ipAddress.toString() + ':' + inetAddress.getPort(); } else { channelId = '[' + ipAddress.toString() + "]:" + inetAddress.getPort(); } } }
Example 14
Source File: LispNatLcafAddressTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void testConstruction() { LispNatLcafAddress natLcafAddress = address1; LispIpv4Address globalEtrRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); LispIpv4Address msRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2")); LispIpv4Address privateEtrRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.3")); assertThat(natLcafAddress.getLength(), is((short) 0)); assertThat(natLcafAddress.getMsUdpPortNumber(), is((short) 80)); assertThat(natLcafAddress.getEtrUdpPortNumber(), is((short) 100)); assertThat(natLcafAddress.getGlobalEtrRlocAddress(), is(globalEtrRlocAddress1)); assertThat(natLcafAddress.getMsRlocAddress(), is(msRlocAddress1)); assertThat(natLcafAddress.getPrivateEtrRlocAddress(), is(privateEtrRlocAddress1)); }
Example 15
Source File: DefaultLispReferralTest.java From onos with Apache License 2.0 | 4 votes |
@Before public void setup() { ReferralBuilder builder1 = new DefaultReferralBuilder(); LispIpv4Address ipv4Address1 = new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS1)); referral1 = builder1 .withPriority((byte) 0x01) .withWeight((byte) 0x01) .withMulticastPriority((byte) 0x01) .withMulticastWeight((byte) 0x01) .withLocalLocator(true) .withRlocProbed(false) .withRouted(true) .withLocatorAfi(ipv4Address1) .build(); ReferralBuilder builder2 = new DefaultReferralBuilder(); sameAsReferral1 = builder2 .withPriority((byte) 0x01) .withWeight((byte) 0x01) .withMulticastPriority((byte) 0x01) .withMulticastWeight((byte) 0x01) .withLocalLocator(true) .withRlocProbed(false) .withRouted(true) .withLocatorAfi(ipv4Address1) .build(); ReferralBuilder builder3 = new DefaultReferralBuilder(); LispIpv4Address ipv4Address2 = new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS2)); referral2 = builder3 .withPriority((byte) 0x02) .withWeight((byte) 0x02) .withMulticastPriority((byte) 0x02) .withMulticastWeight((byte) 0x02) .withLocalLocator(false) .withRlocProbed(true) .withRouted(false) .withLocatorAfi(ipv4Address2) .build(); }
Example 16
Source File: BgpControllerImplTest.java From onos with Apache License 2.0 | 4 votes |
/** * Peer1 has Prefix NLRI (MpReach). */ @Test public void testBgpUpdateMessage8() throws InterruptedException { // Initiate the connections peer1.peerChannelHandler.asNumber = 200; peer1.peerChannelHandler.version = 4; peer1.peerChannelHandler.holdTime = 150; short afi = 16388; byte res = 0; byte safi = 71; bgpControllerImpl.getConfig().setLsCapability(true); BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi); peer1.peerChannelHandler.capabilityTlv.add(tempTlv1); peer1.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.20", 0)); TimeUnit.MILLISECONDS.sleep(1000); //Get peer1 BgpId bgpId = new BgpId(IpAddress.valueOf("127.0.0.20")); BgpPeerImpl peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId); LinkedList<BgpValueType> subTlvs = new LinkedList<>(); BgpValueType tlv = AutonomousSystemTlv.of(2222); subTlvs.add(tlv); tlv = BgpLSIdentifierTlv.of(33686018); subTlvs.add(tlv); byte[] isoNodeID = new byte[] {0x19, 0x21, 0x68, 0x07, 0x70, 0x01}; tlv = IsIsNonPseudonode.of(isoNodeID); subTlvs.add(tlv); NodeDescriptors nodeDes = new NodeDescriptors(subTlvs, (short) 0x1a, (short) 256); LinkedList<BgpValueType> prefixDescriptor = new LinkedList<>(); byte[] prefix = new byte[] {0x20, (byte) 0xc0, (byte) 0xa8, 0x4d, 0x01}; ChannelBuffer tempCb = ChannelBuffers.dynamicBuffer(); tempCb.writeBytes(prefix); tlv = IPReachabilityInformationTlv.read(tempCb, (short) 5); prefixDescriptor.add(tlv); BgpPrefixLSIdentifier key = new BgpPrefixLSIdentifier(nodeDes, prefixDescriptor); AdjRibIn adj = peer.adjRib(); //In Adj-RIB, prefixTree should contain specified key assertThat(adj.prefixTree().containsKey(key), is(true)); BgpLocalRibImpl obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRib(); //In Local-RIB, prefixTree should contain specified key assertThat(obj.prefixTree().containsKey(key), is(true)); }
Example 17
Source File: MastershipProxyManagerTest.java From onos with Apache License 2.0 | 4 votes |
@Test public void testProxyManager() throws Exception { TestClusterCommunicationServiceFactory clusterCommunicatorFactory = new TestClusterCommunicationServiceFactory(); NodeId a = NodeId.nodeId("a"); NodeId b = NodeId.nodeId("b"); DeviceId deviceId = DeviceId.deviceId("a"); Serializer serializer = Serializer.using(KryoNamespaces.BASIC); ProxyInterfaceImpl proxyInterface1 = new ProxyInterfaceImpl(); MastershipProxyManager proxyManager1 = new MastershipProxyManager(); proxyManager1.clusterService = new ClusterServiceAdapter() { @Override public ControllerNode getLocalNode() { return new DefaultControllerNode(a, IpAddress.valueOf(0)); } }; proxyManager1.clusterCommunicator = clusterCommunicatorFactory.newCommunicationService(a); proxyManager1.mastershipService = new MastershipServiceAdapter() { @Override public NodeId getMasterFor(DeviceId deviceId) { return b; } }; proxyManager1.activate(); proxyManager1.registerProxyService(ProxyInterface.class, proxyInterface1, serializer); ProxyInterfaceImpl proxyInterface2 = new ProxyInterfaceImpl(); MastershipProxyManager proxyManager2 = new MastershipProxyManager(); proxyManager2.clusterService = new ClusterServiceAdapter() { @Override public ControllerNode getLocalNode() { return new DefaultControllerNode(b, IpAddress.valueOf(0)); } }; proxyManager2.clusterCommunicator = clusterCommunicatorFactory.newCommunicationService(b); proxyManager2.mastershipService = new MastershipServiceAdapter() { @Override public NodeId getMasterFor(DeviceId deviceId) { return b; } }; proxyManager2.activate(); proxyManager2.registerProxyService(ProxyInterface.class, proxyInterface2, serializer); MastershipProxyFactory<ProxyInterface> proxyFactory1 = proxyManager1.getProxyFactory(ProxyInterface.class, serializer); assertEquals("Hello world!", proxyFactory1.getProxyFor(deviceId).sync("Hello world!")); assertEquals(1, proxyInterface2.syncCalls.get()); assertEquals("Hello world!", proxyFactory1.getProxyFor(deviceId).async("Hello world!").join()); assertEquals(1, proxyInterface2.asyncCalls.get()); MastershipProxyFactory<ProxyInterface> proxyFactory2 = proxyManager2.getProxyFactory(ProxyInterface.class, serializer); assertEquals("Hello world!", proxyFactory2.getProxyFor(deviceId).sync("Hello world!")); assertEquals(2, proxyInterface2.syncCalls.get()); assertEquals("Hello world!", proxyFactory2.getProxyFor(deviceId).async("Hello world!").join()); assertEquals(2, proxyInterface2.asyncCalls.get()); proxyManager1.deactivate(); proxyManager2.deactivate(); }
Example 18
Source File: LispAppDataLcafAddressTest.java From onos with Apache License 2.0 | 4 votes |
@Before public void setup() { AppDataAddressBuilder builder1 = new AppDataAddressBuilder(); LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); address1 = builder1 .withProtocol((byte) 0x01) .withIpTos((short) 10) .withLocalPortLow((short) 1) .withLocalPortHigh((short) 255) .withRemotePortLow((short) 2) .withRemotePortHigh((short) 254) .withAddress(ipv4Address1) .build(); AppDataAddressBuilder builder2 = new AppDataAddressBuilder(); sameAsAddress1 = builder2 .withProtocol((byte) 0x01) .withIpTos((short) 10) .withLocalPortLow((short) 1) .withLocalPortHigh((short) 255) .withRemotePortLow((short) 2) .withRemotePortHigh((short) 254) .withAddress(ipv4Address1) .build(); AppDataAddressBuilder builder3 = new AppDataAddressBuilder(); LispAfiAddress ipv4Address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1")); address2 = builder3 .withProtocol((byte) 0x02) .withIpTos((short) 20) .withLocalPortLow((short) 1) .withLocalPortHigh((short) 255) .withRemotePortLow((short) 2) .withRemotePortHigh((short) 254) .withAddress(ipv4Address2) .build(); }
Example 19
Source File: BgpControllerImplTest.java From onos with Apache License 2.0 | 4 votes |
/** * Peer1 has Node NLRI and Peer2 has Node NLRI with different MpReach and MpUnReach with VPN. */ @Test public void testBgpUpdateMessage4() throws InterruptedException { // Initiate the connections peer1.peerChannelHandler.asNumber = 200; peer1.peerChannelHandler.version = 4; peer1.peerChannelHandler.holdTime = 120; short afi = 16388; byte res = 0; byte safi = (byte) 0x80; bgpControllerImpl.getConfig().setLsCapability(true); BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi); peer1.peerChannelHandler.capabilityTlv.add(tempTlv1); Channel channel = peer1.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.35", 0)); TimeUnit.MILLISECONDS.sleep(1000); //Get peer1 IpAddress ipAddress = IpAddress.valueOf("127.0.0.35"); BgpId bgpId = new BgpId(ipAddress); BgpPeerImpl peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId); LinkedList<BgpValueType> subTlvs1 = new LinkedList<>(); LinkedList<BgpValueType> subTlvs = new LinkedList<>(); BgpValueType tlv = AutonomousSystemTlv.of(2478); subTlvs.add(tlv); tlv = BgpLSIdentifierTlv.of(33686018); subTlvs.add(tlv); NodeDescriptors nodeDes = new NodeDescriptors(subTlvs, (short) 0x10, (short) 256); BgpNodeLSIdentifier key = new BgpNodeLSIdentifier(nodeDes); RouteDistinguisher rd = new RouteDistinguisher((long) 0x0A); VpnAdjRibIn vpnAdj = peer.vpnAdjRib(); //In Adj-RIB, vpnNodeTree should contain rd assertThat(vpnAdj.vpnNodeTree().containsKey(rd), is(true)); Map<BgpNodeLSIdentifier, PathAttrNlriDetails> treeValue = vpnAdj.vpnNodeTree().get(rd); //In Adj-RIB, vpnNodeTree should contain rd key which contains specified value assertThat(treeValue.containsKey(key), is(true)); BgpLocalRibImpl obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRibVpn(); //In Local-RIB, vpnNodeTree should contain rd assertThat(obj.vpnNodeTree().containsKey(rd), is(true)); Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> value = obj.vpnNodeTree().get(rd); //In Local-RIB, vpnNodeTree should contain rd key which contains specified value assertThat(value.containsKey(key), is(true)); peer2.peerChannelHandler.asNumber = 200; peer2.peerChannelHandler.version = 4; peer2.peerChannelHandler.holdTime = 120; bgpControllerImpl.getConfig().setLsCapability(true); tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi); peer1.peerChannelHandler.capabilityTlv.add(tempTlv1); peer2.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.40", 0)); TimeUnit.MILLISECONDS.sleep(1000); //Get peer2 bgpId = new BgpId(IpAddress.valueOf("127.0.0.40")); peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId); tlv = AutonomousSystemTlv.of(686); subTlvs1.add(tlv); tlv = BgpLSIdentifierTlv.of(33686018); subTlvs1.add(tlv); nodeDes = new NodeDescriptors(subTlvs1, (short) 0x10, (short) 256); key = new BgpNodeLSIdentifier(nodeDes); vpnAdj = peer.vpnAdjRib(); //In Adj-RIB, vpnNodeTree should contain rd assertThat(vpnAdj.vpnNodeTree().containsKey(rd), is(true)); treeValue = vpnAdj.vpnNodeTree().get(rd); //In Adj-RIB, vpnNodeTree should contain rd key which contains specified value assertThat(treeValue.containsKey(key), is(true)); //Disconnect peer1 channel.disconnect(); channel.close(); obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRibVpn(); //In Local-RIB, vpnNodeTree should contain rd assertThat(obj.vpnNodeTree().containsKey(rd), is(true)); value = obj.vpnNodeTree().get(rd); //In Local-RIB, vpnNodeTree should contain rd key which contains specified value assertThat(value.containsKey(key), is(true)); }
Example 20
Source File: AbstractTopoModelTest.java From onos with Apache License 2.0 | 2 votes |
/** * Returns IP address instance for given string. * * @param s string * @return IP address */ protected static IpAddress ip(String s) { return IpAddress.valueOf(s); }