Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
9401224
SCRUM-2487 - mavenize
dragank Feb 26, 2015
1e18aac
SCRUM-2487 - mavenize
dragank Feb 26, 2015
363b594
SCRUM-2487 - mavenize
dragank Feb 26, 2015
dabbfe0
Fix double-offset increment bug in ExtCommunities, and use ASPLAIN no…
codebje Mar 3, 2015
518b418
SCRUM-2487 - Allow writes to file rather than stdout
dragank Mar 3, 2015
05e26c6
SCRUM-2487 - Short circuit System.exit()
dragank Mar 3, 2015
3398bb1
SCRUM-2487 - Add option to capture output errors to a StringBuilder
dragank Mar 3, 2015
03aec8e
Fixed issue with BGPFileReader reading from slow input streams.
rlcintra Mar 19, 2015
c1a8276
Fixed indentation from previous commit (tabs? really?!).
rlcintra Mar 19, 2015
94ba8d8
Added code to ignore the deprecated attribute type 20 (Connector Attr…
rlcintra Apr 16, 2015
7dd7f1b
Added partial support to attribute type 128 (ATTR_SET).
rlcintra Oct 9, 2015
0ec954e
[master] .gitignore
tomhrr Jan 3, 2017
38adab6
[feature/SCRUM-3461] ignore large_community
tomhrr Jan 3, 2017
13c9231
[feature/SCRUM-3461] check for expected content
tomhrr Jan 4, 2017
1356349
Merge pull request #1 from APNIC-net/feature/SCRUM-3461
tomhrr Jan 4, 2017
064715f
[master] bump version
tomhrr Jan 4, 2017
cb5f68d
[master] move to snapshot version
tomhrr Jan 4, 2017
83b8d93
Do not use "record" in exceptions, as it could be huge in malformed MRT.
omuravskiy May 17, 2017
51ce709
[RIPE-NCC-master] fix conflicts
tomhrr May 17, 2017
4a812ea
Merge branch 'RIPE-NCC-master'
tomhrr May 17, 2017
eaa73d3
Keep binary data and add methods to retrieve it after parsing
omuravskiy Jul 3, 2017
8b1ed20
Adding getter for body in MRTRecord
edominguezro Jul 3, 2017
1e25390
Adding getter for header in MRTRecord
edominguezro Jul 3, 2017
a49836b
Reverse default AFI (IPv4 by default)
omuravskiy Jul 11, 2017
9845b98
Keep unsupported Bgp4Update Attributes
omuravskiy Jul 11, 2017
fb6e6ef
Merge branch 'ripencc-keep-binary' of https://github.com/RIPE-NCC/jav…
omuravskiy Jul 11, 2017
02a23b6
Adding srcIP and srcAS attributes to Open and Notification objects.
edominguezro Jul 17, 2017
49990c2
Parsing mrt records based on rfc1771.
edominguezro Aug 1, 2017
302285e
When announcements and withdraws are defined in this bgp message posi…
edominguezro Feb 16, 2018
eec9892
GIIDEV-209 Fixing 4-byte ASNs in the path are treated as signed integer
edominguezro Feb 16, 2018
729aab1
Doing a "hack" in order to show Ipv6 format in Ipv4 embedded prefixes…
edominguezro Feb 19, 2018
a8e85d5
Cleaning up unused import
edominguezro Feb 19, 2018
5245ba5
Changing testing
edominguezro Feb 19, 2018
c810808
Copy arrays using System.arraycopy()
omuravskiy Feb 20, 2018
914aa47
Merge remote-tracking branch 'origin/ripencc-keep-binary'
omuravskiy Feb 20, 2018
b42e301
Merge pull request #3 from RIPE-NCC/master
tomhrr Feb 20, 2018
75451d0
[master] add .travis.yml
tomhrr Feb 20, 2018
2d978ec
Adding getter for the embedded ipv4-ipv6
edominguezro Feb 21, 2018
4debb6f
Fast fix for wrong ipv6 parse
edominguezro Feb 21, 2018
099d38e
Fix more 32-bit ASN / unsigned lengths issues.
omuravskiy Feb 21, 2018
4f307ba
Loosen requirements for collection type in constructor.
omuravskiy Feb 21, 2018
59780b7
Add tests for AS and ASPath
omuravskiy Feb 22, 2018
85c9cb2
Convert JUnit test to TestNG
omuravskiy Feb 22, 2018
95277a7
Updating the Mrtconstants.ipAddressString method in order to allow th…
edominguezro Mar 1, 2018
3125c7d
Merge remote-tracking branch 'origin/master'
edominguezro Mar 1, 2018
a4578a7
Prepare release plugin to make internal releases
Mar 21, 2018
c59822b
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-1
Mar 21, 2018
ef96120
[maven-release-plugin] prepare for next development iteration
Mar 21, 2018
45c6b27
Fix AS_CONFED_SEQUENCE and AS_CONFED_SET constants
omuravskiy Mar 23, 2018
2fb0c84
Merge branch 'track-apnic'
omuravskiy Mar 23, 2018
88537ea
Merge pull request #4 from RIPE-NCC/track-apnic
tomhrr Mar 25, 2018
ccb383c
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-2
Mar 28, 2018
a5d2a77
[maven-release-plugin] prepare for next development iteration
Mar 28, 2018
fe42474
Override getMessage() instead of toString() in custom exception classes
omuravskiy Jul 3, 2018
e0f046c
Fix byte array re-use between parsed objects; add lenient mode
omuravskiy Aug 8, 2018
a47fa2c
Multiple fixes and improvements:
omuravskiy Aug 8, 2018
3b78905
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-3
omuravskiy Aug 31, 2018
573604f
[maven-release-plugin] rollback the release of mrt-0.0.2-RIPE-3
omuravskiy Aug 31, 2018
77d2d5f
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-3
omuravskiy Aug 31, 2018
d98790b
[maven-release-plugin] rollback the release of mrt-0.0.2-RIPE-3
omuravskiy Aug 31, 2018
f45d9ce
[maven-release-plugin] prepare for next development iteration
omuravskiy Aug 31, 2018
8d9bff9
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-4
omuravskiy Aug 31, 2018
cb25e8c
[maven-release-plugin] prepare for next development iteration
omuravskiy Aug 31, 2018
98f6db9
Process advertisements even if there were withdrawals :)
omuravskiy Sep 3, 2018
4ae7fb1
Recognise and parse End-Of-Rib marker
omuravskiy Sep 3, 2018
4de8286
Merge branch 'track-apnic'
omuravskiy Sep 3, 2018
da8ec84
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-5
omuravskiy Sep 3, 2018
8de1d58
[maven-release-plugin] prepare for next development iteration
omuravskiy Sep 3, 2018
b8cbe70
Added ASPath functionality
andrekampert Sep 6, 2018
8c5e02a
Merge branch 'track-apnic'
andrekampert Sep 6, 2018
22f7d11
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-6
andrekampert Sep 6, 2018
d2802c7
[maven-release-plugin] prepare for next development iteration
andrekampert Sep 6, 2018
9e3a6f2
Improved toString handling
andrekampert Sep 6, 2018
94e9d93
Implement getAsList for all AS instances
andrekampert Sep 6, 2018
0e83f81
Merge branch 'track-apnic'
andrekampert Sep 6, 2018
c1c9fa8
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-7
andrekampert Sep 6, 2018
0fe619e
[maven-release-plugin] prepare for next development iteration
andrekampert Sep 6, 2018
85ab9d2
Do not overwrite ASPath if attribute of type 0 received.
omuravskiy Sep 26, 2018
8ce78c4
Merge branch 'track-apnic'
omuravskiy Sep 26, 2018
34a1035
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-8
omuravskiy Sep 26, 2018
1daa6d9
[maven-release-plugin] rollback the release of mrt-0.0.2-RIPE-8
omuravskiy Sep 26, 2018
95ce0cf
[maven-release-plugin] prepare for next development iteration
omuravskiy Sep 26, 2018
996b874
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-9
omuravskiy Sep 26, 2018
5ae097c
[maven-release-plugin] prepare for next development iteration
omuravskiy Sep 26, 2018
8b9d1f9
Ignore LARGE_COMMUNITY with length 0
omuravskiy Oct 9, 2020
5aba510
[maven-release-plugin] prepare for next development iteration
omuravskiy Oct 9, 2020
aede86b
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-11
omuravskiy Oct 9, 2020
e97757d
[maven-release-plugin] prepare for next development iteration
omuravskiy Oct 9, 2020
ca2f820
new urls
constpetrov Jan 13, 2021
b976350
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-12
constpetrov Jan 13, 2021
957cc15
[maven-release-plugin] prepare for next development iteration
constpetrov Jan 13, 2021
e4f3919
Create maven-publish.yml
constpetrov Jan 15, 2021
ad003d8
Remove distribution management
constpetrov Jan 15, 2021
b45c37c
Create UnsupportedAttribute and do not complain on stderr about that
omuravskiy Nov 18, 2021
0198547
Print EOR in the update type
omuravskiy Nov 18, 2021
338d834
New version
constpetrov Nov 26, 2024
6580b56
New version
constpetrov Nov 26, 2024
170d330
[maven-release-plugin] prepare release mrt-0.0.2-RIPE-16
constpetrov Nov 26, 2024
647c729
[maven-release-plugin] prepare for next development iteration
constpetrov Nov 26, 2024
d2feeb0
Add notes on release
constpetrov Nov 26, 2024
8b9a793
Remove unused workflow
constpetrov Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ local.properties
# Eclipse project files
.classpath
.project

