-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from RIPE-NCC/feature/roa-validation-on-inter…
…face-types Validation state logic should use interface types
- Loading branch information
Showing
9 changed files
with
185 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/net/ripe/rpki/commons/validation/roa/RoaPrefixData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package net.ripe.rpki.commons.validation.roa; | ||
|
||
import net.ripe.ipresource.Asn; | ||
import net.ripe.ipresource.IpRange; | ||
|
||
import java.util.Comparator; | ||
|
||
/** | ||
* Represents a Validated Roa Prefix | ||
*/ | ||
public interface RoaPrefixData extends Comparable<RoaPrefixData> { | ||
Comparator<RoaPrefixData> ROA_PREFIX_DATA_COMPARATOR = Comparator.comparing(RoaPrefixData::getAsn).thenComparing(RoaPrefixData::getPrefix).thenComparing(RoaPrefixData::getMaximumLength); | ||
Asn getAsn(); | ||
|
||
/** | ||
* @return The prefix of the entity. <emph>MUST</emph> be a prefix and not a IP range | ||
*/ | ||
IpRange getPrefix(); | ||
|
||
/** | ||
* @return The maximum length of the VRP. The maximum length <emph>MUST</emph> be in the range (inclusive) between | ||
* the prefix length and the length of addresses for the address family. | ||
*/ | ||
int getMaximumLength(); | ||
|
||
@Override | ||
default int compareTo(RoaPrefixData o) { | ||
return ROA_PREFIX_DATA_COMPARATOR.compare(this, o); | ||
} | ||
|
||
default AllowedRoute toAllowedRoute() { | ||
return new AllowedRoute(getAsn(), getPrefix(), getMaximumLength()); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/net/ripe/rpki/commons/validation/roa/RouteData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package net.ripe.rpki.commons.validation.roa; | ||
|
||
import net.ripe.ipresource.Asn; | ||
import net.ripe.ipresource.IpRange; | ||
|
||
import java.util.Comparator; | ||
|
||
public interface RouteData extends Comparable<RouteData> { | ||
Comparator<RouteData> ROUTE_DATA_COMPARATOR = Comparator.comparing(RouteData::getOriginAsn).thenComparing(RouteData::getPrefix); | ||
|
||
Asn getOriginAsn(); | ||
|
||
/** | ||
* @return The prefix of the entity. <emph>MUST</emph> be a prefix and not a IP range | ||
*/ | ||
IpRange getPrefix(); | ||
|
||
@Override | ||
default int compareTo(RouteData o) { | ||
return ROUTE_DATA_COMPARATOR.compare(this, o); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.