diff options
Diffstat (limited to 'src/main/java/com/lumaserv/bgp/BGPSession.java')
-rw-r--r-- | src/main/java/com/lumaserv/bgp/BGPSession.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/com/lumaserv/bgp/BGPSession.java b/src/main/java/com/lumaserv/bgp/BGPSession.java index 94a4f5a..21a5564 100644 --- a/src/main/java/com/lumaserv/bgp/BGPSession.java +++ b/src/main/java/com/lumaserv/bgp/BGPSession.java @@ -1,6 +1,8 @@ package com.lumaserv.bgp; +import com.lumaserv.bgp.protocol.AFI; import com.lumaserv.bgp.protocol.BGPPacket; +import com.lumaserv.bgp.protocol.SAFI; import com.lumaserv.bgp.protocol.message.BGPNotification; import com.lumaserv.bgp.protocol.message.BGPOpen; import com.lumaserv.bgp.protocol.message.BGPUpdate; @@ -92,11 +94,26 @@ public class BGPSession implements Runnable { thread.start(); } - public void sendOpen(BGPOpen request) throws IOException { + void sendOpen(BGPOpen request) throws IOException { outputStream.write(new BGPPacket().setType(BGPPacket.Type.OPEN).setMessage(request.build()).build()); System.out.println("Sent open"); } + public void sendOpen() throws IOException { + BGPOpen.Capabilities caps = new BGPOpen.Capabilities(); + caps.getCapabilities().add(new BGPOpen.MultiprotocolExtensionCapability(AFI.IPV4.getValue(), SAFI.UNICAST.getValue())); + caps.getCapabilities().add(new BGPOpen.MultiprotocolExtensionCapability(AFI.IPV6.getValue(), SAFI.UNICAST.getValue())); + + BGPOpen request = new BGPOpen() + .setAsn(configuration.getLocalAs()) + .setHoldTime(BGPFsm.CONFIG_HOLD_TIME) + .setVersion(BGPFsm.CONFIG_VERSION) + .setIdentifier(configuration.getLocalIdentifier()); + request.getOptionalParameters().add(caps); + + sendOpen(request); + } + public void retryConnection() { if (!socket.isConnected()) { try { |