*.iml
*.ipr
*.iws
.idea
target
atlassian-ide-plugin.xml
.settings
.DS_Store

*.swp
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: java
14 changes: 11 additions & 3 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ java-mrt

Java library to parse the binary MRT format.

I have used this library over the last years extensively.
Please send any bug fixes to me paaguti :#at#: gmail _dot_ com

This library is released under LGPL license. Read LICENSE.txt.

## Releasing
Do not touch anything in `pom.xml`, do not update versions.

1. Commit and push all the changes.
2. `mvn release:clean release:prepare`
- answer all the questions (just hit `return`)
3. `mvn release:perform`
4. Check that new version was released on Nexus
5. Check that new tag was set in Github
6. Make a new release via Github interface using latest tag.
8 changes: 4 additions & 4 deletions build.xml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name = "Paquete análisis BGP-4" default = "rebuild">
<property name = "outputdir" value = "."/>
<property name = "classdir" value = "./bin" />
<property name = "sourcedir" value = "./src" />
<property name = "outputdir" value = "./target"/>
<property name = "classdir" value = "./target/classes" />
<property name = "sourcedir" value = "./src/main/java" />
<property name = "debug" value = "false" />
<property name = "mrt.main.class" value = "org.java-mrt.progs.route_btoa" />
<property name = "mrt.main.class" value = "org.javamrt.progs.route_btoa" />

