本文整理汇总了Java中org.onosproject.routing.RouteEntry类的典型用法代码示例。如果您正苦于以下问题:Java RouteEntry类的具体用法?Java RouteEntry怎么用?Java RouteEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RouteEntry类属于org.onosproject.routing包,在下文中一共展示了RouteEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRouteDelete
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Processes the deletion of a route entry.
* <p>
* The prefix for the routing entry is removed from radix tree.
* If the operation is successful, the prefix is added to the collection
* of prefixes whose intents that will be withdrawn.
* </p>
*
* @param routeEntry the route entry to delete
* @param withdrawPrefixes the collection of accumulated prefixes whose
* intents will be withdrawn
*/
private void processRouteDelete(RouteEntry routeEntry,
Collection<IpPrefix> withdrawPrefixes) {
log.debug("Processing route delete: {}", routeEntry);
boolean isRemoved = removeRibRoute(routeEntry.prefix());
if (isRemoved) {
//
// Only withdraw intents if an entry was actually removed from the
// tree. If no entry was removed, the <prefix, nexthop> wasn't
// there so it's probably already been removed and we don't
// need to do anything.
//
withdrawPrefixes.add(routeEntry.prefix());
}
routesWaitingOnArp.remove(routeEntry.nextHop(), routeEntry);
}
示例2: getLongestMatchableRouteEntry
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
@Override
public RouteEntry getLongestMatchableRouteEntry(IpAddress ipAddress) {
RouteEntry routeEntry = null;
Iterable<RouteEntry> routeEntries;
if (ipAddress.isIp4()) {
routeEntries = ribTable4.getValuesForKeysPrefixing(
createBinaryString(
IpPrefix.valueOf(ipAddress, Ip4Address.BIT_LENGTH)));
} else {
routeEntries = ribTable6.getValuesForKeysPrefixing(
createBinaryString(
IpPrefix.valueOf(ipAddress, Ip6Address.BIT_LENGTH)));
}
if (routeEntries == null) {
return null;
}
Iterator<RouteEntry> it = routeEntries.iterator();
while (it.hasNext()) {
routeEntry = it.next();
}
return routeEntry;
}
示例3: testIpv4RouteAdd
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Tests adding a IPv4 route entry.
*/
@Test
public void testIpv4RouteAdd() {
// Construct a route entry
IpPrefix prefix = Ip4Prefix.valueOf("1.1.1.0/24");
IpAddress nextHopIp = Ip4Address.valueOf("192.168.10.1");
RouteEntry routeEntry = new RouteEntry(prefix, nextHopIp);
// Expected FIB entry
FibEntry fibEntry = new FibEntry(prefix, nextHopIp,
MacAddress.valueOf("00:00:00:00:00:01"));
fibListener.update(Collections.singletonList(new FibUpdate(
FibUpdate.Type.UPDATE, fibEntry)), Collections.emptyList());
replay(fibListener);
router.processRouteUpdates(Collections.singletonList(
new RouteUpdate(RouteUpdate.Type.UPDATE, routeEntry)));
verify(fibListener);
}
示例4: testIpv6RouteAdd
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Tests adding a IPv6 route entry.
*/
@Test
public void testIpv6RouteAdd() {
// Construct a route entry
IpPrefix prefix = Ip6Prefix.valueOf("4000::/64");
IpAddress nextHopIp = Ip6Address.valueOf("1000::1");
RouteEntry routeEntry = new RouteEntry(prefix, nextHopIp);
// Expected FIB entry
FibEntry fibEntry = new FibEntry(prefix, nextHopIp,
MacAddress.valueOf("00:00:00:00:00:04"));
fibListener.update(Collections.singletonList(new FibUpdate(
FibUpdate.Type.UPDATE, fibEntry)), Collections.emptyList());
replay(fibListener);
router.processRouteUpdates(Collections.singletonList(
new RouteUpdate(RouteUpdate.Type.UPDATE, routeEntry)));
verify(fibListener);
}
示例5: testIpv4RouteDelete
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Tests deleting a IPv4 route entry.
*/
@Test
public void testIpv4RouteDelete() {
// Firstly add a route
testIpv4RouteAdd();
RouteEntry deleteRouteEntry = new RouteEntry(
Ip4Prefix.valueOf("1.1.1.0/24"),
Ip4Address.valueOf("192.168.10.1"));
FibEntry deleteFibEntry = new FibEntry(
Ip4Prefix.valueOf("1.1.1.0/24"), null, null);
reset(fibListener);
fibListener.update(Collections.emptyList(), Collections.singletonList(
new FibUpdate(FibUpdate.Type.DELETE, deleteFibEntry)));
replay(fibListener);
router.processRouteUpdates(Collections.singletonList(
new RouteUpdate(RouteUpdate.Type.DELETE, deleteRouteEntry)));
verify(fibListener);
}
示例6: testIpv6RouteDelete
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Tests deleting a IPv6 route entry.
*/
@Test
public void testIpv6RouteDelete() {
// Firstly add a route
testIpv6RouteAdd();
RouteEntry deleteRouteEntry = new RouteEntry(
Ip6Prefix.valueOf("4000::/64"),
Ip6Address.valueOf("1000::1"));
FibEntry deleteFibEntry = new FibEntry(
Ip6Prefix.valueOf("4000::/64"), null, null);
reset(fibListener);
fibListener.update(Collections.emptyList(), Collections.singletonList(
new FibUpdate(FibUpdate.Type.DELETE, deleteFibEntry)));
replay(fibListener);
router.processRouteUpdates(Collections.singletonList(
new RouteUpdate(RouteUpdate.Type.DELETE, deleteRouteEntry)));
verify(fibListener);
}
示例7: testIpv4LocalRouteAdd
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Tests adding a IPv4 route whose next hop is the local BGP speaker.
*/
@Test
public void testIpv4LocalRouteAdd() {
// Construct a route entry, the next hop is the local BGP speaker
RouteEntry routeEntry = new RouteEntry(
Ip4Prefix.valueOf("1.1.1.0/24"),
Ip4Address.valueOf("0.0.0.0"));
// No methods on the FIB listener should be called
replay(fibListener);
reset(routingConfigurationService);
expect(routingConfigurationService.isIpPrefixLocal(
anyObject(IpPrefix.class))).andReturn(true);
replay(routingConfigurationService);
// Call the processRouteUpdates() method in Router class
RouteUpdate routeUpdate = new RouteUpdate(RouteUpdate.Type.UPDATE,
routeEntry);
router.processRouteUpdates(Collections.singletonList(routeUpdate));
// Verify
assertEquals(1, router.getRoutes4().size());
assertTrue(router.getRoutes4().contains(routeEntry));
verify(fibListener);
}
示例8: testIpv6LocalRouteAdd
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Tests adding a IPv6 route whose next hop is the local BGP speaker.
*/
@Test
public void testIpv6LocalRouteAdd() {
// Construct a route entry, the next hop is the local BGP speaker
RouteEntry routeEntry = new RouteEntry(
Ip6Prefix.valueOf("4000::/64"),
Ip6Address.valueOf("::"));
// No methods on the FIB listener should be called
replay(fibListener);
reset(routingConfigurationService);
expect(routingConfigurationService.isIpPrefixLocal(
anyObject(IpPrefix.class))).andReturn(true);
replay(routingConfigurationService);
// Call the processRouteUpdates() method in Router class
RouteUpdate routeUpdate = new RouteUpdate(RouteUpdate.Type.UPDATE,
routeEntry);
router.processRouteUpdates(Collections.singletonList(routeUpdate));
// Verify
assertEquals(1, router.getRoutes6().size());
assertTrue(router.getRoutes6().contains(routeEntry));
verify(fibListener);
}
示例9: testRouteAdd
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Tests adding a route entry.
*/
@Test
public void testRouteAdd() {
// Construct a route entry
IpPrefix prefix = Ip4Prefix.valueOf("1.1.1.0/24");
IpAddress nextHopIp = Ip4Address.valueOf("192.168.10.1");
RouteEntry routeEntry = new RouteEntry(prefix, nextHopIp);
// Expected FIB entry
FibEntry fibEntry = new FibEntry(prefix, nextHopIp,
MacAddress.valueOf("00:00:00:00:00:01"));
fibListener.update(Collections.singletonList(new FibUpdate(
FibUpdate.Type.UPDATE, fibEntry)), Collections.emptyList());
replay(fibListener);
router.processRouteUpdates(Collections.singletonList(
new RouteUpdate(RouteUpdate.Type.UPDATE, routeEntry)));
verify(fibListener);
}
示例10: testRouteDelete
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Tests deleting a route entry.
*/
@Test
public void testRouteDelete() {
// Firstly add a route
testRouteAdd();
RouteEntry deleteRouteEntry = new RouteEntry(
Ip4Prefix.valueOf("1.1.1.0/24"),
Ip4Address.valueOf("192.168.10.1"));
FibEntry deleteFibEntry = new FibEntry(
Ip4Prefix.valueOf("1.1.1.0/24"), null, null);
reset(fibListener);
fibListener.update(Collections.emptyList(), Collections.singletonList(
new FibUpdate(FibUpdate.Type.DELETE, deleteFibEntry)));
replay(fibListener);
router.processRouteUpdates(Collections.singletonList(
new RouteUpdate(RouteUpdate.Type.DELETE, deleteRouteEntry)));
verify(fibListener);
}
示例11: testLocalRouteAdd
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Tests adding a route whose next hop is the local BGP speaker.
*/
@Test
public void testLocalRouteAdd() {
// Construct a route entry, the next hop is the local BGP speaker
RouteEntry routeEntry = new RouteEntry(
Ip4Prefix.valueOf("1.1.1.0/24"),
Ip4Address.valueOf("0.0.0.0"));
// No methods on the FIB listener should be called
replay(fibListener);
reset(routingConfigurationService);
expect(routingConfigurationService.isIpPrefixLocal(
anyObject(IpPrefix.class))).andReturn(true);
replay(routingConfigurationService);
// Call the processRouteUpdates() method in Router class
RouteUpdate routeUpdate = new RouteUpdate(RouteUpdate.Type.UPDATE,
routeEntry);
router.processRouteUpdates(Collections.singletonList(routeUpdate));
// Verify
assertEquals(1, router.getRoutes4().size());
assertTrue(router.getRoutes4().contains(routeEntry));
verify(fibListener);
}
示例12: getLongestMatchableRouteEntry
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
@Override
public RouteEntry getLongestMatchableRouteEntry(IpAddress ipAddress) {
Route route = routeService.longestPrefixMatch(ipAddress);
if (route != null) {
return new RouteEntry(route.prefix(), route.nextHop());
}
return null;
}
示例13: getRoutes4
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Gets all IPv4 routes from the RIB.
*
* @return all IPv4 routes from the RIB
*/
@Override
public Collection<RouteEntry> getRoutes4() {
Iterator<KeyValuePair<RouteEntry>> it =
ribTable4.getKeyValuePairsForKeysStartingWith("").iterator();
List<RouteEntry> routes = new LinkedList<>();
while (it.hasNext()) {
KeyValuePair<RouteEntry> entry = it.next();
routes.add(entry.getValue());
}
return routes;
}
示例14: getRoutes6
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Gets all IPv6 routes from the RIB.
*
* @return all IPv6 routes from the RIB
*/
@Override
public Collection<RouteEntry> getRoutes6() {
Iterator<KeyValuePair<RouteEntry>> it =
ribTable6.getKeyValuePairsForKeysStartingWith("").iterator();
List<RouteEntry> routes = new LinkedList<>();
while (it.hasNext()) {
KeyValuePair<RouteEntry> entry = it.next();
routes.add(entry.getValue());
}
return routes;
}
示例15: findRibRoute
import org.onosproject.routing.RouteEntry; //导入依赖的package包/类
/**
* Finds a route in the RIB for a prefix. The prefix can be either IPv4 or
* IPv6.
*
* @param prefix the prefix to use
* @return the route if found, otherwise null
*/
RouteEntry findRibRoute(IpPrefix prefix) {
String binaryString = createBinaryString(prefix);
if (prefix.isIp4()) {
// IPv4
return ribTable4.getValueForExactKey(binaryString);
}
// IPv6
return ribTable6.getValueForExactKey(binaryString);
}