private static Ip part1(String s) { String trimmed = s.substring(1, s.length() - 1); String[] parts = trimmed.split(":"); String part1Str = parts[0]; Ip part1 = Ip.parse(part1Str); return part1; }
@Override public void exitRo_router_id(Ro_router_idContext ctx) { Ip id = Ip.parse(ctx.id.getText()); _currentRoutingInstance.setRouterId(id); }
@Override public void exitS2st_local_address(S2st_local_addressContext ctx) { Ip localAddress = Ip.parse(ctx.ip.getText()); _currentIpsecPeer.setLocalAddress(localAddress); }
@Override public void exitIfia_arp(Ifia_arpContext ctx) { Ip ip = Ip.parse(ctx.ip.getText()); _currentInterfaceOrRange.setAdditionalArpIps( ImmutableSet.<Ip>builder() .addAll(_currentInterfaceOrRange.getAdditionalArpIps()) .add(ip) .build()); }
@Override public void exitOn_range(On_rangeContext ctx) { _configuration .getNetworkObjects() .put( _currentNetworkObjectInfo.getName(), new RangeNetworkObject(Ip.parse(ctx.start.getText()), Ip.parse(ctx.end.getText()))); _w.redFlag("Network object 'range' is not supported for access lists: " + getFullText(ctx)); }
@Override public void exitSrt_next_hop(Srt_next_hopContext ctx) { Ip nextHopIp = Ip.parse(ctx.nexthop.getText()); int distance = toInteger(ctx.distance); StaticNextHopRoute staticRoute = new StaticNextHopRoute(_currentStaticRoutePrefix, nextHopIp, distance); _configuration.getStaticNextHopRoutes().add(staticRoute); }
public Address(JSONObject jObj) throws JSONException { _publicIp = Ip.parse(jObj.getString(JSON_KEY_PUBLIC_IP)); _instanceId = jObj.has(JSON_KEY_INSTANCE_ID) ? jObj.getString(JSON_KEY_INSTANCE_ID) : null; _privateIp = jObj.has(JSON_KEY_PRIVATE_IP_ADDRESS) ? Ip.parse(jObj.getString(JSON_KEY_PRIVATE_IP_ADDRESS)) : null; // TODO: not sure what other information we need to pull }
@Test public void testRange() { testIpRange(Ip.ZERO, Ip.ZERO); testIpRange(Ip.ZERO, Ip.MAX); testIpRange(Ip.MAX, Ip.MAX); testIpRange(Ip.parse("4.23.32.21"), Ip.parse("5.0.0.1")); testIpRange(Ip.parse("5.0.0.1"), Ip.parse("5.0.0.1")); testIpRange(Ip.parse("123.0.0.0"), Ip.parse("123.0.0.255")); testIpRange(Ip.parse("1.255.255.255"), Ip.parse("2.255.255.255")); testIpRange(Ip.parse("0.0.0.1"), Ip.parse("255.255.255.254")); }
@Override public void exitB_local_address(B_local_addressContext ctx) { if (ctx.IP_ADDRESS() != null) { Ip localAddress = Ip.parse(ctx.IP_ADDRESS().getText()); _currentBgpGroup.setLocalAddress(localAddress); } }
public VgwTelemetry(JSONObject jObj) throws JSONException { _status = jObj.getString(AwsVpcEntity.JSON_KEY_STATUS); _statusMessage = jObj.getString(AwsVpcEntity.JSON_KEY_STATUS_MESSAGE); _acceptedRouteCount = jObj.getInt(AwsVpcEntity.JSON_KEY_ACCEPTED_ROUTE_COUNT); _outsideIpAddress = Ip.parse(jObj.getString(AwsVpcEntity.JSON_KEY_OUTSIDE_IP_ADDRESS)); }
@Override public void exitIfiav_virtual_address(Ifiav_virtual_addressContext ctx) { Ip virtualAddress = Ip.parse(ctx.IP_ADDRESS().getText()); int prefixLength = _currentInterfaceAddress.getNetworkBits(); _currentVrrpGroup.setVirtualAddress(new InterfaceAddress(virtualAddress, prefixLength)); }
@Test public void testComplement() { IpSpace ipSpace = new IpWildcard(Ip.create(0x01010001L), Ip.create(0x0000FF00L)).toIpSpace().complement(); assertThat(ipSpace, not(containsIp(Ip.parse("1.1.1.1")))); assertThat(ipSpace, not(containsIp(Ip.parse("1.1.255.1")))); assertThat(ipSpace, containsIp(Ip.parse("1.1.0.0"))); }
@Test public void testDontSpecializeToUniverse() { IpSpace ipSpace = Prefix.parse("1.0.0.0/8").toIpSpace(); Ip ip = Ip.parse("1.1.1.1"); IpSpaceSpecializer specializer = new BDDIpSpaceSpecializer(_toBdd.toBDD(ip), ImmutableMap.of(), _toBdd, false); assertThat(specializer.specialize(ipSpace), equalTo(ipSpace)); } }
@Test public void testCanonicalization() { Prefix p = Prefix.parse("255.255.255.255/15"); assertThat(p.getStartIp(), equalTo(Ip.parse("255.254.0.0"))); assertThat(p.getPrefixLength(), equalTo(15)); }
@Before public void setup() { _flow = Flow.builder() .setIngressNode("ingress") .setTag("tag") .setDstIp(Ip.parse("1.1.1.1")) .build(); _describerNoNamesNorMetadata = new IpSpaceDescriber( new AclTracer(_flow, null, ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of())); }
@Test public void getRemoteIpActivePeer() { Ip ip = Ip.parse("1.1.1.1"); BgpActivePeerConfig activePeerConfig = BgpActivePeerConfig.builder().setPeerAddress(ip).build(); assertThat(getRemoteIp(activePeerConfig), equalTo(new SelfDescribingObject(Schema.IP, ip))); }
private static Flow createFlow(String ipAddrStr) { Flow.Builder b = new Flow.Builder(); b.setIngressNode("ingressNode"); b.setSrcIp(Ip.parse(ipAddrStr)); b.setTag("test"); return b.build(); }
@Test public void testJsonSerialization() throws IOException { BgpRoute br = BgpRoute.builder() .setNetwork(Prefix.parse("1.1.1.0/24")) .setOriginatorIp(Ip.parse("1.1.1.1")) .setOriginType(OriginType.IGP) .setProtocol(RoutingProtocol.BGP) .build(); assertThat(BatfishObjectMapper.clone(br, BgpRoute.class), equalTo(br)); }