<target name = "cleansrc" description = "Borra los backups">
<tstamp/>
Expand Down
75 changes: 75 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.apnic.mrt</groupId>
<artifactId>mrt</artifactId>
<version>0.0.2-RIPE-17-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Java MRT File Dumper</name>
<description>Java Multi-Threaded Routing Toolkit File Dumper</description>
<url>https://github.com/RIPE-NCC/java-mrt</url>

<scm>
<url>https://github.com/RIPE-NCC/java-mrt</url>
<connection>scm:git:git@github.com:RIPE-NCC/java-mrt.git</connection>
<developerConnection>scm:git:git@github.com:RIPE-NCC/java-mrt.git</developerConnection>
<tag>HEAD</tag>
</scm>

<distributionManagement>
<repository>
<id>ripe-releases</id>
<name>Nexus Release Repository</name>
<url>https://artifacts.ripe.net/repository/maven-releases-ncc/</url>
</repository>
<snapshotRepository>
<id>ripe-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>https://artifacts.ripe.net/repository/maven-snapshots-ncc/</url>
</snapshotRepository>
</distributionManagement>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<mainClass>org.javamrt.progs.route_btoa</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<arguments>-Dmaven.javadoc.skip=true -Dmaven.test.skip=true</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
101 changes: 38 additions & 63 deletions src/org/javamrt/mrt/AS.java → src/main/java/org/javamrt/mrt/AS.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

package org.javamrt.mrt;

