Search in sources :

Example 1 with IpRange

use of net.ripe.ipresource.IpRange in project rpki-validator-3 by RIPE-NCC.

the class BgpRisDownloader method parseLine.

private BgpRisEntry parseLine(final String line, final Function<Object, Object> uniq) {
    final Matcher matcher = regexp.matcher(line);
    if (matcher.matches()) {
        final Asn asn = (Asn) uniq.apply(Asn.parse(matcher.group(1)));
        IpRange parsed = IpRange.parse(matcher.group(2));
        final UniqueIpResource start = (UniqueIpResource) uniq.apply(parsed.getStart());
        final UniqueIpResource end = (UniqueIpResource) uniq.apply(parsed.getEnd());
        final IpRange prefix = (IpRange) start.upTo(end);
        final int visibility = Integer.parseInt(matcher.group(3));
        return BgpRisEntry.of(asn, prefix, visibility);
    }
    return null;
}
Also used : IpRange(net.ripe.ipresource.IpRange) UniqueIpResource(net.ripe.ipresource.UniqueIpResource) Matcher(java.util.regex.Matcher) Asn(net.ripe.ipresource.Asn)

Aggregations

Matcher (java.util.regex.Matcher)1 Asn (net.ripe.ipresource.Asn)1 IpRange (net.ripe.ipresource.IpRange)1 UniqueIpResource (net.ripe.ipresource.UniqueIpResource)1