├── .classpath
├── .gitignore
├── .project
├── Code-organization.md
├── LICENSE
├── README.md
├── config-samples
├── Client-Minimal.xml
├── Client-Server-Minimal.xml
├── Server-Minimal.xml
└── log-conf.xml
├── pom.xml
└── src
├── main
└── java
│ └── org
│ └── topology
│ └── bgp_ls
│ ├── bgpd
│ ├── BgpDaemon.java
│ ├── BgpDaemonApplicationListener.java
│ ├── BgpDaemonApplicationSelector.java
│ ├── ConfigurationFileProcessor.java
│ ├── package-info.java
│ └── resources
│ │ └── META-INF
│ │ └── beans.xml
│ ├── config
│ ├── Configuration.java
│ ├── ConfigurationParser.java
│ ├── ModifiableConfiguration.java
│ ├── global
│ │ ├── ApplicationConfiguration.java
│ │ ├── EventType.java
│ │ ├── PeerConfigurationEvent.java
│ │ ├── ServerConfigurationEvent.java
│ │ ├── TypedEvent.java
│ │ └── package-info.java
│ ├── impl
│ │ ├── ConfigurationImpl.java
│ │ ├── ConfigurationParserImpl.java
│ │ └── package-info.java
│ ├── nodes
│ │ ├── AddressFamilyRoutingConfiguration.java
│ │ ├── AddressFamilyRoutingPeerConfiguration.java
│ │ ├── Capabilities.java
│ │ ├── CapabilitiesList.java
│ │ ├── ClientConfiguration.java
│ │ ├── PathAttributeConfiguration.java
│ │ ├── PeerConfiguration.java
│ │ ├── PeerConfigurationTimer.java
│ │ ├── PrefixRoutingFilterConfiguration.java
│ │ ├── RouteConfiguration.java
│ │ ├── RoutingConfiguration.java
│ │ ├── RoutingFilterConfiguration.java
│ │ ├── RoutingInstanceConfiguration.java
│ │ ├── RoutingPeerConfiguration.java
│ │ ├── RoutingProcessorConfiguration.java
│ │ ├── ServerConfiguration.java
│ │ ├── impl
│ │ │ ├── AddressFamilyRoutingConfigurationImpl.java
│ │ │ ├── AddressFamilyRoutingConfigurationParser.java
│ │ │ ├── AddressFamilyRoutingPeerConfigurationImpl.java
│ │ │ ├── AddressFamilyRoutingPeerConfigurationParser.java
│ │ │ ├── BgpClientConfigurationImpl.java
│ │ │ ├── BgpServerConfigurationImpl.java
│ │ │ ├── BgpServerConfigurationParser.java
│ │ │ ├── CapabilitiesParser.java
│ │ │ ├── ClientConfigurationImpl.java
│ │ │ ├── ClientConfigurationParser.java
│ │ │ ├── FixedDefaultsPeerConfigurationTimer.java
│ │ │ ├── HttpServerConfigurationImpl.java
│ │ │ ├── HttpServerConfigurationParser.java
│ │ │ ├── NetworkLayerReachabilityParser.java
│ │ │ ├── PathAttributeConfigurationImpl.java
│ │ │ ├── PathAttributeConfigurationParser.java
│ │ │ ├── PeerConfigurationImpl.java
│ │ │ ├── PeerConfigurationParser.java
│ │ │ ├── PrefixRoutingFilterConfigurationImpl.java
│ │ │ ├── RouteConfigurationImpl.java
│ │ │ ├── RouteConfigurationParser.java
│ │ │ ├── RoutingConfigurationImpl.java
│ │ │ ├── RoutingConfigurationParser.java
│ │ │ ├── RoutingFilterConfigurationImpl.java
│ │ │ ├── RoutingFilterConfigurationParser.java
│ │ │ ├── RoutingFilterType.java
│ │ │ ├── RoutingProcessorConfigurationImpl.java
│ │ │ ├── RoutingProcessorConfigurationParser.java
│ │ │ ├── ServerConfigurationImpl.java
│ │ │ ├── ServerConfigurationParser.java
│ │ │ └── package-info.java
│ │ └── package-info.java
│ └── package-info.java
│ ├── net
│ ├── ASType.java
│ ├── ASTypeAware.java
│ ├── AddressFamily.java
│ ├── AddressFamilyKey.java
│ ├── AddressPrefixBasedORFEntry.java
│ ├── BinaryNextHop.java
│ ├── InetAddressComparator.java
│ ├── InetAddressNextHop.java
│ ├── NetworkLayerReachabilityInformation.java
│ ├── NextHop.java
│ ├── ORFAction.java
│ ├── ORFEntry.java
│ ├── ORFMatch.java
│ ├── ORFRefreshType.java
│ ├── ORFSendReceive.java
│ ├── ORFType.java
│ ├── Origin.java
│ ├── OutboundRouteFilter.java
│ ├── PathSegment.java
│ ├── PathSegmentType.java
│ ├── RIBSide.java
│ ├── SubsequentAddressFamily.java
│ ├── attributes
│ │ ├── ASPathAttribute.java
│ │ ├── AggregatorPathAttribute.java
│ │ ├── AtomicAggregatePathAttribute.java
│ │ ├── ClusterListPathAttribute.java
│ │ ├── CommunityMember.java
│ │ ├── CommunityPathAttribute.java
│ │ ├── LinkStateAttribute.java
│ │ ├── LocalPrefPathAttribute.java
│ │ ├── MultiExitDiscPathAttribute.java
│ │ ├── MultiProtocolNLRI.java
│ │ ├── MultiProtocolNLRIInformation.java
│ │ ├── NextHopPathAttribute.java
│ │ ├── OriginPathAttribute.java
│ │ ├── OriginatorIDPathAttribute.java
│ │ ├── PathAttribute.java
│ │ ├── PathAttributeType.java
│ │ ├── UnknownPathAttribute.java
│ │ ├── bgplsnlri
│ │ │ ├── BgpLsIPTopologyPrefixNLRI.java
│ │ │ ├── BgpLsIdentifier.java
│ │ │ ├── BgpLsIdentifierType.java
│ │ │ ├── BgpLsLinkDescriptor.java
│ │ │ ├── BgpLsLinkNLRI.java
│ │ │ ├── BgpLsNLRIInformation.java
│ │ │ ├── BgpLsNLRIType.java
│ │ │ ├── BgpLsNodeDescriptor.java
│ │ │ ├── BgpLsNodeNLRI.java
│ │ │ ├── BgpLsProtocolId.java
│ │ │ ├── BgpLsType.java
│ │ │ ├── BgpLsTypeV2.java
│ │ │ ├── IPPrefix.java
│ │ │ ├── export
│ │ │ │ ├── BgpLsIPTopologyPrefixNLRIExport.java
│ │ │ │ ├── BgpLsLinkNLRIExport.java
│ │ │ │ ├── BgpLsNodeNLRIExport.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ ├── export
│ │ │ ├── MultiProtocolNLRIExport.java
│ │ │ ├── MultiProtocolNLRIInformationExport.java
│ │ │ └── package-info.java
│ │ └── package-info.java
│ ├── capabilities
│ │ ├── AutonomousSystem4Capability.java
│ │ ├── Capability.java
│ │ ├── MultiProtocolCapability.java
│ │ ├── OutboundRouteFilteringCapability.java
│ │ ├── RouteRefreshCapability.java
│ │ ├── UnknownCapability.java
│ │ └── package-info.java
│ └── package-info.java
│ └── netty
│ ├── BGPv4Constants.java
│ ├── FSMState.java
│ ├── NLRICodec.java
│ ├── PeerConnectionInformation.java
│ ├── PeerConnectionInformationAware.java
│ ├── SingletonRegistry.java
│ ├── fsm
│ ├── BGPv4FSM.java
│ ├── CapabilitesNegotiator.java
│ ├── FSMChannel.java
│ ├── FSMEvent.java
│ ├── FSMEventType.java
│ ├── FSMRegistry.java
│ ├── FireAutomaticStart.java
│ ├── FireConnectRetryTimerExpired.java
│ ├── FireDelayOpenTimerExpired.java
│ ├── FireEventTimeJob.java
│ ├── FireEventTimeManager.java
│ ├── FireHoldTimerExpired.java
│ ├── FireIdleHoldTimerExpired.java
│ ├── FireRepeatedEventTimeManager.java
│ ├── FireSendKeepalive.java
│ ├── InternalFSM.java
│ ├── InternalFSMCallbacks.java
│ ├── InternalFSMChannelManager.java
│ └── package-info.java
│ ├── handlers
│ ├── BGPv4ClientEndpoint.java
│ ├── BGPv4Codec.java
│ ├── BGPv4Reframer.java
│ ├── BGPv4ServerEndpoint.java
│ ├── BgpEvent.java
│ ├── BgpEventFireChannelFutureListener.java
│ ├── InboundOpenCapabilitiesProcessor.java
│ ├── NotificationEvent.java
│ ├── NotificationHelper.java
│ ├── UpdateAttributeChecker.java
│ ├── ValidateServerIdentifier.java
│ └── package-info.java
│ ├── package-info.java
│ ├── protocol
│ ├── AdministrativeResetNotificationPacket.java
│ ├── AdministrativeShutdownNotificationPacket.java
│ ├── BGPv4Packet.java
│ ├── BGPv4PacketDecoder.java
│ ├── BadMessageLengthException.java
│ ├── BadMessageLengthNotificationPacket.java
│ ├── BadMessageTypeException.java
│ ├── BadMessageTypeNotificationPacket.java
│ ├── CeaseNotificationPacket.java
│ ├── ConnectionCollisionResolutionNotificationPacket.java
│ ├── ConnectionNotSynchronizedException.java
│ ├── ConnectionNotSynchronizedNotificationPacket.java
│ ├── ConnectionRejectedNotificationPacket.java
│ ├── FiniteStateMachineErrorNotificationPacket.java
│ ├── HoldTimerExpiredNotificationPacket.java
│ ├── KeepalivePacket.java
│ ├── MaximumNumberOfPrefixesReachedNotificationPacket.java
│ ├── MessageHeaderErrorNotificationPacket.java
│ ├── NotificationPacket.java
│ ├── OtherConfigurationChangeNotificationPacket.java
│ ├── OutOfResourcesNotificationPacket.java
│ ├── PeerDeconfiguredNotificationPacket.java
│ ├── ProtocolPacketException.java
│ ├── ProtocolPacketUtils.java
│ ├── UnspecifiedCeaseNotificationPacket.java
│ ├── open
│ │ ├── BadBgpIdentifierException.java
│ │ ├── BadBgpIdentifierNotificationPacket.java
│ │ ├── BadPeerASException.java
│ │ ├── BadPeerASNotificationPacket.java
│ │ ├── ByteArrayUnsupportedCapabilityNotificationPacket.java
│ │ ├── CapabilityCodec.java
│ │ ├── CapabilityException.java
│ │ ├── CapabilityListUnsupportedCapabilityNotificationPacket.java
│ │ ├── OpenNotificationPacket.java
│ │ ├── OpenPacket.java
│ │ ├── OpenPacketDecoder.java
│ │ ├── OpenPacketException.java
│ │ ├── UnacceptableHoldTimerException.java
│ │ ├── UnacceptableHoldTimerNotificationPacket.java
│ │ ├── UnspecificOpenNotificationPacket.java
│ │ ├── UnspecificOpenPacketException.java
│ │ ├── UnsupportedCapabilityException.java
│ │ ├── UnsupportedCapabilityNotificationPacket.java
│ │ ├── UnsupportedOptionalParameterException.java
│ │ ├── UnsupportedOptionalParameterNotificationPacket.java
│ │ ├── UnsupportedVersionNumberException.java
│ │ ├── UnsupportedVersionNumberNotificationPacket.java
│ │ └── package-info.java
│ ├── package-info.java
│ ├── refresh
│ │ ├── ORFEntryCodec.java
│ │ ├── RouteRefreshPacket.java
│ │ ├── RouteRefreshPacketDecoder.java
│ │ └── package-info.java
│ └── update
│ │ ├── ASPathAttributeCodecHandler.java
│ │ ├── AggregatorPathAttributeCodecHandler.java
│ │ ├── AtomicAggregatePathAttributeCodecHandler.java
│ │ ├── AttributeException.java
│ │ ├── AttributeFlagsException.java
│ │ ├── AttributeFlagsNotificationPacket.java
│ │ ├── AttributeLengthException.java
│ │ ├── AttributeLengthNotificationPacket.java
│ │ ├── AttributeNotificationPacket.java
│ │ ├── ClusterListPathAttributeCodecHandler.java
│ │ ├── CommunityPathAttributeCodecHandler.java
│ │ ├── InvalidNetworkFieldException.java
│ │ ├── InvalidNetworkFieldNotificationPacket.java
│ │ ├── InvalidNextHopException.java
│ │ ├── InvalidNextHopNotificationPacket.java
│ │ ├── InvalidOriginException.java
│ │ ├── InvalidOriginNotificationPacket.java
│ │ ├── LinkStateAttributeCodec.java
│ │ ├── LocalPrefPathAttributeCodecHandler.java
│ │ ├── MalformedASPathAttributeException.java
│ │ ├── MalformedASPathAttributeNotificationPacket.java
│ │ ├── MalformedAttributeListException.java
│ │ ├── MalformedAttributeListNotificationPacket.java
│ │ ├── MissingWellKnownAttributeException.java
│ │ ├── MissingWellKnownAttributeNotificationPacket.java
│ │ ├── MultiExitDiscPathAttributeCodecHandler.java
│ │ ├── MultiProtocolNLRICodec.java
│ │ ├── MultiProtocolNLRICodecHandler.java
│ │ ├── MultiProtocolNLRIDecoderTypes.java
│ │ ├── NextHopPathAttributeCodecHandler.java
│ │ ├── OptionalAttributeErrorException.java
│ │ ├── OptionalAttributeErrorNotificationPacket.java
│ │ ├── OriginCodec.java
│ │ ├── OriginPathAttributeCodecHandler.java
│ │ ├── OriginatorIDPathAttributeCodecHandler.java
│ │ ├── PathAttributeCodec.java
│ │ ├── PathAttributeCodecHandler.java
│ │ ├── PathSegmentTypeCodec.java
│ │ ├── UnknownPathAttributeCodecHandler.java
│ │ ├── UnrecognizedWellKnownAttributeException.java
│ │ ├── UnrecognizedWellKnownAttributeNotificationPacket.java
│ │ ├── UpdateNotificationPacket.java
│ │ ├── UpdatePacket.java
│ │ ├── UpdatePacketDecoder.java
│ │ ├── UpdatePacketException.java
│ │ ├── bgplsnlri
│ │ ├── BgpLsLinkDescriptorCodec.java
│ │ ├── BgpLsNLRICodec.java
│ │ ├── BgpLsNLRIVpnCodec.java
│ │ ├── BgpLsNodeDescriptorCodec.java
│ │ └── package-info.java
│ │ └── package-info.java
│ └── service
│ ├── BGPv4Client.java
│ ├── BGPv4Server.java
│ ├── BGPv4Service.java
│ ├── ChannelFactoryProducer.java
│ ├── ClientFactory.java
│ └── package-info.java
└── test
└── java
└── org
└── topology
└── bgp_ls
└── AppTest.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.txt
2 | *.dtd
3 | *~
4 | *.swp
5 | .DS_Store
6 | .#*
7 | *.prefs
8 | target
9 | doc/*
10 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | bgp-ls
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.maven.ide.eclipse.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.maven.ide.eclipse.maven2Nature
21 | org.eclipse.jdt.core.javanature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | bgp-ls
2 | ======
3 |
4 | This project aims to expose network topology through Border Gateway Protocol (BGP) Link State extensions defined in [draft-ietf-idr-ls-distribution](http://tools.ietf.org/html/draft-ietf-idr-ls-distribution).
5 |
6 | This is built on top of a BGP daemon that connects to a BGP peer in the network. Topology is learnt via BGP extenions defined in the above draft. The daemon processed real-time topology updates and writes them in JSON format to a text file.
7 |
8 | The core BGP daemon is taken from the open-source project [rbieniek/BGP4J](https://github.com/rbieniek/BGP4J). The base project was modified to run as a standalone Java application and BGP Link state extensions were then added on top of it.
9 |
10 | Currently the code is based off draft-ietf-idr-ls-distribution-01. It is not compatible with version -00 or -02 (and beyond).
11 |
12 | This source is licensed under Apache 2.0.
13 |
14 | Build environment:
15 | -----------------
16 | This project requires a minimum of JavaSE-1.6.
17 |
18 | It depends on the following libraries.
19 | - junit-3.8.1
20 | - quartz-2.1.6 (org.quartz-scheduler)
21 | - jackson-core-asl-1.9.12 (org.codehaus.jackson)
22 | - jackson-mapper-asl-1.9.12 (org.codehaus.jackson)
23 | - commons-lang3-3.1
24 | - logging-1.0.4
25 | - log4j-1.2.15
26 | - slf4j-api-1.7.2 (org.slf4j.api)
27 | - slf4j.log4j12-1.7.2 (org.slf4j.log4j12)
28 | - commons-configuration-1.9 (commons-configuration)
29 | - netty-3.6.3.Final
30 | - cli-1.0.0 (org.mod4j.org.apache.commons)
31 | - commons-lang-2.6
32 | - commons-logging-1.1.1
33 |
34 | Dependencies can be directly obtained using maven pom file.
35 |
36 | Runtime arguments
37 | =================
38 | Required:
39 | -c
40 |
41 | Optional:
42 | -l
43 | -e
44 |
45 | See the config-samples directory, for a sample of config-file and log-config-file
46 |
47 | If the argument is not provided, then topology data will not be exported to a file.
48 |
49 |
50 |
--------------------------------------------------------------------------------
/config-samples/Client-Minimal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/config-samples/Client-Server-Minimal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/config-samples/Server-Minimal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/bgpd/BgpDaemonApplicationListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | /**
18 | * Copyright 2013 Nitin Bahadur (nitinb@gmail.com)
19 | *
20 | * License: same as above
21 | *
22 | * Modified to run as an independent java application, one that does not
23 | * require webserver or app server
24 | */
25 | package org.topology.bgp_ls.bgpd;
26 |
27 | import org.topology.bgp_ls.netty.service.BGPv4Service;
28 |
29 | /**
30 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
31 | *
32 | */
33 | public class BgpDaemonApplicationListener extends Thread implements Runnable {
34 | private BGPv4Service bgpService;
35 |
36 | /**
37 | *
38 | */
39 | public BgpDaemonApplicationListener() {
40 | }
41 |
42 | public void run () {
43 | bgpService = new BGPv4Service();
44 | bgpService.startService();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/bgpd/BgpDaemonApplicationSelector.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.bgpd;
18 |
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | @Retention(RetentionPolicy.RUNTIME)
27 | public @interface BgpDaemonApplicationSelector {
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/bgpd/ConfigurationFileProcessor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4j.apps.bgpd.config.ConfigurationFileProcessor.java
17 | */
18 | package org.topology.bgp_ls.bgpd;
19 |
20 | import org.apache.commons.configuration.ConfigurationException;
21 | import org.apache.commons.configuration.XMLConfiguration;
22 | import org.topology.bgp_ls.config.ConfigurationParser;
23 | import org.topology.bgp_ls.config.global.ApplicationConfiguration;
24 | import org.topology.bgp_ls.netty.SingletonRegistry;
25 |
26 | /**
27 | * This class manages the access to the configuration file provided on the command line.
28 | *
29 | * NB: The current version just parses the config file once. A future release will support automatic
30 | * detection of an updated configuration file and soft configuration changes
31 | *
32 | * @author Rainer Bieniek (rainer@bgp4j.org)
33 | *
34 | */
35 | public class ConfigurationFileProcessor {
36 |
37 | private ConfigurationParser configurationParser;
38 | private ApplicationConfiguration applicationConfiguration;
39 |
40 |
41 | public ConfigurationFileProcessor () {
42 | configurationParser = new ConfigurationParser();
43 | applicationConfiguration = (ApplicationConfiguration)SingletonRegistry.getInstance(ApplicationConfiguration.class.getName());
44 | }
45 |
46 | public void processConfigFile(String configFile) throws ConfigurationException {
47 | applicationConfiguration.importConfiguration(configurationParser.parseConfiguration(new XMLConfiguration(configFile)));
48 | }
49 |
50 | public ApplicationConfiguration getApplicationConfiguration() {
51 | return applicationConfiguration;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/bgpd/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for running BGP topology client as an application
3 | */
4 | package org.topology.bgp_ls.bgpd;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/bgpd/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
21 |
22 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/Configuration.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.Configuration.java
17 | */
18 | package org.topology.bgp_ls.config;
19 |
20 | import java.util.List;
21 | import java.util.Set;
22 |
23 | import org.topology.bgp_ls.config.nodes.PeerConfiguration;
24 | import org.topology.bgp_ls.config.nodes.RoutingProcessorConfiguration;
25 | import org.topology.bgp_ls.config.nodes.ServerConfiguration;
26 |
27 | /**
28 | * Configuration object of the BGP daemon.
29 | *
30 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
31 | *
32 | */
33 | public interface Configuration {
34 |
35 | /**
36 | * get the server configuration
37 | *
38 | * @return
39 | */
40 | public ServerConfiguration getBgpServerConfiguration();
41 |
42 | /**
43 | * get the HTTP server configuration
44 | *
45 | * @return
46 | */
47 | public ServerConfiguration getHttpServerConfiguration();
48 |
49 | /**
50 | * list peer names
51 | *
52 | * @return
53 | */
54 | public Set listPeerNames();
55 |
56 | /**
57 | * list peer names
58 | *
59 | * @return
60 | */
61 | public List listPeerConfigurations();
62 |
63 | /**
64 | *
65 | */
66 | public PeerConfiguration getPeer(String peerName);
67 |
68 | /**
69 | *
70 | * @return
71 | */
72 | public RoutingProcessorConfiguration getRoutingProcessorConfiguration();
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/ModifiableConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.ModifiableConfiguration.java
17 | */
18 | package org.topology.bgp_ls.config;
19 |
20 | import org.topology.bgp_ls.config.nodes.ServerConfiguration;
21 | import org.topology.bgp_ls.config.nodes.RoutingProcessorConfiguration;
22 |
23 | /**
24 | * Interface implemented by configuration obejct which support modifications of its contents
25 | *
26 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
27 | *
28 | */
29 | public interface ModifiableConfiguration extends Configuration {
30 | /**
31 | *
32 | *
33 | * @param serverConfiguration
34 | */
35 | public void setBgpServerConfiguration(ServerConfiguration serverConfiguration);
36 |
37 | /**
38 | *
39 | *
40 | * @param serverConfiguration
41 | */
42 | public void setHttpServerConfiguration(ServerConfiguration serverConfiguration);
43 |
44 | /**
45 | *
46 | * @param routingProcessorConfiguration
47 | */
48 | public void setRoutingProcessorConfiguration(RoutingProcessorConfiguration routingProcessorConfiguration);
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/global/EventType.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.config.global;
2 |
3 | public enum EventType {
4 | CONFIGURATION_ADDED,
5 | CONFIGURATION_CHANGED,
6 | CONFIGURATION_REMOVED;
7 |
8 | public static EventType determineEvent(Object former, Object current) {
9 | if(former == null && current != null)
10 | return CONFIGURATION_ADDED;
11 | else if(former != null && current == null)
12 | return CONFIGURATION_REMOVED;
13 | else if(former != null && current != null && !former.equals(current))
14 | return CONFIGURATION_CHANGED;
15 | else
16 | return null;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/global/PeerConfigurationEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.global.BgpServerConfigurationEvent.java
17 | */
18 | package org.topology.bgp_ls.config.global;
19 |
20 | import org.topology.bgp_ls.config.nodes.PeerConfiguration;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class PeerConfigurationEvent extends TypedEvent {
27 |
28 | private PeerConfiguration former;
29 | private PeerConfiguration current;
30 |
31 | public PeerConfigurationEvent(EventType type, PeerConfiguration former, PeerConfiguration current) {
32 | super(type);
33 |
34 | this.former = former;
35 | this.current = current;
36 | }
37 |
38 | /**
39 | * @return the configuration
40 | */
41 | public PeerConfiguration getFormer() {
42 | return former;
43 | }
44 |
45 | /**
46 | * @return the current
47 | */
48 | public PeerConfiguration getCurrent() {
49 | return current;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/global/ServerConfigurationEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.global.BgpServerConfigurationEvent.java
17 | */
18 | package org.topology.bgp_ls.config.global;
19 |
20 | import org.topology.bgp_ls.config.nodes.ServerConfiguration;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class ServerConfigurationEvent extends TypedEvent {
27 |
28 | private ServerConfiguration configuration;
29 |
30 | public ServerConfigurationEvent(EventType type, ServerConfiguration configuration) {
31 | super(type);
32 | this.configuration = configuration;
33 | }
34 |
35 | /**
36 | * @return the configuration
37 | */
38 | public ServerConfiguration getConfiguration() {
39 | return configuration;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/global/TypedEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.global.TypedEvent.java
17 | */
18 | package org.topology.bgp_ls.config.global;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class TypedEvent {
25 |
26 | protected TypedEvent(EventType type) {
27 | this.type = type;
28 | }
29 |
30 | private EventType type;
31 |
32 | /**
33 | * @return the type
34 | */
35 | public EventType getType() {
36 | return type;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/global/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for building configuration objects and reacting to changes in configuration
3 | */
4 | package org.topology.bgp_ls.config.global;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/impl/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Implementation of object level configuration parsing
3 | */
4 | package org.topology.bgp_ls.config.impl;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/AddressFamilyRoutingConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes;
5 |
6 | import java.util.Set;
7 |
8 | import org.topology.bgp_ls.net.AddressFamilyKey;
9 |
10 | /**
11 | * @author rainer
12 | *
13 | */
14 | public interface AddressFamilyRoutingConfiguration extends Comparable {
15 |
16 | /**
17 | * get the keying address / subsequent address family pair
18 | *
19 | * @return
20 | */
21 | public AddressFamilyKey getKey();
22 |
23 | /**
24 | * get the routes advertised for this address / subsequent address pair
25 | *
26 | * @return
27 | */
28 | public Set getRoutes();
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/AddressFamilyRoutingPeerConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes;
5 |
6 | import java.util.Set;
7 |
8 | import org.topology.bgp_ls.net.AddressFamilyKey;
9 |
10 | /**
11 | * @author rainer
12 | *
13 | */
14 | public interface AddressFamilyRoutingPeerConfiguration extends Comparable {
15 |
16 | /**
17 | * get the address family key for this rooting confguration
18 | *
19 | * @return
20 | */
21 | public AddressFamilyKey getAddressFamilyKey();
22 |
23 | /**
24 | * get the path attributes which are inserted into routes injected into the
25 | * local-side routing information base of a peer
26 | *
27 | * @return
28 | */
29 | public PathAttributeConfiguration getLocalDefaultPathAttributes();
30 |
31 | /**
32 | * get the filters to be applied on routes before they are inserted into the
33 | * local-side routing information base of a peer
34 | *
35 | * @return
36 | */
37 | public Set getLocalRoutingFilters();
38 |
39 | /**
40 | * get the path attributes which are inserted into routes received from the
41 | * remote-side routing information base of a peer
42 | *
43 | * @return
44 | */
45 | public PathAttributeConfiguration getRemoteDefaultPathAttributes();
46 |
47 | /**
48 | * get the filters to be applied on routes after they have been received from the remote-side
49 | * routing information base of a peer
50 | *
51 | * @return
52 | */
53 | public Set getRemoteRoutingFilters();
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/Capabilities.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.nodes.Capabilities.java
17 | */
18 | package org.topology.bgp_ls.config.nodes;
19 |
20 | import java.util.Set;
21 |
22 | import org.topology.bgp_ls.net.capabilities.Capability;
23 |
24 | /**
25 | * @author Rainer Bieniek (rainer@bgp4j.org)
26 | *
27 | */
28 | public interface Capabilities {
29 |
30 | /**
31 | *
32 | * @return
33 | */
34 | public Set getRequiredCapabilities();
35 |
36 | /**
37 | *
38 | * @return
39 | */
40 | public Set getOptionalCapabilities();
41 |
42 | /**
43 | *
44 | * @return
45 | */
46 | @Override
47 | public boolean equals(Object other);
48 |
49 | /**
50 | *
51 | * @return
52 | */
53 | @Override
54 | public int hashCode();
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/ClientConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.ServerConfiguration.java
17 | */
18 | package org.topology.bgp_ls.config.nodes;
19 |
20 | import java.net.InetSocketAddress;
21 |
22 | /**
23 | * Configuration for generic network server
24 | *
25 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
26 | *
27 | */
28 | public interface ClientConfiguration {
29 | /**
30 | * get the listen address with the port number
31 | * @return
32 | */
33 | public InetSocketAddress getRemoteAddress();
34 |
35 | /**
36 | *
37 | * @return
38 | */
39 | @Override
40 | public boolean equals(Object other);
41 |
42 | /**
43 | *
44 | * @return
45 | */
46 | @Override
47 | public int hashCode();
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/PathAttributeConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes;
5 |
6 | import java.util.Set;
7 |
8 | import org.topology.bgp_ls.net.attributes.PathAttribute;
9 |
10 | /**
11 | * @author rainer
12 | *
13 | */
14 | public interface PathAttributeConfiguration extends Comparable{
15 |
16 | /**
17 | *
18 | * @return
19 | */
20 | public Set getAttributes();
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/PeerConfigurationTimer.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes;
5 |
6 | /**
7 | * @author nitinb
8 | *
9 | */
10 | public interface PeerConfigurationTimer {
11 |
12 | /**
13 | * @return
14 | */
15 | public int getHoldTime();
16 |
17 | /**
18 | * @return
19 | */
20 | public int getIdleHoldTime();
21 |
22 | /**
23 | * @return
24 | */
25 | public int getDelayOpenTime();
26 |
27 | /**
28 | * @return
29 | */
30 | public int getConnectRetryTime();
31 |
32 | /**
33 | * @return
34 | */
35 | public int getAutomaticStartInterval();
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/PrefixRoutingFilterConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes;
5 |
6 | import java.util.Set;
7 |
8 | import org.topology.bgp_ls.net.NetworkLayerReachabilityInformation;
9 |
10 | /**
11 | * @author rainer
12 | *
13 | */
14 | public interface PrefixRoutingFilterConfiguration extends RoutingFilterConfiguration {
15 |
16 | /**
17 | * get the route prefixes which are filtered out
18 | *
19 | * @return
20 | */
21 | public Set getFilterPrefixes();
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/RouteConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes;
5 |
6 | import org.topology.bgp_ls.net.NetworkLayerReachabilityInformation;
7 |
8 | /**
9 | * @author rainer
10 | *
11 | */
12 | public interface RouteConfiguration extends Comparable {
13 |
14 | /**
15 | * get the NLRI of the advertised route
16 | *
17 | * @return
18 | */
19 | public NetworkLayerReachabilityInformation getNlri();
20 |
21 | /**
22 | * get the path attributes which should be advertised for a route
23 | *
24 | * @return
25 | */
26 | public PathAttributeConfiguration getPathAttributes();
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/RoutingConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes;
5 |
6 | import java.util.Set;
7 |
8 | /**
9 | * @author rainer
10 | *
11 | */
12 | public interface RoutingConfiguration extends Comparable {
13 |
14 | /**
15 | * get the routing confguration per Adress and Subsequent Address family per
16 | *
17 | * @return
18 | */
19 | public Set getRoutingConfigurations();
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/RoutingFilterConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes;
5 |
6 | /**
7 | * @author rainer
8 | *
9 | */
10 | public interface RoutingFilterConfiguration extends Comparable {
11 |
12 | /**
13 | * get the routing filter name
14 | *
15 | * @return
16 | */
17 | public String getName();
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/RoutingInstanceConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes;
5 |
6 | /**
7 | * @author rainer
8 | *
9 | */
10 | public interface RoutingInstanceConfiguration extends Comparable {
11 |
12 | public RoutingPeerConfiguration getFirstPeer();
13 |
14 | public RoutingPeerConfiguration getSecondPeer();
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/RoutingPeerConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes;
5 |
6 | import java.util.Set;
7 |
8 | /**
9 | * @author rainer
10 | *
11 | */
12 | public interface RoutingPeerConfiguration extends Comparable {
13 |
14 | /**
15 | * get the peer name.
16 | *
17 | * @return
18 | */
19 | public String getPeerName();
20 |
21 | /**
22 | * get the routing configurations specific per AddressFamilyKey
23 | *
24 | * @return
25 | */
26 | public Set getAddressFamilyConfigrations();
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/RoutingProcessorConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes;
5 |
6 | import java.util.Set;
7 |
8 | /**
9 | * @author rainer
10 | *
11 | */
12 | public interface RoutingProcessorConfiguration extends Comparable {
13 |
14 | public Set getRoutingInstances();
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/ServerConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.ServerConfiguration.java
17 | */
18 | package org.topology.bgp_ls.config.nodes;
19 |
20 | import java.net.InetSocketAddress;
21 |
22 | /**
23 | * Configuration for generic network server
24 | *
25 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
26 | *
27 | */
28 | public interface ServerConfiguration {
29 |
30 | /**
31 | * Sets the port for the server
32 | */
33 | public void setPort (int port);
34 |
35 | /**
36 | * return the port for this server
37 | * @return
38 | */
39 | public int getPort();
40 |
41 | /**
42 | * get the listen address with the port number
43 | * @return
44 | */
45 | public InetSocketAddress getListenAddress();
46 |
47 | /**
48 | *
49 | * @return
50 | */
51 | @Override
52 | public boolean equals(Object other);
53 |
54 | /**
55 | *
56 | * @return
57 | */
58 | @Override
59 | public int hashCode();
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/impl/AddressFamilyRoutingConfigurationParser.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes.impl;
5 |
6 | import java.util.LinkedList;
7 | import java.util.List;
8 |
9 | import org.apache.commons.configuration.ConfigurationException;
10 | import org.apache.commons.configuration.HierarchicalConfiguration;
11 | import org.topology.bgp_ls.config.nodes.AddressFamilyRoutingConfiguration;
12 | import org.topology.bgp_ls.config.nodes.RouteConfiguration;
13 | import org.topology.bgp_ls.net.AddressFamily;
14 | import org.topology.bgp_ls.net.AddressFamilyKey;
15 | import org.topology.bgp_ls.net.SubsequentAddressFamily;
16 | import org.topology.bgp_ls.netty.SingletonRegistry;
17 |
18 | /**
19 | * @author rainer
20 | *
21 | */
22 | public class AddressFamilyRoutingConfigurationParser {
23 |
24 | private RouteConfigurationParser routeParser;
25 |
26 | public AddressFamilyRoutingConfigurationParser() {
27 | routeParser = (RouteConfigurationParser)SingletonRegistry.getInstance(RouteConfigurationParser.class.getName());
28 | }
29 |
30 | AddressFamilyRoutingConfiguration parseConfiguration(HierarchicalConfiguration config) throws ConfigurationException {
31 | try {
32 | AddressFamilyKey key = new AddressFamilyKey(AddressFamily.fromString(config.getString("[@addressFamily]")),
33 | SubsequentAddressFamily.fromString(config.getString("[@subsequentAddressFamily]")));
34 |
35 | List routes = new LinkedList();
36 |
37 | for(HierarchicalConfiguration routeConfig : config.configurationsAt("Route"))
38 | routes.add(routeParser.parseConfiguration(routeConfig));
39 |
40 | return new AddressFamilyRoutingConfigurationImpl(key, routes);
41 | } catch(IllegalArgumentException e) {
42 | throw new ConfigurationException("Invalid value: ", e);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/impl/BgpClientConfigurationImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.nodes.impl.BgpClientConfigurationImpl.java
17 | */
18 | /**
19 | * Copyright 2013 Nitin Bahadur (nitinb@gmail.com)
20 | *
21 | * License: same as above
22 | *
23 | * Modified to run as an independent java application, one that does not
24 | * require webserver or app server
25 | */
26 | package org.topology.bgp_ls.config.nodes.impl;
27 |
28 | import org.topology.bgp_ls.config.nodes.ClientConfiguration;
29 | import org.apache.commons.configuration.ConfigurationException;
30 |
31 | /**
32 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
33 | *
34 | */
35 | public class BgpClientConfigurationImpl extends ClientConfigurationImpl {
36 |
37 | private static final int BGP_PORT = 179;
38 |
39 | public BgpClientConfigurationImpl() {}
40 |
41 | public BgpClientConfigurationImpl (ClientConfiguration config) throws ConfigurationException {
42 | super(config.getRemoteAddress().getAddress(), BGP_PORT);
43 | }
44 |
45 | public int getDefaultPort() {
46 | return BGP_PORT;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/impl/BgpServerConfigurationImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.impl.BgpServerConfigurationImpl.java
17 | */
18 | /**
19 | * Copyright 2013 Nitin Bahadur (nitinb@gmail.com)
20 | *
21 | * License: same as above
22 | *
23 | * Modified to run as an independent java application, one that does not
24 | * require webserver or app server
25 | */
26 | package org.topology.bgp_ls.config.nodes.impl;
27 |
28 | /**
29 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
30 | *
31 | */
32 | public class BgpServerConfigurationImpl extends ServerConfigurationImpl {
33 |
34 | private static final int BGP_PORT = 179;
35 |
36 | public BgpServerConfigurationImpl() {
37 | super.setPort(BGP_PORT);
38 | }
39 |
40 | public int getDefaultPort () {
41 | return BGP_PORT;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/impl/BgpServerConfigurationParser.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.impl.BgpServerConfigurationParser.java
17 | */
18 | package org.topology.bgp_ls.config.nodes.impl;
19 |
20 | import java.util.List;
21 |
22 | import org.apache.commons.configuration.ConfigurationException;
23 | import org.apache.commons.configuration.HierarchicalConfiguration;
24 | import org.topology.bgp_ls.config.nodes.ServerConfiguration;
25 |
26 | /**
27 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
28 | *
29 | */
30 | public class BgpServerConfigurationParser extends ServerConfigurationParser {
31 |
32 | public BgpServerConfigurationParser () {
33 | }
34 |
35 | public ServerConfiguration parseConfig(HierarchicalConfiguration config) throws ConfigurationException {
36 | BgpServerConfigurationImpl result = new BgpServerConfigurationImpl();
37 | List serverConfig = config.configurationsAt("Server");
38 |
39 | if(serverConfig.size() == 1) {
40 | result.setServerConfiguration(super.parseConfig(serverConfig.get(0)));
41 | } else if(serverConfig.size() > 1) {
42 | throw new ConfigurationException("duplicate element");
43 | }
44 |
45 | return result;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/impl/ClientConfigurationParser.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.config.nodes.impl;
18 |
19 | import java.net.InetAddress;
20 | import java.net.InetSocketAddress;
21 | import java.net.UnknownHostException;
22 |
23 | import org.apache.commons.configuration.ConfigurationException;
24 | import org.apache.commons.configuration.HierarchicalConfiguration;
25 | import org.apache.commons.lang3.StringUtils;
26 | import org.topology.bgp_ls.config.nodes.ClientConfiguration;
27 | import org.slf4j.Logger;
28 | import org.slf4j.LoggerFactory;
29 |
30 | /**
31 | * Parse a generic server configuration
32 | *
33 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
34 | *
35 | */
36 | public class ClientConfigurationParser {
37 | private static final Logger log = LoggerFactory.getLogger(ClientConfigurationParser.class);
38 |
39 | public ClientConfigurationParser () {
40 | }
41 |
42 | public ClientConfiguration parseConfig(HierarchicalConfiguration config) throws ConfigurationException {
43 | InetAddress address = null;
44 | int port = config.getInt("[@port]", 0);
45 | String listenRep = config.getString("[@remote]");
46 |
47 | if(StringUtils.isBlank(listenRep))
48 | throw new ConfigurationException("remote attribute required");
49 |
50 | try {
51 | address = InetAddress.getByName(listenRep);
52 | } catch (UnknownHostException e) {
53 | log.error("failed to parse remote address: " + listenRep, e);
54 |
55 | throw new ConfigurationException(e);
56 | }
57 |
58 | return new ClientConfigurationImpl(new InetSocketAddress(address, port));
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/impl/HttpServerConfigurationImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.impl.HttpServerConfigurationImpl.java
17 | */
18 | /**
19 | * Copyright 2013 Nitin Bahadur (nitinb@gmail.com)
20 | *
21 | * License: same as above
22 | *
23 | * Modified to run as an independent java application, one that does not
24 | * require webserver or app server
25 | */
26 | package org.topology.bgp_ls.config.nodes.impl;
27 |
28 | /**
29 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
30 | *
31 | */
32 | public class HttpServerConfigurationImpl extends ServerConfigurationImpl {
33 |
34 | private static final int HTTP_NON_ROOT_PORT = 8080;
35 |
36 | public HttpServerConfigurationImpl() {
37 | super.setPort(HTTP_NON_ROOT_PORT);
38 | }
39 |
40 | public int getDefaultPort() {
41 | return HTTP_NON_ROOT_PORT;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/impl/HttpServerConfigurationParser.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.impl.BgpServerConfigurationParser.java
17 | */
18 | package org.topology.bgp_ls.config.nodes.impl;
19 |
20 | import java.util.List;
21 |
22 | import org.apache.commons.configuration.ConfigurationException;
23 | import org.apache.commons.configuration.HierarchicalConfiguration;
24 | import org.topology.bgp_ls.config.nodes.ServerConfiguration;
25 |
26 | /**
27 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
28 | *
29 | */
30 | public class HttpServerConfigurationParser extends ServerConfigurationParser {
31 |
32 | public HttpServerConfigurationParser () {
33 | }
34 |
35 | public ServerConfiguration parseConfig(HierarchicalConfiguration config) throws ConfigurationException {
36 | HttpServerConfigurationImpl result = new HttpServerConfigurationImpl();
37 | List serverConfig = config.configurationsAt("Server");
38 |
39 | if(serverConfig.size() == 1)
40 | result.setServerConfiguration(super.parseConfig(serverConfig.get(0)));
41 | else if(serverConfig.size() > 1)
42 | throw new ConfigurationException("duplicate element");
43 | else
44 | result.setServerConfiguration(new ServerConfigurationImpl());
45 |
46 | return result;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/impl/RouteConfigurationParser.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes.impl;
5 |
6 | import java.util.List;
7 |
8 | import org.apache.commons.configuration.ConfigurationException;
9 | import org.apache.commons.configuration.HierarchicalConfiguration;
10 | import org.apache.commons.lang3.StringUtils;
11 | import org.topology.bgp_ls.config.nodes.PathAttributeConfiguration;
12 | import org.topology.bgp_ls.config.nodes.RouteConfiguration;
13 | import org.topology.bgp_ls.netty.SingletonRegistry;
14 |
15 | /**
16 | * @author rainer
17 | *
18 | */
19 | public class RouteConfigurationParser {
20 | private PathAttributeConfigurationParser pathAttrParser;
21 | private NetworkLayerReachabilityParser nlriParser;
22 |
23 | public RouteConfigurationParser() {
24 | nlriParser = (NetworkLayerReachabilityParser)SingletonRegistry.getInstance(NetworkLayerReachabilityParser.class.getName());
25 | pathAttrParser = (PathAttributeConfigurationParser)SingletonRegistry.getInstance(PathAttributeConfigurationParser.class.getName());
26 | }
27 |
28 | public RouteConfiguration parseConfiguration(HierarchicalConfiguration config) throws ConfigurationException {
29 | String prefix = config.getString("Prefix[@value]");
30 | List pa = config.configurationsAt("PathAttributes");
31 |
32 | if(StringUtils.isBlank(prefix))
33 | throw new ConfigurationException("NLRI missing");
34 | if(pa.size() > 1)
35 | throw new ConfigurationException("PathAttributes missing of given multiple times");
36 | else {
37 | PathAttributeConfiguration pac = new PathAttributeConfigurationImpl();
38 |
39 | if(pa.size() == 1)
40 | pac = pathAttrParser.parseConfiguration(pa.get(0));
41 |
42 | return new RouteConfigurationImpl(nlriParser.parseNlri(prefix), pac);
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/impl/RoutingConfigurationParser.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes.impl;
5 |
6 | import java.util.HashSet;
7 | import java.util.Set;
8 |
9 | import org.apache.commons.configuration.ConfigurationException;
10 | import org.apache.commons.configuration.HierarchicalConfiguration;
11 | import org.topology.bgp_ls.config.nodes.AddressFamilyRoutingConfiguration;
12 | import org.topology.bgp_ls.config.nodes.RoutingConfiguration;
13 | import org.topology.bgp_ls.net.AddressFamilyKey;
14 |
15 | /**
16 | * @author rainer
17 | *
18 | */
19 | public class RoutingConfigurationParser {
20 |
21 | private AddressFamilyRoutingConfigurationParser afParser;
22 |
23 | public RoutingConfigurationParser() {
24 | afParser = new AddressFamilyRoutingConfigurationParser();
25 | }
26 |
27 | public RoutingConfiguration parseConfiguration(HierarchicalConfiguration config) throws ConfigurationException {
28 | RoutingConfigurationImpl result = new RoutingConfigurationImpl();
29 | Set keys = new HashSet();
30 |
31 | for(HierarchicalConfiguration afConfig: config.configurationsAt("AddressFamily")) {
32 | AddressFamilyRoutingConfiguration afRouting = afParser.parseConfiguration(afConfig);
33 |
34 | if(keys.contains(afRouting.getKey()))
35 | throw new ConfigurationException("Duplicate address family: " + afRouting.getKey());
36 |
37 | result.getRoutingConfigurations().add(afRouting);
38 | keys.add(afRouting.getKey());
39 | }
40 |
41 | return result;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/impl/RoutingFilterType.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package org.topology.bgp_ls.config.nodes.impl;
5 |
6 | /**
7 | * @author rainer
8 | *
9 | */
10 | public enum RoutingFilterType {
11 | PREFIX;
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/impl/RoutingProcessorConfigurationParser.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.bgp4.config.nodes.CapabilitiesList.java
17 | */
18 | /**
19 | * Copyright 2013 Nitin Bahadur (nitinb@gmail.com)
20 | *
21 | * License: same as above
22 | *
23 | * Modified to run as an independent java application, one that does not
24 | * require webserver or app server
25 | */
26 | package org.topology.bgp_ls.config.nodes.impl;
27 |
28 | import org.apache.commons.configuration.ConfigurationException;
29 | import org.apache.commons.configuration.HierarchicalConfiguration;
30 | import org.topology.bgp_ls.config.nodes.RoutingProcessorConfiguration;
31 |
32 | /**
33 | * @author rainer
34 | *
35 | */
36 | public class RoutingProcessorConfigurationParser {
37 |
38 | public RoutingProcessorConfiguration parseConfiguration(HierarchicalConfiguration config) throws ConfigurationException {
39 | return null;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/impl/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Implementation of parsing and storing various configuration objects
3 | */
4 | package org.topology.bgp_ls.config.nodes.impl;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/nodes/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Interfaces and classes that broadly define configuration objects
3 | */
4 | package org.topology.bgp_ls.config.nodes;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/config/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for abstracting overall configuration parsing details
3 | */
4 | package org.topology.bgp_ls.config;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/ASType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.ASType.java
17 | */
18 | package org.topology.bgp_ls.net;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public enum ASType {
25 | AS_NUMBER_2OCTETS,
26 | AS_NUMBER_4OCTETS,
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/ASTypeAware.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.net;
2 |
3 | public interface ASTypeAware {
4 |
5 | /**
6 | * @return the asType
7 | */
8 | public abstract ASType getAsType();
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/InetAddressComparator.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.net;
2 |
3 | import java.net.InetAddress;
4 | import java.util.Comparator;
5 |
6 | public final class InetAddressComparator implements Comparator {
7 | public int compare(InetAddress l, InetAddress r) {
8 | byte[] la = l.getAddress();
9 | byte[] ra = r.getAddress();
10 |
11 | if(la.length < ra.length)
12 | return -1;
13 | else if(la.length > ra.length)
14 | return 1;
15 | else {
16 | for(int i=0; i ra[i])
20 | return 1;
21 | }
22 |
23 | return 0;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/NextHop.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.rib.NextHop.java
17 | */
18 | package org.topology.bgp_ls.net;
19 |
20 | /**
21 | * Generic next-hop information
22 | *
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public interface NextHop extends Comparable {
27 |
28 | public enum Type {
29 | InetAddress,
30 | Binary;
31 | }
32 |
33 | /**
34 | * Equals other instance
35 | *
36 | * @param o
37 | * @return
38 | */
39 | public boolean equals(Object o);
40 |
41 | /**
42 | * Hash code of this instance
43 | *
44 | * @return
45 | */
46 | public int hashCode();
47 |
48 | /**
49 | * get the type of the next hop
50 | *
51 | * @return
52 | */
53 | public Type getType();
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/ORFAction.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.refresh.ORFAction.java
17 | */
18 | package org.topology.bgp_ls.net;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public enum ORFAction {
25 | ADD,
26 | REMOVE,
27 | REMOVE_ALL;
28 |
29 | public int toCode() {
30 | switch(this) {
31 | case ADD:
32 | return 0;
33 | case REMOVE:
34 | return 1;
35 | case REMOVE_ALL:
36 | return 2;
37 | default:
38 | throw new IllegalArgumentException("unknown ORF action: " + this);
39 | }
40 | }
41 |
42 | public static ORFAction fromCode(int code) {
43 | switch(code) {
44 | case 0:
45 | return ADD;
46 | case 1:
47 | return REMOVE;
48 | case 2:
49 | return REMOVE_ALL;
50 | default:
51 | throw new IllegalArgumentException("unknown ORF action code: " + code);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/ORFEntry.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | * File: org.topology.bgp_ls.netty.protocol.refresh.ORFEntry.java
18 | */
19 | package org.topology.bgp_ls.net;
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public abstract class ORFEntry {
26 | private ORFAction action;
27 | private ORFMatch match;
28 |
29 | protected ORFEntry(ORFAction action, ORFMatch match) {
30 | this.action = action;
31 | this.match = match;
32 | }
33 |
34 | /**
35 | * get the ORF type code
36 | *
37 | * @return
38 | */
39 | public abstract ORFType getORFType();
40 |
41 | /**
42 | * @return the action
43 | */
44 | public ORFAction getAction() {
45 | return action;
46 | }
47 |
48 | /**
49 | * @return the match
50 | */
51 | public ORFMatch getMatch() {
52 | return match;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/ORFMatch.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.refresh.ORFMatch.java
17 | */
18 | package org.topology.bgp_ls.net;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public enum ORFMatch {
25 | PERMIT,
26 | DENY;
27 |
28 | public int toCode() {
29 | switch(this) {
30 | case PERMIT:
31 | return 0;
32 | case DENY:
33 | return 1;
34 | default:
35 | throw new IllegalArgumentException("unknown ORF action code: " + this);
36 | }
37 | }
38 |
39 | public static ORFMatch fromCode(int code) {
40 | switch(code) {
41 | case 0:
42 | return PERMIT;
43 | case 1:
44 | return DENY;
45 | default:
46 | throw new IllegalArgumentException("unknown ORF action code: " + code);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/ORFRefreshType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.refresh.ORFRefreshType.java
17 | */
18 | package org.topology.bgp_ls.net;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public enum ORFRefreshType {
25 | IMMEDIATE,
26 | DEFER;
27 |
28 | public int toCode() {
29 | switch(this) {
30 | case IMMEDIATE:
31 | return 1;
32 | case DEFER:
33 | return 2;
34 | default:
35 | throw new IllegalArgumentException("unknown OutboundRouteFilter refresh type " + this);
36 | }
37 | }
38 |
39 | public static ORFRefreshType fromCode(int code) {
40 | switch(code) {
41 | case 1:
42 | return IMMEDIATE;
43 | case 2:
44 | return DEFER;
45 | default:
46 | throw new IllegalArgumentException("unknown OutboundRouteFilter refresh type code " + code);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/ORFSendReceive.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.net;
2 |
3 | import org.apache.commons.lang3.StringUtils;
4 |
5 | public enum ORFSendReceive {
6 | RECEIVE,
7 | SEND,
8 | BOTH;
9 |
10 | public int toCode() {
11 | switch(this) {
12 | case RECEIVE:
13 | return 1;
14 | case SEND:
15 | return 2;
16 | case BOTH:
17 | return 3;
18 | default:
19 | throw new IllegalArgumentException("unknown Send/Receive type " + this);
20 | }
21 | }
22 |
23 | public static ORFSendReceive fromCode(int code) {
24 | switch(code) {
25 | case 1:
26 | return RECEIVE;
27 | case 2:
28 | return SEND;
29 | case 3:
30 | return BOTH;
31 | default:
32 | throw new IllegalArgumentException("unknown Send/Receive type code " + code);
33 | }
34 | }
35 |
36 | public static ORFSendReceive fromString(String value) {
37 | if(StringUtils.equalsIgnoreCase("receive", value)) {
38 | return RECEIVE;
39 | } else if(StringUtils.equalsIgnoreCase("send", value)) {
40 | return SEND;
41 | } else if(StringUtils.equalsIgnoreCase("both", value)) {
42 | return BOTH;
43 | } else
44 | throw new IllegalArgumentException("unknown Send/Receive type: " + value);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/ORFType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.refresh.ORFType.java
17 | */
18 | package org.topology.bgp_ls.net;
19 |
20 | import org.apache.commons.lang3.StringUtils;
21 |
22 |
23 | /**
24 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
25 | *
26 | */
27 | public enum ORFType {
28 | ADDRESS_PREFIX_BASED;
29 |
30 | /** Address prefix based outbound route filter type (RFC 5292) */
31 | private static final int BGP_OUTBOUND_ROUTE_FILTER_TYPE_ADDRESS_PREFIX_BASED = 64;
32 |
33 | public int toCode() {
34 | switch(this) {
35 | case ADDRESS_PREFIX_BASED:
36 | return BGP_OUTBOUND_ROUTE_FILTER_TYPE_ADDRESS_PREFIX_BASED;
37 | default:
38 | throw new IllegalArgumentException("cannot encode OutboudRouteFilter type " + this);
39 | }
40 | }
41 |
42 | public static ORFType fromCode(int code) {
43 | switch(code) {
44 | case BGP_OUTBOUND_ROUTE_FILTER_TYPE_ADDRESS_PREFIX_BASED:
45 | return ADDRESS_PREFIX_BASED;
46 | default:
47 | throw new IllegalArgumentException("cannot encode OutboudRouteFilter type code " + code);
48 | }
49 | }
50 |
51 | public static ORFType fromString(String value) {
52 | if(StringUtils.equalsIgnoreCase("addressPrefixBased", value)) {
53 | return ADDRESS_PREFIX_BASED;
54 | } else
55 | throw new IllegalArgumentException("cannot encode OutboudRouteFilter type: " + value);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/Origin.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.net;
2 |
3 | import org.apache.commons.lang3.StringUtils;
4 |
5 | /**
6 | * Discrete origin types as specified in RFC 4271
7 | *
8 | * @author rainer
9 | *
10 | */
11 | public enum Origin {
12 |
13 | /** NLRI is interior to the originating AS (RFC 4271) */
14 | IGP,
15 |
16 | /** NLRI learned via EGP protocol (RFC 4271, RFC 904) */
17 | EGP,
18 |
19 | /** NLRI learned by some other means (RFC 4271)*/
20 | INCOMPLETE;
21 |
22 | public static Origin fromString(String value) {
23 | if(StringUtils.equalsIgnoreCase("igp", value))
24 | return IGP;
25 | else if(StringUtils.equalsIgnoreCase("egp", value))
26 | return EGP;
27 | if(StringUtils.equalsIgnoreCase("incomplete", value))
28 | return INCOMPLETE;
29 | else
30 | throw new IllegalArgumentException("Illegal Origin type: " + value);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/PathSegmentType.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.net;
2 |
3 | public enum PathSegmentType {
4 | AS_SET, // unordered set of ASes a route in the UPDATE message has traversed
5 | AS_SEQUENCE, // ordered set of ASes a route in the UPDATE message has traversed
6 | AS_CONFED_SET, // unordered set of ASes in a confederation a route in the UPDATE message has traversed
7 | AS_CONFED_SEQUENCE, // ordered set of ASes in a confederation a route in the UPDATE message has traversed
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/RIBSide.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.rib.RIBSide.java
17 | */
18 | package org.topology.bgp_ls.net;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public enum RIBSide {
25 | Local,
26 | Remote;
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/attributes/AtomicAggregatePathAttribute.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.update.AttomicAggregatePathAttribute.java
17 | */
18 | package org.topology.bgp_ls.net.attributes;
19 |
20 | import org.apache.commons.lang3.builder.ToStringBuilder;
21 |
22 |
23 | /**
24 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
25 | *
26 | */
27 | public class AtomicAggregatePathAttribute extends PathAttribute {
28 |
29 | public AtomicAggregatePathAttribute() {
30 | super(Category.WELL_KNOWN_DISCRETIONARY);
31 | }
32 |
33 | @Override
34 | protected PathAttributeType internalType() {
35 | return PathAttributeType.ATOMIC_AGGREGATE;
36 | }
37 |
38 | @Override
39 | protected boolean subclassEquals(PathAttribute obj) {
40 | return true;
41 | }
42 |
43 | @Override
44 | protected int subclassHashCode() {
45 | return 0;
46 | }
47 |
48 | @Override
49 | protected int subclassCompareTo(PathAttribute o) {
50 | return 0;
51 | }
52 |
53 | @Override
54 | protected ToStringBuilder subclassToString() {
55 | return new ToStringBuilder(this);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/attributes/MultiProtocolNLRIInformation.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Nitin Bahadur (nitinb@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.net.attributes;
18 |
19 | import org.topology.bgp_ls.net.AddressFamily;
20 | import org.topology.bgp_ls.net.SubsequentAddressFamily;
21 |
22 | /**
23 | * Minimal representation of a BGP NLRI's data. This object should be extended
24 | * to represent the actual NLRI content.
25 | * @author nitinb
26 | *
27 | */
28 | public class MultiProtocolNLRIInformation {
29 | AddressFamily afi;
30 | SubsequentAddressFamily safi;
31 |
32 | /**
33 | * @param afi BGP address family
34 | * @param safi BGP subsequent address family
35 | */
36 | protected MultiProtocolNLRIInformation(AddressFamily afi, SubsequentAddressFamily safi) {
37 | this.afi = afi;
38 | this.safi = safi;
39 | }
40 |
41 | /**
42 | * Returns the subsequent address family associated with this object
43 | * @return BGP subsequent address family
44 | */
45 | protected SubsequentAddressFamily getSubsequentAddressFamily() {
46 | return safi;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/attributes/PathAttributeType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.net.attributes.PathAttributeType.java
17 | */
18 | package org.topology.bgp_ls.net.attributes;
19 |
20 | /**
21 | * Path attribute type used internally for sorting, comparing and hash-code building.
22 | *
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public enum PathAttributeType {
27 | AGGREGATOR,
28 | AS_PATH,
29 | ATOMIC_AGGREGATE,
30 | CLUSTER_LIST,
31 | COMMUNITY,
32 | LOCAL_PREF,
33 | MULTI_EXIT_DISC,
34 | MULTI_PROTOCOL_REACHABLE,
35 | MULTI_PROTOCOL_UNREACHABLE,
36 | NEXT_HOP,
37 | ORIGINATOR_ID,
38 | ORIGIN,
39 | LINK_STATE,
40 | UNKNOWN
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/attributes/bgplsnlri/BgpLsNLRIInformation.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Nitin Bahadur (nitinb@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.net.attributes.bgplsnlri;
18 |
19 | import org.topology.bgp_ls.net.AddressFamily;
20 | import org.topology.bgp_ls.net.SubsequentAddressFamily;
21 | import org.topology.bgp_ls.net.attributes.MultiProtocolNLRIInformation;
22 |
23 | /**
24 | * This object extends the MultiProtocol NLRI object with the BGP-LS information.
25 | * @author nitinb
26 | *
27 | */
28 | public class BgpLsNLRIInformation extends MultiProtocolNLRIInformation {
29 |
30 | private BgpLsNLRIType nlriType;
31 | private byte[] routeDistinguisher;
32 |
33 | /**
34 | * @param safi BGP subsequent address family
35 | * @param nlriType Type of BGP NLRI
36 | */
37 | public BgpLsNLRIInformation(SubsequentAddressFamily safi, BgpLsNLRIType nlriType) {
38 | super(AddressFamily.BGP_LS, safi);
39 | this.nlriType = nlriType;
40 | }
41 |
42 |
43 | /**
44 | * Gets the BGP NLRI type associated with the object
45 | * @return nlriType
46 | */
47 | public BgpLsNLRIType getNlriType() {
48 | return nlriType;
49 | }
50 |
51 | /**
52 | * Gets the BGP link state route distinguisher
53 | * @return route distinguisher
54 | */
55 | public byte[] getRouteDistinguisher() {
56 | return routeDistinguisher;
57 | }
58 |
59 | /**
60 | * Sets the route distinguisher for the BGP link state object
61 | * @param routeDistinguisher the route distinguisher
62 | */
63 | public void setRouteDistinguisher(byte[] routeDistinguisher) {
64 | if (getSubsequentAddressFamily() == SubsequentAddressFamily.NLRI_MPLS_VPN) {
65 | this.routeDistinguisher = routeDistinguisher;
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/attributes/bgplsnlri/export/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes that export link-state topology data in JSON format
3 | */
4 | package org.topology.bgp_ls.net.attributes.bgplsnlri.export;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/attributes/bgplsnlri/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes that describe the objects representing the BGP link-state topology
3 | */
4 | package org.topology.bgp_ls.net.attributes.bgplsnlri;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/attributes/export/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for exporting overall Multi-Protocol NLRI data
3 | */
4 | package org.topology.bgp_ls.net.attributes.export;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/attributes/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes that describe BGP attribute objects
3 | */
4 | package org.topology.bgp_ls.net.attributes;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/capabilities/RouteRefreshCapability.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.net.capabilities;
18 |
19 | import org.apache.commons.lang3.builder.ToStringBuilder;
20 |
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class RouteRefreshCapability extends Capability {
27 |
28 | /* (non-Javadoc)
29 | * @see org.topology.bgp_ls.net.Capability#orderNumber()
30 | */
31 | @Override
32 | protected int orderNumber() {
33 | return ORDER_NUMBER_ROUTE_REFRESH_CAPABILITY;
34 | }
35 |
36 | /* (non-Javadoc)
37 | * @see java.lang.Object#toString()
38 | */
39 | @Override
40 | public String toString() {
41 | return ToStringBuilder.reflectionToString(this);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/capabilities/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for representing BGP capability objects
3 | */
4 | package org.topology.bgp_ls.net.capabilities;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/net/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes that describe basic BGP objects
3 | */
4 | package org.topology.bgp_ls.net;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/FSMState.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.fsm.FSMState.java
17 | */
18 | package org.topology.bgp_ls.netty;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public enum FSMState {
25 | Idle,
26 | Connect,
27 | Active,
28 | OpenSent,
29 | OpenConfirm,
30 | Established;
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/NLRICodec.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.NLRICodec.java
17 | */
18 | package org.topology.bgp_ls.netty;
19 |
20 | import org.topology.bgp_ls.net.NetworkLayerReachabilityInformation;
21 | import org.jboss.netty.buffer.ChannelBuffer;
22 | import org.jboss.netty.buffer.ChannelBuffers;
23 |
24 | /**
25 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
26 | *
27 | */
28 | public class NLRICodec {
29 |
30 | public NetworkLayerReachabilityInformation decodeNLRI(ChannelBuffer buffer) {
31 | NetworkLayerReachabilityInformation nlri = new NetworkLayerReachabilityInformation();
32 | int prefixLength = buffer.readUnsignedByte();
33 | byte[] prefixBytes = null;
34 |
35 | if(prefixLength > 0) {
36 | prefixBytes = new byte[NetworkLayerReachabilityInformation.calculateOctetsForPrefixLength(prefixLength)];
37 |
38 | buffer.readBytes(prefixBytes);
39 | }
40 | nlri.setPrefix(prefixLength, prefixBytes);
41 |
42 | return nlri;
43 | }
44 |
45 | public int calculateEncodedNLRILength(NetworkLayerReachabilityInformation nlri) {
46 | return NetworkLayerReachabilityInformation.calculateOctetsForPrefixLength(nlri.getPrefixLength()) + 1;
47 | }
48 |
49 | public ChannelBuffer encodeNLRI(NetworkLayerReachabilityInformation nlri) {
50 | ChannelBuffer buffer = ChannelBuffers.buffer(calculateEncodedNLRILength(nlri));
51 |
52 | buffer.writeByte(nlri.getPrefixLength());
53 | if(nlri.getPrefixLength() > 0) {
54 | buffer.writeBytes(nlri.getPrefix());
55 | }
56 |
57 | return buffer;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/PeerConnectionInformation.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.topology.bgp_ls.netty;
17 |
18 | import org.topology.bgp_ls.net.ASType;
19 |
20 |
21 | /**
22 | * This bean contains all information about the BGP connection that needs to be accessible
23 | * by channel handlers. It is stored in the ChannelHandlerContext after the OPEN handshake.
24 | *
25 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
26 | *
27 | */
28 | public interface PeerConnectionInformation {
29 | public ASType getAsTypeInUse() ;
30 |
31 | /**
32 | *
33 | * @return
34 | */
35 | public int getLocalAS();
36 |
37 | /**
38 | *
39 | * @return
40 | */
41 | public int getRemoteAS();
42 |
43 | /**
44 | * Test if the connection describes an IBGP connection (peers in the same AS)
45 | *
46 | * @return true
if IBGP connection, false
otherwise
47 | */
48 | public boolean isIBGPConnection();
49 |
50 | /**
51 | * Test if the connection describes an EBGP connection (peers in the same AS)
52 | *
53 | * @return true
if EBGP connection, false
otherwise
54 | */
55 | public boolean isEBGPConnection();
56 |
57 | /**
58 | * Test if this connection uses 4 octet AS numbers
59 | *
60 | * @return
61 | */
62 | public boolean isAS4OctetsInUse();
63 |
64 | /**
65 | * @return the localBgpIdentifier
66 | */
67 | public long getLocalBgpIdentifier();
68 |
69 | /**
70 | * @return the remoteBgpIdentifier
71 | */
72 | public long getRemoteBgpIdentifier();
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/PeerConnectionInformationAware.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.PeerConnectionInformationAware.java
17 | */
18 | package org.topology.bgp_ls.netty;
19 |
20 | import java.lang.annotation.Documented;
21 | import java.lang.annotation.ElementType;
22 | import java.lang.annotation.Retention;
23 | import java.lang.annotation.RetentionPolicy;
24 | import java.lang.annotation.Target;
25 |
26 | /**
27 | * Channel handlers annotated with this annotation are provisioned with a per-channel
28 | * peer connection information block
29 | *
30 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
31 | *
32 | */
33 | @Documented
34 | @Retention(RetentionPolicy.RUNTIME)
35 | @Target(ElementType.TYPE)
36 | public @interface PeerConnectionInformationAware {
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/fsm/FSMChannel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.fsm.FSMChannel.java
17 | */
18 | package org.topology.bgp_ls.netty.fsm;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public interface FSMChannel {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/fsm/FireAutomaticStart.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.netty.fsm;
2 |
3 | public class FireAutomaticStart extends FireEventTimeJob {
4 | public FireAutomaticStart() {
5 | super(FSMEvent.automaticStart());
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/fsm/FireConnectRetryTimerExpired.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.netty.fsm;
2 |
3 | public class FireConnectRetryTimerExpired extends FireEventTimeJob {
4 | public FireConnectRetryTimerExpired() {
5 | super(FSMEvent.connectRetryTimerExpires());
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/fsm/FireDelayOpenTimerExpired.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.netty.fsm;
2 |
3 | public class FireDelayOpenTimerExpired extends FireEventTimeJob {
4 | public FireDelayOpenTimerExpired() {
5 | super(FSMEvent.delayOpenTimerExpires());
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/fsm/FireEventTimeJob.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.netty.fsm;
2 |
3 | import org.quartz.Job;
4 | import org.quartz.JobExecutionContext;
5 | import org.quartz.JobExecutionException;
6 |
7 | class FireEventTimeJob implements Job {
8 | final static String FSM_KEY = "fsm";
9 |
10 | private FSMEvent event;
11 |
12 | protected FireEventTimeJob(FSMEvent event) {
13 | this.event = event;
14 | }
15 |
16 | @Override
17 | public void execute(JobExecutionContext context) throws JobExecutionException {
18 | ((InternalFSM)context.getMergedJobDataMap().get(FSM_KEY)).handleEvent(event);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/fsm/FireHoldTimerExpired.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.netty.fsm;
2 |
3 | public class FireHoldTimerExpired extends FireEventTimeJob {
4 | public FireHoldTimerExpired() {
5 | super(FSMEvent.holdTimerExpires());
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/fsm/FireIdleHoldTimerExpired.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.netty.fsm;
2 |
3 | public class FireIdleHoldTimerExpired extends FireEventTimeJob {
4 | public FireIdleHoldTimerExpired() {
5 | super(FSMEvent.idleHoldTimerExpires());
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/fsm/FireSendKeepalive.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls.netty.fsm;
2 |
3 | public class FireSendKeepalive extends FireEventTimeJob {
4 | public FireSendKeepalive() {
5 | super(FSMEvent.keepaliveTimerExpires());
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/fsm/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for managing the BGP finite state machine
3 | */
4 | package org.topology.bgp_ls.netty.fsm;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/handlers/BgpEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.handlers.BgpEvent.java
17 | */
18 | package org.topology.bgp_ls.netty.handlers;
19 |
20 | /**
21 | * Base class for events sent from individual channel handlers upstream to the controlling FSM
22 | *
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class BgpEvent {
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/handlers/BgpEventFireChannelFutureListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.handlers.BgpEventFireChannelFutureListener.java
17 | */
18 | package org.topology.bgp_ls.netty.handlers;
19 |
20 | import org.jboss.netty.channel.ChannelFuture;
21 | import org.jboss.netty.channel.ChannelFutureListener;
22 | import org.jboss.netty.channel.ChannelHandlerContext;
23 | import org.jboss.netty.channel.UpstreamMessageEvent;
24 |
25 | /**
26 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
27 | *
28 | */
29 | public class BgpEventFireChannelFutureListener implements ChannelFutureListener {
30 |
31 | private ChannelHandlerContext upstreamContext;
32 | private BgpEvent bgpEvent;
33 |
34 | BgpEventFireChannelFutureListener(ChannelHandlerContext upstreamContext) {
35 | this.upstreamContext = upstreamContext;
36 | }
37 |
38 | /* (non-Javadoc)
39 | * @see org.jboss.netty.channel.ChannelFutureListener#operationComplete(org.jboss.netty.channel.ChannelFuture)
40 | */
41 | @Override
42 | public void operationComplete(ChannelFuture future) throws Exception {
43 | if(upstreamContext != null && bgpEvent != null) {
44 | upstreamContext.sendUpstream(new UpstreamMessageEvent(upstreamContext.getChannel(),
45 | bgpEvent,
46 | upstreamContext.getChannel().getRemoteAddress()));
47 | }
48 | }
49 |
50 | /**
51 | * @return the bgpEvent
52 | */
53 | public BgpEvent getBgpEvent() {
54 | return bgpEvent;
55 | }
56 |
57 | /**
58 | * @param bgpEvent the bgpEvent to set
59 | */
60 | public void setBgpEvent(BgpEvent bgpEvent) {
61 | this.bgpEvent = bgpEvent;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/handlers/NotificationEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.handlers.NotificationEvent.java
17 | */
18 | package org.topology.bgp_ls.netty.handlers;
19 |
20 | import java.util.Collection;
21 | import java.util.Collections;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 |
25 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
26 |
27 | /**
28 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
29 | *
30 | */
31 | public class NotificationEvent extends BgpEvent {
32 |
33 | private List notifications = new LinkedList();
34 |
35 | public NotificationEvent(NotificationPacket packet) {
36 | notifications.add(packet);
37 | }
38 |
39 | public NotificationEvent(Collection notifications) {
40 | this.notifications.addAll(notifications);
41 | }
42 |
43 | /**
44 | * @return the notifications
45 | */
46 | public List getNotifications() {
47 | return Collections.unmodifiableList(notifications);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/handlers/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes that handle BGP socket events and call the appropriate decode routines
3 | */
4 | package org.topology.bgp_ls.netty.handlers;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * BGP overall constants and some interfaces
3 | */
4 | package org.topology.bgp_ls.netty;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/AdministrativeResetNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.AdministrativeResetNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class AdministrativeResetNotificationPacket extends CeaseNotificationPacket {
25 |
26 | /**
27 | * @param subcode
28 | */
29 | public AdministrativeResetNotificationPacket() {
30 | super(CeaseNotificationPacket.SUBCODE_ADMINSTRATIVE_RESET);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/AdministrativeShutdownNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.AdministrativeShutdownNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class AdministrativeShutdownNotificationPacket extends
25 | CeaseNotificationPacket {
26 |
27 | /**
28 | * @param subcode
29 | */
30 | public AdministrativeShutdownNotificationPacket() {
31 | super(CeaseNotificationPacket.SUBCODE_ADMINSTRATIVE_SHUTDOWN);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/BadMessageLengthException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.BadMessageLengthException.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class BadMessageLengthException extends ProtocolPacketException {
25 |
26 | private int length;
27 |
28 | /**
29 | *
30 | */
31 | private static final long serialVersionUID = 4333191817393984978L;
32 |
33 | /**
34 | * @param message
35 | * @param cause
36 | */
37 | public BadMessageLengthException(int length) {
38 | this.length = length;
39 | }
40 |
41 | /**
42 | *
43 | */
44 | public BadMessageLengthException() {
45 | }
46 |
47 | /**
48 | * @param message
49 | */
50 | public BadMessageLengthException(String message, int length) {
51 | super(message);
52 |
53 | this.length = length;
54 | }
55 |
56 | /* (non-Javadoc)
57 | * @see org.topology.bgp_ls.netty.protocol.ProtocolPacketFormatException#toNotificationPacket()
58 | */
59 | @Override
60 | public NotificationPacket toNotificationPacket() {
61 | return new BadMessageLengthNotificationPacket(this.length);
62 | }
63 |
64 | /**
65 | * @return the length
66 | */
67 | public int getLength() {
68 | return length;
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/BadMessageLengthNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol;
18 |
19 | import org.jboss.netty.buffer.ChannelBuffer;
20 | import org.jboss.netty.buffer.ChannelBuffers;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class BadMessageLengthNotificationPacket extends MessageHeaderErrorNotificationPacket {
27 |
28 | private int length;
29 |
30 | public BadMessageLengthNotificationPacket(int length) {
31 | super(MessageHeaderErrorNotificationPacket.SUBCODE_BAD_MESSAGE_LENGTH);
32 |
33 | setLength(length);
34 | }
35 |
36 | /**
37 | * @return the length
38 | */
39 | public int getLength() {
40 | return length;
41 | }
42 |
43 | /**
44 | * @param length the length to set
45 | */
46 | public void setLength(int length) {
47 | this.length = length;
48 | }
49 |
50 | /* (non-Javadoc)
51 | * @see org.topology.bgp_ls.netty.protocol.NotificationPacket#encodePayload()
52 | */
53 | @Override
54 | protected ChannelBuffer encodeAdditionalPayload() {
55 | ChannelBuffer buffer = ChannelBuffers.buffer(2);
56 |
57 | buffer.writeShort(getLength());
58 |
59 | return buffer;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/BadMessageTypeException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol;
18 |
19 | /**
20 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
21 | *
22 | */
23 | public class BadMessageTypeException extends ProtocolPacketException {
24 |
25 | /**
26 | *
27 | */
28 | private static final long serialVersionUID = -1997353015198092763L;
29 |
30 | private int type;
31 |
32 | /**
33 | *
34 | */
35 | public BadMessageTypeException() {
36 | }
37 |
38 | /**
39 | *
40 | */
41 | public BadMessageTypeException(int type) {
42 | this.type = type;
43 | }
44 |
45 | /**
46 | * @param message
47 | */
48 | public BadMessageTypeException(String message, int type) {
49 | super(message);
50 |
51 | this.type = type;
52 | }
53 |
54 | /**
55 | * @return the type
56 | */
57 | public int getType() {
58 | return type;
59 | }
60 |
61 | @Override
62 | public NotificationPacket toNotificationPacket() {
63 | return new BadMessageTypeNotificationPacket(this.type);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/BadMessageTypeNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol;
18 |
19 | import org.jboss.netty.buffer.ChannelBuffer;
20 | import org.jboss.netty.buffer.ChannelBuffers;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class BadMessageTypeNotificationPacket extends MessageHeaderErrorNotificationPacket {
27 |
28 | private int unknownMessageType;
29 |
30 | public BadMessageTypeNotificationPacket() {
31 | super(MessageHeaderErrorNotificationPacket.SUBCODE_BAD_MESSAGE_LENGTH);
32 | }
33 |
34 | public BadMessageTypeNotificationPacket(int type) {
35 | super(MessageHeaderErrorNotificationPacket.SUBCODE_BAD_MESSAGE_LENGTH);
36 |
37 | setUnknownMessageType(type);
38 | }
39 |
40 | /**
41 | * @return the length
42 | */
43 | public int getUnknownMessageType() {
44 | return unknownMessageType;
45 | }
46 |
47 | /**
48 | * @param length the length to set
49 | */
50 | public void setUnknownMessageType(int length) {
51 | this.unknownMessageType = length;
52 | }
53 |
54 | /* (non-Javadoc)
55 | * @see org.topology.bgp_ls.netty.protocol.NotificationPacket#encodePayload()
56 | */
57 | @Override
58 | protected ChannelBuffer encodeAdditionalPayload() {
59 | ChannelBuffer buffer = ChannelBuffers.buffer(1);
60 |
61 | buffer.writeByte(getType());
62 |
63 | return buffer;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/CeaseNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol;
18 |
19 | import org.topology.bgp_ls.netty.BGPv4Constants;
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class CeaseNotificationPacket extends NotificationPacket {
26 |
27 | protected static final int SUBCODE_UNSPECIFIC = 0;
28 | protected static final int SUBCODE_MAXIMUM_NUMBER_OF_PREFIXES_REACHED = 1;
29 | protected static final int SUBCODE_ADMINSTRATIVE_SHUTDOWN = 2;
30 | protected static final int SUBCODE_PEER_DECONFIGURED = 3;
31 | protected static final int SUBCODE_ADMINSTRATIVE_RESET = 4;
32 | protected static final int SUBCODE_CONNECTION_REJECTED = 5;
33 | protected static final int SUBCODE_OTHER_CONFIGURATION_CHANGE = 6;
34 | protected static final int SUBCODE_CONNECTION_COLLISION_RESOLUTION = 7;
35 | protected static final int SUBCODE_OUT_OF_RESOURCES = 8;
36 |
37 | /**
38 | * @param errorCode
39 | * @param errorSubcode
40 | */
41 | protected CeaseNotificationPacket(int subcode) {
42 | super(BGPv4Constants.BGP_ERROR_CODE_CEASE, subcode);
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/ConnectionCollisionResolutionNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.ConnectionCollisionResolutionNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class ConnectionCollisionResolutionNotificationPacket extends CeaseNotificationPacket {
25 |
26 | /**
27 | * @param subcode
28 | */
29 | public ConnectionCollisionResolutionNotificationPacket() {
30 | super(CeaseNotificationPacket.SUBCODE_CONNECTION_COLLISION_RESOLUTION);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/ConnectionNotSynchronizedException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.ConnectionNotSynchronizedException.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class ConnectionNotSynchronizedException extends
25 | ProtocolPacketException {
26 |
27 | /**
28 | *
29 | */
30 | private static final long serialVersionUID = 988239317361192202L;
31 |
32 | public ConnectionNotSynchronizedException() {
33 | // TODO Auto-generated constructor stub
34 | }
35 |
36 | public ConnectionNotSynchronizedException(String message, Throwable cause) {
37 | super(message, cause);
38 | // TODO Auto-generated constructor stub
39 | }
40 |
41 | public ConnectionNotSynchronizedException(String message) {
42 | super(message);
43 | // TODO Auto-generated constructor stub
44 | }
45 |
46 | public ConnectionNotSynchronizedException(Throwable cause) {
47 | super(cause);
48 | // TODO Auto-generated constructor stub
49 | }
50 |
51 | /* (non-Javadoc)
52 | * @see org.topology.bgp_ls.netty.protocol.ProtocolPacketFormatException#toNotificationPacket()
53 | */
54 | @Override
55 | public NotificationPacket toNotificationPacket() {
56 | return new ConnectionNotSynchronizedNotificationPacket();
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/ConnectionNotSynchronizedNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol;
18 |
19 | /**
20 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
21 | *
22 | */
23 | public class ConnectionNotSynchronizedNotificationPacket extends MessageHeaderErrorNotificationPacket {
24 |
25 | public ConnectionNotSynchronizedNotificationPacket() {
26 | super(MessageHeaderErrorNotificationPacket.SUBCODE_CONNECTION_NOT_SYNCHRONIZED);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/ConnectionRejectedNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.ConnectionRejectedNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class ConnectionRejectedNotificationPacket extends CeaseNotificationPacket {
25 |
26 | /**
27 | * @param subcode
28 | */
29 | public ConnectionRejectedNotificationPacket() {
30 | super(CeaseNotificationPacket.SUBCODE_CONNECTION_REJECTED);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/FiniteStateMachineErrorNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol;
18 |
19 | import org.topology.bgp_ls.netty.BGPv4Constants;
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class FiniteStateMachineErrorNotificationPacket extends NotificationPacket {
26 |
27 | /**
28 | * @param errorCode
29 | * @param errorSubcode
30 | */
31 | public FiniteStateMachineErrorNotificationPacket() {
32 | super(BGPv4Constants.BGP_ERROR_CODE_CEASE, 0);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/HoldTimerExpiredNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol;
18 |
19 | import org.topology.bgp_ls.netty.BGPv4Constants;
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class HoldTimerExpiredNotificationPacket extends NotificationPacket {
26 |
27 | /**
28 | * @param errorCode
29 | * @param errorSubcode
30 | */
31 | public HoldTimerExpiredNotificationPacket() {
32 | super(BGPv4Constants.BGP_ERROR_CODE_HOLD_TIMER_EXPIRED, 0);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/KeepalivePacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol;
18 |
19 | import org.topology.bgp_ls.netty.BGPv4Constants;
20 | import org.jboss.netty.buffer.ChannelBuffer;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class KeepalivePacket extends BGPv4Packet {
27 |
28 | @Override
29 | protected ChannelBuffer encodePayload() {
30 | return null;
31 | }
32 |
33 | @Override
34 | public int getType() {
35 | return BGPv4Constants.BGP_PACKET_TYPE_KEEPALIVE;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/MessageHeaderErrorNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol;
18 |
19 | import org.topology.bgp_ls.netty.BGPv4Constants;
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class MessageHeaderErrorNotificationPacket extends NotificationPacket {
26 |
27 | protected static final int SUBCODE_CONNECTION_NOT_SYNCHRONIZED = 1;
28 | protected static final int SUBCODE_BAD_MESSAGE_LENGTH = 2;
29 | protected static final int SUBCODE_BAD_MESSAGE_TYPE = 3;
30 |
31 | protected MessageHeaderErrorNotificationPacket(int subcode) {
32 | super(BGPv4Constants.BGP_ERROR_CODE_MESSAGE_HEADER, subcode);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/OtherConfigurationChangeNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.OtherConfigurationChangeNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class OtherConfigurationChangeNotificationPacket extends CeaseNotificationPacket {
25 |
26 | /**
27 | * @param subcode
28 | */
29 | public OtherConfigurationChangeNotificationPacket() {
30 | super(CeaseNotificationPacket.SUBCODE_OTHER_CONFIGURATION_CHANGE);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/OutOfResourcesNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.OutOfResourcesNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class OutOfResourcesNotificationPacket extends CeaseNotificationPacket {
25 |
26 | /**
27 | * @param subcode
28 | */
29 | public OutOfResourcesNotificationPacket() {
30 | super(CeaseNotificationPacket.SUBCODE_OUT_OF_RESOURCES);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/PeerDeconfiguredNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.PeerDeconfiguredNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class PeerDeconfiguredNotificationPacket extends CeaseNotificationPacket {
25 |
26 | /**
27 | * @param subcode
28 | */
29 | public PeerDeconfiguredNotificationPacket() {
30 | super(CeaseNotificationPacket.SUBCODE_PEER_DECONFIGURED);
31 | // TODO Auto-generated constructor stub
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/ProtocolPacketException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol;
18 |
19 | /**
20 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
21 | *
22 | */
23 | public abstract class ProtocolPacketException extends RuntimeException {
24 |
25 | /**
26 | *
27 | */
28 | private static final long serialVersionUID = -973351159524540205L;
29 |
30 | public ProtocolPacketException(String message, Throwable cause) {
31 | super(message, cause);
32 | }
33 |
34 | public ProtocolPacketException(Throwable cause) {
35 | super(cause);
36 | }
37 |
38 | public ProtocolPacketException() {
39 | super();
40 | }
41 |
42 | public ProtocolPacketException(String message) {
43 | super(message);
44 | }
45 |
46 | public abstract NotificationPacket toNotificationPacket();
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/ProtocolPacketUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.ProtocolPacketUtils.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol;
19 |
20 | import org.topology.bgp_ls.netty.BGPv4Constants;
21 | import org.jboss.netty.buffer.ChannelBuffer;
22 |
23 | /**
24 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
25 | *
26 | */
27 | public class ProtocolPacketUtils {
28 |
29 | /**
30 | * verify the packet size.
31 | *
32 | * @param minimumPacketSize the minimum size in octets the protocol packet must have to be well-formed. If -1 is passed the check is not performed.
33 | * @param maximumPacketSize the maximum size in octets the protocol packet may have to be well-formed. If -1 is passed the check is not performed.
34 | */
35 | public static void verifyPacketSize(ChannelBuffer buffer, int minimumPacketSize, int maximumPacketSize) {
36 | if(minimumPacketSize != -1) {
37 | if(buffer.readableBytes() < (minimumPacketSize - BGPv4Constants.BGP_PACKET_HEADER_LENGTH)) {
38 | throw new ConnectionNotSynchronizedException("expected minimum " + (minimumPacketSize - BGPv4Constants.BGP_PACKET_HEADER_LENGTH)
39 | + " octest, received " + buffer.readableBytes() + " octets");
40 | }
41 | }
42 | if(maximumPacketSize != -1) {
43 | if(buffer.readableBytes() > (maximumPacketSize - BGPv4Constants.BGP_PACKET_HEADER_LENGTH)) {
44 | throw new ConnectionNotSynchronizedException("expected maximum " + (maximumPacketSize - BGPv4Constants.BGP_PACKET_HEADER_LENGTH)
45 | + "octest, received " + buffer.readableBytes() + "octets");
46 | }
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/UnspecifiedCeaseNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.UnspecifiedCeaseNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol;
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class UnspecifiedCeaseNotificationPacket extends CeaseNotificationPacket {
25 |
26 | /**
27 | * @param subcode
28 | */
29 | public UnspecifiedCeaseNotificationPacket() {
30 | super(CeaseNotificationPacket.SUBCODE_UNSPECIFIC);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/BadBgpIdentifierException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.BadBgpIdentifierException.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.open;
19 |
20 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class BadBgpIdentifierException extends OpenPacketException {
27 |
28 | /**
29 | *
30 | */
31 | private static final long serialVersionUID = -7669781009811724080L;
32 |
33 | /**
34 | *
35 | */
36 | public BadBgpIdentifierException() {
37 | }
38 |
39 | /**
40 | * @param message
41 | */
42 | public BadBgpIdentifierException(String message) {
43 | super(message);
44 | }
45 |
46 | @Override
47 | public NotificationPacket toNotificationPacket() {
48 | return new BadBgpIdentifierNotificationPacket();
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/BadBgpIdentifierNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.open;
18 |
19 |
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class BadBgpIdentifierNotificationPacket extends OpenNotificationPacket {
26 |
27 | public BadBgpIdentifierNotificationPacket() {
28 | super(OpenNotificationPacket.SUBCODE_BAD_BGP_IDENTIFIER);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/BadPeerASException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.BadPeerASException.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.open;
19 |
20 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class BadPeerASException extends OpenPacketException {
27 |
28 | /**
29 | *
30 | */
31 | private static final long serialVersionUID = -6036362844150257520L;
32 |
33 | /**
34 | * @param message
35 | * @param cause
36 | */
37 | public BadPeerASException(String message, Throwable cause) {
38 | super(message, cause);
39 | }
40 |
41 | /**
42 | * @param cause
43 | */
44 | public BadPeerASException(Throwable cause) {
45 | super(cause);
46 | }
47 |
48 | /**
49 | *
50 | */
51 | public BadPeerASException() {
52 | }
53 |
54 | /**
55 | * @param message
56 | */
57 | public BadPeerASException(String message) {
58 | super(message);
59 | }
60 |
61 | /* (non-Javadoc)
62 | * @see org.topology.bgp_ls.netty.protocol.ProtocolPacketFormatException#toNotificationPacket()
63 | */
64 | @Override
65 | public NotificationPacket toNotificationPacket() {
66 | return new BadPeerASNotificationPacket();
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/BadPeerASNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.open;
18 |
19 |
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class BadPeerASNotificationPacket extends OpenNotificationPacket {
26 |
27 | public BadPeerASNotificationPacket() {
28 | super(OpenNotificationPacket.SUBCODE_BAD_PEER_AS);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/ByteArrayUnsupportedCapabilityNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.open;
18 |
19 | import org.jboss.netty.buffer.ChannelBuffer;
20 | import org.jboss.netty.buffer.ChannelBuffers;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class ByteArrayUnsupportedCapabilityNotificationPacket extends UnsupportedCapabilityNotificationPacket {
27 |
28 | private byte[] capability;
29 |
30 | public ByteArrayUnsupportedCapabilityNotificationPacket(byte[] capability) {
31 | this.capability = capability;
32 | }
33 |
34 | /* (non-Javadoc)
35 | * @see org.topology.bgp_ls.netty.protocol.NotificationPacket#encodeAdditionalPayload()
36 | */
37 | @Override
38 | protected ChannelBuffer encodeAdditionalPayload() {
39 | ChannelBuffer buffer = ChannelBuffers.buffer(capability.length);
40 |
41 | buffer.writeBytes(capability);
42 |
43 | return buffer;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/CapabilityListUnsupportedCapabilityNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.open.CapabilityListUnsupportedCapabilityNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.open;
19 |
20 | import java.util.List;
21 |
22 | import org.topology.bgp_ls.net.capabilities.Capability;
23 | import org.jboss.netty.buffer.ChannelBuffer;
24 |
25 | /**
26 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
27 | *
28 | */
29 | public class CapabilityListUnsupportedCapabilityNotificationPacket extends UnsupportedCapabilityNotificationPacket {
30 |
31 | private List capabilities;
32 |
33 | public CapabilityListUnsupportedCapabilityNotificationPacket(List capabilities) {
34 | this.capabilities = capabilities;
35 | }
36 |
37 | /* (non-Javadoc)
38 | * @see org.topology.bgp_ls.netty.protocol.NotificationPacket#encodeAdditionalPayload()
39 | */
40 | @Override
41 | protected ChannelBuffer encodeAdditionalPayload() {
42 | return CapabilityCodec.encodeCapabilities(capabilities);
43 | }
44 |
45 | /**
46 | * @return the capabilities
47 | */
48 | public List getCapabilities() {
49 | return capabilities;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/OpenNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.open;
18 |
19 | import org.topology.bgp_ls.netty.BGPv4Constants;
20 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class OpenNotificationPacket extends NotificationPacket {
27 |
28 | protected static final int SUBCODE_UNSPECIFIC = 0;
29 | protected static final int SUBCODE_UNSUPPORTED_VERSION_NUMBER = 1;
30 | protected static final int SUBCODE_BAD_PEER_AS = 2;
31 | protected static final int SUBCODE_BAD_BGP_IDENTIFIER = 3;
32 | protected static final int SUBCODE_UNSUPPORTED_OPTIONAL_PARAMETER = 4;
33 | protected static final int SUBCODE_UNACCEPTABLE_HOLD_TIMER = 6;
34 | protected static final int SUBCODE_UNSUPPORTED_CAPABILITY = 7;
35 |
36 | protected OpenNotificationPacket(int subcode) {
37 | super(BGPv4Constants.BGP_ERROR_CODE_OPEN, subcode);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/OpenPacketException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.OpenPacketException.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.open;
19 |
20 | import org.topology.bgp_ls.netty.protocol.ProtocolPacketException;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public abstract class OpenPacketException extends ProtocolPacketException {
27 |
28 | /**
29 | *
30 | */
31 | private static final long serialVersionUID = 229532748368735248L;
32 |
33 | /**
34 | * @param message
35 | * @param cause
36 | */
37 | public OpenPacketException(String message, Throwable cause) {
38 | super(message, cause);
39 | }
40 |
41 | /**
42 | * @param cause
43 | */
44 | public OpenPacketException(Throwable cause) {
45 | super(cause);
46 | }
47 |
48 | /**
49 | *
50 | */
51 | public OpenPacketException() {
52 | }
53 |
54 | /**
55 | * @param message
56 | */
57 | public OpenPacketException(String message) {
58 | super(message);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/UnacceptableHoldTimerException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.UnacceptableHoldTimerException.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.open;
19 |
20 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class UnacceptableHoldTimerException extends OpenPacketException {
27 |
28 | /**
29 | *
30 | */
31 | private static final long serialVersionUID = -2100244665501484800L;
32 |
33 | /**
34 | * @param message
35 | * @param cause
36 | */
37 | public UnacceptableHoldTimerException(String message, Throwable cause) {
38 | super(message, cause);
39 | }
40 |
41 | /**
42 | * @param cause
43 | */
44 | public UnacceptableHoldTimerException(Throwable cause) {
45 | super(cause);
46 | }
47 |
48 | /**
49 | *
50 | */
51 | public UnacceptableHoldTimerException() {
52 | }
53 |
54 | /**
55 | * @param message
56 | */
57 | public UnacceptableHoldTimerException(String message) {
58 | super(message);
59 | }
60 |
61 | /* (non-Javadoc)
62 | * @see org.topology.bgp_ls.netty.protocol.ProtocolPacketFormatException#toNotificationPacket()
63 | */
64 | @Override
65 | public NotificationPacket toNotificationPacket() {
66 | return new UnacceptableHoldTimerNotificationPacket();
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/UnacceptableHoldTimerNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.open;
18 |
19 | /**
20 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
21 | *
22 | */
23 | public class UnacceptableHoldTimerNotificationPacket extends OpenNotificationPacket {
24 |
25 | protected UnacceptableHoldTimerNotificationPacket() {
26 | super(OpenNotificationPacket.SUBCODE_UNACCEPTABLE_HOLD_TIMER);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/UnspecificOpenNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.open;
18 |
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class UnspecificOpenNotificationPacket extends OpenNotificationPacket {
25 |
26 | protected UnspecificOpenNotificationPacket() {
27 | super(OpenNotificationPacket.SUBCODE_UNSPECIFIC);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/UnspecificOpenPacketException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.UnspecificOpenPacketException.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.open;
19 |
20 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class UnspecificOpenPacketException extends OpenPacketException {
27 |
28 | /**
29 | *
30 | */
31 | private static final long serialVersionUID = -2310805310691844533L;
32 |
33 | /**
34 | * @param message
35 | * @param cause
36 | */
37 | public UnspecificOpenPacketException(String message, Throwable cause) {
38 | super(message, cause);
39 | }
40 |
41 | /**
42 | * @param cause
43 | */
44 | public UnspecificOpenPacketException(Throwable cause) {
45 | super(cause);
46 | }
47 |
48 | /**
49 | *
50 | */
51 | public UnspecificOpenPacketException() {
52 | }
53 |
54 | /**
55 | * @param message
56 | */
57 | public UnspecificOpenPacketException(String message) {
58 | super(message);
59 | }
60 |
61 | /* (non-Javadoc)
62 | * @see org.topology.bgp_ls.netty.protocol.ProtocolPacketFormatException#toNotificationPacket()
63 | */
64 | @Override
65 | public NotificationPacket toNotificationPacket() {
66 | return new UnspecificOpenNotificationPacket();
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/UnsupportedCapabilityNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.open;
18 |
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class UnsupportedCapabilityNotificationPacket extends OpenNotificationPacket {
25 |
26 | protected UnsupportedCapabilityNotificationPacket() {
27 | super(OpenNotificationPacket.SUBCODE_UNSUPPORTED_CAPABILITY);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/UnsupportedOptionalParameterException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.UnsupportedOptionalParameterException.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.open;
19 |
20 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class UnsupportedOptionalParameterException extends OpenPacketException {
27 |
28 | /**
29 | *
30 | */
31 | private static final long serialVersionUID = 6193635931471963435L;
32 |
33 | public UnsupportedOptionalParameterException() {
34 | }
35 |
36 | public UnsupportedOptionalParameterException(String message) {
37 | super(message);
38 | }
39 |
40 | @Override
41 | public NotificationPacket toNotificationPacket() {
42 | return new UnsupportedOptionalParameterNotificationPacket();
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/UnsupportedOptionalParameterNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.open;
18 |
19 |
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class UnsupportedOptionalParameterNotificationPacket extends OpenNotificationPacket {
26 |
27 | protected UnsupportedOptionalParameterNotificationPacket() {
28 | super(OpenNotificationPacket.SUBCODE_UNSUPPORTED_OPTIONAL_PARAMETER);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/UnsupportedVersionNumberException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.BgpProtocolVersionException.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.open;
19 |
20 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class UnsupportedVersionNumberException extends OpenPacketException {
27 |
28 | private int supportedProtocolVersion;
29 |
30 | /**
31 | *
32 | */
33 | private static final long serialVersionUID = -6258258151952280005L;
34 |
35 | public UnsupportedVersionNumberException() {
36 | }
37 |
38 | public UnsupportedVersionNumberException(int supportedProtocolVersion) {
39 | this.supportedProtocolVersion = supportedProtocolVersion;
40 | }
41 |
42 | public UnsupportedVersionNumberException(String message, int supportedProtocolVersion) {
43 | super(message);
44 |
45 | this.supportedProtocolVersion = supportedProtocolVersion;
46 | }
47 |
48 | /**
49 | * @return the supportedProtocolVersion
50 | */
51 | public int getSupportedProtocolVersion() {
52 | return supportedProtocolVersion;
53 | }
54 |
55 | @Override
56 | public NotificationPacket toNotificationPacket() {
57 | return new UnsupportedVersionNumberNotificationPacket(supportedProtocolVersion);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/UnsupportedVersionNumberNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.open;
18 |
19 | import org.topology.bgp_ls.netty.BGPv4Constants;
20 | import org.jboss.netty.buffer.ChannelBuffer;
21 | import org.jboss.netty.buffer.ChannelBuffers;
22 |
23 | /**
24 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
25 | *
26 | */
27 | public class UnsupportedVersionNumberNotificationPacket extends OpenNotificationPacket {
28 |
29 | private int supportedProtocolVersion = BGPv4Constants.BGP_VERSION;
30 |
31 | public UnsupportedVersionNumberNotificationPacket() {
32 | super(OpenNotificationPacket.SUBCODE_UNSUPPORTED_VERSION_NUMBER);
33 | }
34 |
35 | public UnsupportedVersionNumberNotificationPacket(int version) {
36 | super(OpenNotificationPacket.SUBCODE_UNSUPPORTED_VERSION_NUMBER);
37 |
38 | this.supportedProtocolVersion = version;
39 | }
40 |
41 | /* (non-Javadoc)
42 | * @see org.topology.bgp_ls.netty.protocol.NotificationPacket#encodePayload()
43 | */
44 | @Override
45 | protected ChannelBuffer encodeAdditionalPayload() {
46 | ChannelBuffer buffer = ChannelBuffers.buffer(2);
47 |
48 | buffer.writeShort(this.supportedProtocolVersion);
49 |
50 | return buffer;
51 | }
52 |
53 | /**
54 | * @return the version
55 | */
56 | public int getSupportedProtocolVersion() {
57 | return supportedProtocolVersion;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/open/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for encoding/decoding BGP Open packets and associated error handling
3 | */
4 | package org.topology.bgp_ls.netty.protocol.open;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for encoding/decoding BGP packets and associated error conditions
3 | */
4 | package org.topology.bgp_ls.netty.protocol;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/refresh/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for encoding/decoding BGP Refresh packets
3 | */
4 | package org.topology.bgp_ls.netty.protocol.refresh;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/AggregatorPathAttributeCodecHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.update.AggregatorPathAttributeCodecHandler.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.topology.bgp_ls.net.attributes.AggregatorPathAttribute;
21 | import org.topology.bgp_ls.netty.BGPv4Constants;
22 | import org.jboss.netty.buffer.ChannelBuffer;
23 | import org.jboss.netty.buffer.ChannelBuffers;
24 |
25 | /**
26 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
27 | *
28 | */
29 | public class AggregatorPathAttributeCodecHandler extends PathAttributeCodecHandler {
30 |
31 | /* (non-Javadoc)
32 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#typeCode(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
33 | */
34 | @Override
35 | public int typeCode(AggregatorPathAttribute attr) {
36 | return (attr.isFourByteASNumber()
37 | ? BGPv4Constants.BGP_PATH_ATTRIBUTE_TYPE_AS4_AGGREGATOR
38 | : BGPv4Constants.BGP_PATH_ATTRIBUTE_TYPE_AGGREGATOR);
39 | }
40 |
41 | @Override
42 | public int valueLength(AggregatorPathAttribute attr) {
43 | return (attr.isFourByteASNumber() ? 8 : 6);
44 | }
45 |
46 | @Override
47 | public ChannelBuffer encodeValue(AggregatorPathAttribute attr) {
48 | ChannelBuffer buffer = ChannelBuffers.buffer(valueLength(attr));
49 |
50 | if(attr.isFourByteASNumber())
51 | buffer.writeInt(attr.getAsNumber());
52 | else
53 | buffer.writeShort(attr.getAsNumber());
54 |
55 | buffer.writeBytes(attr.getAggregator().getAddress());
56 |
57 | return buffer;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/AtomicAggregatePathAttributeCodecHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.update.AtomicAggregatePathAttributeCodecHandler.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.topology.bgp_ls.net.attributes.AtomicAggregatePathAttribute;
21 | import org.topology.bgp_ls.netty.BGPv4Constants;
22 | import org.jboss.netty.buffer.ChannelBuffer;
23 |
24 | /**
25 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
26 | *
27 | */
28 | public class AtomicAggregatePathAttributeCodecHandler extends
29 | PathAttributeCodecHandler {
30 |
31 | /* (non-Javadoc)
32 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#typeCode(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
33 | */
34 | @Override
35 | public int typeCode(AtomicAggregatePathAttribute attr) {
36 | return BGPv4Constants.BGP_PATH_ATTRIBUTE_TYPE_ATOMIC_AGGREGATE;
37 | }
38 |
39 | /* (non-Javadoc)
40 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#valueLength(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
41 | */
42 | @Override
43 | public int valueLength(AtomicAggregatePathAttribute attr) {
44 | return 0;
45 | }
46 |
47 | /* (non-Javadoc)
48 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#encodeValue(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
49 | */
50 | @Override
51 | public ChannelBuffer encodeValue(AtomicAggregatePathAttribute attr) {
52 | return null;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/AttributeFlagsException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.AttributeFlagsException.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class AttributeFlagsException extends UpdatePacketException {
27 |
28 | /**
29 | *
30 | */
31 | private static final long serialVersionUID = -359375717544249436L;
32 |
33 | private byte[] offendingAttribute;
34 |
35 | /**
36 | *
37 | */
38 | public AttributeFlagsException() {
39 | }
40 |
41 | /**
42 | * @param message
43 | */
44 | public AttributeFlagsException(String message) {
45 | super(message);
46 | }
47 |
48 | /* (non-Javadoc)
49 | * @see org.topology.bgp_ls.netty.protocol.ProtocolPacketException#toNotificationPacket()
50 | */
51 | @Override
52 | public NotificationPacket toNotificationPacket() {
53 | return new AttributeFlagsNotificationPacket(offendingAttribute);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/AttributeFlagsNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.update;
18 |
19 |
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class AttributeFlagsNotificationPacket extends AttributeNotificationPacket {
26 |
27 | public AttributeFlagsNotificationPacket(byte[] offendingAttribute) {
28 | super(UpdateNotificationPacket.SUBCODE_ATTRIBUTE_FLAGS_ERROR, offendingAttribute);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/AttributeLengthException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.update;
18 |
19 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class AttributeLengthException extends AttributeException {
26 |
27 | /**
28 | *
29 | */
30 | private static final long serialVersionUID = -3386494133413403227L;
31 |
32 | /**
33 | *
34 | */
35 | public AttributeLengthException() {
36 | }
37 |
38 | public AttributeLengthException(byte[] offendingAttribute) {
39 | super(offendingAttribute);
40 | }
41 |
42 | public AttributeLengthException(String message, byte[] offendingAttribute) {
43 | super(message, offendingAttribute);
44 | }
45 |
46 | @Override
47 | public NotificationPacket toNotificationPacket() {
48 | return new AttributeLengthNotificationPacket(getOffendingAttribute());
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/AttributeLengthNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.PathAttributeLengthNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class AttributeLengthNotificationPacket extends AttributeNotificationPacket {
26 |
27 | /**
28 | * @param subcode
29 | */
30 | public AttributeLengthNotificationPacket(byte[] offendingAttribute) {
31 | super(UpdateNotificationPacket.SUBCODE_ATTRIBUTE_LENGTH_ERROR, offendingAttribute);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/AttributeNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.PathAttributeLengthNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.jboss.netty.buffer.ChannelBuffer;
21 | import org.jboss.netty.buffer.ChannelBuffers;
22 |
23 | /**
24 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
25 | *
26 | */
27 | public class AttributeNotificationPacket extends UpdateNotificationPacket {
28 |
29 | private byte[] offendingAttribute;
30 |
31 | /**
32 | * @param subcode
33 | */
34 | protected AttributeNotificationPacket(int subcode, byte[] offendingAttribute) {
35 | super(subcode);
36 |
37 | this.offendingAttribute = offendingAttribute;
38 | }
39 |
40 | /* (non-Javadoc)
41 | * @see org.topology.bgp_ls.netty.protocol.NotificationPacket#encodeAdditionalPayload()
42 | */
43 | @Override
44 | protected final ChannelBuffer encodeAdditionalPayload() {
45 | ChannelBuffer buffer = null;
46 |
47 | if(offendingAttribute != null) {
48 | buffer = ChannelBuffers.buffer(offendingAttribute.length);
49 |
50 | buffer.writeBytes(offendingAttribute);
51 | }
52 |
53 | return buffer;
54 | }
55 |
56 | /**
57 | * @return the offendingAttribute
58 | */
59 | public byte[] getOffendingAttribute() {
60 | return offendingAttribute;
61 | }
62 |
63 | /**
64 | * @param offendingAttribute the offendingAttribute to set
65 | */
66 | void setOffendingAttribute(byte[] offendingAttribute) {
67 | this.offendingAttribute = offendingAttribute;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/InvalidNetworkFieldException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.update;
18 |
19 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class InvalidNetworkFieldException extends UpdatePacketException {
26 |
27 | /**
28 | *
29 | */
30 | private static final long serialVersionUID = -3338743494817410009L;
31 |
32 | /**
33 | *
34 | */
35 | public InvalidNetworkFieldException() {
36 | }
37 |
38 | /**
39 | * @param message
40 | */
41 | public InvalidNetworkFieldException(String message) {
42 | super(message);
43 | }
44 |
45 | @Override
46 | public NotificationPacket toNotificationPacket() {
47 | return new InvalidNetworkFieldNotificationPacket();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/InvalidNetworkFieldNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.update;
18 |
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class InvalidNetworkFieldNotificationPacket extends
25 | UpdateNotificationPacket {
26 |
27 | /**
28 | * @param subcode
29 | */
30 | public InvalidNetworkFieldNotificationPacket() {
31 | super(UpdateNotificationPacket.SUBCODE_INVALID_NETWORK_FIELD);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/InvalidNextHopException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.update;
18 |
19 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class InvalidNextHopException extends AttributeException {
26 |
27 | /**
28 | *
29 | */
30 | private static final long serialVersionUID = 8535948955861003621L;
31 |
32 | /**
33 | *
34 | */
35 | public InvalidNextHopException() {
36 | }
37 |
38 | /**
39 | * @param offendingAttribute
40 | */
41 | public InvalidNextHopException(byte[] offendingAttribute) {
42 | super(offendingAttribute);
43 | }
44 |
45 | /**
46 | * @param message
47 | * @param offendingAttribute
48 | */
49 | public InvalidNextHopException(String message, byte[] offendingAttribute) {
50 | super(message, offendingAttribute);
51 | }
52 |
53 | @Override
54 | public NotificationPacket toNotificationPacket() {
55 | return new InvalidNextHopNotificationPacket(getOffendingAttribute());
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/InvalidNextHopNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.InvalidNextHopNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class InvalidNextHopNotificationPacket extends AttributeNotificationPacket {
26 |
27 | /**
28 | * @param subcode
29 | * @param offendingAttribute
30 | */
31 | public InvalidNextHopNotificationPacket(byte[] offendingAttribute) {
32 | super(UpdateNotificationPacket.SUBCODE_INVALID_NEXT_HOP_ATTRIBUTE, offendingAttribute);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/InvalidOriginException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.update;
18 |
19 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class InvalidOriginException extends AttributeException {
26 | /**
27 | *
28 | */
29 | private static final long serialVersionUID = 4983725877677879162L;
30 |
31 | /**
32 | *
33 | */
34 | public InvalidOriginException() {
35 | }
36 |
37 | /**
38 | * @param offendingAttribute
39 | */
40 | public InvalidOriginException(byte[] offendingAttribute) {
41 | super(offendingAttribute);
42 | }
43 |
44 | /**
45 | * @param message
46 | */
47 | public InvalidOriginException(String message, byte[] offendingAttribute) {
48 | super(message, offendingAttribute);
49 | }
50 |
51 | @Override
52 | public NotificationPacket toNotificationPacket() {
53 | return new InvalidOriginNotificationPacket(getOffendingAttribute());
54 | }
55 |
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/InvalidOriginNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.InvalidOriginNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class InvalidOriginNotificationPacket extends AttributeNotificationPacket {
26 |
27 | /**
28 | * @param subcode
29 | * @param offendingAttribute
30 | */
31 | public InvalidOriginNotificationPacket(byte[] offendingAttribute) {
32 | super(UpdateNotificationPacket.SUBCODE_INVALID_ORIGIN_ATTRIBUTE, offendingAttribute);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/LocalPrefPathAttributeCodecHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.update.LocalPrefPathAttributeCodecHandler.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.topology.bgp_ls.net.attributes.LocalPrefPathAttribute;
21 | import org.topology.bgp_ls.netty.BGPv4Constants;
22 | import org.jboss.netty.buffer.ChannelBuffer;
23 | import org.jboss.netty.buffer.ChannelBuffers;
24 |
25 | /**
26 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
27 | *
28 | */
29 | public class LocalPrefPathAttributeCodecHandler extends
30 | PathAttributeCodecHandler {
31 |
32 | /* (non-Javadoc)
33 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#typeCode(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
34 | */
35 | @Override
36 | public int typeCode(LocalPrefPathAttribute attr) {
37 | return BGPv4Constants.BGP_PATH_ATTRIBUTE_TYPE_LOCAL_PREF;
38 | }
39 |
40 | /* (non-Javadoc)
41 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#valueLength(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
42 | */
43 | @Override
44 | public int valueLength(LocalPrefPathAttribute attr) {
45 | return 4;
46 | }
47 |
48 | /* (non-Javadoc)
49 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#encodeValue(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
50 | */
51 | @Override
52 | public ChannelBuffer encodeValue(LocalPrefPathAttribute attr) {
53 | ChannelBuffer buffer = ChannelBuffers.buffer(4);
54 |
55 | buffer.writeInt(attr.getLocalPreference());
56 |
57 | return buffer;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/MalformedASPathAttributeException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.update;
18 |
19 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class MalformedASPathAttributeException extends AttributeException {
26 |
27 | /**
28 | *
29 | */
30 | private static final long serialVersionUID = 835955227257193451L;
31 |
32 | /**
33 | *
34 | */
35 | public MalformedASPathAttributeException() {
36 | }
37 |
38 | /**
39 | * @param offendingAttribute
40 | */
41 | public MalformedASPathAttributeException(byte[] offendingAttribute) {
42 | super(offendingAttribute);
43 | }
44 |
45 | /**
46 | * @param message
47 | * @param offendingAttribute
48 | */
49 | public MalformedASPathAttributeException(String message,
50 | byte[] offendingAttribute) {
51 | super(message, offendingAttribute);
52 | }
53 |
54 | @Override
55 | public NotificationPacket toNotificationPacket() {
56 | return new MalformedASPathAttributeNotificationPacket(getOffendingAttribute());
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/MalformedASPathAttributeNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.MalformedASPathAttributeNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class MalformedASPathAttributeNotificationPacket extends
26 | AttributeNotificationPacket {
27 |
28 | /**
29 | * @param subcode
30 | * @param offendingAttribute
31 | */
32 | public MalformedASPathAttributeNotificationPacket(byte[] offendingAttribute) {
33 | super(UpdateNotificationPacket.SUBCODE_MALFORMED_AS_PATH, offendingAttribute);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/MalformedAttributeListException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.update;
18 |
19 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class MalformedAttributeListException extends UpdatePacketException {
26 |
27 | /**
28 | *
29 | */
30 | private static final long serialVersionUID = -3338743494817410009L;
31 |
32 | /**
33 | *
34 | */
35 | public MalformedAttributeListException() {
36 | }
37 |
38 | /**
39 | * @param message
40 | */
41 | public MalformedAttributeListException(String message) {
42 | super(message);
43 | }
44 |
45 | @Override
46 | public NotificationPacket toNotificationPacket() {
47 | return new MalformedAttributeListNotificationPacket();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/MalformedAttributeListNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.update;
18 |
19 |
20 | /**
21 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
22 | *
23 | */
24 | public class MalformedAttributeListNotificationPacket extends
25 | UpdateNotificationPacket {
26 |
27 | /**
28 | * @param subcode
29 | */
30 | public MalformedAttributeListNotificationPacket() {
31 | super(UpdateNotificationPacket.SUBCODE_MALFORMED_ATTRIBUTE_LIST);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/MissingWellKnownAttributeException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.MissingWellKnownAttributeException.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class MissingWellKnownAttributeException extends UpdatePacketException {
27 | /**
28 | *
29 | */
30 | private static final long serialVersionUID = 6006146463252407190L;
31 |
32 | private int attributeCode;
33 |
34 | public MissingWellKnownAttributeException() {
35 | }
36 |
37 | public MissingWellKnownAttributeException(int attributeCode) {
38 | this.attributeCode = attributeCode;
39 | }
40 |
41 | public MissingWellKnownAttributeException(String message, int attributeCode) {
42 | super(message);
43 |
44 | this.attributeCode = attributeCode;
45 | }
46 |
47 | @Override
48 | public NotificationPacket toNotificationPacket() {
49 | return new MissingWellKnownAttributeNotificationPacket(this.attributeCode);
50 | }
51 |
52 | /**
53 | * @return the attributeCode
54 | */
55 | public int getAttributeCode() {
56 | return attributeCode;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/MissingWellKnownAttributeNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.WellKnownAttributeMissingNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.jboss.netty.buffer.ChannelBuffer;
21 | import org.jboss.netty.buffer.ChannelBuffers;
22 |
23 | /**
24 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
25 | *
26 | */
27 | public class MissingWellKnownAttributeNotificationPacket extends UpdateNotificationPacket {
28 |
29 | private int attributeCode;
30 |
31 | /**
32 | * @param attributeCode
33 | * @param subcode
34 | */
35 | public MissingWellKnownAttributeNotificationPacket(int attributeCode) {
36 | super(UpdateNotificationPacket.SUBCODE_MISSING_WELL_KNOWN_ATTRIBUTE);
37 |
38 | this.attributeCode = attributeCode;
39 | }
40 |
41 | /* (non-Javadoc)
42 | * @see org.topology.bgp_ls.netty.protocol.NotificationPacket#encodeAdditionalPayload()
43 | */
44 | @Override
45 | protected ChannelBuffer encodeAdditionalPayload() {
46 | ChannelBuffer buffer = ChannelBuffers.buffer(1);
47 |
48 | buffer.writeByte(attributeCode);
49 |
50 | return buffer;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/MultiProtocolNLRICodec.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Nitin Bahadur (nitinb@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.update;
18 |
19 | import org.topology.bgp_ls.net.attributes.MultiProtocolNLRIInformation;
20 | import org.jboss.netty.buffer.ChannelBuffer;
21 |
22 | /**
23 | * This class is a wrapper class for decoding/encoding NLRIs of type
24 | * Multi-protocol BGP. Each AFI/SAFI combo should extend this class
25 | * to define it's own implementation.
26 | *
27 | * @author nitinb
28 | *
29 | */
30 | public class MultiProtocolNLRICodec {
31 |
32 |
33 | public MultiProtocolNLRIInformation decodeNLRI(ChannelBuffer buffer) {
34 | return null;
35 | }
36 |
37 |
38 | public int calculateEncodedNLRILength(MultiProtocolNLRIInformation nlri) {
39 | return 0;
40 | }
41 |
42 | public ChannelBuffer encodeNLRI(MultiProtocolNLRIInformation nlri) {
43 | return null;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/MultiProtocolNLRIDecoderTypes.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Nitin Bahadur (nitinb@gmail.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.update;
18 |
19 | import java.util.HashMap;
20 | import java.util.Map;
21 |
22 | import org.topology.bgp_ls.net.AddressFamily;
23 | import org.topology.bgp_ls.net.AddressFamilyKey;
24 | import org.topology.bgp_ls.net.SubsequentAddressFamily;
25 |
26 | /**
27 | * @author nitinb
28 | *
29 | */
30 | public class MultiProtocolNLRIDecoderTypes {
31 | private static MapnlriTypes = new HashMap();
32 |
33 | static {
34 | nlriTypes.put(AddressFamilyKey.BGP_LS_TOPOLOGY, "org.topology.bgp_ls.netty.protocol.update.bgplsnlri.BgpLsNLRICodec");
35 | nlriTypes.put(AddressFamilyKey.BGP_LS_VPN_TOPOLOGY, "org.topology.bgp_ls.netty.protocol.update.bgplsnlri.BgpLsVpnNLRICodec");
36 | }
37 |
38 | /**
39 | * Returns the name of the NLRI, given an AFI/SAFI combo
40 | * @param addressFamily
41 | * @param subsequentAddressFamily
42 | * @return Name of NLRI
43 | */
44 | public static String getSubClass(AddressFamily addressFamily, SubsequentAddressFamily subsequentAddressFamily) {
45 | return nlriTypes.get(new AddressFamilyKey(addressFamily, subsequentAddressFamily));
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/NextHopPathAttributeCodecHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.update.NextHopPathAttributeCodecHandler.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.topology.bgp_ls.net.attributes.NextHopPathAttribute;
21 | import org.topology.bgp_ls.netty.BGPv4Constants;
22 | import org.jboss.netty.buffer.ChannelBuffer;
23 | import org.jboss.netty.buffer.ChannelBuffers;
24 |
25 | /**
26 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
27 | *
28 | */
29 | public class NextHopPathAttributeCodecHandler extends
30 | PathAttributeCodecHandler {
31 |
32 | /* (non-Javadoc)
33 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#typeCode(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
34 | */
35 | @Override
36 | public int typeCode(NextHopPathAttribute attr) {
37 | return BGPv4Constants.BGP_PATH_ATTRIBUTE_TYPE_NEXT_HOP;
38 | }
39 |
40 | /* (non-Javadoc)
41 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#valueLength(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
42 | */
43 | @Override
44 | public int valueLength(NextHopPathAttribute attr) {
45 | return 4;
46 | }
47 |
48 | /* (non-Javadoc)
49 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#encodeValue(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
50 | */
51 | @Override
52 | public ChannelBuffer encodeValue(NextHopPathAttribute attr) {
53 | ChannelBuffer buffer = ChannelBuffers.buffer(4);
54 |
55 | buffer.writeBytes(attr.getNextHop().getAddress().getAddress());
56 |
57 | return buffer;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/OptionalAttributeErrorNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.UnrecognizedWellKnownAttributeNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class OptionalAttributeErrorNotificationPacket extends
26 | AttributeNotificationPacket {
27 |
28 | /**
29 | * @param subcode
30 | * @param offendingAttribute
31 | */
32 | public OptionalAttributeErrorNotificationPacket(byte[] offendingAttribute) {
33 | super(UpdateNotificationPacket.SUBCODE_OPTIONAL_ATTRIBUTE_ERROR, offendingAttribute);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/OriginCodec.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.update.OriginCodec.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.topology.bgp_ls.net.Origin;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class OriginCodec {
27 |
28 | static Origin fromCode(int code) {
29 | switch(code) {
30 | case 0:
31 | return Origin.IGP;
32 | case 1:
33 | return Origin.EGP;
34 | case 2:
35 | return Origin.INCOMPLETE;
36 | default:
37 | throw new IllegalArgumentException("unknown origin code: " + code);
38 | }
39 | }
40 |
41 | static int toCode(Origin origin) {
42 | switch(origin) {
43 | case IGP:
44 | return 0;
45 | case EGP:
46 | return 1;
47 | case INCOMPLETE:
48 | return 2;
49 | default:
50 | throw new IllegalArgumentException("unknown origin code: " +origin);
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/OriginPathAttributeCodecHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.update.OriginPathAttributeCodecHandler.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.topology.bgp_ls.net.attributes.OriginPathAttribute;
21 | import org.topology.bgp_ls.netty.BGPv4Constants;
22 | import org.jboss.netty.buffer.ChannelBuffer;
23 | import org.jboss.netty.buffer.ChannelBuffers;
24 |
25 | /**
26 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
27 | *
28 | */
29 | public class OriginPathAttributeCodecHandler extends
30 | PathAttributeCodecHandler {
31 |
32 | /* (non-Javadoc)
33 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#typeCode(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
34 | */
35 | @Override
36 | public int typeCode(OriginPathAttribute attr) {
37 | return BGPv4Constants.BGP_PATH_ATTRIBUTE_TYPE_ORIGIN;
38 | }
39 |
40 | /* (non-Javadoc)
41 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#valueLength(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
42 | */
43 | @Override
44 | public int valueLength(OriginPathAttribute attr) {
45 | return 1; // fixed one byte
46 | }
47 |
48 | /* (non-Javadoc)
49 | * @see org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler#encodeValue(org.topology.bgp_ls.netty.protocol.update.PathAttribute)
50 | */
51 | @Override
52 | public ChannelBuffer encodeValue(OriginPathAttribute attr) {
53 | ChannelBuffer buffer = ChannelBuffers.buffer(1);
54 |
55 | buffer.writeByte(OriginCodec.toCode(attr.getOrigin()));
56 |
57 | return buffer;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/PathAttributeCodecHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.update.PathAttributeCodecHandler.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.topology.bgp_ls.net.attributes.PathAttribute;
21 | import org.jboss.netty.buffer.ChannelBuffer;
22 |
23 | /**
24 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
25 | *
26 | */
27 | public abstract class PathAttributeCodecHandler {
28 |
29 | public abstract int typeCode(T attr);
30 |
31 | public abstract int valueLength(T attr);
32 |
33 | public abstract ChannelBuffer encodeValue(T attr);
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/PathSegmentTypeCodec.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.update.PathSegmentTypeCodec.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.topology.bgp_ls.net.PathSegmentType;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class PathSegmentTypeCodec {
27 |
28 | private static final int AS_SET_CODE = 1;
29 | private static final int AS_SEQUENCE_CODE = 2;
30 | private static final int AS_CONFED_SEQUENCE_CODE = 3;
31 | private static final int AS_CONFED_SET_CODE = 4;
32 |
33 |
34 | static PathSegmentType fromCode(int code) {
35 | switch(code) {
36 | case AS_SET_CODE:
37 | return PathSegmentType.AS_SET;
38 | case AS_SEQUENCE_CODE:
39 | return PathSegmentType.AS_SEQUENCE;
40 | case AS_CONFED_SEQUENCE_CODE:
41 | return PathSegmentType.AS_CONFED_SEQUENCE;
42 | case AS_CONFED_SET_CODE:
43 | return PathSegmentType.AS_CONFED_SET;
44 | default:
45 | throw new IllegalArgumentException("illegal AS_PATH type" + code);
46 | }
47 | }
48 |
49 | // unordered set of ASes in a confederation a route in the UPDATE message has traversed
50 |
51 | static int toCode(PathSegmentType type) {
52 | switch(type) {
53 | case AS_SET:
54 | return AS_SET_CODE;
55 | case AS_SEQUENCE:
56 | return AS_SEQUENCE_CODE;
57 | case AS_CONFED_SEQUENCE:
58 | return AS_CONFED_SEQUENCE_CODE;
59 | case AS_CONFED_SET:
60 | return AS_CONFED_SET_CODE;
61 | default:
62 | throw new IllegalArgumentException("illegal AS_PATH type" + type);
63 | }
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/UnrecognizedWellKnownAttributeNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.UnrecognizedWellKnownAttributeNotificationPacket.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 |
21 | /**
22 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
23 | *
24 | */
25 | public class UnrecognizedWellKnownAttributeNotificationPacket extends
26 | AttributeNotificationPacket {
27 |
28 | /**
29 | * @param subcode
30 | * @param offendingAttribute
31 | */
32 | public UnrecognizedWellKnownAttributeNotificationPacket(byte[] offendingAttribute) {
33 | super(UpdateNotificationPacket.SUBCODE_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE, offendingAttribute);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/UpdateNotificationPacket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.protocol.update;
18 |
19 | import org.topology.bgp_ls.netty.BGPv4Constants;
20 | import org.topology.bgp_ls.netty.protocol.NotificationPacket;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public class UpdateNotificationPacket extends NotificationPacket {
27 |
28 | protected static final int SUBCODE_MALFORMED_ATTRIBUTE_LIST = 1;
29 | protected static final int SUBCODE_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE = 2;
30 | protected static final int SUBCODE_MISSING_WELL_KNOWN_ATTRIBUTE = 3;
31 | protected static final int SUBCODE_ATTRIBUTE_FLAGS_ERROR = 4;
32 | protected static final int SUBCODE_ATTRIBUTE_LENGTH_ERROR = 5;
33 | protected static final int SUBCODE_INVALID_ORIGIN_ATTRIBUTE = 6;
34 | protected static final int SUBCODE_INVALID_NEXT_HOP_ATTRIBUTE = 8;
35 | protected static final int SUBCODE_OPTIONAL_ATTRIBUTE_ERROR = 9;
36 | protected static final int SUBCODE_INVALID_NETWORK_FIELD = 10;
37 | protected static final int SUBCODE_MALFORMED_AS_PATH = 11;
38 |
39 | protected UpdateNotificationPacket(int subcode) {
40 | super(BGPv4Constants.BGP_ERROR_CODE_UPDATE, subcode);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/UpdatePacketException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * File: org.topology.bgp_ls.netty.protocol.UpdatePacketException.java
17 | */
18 | package org.topology.bgp_ls.netty.protocol.update;
19 |
20 | import org.topology.bgp_ls.netty.protocol.ProtocolPacketException;
21 |
22 | /**
23 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
24 | *
25 | */
26 | public abstract class UpdatePacketException extends ProtocolPacketException {
27 |
28 | /**
29 | *
30 | */
31 | private static final long serialVersionUID = 755683737903202898L;
32 |
33 | /**
34 | *
35 | */
36 | public UpdatePacketException() {
37 | }
38 |
39 | public UpdatePacketException(String message) {
40 | super(message);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/bgplsnlri/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for decoding BGP link state packets
3 | */
4 | package org.topology.bgp_ls.netty.protocol.update.bgplsnlri;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/protocol/update/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for encoding/decoding BGP Update packets and associated error handling
3 | */
4 | package org.topology.bgp_ls.netty.protocol.update;
5 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/service/ChannelFactoryProducer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.service;
18 |
19 | import java.util.concurrent.Executors;
20 |
21 | import org.jboss.netty.channel.ChannelFactory;
22 | import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
23 |
24 | /**
25 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
26 | *
27 | */
28 | public class ChannelFactoryProducer {
29 |
30 | ChannelFactory produceClientChannelFactory() {
31 | return new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/service/ClientFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Rainer Bieniek (Rainer.Bieniek@web.de)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.topology.bgp_ls.netty.service;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * Producer qualifier for client channel socket factory
27 | *
28 | * @author Rainer Bieniek (Rainer.Bieniek@web.de)
29 | *
30 | */
31 | @Documented
32 | @Retention(RetentionPolicy.RUNTIME)
33 | @Target({ElementType.FIELD , ElementType.PARAMETER, ElementType.METHOD})
34 | public @interface ClientFactory {
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/topology/bgp_ls/netty/service/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for starting BGP application as either a netty server or client
3 | */
4 | package org.topology.bgp_ls.netty.service;
5 |
--------------------------------------------------------------------------------
/src/test/java/org/topology/bgp_ls/AppTest.java:
--------------------------------------------------------------------------------
1 | package org.topology.bgp_ls;
2 |
3 | import junit.framework.Test;
4 | import junit.framework.TestCase;
5 | import junit.framework.TestSuite;
6 |
7 | /**
8 | * Unit test for simple App.
9 | */
10 | public class AppTest
11 | extends TestCase
12 | {
13 | /**
14 | * Create the test case
15 | *
16 | * @param testName name of the test case
17 | */
18 | public AppTest( String testName )
19 | {
20 | super( testName );
21 | }
22 |
23 | /**
24 | * @return the suite of tests being tested
25 | */
26 | public static Test suite()
27 | {
28 | return new TestSuite( AppTest.class );
29 | }
30 |
31 | /**
32 | * Rigourous Test :-)
33 | */
34 | public void testApp()
35 | {
36 | assertTrue( true );
37 | }
38 | }
39 |
--------------------------------------------------------------------------------