summaryrefslogtreecommitdiff
path: root/src/main/java/com/lumaserv/bgp/BGPServer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/lumaserv/bgp/BGPServer.java')
-rw-r--r--src/main/java/com/lumaserv/bgp/BGPServer.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main/java/com/lumaserv/bgp/BGPServer.java b/src/main/java/com/lumaserv/bgp/BGPServer.java
index 27019b6..63c0765 100644
--- a/src/main/java/com/lumaserv/bgp/BGPServer.java
+++ b/src/main/java/com/lumaserv/bgp/BGPServer.java
@@ -45,7 +45,7 @@ public class BGPServer implements Runnable {
BGPPacket packet = BGPPacket.read(socket.getInputStream());
if(packet.getType() != BGPPacket.Type.OPEN)
continue;
- BGPOpen request = new BGPOpen(packet.getMessage());
+ BGPOpen request = (BGPOpen)packet.getMessage();
BGPSessionConfiguration config = sessionConfigurations.stream()
.filter(c -> c.getRemoteAs() == request.getAsn())
.findFirst()
@@ -60,7 +60,7 @@ public class BGPServer implements Runnable {
.setVersion(request.getVersion())
.setIdentifier(config.getLocalIdentifier());
try {
- socket.getOutputStream().write(new BGPPacket().setType(BGPPacket.Type.OPEN).setMessage(response.build()).build());
+ socket.getOutputStream().write(new BGPPacket().setType(BGPPacket.Type.OPEN).setMessage(response).build());
} catch (IOException e) {
e.printStackTrace();
}
@@ -87,7 +87,7 @@ public class BGPServer implements Runnable {
.setHoldTime(holdTime)
.setVersion(version)
.setIdentifier(config.getLocalIdentifier());
- socket.getOutputStream().write(new BGPPacket().setType(BGPPacket.Type.OPEN).setMessage(request.build()).build());
+ socket.getOutputStream().write(new BGPPacket().setType(BGPPacket.Type.OPEN).setMessage(request).build());
System.out.println("Sent open");
@@ -100,10 +100,10 @@ System.out.println("Bad open");
return false;
}
System.out.println("Received open");
- BGPOpen response = new BGPOpen(packet.getMessage());
+ BGPOpen response = (BGPOpen)packet.getMessage();
if(config.getRemoteAs() != response.getAsn()) {
// TODO shutdown, close
-System.out.println("Bad asn");
+System.out.println("Bad asn:" + config.getRemoteAs() + "!=" + response.getAsn());
return false;
}