import java.math.BigInteger;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
* @author paag
Expand All @@ -16,81 +19,44 @@
public class AS implements Comparable<AS>, Comparator<AS> {
public static final int AS_TRANS = 23456;
public static final AS NullAS = new AS(0);
// protected long ASnumber;
protected byte ASCode[] = {0,0,0,0};
private long asNumber;

protected AS() {
}

public AS(long ASnumber) {
setASCode(ASnumber & 0xffffffff);
asNumber = ASnumber & 0xffffffffL;
}

public AS(byte[] as) throws Exception {
setASCode(as);
}


private void setASCode(long val) {
for (int i = 0; i < 4; i++)
ASCode[i] = (byte) ((val >> ((3 - i) * 8)) & 0xff);
}

private void setASCode(byte[] newval) throws Exception {
if (newval.length == 2) {
this.ASCode[0] =
this.ASCode[1] = 0;
this.ASCode[2] = newval[0];
this.ASCode[3] = newval[1];
} else if (newval.length == 4) {
this.ASCode[0] = newval[0];
this.ASCode[1] = newval[1];
this.ASCode[2] = newval[2];
this.ASCode[3] = newval[3];
} else
throw new Exception(String.format("AS must be 2 or 4 bytes long (%d not allowed)",newval.length));
public AS(byte[] as) {
if (as.length != 2 && as.length != 4) {
throw new IllegalArgumentException(String.format("AS must be 2 or 4 bytes long (%d not allowed)", as.length));
}
asNumber = new BigInteger(1, as).longValue();
}

public long getASN() {
long result = 0;
for (int i=0; i<ASCode.length;i++) {
result = (result << 8) & 0xffffff00;
result = result | (ASCode[i] & 0x000000ff);
}
return result;
return asNumber;
}

public void setASN(long ASnumber) {
this.setASCode(ASnumber & 0xffffffff);
this.asNumber = ASnumber & 0xffffffffL;
}

// public long getASN() {
// return this.ASnumber;
// }


public int compareTo(org.javamrt.mrt.AS other) {
return compare(this, other);
}

public int compare(org.javamrt.mrt.AS as1, org.javamrt.mrt.AS as2) {
for (int i=0;i<4;i++) {
if (as1.ASCode[i] == as2.ASCode[i])
continue;
return ((int)as1.ASCode[i] & 0xff) - ((int)as2.ASCode[i] & 0xff);
}
return 0;
return Long.compare(as1.asNumber, as2.asNumber);
}

/**
* @param AS other
* @return true if the other AS
*/
private boolean equals(AS other) {
for (int i=0; i<4; i++)
if (this.ASCode[i] != other.ASCode[i])
return false;
return true;
return other != null && this.asNumber == other.asNumber;
}

/**
Expand Down Expand Up @@ -118,38 +84,36 @@ public boolean equals(Object other) {
return false;
}

@Override
public int hashCode() {
return Long.hashCode(asNumber);
}

/**
* @return true if this is a 4 byte AS number
*/
public boolean is4Byte() {
return this.ASCode[0] != 0 || this.ASCode[1] != 0;
return asNumber > 0xFFFFL;
}

/**
* @return true if the AS number is 23456, the 4 byte AS place holder
* comparison is byte by byte
* @return true if the AS number is 23456
*/
public boolean isPlaceholder() {
return this.equals(AS_TRANS);
return asNumber == AS_TRANS;
}

/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
if (this.equals(0)) return "AS_NULL";
if (this.equals(AS_TRANS)) return "AS_TRANS";
if (this.is4Byte()) return String.format("%d.%d",hiWord(),loWord());
return String.format("%d", loWord());
}
// this has never worked, so do not think we should fix it now
// if (this.equals(0)) return "AS_NULL";
// if (this.equals(AS_TRANS)) return "AS_TRANS";

private int hiWord() {
return ((this.ASCode[0] & 0xff) << 8) | (this.ASCode[1] & 0xff);
return String.valueOf(asNumber);
}

private int loWord() {
return ((this.ASCode[2] & 0xff) << 8) | (this.ASCode[3] & 0xff);
}
/**
* @param prefix
* @return a String containing the prefix followed by the AS textual representation
Expand All @@ -173,11 +137,22 @@ public static AS parseString(String asspec) throws Exception {
asnum = asnum * 0x10000L + asnum1;
result = new AS(asnum);
} else {
result = new AS(Long.parseLong(asspec));
long number = Long.parseLong(asspec);
if (number < 0 || number > 0xFFFFFFFFL) {
throw new IllegalArgumentException("number must be in [0,4294967295]");
}
result = new AS(number);
}
} else {
throw new Exception ("Incorrect AS specification: "+asspec);
}
return result;
}

/**
* @return list of ASNs, especially useful when not interested in whether it is some type of set, but just want to deal with the numbers
*/
public List<AS> getASList() {
return Collections.singletonList(this);
}
}
30 changes: 30 additions & 0 deletions src/main/java/org/javamrt/mrt/ASConfedSequence.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// This file is part of java-mrt
// A library to parse MRT files

// This file is released under LGPL 3.0
// http://www.gnu.org/licenses/lgpl-3.0-standalone.html

package org.javamrt.mrt;

import java.util.List;
import java.util.LinkedList;
import java.util.stream.Collectors;

public class ASConfedSequence extends AS {
LinkedList<AS> asList;

public ASConfedSequence(List<AS> asList) {
this.asList = new LinkedList<>();
this.asList.addAll(asList);
}

@Override
public String toString() {
return asList.stream().map(AS::toString).collect(Collectors.joining(" ", "[", "]"));
}

@Override
public List<AS> getASList() {
return this.asList;
}
}
32 changes: 32 additions & 0 deletions src/main/java/org/javamrt/mrt/ASConfedSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// This file is part of java-mrt
// A library to parse MRT files

// This file is released under LGPL 3.0
// http://www.gnu.org/licenses/lgpl-3.0-standalone.html

package org.javamrt.mrt;

import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

public class ASConfedSet extends AS {

private LinkedList<AS> asList;

public ASConfedSet(final List<AS> asList) {
this.asList = new LinkedList<>();
this.asList.addAll(asList);
}

@Override
public String toString() {
return asList.stream().map(AS::toString).collect(Collectors.joining(" ", "{", "}"));
}

@Override
public List<AS> getASList() {
return this.asList;
}
}

Loading