summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/protocols/bgp
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/protocols/bgp')
-rwxr-xr-xframework/src/onos/protocols/bgp/api/pom.xml90
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpCfg.java297
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java28
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java131
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java130
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpId.java121
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java35
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java60
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java35
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPacketStats.java52
-rw-r--r--framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeer.java113
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerCfg.java180
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerManager.java54
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpSessionInfo.java70
-rwxr-xr-xframework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/package-info.java20
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/pom.xml76
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/exceptions/BgpParseException.java106
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/exceptions/package-info.java20
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpFactories.java82
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpFactory.java60
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpKeepaliveMsg.java48
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpLSNlri.java54
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpLinkLsNlri.java47
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpMessage.java71
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpMessageReader.java36
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpMessageWriter.java36
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpNodeLSNlri.java30
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpNotificationMsg.java77
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpOpenMsg.java127
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpPrefixLSNlri.java40
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpType.java45
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpUpdateMsg.java48
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpVersion.java45
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/IGPRouterID.java23
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/NlriType.java45
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/Writeable.java35
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java297
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLsNlriVer4.java210
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSIdentifier.java122
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java212
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixIPv4LSNlriVer4.java205
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java272
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/NodeDescriptors.java264
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.java135
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetailsLocalRib.java122
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/package-info.java20
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/package-info.java20
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpFactoryVer4.java58
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java157
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpMessageVer4.java111
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java265
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java518
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java200
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java285
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/package-info.java20
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java130
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java175
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java214
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java130
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpErrorType.java74
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpHeader.java161
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpLSIdentifierTlv.java131
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java47
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java120
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.java165
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java133
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java133
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java124
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java146
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java142
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkStateAttributes.java314
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LocalPref.java121
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Med.java121
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpReachNlri.java225
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpUnReachNlri.java210
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java166
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/NextHop.java139
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java121
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java132
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.java168
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Origin.java168
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java79
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java199
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeIsIsAreaId.java136
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java164
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java135
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrOpaqueNode.java138
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java140
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java143
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetric.java178
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIsIsAdminstGrp.java136
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidth.java156
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMask.java158
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java134
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttrib.java139
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionType.java246
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrSrlg.java136
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetric.java138
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidth.java163
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrExtRouteTag.java145
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java204
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetric.java137
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueData.java139
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddr.java193
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java142
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/package-info.java20
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/package-info.java20
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Constants.java37
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/UnSupportedAttribute.java51
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Validation.java223
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/package-info.java20
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrMaxLinkBandwidthTest.java44
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrTeDefaultMetricTest.java42
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrOpaqueDataTest.java42
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpKeepaliveMsgTest.java66
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpNotificationMsgTest.java224
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpOpenMsgTest.java314
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpUpdateMsgTest.java1496
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AreaIdTest.java39
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/As4PathTest.java55
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AsPathTest.java55
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AutonomousSystemTest.java39
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/BgpLSIdentifierTest.java39
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPReachabilityInformationTest.java40
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv4AddressTest.java40
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv6AddressTest.java40
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IsIsNonPseudonodeTest.java39
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IsIsPseudonodeTest.java39
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTest.java39
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/LocalPrefTest.java36
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/MedTest.java36
-rwxr-xr-xframework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/NextHopTest.java40
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OriginTest.java39
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfPseudonodeTest.java42
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfRouteTypeTest.java39
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlvTest.java50
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6Test.java49
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetricTest.java43
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidthTest.java43
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMaskTest.java42
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrNameTest.java38
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttribTest.java41
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionTypeTest.java56
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetricTest.java40
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidthTest.java56
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlagsTest.java53
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetricTest.java39
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueDataTest.java41
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddrTest.java51
-rw-r--r--framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTagTest.java54
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/pom.xml61
-rw-r--r--framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/AdjRibIn.java132
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java896
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConfig.java364
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConnectPeerImpl.java133
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpControllerImpl.java266
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpKeepAliveTimer.java72
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java603
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpMessageDecoder.java60
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpMessageEncoder.java60
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPacketStatsImpl.java124
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerConfig.java121
-rw-r--r--framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerImpl.java346
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPipelineFactory.java74
-rw-r--r--framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpSelectionAlgo.java242
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpSessionInfoImpl.java93
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/Controller.java254
-rw-r--r--framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/VpnAdjRibIn.java209
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/package-info.java20
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpControllerImplTest.java322
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerChannelHandlerTest.java107
-rwxr-xr-xframework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerFrameDecoderTest.java168
-rw-r--r--framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/controller/impl/BgpSelectionAlgoTest.java595
-rwxr-xr-xframework/src/onos/protocols/bgp/pom.xml40
174 files changed, 0 insertions, 23001 deletions
diff --git a/framework/src/onos/protocols/bgp/api/pom.xml b/framework/src/onos/protocols/bgp/api/pom.xml
deleted file mode 100755
index d233c48e..00000000
--- a/framework/src/onos/protocols/bgp/api/pom.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-bgp</artifactId>
- <version>1.4.0-rc1</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>onos-bgp-api</artifactId>
- <packaging>bundle</packaging>
-
- <description>ONOS BGP controller subsystem API</description>
-
- <dependencies>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-bgpio</artifactId>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-api</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.3</version>
- <configuration>
- <artifactSet>
- <excludes>
- <exclude>io.netty:netty</exclude>
- <exclude>com.google.guava:guava</exclude>
- <exclude>org.slf4j:slfj-api</exclude>
- <exclude>ch.qos.logback:logback-core</exclude>
- <exclude>ch.qos.logback:logback-classic</exclude>
- <exclude>com.google.code.findbugs:annotations</exclude>
- </excludes>
- </artifactSet>
- </configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Export-Package>
- org.onosproject.bgp.*,org.onosproject.bgpio.*,org.onosproject.bgp.controller
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpCfg.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpCfg.java
deleted file mode 100755
index 6f64d2bb..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpCfg.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.controller;
-
-import java.util.TreeMap;
-
-/**
- * Abstraction of an BGP configuration. Manages the BGP configuration from CLI to the BGP controller.
- */
-public interface BgpCfg {
-
- enum State {
- /**
- * Signifies that its just created.
- */
- INIT,
-
- /**
- * Signifies that only IP Address is configured.
- */
- IP_CONFIGURED,
-
- /**
- * Signifies that only Autonomous System is configured.
- */
- AS_CONFIGURED,
-
- /**
- * Signifies that both IP and Autonomous System is configured.
- */
- IP_AS_CONFIGURED
- }
-
- /**
- * Returns the status of the configuration based on this state certain operations like connection is handled.
- *
- * @return State of the configuration
- */
- State getState();
-
- /**
- * To set the current state of the configuration.
- *
- * @param state Configuration State enum
- */
- void setState(State state);
-
- /**
- * Get the status of the link state support for this BGP speaker.
- *
- * @return true if the link state is supported else false
- */
- boolean getLsCapability();
-
- /**
- * Set the link state support to this BGP speaker.
- *
- * @param lscapability true value if link state is supported else false
- */
- void setLsCapability(boolean lscapability);
-
- /**
- * Get the status of the 32 bit AS support for this BGP speaker.
- *
- * @return true if the 32 bit AS number is supported else false
- */
- boolean getLargeASCapability();
-
- /**
- * Set the 32 bit AS support capability to this BGP speaker.
- *
- * @param largeAs true value if the 32 bit AS is supported else false
- */
- void setLargeASCapability(boolean largeAs);
-
- /**
- * Set the AS number to which this BGP speaker belongs.
- *
- * @param localAs 16 or 32 bit AS number, length is dependent on the capability
- */
- void setAsNumber(int localAs);
-
- /**
- * Get the AS number to which this BGP speaker belongs.
- *
- * @return 16 or 32 bit AS number, length is dependent on the capability
- */
- int getAsNumber();
-
- /**
- * Get the connection retry count number.
- *
- * @return connection retry count if there is a connection error
- */
- int getMaxConnRetryCount();
-
- /**
- * Set the connection retry count.
- *
- * @param retryCount number of times to try to connect if there is any error
- */
- void setMaxConnRetryCout(int retryCount);
-
- /**
- * Get the connection retry time in seconds.
- *
- * @return connection retry time in seconds
- */
- int getMaxConnRetryTime();
-
- /**
- * Set the connection retry time in seconds.
- *
- * @param retryTime connection retry times in seconds
- */
- void setMaxConnRetryTime(int retryTime);
-
- /**
- * Set the keep alive timer for the connection.
- *
- * @param holdTime connection hold timer in seconds
- */
- void setHoldTime(short holdTime);
-
- /**
- * Returns the connection hold timer in seconds.
- *
- * @return connection hold timer in seconds
- */
- short getHoldTime();
-
- /**
- * Returns the maximum number of session supported.
- *
- * @return maximum number of session supported
- */
- int getMaxSession();
-
- /**
- * Set the maximum number of sessions to support.
- *
- * @param maxsession maximum number of session
- */
- void setMaxSession(int maxsession);
-
- /**
- * Returns the Router ID of this BGP speaker.
- *
- * @return IP address in string format
- */
- String getRouterId();
-
- /**
- * Set the Router ID of this BGP speaker.
- *
- * @param routerid IP address in string format
- */
- void setRouterId(String routerid);
-
- /**
- * Add the BGP peer IP address and the AS number to which it belongs.
- *
- * @param routerid IP address in string format
- * @param remoteAs AS number to which it belongs
- *
- * @return true if added successfully else false
- */
- boolean addPeer(String routerid, int remoteAs);
-
- /**
- * Add the BGP peer IP address and the keep alive time.
- *
- * @param routerid IP address in string format
- * @param holdTime keep alive time for the connection
- *
- * @return true if added successfully else false
- */
- boolean addPeer(String routerid, short holdTime);
-
- /**
- * Add the BGP peer IP address, the AS number to which it belongs and keep alive time.
- *
- * @param routerid IP address in string format
- * @param remoteAs AS number to which it belongs
- * @param holdTime keep alive time for the connection
- *
- * @return true if added successfully else false
- */
- boolean addPeer(String routerid, int remoteAs, short holdTime);
-
- /**
- * Remove the BGP peer with this IP address.
- *
- * @param routerid router IP address
- *
- * @return true if removed successfully else false
- */
- boolean removePeer(String routerid);
-
- /**
- * Connect to BGP peer with this IP address.
- *
- * @param routerid router IP address
- *
- * @return true of the configuration is found and able to connect else false
- */
- boolean connectPeer(String routerid);
-
- /**
- * Disconnect this BGP peer with this IP address.
- *
- * @param routerid router IP address in string format
- *
- * @return true if the configuration is found and able to disconnect else false
- */
- boolean disconnectPeer(String routerid);
-
- /**
- * Returns the peer tree information.
- *
- * @return return the tree map with IP as key and BGPPeerCfg as object
- */
- TreeMap<String, BgpPeerCfg> displayPeers();
-
- /**
- * Return the BGP Peer information with this matching IP.
- *
- * @param routerid router IP address in string format
- *
- * @return BGPPeerCfg object
- */
- BgpPeerCfg displayPeers(String routerid);
-
- /**
- * Check if this BGP peer is configured.
- *
- * @param routerid router IP address in string format
- *
- * @return true if configured exists else false
- */
- boolean isPeerConfigured(String routerid);
-
- /**
- * Check if this BGP speaker is having connection with the peer.
- *
- * @param routerid router IP address in string format
- *
- * @return true if the connection exists else false
- */
- boolean isPeerConnected(String routerid);
-
- /**
- * Return the peer tree map.
- *
- * @return return the tree map with IP as key and BGPPeerCfg as object
- */
- TreeMap<String, BgpPeerCfg> getPeerTree();
-
- /**
- * Set the current connection state information.
- *
- * @param routerid router IP address in string format
- * @param state state information
- */
- void setPeerConnState(String routerid, BgpPeerCfg.State state);
-
- /**
- * Check if the peer can be connected or not.
- *
- * @param routerid router IP address in string format
- *
- * @return true if the peer can be connected else false
- */
- boolean isPeerConnectable(String routerid);
-
- /**
- * Get the current peer connection state information.
- *
- * @param routerid router IP address in string format
- *
- * @return state information
- */
- BgpPeerCfg.State getPeerConnState(String routerid);
-}
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java
deleted file mode 100755
index 8f33ee87..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.onosproject.bgp.controller;
-
-/**
- * Abstraction of an BGP connect peer, initiate remote connection to BGP peer on configuration.
- */
-public interface BgpConnectPeer {
- /**
- * Initiate bgp peer connection.
- */
- void connectPeer();
-
- /**
- * End bgp peer connection.
- */
- void disconnectPeer();
-}
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java
deleted file mode 100755
index 0930e8e8..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgp.controller;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpMessage;
-
-/**
- * Abstraction of an BGP controller. Serves as a one stop shop for obtaining BGP devices and (un)register listeners on
- * bgp events
- */
-public interface BgpController {
-
- /**
- * Returns list of bgp peers connected to this BGP controller.
- *
- * @return Iterable of BGPPeer elements
- */
- Iterable<BgpPeer> getPeers();
-
- /**
- * Returns the actual bgp peer for the given ip address.
- *
- * @param bgpId the id of the bgp peer to fetch
- * @return the interface to this bgp peer
- */
- BgpPeer getPeer(BgpId bgpId);
-
- /**
- * Register a listener for BGP message events.
- *
- * @param listener the listener to notify
- */
- void addListener(BgpNodeListener listener);
-
- /**
- * Unregister a listener.
- *
- * @param listener the listener to unregister
- */
- void removeListener(BgpNodeListener listener);
-
- /**
- * Send a message to a particular bgp peer.
- *
- * @param bgpId the id of the peer to send message.
- * @param msg the message to send
- */
- void writeMsg(BgpId bgpId, BgpMessage msg);
-
- /**
- * Process a message and notify the appropriate listeners.
- *
- * @param bgpId id of the peer the message arrived on
- * @param msg the message to process.
- * @throws BgpParseException on data processing error
- */
- void processBGPPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException;
-
- /**
- * Close all connected BGP peers.
- *
- */
- void closeConnectedPeers();
-
- /**
- * Get the BGPConfig class to the caller.
- *
- * @return configuration object
- */
- BgpCfg getConfig();
-
- /**
- * Get the BGP connected peers to this controller.
- *
- * @return the integer number
- */
- int connectedPeerCount();
-
- /**
- * Return BGP local RIB instance with VPN.
- *
- * @return BGPLocalRibImpl local RIB with VPN
- */
- BgpLocalRib bgpLocalRibVpn();
-
- /**
- * Return BGP local RIB instance.
- *
- * @return BGPLocalRibImpl local RIB
- */
- BgpLocalRib bgpLocalRib();
-
- /**
- * Return BGP peer manager.
- *
- * @return BGPPeerManager peer manager instance
- */
- BgpPeerManager peerManager();
-
- /**
- * Return BGP connected peers.
- *
- * @return connectedPeers connected peers
- */
- Map<BgpId, BgpPeer> connectedPeers();
-
- /**
- * Return BGP node listener.
- *
- * @return node listener
- */
- Set<BgpNodeListener> listener();
-}
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java
deleted file mode 100755
index ed04dc94..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package org.onosproject.bgp.controller;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The class representing a network bgp device id. This class is immutable.
- */
-public final class BgpDpid {
- private static final Logger log = LoggerFactory.getLogger(BgpDpid.class);
-
- private static final String SCHEME = "bgp";
- private static final long UNKNOWN = 0;
- private StringBuilder stringBuilder;
- public static final int NODE_DESCRIPTOR_LOCAL = 1;
- public static final int NODE_DESCRIPTOR_REMOTE = 2;
-
- /**
- * Initialize bgp id to generate URI.
- *
- * @param linkNlri node Nlri.
- * @param nodeDescriptorType node descriptor type, local/remote
- */
- public BgpDpid(final BgpLinkLsNlriVer4 linkNlri, int nodeDescriptorType) {
- this.stringBuilder = new StringBuilder("bgpls://");
-
- if (linkNlri.getRouteDistinguisher() != null) {
- this.stringBuilder.append(linkNlri.getRouteDistinguisher().getRouteDistinguisher()).append(':');
- }
-
- try {
- this.stringBuilder.append(linkNlri.getProtocolId()).append(':').append(linkNlri.getIdentifier())
- .append('/');
-
- if (nodeDescriptorType == NODE_DESCRIPTOR_LOCAL) {
- add(linkNlri.localNodeDescriptors());
- } else if (nodeDescriptorType == NODE_DESCRIPTOR_REMOTE) {
- add(linkNlri.remoteNodeDescriptors());
- }
- } catch (BgpParseException e) {
- log.info("Exception BgpId string: " + e.toString());
- }
-
- }
-
- /**
- * Initialize bgp id to generate URI.
- *
- * @param nodeNlri node Nlri.
- */
- public BgpDpid(final BgpNodeLSNlriVer4 nodeNlri) {
- this.stringBuilder = new StringBuilder("bgpls://");
-
- if (nodeNlri.getRouteDistinguisher() != null) {
- this.stringBuilder.append(nodeNlri.getRouteDistinguisher().getRouteDistinguisher()).append(':');
- }
-
- try {
-
- this.stringBuilder.append(nodeNlri.getProtocolId()).append(':').append(nodeNlri.getIdentifier())
- .append('/');
-
- add(nodeNlri.getLocalNodeDescriptors());
-
- } catch (BgpParseException e) {
- log.info("Exception node string: " + e.toString());
- }
- }
-
- BgpDpid add(final Object value) {
- if (value != null) {
- this.stringBuilder.append('&').append('=').append(value.toString());
- }
- return this;
- }
-
- @Override
- public String toString() {
- return this.stringBuilder.toString();
- }
-
- /**
- * Produces bgp URI.
- *
- * @param value string to get URI
- * @return bgp URI, otherwise null
- */
- public static URI uri(String value) {
- try {
- return new URI(SCHEME, value, null);
- } catch (URISyntaxException e) {
- log.info("Exception BgpId URI: " + e.toString());
- }
- return null;
- }
-
- /**
- * Returns bgpDpid created from the given device URI.
- *
- * @param uri device URI
- * @return object of BgpDpid
- */
- public static BgpDpid bgpDpid(URI uri) {
- checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme");
-
- // TODO: return BgpDpid generated from uri
- return null;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpId.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpId.java
deleted file mode 100755
index 7a6c625d..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpId.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgp.controller;
-
-import org.onlab.packet.IpAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-/**
- * The class representing a network peer bgp ip.
- * This class is immutable.
- */
-public final class BgpId {
-
- private static final String SCHEME = "bgp";
- private static final long UNKNOWN = 0;
- private final IpAddress ipAddress;
-
- /**
- * Private constructor.
- */
- private BgpId(IpAddress ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- /**
- * Create a BGPId from ip address.
- *
- * @param ipAddress IP address
- * @return object of BGPId
- */
- public static BgpId bgpId(IpAddress ipAddress) {
- return new BgpId(ipAddress);
- }
-
- /**
- * Returns the ip address.
- *
- * @return ipAddress
- */
- public IpAddress ipAddress() {
- return ipAddress;
- }
-
- /**
- * Convert the BGPId value to a ':' separated hexadecimal string.
- *
- * @return the BGPId value as a ':' separated hexadecimal string.
- */
- @Override
- public String toString() {
- return ipAddress.toString();
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof BgpId)) {
- return false;
- }
-
- BgpId otherBGPid = (BgpId) other;
- return Objects.equals(ipAddress, otherBGPid.ipAddress);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(ipAddress);
- }
-
- /**
- * Returns BGPId created from the given device URI.
- *
- * @param uri device URI
- * @return object of BGPId
- */
- public static BgpId bgpId(URI uri) {
- checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme");
- return new BgpId(IpAddress.valueOf(uri.getSchemeSpecificPart()));
- }
-
- /**
- * Produces device URI from the given DPID.
- *
- * @param bgpId device bgpId
- * @return device URI
- */
- public static URI uri(BgpId bgpId) {
- return uri(bgpId.ipAddress());
- }
-
- /**
- * Produces device URI from the given DPID long.
- *
- * @param ipAddress device ip address
- * @return device URI
- */
- public static URI uri(IpAddress ipAddress) {
- try {
- return new URI(SCHEME, ipAddress.toString(), null);
- } catch (URISyntaxException e) {
- return null;
- }
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java
deleted file mode 100755
index 8b34e314..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.onosproject.bgp.controller;
-
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-
-/**
- * Allows for providers interested in Link events to be notified.
- */
-public interface BgpLinkListener {
-
- /**
- * Notify that got a packet of link from network and need do processing.
- *
- * @param linkNlri bgp link
- */
- void addLink(BgpLinkLsNlriVer4 linkNlri);
-
- /**
- * Notify that got a packet of link from network and need do processing.
- *
- * @param linkNlri bgp link
- */
- void deleteLink(BgpLinkLsNlriVer4 linkNlri);
-}
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java
deleted file mode 100755
index 636c1c85..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package org.onosproject.bgp.controller;
-
-import org.onosproject.bgpio.protocol.BgpLSNlri;
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
-import org.onosproject.bgpio.types.RouteDistinguisher;
-
-/**
- * Abstraction of BGP local RIB.
- */
-public interface BgpLocalRib {
-
- /**
- * Add NLRI to local RIB.
- *
- * @param sessionInfo session info
- * @param nlri network layer reach info
- * @param details nlri details
- */
- void add(BgpSessionInfo sessionInfo, BgpLSNlri nlri, PathAttrNlriDetails details);
-
- /**
- * Removes NLRI identifier if it exists.
- *
- * @param nlri info
- */
- void delete(BgpLSNlri nlri);
-
- /**
- * Update NLRI identifier mapped with route distinguisher if it exists in tree otherwise add NLRI infomation mapped
- * to respective route distinguisher.
- *
- * @param sessionInfo BGP session info
- * @param nlri info
- * @param details has pathattribute, protocol id and identifier
- * @param routeDistinguisher unique for each VPN
- */
- void add(BgpSessionInfo sessionInfo, BgpLSNlri nlri, PathAttrNlriDetails details,
- RouteDistinguisher routeDistinguisher);
-
- /**
- * Removes VPN NLRI identifier mapped to route distinguisher if it exists.
- *
- * @param nlri info
- * @param routeDistinguisher unique for each VPN
- */
- void delete(BgpLSNlri nlri, RouteDistinguisher routeDistinguisher);
-}
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java
deleted file mode 100755
index 726d931b..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.onosproject.bgp.controller;
-
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
-
-/**
- * Allows for providers interested in node events to be notified.
- */
-public interface BgpNodeListener {
-
- /**
- * Notifies that the node was added.
- *
- * @param nodeNlri node rechability info
- */
- void addNode(BgpNodeLSNlriVer4 nodeNlri);
-
- /**
- * Notifies that the node was removed.
- *
- * @param nodeNlri node rechability info
- */
- void deleteNode(BgpNodeLSNlriVer4 nodeNlri);
-}
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPacketStats.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPacketStats.java
deleted file mode 100755
index 8fd3c688..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPacketStats.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgp.controller;
-
-/**
- * A representation of a packet context which allows any provider to view a packet in event, but may block the response
- * to the event if blocked has been called. This packet context can be used to react to the packet in event with a
- * packet out.
- */
-public interface BgpPacketStats {
- /**
- * Returns the count for no of packets sent out.
- *
- * @return int value of no of packets sent
- */
- int outPacketCount();
-
- /**
- * Returns the count for no of packets received.
- *
- * @return int value of no of packets sent
- */
- int inPacketCount();
-
- /**
- * Returns the count for no of wrong packets received.
- *
- * @return int value of no of wrong packets received
- */
- int wrongPacketCount();
-
- /**
- * Returns the time.
- *
- * @return the time
- */
- long getTime();
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeer.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeer.java
deleted file mode 100644
index 9f4d47da..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeer.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.controller;
-import java.util.List;
-import org.jboss.netty.channel.Channel;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpFactory;
-import org.onosproject.bgpio.protocol.BgpMessage;
-import org.onosproject.bgpio.types.BgpValueType;
-
-/**
- * Represents the peer side of an BGP peer.
- *
- */
-public interface BgpPeer {
-
- /**
- * Sets the associated Netty channel for this bgp peer.
- *
- * @param channel the Netty channel
- */
- void setChannel(Channel channel);
-
- /**
- * Gets the associated Netty channel handler for this bgp peer.
- *
- * @return Channel channel connected.
- */
- Channel getChannel();
-
- /**
- * Sets whether the bgp peer is connected.
- *
- * @param connected whether the bgp peer is connected
- */
- void setConnected(boolean connected);
-
- /**
- * Checks whether the handshake is complete.
- *
- * @return true is finished, false if not.
- */
- boolean isHandshakeComplete();
-
- /**
- * Writes the message to the peer.
- *
- * @param msg the message to write
- */
- void sendMessage(BgpMessage msg);
-
- /**
- * Writes the BGPMessage list to the peer.
- *
- * @param msgs the messages to be written
- */
- void sendMessage(List<BgpMessage> msgs);
-
- /**
- * Provides the factory for BGP version.
- *
- * @return BGP version specific factory.
- */
- BgpFactory factory();
-
- /**
- * Checks if the bgp peer is still connected.
- *
- * @return whether the bgp peer is still connected
- */
- boolean isConnected();
-
- /**
- * Disconnects the bgp peer by closing the TCP connection. Results in a call to the channel handler's
- * channelDisconnected method for cleanup
- */
- void disconnectPeer();
-
- /**
- * Identifies the channel used to communicate with the bgp peer.
- *
- * @return string representation of the connection to the peer
- */
- String channelId();
-
- /**
- * Maintaining Adj-RIB-In separately for each peer.
- *
- * @param pathAttr list of Bgp path attributes
- * @throws BgpParseException while building Adj-Rib-In
- */
- void buildAdjRibIn(List<BgpValueType> pathAttr) throws BgpParseException;
-
- /**
- * Return the BGP session info.
- *
- * @return sessionInfo bgp session info
- */
- BgpSessionInfo sessionInfo();
-}
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerCfg.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerCfg.java
deleted file mode 100755
index 2fb970fc..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerCfg.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.controller;
-
-/**
- * BGP Peer configuration information.
- */
-public interface BgpPeerCfg {
-
- enum State {
-
- /**
- * Signifies that peer connection is idle.
- */
- IDLE,
-
- /**
- * Signifies that connection is initiated.
- */
- CONNECT,
-
- /**
- * Signifies that state is active and connection can be established.
- */
- ACTIVE,
-
- /**
- * Signifies that open is sent and anticipating reply.
- */
- OPENSENT,
-
- /**
- * Signifies that peer sent the open message as reply.
- */
- OPENCONFIRM,
-
- /**
- * Signifies that all the negotiation is successful and ready to exchange other messages.
- */
- ESTABLISHED,
-
- /**
- * Signifies that invalid state.
- */
- INVALID
- }
-
- /**
- * Returns the connection State information of the peer.
- *
- * @return
- * enum state is returned
- */
- State getState();
-
- /**
- * Set the connection state information of the peer.
- *
- * @param state
- * enum state
- */
- void setState(State state);
-
- /**
- * Returns the connection is initiated from us or not.
- *
- * @return
- * true if the connection is initiated by this peer, false if it has been received.
- */
- boolean getSelfInnitConnection();
-
- /**
- * Set the connection is initiated from us or not.
- *
- * @param selfInit
- * true if the connection is initiated by this peer, false if it has been received.
- */
- void setSelfInnitConnection(boolean selfInit);
-
- /**
- * Returns the AS number to which this peer belongs.
- *
- * @return
- * AS number
- */
- int getAsNumber();
-
- /**
- * Set the AS number to which this peer belongs.
- *
- * @param asNumber
- * AS number
- */
- void setAsNumber(int asNumber);
-
- /**
- * Get the keep alive timer value configured.
- *
- * @return
- * keep alive timer value in seconds
- */
- short getHoldtime();
-
- /**
- * Set the keep alive timer value.
- *
- * @param holdTime
- * keep alive timer value in seconds
- */
- void setHoldtime(short holdTime);
-
- /**
- * Return the connection type eBGP or iBGP.
- *
- * @return
- * true if iBGP, false if it is eBGP
- */
- boolean getIsIBgp();
-
- /**
- * Set the connection type eBGP or iBGP.
- *
- * @param isIBgp
- * true if iBGP, false if it is eBGP
- */
- void setIsIBgp(boolean isIBgp);
-
- /**
- * Return the peer router IP address.
- *
- * @return
- * IP address in string format
- */
- String getPeerRouterId();
-
- /**
- * Set the peer router IP address.
- *
- * @param peerId
- * IP address in string format
- */
- void setPeerRouterId(String peerId);
-
- /**
- * Set the peer router IP address and AS number.
- *
- * @param peerId
- * IP address in string format
- * @param asNumber
- * AS number
- */
- void setPeerRouterId(String peerId, int asNumber);
-
- /**
- * Set the peer connect instance.
- *
- * @param connectpeer connect peer instance
- */
- void setConnectPeer(BgpConnectPeer connectpeer);
-
- /**
- * Get the peer connect instance.
- *
- * @return peer connect instance
- */
- BgpConnectPeer connectPeer();
-}
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerManager.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerManager.java
deleted file mode 100755
index 895cc145..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerManager.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.onosproject.bgp.controller;
-
-/**
- * Responsible for keeping track of the current set BGPLS peers connected to the system.
- *
- */
-public interface BgpPeerManager {
-
- /**
- * Add connected peer.
- *
- * @param bgpId BGP ID to add
- * @param bgpPeer BGp peer instance
- *
- * @return false if peer already exist, otherwise true
- */
- public boolean addConnectedPeer(BgpId bgpId, BgpPeer bgpPeer);
-
- /**
- * Validate wheather peer is connected.
- *
- * @param bgpId BGP ID to validate
- *
- * @return true if peer exist, otherwise false
- */
- public boolean isPeerConnected(BgpId bgpId);
-
- /**
- * Remove connected peer.
- *
- * @param bgpId BGP ID
- */
- public void removeConnectedPeer(BgpId bgpId);
-
- /**
- * Gets connected peer.
- *
- * @param bgpId BGP ID
- * @return BGPPeer the connected peer, otherwise null
- */
- public BgpPeer getPeer(BgpId bgpId);
-}
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpSessionInfo.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpSessionInfo.java
deleted file mode 100755
index a21a23d2..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpSessionInfo.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package org.onosproject.bgp.controller;
-
-import org.onosproject.bgpio.protocol.BgpVersion;
-
-/**
- * Abstraction of an BGP session info. Maintian session parameters obtained during session creation.
- */
-public interface BgpSessionInfo {
- /**
- * Gets the bgp session type iBGP/eBGP.
- *
- * @return isiBGPSession, true if session is of type internal, otherwise false.
- */
- boolean isIbgpSession();
-
- /**
- * Gets the negotiated hold time for the session.
- *
- * @return negotiated hold time.
- */
- short negotiatedholdTime();
-
- /**
- * Gets the BGP ID of BGP peer.
- *
- * @return bgp ID.
- */
- BgpId remoteBgpId();
-
- /**
- * Gets the BGP version of peer.
- *
- * @return bgp version.
- */
- BgpVersion remoteBgpVersion();
-
- /**
- * Gets the BGP remote bgp AS number.
- *
- * @return remoteBgpASNum peer AS number.
- */
- long remoteBgpASNum();
-
- /**
- * Gets the BGP peer hold time.
- *
- * @return bgp hold time.
- */
- short remoteBgpHoldTime();
-
- /**
- * Gets the BGP version for this bgp peer.
- *
- * @return bgp identifier.
- */
- int remoteBgpIdentifier();
-}
diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/package-info.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/package-info.java
deleted file mode 100755
index 4dd775b8..00000000
--- a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * BGP controller API.
- */
-package org.onosproject.bgp.controller;
diff --git a/framework/src/onos/protocols/bgp/bgpio/pom.xml b/framework/src/onos/protocols/bgp/bgpio/pom.xml
deleted file mode 100755
index 06206e8f..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/pom.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-bgp</artifactId>
- <version>1.4.0-rc1</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>onos-bgpio</artifactId>
- <packaging>bundle</packaging>
-
- <description>ONOS BGPio Protocol subsystem</description>
-
- <dependencies>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onlab-osgi</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/exceptions/BgpParseException.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/exceptions/BgpParseException.java
deleted file mode 100755
index d0890320..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/exceptions/BgpParseException.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.exceptions;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Custom Exception for BGP IO.
- */
-public class BgpParseException extends Exception {
-
- private static final long serialVersionUID = 1L;
- private byte errorCode;
- private byte errorSubCode;
- private ChannelBuffer data;
-
- /**
- * Default constructor to create a new exception.
- */
- public BgpParseException() {
- super();
- }
-
- /**
- * Constructor to create exception from message and cause.
- *
- * @param message the detail of exception in string
- * @param cause underlying cause of the error
- */
- public BgpParseException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Constructor to create exception from message.
- *
- * @param message the detail of exception in string
- */
- public BgpParseException(final String message) {
- super(message);
- }
-
- /**
- * Constructor to create exception from cause.
- *
- * @param cause underlying cause of the error
- */
- public BgpParseException(final Throwable cause) {
- super(cause);
- }
-
- /**
- * Constructor to create exception from error code and error subcode.
- *
- * @param errorCode error code of BGP message
- * @param errorSubCode error subcode of BGP message
- * @param data error data of BGP message
- */
- public BgpParseException(final byte errorCode, final byte errorSubCode, final ChannelBuffer data) {
- super();
- this.errorCode = errorCode;
- this.errorSubCode = errorSubCode;
- this.data = data;
- }
-
- /**
- * Returns errorcode for this exception.
- *
- * @return errorcode for this exception
- */
- public byte getErrorCode() {
- return this.errorCode;
- }
-
- /**
- * Returns error Subcode for this exception.
- *
- * @return error Subcode for this exception
- */
- public byte getErrorSubCode() {
- return this.errorSubCode;
- }
-
- /**
- * Returns error data for this exception.
- *
- * @return error data for this exception
- */
- public ChannelBuffer getData() {
- return this.data;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/exceptions/package-info.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/exceptions/package-info.java
deleted file mode 100755
index 78b28072..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/exceptions/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * BGP custom exceptions.
- */
-package org.onosproject.bgpio.exceptions;
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpFactories.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpFactories.java
deleted file mode 100755
index eb18c7d1..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpFactories.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.ver4.BgpFactoryVer4;
-import org.onosproject.bgpio.types.BgpHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstraction to provide the version for BGP.
- */
-public final class BgpFactories {
-
- protected static final Logger log = LoggerFactory.getLogger(BgpFactories.class);
-
- private static final GenericReader GENERIC_READER = new GenericReader();
-
- private BgpFactories() {
- }
-
- /**
- * Returns the instance of BGP Version.
- *
- * @param version BGP version
- * @return BGP version
- */
- public static BgpFactory getFactory(BgpVersion version) {
- switch (version) {
- case BGP_4:
- return BgpFactoryVer4.INSTANCE;
- default:
- throw new IllegalArgumentException("[BgpFactory:]Unknown version: " + version);
- }
- }
-
- /**
- * Reader class for reading BGP messages from channel buffer.
- *
- */
- private static class GenericReader implements BgpMessageReader<BgpMessage> {
-
- @Override
- public BgpMessage readFrom(ChannelBuffer bb, BgpHeader bgpHeader)
- throws BgpParseException {
- BgpFactory factory;
-
- if (!bb.readable()) {
- log.error("Empty message received");
- throw new BgpParseException("Empty message received");
- }
- // TODO: Currently only BGP version 4 is supported
- factory = org.onosproject.bgpio.protocol.ver4.BgpFactoryVer4.INSTANCE;
- return factory.getReader().readFrom(bb, bgpHeader);
- }
- }
-
- /**
- * Returns BGP messsage generic reader.
- *
- * @return bgp message generic reader
- */
- public static BgpMessageReader<BgpMessage> getGenericReader() {
- return GENERIC_READER;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpFactory.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpFactory.java
deleted file mode 100755
index 11a85ff8..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpFactory.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol;
-
-/**
- * Abstraction of an message factory providing builder functions to BGP messages
- * and objects.
- *
- */
-public interface BgpFactory {
-
- /**
- * Gets the builder object for a open message.
- *
- * @return builder object for open message
- */
- BgpOpenMsg.Builder openMessageBuilder();
-
- /**
- * Gets the builder object for a keepalive message.
- *
- * @return builder object for keepalive message
- */
- BgpKeepaliveMsg.Builder keepaliveMessageBuilder();
-
- /**
- * Gets the builder object for a notification message.
- *
- * @return builder object for notification message.
- */
- BgpNotificationMsg.Builder notificationMessageBuilder();
-
- /**
- * Gets the BGP message reader.
- *
- * @return BGP message reader
- */
- BgpMessageReader<BgpMessage> getReader();
-
- /**
- * Returns BGP version.
- *
- * @return BGP version
- */
- BgpVersion getVersion();
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpKeepaliveMsg.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpKeepaliveMsg.java
deleted file mode 100644
index 0cb776a0..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpKeepaliveMsg.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.types.BgpHeader;
-
-/**
- * Abstraction of an entity providing BGP Keepalive Message.
- */
-public interface BgpKeepaliveMsg extends BgpMessage {
-
- @Override
- BgpVersion getVersion();
-
- @Override
- BgpType getType();
-
- @Override
- void writeTo(ChannelBuffer channelBuffer);
-
- @Override
- BgpHeader getHeader();
-
- /**
- * Builder interface with get and set functions to build Keepalive message.
- */
- interface Builder extends BgpMessage.Builder {
- @Override
- BgpKeepaliveMsg build();
-
- @Override
- Builder setHeader(BgpHeader bgpMsgHeader);
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpLSNlri.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpLSNlri.java
deleted file mode 100644
index dd8857a7..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpLSNlri.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol;
-
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType;
-import org.onosproject.bgpio.types.RouteDistinguisher;
-
-/**
- * Abstraction of an entity providing BGP-LS NLRI.
- */
-public interface BgpLSNlri {
- /**
- * Returns NlriType of BGP-LS NLRI.
- *
- * @return NlriType of BGP-LS NLRI
- */
- NlriType getNlriType();
-
- /**
- * Returns Identifier in Nlri.
- *
- * @return Identifier in Nlri
- */
- long getIdentifier();
-
- /**
- * Returns Protocol Id in Nlri.
- *
- * @return Protocol Id in Nlri
- * @throws BgpParseException while getting protocol ID
- */
- ProtocolType getProtocolId() throws BgpParseException;
-
- /**
- * Returns Route distinguisher in Nlri.
- *
- * @return Route distinguisher in Nlri
- */
- RouteDistinguisher getRouteDistinguisher();
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpLinkLsNlri.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpLinkLsNlri.java
deleted file mode 100644
index 3924a13b..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpLinkLsNlri.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol;
-
-import java.util.List;
-
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors;
-
-/**
- * Abstraction of an entity providing BGP-LS Link NLRI.
- */
-public interface BgpLinkLsNlri extends BgpLSNlri {
- /**
- * Returns local node descriptors.
- *
- * @return local node descriptors
- */
- NodeDescriptors localNodeDescriptors();
-
- /**
- * Returns remote node descriptors.
- *
- * @return remote node descriptors
- */
- NodeDescriptors remoteNodeDescriptors();
-
- /**
- * Returns link descriptors.
- *
- * @return link descriptors
- */
- List<BgpValueType> linkDescriptors();
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpMessage.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpMessage.java
deleted file mode 100644
index f1e1b96f..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpMessage.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpHeader;
-
-/**
- * Abstraction of an entity providing BGP Messages.
- */
-public interface BgpMessage extends Writeable {
- /**
- * Returns BGP Header of BGP Message.
- *
- * @return BGP Header of BGP Message
- */
- BgpHeader getHeader();
-
- /**
- * Returns version of BGP Message.
- *
- * @return version of BGP Message
- */
- BgpVersion getVersion();
-
- /**
- * Returns BGP Type of BGP Message.
- *
- * @return BGP Type of BGP Message
- */
- BgpType getType();
-
- @Override
- void writeTo(ChannelBuffer cb) throws BgpParseException;
-
- /**
- * Builder interface with get and set functions to build BGP Message.
- */
- interface Builder {
- /**
- * Builds BGP Message.
- *
- * @return BGP Message
- * @throws BgpParseException while building bgp message
- */
- BgpMessage build() throws BgpParseException;
-
- /**
- * Sets BgpHeader and return its builder.
- *
- * @param bgpMsgHeader BGP Message Header
- * @return builder by setting BGP message header
- */
- Builder setHeader(BgpHeader bgpMsgHeader);
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpMessageReader.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpMessageReader.java
deleted file mode 100755
index b8318b29..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpMessageReader.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpHeader;
-
-/**
- * Abstraction of an entity providing BGP Message Reader.
- */
-public interface BgpMessageReader<T> {
-
- /**
- * Reads the Objects in the BGP Message and Returns BGP Message.
- *
- * @param cb Channel Buffer
- * @param bgpHeader BGP message header
- * @return BGP Message
- * @throws BgpParseException while parsing BGP message.
- */
- T readFrom(ChannelBuffer cb, BgpHeader bgpHeader) throws BgpParseException;
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpMessageWriter.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpMessageWriter.java
deleted file mode 100644
index bb75b5ea..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpMessageWriter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-
-/**
- * Abstraction of an entity providing BGP Message Writer.
- */
-public interface BgpMessageWriter<T> {
-
- /**
- * Writes the Objects of the BGP Message into Channel Buffer.
- *
- * @param cb Channel Buffer
- * @param message BGP Message
- * @throws BgpParseException
- * While writing message
- */
- void write(ChannelBuffer cb, T message) throws BgpParseException;
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpNodeLSNlri.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpNodeLSNlri.java
deleted file mode 100644
index 13ef5cc5..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpNodeLSNlri.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol;
-
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
-
-/**
- * Abstraction of an entity providing BGP-LS Node NLRI.
- */
-public interface BgpNodeLSNlri extends BgpLSNlri {
- /**
- * Returns local node descriptors.
- *
- * @return local node descriptors
- */
- BgpNodeLSIdentifier getLocalNodeDescriptors();
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpNotificationMsg.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpNotificationMsg.java
deleted file mode 100644
index e3361aa7..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpNotificationMsg.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol;
-
-import org.onosproject.bgpio.exceptions.BgpParseException;
-
-/**
- * Abstraction of an entity providing BGP notification message.
- */
-public interface BgpNotificationMsg extends BgpMessage {
- /**
- * Returns errorCode in notification message.
- *
- * @return errorCode in notification message
- */
- byte getErrorCode();
-
- /**
- * Returns error subCode in notification message.
- *
- * @return error subCode in notification message
- */
- byte getErrorSubCode();
-
- /**
- * Returns error data in notification message.
- *
- * @return error data in notification message
- */
- byte[] getData();
-
- /**
- * Builder interface with get and set functions to build notification message.
- */
- public interface Builder extends BgpMessage.Builder {
-
- @Override
- BgpNotificationMsg build() throws BgpParseException;
-
- /**
- * Sets errorCode in notification message and return its builder.
- *
- * @param errorCode in notification message
- * @return builder by setting errorCode in notification message
- */
- Builder setErrorCode(byte errorCode);
-
- /**
- * Sets error subCode in notification message and return its builder.
- *
- * @param errorSubCode in notification message
- * @return builder by setting error subCode in notification message
- */
- Builder setErrorSubCode(byte errorSubCode);
-
- /**
- * Sets error data in notification message and return its builder.
- *
- * @param data in notification message
- * @return builder by setting Data in notification message
- */
- Builder setData(byte[] data);
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpOpenMsg.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpOpenMsg.java
deleted file mode 100644
index 94ec2235..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpOpenMsg.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol;
-
-import java.util.LinkedList;
-
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpHeader;
-import org.onosproject.bgpio.types.BgpValueType;
-
-/**
- * Abstraction of an entity providing BGP Open Message.
- */
-public interface BgpOpenMsg extends BgpMessage {
-
- @Override
- BgpHeader getHeader();
-
- @Override
- BgpVersion getVersion();
-
- @Override
- BgpType getType();
-
- /**
- * Returns hold time of Open Message.
- *
- * @return hold time of Open Message
- */
- short getHoldTime();
-
- /**
- * Returns AS Number of Open Message.
- *
- * @return AS Number of Open Message
- */
- short getAsNumber();
-
- /**
- * Returns BGP Identifier of Open Message.
- *
- * @return BGP Identifier of Open Message
- */
- int getBgpId();
-
- /**
- * Returns capabilities of Open Message.
- *
- * @return capabilities of Open Message
- */
- LinkedList<BgpValueType> getCapabilityTlv();
-
- /**
- * Builder interface with get and set functions to build Open message.
- */
- interface Builder extends BgpMessage.Builder {
-
- @Override
- BgpOpenMsg build() throws BgpParseException;
-
- /**
- * Sets hold time in Open Message and return its builder.
- *
- * @param holdtime hold timer value in open message
- * @return builder by setting hold time
- */
- Builder setHoldTime(short holdtime);
-
- /**
- * Sets AS number in Open Message and return its builder.
- *
- * @param asNumber as number in open message
- * @return builder by setting asNumber
- */
- Builder setAsNumber(short asNumber);
-
- /**
- * Sets BGP Identifier in Open Message and return its builder.
- *
- * @param bgpId BGP Identifier in open message
- * @return builder by setting BGP Identifier
- */
- Builder setBgpId(int bgpId);
-
- /**
- * Sets capabilities in Open Message and return its builder.
- *
- * @param capabilityTlv capabilities in open message
- * @return builder by setting capabilities
- */
- Builder setCapabilityTlv(LinkedList<BgpValueType> capabilityTlv);
-
- /**
- * Sets isLargeAsCapabilityTlvSet and return its builder.
- *
- * @param isLargeAsCapabilitySet
- * boolean value to know whether large AS capability is set or not
- * @return builder by setting capabilities
- */
- Builder setLargeAsCapabilityTlv(boolean isLargeAsCapabilitySet);
-
- /**
- * Sets isLsCapabilityTlvSet and return its builder.
- *
- * @param isLsCapabilitySet
- * boolean value to know whether LS capability is set or not
- * @return builder by setting capabilities
- */
- Builder setLsCapabilityTlv(boolean isLsCapabilitySet);
-
- @Override
- Builder setHeader(BgpHeader bgpMsgHeader);
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpPrefixLSNlri.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpPrefixLSNlri.java
deleted file mode 100644
index 54bcdba3..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpPrefixLSNlri.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol;
-
-import java.util.List;
-
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors;
-
-/**
- * Abstraction of an entity providing BGP-LS Prefix NLRI.
- */
-public interface BgpPrefixLSNlri extends BgpLSNlri {
- /**
- * Returns local node descriptors.
- *
- * @return local node descriptors
- */
- NodeDescriptors getLocalNodeDescriptors();
-
- /**
- * Returns list of Prefix descriptor.
- *
- * @return list of Prefix descriptor
- */
- List<BgpValueType> getPrefixdescriptor();
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpType.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpType.java
deleted file mode 100755
index b90721d5..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpType.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol;
-
-/**
- * Enum to Provide the Different types of BGP messages.
- */
-public enum BgpType {
-
- NONE(0), OPEN(1), UPDATE(2), NOTIFICATION(3), KEEP_ALIVE(4);
-
- int value;
-
- /**
- * Assign value with the value val as the types of BGP message.
- *
- * @param val type of BGP message
- */
- BgpType(int val) {
- value = val;
- }
-
- /**
- * Returns value as type of BGP message.
- *
- * @return value type of BGP message
- */
- public byte getType() {
- return (byte) value;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpUpdateMsg.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpUpdateMsg.java
deleted file mode 100644
index d79a4236..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpUpdateMsg.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol;
-
-import java.util.List;
-
-import org.onlab.packet.IpPrefix;
-import org.onosproject.bgpio.protocol.ver4.BgpPathAttributes;
-
-/**
- * Abstraction of an entity providing BGP Update Message.
- */
-public interface BgpUpdateMsg extends BgpMessage {
- /**
- * Returns path attributes in BGP Update Message.
- *
- * @return path attributes in BGP Update Message
- */
- BgpPathAttributes bgpPathAttributes();
-
- /**
- * Returns withdrawn Routes.
- *
- * @return withdrawn Routes
- */
- List<IpPrefix> withdrawnRoutes();
-
- /**
- * Returns NLRI list of prefix.
- *
- * @return NLRI list of prefix
- */
- List<IpPrefix> nlri();
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpVersion.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpVersion.java
deleted file mode 100755
index b1f037f4..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BgpVersion.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol;
-
-/**
- * Enum to provide BGP Message Version.
- */
-public enum BgpVersion {
-
- BGP_4(4);
-
- public final int packetVersion;
-
- /**
- * Assign BGP PacketVersion with specified packetVersion.
- *
- * @param packetVersion version of BGP
- */
- BgpVersion(final int packetVersion) {
- this.packetVersion = packetVersion;
- }
-
- /**
- * Returns Packet version of BGP Message.
- *
- * @return packetVersion
- */
- public int getPacketVersion() {
- return packetVersion;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/IGPRouterID.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/IGPRouterID.java
deleted file mode 100644
index 0e531d64..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/IGPRouterID.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol;
-
-/**
- * Provides Abstraction of IGP RouterID TLV.
- */
-public interface IGPRouterID {
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/NlriType.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/NlriType.java
deleted file mode 100644
index 535ba71d..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/NlriType.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol;
-
-/**
- * Enum to Provide the Different BGP-LS NLRI types.
- */
-public enum NlriType {
-
- NODE(1), LINK(2), PREFIX_IPV4(3), PREFIX_IPV6(4);
-
- int value;
-
- /**
- * Assign value with the value as the LINK-STATE NLRI type.
- *
- * @param value LINK-STATE NLRI type
- */
- NlriType(int value) {
- this.value = value;
- }
-
- /**
- * Returns value as LINK-STATE NLRI type.
- *
- * @return value LINK-STATE NLRI type
- */
- public byte getType() {
- return (byte) value;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/Writeable.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/Writeable.java
deleted file mode 100755
index 1c6f7fc2..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/Writeable.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-
-/**
- * Abstraction of an entity providing functionality to write byte streams of
- * Messages to channel buffer.
- */
-public interface Writeable {
-
- /**
- * Writes byte streams of messages to channel buffer.
- *
- * @param cb channelBuffer
- * @throws BgpParseException when error occurs while writing BGP message to channel buffer
- */
- void writeTo(ChannelBuffer cb) throws BgpParseException;
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
deleted file mode 100644
index a4360fdf..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol.linkstate;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.IPv4AddressTlv;
-import org.onosproject.bgpio.types.IPv6AddressTlv;
-import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv;
-import org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId;
-import org.onosproject.bgpio.util.Constants;
-import org.onosproject.bgpio.util.UnSupportedAttribute;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
-
-/**
- * Implementation of local node descriptors, remote node descriptors and link descriptors.
- */
-public class BgpLinkLSIdentifier implements Comparable<Object> {
- private static final Logger log = LoggerFactory.getLogger(BgpLinkLSIdentifier.class);
- public static final short IPV4_INTERFACE_ADDRESS_TYPE = 259;
- public static final short IPV4_NEIGHBOR_ADDRESS_TYPE = 260;
- public static final short IPV6_INTERFACE_ADDRESS_TYPE = 261;
- public static final short IPV6_NEIGHBOR_ADDRESS_TYPE = 262;
-
- private NodeDescriptors localNodeDescriptors;
- private NodeDescriptors remoteNodeDescriptors;
- private List<BgpValueType> linkDescriptor;
-
- /**
- * Initialize fields.
- */
- public BgpLinkLSIdentifier() {
- this.localNodeDescriptors = null;
- this.remoteNodeDescriptors = null;
- this.linkDescriptor = null;
- }
-
- /**
- * Constructors to initialize parameters.
- *
- * @param localNodeDescriptors local node descriptors
- * @param remoteNodeDescriptors remote node descriptors
- * @param linkDescriptor link descriptors
- */
- public BgpLinkLSIdentifier(NodeDescriptors localNodeDescriptors, NodeDescriptors remoteNodeDescriptors,
- LinkedList<BgpValueType> linkDescriptor) {
- this.localNodeDescriptors = Preconditions.checkNotNull(localNodeDescriptors);
- this.remoteNodeDescriptors = Preconditions.checkNotNull(remoteNodeDescriptors);
- this.linkDescriptor = Preconditions.checkNotNull(linkDescriptor);
- }
-
- /**
- * Reads channel buffer and parses link identifier.
- *
- * @param cb ChannelBuffer
- * @param protocolId in linkstate nlri
- * @return object of BGPLinkLSIdentifier
- * @throws BgpParseException while parsing link identifier
- */
- public static BgpLinkLSIdentifier parseLinkIdendifier(ChannelBuffer cb, byte protocolId) throws BgpParseException {
- //Parse local node descriptor
- NodeDescriptors localNodeDescriptors = new NodeDescriptors();
- localNodeDescriptors = parseNodeDescriptors(cb, NodeDescriptors.LOCAL_NODE_DES_TYPE, protocolId);
-
- //Parse remote node descriptor
- NodeDescriptors remoteNodeDescriptors = new NodeDescriptors();
- remoteNodeDescriptors = parseNodeDescriptors(cb, NodeDescriptors.REMOTE_NODE_DES_TYPE, protocolId);
-
- //Parse link descriptor
- LinkedList<BgpValueType> linkDescriptor = new LinkedList<>();
- linkDescriptor = parseLinkDescriptors(cb);
- return new BgpLinkLSIdentifier(localNodeDescriptors, remoteNodeDescriptors, linkDescriptor);
- }
-
- /**
- * Parses Local/Remote node descriptors.
- *
- * @param cb ChannelBuffer
- * @param desType descriptor type
- * @param protocolId protocol identifier
- * @return object of NodeDescriptors
- * @throws BgpParseException while parsing Local/Remote node descriptors
- */
- public static NodeDescriptors parseNodeDescriptors(ChannelBuffer cb, short desType, byte protocolId)
- throws BgpParseException {
- log.debug("parse Node descriptors");
- ChannelBuffer tempBuf = cb.copy();
- short type = cb.readShort();
- short length = cb.readShort();
- if (cb.readableBytes() < length) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
- tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN_AS_SHORT));
- }
- NodeDescriptors nodeIdentifier = new NodeDescriptors();
- ChannelBuffer tempCb = cb.readBytes(length);
-
- if (type == desType) {
- nodeIdentifier = NodeDescriptors.read(tempCb, length, desType, protocolId);
- } else {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
- }
- return nodeIdentifier;
- }
-
- /**
- * Parses link descriptors.
- *
- * @param cb ChannelBuffer
- * @return list of link descriptors
- * @throws BgpParseException while parsing link descriptors
- */
- public static LinkedList<BgpValueType> parseLinkDescriptors(ChannelBuffer cb) throws BgpParseException {
- LinkedList<BgpValueType> linkDescriptor = new LinkedList<>();
- BgpValueType tlv = null;
- int count = 0;
-
- while (cb.readableBytes() > 0) {
- ChannelBuffer tempBuf = cb.copy();
- short type = cb.readShort();
- short length = cb.readShort();
- if (cb.readableBytes() < length) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
- tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN_AS_SHORT));
- }
- ChannelBuffer tempCb = cb.readBytes(length);
- switch (type) {
- case LinkLocalRemoteIdentifiersTlv.TYPE:
- tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb);
- break;
- case IPV4_INTERFACE_ADDRESS_TYPE:
- tlv = IPv4AddressTlv.read(tempCb, IPV4_INTERFACE_ADDRESS_TYPE);
- break;
- case IPV4_NEIGHBOR_ADDRESS_TYPE:
- tlv = IPv4AddressTlv.read(tempCb, IPV4_NEIGHBOR_ADDRESS_TYPE);
- break;
- case IPV6_INTERFACE_ADDRESS_TYPE:
- tlv = IPv6AddressTlv.read(tempCb, IPV6_INTERFACE_ADDRESS_TYPE);
- break;
- case IPV6_NEIGHBOR_ADDRESS_TYPE:
- tlv = IPv6AddressTlv.read(tempCb, IPV6_NEIGHBOR_ADDRESS_TYPE);
- break;
- case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY:
- tlv = BgpAttrNodeMultiTopologyId.read(tempCb);
- count = count++;
- //MultiTopologyId TLV cannot repeat more than once
- if (count > 1) {
- //length + 4 implies data contains type, length and value
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length
- + Constants.TYPE_AND_LEN_AS_SHORT));
- }
- break;
- default:
- UnSupportedAttribute.skipBytes(tempCb, length);
- }
- linkDescriptor.add(tlv);
- }
- return linkDescriptor;
- }
-
- /**
- * Returns local node descriptors.
- *
- * @return local node descriptors
- */
- public NodeDescriptors localNodeDescriptors() {
- return this.localNodeDescriptors;
- }
-
- /**
- * Returns remote node descriptors.
- *
- * @return remote node descriptors
- */
- public NodeDescriptors remoteNodeDescriptors() {
- return this.remoteNodeDescriptors;
- }
-
- /**
- * Returns link descriptors.
- *
- * @return link descriptors
- */
- public List<BgpValueType> linkDescriptors() {
- return this.linkDescriptor;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(linkDescriptor, localNodeDescriptors, remoteNodeDescriptors);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof BgpLinkLSIdentifier) {
- int countObjSubTlv = 0;
- int countOtherSubTlv = 0;
- boolean isCommonSubTlv = true;
- BgpLinkLSIdentifier other = (BgpLinkLSIdentifier) obj;
- Iterator<BgpValueType> objListIterator = other.linkDescriptor.iterator();
- countOtherSubTlv = other.linkDescriptor.size();
- countObjSubTlv = linkDescriptor.size();
- if (countObjSubTlv != countOtherSubTlv) {
- return false;
- } else {
- while (objListIterator.hasNext() && isCommonSubTlv) {
- BgpValueType subTlv = objListIterator.next();
- if (linkDescriptor.contains(subTlv) && other.linkDescriptor.contains(subTlv)) {
- isCommonSubTlv = Objects.equals(linkDescriptor.get(linkDescriptor.indexOf(subTlv)),
- other.linkDescriptor.get(other.linkDescriptor.indexOf(subTlv)));
- } else {
- isCommonSubTlv = false;
- }
- }
- return isCommonSubTlv && Objects.equals(this.localNodeDescriptors, other.localNodeDescriptors)
- && Objects.equals(this.remoteNodeDescriptors, other.remoteNodeDescriptors);
- }
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("localNodeDescriptors", localNodeDescriptors)
- .add("remoteNodeDescriptors", remoteNodeDescriptors)
- .add("linkDescriptor", linkDescriptor)
- .toString();
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- int result = this.localNodeDescriptors.compareTo(((BgpLinkLSIdentifier) o).localNodeDescriptors);
- if (result != 0) {
- return result;
- } else if (this.remoteNodeDescriptors.compareTo(((BgpLinkLSIdentifier) o).remoteNodeDescriptors) != 0) {
- return this.remoteNodeDescriptors.compareTo(((BgpLinkLSIdentifier) o).remoteNodeDescriptors);
- } else {
- int countOtherSubTlv = ((BgpLinkLSIdentifier) o).linkDescriptor.size();
- int countObjSubTlv = linkDescriptor.size();
- if (countOtherSubTlv != countObjSubTlv) {
- if (countOtherSubTlv > countObjSubTlv) {
- return 1;
- } else {
- return -1;
- }
- }
- ListIterator<BgpValueType> listIterator = linkDescriptor.listIterator();
- ListIterator<BgpValueType> listIteratorOther = ((BgpLinkLSIdentifier) o).linkDescriptor.listIterator();
- while (listIterator.hasNext()) {
- BgpValueType tlv = listIterator.next();
- if (linkDescriptor.contains(tlv) && ((BgpLinkLSIdentifier) o).linkDescriptor.contains(tlv)) {
- int res = linkDescriptor.get(linkDescriptor.indexOf(tlv)).compareTo(
- ((BgpLinkLSIdentifier) o).linkDescriptor.get(((BgpLinkLSIdentifier) o).linkDescriptor
- .indexOf(tlv)));
- if (res != 0) {
- return res;
- }
- } else {
- return 1;
- }
- }
- }
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLsNlriVer4.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLsNlriVer4.java
deleted file mode 100755
index 01d369e4..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLsNlriVer4.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol.linkstate;
-
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpLinkLsNlri;
-import org.onosproject.bgpio.protocol.NlriType;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.RouteDistinguisher;
-import org.onosproject.bgpio.util.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implementation of Link LS NLRI.
- */
-public class BgpLinkLsNlriVer4 implements BgpLinkLsNlri {
-
- /*
- * REFERENCE : draft-ietf-idr-ls-distribution-11
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+
- | Protocol-ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Identifier |
- | (64 bits) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Local Node Descriptors (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Remote Node Descriptors (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Link Descriptors (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Figure : The Link NLRI format
- */
- private static final Logger log = LoggerFactory.getLogger(BgpLinkLsNlriVer4.class);
- public static final int LINK_NLRITYPE = 2;
-
- private BgpLinkLSIdentifier linkLSIdentifier;
- private byte protocolId;
- private long identifier;
- private RouteDistinguisher routeDistinguisher;
- private boolean isVpn;
-
- /**
- * Initialize fields.
- */
- public BgpLinkLsNlriVer4() {
- this.protocolId = 0;
- this.identifier = 0;
- this.linkLSIdentifier = null;
- this.routeDistinguisher = null;
- this.isVpn = false;
- }
-
- /**
- * Constructor to initialize parameters for BGP LinkLSNlri.
- *
- * @param protocolId protocol Id
- * @param identifier field in BGP LinkLSNlri
- * @param linkLSIdentifier link LS identifier
- * @param routeDistinguisher route distinguisher from message
- * @param isVpn vpn info availability in message
- */
- public BgpLinkLsNlriVer4(byte protocolId, long identifier, BgpLinkLSIdentifier linkLSIdentifier,
- RouteDistinguisher routeDistinguisher, boolean isVpn) {
- this.protocolId = protocolId;
- this.identifier = identifier;
- this.linkLSIdentifier = linkLSIdentifier;
- this.routeDistinguisher = routeDistinguisher;
- this.isVpn = isVpn;
- }
-
- /**
- * Reads from channelBuffer and parses Link LS Nlri.
- *
- * @param cb ChannelBuffer
- * @param afi Address Family Identifier
- * @param safi Subsequent Address Family Identifier
- * @return object of this class
- * @throws BgpParseException while parsing Link LS NLRI
- */
- public static BgpLinkLsNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BgpParseException {
- boolean isVpn = false;
- RouteDistinguisher routeDistinguisher = null;
- if ((afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
- routeDistinguisher = new RouteDistinguisher();
- routeDistinguisher = RouteDistinguisher.read(cb);
- isVpn = true;
- } else {
- isVpn = false;
- }
- byte protocolId = cb.readByte();
- long identifier = cb.readLong();
-
- BgpLinkLSIdentifier linkLSIdentifier = new BgpLinkLSIdentifier();
- linkLSIdentifier = BgpLinkLSIdentifier.parseLinkIdendifier(cb, protocolId);
- return new BgpLinkLsNlriVer4(protocolId, identifier, linkLSIdentifier, routeDistinguisher, isVpn);
- }
-
- @Override
- public NlriType getNlriType() {
- return NlriType.LINK;
- }
-
- @Override
- public long getIdentifier() {
- return this.identifier;
- }
-
- /**
- * Set the link LS identifier.
- *
- * @param linkLSIdentifier link LS identifier to set
- */
- public void setLinkLSIdentifier(BgpLinkLSIdentifier linkLSIdentifier) {
- this.linkLSIdentifier = linkLSIdentifier;
- }
-
- @Override
- public ProtocolType getProtocolId() throws BgpParseException {
- switch (protocolId) {
- case Constants.ISIS_LEVELONE:
- return ProtocolType.ISIS_LEVEL_ONE;
- case Constants.ISIS_LEVELTWO:
- return ProtocolType.ISIS_LEVEL_TWO;
- case Constants.OSPFV2:
- return ProtocolType.OSPF_V2;
- case Constants.DIRECT:
- return ProtocolType.DIRECT;
- case Constants.STATIC_CONFIGURATION:
- return ProtocolType.STATIC_CONFIGURATION;
- case Constants.OSPFV3:
- return ProtocolType.OSPF_V3;
- default:
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
- }
- }
-
- @Override
- public NodeDescriptors localNodeDescriptors() {
- return this.linkLSIdentifier.localNodeDescriptors();
- }
-
- @Override
- public NodeDescriptors remoteNodeDescriptors() {
- return this.linkLSIdentifier.remoteNodeDescriptors();
- }
-
- /**
- * Returns whether VPN is present or not.
- *
- * @return whether VPN is present or not
- */
- public boolean isVpnPresent() {
- return this.isVpn;
- }
-
- @Override
- public RouteDistinguisher getRouteDistinguisher() {
- return this.routeDistinguisher;
- }
-
- /**
- * Returns link identifier.
- *
- * @return link identifier
- */
- public BgpLinkLSIdentifier getLinkIdentifier() {
- return this.linkLSIdentifier;
- }
-
- @Override
- public List<BgpValueType> linkDescriptors() {
- return this.linkLSIdentifier.linkDescriptors();
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("protocolId", protocolId)
- .add("identifier", identifier)
- .add("RouteDistinguisher ", routeDistinguisher)
- .add("linkLSIdentifier", linkLSIdentifier)
- .toString();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSIdentifier.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSIdentifier.java
deleted file mode 100644
index 6c2c96d9..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSIdentifier.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol.linkstate;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.util.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implementation of Node Identifier which includes local node descriptor/remote node descriptors.
- */
-public class BgpNodeLSIdentifier implements Comparable<Object> {
-
- private static final Logger log = LoggerFactory.getLogger(BgpNodeLSIdentifier.class);
- private NodeDescriptors nodeDescriptors;
-
- /**
- * Resets fields.
- */
- public BgpNodeLSIdentifier() {
- this.nodeDescriptors = null;
- }
-
- /**
- * Constructor to initialize fields.
- *
- * @param nodeDescriptors local/remote node descriptor
- */
- public BgpNodeLSIdentifier(NodeDescriptors nodeDescriptors) {
- this.nodeDescriptors = nodeDescriptors;
- }
-
- /**
- * Parse local node descriptors.
- *
- * @param cb ChannelBuffer
- * @param protocolId protocol identifier
- * @return object of this BGPNodeLSIdentifier
- * @throws BgpParseException while parsing local node descriptors
- */
- public static BgpNodeLSIdentifier parseLocalNodeDescriptors(ChannelBuffer cb, byte protocolId)
- throws BgpParseException {
- log.debug("parse Local node descriptor");
- ChannelBuffer tempBuf = cb.copy();
- short type = cb.readShort();
- short length = cb.readShort();
- if (cb.readableBytes() < length) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
- tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN));
- }
- NodeDescriptors nodeDescriptors = new NodeDescriptors();
- ChannelBuffer tempCb = cb.readBytes(length);
-
- if (type == NodeDescriptors.LOCAL_NODE_DES_TYPE) {
- nodeDescriptors = NodeDescriptors.read(tempCb, length, type, protocolId);
- } else {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
- }
- return new BgpNodeLSIdentifier(nodeDescriptors);
- }
-
- /**
- * Returns node descriptors.
- *
- * @return node descriptors
- */
- public NodeDescriptors getNodedescriptors() {
- return this.nodeDescriptors;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof BgpNodeLSIdentifier) {
- BgpNodeLSIdentifier other = (BgpNodeLSIdentifier) obj;
- return Objects.equals(nodeDescriptors, other.nodeDescriptors);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(nodeDescriptors);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("NodeDescriptors", nodeDescriptors)
- .toString();
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- return this.nodeDescriptors.compareTo(((BgpNodeLSIdentifier) o).nodeDescriptors);
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
deleted file mode 100644
index b27096cf..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol.linkstate;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpNodeLSNlri;
-import org.onosproject.bgpio.protocol.NlriType;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.RouteDistinguisher;
-import org.onosproject.bgpio.util.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implementation of Node LS NLRI.
- */
-public class BgpNodeLSNlriVer4 implements BgpNodeLSNlri {
-
- /*
- *REFERENCE : draft-ietf-idr-ls-distribution-11
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+
- | Protocol-ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Identifier |
- | (64 bits) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Local Node Descriptors (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Figure : The Node NLRI format
- */
-
- protected static final Logger log = LoggerFactory.getLogger(BgpNodeLSNlriVer4.class);
-
- public static final int NODE_NLRITYPE = 1;
- public static final int IDENTIFIER_LENGTH = 16;
- private long identifier;
- private byte protocolId;
- private BgpNodeLSIdentifier localNodeDescriptors;
- private RouteDistinguisher routeDistinguisher;
- private boolean isVpn;
-
- /**
- * Enum to provide PROTOCOLTYPE.
- */
- public enum ProtocolType {
- ISIS_LEVEL_ONE(1), ISIS_LEVEL_TWO(2), OSPF_V2(3), DIRECT(4), STATIC_CONFIGURATION(5), OSPF_V3(6);
- int value;
-
- /**
- * Assign val with the value as the protocol type.
- *
- * @param val protocol type
- */
- ProtocolType(int val) {
- value = val;
- }
-
- /**
- * Returns value of protocol type.
- *
- * @return protocol type
- */
- public byte getType() {
- return (byte) value;
- }
- }
-
- /**
- * Reset fields.
- */
- public BgpNodeLSNlriVer4() {
- this.identifier = 0;
- this.protocolId = 0;
- this.localNodeDescriptors = null;
- this.routeDistinguisher = null;
- this.isVpn = false;
- }
-
- /**
- * Constructors to initialize its parameters.
- *
- * @param identifier of LinkState Nlri
- * @param protocolId of LinkState Nlri
- * @param localNodeDescriptors local node descriptors
- * @param isVpn true if VPN info is present
- * @param routeDistinguisher unique for each VPN
- */
- public BgpNodeLSNlriVer4(long identifier, byte protocolId, BgpNodeLSIdentifier localNodeDescriptors, boolean isVpn,
- RouteDistinguisher routeDistinguisher) {
- this.identifier = identifier;
- this.protocolId = protocolId;
- this.localNodeDescriptors = localNodeDescriptors;
- this.routeDistinguisher = routeDistinguisher;
- this.isVpn = isVpn;
- }
-
- /**
- * Reads from channelBuffer and parses Node LS Nlri.
- *
- * @param cb ChannelBuffer
- * @param afi Address Family Identifier
- * @param safi Subsequent Address Family Identifier
- * @return object of this class
- * @throws BgpParseException while parsing node descriptors
- */
- public static BgpNodeLSNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BgpParseException {
- boolean isVpn = false;
- RouteDistinguisher routeDistinguisher = null;
- if ((afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
- routeDistinguisher = new RouteDistinguisher();
- routeDistinguisher = RouteDistinguisher.read(cb);
- isVpn = true;
- } else {
- isVpn = false;
- }
- byte protocolId = cb.readByte();
- long identifier = cb.readLong();
-
- // Parse Local Node Descriptors
- BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier();
- localNodeDescriptors = BgpNodeLSIdentifier.parseLocalNodeDescriptors(cb, protocolId);
- return new BgpNodeLSNlriVer4(identifier, protocolId, localNodeDescriptors, isVpn, routeDistinguisher);
- }
-
- @Override
- public NlriType getNlriType() {
- return NlriType.NODE;
- }
-
- @Override
- public BgpNodeLSIdentifier getLocalNodeDescriptors() {
- return this.localNodeDescriptors;
- }
-
- /**
- * Returns whether VPN is present or not.
- *
- * @return whether VPN is present or not
- */
- public boolean isVpnPresent() {
- return this.isVpn;
- }
-
- @Override
- public RouteDistinguisher getRouteDistinguisher() {
- return this.routeDistinguisher;
- }
-
- @Override
- public long getIdentifier() {
- return this.identifier;
- }
-
- /**
- * Set the node LS identifier.
- *
- * @param localNodeDescriptors node LS identifier to set
- */
- public void setNodeLSIdentifier(BgpNodeLSIdentifier localNodeDescriptors) {
- this.localNodeDescriptors = localNodeDescriptors;
- }
-
- @Override
- public ProtocolType getProtocolId() throws BgpParseException {
- switch (protocolId) {
- case Constants.ISIS_LEVELONE:
- return ProtocolType.ISIS_LEVEL_ONE;
- case Constants.ISIS_LEVELTWO:
- return ProtocolType.ISIS_LEVEL_TWO;
- case Constants.OSPFV2:
- return ProtocolType.OSPF_V2;
- case Constants.DIRECT:
- return ProtocolType.DIRECT;
- case Constants.STATIC_CONFIGURATION:
- return ProtocolType.STATIC_CONFIGURATION;
- case Constants.OSPFV3:
- return ProtocolType.OSPF_V3;
- default:
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("protocolId", protocolId)
- .add("identifier", identifier)
- .add("RouteDistinguisher ", routeDistinguisher)
- .add("localNodeDescriptors", localNodeDescriptors)
- .toString();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixIPv4LSNlriVer4.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixIPv4LSNlriVer4.java
deleted file mode 100644
index 49cb74bd..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixIPv4LSNlriVer4.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol.linkstate;
-
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpPrefixLSNlri;
-import org.onosproject.bgpio.protocol.NlriType;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.RouteDistinguisher;
-import org.onosproject.bgpio.util.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implementation of Prefix IPV4 LS NLRI.
- */
-public class BgpPrefixIPv4LSNlriVer4 implements BgpPrefixLSNlri {
-
- /*
- * REFERENCE : draft-ietf-idr-ls-distribution-11
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+
- | Protocol-ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Identifier |
- | (64 bits) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Local Node Descriptor (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Prefix Descriptors (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Figure : The IPv4/IPv6 Topology Prefix NLRI format
- */
-
- protected static final Logger log = LoggerFactory.getLogger(BgpPrefixIPv4LSNlriVer4.class);
-
- public static final int PREFIX_IPV4_NLRITYPE = 3;
- public static final int IDENTIFIER_LENGTH = 16;
- private long identifier;
- private byte protocolId;
- private RouteDistinguisher routeDistinguisher;
- private boolean isVpn;
- private BgpPrefixLSIdentifier bgpPrefixLSIdentifier;
-
- /**
- * Resets parameters.
- */
- public BgpPrefixIPv4LSNlriVer4() {
- this.identifier = 0;
- this.protocolId = 0;
- this.bgpPrefixLSIdentifier = null;
- this.routeDistinguisher = null;
- this.isVpn = false;
- }
-
- /**
- * Constructor to initialize parameters for BGP PrefixLSNlri.
- *
- * @param identifier field in BGP PrefixLSNlri
- * @param protocolId protocol Id
- * @param bgpPrefixLSIdentifier prefix LS Identifier
- * @param routeDistinguisher RouteDistinguisher
- * @param isVpn vpn availability in message
- */
- public BgpPrefixIPv4LSNlriVer4(long identifier, byte protocolId, BgpPrefixLSIdentifier bgpPrefixLSIdentifier,
- RouteDistinguisher routeDistinguisher, boolean isVpn) {
- this.identifier = identifier;
- this.protocolId = protocolId;
- this.bgpPrefixLSIdentifier = bgpPrefixLSIdentifier;
- this.routeDistinguisher = routeDistinguisher;
- this.isVpn = isVpn;
- }
-
- /**
- * Reads from channelBuffer and parses Prefix LS Nlri.
- *
- * @param cb ChannelBuffer
- * @param afi Address family identifier
- * @param safi Subsequent address family identifier
- * @return object of BGPPrefixIPv4LSNlriVer4
- * @throws BgpParseException while parsing Prefix LS Nlri
- */
- public static BgpPrefixIPv4LSNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BgpParseException {
-
- boolean isVpn = false;
- RouteDistinguisher routeDistinguisher = null;
- if ((afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
- routeDistinguisher = new RouteDistinguisher();
- routeDistinguisher = RouteDistinguisher.read(cb);
- isVpn = true;
- } else {
- isVpn = false;
- }
- byte protocolId = cb.readByte();
- long identifier = cb.readLong();
-
- BgpPrefixLSIdentifier bgpPrefixLSIdentifier = new BgpPrefixLSIdentifier();
- bgpPrefixLSIdentifier = BgpPrefixLSIdentifier.parsePrefixIdendifier(cb, protocolId);
- return new BgpPrefixIPv4LSNlriVer4(identifier, protocolId, bgpPrefixLSIdentifier, routeDistinguisher, isVpn);
- }
-
- @Override
- public NlriType getNlriType() {
- return NlriType.PREFIX_IPV4;
- }
-
- @Override
- public NodeDescriptors getLocalNodeDescriptors() {
- return this.bgpPrefixLSIdentifier.getLocalNodeDescriptors();
- }
-
- @Override
- public long getIdentifier() {
- return this.identifier;
- }
-
- /**
- * Set the prefix LS identifier.
- *
- * @param bgpPrefixLSIdentifier prefix identifier to set
- */
- public void setPrefixLSIdentifier(BgpPrefixLSIdentifier bgpPrefixLSIdentifier) {
- this.bgpPrefixLSIdentifier = bgpPrefixLSIdentifier;
- }
-
- @Override
- public ProtocolType getProtocolId() throws BgpParseException {
- switch (protocolId) {
- case Constants.ISIS_LEVELONE:
- return ProtocolType.ISIS_LEVEL_ONE;
- case Constants.ISIS_LEVELTWO:
- return ProtocolType.ISIS_LEVEL_TWO;
- case Constants.OSPFV2:
- return ProtocolType.OSPF_V2;
- case Constants.DIRECT:
- return ProtocolType.DIRECT;
- case Constants.STATIC_CONFIGURATION:
- return ProtocolType.STATIC_CONFIGURATION;
- case Constants.OSPFV3:
- return ProtocolType.OSPF_V3;
- default:
- throw new BgpParseException("protocol id not valid");
- }
- }
-
- /**
- * Returns whether VPN is present or not.
- *
- * @return whether VPN is present or not
- */
- public boolean isVpnPresent() {
- return this.isVpn;
- }
-
- /**
- * Returns Prefix Identifier.
- *
- * @return Prefix Identifier
- */
- public BgpPrefixLSIdentifier getPrefixIdentifier() {
- return this.bgpPrefixLSIdentifier;
- }
-
- @Override
- public RouteDistinguisher getRouteDistinguisher() {
- return this.routeDistinguisher;
- }
-
- @Override
- public List<BgpValueType> getPrefixdescriptor() {
- return this.bgpPrefixLSIdentifier.getPrefixdescriptor();
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("protocolId", protocolId)
- .add("identifier", identifier)
- .add("RouteDistinguisher ", routeDistinguisher)
- .add("bgpPrefixLSIdentifier", bgpPrefixLSIdentifier)
- .toString();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
deleted file mode 100644
index 22e68917..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol.linkstate;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.IPReachabilityInformationTlv;
-import org.onosproject.bgpio.types.OSPFRouteTypeTlv;
-import org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId;
-import org.onosproject.bgpio.util.UnSupportedAttribute;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Implementation of Local node descriptors and prefix descriptors.
- */
-public class BgpPrefixLSIdentifier implements Comparable<Object> {
-
- protected static final Logger log = LoggerFactory.getLogger(BgpPrefixLSIdentifier.class);
- public static final int TYPE_AND_LEN = 4;
- private NodeDescriptors localNodeDescriptors;
- private List<BgpValueType> prefixDescriptor;
-
- /**
- * Resets parameters.
- */
- public BgpPrefixLSIdentifier() {
- this.localNodeDescriptors = null;
- this.prefixDescriptor = null;
- }
-
- /**
- * Constructor to initialize parameters.
- *
- * @param localNodeDescriptors Local node descriptors
- * @param prefixDescriptor Prefix Descriptors
- */
- public BgpPrefixLSIdentifier(NodeDescriptors localNodeDescriptors, List<BgpValueType> prefixDescriptor) {
- this.localNodeDescriptors = localNodeDescriptors;
- this.prefixDescriptor = prefixDescriptor;
- }
-
- /**
- * Reads the channel buffer and parses Prefix Identifier.
- *
- * @param cb ChannelBuffer
- * @param protocolId protocol ID
- * @return object of this class
- * @throws BgpParseException while parsing Prefix Identifier
- */
- public static BgpPrefixLSIdentifier parsePrefixIdendifier(ChannelBuffer cb, byte protocolId)
- throws BgpParseException {
- //Parse Local Node descriptor
- NodeDescriptors localNodeDescriptors = new NodeDescriptors();
- localNodeDescriptors = parseLocalNodeDescriptors(cb, protocolId);
-
- //Parse Prefix descriptor
- List<BgpValueType> prefixDescriptor = new LinkedList<>();
- prefixDescriptor = parsePrefixDescriptors(cb);
- return new BgpPrefixLSIdentifier(localNodeDescriptors, prefixDescriptor);
- }
-
- /**
- * Parse local node descriptors.
- *
- * @param cb ChannelBuffer
- * @param protocolId protocol identifier
- * @return LocalNodeDescriptors
- * @throws BgpParseException while parsing local node descriptors
- */
- public static NodeDescriptors parseLocalNodeDescriptors(ChannelBuffer cb, byte protocolId)
- throws BgpParseException {
- ChannelBuffer tempBuf = cb.copy();
- short type = cb.readShort();
- short length = cb.readShort();
- if (cb.readableBytes() < length) {
- //length + 4 implies data contains type, length and value
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
- tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
- }
- NodeDescriptors localNodeDescriptors = new NodeDescriptors();
- ChannelBuffer tempCb = cb.readBytes(length);
-
- if (type == NodeDescriptors.LOCAL_NODE_DES_TYPE) {
- localNodeDescriptors = NodeDescriptors.read(tempCb, length, type, protocolId);
- } else {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
- }
- return localNodeDescriptors;
- }
-
- /**
- * Parse list of prefix descriptors.
- *
- * @param cb ChannelBuffer
- * @return list of prefix descriptors
- * @throws BgpParseException while parsing list of prefix descriptors
- */
- public static List<BgpValueType> parsePrefixDescriptors(ChannelBuffer cb) throws BgpParseException {
- LinkedList<BgpValueType> prefixDescriptor = new LinkedList<>();
- BgpValueType tlv = null;
- boolean isIpReachInfo = false;
- ChannelBuffer tempCb;
- int count = 0;
-
- while (cb.readableBytes() > 0) {
- ChannelBuffer tempBuf = cb.copy();
- short type = cb.readShort();
- short length = cb.readShort();
- if (cb.readableBytes() < length) {
- //length + 4 implies data contains type, length and value
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
- tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
- }
- tempCb = cb.readBytes(length);
- switch (type) {
- case OSPFRouteTypeTlv.TYPE:
- tlv = OSPFRouteTypeTlv.read(tempCb);
- break;
- case IPReachabilityInformationTlv.TYPE:
- tlv = IPReachabilityInformationTlv.read(tempCb, length);
- isIpReachInfo = true;
- break;
- case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY:
- tlv = BgpAttrNodeMultiTopologyId.read(tempCb);
- count = count + 1;
- if (count > 1) {
- //length + 4 implies data contains type, length and value
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length + TYPE_AND_LEN));
- }
- break;
- default:
- UnSupportedAttribute.skipBytes(tempCb, length);
- }
- prefixDescriptor.add(tlv);
- }
-
- if (!isIpReachInfo) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
- null);
- }
- return prefixDescriptor;
- }
-
- /**
- * Returns local node descriptors.
- *
- * @return local node descriptors
- */
- public NodeDescriptors getLocalNodeDescriptors() {
- return this.localNodeDescriptors;
- }
-
- /**
- * Returns Prefix descriptors.
- *
- * @return Prefix descriptors
- */
- public List<BgpValueType> getPrefixdescriptor() {
- return this.prefixDescriptor;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(prefixDescriptor.hashCode(), localNodeDescriptors);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpPrefixLSIdentifier) {
- int countObjSubTlv = 0;
- int countOtherSubTlv = 0;
- boolean isCommonSubTlv = true;
- BgpPrefixLSIdentifier other = (BgpPrefixLSIdentifier) obj;
-
- Iterator<BgpValueType> objListIterator = other.prefixDescriptor.iterator();
- countOtherSubTlv = other.prefixDescriptor.size();
- countObjSubTlv = prefixDescriptor.size();
- if (countObjSubTlv != countOtherSubTlv) {
- return false;
- } else {
- while (objListIterator.hasNext() && isCommonSubTlv) {
- BgpValueType subTlv = objListIterator.next();
- if (prefixDescriptor.contains(subTlv) && other.prefixDescriptor.contains(subTlv)) {
- isCommonSubTlv = Objects.equals(prefixDescriptor.get(prefixDescriptor.indexOf(subTlv)),
- other.prefixDescriptor.get(other.prefixDescriptor.indexOf(subTlv)));
- } else {
- isCommonSubTlv = false;
- }
- }
- return isCommonSubTlv && Objects.equals(this.localNodeDescriptors, other.localNodeDescriptors);
- }
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("localNodeDescriptors", localNodeDescriptors)
- .add("prefixDescriptor", prefixDescriptor)
- .toString();
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- int result = this.localNodeDescriptors.compareTo(((BgpPrefixLSIdentifier) o).localNodeDescriptors);
- if (result != 0) {
- return result;
- } else {
- int countOtherSubTlv = ((BgpPrefixLSIdentifier) o).prefixDescriptor.size();
- int countObjSubTlv = prefixDescriptor.size();
- if (countOtherSubTlv != countObjSubTlv) {
- if (countOtherSubTlv > countObjSubTlv) {
- return 1;
- } else {
- return -1;
- }
- }
-
- ListIterator<BgpValueType> listIterator = prefixDescriptor.listIterator();
- ListIterator<BgpValueType> listIteratorOther = ((BgpPrefixLSIdentifier) o).prefixDescriptor.listIterator();
- while (listIterator.hasNext()) {
- BgpValueType tlv = listIterator.next();
- if (prefixDescriptor.contains(tlv) && ((BgpPrefixLSIdentifier) o).prefixDescriptor.contains(tlv)) {
- int res = prefixDescriptor.get(prefixDescriptor.indexOf(tlv)).compareTo(
- ((BgpPrefixLSIdentifier) o).prefixDescriptor
- .get(((BgpPrefixLSIdentifier) o).prefixDescriptor.indexOf(tlv)));
- if (res != 0) {
- return res;
- }
- } else {
- return 1;
- }
- }
- }
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/NodeDescriptors.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/NodeDescriptors.java
deleted file mode 100644
index f91ac260..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/NodeDescriptors.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol.linkstate;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.AreaIDTlv;
-import org.onosproject.bgpio.types.AutonomousSystemTlv;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpLSIdentifierTlv;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.IsIsNonPseudonode;
-import org.onosproject.bgpio.types.IsIsPseudonode;
-import org.onosproject.bgpio.types.OSPFNonPseudonode;
-import org.onosproject.bgpio.types.OSPFPseudonode;
-import org.onosproject.bgpio.util.UnSupportedAttribute;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Local and Remote NodeDescriptors which contains Node Descriptor Sub-TLVs.
- */
-public class NodeDescriptors {
-
- /*
- *Reference :draft-ietf-idr-ls-distribution-11
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Node Descriptor Sub-TLVs (variable) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Figure : Local or Remote Node Descriptors TLV format
- */
-
- private static final Logger log = LoggerFactory.getLogger(NodeDescriptors.class);
-
- public static final short LOCAL_NODE_DES_TYPE = 256;
- public static final short REMOTE_NODE_DES_TYPE = 257;
- public static final short IGP_ROUTERID_TYPE = 515;
- public static final short IS_IS_LEVEL_1_PROTOCOL_ID = 1;
- public static final short IS_IS_LEVEL_2_PROTOCOL_ID = 2;
- public static final short OSPF_V2_PROTOCOL_ID = 3;
- public static final short OSPF_V3_PROTOCOL_ID = 6;
- public static final int TYPE_AND_LEN = 4;
- public static final int ISISNONPSEUDONODE_LEN = 6;
- public static final int ISISPSEUDONODE_LEN = 7;
- public static final int OSPFNONPSEUDONODE_LEN = 4;
- public static final int OSPFPSEUDONODE_LEN = 8;
- private List<BgpValueType> subTlvs;
- private short deslength;
- private short desType;
-
- /**
- * Resets parameters.
- */
- public NodeDescriptors() {
- this.subTlvs = null;
- this.deslength = 0;
- this.desType = 0;
- }
-
- /**
- * Constructor to initialize parameters.
- *
- * @param subTlvs list of subTlvs
- * @param deslength Descriptors length
- * @param desType local node descriptor or remote node descriptor type
- */
- public NodeDescriptors(List<BgpValueType> subTlvs, short deslength, short desType) {
- this.subTlvs = subTlvs;
- this.deslength = deslength;
- this.desType = desType;
- }
-
- /**
- * Returns list of subTlvs.
- *
- * @return subTlvs list of subTlvs
- */
- public List<BgpValueType> getSubTlvs() {
- return subTlvs;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(subTlvs.hashCode());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof NodeDescriptors) {
- int countObjSubTlv = 0;
- int countOtherSubTlv = 0;
- boolean isCommonSubTlv = true;
- NodeDescriptors other = (NodeDescriptors) obj;
- Iterator<BgpValueType> objListIterator = other.subTlvs.iterator();
- countOtherSubTlv = other.subTlvs.size();
- countObjSubTlv = subTlvs.size();
- if (countObjSubTlv != countOtherSubTlv) {
- return false;
- } else {
- while (objListIterator.hasNext() && isCommonSubTlv) {
- BgpValueType subTlv = objListIterator.next();
- if (subTlvs.contains(subTlv) && other.subTlvs.contains(subTlv)) {
- isCommonSubTlv = Objects.equals(subTlvs.get(subTlvs.indexOf(subTlv)),
- other.subTlvs.get(other.subTlvs.indexOf(subTlv)));
- } else {
- isCommonSubTlv = false;
- }
- }
- return isCommonSubTlv;
- }
- }
- return false;
- }
-
- /**
- * Reads node descriptors Sub-TLVs.
- *
- * @param cb ChannelBuffer
- * @param desLength node descriptor length
- * @param desType local node descriptor or remote node descriptor type
- * @param protocolId protocol ID
- * @return object of NodeDescriptors
- * @throws BgpParseException while parsing node descriptors
- */
- public static NodeDescriptors read(ChannelBuffer cb, short desLength, short desType, byte protocolId)
- throws BgpParseException {
- log.debug("Read NodeDescriptor");
- List<BgpValueType> subTlvs = new LinkedList<>();
- BgpValueType tlv = null;
-
- while (cb.readableBytes() > 0) {
- ChannelBuffer tempBuf = cb.copy();
- short type = cb.readShort();
- short length = cb.readShort();
- if (cb.readableBytes() < length) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
- tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
- }
- ChannelBuffer tempCb = cb.readBytes(length);
- switch (type) {
- case AutonomousSystemTlv.TYPE:
- tlv = AutonomousSystemTlv.read(tempCb);
- break;
- case BgpLSIdentifierTlv.TYPE:
- tlv = BgpLSIdentifierTlv.read(tempCb);
- break;
- case AreaIDTlv.TYPE:
- tlv = AreaIDTlv.read(tempCb);
- break;
- case IGP_ROUTERID_TYPE:
- if (protocolId == IS_IS_LEVEL_1_PROTOCOL_ID || protocolId == IS_IS_LEVEL_2_PROTOCOL_ID) {
- if (length == ISISNONPSEUDONODE_LEN) {
- tlv = IsIsNonPseudonode.read(tempCb);
- } else if (length == ISISPSEUDONODE_LEN) {
- tlv = IsIsPseudonode.read(tempCb);
- }
- } else if (protocolId == OSPF_V2_PROTOCOL_ID || protocolId == OSPF_V3_PROTOCOL_ID) {
- if (length == OSPFNONPSEUDONODE_LEN) {
- tlv = OSPFNonPseudonode.read(tempCb);
- } else if (length == OSPFPSEUDONODE_LEN) {
- tlv = OSPFPseudonode.read(tempCb);
- }
- }
- break;
- default:
- UnSupportedAttribute.skipBytes(tempCb, length);
- }
- subTlvs.add(tlv);
- }
- return new NodeDescriptors(subTlvs, desLength, desType);
- }
-
- /**
- * Returns node descriptors length.
- *
- * @return node descriptors length
- */
- public short getLength() {
- return this.deslength;
- }
-
- /**
- * Returns node descriptors type.
- *
- * @return node descriptors type
- */
- public short getType() {
- return this.desType;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("desType", desType)
- .add("deslength", deslength)
- .add("subTlvs", subTlvs)
- .toString();
- }
-
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- ListIterator<BgpValueType> listIterator = subTlvs.listIterator();
- ListIterator<BgpValueType> listIteratorOther = ((NodeDescriptors) o).subTlvs.listIterator();
- int countOtherSubTlv = ((NodeDescriptors) o).subTlvs.size();
- int countObjSubTlv = subTlvs.size();
- if (countOtherSubTlv != countObjSubTlv) {
- if (countOtherSubTlv > countObjSubTlv) {
- return 1;
- } else {
- return -1;
- }
- } else {
- while (listIterator.hasNext()) {
- BgpValueType tlv = listIterator.next();
- log.debug("NodeDescriptor compare subtlv's");
- if (subTlvs.contains(tlv) && ((NodeDescriptors) o).subTlvs.contains(tlv)) {
- int result = subTlvs.get(subTlvs.indexOf(tlv)).compareTo(
- ((NodeDescriptors) o).subTlvs.get(((NodeDescriptors) o).subTlvs.indexOf(tlv)));
- if (result != 0) {
- return result;
- }
- } else {
- return 1;
- }
- }
- }
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.java
deleted file mode 100755
index 9578ccfe..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol.linkstate;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType;
-import org.onosproject.bgpio.types.BgpValueType;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * This Class stores path Attributes, protocol ID and Identifier of LinkState NLRI.
- */
-public class PathAttrNlriDetails {
- private List<BgpValueType> pathAttributes;
- private ProtocolType protocolID;
- private long identifier;
-
- /**
- * Sets path attribute with specified path attribute.
- *
- * @param pathAttributes in update message
- */
- public void setPathAttribute(List<BgpValueType> pathAttributes) {
- this.pathAttributes = pathAttributes;
- }
-
- /**
- * Returns path attributes.
- *
- * @return path attributes
- */
- public List<BgpValueType> pathAttributes() {
- return this.pathAttributes;
- }
-
- /**
- * Sets protocolID with specified protocolID.
- *
- * @param protocolID in linkstate nlri
- */
- public void setProtocolID(ProtocolType protocolID) {
- this.protocolID = protocolID;
- }
-
- /**
- * Returns protocolID.
- *
- * @return protocolID
- */
- public ProtocolType protocolID() {
- return this.protocolID;
- }
-
- /**
- * Sets identifier with specified identifier.
- *
- * @param identifier in linkstate nlri
- */
- public void setIdentifier(long identifier) {
- this.identifier = identifier;
- }
-
- /**
- * Returns Identifier.
- *
- * @return Identifier
- */
- public long identifier() {
- return this.identifier;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(pathAttributes, protocolID, identifier);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof PathAttrNlriDetails) {
- int countObjSubTlv = 0;
- int countOtherSubTlv = 0;
- boolean isCommonSubTlv = true;
- PathAttrNlriDetails other = (PathAttrNlriDetails) obj;
- Iterator<BgpValueType> objListIterator = other.pathAttributes.iterator();
- countOtherSubTlv = other.pathAttributes.size();
- countObjSubTlv = pathAttributes.size();
- if (countObjSubTlv != countOtherSubTlv) {
- return false;
- } else {
- while (objListIterator.hasNext() && isCommonSubTlv) {
- BgpValueType subTlv = objListIterator.next();
- if (pathAttributes.contains(subTlv) && other.pathAttributes.contains(subTlv)) {
- isCommonSubTlv = Objects.equals(pathAttributes.get(pathAttributes.indexOf(subTlv)),
- other.pathAttributes.get(other.pathAttributes.indexOf(subTlv)));
- } else {
- isCommonSubTlv = false;
- }
- }
- return isCommonSubTlv && Objects.equals(identifier, other.identifier)
- && Objects.equals(protocolID, other.protocolID);
- }
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("identifier", identifier)
- .add("protocolID", protocolID)
- .add("pathAttributes", pathAttributes)
- .toString();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetailsLocalRib.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetailsLocalRib.java
deleted file mode 100755
index 4172ae46..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetailsLocalRib.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.onosproject.bgpio.protocol.linkstate;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-import com.google.common.base.MoreObjects;
-
-/**
- * This Class stores path Attributes, protocol ID and Identifier of LinkState nlri.
- */
-public class PathAttrNlriDetailsLocalRib {
-
- private IpAddress localRibIpAddress;
- private long localRibAsNum;
- private int localRibIdentifier;
- private boolean isLocalRibIbgpSession;
- private PathAttrNlriDetails localRibNlridetails;
-
- /**
- * Constructor to initialize parameter.
- *
- * @param localRibIpAddress peer ip address
- * @param localRibIdentifier peer identifier
- * @param localRibAsNum peer As number
- * @param isLocalRibIbgpSession flag to indicate is Ibgp session
- * @param localRibNlridetails Nlri details
- *
- */
- public PathAttrNlriDetailsLocalRib(IpAddress localRibIpAddress, int localRibIdentifier, long localRibAsNum,
- boolean isLocalRibIbgpSession, PathAttrNlriDetails localRibNlridetails) {
- this.localRibIpAddress = localRibIpAddress;
- this.localRibAsNum = localRibAsNum;
- this.localRibIdentifier = localRibIdentifier;
- this.isLocalRibIbgpSession = isLocalRibIbgpSession;
- this.localRibNlridetails = localRibNlridetails;
- }
-
- /**
- * Gets the Ipaddress updated in local rib.
- *
- * @return localRibIpAddress ip address
- */
- public IpAddress localRibIpAddress() {
- return localRibIpAddress;
- }
-
- /**
- * Gets the autonomous system number updated in local rib.
- *
- * @return localRibAsNum autonomous system number
- */
- public long localRibAsNum() {
- return localRibAsNum;
- }
-
- /**
- * Gets the indetifier updated in local rib.
- *
- * @return localRibIdentifier identifier
- */
- public int localRibIdentifier() {
- return localRibIdentifier;
- }
-
- /**
- * Gets the bgp session type updated in local rib.
- *
- * @return isLocalRibIbgpSession session type
- */
- public boolean isLocalRibIbgpSession() {
- return isLocalRibIbgpSession;
- }
-
- /**
- * Returns local RIB Nlri details.
- *
- * @return localRibNlridetails Nlri details in local rib
- */
- public PathAttrNlriDetails localRibNlridetails() {
- return this.localRibNlridetails;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(localRibIpAddress, localRibIdentifier, localRibAsNum, isLocalRibIbgpSession,
- localRibNlridetails.hashCode());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PathAttrNlriDetailsLocalRib) {
- PathAttrNlriDetailsLocalRib other = (PathAttrNlriDetailsLocalRib) obj;
- return Objects.equals(localRibIpAddress, other.localRibIpAddress)
- && Objects.equals(localRibIdentifier, other.localRibIdentifier)
- && Objects.equals(localRibAsNum, other.localRibAsNum)
- && Objects.equals(isLocalRibIbgpSession, other.isLocalRibIbgpSession)
- && Objects.equals(localRibNlridetails, other.localRibNlridetails);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).add("peerIdentifier", localRibIdentifier)
- .add("localRibpathAttributes", localRibNlridetails.pathAttributes()).toString();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/package-info.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/package-info.java
deleted file mode 100755
index 87ba60f0..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * BGP Protocol specific link state details.
- */
-package org.onosproject.bgpio.protocol.linkstate;
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/package-info.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/package-info.java
deleted file mode 100755
index 723b31b1..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * BGP Protocol specific components.
- */
-package org.onosproject.bgpio.protocol;
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpFactoryVer4.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpFactoryVer4.java
deleted file mode 100755
index c57832b6..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpFactoryVer4.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol.ver4;
-
-import org.onosproject.bgpio.protocol.BgpFactory;
-import org.onosproject.bgpio.protocol.BgpKeepaliveMsg;
-import org.onosproject.bgpio.protocol.BgpMessage;
-import org.onosproject.bgpio.protocol.BgpMessageReader;
-import org.onosproject.bgpio.protocol.BgpNotificationMsg;
-import org.onosproject.bgpio.protocol.BgpOpenMsg;
-import org.onosproject.bgpio.protocol.BgpVersion;
-
-/**
- * Provides BGP Factory and returns builder classes for all objects and messages.
- */
-public class BgpFactoryVer4 implements BgpFactory {
-
- public static final BgpFactoryVer4 INSTANCE = new BgpFactoryVer4();
-
- @Override
- public BgpOpenMsg.Builder openMessageBuilder() {
- return new BgpOpenMsgVer4.Builder();
- }
-
- @Override
- public BgpKeepaliveMsg.Builder keepaliveMessageBuilder() {
- return new BgpKeepaliveMsgVer4.Builder();
- }
-
- @Override
- public BgpNotificationMsg.Builder notificationMessageBuilder() {
- return new BgpNotificationMsgVer4.Builder();
- }
-
- @Override
- public BgpMessageReader<BgpMessage> getReader() {
- return BgpMessageVer4.READER;
- }
-
- @Override
- public BgpVersion getVersion() {
- return BgpVersion.BGP_4;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
deleted file mode 100644
index 2c141586..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol.ver4;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpKeepaliveMsg;
-import org.onosproject.bgpio.protocol.BgpMessageReader;
-import org.onosproject.bgpio.protocol.BgpMessageWriter;
-import org.onosproject.bgpio.types.BgpHeader;
-import org.onosproject.bgpio.protocol.BgpType;
-import org.onosproject.bgpio.protocol.BgpVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides BGP keep alive message.
- */
-public class BgpKeepaliveMsgVer4 implements BgpKeepaliveMsg {
-
- /*
- <Keepalive Message>::= <Common Header>
- A KEEPALIVE message consists of only the message header and has a
- length of 19 octets.
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- + +
- | |
- + +
- | Marker |
- + +
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Length | Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- REFERENCE : RFC 4271
- */
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpKeepaliveMsgVer4.class);
-
- private BgpHeader bgpMsgHeader;
- public static final byte PACKET_VERSION = 4;
- public static final int PACKET_MINIMUM_LENGTH = 19;
- public static final int MARKER_LENGTH = 16;
- public static final BgpType MSG_TYPE = BgpType.KEEP_ALIVE;
- public static byte[] marker = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff};
-
- public static final BgpKeepaliveMsgVer4.Reader READER = new Reader();
-
- /**
- * Reader class for reading BGP keepalive message from channel buffer.
- */
- static class Reader implements BgpMessageReader<BgpKeepaliveMsg> {
-
- @Override
- public BgpKeepaliveMsg readFrom(ChannelBuffer cb, BgpHeader bgpHeader)
- throws BgpParseException {
-
- /* bgpHeader is not required in case of keepalive message and
- Header is already read and no other fields except header in keepalive message.*/
- return new BgpKeepaliveMsgVer4();
- }
- }
-
- /**
- * Default constructor.
- */
- public BgpKeepaliveMsgVer4() {
- }
-
- /**
- * Builder class for BGP keepalive message.
- */
- static class Builder implements BgpKeepaliveMsg.Builder {
- BgpHeader bgpMsgHeader;
-
- @Override
- public Builder setHeader(BgpHeader bgpMsgHeader) {
- this.bgpMsgHeader = bgpMsgHeader;
- return this;
- }
-
- @Override
- public BgpKeepaliveMsg build() {
- return new BgpKeepaliveMsgVer4();
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer cb) {
- WRITER.write(cb, this);
- }
-
- static final Writer WRITER = new Writer();
-
- /**
- * Writer class for writing the BGP keepalive message to channel buffer.
- */
- static class Writer implements BgpMessageWriter<BgpKeepaliveMsgVer4> {
-
- @Override
- public void write(ChannelBuffer cb, BgpKeepaliveMsgVer4 message) {
-
- // write marker
- cb.writeBytes(marker, 0, MARKER_LENGTH);
-
- // write length of header
- cb.writeShort(PACKET_MINIMUM_LENGTH);
-
- // write the type of message
- cb.writeByte(MSG_TYPE.getType());
- }
- }
-
- @Override
- public BgpVersion getVersion() {
- return BgpVersion.BGP_4;
- }
-
- @Override
- public BgpType getType() {
- return MSG_TYPE;
- }
-
- @Override
- public BgpHeader getHeader() {
- return this.bgpMsgHeader;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).toString();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpMessageVer4.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpMessageVer4.java
deleted file mode 100755
index 1c05dae4..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpMessageVer4.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.protocol.ver4;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpFactories;
-import org.onosproject.bgpio.protocol.BgpMessage;
-import org.onosproject.bgpio.protocol.BgpMessageReader;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpHeader;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Provides BGP messages.
- */
-public abstract class BgpMessageVer4 {
-
- protected static final Logger log = LoggerFactory.getLogger(BgpFactories.class);
-
- static final byte OPEN_MSG_TYPE = 0x1;
- static final byte KEEPALIVE_MSG_TYPE = 0x4;
- static final byte UPDATE_MSG_TYPE = 0x2;
- static final byte NOTIFICATION_MSG_TYPE = 0x3;
- static final int MINIMUM_COMMON_HEADER_LENGTH = 19;
- static final int HEADER_AND_MSG_LEN = 18;
- static final int MAXIMUM_PACKET_LENGTH = 4096;
-
- public static final BgpMessageVer4.Reader READER = new Reader();
-
- /**
- * Reader class for reading BGP messages from channel buffer.
- *
- */
- static class Reader implements BgpMessageReader<BgpMessage> {
- @Override
- public BgpMessage readFrom(ChannelBuffer cb, BgpHeader bgpHeader)
- throws BgpParseException {
-
- if (cb.readableBytes() < MINIMUM_COMMON_HEADER_LENGTH) {
- log.error("Packet should have minimum length.");
- Validation.validateLen(BgpErrorType.MESSAGE_HEADER_ERROR, BgpErrorType.BAD_MESSAGE_LENGTH,
- cb.readableBytes());
- }
- if (cb.readableBytes() > MAXIMUM_PACKET_LENGTH) {
- log.error("Packet length should not exceed {}.", MAXIMUM_PACKET_LENGTH);
- Validation.validateLen(BgpErrorType.MESSAGE_HEADER_ERROR, BgpErrorType.BAD_MESSAGE_LENGTH,
- cb.readableBytes());
- }
- try {
- // fixed value property version == 4
- byte[] marker = new byte[BgpHeader.MARKER_LENGTH];
- cb.readBytes(marker, 0, BgpHeader.MARKER_LENGTH);
- bgpHeader.setMarker(marker);
- for (int i = 0; i < BgpHeader.MARKER_LENGTH; i++) {
- if (marker[i] != (byte) 0xff) {
- throw new BgpParseException(BgpErrorType.MESSAGE_HEADER_ERROR,
- BgpErrorType.CONNECTION_NOT_SYNCHRONIZED, null);
- }
- }
- short length = cb.readShort();
- if (length > cb.readableBytes() + HEADER_AND_MSG_LEN) {
- Validation.validateLen(BgpErrorType.MESSAGE_HEADER_ERROR,
- BgpErrorType.BAD_MESSAGE_LENGTH, length);
- }
- bgpHeader.setLength(length);
- byte type = cb.readByte();
- bgpHeader.setType(type);
- log.debug("Reading update message of type " + type);
-
- int len = length - MINIMUM_COMMON_HEADER_LENGTH;
- switch (type) {
- case OPEN_MSG_TYPE:
- log.debug("OPEN MESSAGE is received");
- return BgpOpenMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
- case KEEPALIVE_MSG_TYPE:
- log.debug("KEEPALIVE MESSAGE is received");
- return BgpKeepaliveMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
- case UPDATE_MSG_TYPE:
- log.debug("UPDATE MESSAGE is received");
- return BgpUpdateMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
- case NOTIFICATION_MSG_TYPE:
- log.debug("NOTIFICATION MESSAGE is received");
- return BgpNotificationMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
- default:
- Validation.validateType(BgpErrorType.MESSAGE_HEADER_ERROR, BgpErrorType.BAD_MESSAGE_TYPE, type);
- return null;
- }
- } catch (IndexOutOfBoundsException e) {
- throw new BgpParseException(BgpErrorType.MESSAGE_HEADER_ERROR,
- BgpErrorType.BAD_MESSAGE_LENGTH, null);
- }
- }
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
deleted file mode 100644
index 7243e21a..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol.ver4;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpMessageReader;
-import org.onosproject.bgpio.protocol.BgpMessageWriter;
-import org.onosproject.bgpio.protocol.BgpNotificationMsg;
-import org.onosproject.bgpio.protocol.BgpType;
-import org.onosproject.bgpio.protocol.BgpVersion;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * A NOTIFICATION message is sent when an error condition is detected. The BGP connection is closed immediately after it
- * is sent.
- */
-class BgpNotificationMsgVer4 implements BgpNotificationMsg {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Error code | Error subcode | Data (variable) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- REFERENCE : RFC 4271
- */
-
- private static final Logger log = LoggerFactory.getLogger(BgpNotificationMsgVer4.class);
-
- static final byte PACKET_VERSION = 4;
- //BGPHeader(19) + Error code(1) + Error subcode(1)
- static final int TOTAL_MESSAGE_MIN_LENGTH = 21;
- static final int PACKET_MINIMUM_LENGTH = 2;
- static final BgpType MSG_TYPE = BgpType.NOTIFICATION;
- static final byte DEFAULT_ERRORSUBCODE = 0;
- static final byte[] MARKER = {(byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff };
- static final byte MESSAGE_TYPE = 3;
- static final BgpHeader DEFAULT_MESSAGE_HEADER = new BgpHeader(MARKER, BgpHeader.DEFAULT_HEADER_LENGTH,
- MESSAGE_TYPE);
-
- private byte errorCode;
- private byte errorSubCode;
- private byte[] data;
- private BgpHeader bgpHeader;
- public static final BgpNotificationMsgVer4.Reader READER = new Reader();
-
- /**
- * Initialize fields.
- */
- public BgpNotificationMsgVer4() {
- this.bgpHeader = null;
- this.data = null;
- this.errorCode = 0;
- this.errorSubCode = 0;
- }
-
- /**
- * Constructor to initialize parameters.
- *
- * @param bgpHeader BGP Header in notification message
- * @param errorCode error code
- * @param errorSubCode error subcode
- * @param data field
- */
- public BgpNotificationMsgVer4(BgpHeader bgpHeader, byte errorCode, byte errorSubCode, byte[] data) {
- this.bgpHeader = bgpHeader;
- this.data = data;
- this.errorCode = errorCode;
- this.errorSubCode = errorSubCode;
- }
-
- /**
- * Reader reads BGP Notification Message from the channel buffer.
- */
- static class Reader implements BgpMessageReader<BgpNotificationMsg> {
- @Override
- public BgpNotificationMsg readFrom(ChannelBuffer cb, BgpHeader bgpHeader) throws BgpParseException {
- byte errorCode;
- byte errorSubCode;
- if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
- throw new BgpParseException("Not enough readable bytes");
- }
- errorCode = cb.readByte();
- errorSubCode = cb.readByte();
- //Message Length = 21 + Data Length
- int dataLength = bgpHeader.getLength() - TOTAL_MESSAGE_MIN_LENGTH;
- byte[] data = new byte[dataLength];
- cb.readBytes(data, 0, dataLength);
- return new BgpNotificationMsgVer4(bgpHeader, errorCode, errorSubCode, data);
- }
- }
-
- /**
- * Builder class for BGP notification message.
- */
- static class Builder implements BgpNotificationMsg.Builder {
- private byte errorCode;
- private byte errorSubCode;
- private byte[] data;
- private BgpHeader bgpHeader;
- private boolean isErrorCodeSet = false;
- private boolean isErrorSubCodeSet = false;
- private boolean isBGPHeaderSet = false;
-
- @Override
- public BgpNotificationMsg build() throws BgpParseException {
- BgpHeader bgpHeader = this.isBGPHeaderSet ? this.bgpHeader : DEFAULT_MESSAGE_HEADER;
- if (!this.isErrorCodeSet) {
- throw new BgpParseException("Error code must be present");
- }
-
- byte errorSubCode = this.isErrorSubCodeSet ? this.errorSubCode : DEFAULT_ERRORSUBCODE;
- return new BgpNotificationMsgVer4(bgpHeader, this.errorCode, errorSubCode, this.data);
- }
-
- @Override
- public Builder setErrorCode(byte errorCode) {
- this.errorCode = errorCode;
- this.isErrorCodeSet = true;
- return this;
- }
-
- @Override
- public Builder setErrorSubCode(byte errorSubCode) {
- this.errorSubCode = errorSubCode;
- this.isErrorSubCodeSet = true;
- return this;
- }
-
- @Override
- public Builder setData(byte[] data) {
- if (data != null) {
- this.data = data;
- }
- return this;
- }
-
- @Override
- public Builder setHeader(BgpHeader bgpMsgHeader) {
- this.bgpHeader = bgpMsgHeader;
- return this;
- }
- }
-
- @Override
- public BgpVersion getVersion() {
- return BgpVersion.BGP_4;
- }
-
- @Override
- public BgpType getType() {
- return BgpType.NOTIFICATION;
- }
-
- @Override
- public void writeTo(ChannelBuffer cb) throws BgpParseException {
- WRITER.write(cb, this);
- }
-
- static final Writer WRITER = new Writer();
-
- /**
- * Writer writes BGP notification message to channel buffer.
- */
- static class Writer implements BgpMessageWriter<BgpNotificationMsgVer4> {
- @Override
- public void write(ChannelBuffer cb, BgpNotificationMsgVer4 message) throws BgpParseException {
- int msgStartIndex = cb.writerIndex();
- int headerLenIndex = message.bgpHeader.write(cb);
- if (headerLenIndex <= 0) {
- throw new BgpParseException(BgpErrorType.MESSAGE_HEADER_ERROR, (byte) 0, null);
- }
- cb.writeByte(message.errorCode);
- cb.writeByte(message.errorSubCode);
- if (message.data != null) {
- cb.writeBytes(message.data);
- }
-
- //Update message length field in notification message
- int length = cb.writerIndex() - msgStartIndex;
- cb.setShort(headerLenIndex, (short) length);
- message.bgpHeader.setLength((short) length);
- }
- }
-
- @Override
- public byte getErrorCode() {
- return this.errorCode;
- }
-
- /**
- * Sets errorcode with specified errorcode.
- *
- * @param errorCode field
- */
- public void setErrorCode(byte errorCode) {
- this.errorCode = errorCode;
- }
-
- @Override
- public byte getErrorSubCode() {
- return this.errorSubCode;
- }
-
- /**
- * Sets error subcode with specified errorSubCode.
- *
- * @param errorSubCode field
- */
- public void setErrorSubCode(byte errorSubCode) {
- this.errorSubCode = errorSubCode;
- }
-
- @Override
- public byte[] getData() {
- return this.data;
- }
-
- /**
- * Sets error data with specified data.
- *
- * @param data field
- */
- public void setData(byte[] data) {
- this.data = data;
- }
-
- @Override
- public BgpHeader getHeader() {
- return this.bgpHeader;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("bgpHeader", bgpHeader)
- .add("data", data)
- .add("errorCode", errorCode)
- .add("errorSubCode", errorSubCode)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
deleted file mode 100644
index 359eec25..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol.ver4;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpMessageReader;
-import org.onosproject.bgpio.protocol.BgpMessageWriter;
-import org.onosproject.bgpio.protocol.BgpOpenMsg;
-import org.onosproject.bgpio.protocol.BgpType;
-import org.onosproject.bgpio.protocol.BgpVersion;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpHeader;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv;
-import org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides BGP open message.
- */
-public class BgpOpenMsgVer4 implements BgpOpenMsg {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+
- | Version |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | My Autonomous System |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Hold Time |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | BGP Identifier |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Opt Parm Len |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Optional Parameters (variable) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- OPEN Message Format
- REFERENCE : RFC 4271
- */
-
- protected static final Logger log = LoggerFactory.getLogger(BgpOpenMsgVer4.class);
-
- public static final byte PACKET_VERSION = 4;
- public static final int OPEN_MSG_MINIMUM_LENGTH = 10;
- public static final int MSG_HEADER_LENGTH = 19;
- public static final int MARKER_LENGTH = 16;
- public static final int DEFAULT_HOLD_TIME = 120;
- public static final short AS_TRANS = 23456;
- public static final int OPT_PARA_TYPE_CAPABILITY = 2;
- public static final BgpType MSG_TYPE = BgpType.OPEN;
- public static final short AFI = 16388;
- public static final byte SAFI = 71;
- public static final byte RES = 0;
- public static final int FOUR_OCTET_AS_NUM_CAPA_TYPE = 65;
- public static final byte[] MARKER = new byte[]{(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff};
- public static final BgpHeader DEFAULT_OPEN_HEADER = new BgpHeader(MARKER,
- (short) OPEN_MSG_MINIMUM_LENGTH, (byte) 0X01);
- private BgpHeader bgpMsgHeader;
- private byte version;
- private short asNumber;
- private short holdTime;
- private int bgpId;
- private boolean isLargeAsCapabilitySet;
- private LinkedList<BgpValueType> capabilityTlv;
-
- public static final BgpOpenMsgVer4.Reader READER = new Reader();
-
- /**
- * reset variables.
- */
- public BgpOpenMsgVer4() {
- this.bgpMsgHeader = null;
- this.version = 0;
- this.holdTime = 0;
- this.asNumber = 0;
- this.bgpId = 0;
- this.capabilityTlv = null;
- }
-
- /**
- * Constructor to initialize all variables of BGP Open message.
- *
- * @param bgpMsgHeader BGP Header in open message
- * @param version BGP version in open message
- * @param holdTime hold time in open message
- * @param asNumber AS number in open message
- * @param bgpId BGP identifier in open message
- * @param capabilityTlv capabilities in open message
- */
- public BgpOpenMsgVer4(BgpHeader bgpMsgHeader, byte version, short asNumber, short holdTime,
- int bgpId, LinkedList<BgpValueType> capabilityTlv) {
- this.bgpMsgHeader = bgpMsgHeader;
- this.version = version;
- this.asNumber = asNumber;
- this.holdTime = holdTime;
- this.bgpId = bgpId;
- this.capabilityTlv = capabilityTlv;
- }
-
- @Override
- public BgpHeader getHeader() {
- return this.bgpMsgHeader;
- }
-
- @Override
- public BgpVersion getVersion() {
- return BgpVersion.BGP_4;
- }
-
- @Override
- public BgpType getType() {
- return MSG_TYPE;
- }
-
- @Override
- public short getHoldTime() {
- return this.holdTime;
- }
-
- @Override
- public short getAsNumber() {
- return this.asNumber;
- }
-
- @Override
- public int getBgpId() {
- return this.bgpId;
- }
-
- @Override
- public LinkedList<BgpValueType> getCapabilityTlv() {
- return this.capabilityTlv;
- }
-
- /**
- * Reader class for reading BGP open message from channel buffer.
- */
- public static class Reader implements BgpMessageReader<BgpOpenMsg> {
-
- @Override
- public BgpOpenMsg readFrom(ChannelBuffer cb, BgpHeader bgpHeader) throws BgpParseException {
-
- byte version;
- short holdTime;
- short asNumber;
- int bgpId;
- byte optParaLen = 0;
- byte optParaType;
- byte capParaLen = 0;
- LinkedList<BgpValueType> capabilityTlv = new LinkedList<>();
-
- if (cb.readableBytes() < OPEN_MSG_MINIMUM_LENGTH) {
- log.error("[readFrom] Invalid length: Packet size is less than the minimum length ");
- Validation.validateLen(BgpErrorType.OPEN_MESSAGE_ERROR, BgpErrorType.BAD_MESSAGE_LENGTH,
- cb.readableBytes());
- }
-
- // Read version
- version = cb.readByte();
- if (version != PACKET_VERSION) {
- log.error("[readFrom] Invalid version: " + version);
- throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR,
- BgpErrorType.UNSUPPORTED_VERSION_NUMBER, null);
- }
-
- // Read AS number
- asNumber = cb.readShort();
-
- // Read Hold timer
- holdTime = cb.readShort();
-
- // Read BGP Identifier
- bgpId = cb.readInt();
-
- // Read optional parameter length
- optParaLen = cb.readByte();
-
- // Read Capabilities if optional parameter length is greater than 0
- if (optParaLen != 0) {
- // Read optional parameter type
- optParaType = cb.readByte();
-
- // Read optional parameter length
- capParaLen = cb.readByte();
-
- if (cb.readableBytes() < capParaLen) {
- throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR, (byte) 0, null);
- }
-
- ChannelBuffer capaCb = cb.readBytes(capParaLen);
-
- // Parse capabilities only if optional parameter type is 2
- if ((optParaType == OPT_PARA_TYPE_CAPABILITY) && (capParaLen != 0)) {
- capabilityTlv = parseCapabilityTlv(capaCb);
- } else {
- throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR,
- BgpErrorType.UNSUPPORTED_OPTIONAL_PARAMETER, null);
- }
- }
- return new BgpOpenMsgVer4(bgpHeader, version, asNumber, holdTime, bgpId, capabilityTlv);
- }
- }
-
- /**
- * Parsing capabilities.
- *
- * @param cb of type channel buffer
- * @return capabilityTlv of open message
- * @throws BgpParseException while parsing capabilities
- */
- protected static LinkedList<BgpValueType> parseCapabilityTlv(ChannelBuffer cb) throws BgpParseException {
-
- LinkedList<BgpValueType> capabilityTlv = new LinkedList<>();
-
- while (cb.readableBytes() > 0) {
- BgpValueType tlv;
- short type = cb.readByte();
- short length = cb.readByte();
-
- switch (type) {
- case FourOctetAsNumCapabilityTlv.TYPE:
- log.debug("FourOctetAsNumCapabilityTlv");
- if (FourOctetAsNumCapabilityTlv.LENGTH != length) {
- throw new BgpParseException("Invalid length received for FourOctetAsNumCapabilityTlv.");
- }
- if (length > cb.readableBytes()) {
- throw new BgpParseException("Four octet as num tlv length"
- + " is more than readableBytes.");
- }
- int as4Num = cb.readInt();
- tlv = new FourOctetAsNumCapabilityTlv(as4Num);
- break;
- case MultiProtocolExtnCapabilityTlv.TYPE:
- log.debug("MultiProtocolExtnCapabilityTlv");
- if (MultiProtocolExtnCapabilityTlv.LENGTH != length) {
- throw new BgpParseException("Invalid length received for MultiProtocolExtnCapabilityTlv.");
- }
- if (length > cb.readableBytes()) {
- throw new BgpParseException("BGP LS tlv length is more than readableBytes.");
- }
- short afi = cb.readShort();
- byte res = cb.readByte();
- byte safi = cb.readByte();
- tlv = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
- break;
- default:
- log.debug("Warning: Unsupported TLV: " + type);
- cb.skipBytes(length);
- continue;
- }
- capabilityTlv.add(tlv);
- }
- return capabilityTlv;
- }
-
- /**
- * Builder class for BGP open message.
- */
- static class Builder implements BgpOpenMsg.Builder {
-
- private boolean isHeaderSet = false;
- private BgpHeader bgpMsgHeader;
- private boolean isHoldTimeSet = false;
- private short holdTime;
- private boolean isAsNumSet = false;
- private short asNumber;
- private boolean isBgpIdSet = false;
- private int bgpId;
- private boolean isLargeAsCapabilityTlvSet = false;
- private boolean isLsCapabilityTlvSet = false;
-
- LinkedList<BgpValueType> capabilityTlv = new LinkedList<>();
-
- @Override
- public BgpOpenMsg build() throws BgpParseException {
- BgpHeader bgpMsgHeader = this.isHeaderSet ? this.bgpMsgHeader : DEFAULT_OPEN_HEADER;
- short holdTime = this.isHoldTimeSet ? this.holdTime : DEFAULT_HOLD_TIME;
-
- if (!this.isAsNumSet) {
- throw new BgpParseException("BGP AS number is not set (mandatory)");
- }
-
- if (!this.isBgpIdSet) {
- throw new BgpParseException("BGPID is not set (mandatory)");
- }
-
- if (this.isLargeAsCapabilityTlvSet) {
- BgpValueType tlv;
- int value = this.asNumber;
- tlv = new FourOctetAsNumCapabilityTlv(value);
- this.capabilityTlv.add(tlv);
- }
-
- if (this.isLsCapabilityTlvSet) {
- BgpValueType tlv;
- tlv = new MultiProtocolExtnCapabilityTlv(AFI, RES, SAFI);
- this.capabilityTlv.add(tlv);
- }
-
- return new BgpOpenMsgVer4(bgpMsgHeader, PACKET_VERSION, this.asNumber, holdTime, this.bgpId,
- this.capabilityTlv);
- }
-
- @Override
- public Builder setHeader(BgpHeader bgpMsgHeader) {
- this.bgpMsgHeader = bgpMsgHeader;
- return this;
- }
-
- @Override
- public Builder setHoldTime(short holdTime) {
- this.holdTime = holdTime;
- this.isHoldTimeSet = true;
- return this;
- }
-
- @Override
- public Builder setAsNumber(short asNumber) {
- this.asNumber = asNumber;
- this.isAsNumSet = true;
- return this;
- }
-
- @Override
- public Builder setBgpId(int bgpId) {
- this.bgpId = bgpId;
- this.isBgpIdSet = true;
- return this;
- }
-
- @Override
- public Builder setCapabilityTlv(LinkedList<BgpValueType> capabilityTlv) {
- this.capabilityTlv = capabilityTlv;
- return this;
- }
-
- @Override
- public Builder setLargeAsCapabilityTlv(boolean isLargeAsCapabilitySet) {
- this.isLargeAsCapabilityTlvSet = isLargeAsCapabilitySet;
- return this;
- }
-
- @Override
- public Builder setLsCapabilityTlv(boolean isLsCapabilitySet) {
- this.isLsCapabilityTlvSet = isLsCapabilitySet;
- return this;
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer cb) {
- try {
- WRITER.write(cb, this);
- } catch (BgpParseException e) {
- log.debug("[writeTo] Error: " + e.toString());
- }
- }
-
- public static final Writer WRITER = new Writer();
-
- /**
- * Writer class for writing BGP open message to channel buffer.
- */
- public static class Writer implements BgpMessageWriter<BgpOpenMsgVer4> {
-
- @Override
- public void write(ChannelBuffer cb, BgpOpenMsgVer4 message) throws BgpParseException {
-
- int optParaLen = 0;
- int as4num = 0;
-
- int startIndex = cb.writerIndex();
-
- // write common header and get msg length index
- int msgLenIndex = message.bgpMsgHeader.write(cb);
-
- if (msgLenIndex <= 0) {
- throw new BgpParseException("Unable to write message header.");
- }
-
- // write version in 1-octet
- cb.writeByte(message.version);
-
- // get as4num if LS Capability is set
- if (message.isLargeAsCapabilitySet) {
- LinkedList<BgpValueType> capabilityTlv = message
- .getCapabilityTlv();
- ListIterator<BgpValueType> listIterator = capabilityTlv
- .listIterator();
-
- while (listIterator.hasNext()) {
- BgpValueType tlv = listIterator.next();
- if (tlv.getType() == FOUR_OCTET_AS_NUM_CAPA_TYPE) {
- as4num = ((FourOctetAsNumCapabilityTlv) tlv).getInt();
- break;
- }
- }
- }
-
- if ((message.isLargeAsCapabilitySet) && (as4num > 65535)) {
- // write As number as AS_TRANS
- cb.writeShort(AS_TRANS);
- } else {
- // write AS number in next 2-octet
- cb.writeShort(message.asNumber);
- }
-
- // write HoldTime in next 2-octet
- cb.writeShort(message.holdTime);
-
- // write BGP Identifier in next 4-octet
- cb.writeInt(message.bgpId);
-
- // store the index of Optional parameter length
- int optParaLenIndex = cb.writerIndex();
-
- // set optional parameter length as 0
- cb.writeByte(0);
-
- // Pack capability TLV
- optParaLen = message.packCapabilityTlv(cb, message);
-
- if (optParaLen != 0) {
- // Update optional parameter length
- cb.setByte(optParaLenIndex, (byte) (optParaLen + 2)); //+2 for optional parameter type.
- }
-
- // write OPEN Object Length
- int length = cb.writerIndex() - startIndex;
- cb.setShort(msgLenIndex, (short) length);
- message.bgpMsgHeader.setLength((short) length);
- }
- }
-
- /**
- * returns length of capability tlvs.
- *
- * @param cb of type channel buffer
- * @param message of type BGPOpenMsgVer4
- * @return capParaLen of open message
- */
- protected int packCapabilityTlv(ChannelBuffer cb, BgpOpenMsgVer4 message) {
- int startIndex = cb.writerIndex();
- int capParaLen = 0;
- int capParaLenIndex = 0;
-
- LinkedList<BgpValueType> capabilityTlv = message.capabilityTlv;
- ListIterator<BgpValueType> listIterator = capabilityTlv.listIterator();
-
- if (listIterator.hasNext()) {
- // Set optional parameter type as 2
- cb.writeByte(OPT_PARA_TYPE_CAPABILITY);
-
- // Store the index of capability parameter length and update length at the end
- capParaLenIndex = cb.writerIndex();
-
- // Set capability parameter length as 0
- cb.writeByte(0);
-
- // Update the startIndex to know the length of capability tlv
- startIndex = cb.writerIndex();
- }
-
- while (listIterator.hasNext()) {
- BgpValueType tlv = listIterator.next();
- if (tlv == null) {
- log.debug("Warning: tlv is null from CapabilityTlv list");
- continue;
- }
- tlv.write(cb);
- }
-
- capParaLen = cb.writerIndex() - startIndex;
-
- if (capParaLen != 0) {
- // Update capability parameter length
- cb.setByte(capParaLenIndex, (byte) capParaLen);
- }
- return capParaLen;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("bgpMsgHeader", bgpMsgHeader)
- .add("version", version)
- .add("holdTime", holdTime)
- .add("asNumber", asNumber)
- .add("bgpId", bgpId)
- .add("capabilityTlv", capabilityTlv)
- .toString();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
deleted file mode 100644
index 13e52ca2..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol.ver4;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.As4Path;
-import org.onosproject.bgpio.types.AsPath;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.LocalPref;
-import org.onosproject.bgpio.types.Med;
-import org.onosproject.bgpio.types.NextHop;
-import org.onosproject.bgpio.types.Origin;
-import org.onosproject.bgpio.types.MpReachNlri;
-import org.onosproject.bgpio.types.MpUnReachNlri;
-import org.onosproject.bgpio.util.UnSupportedAttribute;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Implementation of BGP Path Attribute.
- */
-public class BgpPathAttributes {
-
- /* Path attribute:
- <attribute type, attribute length, attribute value>
-
- 0 1
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Attr. Flags |Attr. Type Code|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- REFERENCE : RFC 4271
- */
- protected static final Logger log = LoggerFactory.getLogger(BgpPathAttributes.class);
-
- public static final int LINK_STATE_ATTRIBUTE_TYPE = 50;
- public static final int MPREACHNLRI_TYPE = 14;
- public static final int MPUNREACHNLRI_TYPE = 15;
-
- private final List<BgpValueType> pathAttribute;
-
- /**
- * Initialize parameter.
- */
- public BgpPathAttributes() {
- this.pathAttribute = null;
- }
-
- /**
- * Constructor to initialize parameters for BGP path attributes.
- *
- * @param pathAttribute list of path attributes
- */
- public BgpPathAttributes(List<BgpValueType> pathAttribute) {
- this.pathAttribute = pathAttribute;
- }
-
- /**
- * Returns list of path attributes.
- *
- * @return list of path attributes
- */
- public List<BgpValueType> pathAttributes() {
- return this.pathAttribute;
- }
-
- /**
- * Reads from channelBuffer and parses BGP path attributes.
- *
- * @param cb channelBuffer
- * @return object of BgpPathAttributes
- * @throws BgpParseException while parsing BGP path attributes
- */
- public static BgpPathAttributes read(ChannelBuffer cb)
- throws BgpParseException {
-
- BgpValueType pathAttribute = null;
- List<BgpValueType> pathAttributeList = new LinkedList<>();
- boolean isOrigin = false;
- boolean isAsPath = false;
- boolean isNextHop = false;
- boolean isMpReach = false;
- boolean isMpUnReach = false;
- while (cb.readableBytes() > 0) {
- cb.markReaderIndex();
- byte flags = cb.readByte();
- byte typeCode = cb.readByte();
- cb.resetReaderIndex();
- switch (typeCode) {
- case Origin.ORIGIN_TYPE:
- pathAttribute = Origin.read(cb);
- isOrigin = ((Origin) pathAttribute).isOriginSet();
- break;
- case AsPath.ASPATH_TYPE:
- pathAttribute = AsPath.read(cb);
- isAsPath = ((AsPath) pathAttribute).isaspathSet();
- break;
- case As4Path.AS4PATH_TYPE:
- pathAttribute = As4Path.read(cb);
- break;
- case NextHop.NEXTHOP_TYPE:
- pathAttribute = NextHop.read(cb);
- isNextHop = ((NextHop) pathAttribute).isNextHopSet();
- break;
- case Med.MED_TYPE:
- pathAttribute = Med.read(cb);
- break;
- case LocalPref.LOCAL_PREF_TYPE:
- pathAttribute = LocalPref.read(cb);
- break;
- case MpReachNlri.MPREACHNLRI_TYPE:
- pathAttribute = MpReachNlri.read(cb);
- isMpReach = ((MpReachNlri) pathAttribute).isMpReachNlriSet();
- break;
- case MpUnReachNlri.MPUNREACHNLRI_TYPE:
- pathAttribute = MpUnReachNlri.read(cb);
- isMpUnReach = ((MpUnReachNlri) pathAttribute)
- .isMpUnReachNlriSet();
- break;
- case LINK_STATE_ATTRIBUTE_TYPE:
- //TODO: To be merged later
- break;
- default:
- //skip bytes for unsupported attribute types
- UnSupportedAttribute.read(cb);
- }
- pathAttributeList.add(pathAttribute);
- }
-
- checkMandatoryAttr(isOrigin, isAsPath, isNextHop, isMpReach, isMpUnReach);
- //TODO:if mp_reach or mp_unreach not present ignore the packet
- return new BgpPathAttributes(pathAttributeList);
- }
-
- /**
- * Checks mandatory attributes are presents, if not present throws exception.
- *
- * @param isOrigin say whether origin attribute is present
- * @param isAsPath say whether aspath attribute is present
- * @param isNextHop say whether nexthop attribute is present
- * @param isMpReach say whether mpreach attribute is present
- * @param isMpUnReach say whether mpunreach attribute is present
- * @throws BgpParseException if mandatory path attribute is not present
- */
- public static void checkMandatoryAttr(boolean isOrigin, boolean isAsPath,
- boolean isNextHop, boolean isMpReach, boolean isMpUnReach)
- throws BgpParseException {
- // Mandatory attributes validation not required for MP_UNREACH
- if (isMpUnReach) {
- return;
- }
-
- if (!isOrigin) {
- log.debug("Mandatory Attributes not Present");
- Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
- Origin.ORIGIN_TYPE);
- }
- if (!isAsPath) {
- log.debug("Mandatory Attributes not Present");
- Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
- AsPath.ASPATH_TYPE);
- }
- if (!isMpUnReach && !isMpReach && !isNextHop) {
- log.debug("Mandatory Attributes not Present");
- Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
- NextHop.NEXTHOP_TYPE);
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("pathAttribute", pathAttribute)
- .toString();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
deleted file mode 100644
index 4d6af594..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol.ver4;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpMessageReader;
-import org.onosproject.bgpio.protocol.BgpType;
-import org.onosproject.bgpio.protocol.BgpUpdateMsg;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpHeader;
-import org.onosproject.bgpio.util.Validation;
-import org.onosproject.bgpio.protocol.BgpVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * BGP Update Message: UPDATE messages are used to transfer routing information
- * between BGP peers. The information in the UPDATE message is used by core to
- * construct a graph
- */
-public class BgpUpdateMsgVer4 implements BgpUpdateMsg {
-
- /* 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- + +
- | |
- + +
- | Marker |
- + +
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Length | Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Withdrawn Routes Length (2 octets) |
- +-----------------------------------------------------+
- | Withdrawn Routes (variable) |
- +-----------------------------------------------------+
- | Total Path Attribute Length (2 octets) |
- +-----------------------------------------------------+
- | Path Attributes (variable) |
- +-----------------------------------------------------+
- | Network Layer Reachability Information (variable) |
- +-----------------------------------------------------+
- REFERENCE : RFC 4271
- */
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpUpdateMsgVer4.class);
-
- public static final byte PACKET_VERSION = 4;
- //Withdrawn Routes Length(2) + Total Path Attribute Length(2)
- public static final int PACKET_MINIMUM_LENGTH = 4;
- public static final int BYTE_IN_BITS = 8;
- public static final int MIN_LEN_AFTER_WITHDRW_ROUTES = 2;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 19;
- public static final BgpType MSG_TYPE = BgpType.UPDATE;
- public static final BgpUpdateMsgVer4.Reader READER = new Reader();
-
- private List<IpPrefix> withdrawnRoutes;
- private BgpPathAttributes bgpPathAttributes;
- private BgpHeader bgpHeader;
- private List<IpPrefix> nlri;
-
- /**
- * Constructor to initialize parameters for BGP Update message.
- *
- * @param bgpHeader in Update message
- * @param withdrawnRoutes withdrawn routes
- * @param bgpPathAttributes BGP Path attributes
- * @param nlri Network Layer Reachability Information
- */
- public BgpUpdateMsgVer4(BgpHeader bgpHeader, List<IpPrefix> withdrawnRoutes,
- BgpPathAttributes bgpPathAttributes, List<IpPrefix> nlri) {
- this.bgpHeader = bgpHeader;
- this.withdrawnRoutes = withdrawnRoutes;
- this.bgpPathAttributes = bgpPathAttributes;
- this.nlri = nlri;
- }
-
- /**
- * Reader reads BGP Update Message from the channel buffer.
- */
- static class Reader implements BgpMessageReader<BgpUpdateMsg> {
-
- @Override
- public BgpUpdateMsg readFrom(ChannelBuffer cb, BgpHeader bgpHeader)
- throws BgpParseException {
-
- if (cb.readableBytes() != (bgpHeader.getLength() - MINIMUM_COMMON_HEADER_LENGTH)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.BAD_MESSAGE_LENGTH, bgpHeader.getLength());
- }
-
- LinkedList<IpPrefix> withDrwRoutes = new LinkedList<>();
- LinkedList<IpPrefix> nlri = new LinkedList<>();
- BgpPathAttributes bgpPathAttributes = new BgpPathAttributes();
- // Reading Withdrawn Routes Length
- Short withDrwLen = cb.readShort();
-
- if (cb.readableBytes() < withDrwLen) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
- cb.readableBytes());
- }
- ChannelBuffer tempCb = cb.readBytes(withDrwLen);
- if (withDrwLen != 0) {
- // Parsing WithdrawnRoutes
- withDrwRoutes = parseWithdrawnRoutes(tempCb);
- }
- if (cb.readableBytes() < MIN_LEN_AFTER_WITHDRW_ROUTES) {
- log.debug("Bgp Path Attribute len field not present");
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
- }
-
- // Reading Total Path Attribute Length
- short totPathAttrLen = cb.readShort();
- int len = withDrwLen + totPathAttrLen + PACKET_MINIMUM_LENGTH;
- if (len > bgpHeader.getLength()) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
- }
- if (totPathAttrLen != 0) {
- // Parsing BGPPathAttributes
- if (cb.readableBytes() < totPathAttrLen) {
- Validation
- .validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
- cb.readableBytes());
- }
- tempCb = cb.readBytes(totPathAttrLen);
- bgpPathAttributes = BgpPathAttributes.read(tempCb);
- }
- if (cb.readableBytes() > 0) {
- // Parsing NLRI
- nlri = parseNlri(cb);
- }
- return new BgpUpdateMsgVer4(bgpHeader, withDrwRoutes,
- bgpPathAttributes, nlri);
- }
- }
-
- /**
- * Parses NLRI from channel buffer.
- *
- * @param cb channelBuffer
- * @return list of IP Prefix
- * @throws BgpParseException while parsing NLRI
- */
- public static LinkedList<IpPrefix> parseNlri(ChannelBuffer cb)
- throws BgpParseException {
- LinkedList<IpPrefix> nlri = new LinkedList<>();
- while (cb.readableBytes() > 0) {
- int length = cb.readByte();
- IpPrefix ipPrefix;
- if (length == 0) {
- byte[] prefix = new byte[] {0};
- ipPrefix = Validation.bytesToPrefix(prefix, length);
- nlri.add(ipPrefix);
- } else {
- int len = length / BYTE_IN_BITS;
- int reminder = length % BYTE_IN_BITS;
- if (reminder > 0) {
- len = len + 1;
- }
- if (cb.readableBytes() < len) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
- cb.readableBytes());
- }
- byte[] prefix = new byte[len];
- cb.readBytes(prefix, 0, len);
- ipPrefix = Validation.bytesToPrefix(prefix, length);
- nlri.add(ipPrefix);
- }
- }
- return nlri;
- }
-
- /**
- * Parsing withdrawn routes from channel buffer.
- *
- * @param cb channelBuffer
- * @return list of IP prefix
- * @throws BgpParseException while parsing withdrawn routes
- */
- public static LinkedList<IpPrefix> parseWithdrawnRoutes(ChannelBuffer cb)
- throws BgpParseException {
- LinkedList<IpPrefix> withDrwRoutes = new LinkedList<>();
- while (cb.readableBytes() > 0) {
- int length = cb.readByte();
- IpPrefix ipPrefix;
- if (length == 0) {
- byte[] prefix = new byte[] {0};
- ipPrefix = Validation.bytesToPrefix(prefix, length);
- withDrwRoutes.add(ipPrefix);
- } else {
- int len = length / BYTE_IN_BITS;
- int reminder = length % BYTE_IN_BITS;
- if (reminder > 0) {
- len = len + 1;
- }
- if (cb.readableBytes() < len) {
- Validation
- .validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
- cb.readableBytes());
- }
- byte[] prefix = new byte[len];
- cb.readBytes(prefix, 0, len);
- ipPrefix = Validation.bytesToPrefix(prefix, length);
- withDrwRoutes.add(ipPrefix);
- }
- }
- return withDrwRoutes;
- }
-
- @Override
- public BgpVersion getVersion() {
- return BgpVersion.BGP_4;
- }
-
- @Override
- public BgpType getType() {
- return BgpType.UPDATE;
- }
-
- @Override
- public void writeTo(ChannelBuffer channelBuffer) throws BgpParseException {
- //Not to be implemented as of now
- }
-
- @Override
- public BgpPathAttributes bgpPathAttributes() {
- return this.bgpPathAttributes;
- }
-
- @Override
- public List<IpPrefix> withdrawnRoutes() {
- return withdrawnRoutes;
- }
-
- @Override
- public List<IpPrefix> nlri() {
- return nlri;
- }
-
- @Override
- public BgpHeader getHeader() {
- return this.bgpHeader;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("bgpHeader", bgpHeader)
- .add("withDrawnRoutes", withdrawnRoutes)
- .add("nlri", nlri)
- .add("bgpPathAttributes", bgpPathAttributes)
- .toString();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/package-info.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/package-info.java
deleted file mode 100755
index fb8c67c0..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * BGP Protocol specific details of version 4.
- */
-package org.onosproject.bgpio.protocol.ver4; \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java
deleted file mode 100644
index 842c6f02..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides AreaID Tlv which contains opaque value (32 Bit Area-ID).
- */
-public class AreaIDTlv implements BgpValueType {
-
- /* Reference :draft-ietf-idr-ls-distribution-11
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type= 514 | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | opaque value (32 Bit Area-ID) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- public static final short TYPE = 514;
- public static final short LENGTH = 4;
-
- private final int areaID;
-
- /**
- * Constructor to initialize areaID.
- *
- * @param areaID of BGP AreaID Tlv
- */
- public AreaIDTlv(int areaID) {
- this.areaID = areaID;
- }
-
- /**
- * Returns object of this class with specified areaID.
- *
- * @param areaID opaque value of area id
- * @return object of AreaIDTlv
- */
- public static AreaIDTlv of(final int areaID) {
- return new AreaIDTlv(areaID);
- }
-
- /**
- * Returns opaque value of area id.
- *
- * @return opaque value of area id
- */
- public int getAreaID() {
- return areaID;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(areaID);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof AreaIDTlv) {
- AreaIDTlv other = (AreaIDTlv) obj;
- return Objects.equals(areaID, other.areaID);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(areaID);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of AreaIDTlv.
- *
- * @param cb ChannelBuffer
- * @return object of AreaIDTlv
- */
- public static AreaIDTlv read(ChannelBuffer cb) {
- return AreaIDTlv.of(cb.readInt());
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- return ((Integer) (this.areaID)).compareTo((Integer) (((AreaIDTlv) o).areaID));
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", areaID)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java
deleted file mode 100644
index 3ceca2ce..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.util.Constants;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Implementation of As4Path BGP Path Attribute.
- */
-public class As4Path implements BgpValueType {
- private static final Logger log = LoggerFactory.getLogger(AsPath.class);
- public static final byte AS4PATH_TYPE = 17;
- public static final byte ASNUM_SIZE = 4;
-
- private List<Integer> as4pathSet;
- private List<Integer> as4pathSeq;
-
- /**
- * Initialize fields.
- */
- public As4Path() {
- this.as4pathSeq = null;
- this.as4pathSet = null;
- }
-
- /**
- * Constructor to initialize parameters.
- *
- * @param as4pathSet AS4path Set
- * @param as4pathSeq AS4path Sequence
- */
- public As4Path(List<Integer> as4pathSet, List<Integer> as4pathSeq) {
- this.as4pathSeq = as4pathSeq;
- this.as4pathSet = as4pathSet;
- }
-
- /**
- * Reads from the channel buffer and parses As4Path.
- *
- * @param cb ChannelBuffer
- * @return object of As4Path
- * @throws BgpParseException while parsing As4Path
- */
- public static As4Path read(ChannelBuffer cb) throws BgpParseException {
- List<Integer> as4pathSet = new ArrayList<>();
- List<Integer> as4pathSeq = new ArrayList<>();
- ChannelBuffer tempCb = cb.copy();
- Validation validation = Validation.parseAttributeHeader(cb);
-
- if (cb.readableBytes() < validation.getLength()) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- validation.getLength());
- }
- //if fourth bit is set length is read as short otherwise as byte , len includes type, length and value
- int len = validation.isShort() ? validation.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : validation
- .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
- ChannelBuffer data = tempCb.readBytes(len);
- if (validation.getFirstBit() && !validation.getSecondBit() && validation.getThirdBit()) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
- }
-
- ChannelBuffer tempBuf = cb.readBytes(validation.getLength());
- while (tempBuf.readableBytes() > 0) {
- byte pathSegType = tempBuf.readByte();
- //no of ASes
- byte pathSegLen = tempBuf.readByte();
- //length = no of Ases * ASnum size (4 bytes)
- int length = pathSegLen * ASNUM_SIZE;
- if (tempBuf.readableBytes() < length) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR, length);
- }
- ChannelBuffer aspathBuf = tempBuf.readBytes(length);
- while (aspathBuf.readableBytes() > 0) {
- int asNum;
- asNum = aspathBuf.readInt();
- switch (pathSegType) {
- case AsPath.ASPATH_SET_TYPE:
- as4pathSet.add(asNum);
- break;
- case AsPath.ASPATH_SEQ_TYPE:
- as4pathSeq.add(asNum);
- break;
- default: log.debug("Other type Not Supported:" + pathSegType);
- }
- }
- }
- return new As4Path(as4pathSet, as4pathSeq);
- }
-
- @Override
- public short getType() {
- return AS4PATH_TYPE;
- }
-
- /**
- * Returns list of ASNum in AS4path Sequence.
- *
- * @return list of ASNum in AS4path Sequence
- */
- public List<Integer> as4PathSEQ() {
- return this.as4pathSeq;
- }
-
- /**
- * Returns list of ASNum in AS4path Set.
- *
- * @return list of ASNum in AS4path Set
- */
- public List<Integer> as4PathSET() {
- return this.as4pathSet;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(as4pathSet, as4pathSeq);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof As4Path) {
- As4Path other = (As4Path) obj;
- return Objects.equals(as4pathSet, other.as4pathSet) && Objects.equals(as4pathSeq, other.as4pathSeq);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("as4pathSet", as4pathSet)
- .add("as4pathSeq", as4pathSeq)
- .toString();
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- //Not required to Implement as of now
- return 0;
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java
deleted file mode 100644
index 2a050c44..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.types;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.util.Constants;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Implementation of AsPath mandatory BGP Path Attribute.
- */
-public class AsPath implements BgpValueType {
- /**
- * Enum to provide AS types.
- */
- public enum ASTYPE {
- AS_SET(1), AS_SEQUENCE(2), AS_CONFED_SEQUENCE(3), AS_CONFED_SET(4);
- int value;
-
- /**
- * Assign val with the value as the AS type.
- *
- * @param val AS type
- */
- ASTYPE(int val) {
- value = val;
- }
-
- /**
- * Returns value of AS type.
- *
- * @return AS type
- */
- public byte type() {
- return (byte) value;
- }
- }
-
- private static final Logger log = LoggerFactory.getLogger(AsPath.class);
- public static final byte ASPATH_TYPE = 2;
- public static final byte ASPATH_SET_TYPE = 1;
- public static final byte ASPATH_SEQ_TYPE = 2;
- public static final byte ASNUM_SIZE = 2;
-
- private boolean isAsPath = false;
- private List<Short> aspathSet;
- private List<Short> aspathSeq;
-
- /**
- * Initialize Fields.
- */
- public AsPath() {
- this.aspathSeq = null;
- this.aspathSet = null;
- }
-
- /**
- * Constructor to initialize parameters.
- *
- * @param aspathSet ASpath Set type
- * @param aspathSeq ASpath Sequence type
- */
- public AsPath(List<Short> aspathSet, List<Short> aspathSeq) {
- this.aspathSeq = aspathSeq;
- this.aspathSet = aspathSet;
- this.isAsPath = true;
- }
-
- /**
- * Reads from the channel buffer and parses AsPath.
- *
- * @param cb ChannelBuffer
- * @return object of AsPath
- * @throws BgpParseException while parsing AsPath
- */
- public static AsPath read(ChannelBuffer cb) throws BgpParseException {
- List<Short> aspathSet = new ArrayList<>();
- List<Short> aspathSeq = new ArrayList<>();
- ChannelBuffer tempCb = cb.copy();
- Validation validation = Validation.parseAttributeHeader(cb);
-
- if (cb.readableBytes() < validation.getLength()) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- validation.getLength());
- }
- //if fourth bit is set, length is read as short otherwise as byte , len includes type, length and value
- int len = validation.isShort() ? validation.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : validation
- .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
- ChannelBuffer data = tempCb.readBytes(len);
- if (validation.getFirstBit() && !validation.getSecondBit() && validation.getThirdBit()) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
- }
-
- ChannelBuffer tempBuf = cb.readBytes(validation.getLength());
- while (tempBuf.readableBytes() > 0) {
- byte pathSegType = tempBuf.readByte();
- //no of ASes
- byte pathSegLen = tempBuf.readByte();
- int length = pathSegLen * ASNUM_SIZE;
- if (tempBuf.readableBytes() < length) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR, length);
- }
- ChannelBuffer aspathBuf = tempBuf.readBytes(length);
- while (aspathBuf.readableBytes() > 0) {
- short asNum;
- asNum = aspathBuf.readShort();
- switch (pathSegType) {
- case ASPATH_SET_TYPE:
- aspathSet.add(asNum);
- break;
- case ASPATH_SEQ_TYPE:
- aspathSeq.add(asNum);
- break;
- default: log.debug("Other type Not Supported:" + pathSegType);
- }
- }
- }
- return new AsPath(aspathSet, aspathSeq);
- }
-
- @Override
- public short getType() {
- return ASPATH_TYPE;
- }
-
- /**
- * Returns whether ASpath path attribute is present.
- *
- * @return whether ASpath path attribute is present
- */
- public boolean isaspathSet() {
- return this.isAsPath;
- }
-
- /**
- * Returns list of ASNum in ASpath Sequence.
- *
- * @return list of ASNum in ASpath Sequence
- */
- public List<Short> asPathSeq() {
- return this.aspathSeq;
- }
-
- /**
- * Returns list of ASNum in ASpath SET.
- *
- * @return list of ASNum in ASpath SET
- */
- public List<Short> asPathSet() {
- return this.aspathSet;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(aspathSet, aspathSeq);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof AsPath) {
- AsPath other = (AsPath) obj;
- return Objects.equals(aspathSet, other.aspathSet) && Objects.equals(aspathSeq, other.aspathSeq);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("aspathSet", aspathSet)
- .add("aspathSeq", aspathSeq)
- .toString();
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- //Not required to Implement as of now
- return 0;
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java
deleted file mode 100644
index 119926c8..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Autonomous System Tlv which contains opaque value (32 Bit AS Number).
- */
-public class AutonomousSystemTlv implements BgpValueType {
-
- /* Reference :draft-ietf-idr-ls-distribution-11
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type= 512 | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | opaque value (32 Bit AS Number) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- public static final short TYPE = 512;
- public static final short LENGTH = 4;
-
- private final int asNum;
-
- /**
- * Constructor to initialize asNum.
- *
- * @param asNum 32 Bit AS Number
- */
- public AutonomousSystemTlv(int asNum) {
- this.asNum = asNum;
- }
-
- /**
- * Returns object of this class with specified asNum.
- *
- * @param asNum 32 Bit AS Number
- * @return object of AutonomousSystemTlv
- */
- public static AutonomousSystemTlv of(final int asNum) {
- return new AutonomousSystemTlv(asNum);
- }
-
- /**
- * Returns opaque value of AS Number.
- *
- * @return opaque value of AS Number
- */
- public int getAsNum() {
- return asNum;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(asNum);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof AutonomousSystemTlv) {
- AutonomousSystemTlv other = (AutonomousSystemTlv) obj;
- return Objects.equals(asNum, other.asNum);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(asNum);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of AutonomousSystemTlv.
- *
- * @param c ChannelBuffer
- * @return object of AutonomousSystemTlv
- */
- public static AutonomousSystemTlv read(ChannelBuffer c) {
- return AutonomousSystemTlv.of(c.readInt());
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- return ((Integer) (this.asNum)).compareTo((Integer) (((AutonomousSystemTlv) o).asNum));
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("asNum", asNum)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpErrorType.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpErrorType.java
deleted file mode 100644
index c0932ebe..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpErrorType.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.types;
-
-/**
- * BgpErrorType class defines all errorCodes and error Subcodes required for Notification message.
- */
-public final class BgpErrorType {
- private BgpErrorType() {
- }
-
- //Error Codes
- public static final byte MESSAGE_HEADER_ERROR = 1;
- public static final byte OPEN_MESSAGE_ERROR = 2;
- public static final byte UPDATE_MESSAGE_ERROR = 3;
- public static final byte HOLD_TIMER_EXPIRED = 4;
- public static final byte FINITE_STATE_MACHINE_ERROR = 5;
- public static final byte CEASE = 6;
-
- //Message Header Error subcodes
- public static final byte CONNECTION_NOT_SYNCHRONIZED = 1;
- public static final byte BAD_MESSAGE_LENGTH = 2;
- public static final byte BAD_MESSAGE_TYPE = 3;
-
- //OPEN Message Error subcodes
- public static final byte UNSUPPORTED_VERSION_NUMBER = 1;
- public static final byte BAD_PEER_AS = 2;
- public static final byte BAD_BGP_IDENTIFIER = 3;
- public static final byte UNSUPPORTED_OPTIONAL_PARAMETER = 4;
- public static final byte UNACCEPTABLE_HOLD_TIME = 5;
- public static final byte UNSUPPORTED_CAPABILITY = 7;
-
- //UPDATE Message Error subcodes
- public static final byte MALFORMED_ATTRIBUTE_LIST = 1;
- public static final byte UNRECOGNIZED_WELLKNOWN_ATTRIBUTE = 2;
- public static final byte MISSING_WELLKNOWN_ATTRIBUTE = 3;
- public static final byte ATTRIBUTE_FLAGS_ERROR = 4;
- public static final byte ATTRIBUTE_LENGTH_ERROR = 5;
- public static final byte INVALID_ORIGIN_ATTRIBUTE = 6;
- public static final byte INVALID_NEXTHOP_ATTRIBUTE = 8;
- public static final byte OPTIONAL_ATTRIBUTE_ERROR = 9;
- public static final byte INVALID_NETWORK_FIELD = 10;
- public static final byte MALFORMED_ASPATH = 11;
-
- //FSM Error subcodes
- public static final byte UNSPECIFIED_ERROR = 0;
- public static final byte RECEIVE_UNEXPECTED_MESSAGE_IN_OPENSENT_STATE = 1;
- public static final byte RECEIVE_UNEXPECTED_MESSAGE_IN_OPENCONFIRM_STATE = 2;
- public static final byte RECEIVE_UNEXPECTED_MESSAGE_IN_ESTABLISHED_STATE = 3;
-
- //Cease Error subcodes
- public static final byte MAXIMUM_NUMBER_OF_PREFIXES_REACHED = 1;
- public static final byte ADMINISTRATIVE_SHUTDOWN = 2;
- public static final byte PEER_DECONFIGURED = 3;
- public static final byte ADMINISTRATIVE_RESET = 4;
- public static final byte CONNECTION_REJECTED = 5;
- public static final byte OTHER_CONFIGURATION_CHANGE = 6;
- public static final byte CONNECTION_COLLISION_RESOLUTION = 7;
- public static final byte OUT_OF_RESOURCES = 8;
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpHeader.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpHeader.java
deleted file mode 100755
index ad637753..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpHeader.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Provides BGP Message Header which is common for all the Messages.
- */
-
-public class BgpHeader {
-
- /* 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- + +
- | |
- + +
- | Marker |
- + +
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Length | Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- protected static final Logger log = LoggerFactory.getLogger(BgpHeader.class);
-
- public static final int MARKER_LENGTH = 16;
- public static final short DEFAULT_HEADER_LENGTH = 19;
-
- private byte[] marker;
- private byte type;
- private short length;
-
- /**
- * Reset fields.
- */
- public BgpHeader() {
- this.marker = null;
- this.length = 0;
- this.type = 0;
- }
-
- /**
- * Constructors to initialize parameters.
- *
- * @param marker field in BGP header
- * @param length message length
- * @param type message type
- */
- public BgpHeader(byte[] marker, short length, byte type) {
- this.marker = marker;
- this.length = length;
- this.type = type;
- }
-
- /**
- * Sets marker field.
- *
- * @param value marker field
- */
- public void setMarker(byte[] value) {
- this.marker = value;
- }
-
- /**
- * Sets message type.
- *
- * @param value message type
- */
- public void setType(byte value) {
- this.type = value;
- }
-
- /**
- * Sets message length.
- *
- * @param value message length
- */
- public void setLength(short value) {
- this.length = value;
- }
-
- /**
- * Returns message length.
- *
- * @return message length
- */
- public short getLength() {
- return this.length;
- }
-
- /**
- * Returns message marker.
- *
- * @return message marker
- */
- public byte[] getMarker() {
- return this.marker;
- }
-
- /**
- * Returns message type.
- *
- * @return message type
- */
- public byte getType() {
- return this.type;
- }
-
- /**
- * Writes Byte stream of BGP header to channel buffer.
- *
- * @param cb ChannelBuffer
- * @return length index of message header
- */
- public int write(ChannelBuffer cb) {
-
- cb.writeBytes(getMarker(), 0, MARKER_LENGTH);
-
- int headerLenIndex = cb.writerIndex();
- cb.writeShort((short) 0);
- cb.writeByte(type);
-
- return headerLenIndex;
- }
-
- /**
- * Read from channel buffer and Returns BGP header.
- *
- * @param cb ChannelBuffer
- * @return object of BGPHeader
- */
- public static BgpHeader read(ChannelBuffer cb) {
-
- byte[] marker = new byte[MARKER_LENGTH];
- byte type;
- short length;
- cb.readBytes(marker, 0, MARKER_LENGTH);
- length = cb.readShort();
- type = cb.readByte();
- return new BgpHeader(marker, length, type);
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpLSIdentifierTlv.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpLSIdentifierTlv.java
deleted file mode 100644
index 58645d4f..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpLSIdentifierTlv.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides BGPLSIdentifier Tlv which contains opaque value (32 Bit BGPLS-Identifier).
- */
-public class BgpLSIdentifierTlv implements BgpValueType {
-
- /* Reference :draft-ietf-idr-ls-distribution-11
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type= 513 | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | opaque value (32 Bit BGPLS-Identifier) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- public static final short TYPE = 513;
- public static final short LENGTH = 4;
-
- private final int bgpLsIdentifier;
-
- /**
- * Constructor to initialize bgpLsIdentifier.
- *
- * @param bgpLsIdentifier BGPLS-Identifier
- */
- public BgpLSIdentifierTlv(int bgpLsIdentifier) {
- this.bgpLsIdentifier = bgpLsIdentifier;
- }
-
- /**
- * Returns object of this class with specified bgpLsIdentifier.
- *
- * @param bgpLsIdentifier BGPLS-Identifier
- * @return BGPLS-Identifier
- */
- public static BgpLSIdentifierTlv of(final int bgpLsIdentifier) {
- return new BgpLSIdentifierTlv(bgpLsIdentifier);
- }
-
- /**
- * Returns opaque value of BGPLS-Identifier.
- *
- * @return opaque value of BGPLS-Identifier
- */
- public int getBgpLsIdentifier() {
- return bgpLsIdentifier;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(bgpLsIdentifier);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpLSIdentifierTlv) {
- BgpLSIdentifierTlv other = (BgpLSIdentifierTlv) obj;
- return Objects.equals(bgpLsIdentifier, other.bgpLsIdentifier);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(bgpLsIdentifier);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and parses BGPLS Identifier TLV.
- *
- * @param cb ChannelBuffer
- * @return object of BGPLSIdentifierTlv
- */
- public static BgpLSIdentifierTlv read(ChannelBuffer cb) {
- return BgpLSIdentifierTlv.of(cb.readInt());
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- return ((Integer) (this.bgpLsIdentifier)).compareTo((Integer) (((BgpLSIdentifierTlv) o).bgpLsIdentifier));
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", bgpLsIdentifier)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
deleted file mode 100644
index af7f4b75..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Abstraction which Provides the BGP of TLV format.
- */
-public interface BgpValueType {
- /**
- * Returns the Type of BGP Message.
- *
- * @return short value of type
- */
- short getType();
-
- /**
- * Writes the byte Stream of BGP Message to channel buffer.
- *
- * @param cb channel buffer
- * @return length written to channel buffer
- */
- int write(ChannelBuffer cb);
-
- /**
- * Compares two objects.
- *
- * @param o object
- * @return result after comparing two objects
- */
- int compareTo(Object o);
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java
deleted file mode 100644
index 59db3318..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides FourOctetAsNumCapabilityTlv Capability Tlv.
- */
-public class FourOctetAsNumCapabilityTlv implements BgpValueType {
-
- /**
- * support to indicate its support for four-octet AS numbers -CAPABILITY TLV format.
- */
- protected static final Logger log = LoggerFactory
- .getLogger(FourOctetAsNumCapabilityTlv.class);
-
- public static final byte TYPE = 65;
- public static final byte LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * constructor to initialize rawValue.
- * @param rawValue FourOctetAsNumCapabilityTlv
- */
- public FourOctetAsNumCapabilityTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * constructor to initialize raw.
- * @param raw AS number
- * @return object of FourOctetAsNumCapabilityTlv
- */
- public static FourOctetAsNumCapabilityTlv of(final int raw) {
- return new FourOctetAsNumCapabilityTlv(raw);
- }
-
- /**
- * Returns value of TLV.
- * @return int value of rawValue
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof FourOctetAsNumCapabilityTlv) {
- FourOctetAsNumCapabilityTlv other = (FourOctetAsNumCapabilityTlv) obj;
- return Objects.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- int iLenStartIndex = cb.writerIndex();
- cb.writeByte(TYPE);
- cb.writeByte(LENGTH);
- cb.writeInt(rawValue);
- return cb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of FourOctetAsNumCapabilityTlv.
- * @param cb type of channel buffer
- * @return object of FourOctetAsNumCapabilityTlv
- */
- public static FourOctetAsNumCapabilityTlv read(ChannelBuffer cb) {
- return FourOctetAsNumCapabilityTlv.of(cb.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.java
deleted file mode 100644
index d97537e8..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.bgpio.util.Validation;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides IP Reachability InformationTlv Tlv which contains IP Prefix.
- */
-public class IPReachabilityInformationTlv implements BgpValueType {
-
- /*
- * Reference :draft-ietf-idr-ls-distribution-11
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Prefix Length | IP Prefix (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Figure 14: IP Reachability Information TLV Format
- */
-
- public static final short TYPE = 265;
- public static final int ONE_BYTE_LEN = 8;
-
- private byte prefixLen;
- private byte[] ipPrefix;
- public short length;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param prefixLen length of IP Prefix
- * @param ipPrefix IP Prefix
- * @param length length of value field
- */
- public IPReachabilityInformationTlv(byte prefixLen, byte[] ipPrefix, short length) {
- this.ipPrefix = ipPrefix;
- this.prefixLen = prefixLen;
- this.length = length;
- }
-
- /**
- * Returns IP Prefix.
- *
- * @return IP Prefix
- */
- public IpPrefix getPrefixValue() {
- IpPrefix prefix = Validation.bytesToPrefix(ipPrefix, prefixLen);
- return prefix;
- }
-
- /**
- * Returns IP Prefix length.
- *
- * @return IP Prefix length
- */
- public byte getPrefixLen() {
- return this.prefixLen;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(Arrays.hashCode(ipPrefix), prefixLen);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof IPReachabilityInformationTlv) {
- IPReachabilityInformationTlv other = (IPReachabilityInformationTlv) obj;
- return Objects.equals(prefixLen, other.prefixLen) && Arrays.equals(ipPrefix, other.ipPrefix);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- int iLenStartIndex = cb.writerIndex();
- cb.writeShort(TYPE);
- cb.writeShort(length);
- cb.writeByte(prefixLen);
- cb.writeBytes(ipPrefix);
- return cb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IPReachabilityInformationTlv.
- *
- * @param cb ChannelBuffer
- * @param length of value field
- * @return object of IPReachabilityInformationTlv
- */
- public static IPReachabilityInformationTlv read(ChannelBuffer cb, short length) {
- byte preficLen = cb.readByte();
- byte[] prefix;
- if (preficLen == 0) {
- prefix = new byte[] {0};
- } else {
- int len = preficLen / ONE_BYTE_LEN;
- int reminder = preficLen % ONE_BYTE_LEN;
- if (reminder > 0) {
- len = len + 1;
- }
- prefix = new byte[len];
- cb.readBytes(prefix, 0, len);
- }
- return IPReachabilityInformationTlv.of(preficLen, prefix, length);
- }
-
- public static IPReachabilityInformationTlv of(final byte preficLen, final byte[] prefix, final short length) {
- return new IPReachabilityInformationTlv(preficLen, prefix, length);
- }
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- ByteBuffer value1 = ByteBuffer.wrap(this.ipPrefix);
- ByteBuffer value2 = ByteBuffer.wrap(((IPReachabilityInformationTlv) o).ipPrefix);
- return value1.compareTo(value2);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", length)
- .add("Prefixlength", getPrefixLen())
- .add("Prefixvalue", getPrefixValue())
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java
deleted file mode 100644
index 4efde70e..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.net.InetAddress;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.util.Validation;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
-
-/**
- * Provides Implementation of IPv4AddressTlv.
- */
-public class IPv4AddressTlv implements BgpValueType {
- private static final int LENGTH = 4;
-
- private Ip4Address address;
- private short type;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param address Ipv4 address of interface/neighbor
- * @param type address type
- */
- public IPv4AddressTlv(Ip4Address address, short type) {
- this.address = Preconditions.checkNotNull(address);
- this.type = type;
- }
-
- /**
- * Returns Ipv4 address of interface/neighbor.
- *
- * @return Ipv4 address of interface/neighbor
- */
- public Ip4Address address() {
- return address;
- }
-
- @Override
- public short getType() {
- return this.type;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(address);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IPv4AddressTlv) {
- IPv4AddressTlv other = (IPv4AddressTlv) obj;
- return Objects.equals(this.address, other.address) && Objects.equals(this.type, other.type);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- int iLenStartIndex = cb.writerIndex();
- cb.writeShort(type);
- cb.writeShort(LENGTH);
- cb.writeInt(address.toInt());
- return cb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IPv4AddressTlv.
- *
- * @param cb channelBuffer
- * @param type address type
- * @return object of IPv4AddressTlv
- * @throws BgpParseException while parsing IPv4AddressTlv
- */
- public static IPv4AddressTlv read(ChannelBuffer cb, short type) throws BgpParseException {
- InetAddress ipAddress = Validation.toInetAddress(LENGTH, cb);
- if (ipAddress.isMulticastAddress()) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
- }
- Ip4Address address = Ip4Address.valueOf(ipAddress);
- return IPv4AddressTlv.of(address, type);
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param address Ipv4 interface/neighbor Address
- * @param type says Ipv4 address of interface/neighbor tlv type
- * @return object of this class
- */
- public static IPv4AddressTlv of(final Ip4Address address , final short type) {
- return new IPv4AddressTlv(address, type);
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- return ((Ip4Address) (this.address)).compareTo((Ip4Address) (((IPv4AddressTlv) o).address));
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("type", type)
- .add("LENGTH", LENGTH)
- .add("address", address)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java
deleted file mode 100644
index 087cd5c6..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.net.InetAddress;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip6Address;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.util.Validation;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
-
-/**
- * Provides Implementation of IPv6AddressTlv.
- */
-public class IPv6AddressTlv implements BgpValueType {
- private static final int LENGTH = 16;
-
- private final Ip6Address address;
- private short type;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param address Ipv6 address of interface/neighbor
- * @param type address type
- */
- public IPv6AddressTlv(Ip6Address address, short type) {
- this.address = Preconditions.checkNotNull(address);
- this.type = type;
- }
-
- /**
- * Returns Ipv6 address of interface/neighbor.
- *
- * @return Ipv6 address of interface/neighbor
- */
- public Ip6Address address() {
- return address;
- }
-
- @Override
- public short getType() {
- return type;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(address);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IPv6AddressTlv) {
- IPv6AddressTlv other = (IPv6AddressTlv) obj;
- return Objects.equals(this.address, other.address) && Objects.equals(this.type, other.type);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- int iLenStartIndex = cb.writerIndex();
- cb.writeShort(type);
- cb.writeShort(LENGTH);
- cb.writeBytes(address.toOctets());
- return cb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IPv6AddressTlv.
- *
- * @param cb channelBuffer
- * @param type address type
- * @return object of IPv6AddressTlv
- * @throws BgpParseException while parsing IPv6AddressTlv
- */
- public static IPv6AddressTlv read(ChannelBuffer cb, short type) throws BgpParseException {
- InetAddress ipAddress = Validation.toInetAddress(LENGTH, cb);
- if (ipAddress.isMulticastAddress()) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
- }
- Ip6Address address = Ip6Address.valueOf(ipAddress);
- return IPv6AddressTlv.of(address, type);
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param address Ipv6 interface/neighbor address
- * @param type says Ipv6 address of interface/neighbor tlv type
- * @return object of this class
- */
- public static IPv6AddressTlv of(final Ip6Address address , final short type) {
- return new IPv6AddressTlv(address, type);
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- return ((Ip6Address) (this.address)).compareTo((Ip6Address) (((IPv6AddressTlv) o).address));
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("type", type)
- .add("LENGTH", LENGTH)
- .add("address", address)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java
deleted file mode 100644
index 427aa929..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.protocol.IGPRouterID;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Implementation of IsIsNonPseudonode Tlv.
- */
-public class IsIsNonPseudonode implements IGPRouterID, BgpValueType {
- public static final short TYPE = 515;
- public static final short LENGTH = 6;
-
- private final byte[] isoNodeID;
-
- /**
- * Constructor to initialize isoNodeID.
- *
- * @param isoNodeID ISO system-ID
- */
- public IsIsNonPseudonode(byte[] isoNodeID) {
- this.isoNodeID = Arrays.copyOf(isoNodeID, isoNodeID.length);
- }
-
- /**
- * Returns object of this class with specified isoNodeID.
- *
- * @param isoNodeID ISO system-ID
- * @return object of IsIsNonPseudonode
- */
- public static IsIsNonPseudonode of(final byte[] isoNodeID) {
- return new IsIsNonPseudonode(isoNodeID);
- }
-
- /**
- * Returns ISO NodeID.
- *
- * @return ISO NodeID
- */
- public byte[] getISONodeID() {
- return isoNodeID;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(isoNodeID);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IsIsNonPseudonode) {
- IsIsNonPseudonode other = (IsIsNonPseudonode) obj;
- return Arrays.equals(isoNodeID, other.isoNodeID);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeBytes(isoNodeID);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IsIsNonPseudonode.
- *
- * @param cb ChannelBuffer
- * @return object of IsIsNonPseudonode
- */
- public static IsIsNonPseudonode read(ChannelBuffer cb) {
- byte[] isoNodeID = new byte[LENGTH];
- cb.readBytes(isoNodeID);
- return IsIsNonPseudonode.of(isoNodeID);
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- ByteBuffer value1 = ByteBuffer.wrap(this.isoNodeID);
- ByteBuffer value2 = ByteBuffer.wrap(((IsIsNonPseudonode) o).isoNodeID);
- return value1.compareTo(value2);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("ISONodeID", isoNodeID)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java
deleted file mode 100644
index 094c4382..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.protocol.IGPRouterID;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides implementation of IsIsPseudonode Tlv.
- */
-public class IsIsPseudonode implements IGPRouterID, BgpValueType {
- public static final short TYPE = 515;
- public static final short LENGTH = 7;
-
- private final byte[] isoNodeID;
- private byte psnIdentifier;
-
- /**
- * Constructor to initialize isoNodeID.
- *
- * @param isoNodeID ISO system-ID
- * @param psnIdentifier PSN identifier
- */
- public IsIsPseudonode(byte[] isoNodeID, byte psnIdentifier) {
- this.isoNodeID = Arrays.copyOf(isoNodeID, isoNodeID.length);
- this.psnIdentifier = psnIdentifier;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param isoNodeID ISO system-ID
- * @param psnIdentifier PSN identifier
- * @return object of IsIsPseudonode
- */
- public static IsIsPseudonode of(final byte[] isoNodeID,
- final byte psnIdentifier) {
- return new IsIsPseudonode(isoNodeID, psnIdentifier);
- }
-
- /**
- * Returns ISO NodeID.
- *
- * @return ISO NodeID
- */
- public byte[] getISONodeID() {
- return isoNodeID;
- }
-
- /**
- * Returns PSN Identifier.
- *
- * @return PSN Identifier
- */
- public byte getPSNIdentifier() {
- return this.psnIdentifier;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(isoNodeID) & Objects.hash(psnIdentifier);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IsIsPseudonode) {
- IsIsPseudonode other = (IsIsPseudonode) obj;
- return Arrays.equals(isoNodeID, other.isoNodeID)
- && Objects.equals(psnIdentifier, other.psnIdentifier);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeBytes(isoNodeID, 0, LENGTH - 1);
- c.writeByte(psnIdentifier);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IsIsPseudonode.
- *
- * @param cb ChannelBuffer
- * @return object of IsIsPseudonode
- */
- public static IsIsPseudonode read(ChannelBuffer cb) {
- byte[] isoNodeID = new byte[LENGTH - 1];
- cb.readBytes(isoNodeID);
- byte psnIdentifier = cb.readByte();
- return IsIsPseudonode.of(isoNodeID, psnIdentifier);
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- ByteBuffer value1 = ByteBuffer.wrap(this.isoNodeID);
- ByteBuffer value2 = ByteBuffer.wrap(((IsIsPseudonode) o).isoNodeID);
- if (value1.compareTo(value2) != 0) {
- return value1.compareTo(value2);
- }
- return ((Byte) (this.psnIdentifier)).compareTo((Byte) (((IsIsPseudonode) o).psnIdentifier));
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("isoNodeID", isoNodeID)
- .add("psnIdentifier", psnIdentifier)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java
deleted file mode 100644
index 0c412432..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Implementation of Link Local/Remote IdentifiersTlv.
- */
-public class LinkLocalRemoteIdentifiersTlv implements BgpValueType {
- public static final short TYPE = 258;
- private static final int LENGTH = 8;
-
- private final int linkLocalIdentifer;
- private final int linkRemoteIdentifer;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param linkLocalIdentifer link local Identifer
- * @param linkRemoteIdentifer link remote Identifer
- */
- public LinkLocalRemoteIdentifiersTlv(int linkLocalIdentifer, int linkRemoteIdentifer) {
- this.linkLocalIdentifer = linkLocalIdentifer;
- this.linkRemoteIdentifer = linkRemoteIdentifer;
- }
-
- /**
- * Returns link remote Identifer.
- *
- * @return link remote Identifer
- */
- public int getLinkRemoteIdentifier() {
- return linkRemoteIdentifer;
- }
-
- /**
- * Returns link local Identifer.
- *
- * @return link local Identifer
- */
- public int getLinkLocalIdentifier() {
- return linkLocalIdentifer;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(linkLocalIdentifer, linkRemoteIdentifer);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LinkLocalRemoteIdentifiersTlv) {
- LinkLocalRemoteIdentifiersTlv other = (LinkLocalRemoteIdentifiersTlv) obj;
- return Objects.equals(this.linkLocalIdentifer, other.linkLocalIdentifer)
- && Objects.equals(this.linkRemoteIdentifer, other.linkRemoteIdentifer);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- int iLenStartIndex = cb.writerIndex();
- cb.writeShort(TYPE);
- cb.writeShort(LENGTH);
- cb.writeInt(linkLocalIdentifer);
- cb.writeInt(linkRemoteIdentifer);
- return cb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of LinkLocalRemoteIdentifiersTlv.
- *
- * @param cb channelBuffer
- * @return object of LinkLocalRemoteIdentifiersTlv
- */
- public static LinkLocalRemoteIdentifiersTlv read(ChannelBuffer cb) {
- int linkLocalIdentifer = cb.readInt();
- int linkRemoteIdentifer = cb.readInt();
- return LinkLocalRemoteIdentifiersTlv.of(linkLocalIdentifer, linkRemoteIdentifer);
- }
-
- /**
- * Returns object of this class with specified link local identifer and link remote identifer.
- *
- * @param linkLocalIdentifer link local identifier
- * @param linkRemoteIdentifer link remote identifier
- * @return object of LinkLocalRemoteIdentifiersTlv
- */
- public static LinkLocalRemoteIdentifiersTlv of(final int linkLocalIdentifer, final int linkRemoteIdentifer) {
- return new LinkLocalRemoteIdentifiersTlv(linkLocalIdentifer, linkRemoteIdentifer);
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- int result = ((Integer) (this.linkLocalIdentifer))
- .compareTo((Integer) (((LinkLocalRemoteIdentifiersTlv) o).linkLocalIdentifer));
- if (result != 0) {
- return result;
- }
- return ((Integer) (this.linkRemoteIdentifer))
- .compareTo((Integer) (((LinkLocalRemoteIdentifiersTlv) o).linkRemoteIdentifer));
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("TYPE", TYPE)
- .add("LENGTH", LENGTH)
- .add("linkLocalIdentifer", linkLocalIdentifer)
- .add("linkRemoteIdentifer", linkRemoteIdentifer)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkStateAttributes.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkStateAttributes.java
deleted file mode 100644
index cdf6ebeb..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkStateAttributes.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.attr.BgpAttrNodeFlagBitTlv;
-import org.onosproject.bgpio.types.attr.BgpAttrNodeIsIsAreaId;
-import org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId;
-import org.onosproject.bgpio.types.attr.BgpAttrNodeName;
-import org.onosproject.bgpio.types.attr.BgpAttrOpaqueNode;
-import org.onosproject.bgpio.types.attr.BgpAttrRouterIdV4;
-import org.onosproject.bgpio.types.attr.BgpAttrRouterIdV6;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrIgpMetric;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrIsIsAdminstGrp;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrMplsProtocolMask;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrName;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrOpaqLnkAttrib;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrProtectionType;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrSrlg;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrUnRsrvdLinkBandwidth;
-import org.onosproject.bgpio.types.attr.BgpPrefixAttrExtRouteTag;
-import org.onosproject.bgpio.types.attr.BgpPrefixAttrIgpFlags;
-import org.onosproject.bgpio.types.attr.BgpPrefixAttrMetric;
-import org.onosproject.bgpio.types.attr.BgpPrefixAttrOspfFwdAddr;
-import org.onosproject.bgpio.types.attr.BgpPrefixAttrOpaqueData;
-import org.onosproject.bgpio.types.attr.BgpPrefixAttrRouteTag;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP Link state attribute.
- */
-public class LinkStateAttributes implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(LinkStateAttributes.class);
-
- /* Node Attributes */
- public static final short ATTR_NODE_MT_TOPOLOGY_ID = 263;
- public static final short ATTR_NODE_FLAG_BITS = 1024;
- public static final short ATTR_NODE_OPAQUE_NODE = 1025;
- public static final short ATTR_NODE_NAME = 1026;
- public static final short ATTR_NODE_ISIS_AREA_ID = 1027;
- public static final short ATTR_NODE_IPV4_LOCAL_ROUTER_ID = 1028;
- public static final short ATTR_NODE_IPV6_LOCAL_ROUTER_ID = 1029;
-
- /* Link Attributes */
- public static final short ATTR_LINK_IPV4_REMOTE_ROUTER_ID = 1030;
- public static final short ATTR_LINK_IPV6_REMOTE_ROUTER_ID = 1031;
- public static final short ATTR_LINK_ADMINISTRATIVE_GRPS = 1088;
- public static final short ATTR_LINK_MAX_BANDWIDTH = 1089;
- public static final short ATTR_LINK_MAX_RES_BANDWIDTH = 1090;
- public static final short ATTR_LINK_UNRES_BANDWIDTH = 1091;
- public static final short ATTR_LINK_TE_DEFAULT_METRIC = 1092;
- public static final short ATTR_LINK_PROTECTION_TYPE = 1093;
- public static final short ATTR_LINK_MPLS_PROTOCOL_MASK = 1094;
- public static final short ATTR_LINK_IGP_METRIC = 1095;
- public static final short ATTR_LINK_SHR_RISK_GRP = 1096;
- public static final short ATTR_LINK_OPAQUE_ATTR = 1097;
- public static final short ATTR_LINK_NAME_ATTR = 1098;
-
- /* Prefix Attributes */
- public static final short ATTR_PREFIX_IGP_FLAG = 1152;
- public static final short ATTR_PREFIX_ROUTE_TAG = 1153;
- public static final short ATTR_PREFIX_EXTENDED_TAG = 1154;
- public static final short ATTR_PREFIX_METRIC = 1155;
- public static final short ATTR_PREFIX_OSPF_FWD_ADDR = 1156;
- public static final short ATTR_PREFIX_OPAQUE_ATTR = 1157;
-
- public static final byte LINKSTATE_ATTRIB_TYPE = 50;
- public static final byte TYPE_AND_LEN = 4;
- private boolean isLinkStateAttribute = false;
- private List<BgpValueType> linkStateAttribList;
-
- /**
- * Constructor to reset parameters.
- */
- LinkStateAttributes() {
- this.linkStateAttribList = null;
- }
-
- /**
- * Constructor to initialize parameters.
- *
- * @param linkStateAttribList Linked list of Link, Node and Prefix TLVs
- */
- LinkStateAttributes(List<BgpValueType> linkStateAttribList) {
- this.linkStateAttribList = linkStateAttribList;
- this.isLinkStateAttribute = true;
- }
-
- /**
- * Returns linked list of Link, Node and Prefix TLVs.
- *
- * @return linked list of Link, Node and Prefix TLVs
- */
- public List<BgpValueType> linkStateAttributes() {
- return this.linkStateAttribList;
- }
-
- /**
- * Returns if the Link state attributes are set or not.
- *
- * @return a boolean value to to check if the LS attributes are set or not
- */
- public boolean isLinkStateAttributeSet() {
- return this.isLinkStateAttribute;
- }
-
- /**
- * Reads the Link state attribute TLVs.
- *
- * @param cb ChannelBuffer
- * @return constructor of LinkStateAttributes
- * @throws BgpParseException while parsing link state attributes
- */
- public static LinkStateAttributes read(ChannelBuffer cb)
- throws BgpParseException {
-
- ChannelBuffer tempBuf = cb;
- Validation parseFlags = Validation.parseAttributeHeader(cb);
- int len = parseFlags.isShort() ? parseFlags.getLength() + TYPE_AND_LEN
- : parseFlags.getLength() + 3;
-
- ChannelBuffer data = tempBuf.readBytes(len);
- if (!parseFlags.getFirstBit() || parseFlags.getSecondBit()
- || parseFlags.getThirdBit()) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_FLAGS_ERROR,
- data);
- }
-
- if (cb.readableBytes() < parseFlags.getLength()) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.BAD_MESSAGE_LENGTH,
- parseFlags.getLength());
- }
-
- BgpValueType bgpLSAttrib = null;
- LinkedList<BgpValueType> linkStateAttribList;
- linkStateAttribList = new LinkedList<BgpValueType>();
- ChannelBuffer tempCb = cb.readBytes(parseFlags.getLength());
- while (tempCb.readableBytes() > 0) {
- short tlvCodePoint = tempCb.readShort();
- switch (tlvCodePoint) {
-
- /********* 7 NODE ATTRIBUTES ********/
- case ATTR_NODE_MT_TOPOLOGY_ID: /* 263 Multi-Topology Identifier*/
- bgpLSAttrib = BgpAttrNodeMultiTopologyId.read(tempCb);
- break;
-
- case ATTR_NODE_FLAG_BITS: /*Node flag bit TLV*/
- bgpLSAttrib = BgpAttrNodeFlagBitTlv.read(tempCb);
- break;
-
- case ATTR_NODE_OPAQUE_NODE: /*Opaque Node Attribute*/
- bgpLSAttrib = BgpAttrOpaqueNode.read(tempCb);
- break;
-
- case ATTR_NODE_NAME: /*Node Name*/
- bgpLSAttrib = BgpAttrNodeName.read(tempCb);
- break;
-
- case ATTR_NODE_ISIS_AREA_ID: /*IS-IS Area Identifier TLV*/
- bgpLSAttrib = BgpAttrNodeIsIsAreaId.read(tempCb);
- break;
-
- case ATTR_NODE_IPV4_LOCAL_ROUTER_ID: /*IPv4 Router-ID of Local Node*/
- bgpLSAttrib = BgpAttrRouterIdV4.read(tempCb, (short) ATTR_NODE_IPV4_LOCAL_ROUTER_ID);
- break;
-
- case ATTR_NODE_IPV6_LOCAL_ROUTER_ID: /*IPv6 Router-ID of Local Node*/
- bgpLSAttrib = BgpAttrRouterIdV6.read(tempCb, (short) ATTR_NODE_IPV6_LOCAL_ROUTER_ID);
- break;
-
- /********* 15 LINK ATTRIBUTES ********/
-
- case ATTR_LINK_IPV4_REMOTE_ROUTER_ID: /*IPv4 Router-ID of Remote Node*/
- bgpLSAttrib = BgpAttrRouterIdV4.read(tempCb, (short) 1030);
- break;
-
- case ATTR_LINK_IPV6_REMOTE_ROUTER_ID: /*IPv6 Router-ID of Remote Node*/
- bgpLSAttrib = BgpAttrRouterIdV6.read(tempCb, (short) 1031);
- break;
-
- case ATTR_LINK_ADMINISTRATIVE_GRPS: /*ISIS Administrative group STLV 3*/
- bgpLSAttrib = BgpLinkAttrIsIsAdminstGrp.read(tempCb);
- break;
-
- case ATTR_LINK_MAX_BANDWIDTH: /*Maximum link bandwidth*/
- bgpLSAttrib = BgpLinkAttrMaxLinkBandwidth.read(tempCb,
- (short) 1089);
- break;
-
- case ATTR_LINK_MAX_RES_BANDWIDTH: /* Maximum Reservable link bandwidth */
- bgpLSAttrib = BgpLinkAttrMaxLinkBandwidth.read(tempCb,
- (short) 1090);
- break;
-
- case ATTR_LINK_UNRES_BANDWIDTH: /* UnReserved link bandwidth */
- bgpLSAttrib = BgpLinkAttrUnRsrvdLinkBandwidth
- .read(tempCb, (short) 1091);
- break;
-
- case ATTR_LINK_TE_DEFAULT_METRIC: /* TE Default Metric */
- bgpLSAttrib = BgpLinkAttrTeDefaultMetric.read(tempCb);
- break;
-
- case ATTR_LINK_PROTECTION_TYPE:/* Link Protection type */
- bgpLSAttrib = BgpLinkAttrProtectionType.read(tempCb);
- break;
-
- case ATTR_LINK_MPLS_PROTOCOL_MASK: /* MPLS Protocol Mask */
- bgpLSAttrib = BgpLinkAttrMplsProtocolMask.read(tempCb); // 2
- break;
-
- case ATTR_LINK_IGP_METRIC: /* IGP Metric */
- bgpLSAttrib = BgpLinkAttrIgpMetric.read(tempCb); // 2
- break;
-
- case ATTR_LINK_SHR_RISK_GRP: /* Shared Risk Link Group */
- bgpLSAttrib = BgpLinkAttrSrlg.read(tempCb); // 3
- break;
-
- case ATTR_LINK_OPAQUE_ATTR: /* Opaque link attribute */
- bgpLSAttrib = BgpLinkAttrOpaqLnkAttrib.read(tempCb);
- break;
-
- case ATTR_LINK_NAME_ATTR: /* Link Name attribute */
- bgpLSAttrib = BgpLinkAttrName.read(tempCb);
- break;
-
- /********* 6 PREFIX ATTRIBUTES ********/
-
- case ATTR_PREFIX_IGP_FLAG: /* IGP Flags */
- bgpLSAttrib = BgpPrefixAttrIgpFlags.read(tempCb);
- break;
-
- case ATTR_PREFIX_ROUTE_TAG: /* Route Tag */
- bgpLSAttrib = BgpPrefixAttrRouteTag.read(tempCb);
- break;
-
- case ATTR_PREFIX_EXTENDED_TAG: /* Extended Tag */
- bgpLSAttrib = BgpPrefixAttrExtRouteTag.read(tempCb);
- break;
-
- case ATTR_PREFIX_METRIC: /* Prefix Metric */
- bgpLSAttrib = BgpPrefixAttrMetric.read(tempCb);
- break;
-
- case ATTR_PREFIX_OSPF_FWD_ADDR: /* OSPF Forwarding Address */
- bgpLSAttrib = BgpPrefixAttrOspfFwdAddr.read(tempCb);
- break;
-
- case ATTR_PREFIX_OPAQUE_ATTR: /* Opaque Prefix Attribute */
- bgpLSAttrib = BgpPrefixAttrOpaqueData.read(tempCb);
- break;
-
- default:
- throw new BgpParseException(
- "The Bgp-LS Attribute is not supported : "
- + tlvCodePoint);
- }
-
- linkStateAttribList.add(bgpLSAttrib);
- }
- return new LinkStateAttributes(linkStateAttribList);
- }
-
- @Override
- public short getType() {
- return LINKSTATE_ATTRIB_TYPE;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("linkStateAttribList", linkStateAttribList).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LocalPref.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LocalPref.java
deleted file mode 100644
index 36793c18..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LocalPref.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.util.Constants;
-import org.onosproject.bgpio.util.Validation;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides implementation of LocalPref BGP Path Attribute.
- */
-public class LocalPref implements BgpValueType {
- public static final byte LOCAL_PREF_TYPE = 5;
- public static final byte LOCAL_PREF_MAX_LEN = 4;
-
- private int localPref;
-
- /**
- * Constructor to initialize LocalPref.
- *
- * @param localPref local preference
- */
- public LocalPref(int localPref) {
- this.localPref = localPref;
- }
-
- /**
- * Returns local preference value.
- *
- * @return local preference value
- */
- public int localPref() {
- return this.localPref;
- }
-
- /**
- * Reads the channel buffer and returns object of LocalPref.
- *
- * @param cb channelBuffer
- * @return object of LocalPref
- * @throws BgpParseException while parsing localPref attribute
- */
- public static LocalPref read(ChannelBuffer cb) throws BgpParseException {
- int localPref;
- ChannelBuffer tempCb = cb.copy();
- Validation parseFlags = Validation.parseAttributeHeader(cb);
- if ((parseFlags.getLength() > LOCAL_PREF_MAX_LEN) || cb.readableBytes() < parseFlags.getLength()) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- parseFlags.getLength());
- }
-
- int len = parseFlags.isShort() ? parseFlags.getLength() +
- Constants.TYPE_AND_LEN_AS_SHORT : parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
- ChannelBuffer data = tempCb.readBytes(len);
- if (parseFlags.getFirstBit()) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
- }
-
- localPref = cb.readInt();
- return new LocalPref(localPref);
- }
-
- @Override
- public short getType() {
- return LOCAL_PREF_TYPE;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(localPref);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LocalPref) {
- LocalPref other = (LocalPref) obj;
- return Objects.equals(localPref, other.localPref);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("localPref", localPref)
- .toString();
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- //Not to implement as of now
- return 0;
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Med.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Med.java
deleted file mode 100644
index 7f1ab53f..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Med.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.util.Constants;
-import org.onosproject.bgpio.util.Validation;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Implementation of Med BGP Path Attribute.
- */
-public class Med implements BgpValueType {
- public static final byte MED_TYPE = 4;
- public static final byte MED_MAX_LEN = 4;
-
- private int med;
-
- /**
- * Constructor to initialize med.
- *
- * @param med MULTI_EXIT_DISC value
- */
- public Med(int med) {
- this.med = med;
- }
-
- /**
- * Returns Med value.
- *
- * @return Med value
- */
- public int med() {
- return this.med;
- }
-
- /**
- * Reads the channel buffer and returns object of Med.
- *
- * @param cb ChannelBuffer
- * @return object of Med
- * @throws BgpParseException while parsing Med path attribute
- */
- public static Med read(ChannelBuffer cb) throws BgpParseException {
- int med;
- ChannelBuffer tempCb = cb.copy();
- Validation parseFlags = Validation.parseAttributeHeader(cb);
-
- if ((parseFlags.getLength() > MED_MAX_LEN) || cb.readableBytes() < parseFlags.getLength()) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- parseFlags.getLength());
- }
- int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags
- .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
- ChannelBuffer data = tempCb.readBytes(len);
- if (!parseFlags.getFirstBit() && parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
- }
-
- med = cb.readInt();
- return new Med(med);
- }
-
- @Override
- public short getType() {
- return MED_TYPE;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(med);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof Med) {
- Med other = (Med) obj;
- return Objects.equals(med, other.med);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("med", med)
- .toString();
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- //Not to implement as of now
- return 0;
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpReachNlri.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpReachNlri.java
deleted file mode 100644
index 2e4e6599..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpReachNlri.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.types;
-
-import java.net.InetAddress;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpLSNlri;
-import org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-import org.onosproject.bgpio.util.Constants;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/*
- * Provides Implementation of MpReach Nlri BGP Path Attribute.
- */
-public class MpReachNlri implements BgpValueType {
-
- private static final Logger log = LoggerFactory.getLogger(MpReachNlri.class);
- public static final byte MPREACHNLRI_TYPE = 14;
- public static final byte LINK_NLRITYPE = 2;
-
- private boolean isMpReachNlri = false;
- private final List<BgpLSNlri> mpReachNlri;
- private final int length;
- private final short afi;
- private final byte safi;
- private final Ip4Address ipNextHop;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param mpReachNlri MpReach Nlri attribute
- * @param afi address family identifier
- * @param safi subsequent address family identifier
- * @param ipNextHop nexthop IpAddress
- * @param length of MpReachNlri
- */
- public MpReachNlri(List<BgpLSNlri> mpReachNlri, short afi, byte safi, Ip4Address ipNextHop, int length) {
- this.mpReachNlri = mpReachNlri;
- this.isMpReachNlri = true;
- this.ipNextHop = ipNextHop;
- this.afi = afi;
- this.safi = safi;
- this.length = length;
- }
-
- /**
- * Returns whether MpReachNlri is present.
- *
- * @return whether MpReachNlri is present
- */
- public boolean isMpReachNlriSet() {
- return this.isMpReachNlri;
- }
-
- /**
- * Returns list of MpReach Nlri.
- *
- * @return list of MpReach Nlri
- */
- public List<BgpLSNlri> mpReachNlri() {
- return this.mpReachNlri;
- }
-
- /**
- * Returns length of MpReachNlri.
- *
- * @return length of MpReachNlri
- */
- public int mpReachNlriLen() {
- return this.length;
- }
-
- /**
- * Reads from ChannelBuffer and parses MpReachNlri.
- *
- * @param cb channelBuffer
- * @return object of MpReachNlri
- * @throws BgpParseException while parsing MpReachNlri
- */
- public static MpReachNlri read(ChannelBuffer cb) throws BgpParseException {
- ChannelBuffer tempBuf = cb.copy();
- Validation parseFlags = Validation.parseAttributeHeader(cb);
- int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT :
- parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
- ChannelBuffer data = tempBuf.readBytes(len);
-
- if (cb.readableBytes() < parseFlags.getLength()) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- parseFlags.getLength());
- }
- if (!parseFlags.getFirstBit() && parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
- }
-
- BgpLSNlri bgpLSNlri = null;
- List<BgpLSNlri> mpReachNlri = new LinkedList<>();
- ChannelBuffer tempCb = cb.readBytes(parseFlags.getLength());
- short afi = 0;
- byte safi = 0;
- Ip4Address ipNextHop = null;
- while (tempCb.readableBytes() > 0) {
- afi = tempCb.readShort();
- safi = tempCb.readByte();
-
- //Supporting for AFI 16388 / SAFI 71 and VPN AFI 16388 / SAFI 128
- if ((afi == Constants.AFI_VALUE) && (safi == Constants.SAFI_VALUE) || (afi == Constants.AFI_VALUE)
- && (safi == Constants.VPN_SAFI_VALUE)) {
- byte nextHopLen = tempCb.readByte();
- InetAddress ipAddress = Validation.toInetAddress(nextHopLen, tempCb);
- if (ipAddress.isMulticastAddress()) {
- throw new BgpParseException("Multicast not supported");
- }
- ipNextHop = Ip4Address.valueOf(ipAddress);
- byte reserved = tempCb.readByte();
-
- while (tempCb.readableBytes() > 0) {
- short nlriType = tempCb.readShort();
- short totNlriLen = tempCb.readShort();
- if (tempCb.readableBytes() < totNlriLen) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
- }
- tempBuf = tempCb.readBytes(totNlriLen);
- switch (nlriType) {
- case BgpNodeLSNlriVer4.NODE_NLRITYPE:
- bgpLSNlri = BgpNodeLSNlriVer4.read(tempBuf, afi, safi);
- break;
- case BgpLinkLsNlriVer4.LINK_NLRITYPE:
- bgpLSNlri = BgpLinkLsNlriVer4.read(tempBuf, afi, safi);
- break;
- case BgpPrefixIPv4LSNlriVer4.PREFIX_IPV4_NLRITYPE:
- bgpLSNlri = BgpPrefixIPv4LSNlriVer4.read(tempBuf, afi, safi);
- break;
- default:
- log.debug("nlriType not supported" + nlriType);
- }
- mpReachNlri.add(bgpLSNlri);
- }
- } else {
- throw new BgpParseException("Not Supporting afi " + afi + "safi " + safi);
- }
- }
- return new MpReachNlri(mpReachNlri, afi, safi, ipNextHop, parseFlags.getLength());
- }
-
- @Override
- public short getType() {
- return MPREACHNLRI_TYPE;
- }
-
- /**
- * Returns AFI.
- *
- * @return AFI
- */
- public short afi() {
- return this.afi;
- }
-
- /**
- * Returns Nexthop IpAddress.
- *
- * @return Nexthop IpAddress
- */
- public Ip4Address nexthop4() {
- return this.ipNextHop;
- }
-
- /**
- * Returns SAFI.
- *
- * @return SAFI
- */
- public byte safi() {
- return this.safi;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- //Not to be Implemented as of now
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("mpReachNlri", mpReachNlri)
- .add("afi", afi)
- .add("safi", safi)
- .add("ipNextHop", ipNextHop)
- .add("length", length)
- .toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpUnReachNlri.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpUnReachNlri.java
deleted file mode 100644
index f354b3ea..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpUnReachNlri.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.types;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpLSNlri;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-import org.onosproject.bgpio.util.Constants;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Implementation of MpUnReach Nlri BGP Path Attribute.
- */
-public class MpUnReachNlri implements BgpValueType {
-
- private static final Logger log = LoggerFactory.getLogger(MpUnReachNlri.class);
- public static final byte MPUNREACHNLRI_TYPE = 15;
- public static final byte LINK_NLRITYPE = 2;
-
- private boolean isMpUnReachNlri = false;
- private final short afi;
- private final byte safi;
- private final List<BgpLSNlri> mpUnReachNlri;
- private final int length;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param mpUnReachNlri MpUnReach Nlri attribute
- * @param afi address family identifier
- * @param safi subsequent address family identifier
- * @param length of MpUnReachNlri
- */
- public MpUnReachNlri(List<BgpLSNlri> mpUnReachNlri, short afi, byte safi,
- int length) {
- this.mpUnReachNlri = mpUnReachNlri;
- this.isMpUnReachNlri = true;
- this.afi = afi;
- this.safi = safi;
- this.length = length;
- }
-
- /**
- * Reads from ChannelBuffer and parses MpUnReachNlri.
- *
- * @param cb ChannelBuffer
- * @return object of MpUnReachNlri
- * @throws BgpParseException while parsing MpUnReachNlri
- */
- public static MpUnReachNlri read(ChannelBuffer cb) throws BgpParseException {
- ChannelBuffer tempBuf = cb.copy();
- Validation parseFlags = Validation.parseAttributeHeader(cb);
- int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT
- : parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
- ChannelBuffer data = tempBuf.readBytes(len);
-
- if (!parseFlags.getFirstBit() && parseFlags.getSecondBit()
- && parseFlags.getThirdBit()) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
- }
-
- if (cb.readableBytes() < parseFlags.getLength()) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR, parseFlags.getLength());
- }
-
- LinkedList<BgpLSNlri> mpUnReachNlri = new LinkedList<>();
- BgpLSNlri bgpLSNlri = null;
- short afi = 0;
- byte safi = 0;
- ChannelBuffer tempCb = cb.readBytes(parseFlags.getLength());
- while (tempCb.readableBytes() > 0) {
- afi = tempCb.readShort();
- safi = tempCb.readByte();
-
- //Supporting only for AFI 16388 / SAFI 71
- if ((afi == Constants.AFI_VALUE) && (safi == Constants.SAFI_VALUE)
- || (afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
- while (tempCb.readableBytes() > 0) {
- short nlriType = tempCb.readShort();
- short totNlriLen = tempCb.readShort();
- if (tempCb.readableBytes() < totNlriLen) {
- Validation.validateLen(
- BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
- }
- tempBuf = tempCb.readBytes(totNlriLen);
- switch (nlriType) {
- case BgpNodeLSNlriVer4.NODE_NLRITYPE:
- bgpLSNlri = BgpNodeLSNlriVer4.read(tempBuf, afi, safi);
- break;
- case BgpLinkLsNlriVer4.LINK_NLRITYPE:
- bgpLSNlri = BgpLinkLsNlriVer4.read(tempBuf, afi, safi);
- break;
- case BgpPrefixIPv4LSNlriVer4.PREFIX_IPV4_NLRITYPE:
- bgpLSNlri = BgpPrefixIPv4LSNlriVer4.read(tempBuf, afi,
- safi);
- break;
- default:
- log.debug("nlriType not supported" + nlriType);
- }
- mpUnReachNlri.add(bgpLSNlri);
- }
- } else {
- //TODO: check with the values got from capability
- throw new BgpParseException("Not Supporting afi " + afi
- + "safi " + safi);
- }
- }
- return new MpUnReachNlri(mpUnReachNlri, afi, safi,
- parseFlags.getLength());
- }
-
- @Override
- public short getType() {
- return MPUNREACHNLRI_TYPE;
- }
-
- /**
- * Returns SAFI.
- *
- * @return SAFI
- */
- public byte safi() {
- return this.safi;
- }
-
- /**
- * Returns AFI.
- *
- * @return AFI
- */
- public short afi() {
- return this.afi;
- }
-
- /**
- * Returns list of MpUnReach Nlri.
- *
- * @return list of MpUnReach Nlri
- */
- public List<BgpLSNlri> mpUnReachNlri() {
- return this.mpUnReachNlri;
- }
-
- /**
- * Returns whether MpReachNlri is present.
- *
- * @return whether MpReachNlri is present
- */
- public boolean isMpUnReachNlriSet() {
- return this.isMpUnReachNlri;
- }
-
- /**
- * Returns length of MpUnReach.
- *
- * @return length of MpUnReach
- */
- public int mpUnReachNlriLen() {
- return this.length;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- //Not to be Implemented as of now
- return 0;
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("mpReachNlri", mpUnReachNlri)
- .add("afi", afi)
- .add("safi", safi)
- .add("length", length)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java
deleted file mode 100644
index 7082483e..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.Objects;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides MultiProtocolExtnCapabilityTlv.
- */
-public class MultiProtocolExtnCapabilityTlv implements BgpValueType {
-
- /*
- 0 7 15 23 31
- +-------+-------+-------+-------+
- | AFI | Res | SAFI |
- +-------+-------+-------+-------+
-
- Multiprotocol Extensions CAPABILITY TLV format
- REFERENCE : RFC 4760
- */
- protected static final Logger log = LoggerFactory
- .getLogger(MultiProtocolExtnCapabilityTlv.class);
-
- public static final byte TYPE = 1;
- public static final byte LENGTH = 4;
-
- private final short afi;
- private final byte res;
- private final byte safi;
-
- /**
- * Constructor to initialize variables.
- * @param afi Address Family Identifiers
- * @param res reserved field
- * @param safi Subsequent Address Family Identifier
- */
- public MultiProtocolExtnCapabilityTlv(short afi, byte res, byte safi) {
- this.afi = afi;
- this.res = res;
- this.safi = safi;
- }
-
- /**
- * Returns object of MultiProtocolExtnCapabilityTlv.
- * @param afi Address Family Identifiers
- * @param res reserved field
- * @param safi Subsequent Address Family Identifier
- * @return object of MultiProtocolExtnCapabilityTlv
- */
- public static MultiProtocolExtnCapabilityTlv of(short afi, byte res,
- byte safi) {
- return new MultiProtocolExtnCapabilityTlv(afi, res, safi);
- }
-
- /**
- * Returns afi Address Family Identifiers value.
- * @return afi Address Family Identifiers value
- */
- public short getAFI() {
- return afi;
- }
-
- /**
- * Returns res reserved field value.
- * @return res reserved field value
- */
- public byte getRes() {
- return res;
- }
-
- /**
- * Returns safi Subsequent Address Family Identifier value.
- * @return safi Subsequent Address Family Identifier value
- */
- public byte getSAFI() {
- return safi;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(afi, res, safi);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof MultiProtocolExtnCapabilityTlv) {
- MultiProtocolExtnCapabilityTlv other = (MultiProtocolExtnCapabilityTlv) obj;
- return Objects.equals(this.afi, other.afi)
- && Objects.equals(this.res, other.res)
- && Objects.equals(this.safi, other.safi);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- int iLenStartIndex = cb.writerIndex();
- cb.writeByte(TYPE);
- cb.writeByte(LENGTH);
-
- // write afi
- cb.writeShort(afi);
-
- // write res
- cb.writeByte(res);
-
- // write safi
- cb.writeByte(safi);
-
- return cb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads from channel buffer and returns object of MultiprotocolCapabilityTlv.
- * @param cb of type channel buffer
- * @return object of MultiProtocolExtnCapabilityTlv
- */
- public static BgpValueType read(ChannelBuffer cb) {
- short afi = cb.readShort();
- byte res = cb.readByte();
- byte safi = cb.readByte();
- return new MultiProtocolExtnCapabilityTlv(afi, res, safi);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("AFI", afi)
- .add("Reserved", res)
- .add("SAFI", safi).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/NextHop.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/NextHop.java
deleted file mode 100644
index 806efe52..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/NextHop.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.net.InetAddress;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.util.Constants;
-import org.onosproject.bgpio.util.Validation;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
-
-/**
- * Implementation of NextHop BGP Path Attribute.
- */
-public class NextHop implements BgpValueType {
- public static final byte NEXTHOP_TYPE = 3;
-
- private boolean isNextHop = false;
- private Ip4Address nextHop;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param nextHop nextHop address
- */
- public NextHop(Ip4Address nextHop) {
- this.nextHop = Preconditions.checkNotNull(nextHop);
- this.isNextHop = true;
- }
-
- /**
- * Returns whether next hop is present.
- *
- * @return whether next hop is present
- */
- public boolean isNextHopSet() {
- return this.isNextHop;
- }
-
- /**
- * Reads from ChannelBuffer and parses NextHop.
- *
- * @param cb ChannelBuffer
- * @return object of NextHop
- * @throws BgpParseException while parsing nexthop attribute
- */
- public static NextHop read(ChannelBuffer cb) throws BgpParseException {
- Ip4Address nextHop;
- ChannelBuffer tempCb = cb.copy();
- Validation parseFlags = Validation.parseAttributeHeader(cb);
-
- if (cb.readableBytes() < parseFlags.getLength()) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- parseFlags.getLength());
- }
- int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags
- .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
- ChannelBuffer data = tempCb.readBytes(len);
- if (parseFlags.getFirstBit() && !parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
- }
-
- InetAddress ipAddress = Validation.toInetAddress(parseFlags.getLength(), cb);
- if (ipAddress.isMulticastAddress()) {
- throw new BgpParseException("Multicast address is not supported");
- }
-
- nextHop = Ip4Address.valueOf(ipAddress);
- return new NextHop(nextHop);
- }
-
- /**
- * Return nexthop address.
- *
- * @return nexthop address
- */
- public Ip4Address nextHop() {
- return nextHop;
- }
-
- @Override
- public short getType() {
- return NEXTHOP_TYPE;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- //Not required to be implemented now
- return 0;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(nextHop);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof NextHop) {
- NextHop other = (NextHop) obj;
- return Objects.equals(nextHop, other.nextHop);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("nextHop", nextHop)
- .toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java
deleted file mode 100644
index d281a4ef..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.protocol.IGPRouterID;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides implementation of OSPFNonPseudonode Tlv.
- */
-public class OSPFNonPseudonode implements IGPRouterID, BgpValueType {
- public static final short TYPE = 515;
- public static final short LENGTH = 4;
-
- private final int routerID;
-
- /**
- * Constructor to initialize routerID.
- *
- * @param routerID routerID
- */
- public OSPFNonPseudonode(int routerID) {
- this.routerID = routerID;
- }
-
- /**
- * Returns object of this class with specified routerID.
- *
- * @param routerID routerID
- * @return object of OSPFNonPseudonode
- */
- public static OSPFNonPseudonode of(final int routerID) {
- return new OSPFNonPseudonode(routerID);
- }
-
- /**
- * Returns RouterID.
- *
- * @return RouterID
- */
- public int getrouterID() {
- return this.routerID;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(routerID);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof OSPFNonPseudonode) {
- OSPFNonPseudonode other = (OSPFNonPseudonode) obj;
- return Objects.equals(routerID, other.routerID);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(routerID);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of OSPFNonPseudonode.
- *
- * @param cb ChannelBuffer
- * @return object of OSPFNonPseudonode
- */
- public static OSPFNonPseudonode read(ChannelBuffer cb) {
- return OSPFNonPseudonode.of(cb.readInt());
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- return ((Integer) (this.routerID)).compareTo((Integer) (((OSPFNonPseudonode) o).routerID));
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("RouterID", routerID)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java
deleted file mode 100644
index 0d17651a..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.bgpio.protocol.IGPRouterID;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides implementation of OSPFPseudonode Tlv.
- */
-public class OSPFPseudonode implements IGPRouterID, BgpValueType {
- public static final short TYPE = 515;
- public static final short LENGTH = 8;
-
- private final int routerID;
- private final Ip4Address drInterface;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param routerID routerID
- * @param drInterface IPv4 address of the DR's interface
- */
- public OSPFPseudonode(int routerID, Ip4Address drInterface) {
- this.routerID = routerID;
- this.drInterface = drInterface;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param routerID routerID
- * @param drInterface IPv4 address of the DR's interface
- * @return object of OSPFPseudonode
- */
- public static OSPFPseudonode of(final int routerID, final Ip4Address drInterface) {
- return new OSPFPseudonode(routerID, drInterface);
- }
-
- /**
- * Returns RouterID.
- *
- * @return RouterID
- */
- public int getrouterID() {
- return this.routerID;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(routerID, drInterface);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof OSPFPseudonode) {
- OSPFPseudonode other = (OSPFPseudonode) obj;
- return Objects.equals(routerID, other.routerID) && Objects.equals(drInterface, other.drInterface);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(routerID);
- c.writeInt(drInterface.toInt());
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of OSPFPseudonode.
- *
- * @param cb ChannelBuffer
- * @return object of OSPFPseudonode
- */
- public static OSPFPseudonode read(ChannelBuffer cb) {
- int routerID = cb.readInt();
- Ip4Address drInterface = Ip4Address.valueOf(cb.readInt());
- return OSPFPseudonode.of(routerID, drInterface);
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- int result = ((Integer) (this.routerID)).compareTo((Integer) (((OSPFPseudonode) o).routerID));
- if (result != 0) {
- return this.drInterface.compareTo(((OSPFPseudonode) o).drInterface);
- }
- return result;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("RouterID", routerID)
- .add("DRInterface", drInterface)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.java
deleted file mode 100644
index be321c95..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides OSPF Route Type Tlv which contains route type.
- */
-public class OSPFRouteTypeTlv implements BgpValueType {
-
- /* Reference :draft-ietf-idr-ls-distribution-11
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Route Type |
- +-+-+-+-+-+-+-+-+
-
- Figure : OSPF Route Type TLV Format
- */
-
- public static final short TYPE = 264;
- public static final short LENGTH = 1;
- public static final int INTRA_AREA_TYPE = 1;
- public static final short INTER_AREA_TYPE = 2;
- public static final short EXTERNAL_TYPE_1 = 3;
- public static final short EXTERNAL_TYPE_2 = 4;
- public static final short NSSA_TYPE_1 = 5;
- public static final short NSSA_TYPE_2 = 6;
-
- private final byte routeType;
-
- /**
- * Enum for Route Type.
- */
- public enum RouteType {
- Intra_Area(1), Inter_Area(2), External_1(3), External_2(4), NSSA_1(5), NSSA_2(6);
- int value;
- RouteType(int val) {
- value = val;
- }
- public byte getType() {
- return (byte) value;
- }
- }
-
- /**
- * Constructor to initialize routeType.
- *
- * @param routeType Route type
- */
- public OSPFRouteTypeTlv(byte routeType) {
- this.routeType = routeType;
- }
-
- /**
- * Returns object of this class with specified routeType.
- *
- * @param routeType Route type
- * @return object of OSPFRouteTypeTlv
- */
- public static OSPFRouteTypeTlv of(final byte routeType) {
- return new OSPFRouteTypeTlv(routeType);
- }
-
- /**
- * Returns RouteType.
- *
- * @return RouteType
- * @throws BgpParseException if routeType is not matched
- */
- public RouteType getValue() throws BgpParseException {
- switch (routeType) {
- case INTRA_AREA_TYPE:
- return RouteType.Intra_Area;
- case INTER_AREA_TYPE:
- return RouteType.Inter_Area;
- case EXTERNAL_TYPE_1:
- return RouteType.External_1;
- case EXTERNAL_TYPE_2:
- return RouteType.External_2;
- case NSSA_TYPE_1:
- return RouteType.NSSA_1;
- case NSSA_TYPE_2:
- return RouteType.NSSA_2;
- default:
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
- }
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(routeType);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof OSPFRouteTypeTlv) {
- OSPFRouteTypeTlv other = (OSPFRouteTypeTlv) obj;
- return Objects.equals(routeType, other.routeType);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeByte(routeType);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads from ChannelBuffer and parses OSPFRouteTypeTlv.
- *
- * @param cb channelBuffer
- * @return object of OSPFRouteTypeTlv
- */
- public static OSPFRouteTypeTlv read(ChannelBuffer cb) {
- return OSPFRouteTypeTlv.of(cb.readByte());
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- return ((Byte) (this.routeType)).compareTo((Byte) (((OSPFRouteTypeTlv) o).routeType));
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", routeType)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Origin.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Origin.java
deleted file mode 100644
index d642d83c..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Origin.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.util.Constants;
-import org.onosproject.bgpio.util.Validation;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Implementation of mandatory BGP Origin path attribute.
- */
-public class Origin implements BgpValueType {
-
- /**
- * Enum to provide ORIGIN types.
- */
- public enum ORIGINTYPE {
- IGP(0), EGP(1), INCOMPLETE(2);
- int value;
- /**
- * Assign val with the value as the ORIGIN type.
- *
- * @param val ORIGIN type
- */
- ORIGINTYPE(int val) {
- value = val;
- }
-
- /**
- * Returns value of ORIGIN type.
- *
- * @return ORIGIN type
- */
- public byte getType() {
- return (byte) value;
- }
- }
-
- public static final byte ORIGIN_TYPE = 1;
- public static final byte ORIGIN_VALUE_LEN = 1;
-
- private boolean isOrigin = false;
- private byte origin;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param origin origin value
- */
- public Origin(byte origin) {
- this.origin = origin;
- this.isOrigin = true;
- }
-
- /**
- * Returns true if origin attribute is present otherwise false.
- *
- * @return whether origin is present or not
- */
- public boolean isOriginSet() {
- return this.isOrigin;
- }
-
- /**
- * Returns type of Origin in Enum values.
- *
- * @return type of Origin in Enum values
- */
- public ORIGINTYPE origin() {
- if (this.origin == 0) {
- return ORIGINTYPE.IGP;
- } else if (this.origin == 1) {
- return ORIGINTYPE.EGP;
- } else {
- return ORIGINTYPE.INCOMPLETE;
- }
- }
-
- /**
- * Reads from ChannelBuffer and parses Origin.
- *
- * @param cb ChannelBuffer
- * @return object of Origin
- * @throws BgpParseException while parsing Origin path attribute
- */
- public static Origin read(ChannelBuffer cb) throws BgpParseException {
- ChannelBuffer tempCb = cb.copy();
- Validation parseFlags = Validation.parseAttributeHeader(cb);
-
- int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags
- .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
- ChannelBuffer data = tempCb.readBytes(len);
- if ((parseFlags.getLength() > ORIGIN_VALUE_LEN) || (cb.readableBytes() < parseFlags.getLength())) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- parseFlags.getLength());
- }
- if (parseFlags.getFirstBit() && !parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
- }
-
- byte originValue;
- originValue = cb.readByte();
- if ((originValue != ORIGINTYPE.INCOMPLETE.value) && (originValue != ORIGINTYPE.IGP.value) &&
- (originValue != ORIGINTYPE.EGP.value)) {
- throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.INVALID_ORIGIN_ATTRIBUTE, data);
- }
- return new Origin(originValue);
- }
-
- @Override
- public short getType() {
- return ORIGIN_TYPE;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- //Not required to Implement as of now
- return 0;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(origin);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof Origin) {
- Origin other = (Origin) obj;
- return Objects.equals(origin, other.origin);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("origin", origin)
- .toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java
deleted file mode 100644
index 37632ad8..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implementation of RouteDistinguisher.
- */
-public class RouteDistinguisher implements Comparable<RouteDistinguisher> {
-
- private long routeDistinguisher;
-
- /**
- * Resets fields.
- */
- public RouteDistinguisher() {
- this.routeDistinguisher = 0;
- }
-
- /**
- * Constructor to initialize parameters.
- *
- * @param routeDistinguisher route distinguisher
- */
- public RouteDistinguisher(long routeDistinguisher) {
- this.routeDistinguisher = routeDistinguisher;
- }
-
- /**
- * Reads route distinguisher from channelBuffer.
- *
- * @param cb channelBuffer
- * @return object of RouteDistinguisher
- */
- public static RouteDistinguisher read(ChannelBuffer cb) {
- return new RouteDistinguisher(cb.readLong());
- }
-
- /**
- * Returns route distinguisher.
- *
- * @return route distinguisher
- */
- public long getRouteDistinguisher() {
- return this.routeDistinguisher;
- }
-
- @Override
- public int compareTo(RouteDistinguisher rd) {
- if (this.equals(rd)) {
- return 0;
- }
- return ((Long) (this.getRouteDistinguisher())).compareTo((Long) (rd.getRouteDistinguisher()));
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("routeDistinguisher", routeDistinguisher)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java
deleted file mode 100755
index e0fef7c8..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP attribute node flag.
- */
-public final class BgpAttrNodeFlagBitTlv implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpAttrNodeFlagBitTlv.class);
-
- public static final int ATTRNODE_FLAGBIT = 1024;
-
- /* Node flag bit TLV */
- private final boolean bOverloadBit;
- private final boolean bAttachedBit;
- private final boolean bExternalBit;
- private final boolean bAbrBit;
-
- public static final byte FIRST_BIT = (byte) 0x80;
- public static final byte SECOND_BIT = 0x40;
- public static final byte THIRD_BIT = 0x20;
- public static final byte FOURTH_BIT = 0x01;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param bOverloadBit Overload bit
- * @param bAttachedBit Attached bit
- * @param bExternalBit External bit
- * @param bAbrBit ABR Bit
- */
- private BgpAttrNodeFlagBitTlv(boolean bOverloadBit, boolean bAttachedBit,
- boolean bExternalBit, boolean bAbrBit) {
- this.bOverloadBit = bOverloadBit;
- this.bAttachedBit = bAttachedBit;
- this.bExternalBit = bExternalBit;
- this.bAbrBit = bAbrBit;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param bOverloadBit Overload bit
- * @param bAttachedBit Attached bit
- * @param bExternalBit External bit
- * @param bAbrBit ABR Bit
- * @return object of BgpAttrNodeFlagBitTlv
- */
- public static BgpAttrNodeFlagBitTlv of(final boolean bOverloadBit,
- final boolean bAttachedBit,
- final boolean bExternalBit,
- final boolean bAbrBit) {
- return new BgpAttrNodeFlagBitTlv(bOverloadBit, bAttachedBit,
- bExternalBit, bAbrBit);
- }
-
- /**
- * Reads the Node Flag Bits.
- *
- * @param cb ChannelBuffer
- * @return attribute node flag bit tlv
- * @throws BgpParseException while parsing BgpAttrNodeFlagBitTlv
- */
- public static BgpAttrNodeFlagBitTlv read(ChannelBuffer cb)
- throws BgpParseException {
- boolean bOverloadBit = false;
- boolean bAttachedBit = false;
- boolean bExternalBit = false;
- boolean bAbrBit = false;
-
- short lsAttrLength = cb.readShort();
-
- if ((lsAttrLength != 1) || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- byte nodeFlagBits = cb.readByte();
-
- bOverloadBit = ((nodeFlagBits & FIRST_BIT) == FIRST_BIT);
- bAttachedBit = ((nodeFlagBits & SECOND_BIT) == SECOND_BIT);
- bExternalBit = ((nodeFlagBits & THIRD_BIT) == THIRD_BIT);
- bAbrBit = ((nodeFlagBits & FOURTH_BIT) == FOURTH_BIT);
-
- return BgpAttrNodeFlagBitTlv.of(bOverloadBit, bAttachedBit,
- bExternalBit, bAbrBit);
- }
-
- /**
- * Returns Overload Bit.
- *
- * @return Overload Bit
- */
- public boolean overLoadBit() {
- return bOverloadBit;
- }
-
- /**
- * Returns Attached Bit.
- *
- * @return Attached Bit
- */
- public boolean attachedBit() {
- return bAttachedBit;
- }
-
- /**
- * Returns External Bit.
- *
- * @return External Bit
- */
- public boolean externalBit() {
- return bExternalBit;
- }
-
- /**
- * Returns ABR Bit.
- *
- * @return ABR Bit
- */
- public boolean abrBit() {
- return bAbrBit;
- }
-
- @Override
- public short getType() {
- return ATTRNODE_FLAGBIT;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(bOverloadBit, bAttachedBit, bExternalBit, bAbrBit);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpAttrNodeFlagBitTlv) {
- BgpAttrNodeFlagBitTlv other = (BgpAttrNodeFlagBitTlv) obj;
- return Objects.equals(bOverloadBit, other.bOverloadBit)
- && Objects.equals(bAttachedBit, other.bAttachedBit)
- && Objects.equals(bExternalBit, other.bExternalBit)
- && Objects.equals(bAbrBit, other.bAbrBit);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("bOverloadBit", bOverloadBit)
- .add("bAttachedBit", bAttachedBit)
- .add("bExternalBit", bExternalBit).add("bAbrBit", bAbrBit)
- .toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeIsIsAreaId.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeIsIsAreaId.java
deleted file mode 100644
index 0435a65f..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeIsIsAreaId.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP attribute ISIS Area Identifier.
- */
-public class BgpAttrNodeIsIsAreaId implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpAttrNodeIsIsAreaId.class);
-
- public static final int ATTRNODE_ISISAREAID = 1027;
-
- /* IS-IS Area Identifier TLV */
- private byte[] isisAreaId;
-
- /**
- * Constructor to initialize value.
- *
- * @param isisAreaId ISIS area Identifier
- */
- public BgpAttrNodeIsIsAreaId(byte[] isisAreaId) {
- this.isisAreaId = Arrays.copyOf(isisAreaId, isisAreaId.length);
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param isisAreaId ISIS area Identifier
- * @return object of BgpAttrNodeIsIsAreaId
- */
- public static BgpAttrNodeIsIsAreaId of(final byte[] isisAreaId) {
- return new BgpAttrNodeIsIsAreaId(isisAreaId);
- }
-
- /**
- * Reads the IS-IS Area Identifier.
- *
- * @param cb ChannelBuffer
- * @return object of BgpAttrNodeIsIsAreaId
- * @throws BgpParseException while parsing BgpAttrNodeIsIsAreaId
- */
- public static BgpAttrNodeIsIsAreaId read(ChannelBuffer cb)
- throws BgpParseException {
- byte[] isisAreaId;
-
- short lsAttrLength = cb.readShort();
-
- if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- isisAreaId = new byte[lsAttrLength];
- cb.readBytes(isisAreaId);
-
- return BgpAttrNodeIsIsAreaId.of(isisAreaId);
- }
-
- /**
- * Returns ISIS area Identifier.
- *
- * @return Area ID
- */
- public byte[] attrNodeIsIsAreaId() {
- return isisAreaId;
- }
-
- @Override
- public short getType() {
- return ATTRNODE_ISISAREAID;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(isisAreaId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpAttrNodeIsIsAreaId) {
- BgpAttrNodeIsIsAreaId other = (BgpAttrNodeIsIsAreaId) obj;
- return Arrays.equals(isisAreaId, other.isisAreaId);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("isisAreaId", isisAreaId).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java
deleted file mode 100644
index 31d855db..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * BGP Multi-Topology ID of the LS attribute.
- */
-public class BgpAttrNodeMultiTopologyId implements BgpValueType {
-
- private static final Logger log = LoggerFactory
- .getLogger(BgpAttrNodeMultiTopologyId.class);
-
- public static final int ATTRNODE_MULTITOPOLOGY = 263;
-
- /* Opaque Node Attribute */
- private List<Short> multiTopologyId = new ArrayList<Short>();
-
- /**
- * Constructor to initialize the Node attribute multi-topology ID.
- *
- * @param multiTopologyId multi-topology ID
- */
- public BgpAttrNodeMultiTopologyId(List<Short> multiTopologyId) {
- this.multiTopologyId = multiTopologyId;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param multiTopologyId Prefix Metric
- * @return object of BgpAttrNodeMultiTopologyId
- */
- public static BgpAttrNodeMultiTopologyId of(ArrayList<Short> multiTopologyId) {
- return new BgpAttrNodeMultiTopologyId(multiTopologyId);
- }
-
- /**
- * Reads the Multi-topology ID of Node attribute.
- *
- * @param cb ChannelBuffer
- * @return Constructor of BgpAttrNodeMultiTopologyId
- * @throws BgpParseException while parsing BgpAttrNodeMultiTopologyId
- */
- public static BgpAttrNodeMultiTopologyId read(ChannelBuffer cb)
- throws BgpParseException {
- ArrayList<Short> multiTopologyId = new ArrayList<Short>();
- short tempMultiTopologyId;
- short lsAttrLength = cb.readShort();
- int len = lsAttrLength / 2; // Length is 2*n and n is the number of MT-IDs
-
- if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- for (int i = 0; i < len; i++) {
- tempMultiTopologyId = cb.readShort();
- multiTopologyId.add(new Short(tempMultiTopologyId));
- }
-
- return new BgpAttrNodeMultiTopologyId(multiTopologyId);
- }
-
- /**
- * to get the multi-topology ID.
- *
- * @return multitopology ID
- */
- public List<Short> attrMultiTopologyId() {
- return multiTopologyId;
- }
-
- @Override
- public short getType() {
- return ATTRNODE_MULTITOPOLOGY;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(multiTopologyId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpAttrNodeMultiTopologyId) {
- BgpAttrNodeMultiTopologyId other = (BgpAttrNodeMultiTopologyId) obj;
- return Objects.equals(multiTopologyId, other.multiTopologyId);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("multiTopologyId", multiTopologyId)
- .toString();
- }
-
- @Override
- public int compareTo(Object o) {
- if (this.equals(o)) {
- return 0;
- }
- int countOtherSubTlv = ((BgpAttrNodeMultiTopologyId) o).multiTopologyId.size();
- int countObjSubTlv = multiTopologyId.size();
- if (countOtherSubTlv != countObjSubTlv) {
- if (countOtherSubTlv > countObjSubTlv) {
- return 1;
- } else {
- return -1;
- }
- }
- ListIterator<Short> listIterator = multiTopologyId.listIterator();
- ListIterator<Short> listIteratorOther = ((BgpAttrNodeMultiTopologyId) o).multiTopologyId.listIterator();
- while (listIterator.hasNext()) {
- short id = listIterator.next();
- short id1 = listIteratorOther.next();
- if (((Short) id).compareTo((Short) id1) != 0) {
- return ((Short) id).compareTo((Short) id1);
- }
- }
- return 0;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
deleted file mode 100644
index 2e1c7a05..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP attribute node name.
- */
-public class BgpAttrNodeName implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpAttrNodeName.class);
-
- public static final int ATTRNODE_NAME = 1026;
-
- /* Node Name */
- private byte[] nodeName;
-
- /**
- * Constructor to initialize value.
- *
- * @param nodeName node name
- */
- public BgpAttrNodeName(byte[] nodeName) {
- this.nodeName = Arrays.copyOf(nodeName, nodeName.length);
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param nodeName node name
- * @return object of BgpAttrNodeName
- */
- public static BgpAttrNodeName of(final byte[] nodeName) {
- return new BgpAttrNodeName(nodeName);
- }
-
- /**
- * Reads the LS attribute node name.
- *
- * @param cb ChannelBuffer
- * @return object of BgpAttrNodeName
- * @throws BgpParseException while parsing BgpAttrNodeName
- */
- public static BgpAttrNodeName read(ChannelBuffer cb)
- throws BgpParseException {
- byte[] nodeName;
-
- short lsAttrLength = cb.readShort();
-
- if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- nodeName = new byte[lsAttrLength];
- cb.readBytes(nodeName);
- return BgpAttrNodeName.of(nodeName);
- }
-
- /**
- * Returns LS attribute node name.
- *
- * @return node name
- */
- public byte[] attrNodeName() {
- return nodeName;
- }
-
- @Override
- public short getType() {
- return ATTRNODE_NAME;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(nodeName);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpAttrNodeName) {
- BgpAttrNodeName other = (BgpAttrNodeName) obj;
- return Arrays.equals(nodeName, other.nodeName);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("nodeName", nodeName).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrOpaqueNode.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrOpaqueNode.java
deleted file mode 100644
index 545755a7..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrOpaqueNode.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP attribute opaque node.
- */
-public class BgpAttrOpaqueNode implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpAttrOpaqueNode.class);
-
- public static final int ATTRNODE_OPAQUEDATA = 1025;
-
- /* Opaque Node Attribute */
- private byte[] opaqueNodeAttribute;
-
- /**
- * Constructor to initialize parameter.
- *
- * @param opaqueNodeAttribute opaque node attribute
- */
- public BgpAttrOpaqueNode(byte[] opaqueNodeAttribute) {
- this.opaqueNodeAttribute = Arrays.copyOf(opaqueNodeAttribute, opaqueNodeAttribute.length);
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param opaqueNodeAttribute Prefix Metric
- * @return object of BgpAttrOpaqueNode
- */
- public static BgpAttrOpaqueNode of(byte[] opaqueNodeAttribute) {
- return new BgpAttrOpaqueNode(opaqueNodeAttribute);
- }
-
- /**
- * Reads the Opaque Node Properties.
- *
- * @param cb ChannelBuffer
- * @return object of BgpAttrOpaqueNode
- * @throws BgpParseException while parsing BgpAttrOpaqueNode
- */
- public static BgpAttrOpaqueNode read(ChannelBuffer cb)
- throws BgpParseException {
-
- byte[] opaqueNodeAttribute;
-
- short lsAttrLength = cb.readShort();
-
- if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- opaqueNodeAttribute = new byte[lsAttrLength];
- cb.readBytes(opaqueNodeAttribute);
-
- return BgpAttrOpaqueNode.of(opaqueNodeAttribute);
- }
-
- /**
- * Returns opaque node attribute.
- *
- * @return LS node attribute value
- */
- public byte[] attrOpaqueNode() {
- return opaqueNodeAttribute;
- }
-
- @Override
- public short getType() {
- return ATTRNODE_OPAQUEDATA;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(opaqueNodeAttribute);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpAttrOpaqueNode) {
- BgpAttrOpaqueNode other = (BgpAttrOpaqueNode) obj;
- return Arrays
- .equals(opaqueNodeAttribute, other.opaqueNodeAttribute);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("opaqueNodeAttribute", opaqueNodeAttribute).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java
deleted file mode 100644
index f3c0d17b..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP attribute node router ID.
- */
-public final class BgpAttrRouterIdV4 implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpAttrRouterIdV4.class);
-
- private final short sType;
-
- /* IPv4 Router-ID of Node */
- private final Ip4Address ip4RouterId;
-
- /**
- * Constructor to initialize the value.
- *
- * @param ip4RouterId IPV4 address of router
- * @param sType TLV type
- */
- private BgpAttrRouterIdV4(Ip4Address ip4RouterId, short sType) {
- this.ip4RouterId = ip4RouterId;
- this.sType = sType;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param ip4RouterId IPv4 address
- * @param sType Type of this TLV
- * @return object of BgpAttrRouterIdV4
- */
- public static BgpAttrRouterIdV4 of(final Ip4Address ip4RouterId,
- final short sType) {
- return new BgpAttrRouterIdV4(ip4RouterId, sType);
- }
-
- /**
- * Reads the IPv4 Router-ID.
- *
- * @param cb ChannelBuffer
- * @param sType tag type
- * @return object of BgpAttrRouterIdV4
- * @throws BgpParseException while parsing BgpAttrRouterIdV4
- */
- public static BgpAttrRouterIdV4 read(ChannelBuffer cb, short sType)
- throws BgpParseException {
- short lsAttrLength = cb.readShort();
-
- if ((lsAttrLength != 4) || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- byte[] ipBytes = new byte[lsAttrLength];
- cb.readBytes(ipBytes, 0, lsAttrLength);
- Ip4Address ip4RouterId = Ip4Address.valueOf(ipBytes);
- return BgpAttrRouterIdV4.of(ip4RouterId, sType);
- }
-
- /**
- * Returns the IPV4 router ID.
- *
- * @return Router ID
- */
- public Ip4Address attrRouterId() {
- return ip4RouterId;
- }
-
- @Override
- public short getType() {
- return sType;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(ip4RouterId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpAttrRouterIdV4) {
- BgpAttrRouterIdV4 other = (BgpAttrRouterIdV4) obj;
- return Objects.equals(ip4RouterId, other.ip4RouterId);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("ip4RouterId", ip4RouterId).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java
deleted file mode 100644
index 648fd56e..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip6Address;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP attribute IPv6 router ID.
- */
-public final class BgpAttrRouterIdV6 implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpAttrRouterIdV6.class);
-
- private final short sType;
-
- /* IPv4 Router-ID of Node */
- private final Ip6Address ip6RouterId;
-
- /**
- * Constructor to initialize the value.
- *
- * @param ip6RouterId IPV6 address of the router ID
- * @param sType TLV type
- */
- private BgpAttrRouterIdV6(Ip6Address ip6RouterId, short sType) {
- this.ip6RouterId = ip6RouterId;
- this.sType = sType;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param ip6RouterId IPV6 address of the router ID
- * @param sType TLV type
- * @return object of BgpAttrRouterIdV6
- */
- public static BgpAttrRouterIdV6 of(final Ip6Address ip6RouterId,
- final short sType) {
- return new BgpAttrRouterIdV6(ip6RouterId, sType);
- }
-
- /**
- * Reads the IPv6 Router-ID.
- *
- * @param cb ChannelBuffer
- * @param sType TLV type
- * @return object of BgpAttrRouterIdV6
- * @throws BgpParseException while parsing BgpAttrRouterIdV6
- */
- public static BgpAttrRouterIdV6 read(ChannelBuffer cb, short sType)
- throws BgpParseException {
- byte[] ipBytes;
- Ip6Address ip6RouterId;
-
- short lsAttrLength = cb.readShort();
-
- if ((lsAttrLength != 16) || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- ipBytes = new byte[lsAttrLength];
- cb.readBytes(ipBytes);
- ip6RouterId = Ip6Address.valueOf(ipBytes);
- return BgpAttrRouterIdV6.of(ip6RouterId, sType);
- }
-
- /**
- * Returns IPV6 router ID.
- *
- * @return Router ID
- */
- public Ip6Address attrRouterId() {
- return ip6RouterId;
- }
-
- @Override
- public short getType() {
- return sType;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(ip6RouterId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpAttrRouterIdV6) {
- BgpAttrRouterIdV6 other = (BgpAttrRouterIdV6) obj;
- return Objects.equals(ip6RouterId, other.ip6RouterId);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("ip6RouterId", ip6RouterId).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetric.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetric.java
deleted file mode 100644
index 5721cf6c..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetric.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP link IGP metric attribute.
- */
-public class BgpLinkAttrIgpMetric implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpLinkAttrIgpMetric.class);
-
- public static final int ATTRLINK_IGPMETRIC = 1095;
- public static final int ATTRLINK_MAX_LEN = 3;
-
- /* Variable metric length based on protocol */
- public static final int ISIS_SMALL_METRIC = 1;
- public static final int OSPF_LINK_METRIC = 2;
- public static final int ISIS_WIDE_METRIC = 3;
-
- /* IGP Metric */
- private final int igpMetric;
- private final int igpMetricLen;
-
- /**
- * Constructor to initialize the value.
- *
- * @param igpMetric 3 byte IGP metric data.
- * @param igpMetricLen length of IGP metric data.
- */
- public BgpLinkAttrIgpMetric(final int igpMetric, final int igpMetricLen) {
- this.igpMetric = igpMetric;
- this.igpMetricLen = igpMetricLen;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param igpMetric 3 byte IGP metric data.
- * @param igpMetricLen length of IGP metric data.
- * @return object of BgpLinkAttrIgpMetric
- */
- public static BgpLinkAttrIgpMetric of(final int igpMetric,
- final int igpMetricLen) {
- return new BgpLinkAttrIgpMetric(igpMetric, igpMetricLen);
- }
-
- /**
- * Reads the BGP link attributes IGP Metric.
- *
- * @param cb Channel buffer
- * @return object of type BgpLinkAttrIgpMetric
- * @throws BgpParseException while parsing BgpLinkAttrIgpMetric
- */
- public static BgpLinkAttrIgpMetric read(ChannelBuffer cb)
- throws BgpParseException {
-
- short linkigp;
- int igpMetric = 0;
- int igpMetricLen = 0;
-
- short lsAttrLength = cb.readShort();
-
- if (cb.readableBytes() < lsAttrLength
- || lsAttrLength > ATTRLINK_MAX_LEN) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- switch (lsAttrLength) {
- case ISIS_SMALL_METRIC:
- igpMetric = cb.readByte();
- igpMetricLen = ISIS_SMALL_METRIC;
- break;
- case OSPF_LINK_METRIC:
- igpMetric = cb.readShort();
- igpMetricLen = OSPF_LINK_METRIC;
- break;
- case ISIS_WIDE_METRIC:
- linkigp = cb.readShort();
- igpMetric = cb.readByte();
- igpMetric = (igpMetric << 16) | linkigp;
- igpMetricLen = ISIS_WIDE_METRIC;
- break;
- default: // validation is already in place
- break;
- }
-
- return BgpLinkAttrIgpMetric.of(igpMetric, igpMetricLen);
- }
-
- /**
- * Returns the variable length IGP metric data.
- *
- * @return IGP metric data
- */
- public int attrLinkIgpMetric() {
- return igpMetric;
- }
-
- /**
- * Returns IGP metric data length.
- *
- * @return IGP metric length
- */
- public int attrLinkIgpMetricLength() {
- return igpMetricLen;
- }
-
- @Override
- public short getType() {
- return ATTRLINK_IGPMETRIC;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(igpMetric, igpMetricLen);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpLinkAttrIgpMetric) {
- BgpLinkAttrIgpMetric other = (BgpLinkAttrIgpMetric) obj;
- return Objects.equals(igpMetric, other.igpMetric)
- && Objects.equals(igpMetricLen, other.igpMetricLen);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("igpMetric", igpMetric).add("igpMetricLen", igpMetricLen)
- .toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIsIsAdminstGrp.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIsIsAdminstGrp.java
deleted file mode 100644
index 448f1e58..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIsIsAdminstGrp.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP attribute Is Is Administrative area.
- */
-public final class BgpLinkAttrIsIsAdminstGrp implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpLinkAttrIsIsAdminstGrp.class);
-
- public static final int ATTRLINK_PROTECTIONTYPE = 1088;
- public static final int ISIS_ADMIN_DATA_LEN = 4;
-
- /* ISIS administrative group */
- private final long isisAdminGrp;
-
- /**
- * Constructor to initialize the values.
- *
- * @param isisAdminGrp ISIS protocol admin group
- */
- public BgpLinkAttrIsIsAdminstGrp(long isisAdminGrp) {
- this.isisAdminGrp = isisAdminGrp;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param isisAdminGrp ISIS admin group
- * @return object of BgpLinkAttrIsIsAdminstGrp
- */
- public static BgpLinkAttrIsIsAdminstGrp of(final long isisAdminGrp) {
- return new BgpLinkAttrIsIsAdminstGrp(isisAdminGrp);
- }
-
- /**
- * Reads the BGP link attributes of ISIS administrative group area.
- *
- * @param cb Channel buffer
- * @return object of type BgpLinkAttrIsIsAdminstGrp
- * @throws BgpParseException while parsing BgpLinkAttrIsIsAdminstGrp
- */
- public static BgpLinkAttrIsIsAdminstGrp read(ChannelBuffer cb)
- throws BgpParseException {
- long isisAdminGrp;
- short lsAttrLength = cb.readShort();
-
- if ((lsAttrLength != ISIS_ADMIN_DATA_LEN)
- || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- isisAdminGrp = cb.readUnsignedInt();
-
- return BgpLinkAttrIsIsAdminstGrp.of(isisAdminGrp);
- }
-
- /**
- * Link attributes of ISIS administrative group area.
- *
- * @return long value of the administrative group area
- */
- public long linkAttrIsIsAdminGrp() {
- return isisAdminGrp;
- }
-
- @Override
- public short getType() {
- return ATTRLINK_PROTECTIONTYPE;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(isisAdminGrp);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpLinkAttrIsIsAdminstGrp) {
- BgpLinkAttrIsIsAdminstGrp other = (BgpLinkAttrIsIsAdminstGrp) obj;
- return Objects.equals(isisAdminGrp, other.isisAdminGrp);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("isisAdminGrp", isisAdminGrp).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidth.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidth.java
deleted file mode 100644
index 2711ca94..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidth.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP attribute Max Link bandwidth.
- */
-public final class BgpLinkAttrMaxLinkBandwidth implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpLinkAttrMaxLinkBandwidth.class);
-
- public static final int MAX_BANDWIDTH_LEN = 4;
- public static final int NO_OF_BITS = 8;
-
- public short type;
-
- /* ISIS administrative group */
- private final float maxBandwidth;
-
- /**
- * Constructor to initialize the values.
- *
- * @param maxBandwidth Maximum link bandwidth.
- * @param type TLV type
- */
- private BgpLinkAttrMaxLinkBandwidth(float maxBandwidth, short type) {
- this.maxBandwidth = maxBandwidth;
- this.type = type;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param maxBandwidth Maximum link bandwidth.
- * @param type TLV type
- * @return object of BgpLinkAttrMaxLinkBandwidth
- */
- public static BgpLinkAttrMaxLinkBandwidth of(final float maxBandwidth,
- final short type) {
- return new BgpLinkAttrMaxLinkBandwidth(maxBandwidth, type);
- }
-
- /**
- * Reads the BGP link attributes of Maximum link bandwidth.
- *
- * @param cb Channel buffer
- * @param type type of this tlv
- * @return object of type BgpLinkAttrMaxLinkBandwidth
- * @throws BgpParseException while parsing BgpLinkAttrMaxLinkBandwidth
- */
- public static BgpLinkAttrMaxLinkBandwidth read(ChannelBuffer cb, short type)
- throws BgpParseException {
- float maxBandwidth;
- short lsAttrLength = cb.readShort();
-
- if ((lsAttrLength != MAX_BANDWIDTH_LEN)
- || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- maxBandwidth = ieeeToFloatRead(cb.readInt()) * NO_OF_BITS;
-
- return BgpLinkAttrMaxLinkBandwidth.of(maxBandwidth, type);
- }
-
- /**
- * Returns Maximum link bandwidth.
- *
- * @return Maximum link bandwidth
- */
- float linkAttrMaxLinkBandwidth() {
- return maxBandwidth;
- }
-
- /**
- * Parse the IEEE floating point notation and returns it in normal float.
- *
- * @param iVal IEEE floating point number
- * @return normal float
- */
- static float ieeeToFloatRead(int iVal) {
- iVal = (((iVal & 0xFF) << 24) | ((iVal & 0xFF00) << 8)
- | ((iVal & 0xFF0000) >> 8) | ((iVal >> 24) & 0xFF));
-
- return Float.intBitsToFloat(iVal);
- }
-
- @Override
- public short getType() {
- return this.type;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(maxBandwidth);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpLinkAttrMaxLinkBandwidth) {
- BgpLinkAttrMaxLinkBandwidth other = (BgpLinkAttrMaxLinkBandwidth) obj;
- return Objects.equals(maxBandwidth, other.maxBandwidth);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("maxBandwidth", maxBandwidth).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMask.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMask.java
deleted file mode 100644
index 2bf1a59d..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMask.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP MPLS protocol mask attribute.
- */
-public class BgpLinkAttrMplsProtocolMask implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpLinkAttrMplsProtocolMask.class);
-
- public static final int ATTRLINK_MPLSPROTOMASK = 1094;
- public static final int MASK_BYTE_LEN = 1;
-
- private final boolean bLdp;
- private final boolean bRsvpTe;
-
- public static final byte FIRST_BIT = (byte) 0x80;
- public static final byte SECOND_BIT = 0x40;
-
- /**
- * Constructor to initialize the values.
- *
- * @param bLdp boolean value true if LDP flag is available
- * @param bRsvpTe boolean value true if RSVP TE information is available
- */
- public BgpLinkAttrMplsProtocolMask(boolean bLdp, boolean bRsvpTe) {
- this.bLdp = bLdp;
- this.bRsvpTe = bRsvpTe;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param bLdp boolean value true if LDP flag is available
- * @param bRsvpTe boolean value true if RSVP TE information is available
- * @return object of BgpLinkAttrMplsProtocolMask
- */
- public static BgpLinkAttrMplsProtocolMask of(final boolean bLdp,
- final boolean bRsvpTe) {
- return new BgpLinkAttrMplsProtocolMask(bLdp, bRsvpTe);
- }
-
- /**
- * Reads the BGP link attributes MPLS protocol mask.
- *
- * @param cb Channel buffer
- * @return object of type BgpLinkAttrMPLSProtocolMask
- * @throws BgpParseException while parsing BgpLinkAttrMplsProtocolMask
- */
- public static BgpLinkAttrMplsProtocolMask read(ChannelBuffer cb)
- throws BgpParseException {
- boolean bLdp = false;
- boolean bRsvpTe = false;
-
- short lsAttrLength = cb.readShort();
-
- if ((lsAttrLength != MASK_BYTE_LEN)
- || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- byte flags = cb.readByte();
-
- bLdp = ((flags & (byte) FIRST_BIT) == FIRST_BIT);
- bRsvpTe = ((flags & (byte) SECOND_BIT) == SECOND_BIT);
-
- return BgpLinkAttrMplsProtocolMask.of(bLdp, bRsvpTe);
- }
-
- /**
- * Returns true if LDP bit is set.
- *
- * @return True if LDP information is set else false.
- */
- public boolean ldpBit() {
- return bLdp;
- }
-
- /**
- * Returns RSVP TE information.
- *
- * @return True if RSVP TE information is set else false.
- */
- public boolean rsvpBit() {
- return bRsvpTe;
- }
-
- @Override
- public short getType() {
- return ATTRLINK_MPLSPROTOMASK;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(bLdp, bRsvpTe);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpLinkAttrMplsProtocolMask) {
- BgpLinkAttrMplsProtocolMask other = (BgpLinkAttrMplsProtocolMask) obj;
- return Objects.equals(bLdp, other.bLdp)
- && Objects.equals(bRsvpTe, other.bRsvpTe);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("bLdp", bLdp).add("bRsvpTe", bRsvpTe).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java
deleted file mode 100644
index 856ffc36..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP link name attribute.
- */
-public class BgpLinkAttrName implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpLinkAttrName.class);
-
- public static final int ATTRLINK_NAME = 1098;
-
- /* Link Name */
- private byte[] linkName;
-
- /**
- * Constructor to initialize the values.
- *
- * @param linkName link name
- */
- public BgpLinkAttrName(byte[] linkName) {
- this.linkName = Arrays.copyOf(linkName, linkName.length);
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param linkName Prefix Metric
- * @return object of BgpLinkAttrName
- */
- public static BgpLinkAttrName of(byte[] linkName) {
- return new BgpLinkAttrName(linkName);
- }
-
- /**
- * Reads the BGP link attributes Name.
- *
- * @param cb Channel buffer
- * @return object of type BgpLinkAttrName
- * @throws BgpParseException while parsing BgpLinkAttrName
- */
- public static BgpLinkAttrName read(ChannelBuffer cb)
- throws BgpParseException {
- byte[] linkName;
- short lsAttrLength = cb.readShort();
-
- if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- linkName = new byte[lsAttrLength];
- cb.readBytes(linkName);
- return BgpLinkAttrName.of(linkName);
- }
-
- /**
- * Returns the link name.
- *
- * @return link name
- */
- public byte[] attrLinkName() {
- return linkName;
- }
-
- @Override
- public short getType() {
- return ATTRLINK_NAME;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(linkName);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpLinkAttrName) {
- BgpLinkAttrName other = (BgpLinkAttrName) obj;
- return Arrays.equals(linkName, other.linkName);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("linkName", linkName).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttrib.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttrib.java
deleted file mode 100644
index 275b85be..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttrib.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP link opaque attribute.
- */
-public final class BgpLinkAttrOpaqLnkAttrib implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpLinkAttrOpaqLnkAttrib.class);
-
- public static final int ATTRNODE_OPAQUELNKATTRIB = 1097;
-
- /* Opaque Node Attribute */
- private final byte[] opaqueLinkAttribute;
-
- /**
- * Constructor to initialize the data.
- *
- * @param opaqueLinkAttribute opaque link attribute
- */
- private BgpLinkAttrOpaqLnkAttrib(byte[] opaqueLinkAttribute) {
- this.opaqueLinkAttribute = Arrays.copyOf(opaqueLinkAttribute,
- opaqueLinkAttribute.length);
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param opaqueLinkAttribute opaque link attribute
- * @return object of BgpLinkAttrOpaqLnkAttrib
- */
- public static BgpLinkAttrOpaqLnkAttrib of(final byte[] opaqueLinkAttribute) {
- return new BgpLinkAttrOpaqLnkAttrib(opaqueLinkAttribute);
- }
-
- /**
- * Reads the BGP link attributes Opaque link attribute.
- *
- * @param cb Channel buffer
- * @return object of type BgpLinkAttrOpaqLnkAttrib
- * @throws BgpParseException while parsing BgpLinkAttrOpaqLnkAttrib
- */
- public static BgpLinkAttrOpaqLnkAttrib read(ChannelBuffer cb)
- throws BgpParseException {
-
- byte[] opaqueLinkAttribute;
-
- short lsAttrLength = cb.readShort();
-
- if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- opaqueLinkAttribute = new byte[lsAttrLength];
- cb.readBytes(opaqueLinkAttribute);
-
- return BgpLinkAttrOpaqLnkAttrib.of(opaqueLinkAttribute);
- }
-
- /**
- * Returns the Opaque link attribute.
- *
- * @return byte array of opaque link attribute.
- */
- public byte[] attrOpaqueLnk() {
- return opaqueLinkAttribute;
- }
-
- @Override
- public short getType() {
- return ATTRNODE_OPAQUELNKATTRIB;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(opaqueLinkAttribute);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpLinkAttrOpaqLnkAttrib) {
- BgpLinkAttrOpaqLnkAttrib other = (BgpLinkAttrOpaqLnkAttrib) obj;
- return Arrays
- .equals(opaqueLinkAttribute, other.opaqueLinkAttribute);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("opaqueLinkAttribute", opaqueLinkAttribute).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionType.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionType.java
deleted file mode 100644
index 59011d97..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionType.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP link protection type attribute.
- */
-public final class BgpLinkAttrProtectionType implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpLinkAttrProtectionType.class);
-
- public static final int ATTRLINK_PROTECTIONTYPE = 1093;
- public static final int LINK_PROTECTION_LEN = 2;
-
- public static final int EXTRA_TRAFFIC = 0x01;
- public static final int UNPROTECTED = 0x02;
- public static final int SHARED = 0x04;
- public static final int DEDICATED_ONE_ISTO_ONE = 0x08;
- public static final int DEDICATED_ONE_PLUS_ONE = 0x10;
- public static final int ENHANCED = 0x20;
-
- /* Link Protection type flags */
- private final boolean bExtraTraffic;
- private final boolean bUnprotected;
- private final boolean bShared;
- private final boolean bDedOneIstoOne;
- private final boolean bDedOnePlusOne;
- private final boolean bEnhanced;
-
- /**
- * Constructor to initialize the value.
- *
- * @param bExtraTraffic Extra Traffic
- * @param bUnprotected Unprotected
- * @param bShared Shared
- * @param bDedOneIstoOne Dedicated 1:1
- * @param bDedOnePlusOne Dedicated 1+1
- * @param bEnhanced Enhanced
- */
- private BgpLinkAttrProtectionType(boolean bExtraTraffic,
- boolean bUnprotected,
- boolean bShared, boolean bDedOneIstoOne,
- boolean bDedOnePlusOne, boolean bEnhanced) {
- this.bExtraTraffic = bExtraTraffic;
- this.bUnprotected = bUnprotected;
- this.bShared = bShared;
- this.bDedOneIstoOne = bDedOneIstoOne;
- this.bDedOnePlusOne = bDedOnePlusOne;
- this.bEnhanced = bEnhanced;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param bExtraTraffic Extra Traffic
- * @param bUnprotected Unprotected
- * @param bShared Shared
- * @param bDedOneIstoOne Dedicated 1:1
- * @param bDedOnePlusOne Dedicated 1+1
- * @param bEnhanced Enhanced
- * @return object of BgpLinkAttrProtectionType
- */
- public static BgpLinkAttrProtectionType of(boolean bExtraTraffic,
- boolean bUnprotected,
- boolean bShared,
- boolean bDedOneIstoOne,
- boolean bDedOnePlusOne,
- boolean bEnhanced) {
- return new BgpLinkAttrProtectionType(bExtraTraffic, bUnprotected,
- bShared, bDedOneIstoOne,
- bDedOnePlusOne, bEnhanced);
- }
-
- /**
- * Reads the BGP link attributes protection type.
- *
- * @param cb Channel buffer
- * @return object of type BgpLinkAttrProtectionType
- * @throws BgpParseException while parsing BgpLinkAttrProtectionType
- */
- public static BgpLinkAttrProtectionType read(ChannelBuffer cb)
- throws BgpParseException {
- short linkProtectionType;
- byte higherByte;
- short lsAttrLength = cb.readShort();
-
- boolean bExtraTraffic;
- boolean bUnprotected;
- boolean bShared;
- boolean bDedOneIstoOne;
- boolean bDedOnePlusOne;
- boolean bEnhanced;
-
- if ((lsAttrLength != LINK_PROTECTION_LEN)
- || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- linkProtectionType = cb.readShort();
- higherByte = (byte) (linkProtectionType >> 8);
-
- bExtraTraffic = ((higherByte & (byte) EXTRA_TRAFFIC) == EXTRA_TRAFFIC);
- bUnprotected = ((higherByte & (byte) UNPROTECTED) == UNPROTECTED);
- bShared = ((higherByte & (byte) SHARED) == SHARED);
- bDedOneIstoOne = ((higherByte & (byte) DEDICATED_ONE_ISTO_ONE) == DEDICATED_ONE_ISTO_ONE);
- bDedOnePlusOne = ((higherByte & (byte) DEDICATED_ONE_PLUS_ONE) == DEDICATED_ONE_PLUS_ONE);
- bEnhanced = ((higherByte & (byte) ENHANCED) == ENHANCED);
-
- return BgpLinkAttrProtectionType.of(bExtraTraffic, bUnprotected,
- bShared, bDedOneIstoOne,
- bDedOnePlusOne, bEnhanced);
- }
-
- /**
- * Returns ExtraTraffic Bit.
- *
- * @return ExtraTraffic Bit
- */
- public boolean extraTraffic() {
- return bExtraTraffic;
- }
-
- /**
- * Returns Unprotected Bit.
- *
- * @return Unprotected Bit
- */
- public boolean unprotected() {
- return bUnprotected;
- }
-
- /**
- * Returns Shared Bit.
- *
- * @return Shared Bit
- */
- public boolean shared() {
- return bShared;
- }
-
- /**
- * Returns DedOneIstoOne Bit.
- *
- * @return DedOneIstoOne Bit
- */
- public boolean dedOneIstoOne() {
- return bDedOneIstoOne;
- }
-
- /**
- * Returns DedOnePlusOne Bit.
- *
- * @return DedOnePlusOne Bit
- */
- public boolean dedOnePlusOne() {
- return bDedOnePlusOne;
- }
-
- /**
- * Returns Enhanced Bit.
- *
- * @return Enhanced Bit
- */
- public boolean enhanced() {
- return bEnhanced;
- }
-
- @Override
- public short getType() {
- return ATTRLINK_PROTECTIONTYPE;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(bExtraTraffic, bUnprotected, bShared,
- bDedOneIstoOne, bDedOnePlusOne, bEnhanced);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpLinkAttrProtectionType) {
- BgpLinkAttrProtectionType other = (BgpLinkAttrProtectionType) obj;
- return Objects.equals(bExtraTraffic, other.bExtraTraffic)
- && Objects.equals(bUnprotected, other.bUnprotected)
- && Objects.equals(bShared, other.bShared)
- && Objects.equals(bDedOneIstoOne, other.bDedOneIstoOne)
- && Objects.equals(bDedOnePlusOne, other.bDedOnePlusOne)
- && Objects.equals(bEnhanced, other.bEnhanced);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("bExtraTraffic", bExtraTraffic)
- .add("bUnprotected", bUnprotected).add("bShared", bShared)
- .add("bDedOneIstoOne", bDedOneIstoOne)
- .add("bDedOnePlusOne", bDedOnePlusOne)
- .add("bEnhanced", bEnhanced).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrSrlg.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrSrlg.java
deleted file mode 100644
index 4a6f23f9..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrSrlg.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP link Shared Risk Link Group attribute.
- */
-public class BgpLinkAttrSrlg implements BgpValueType {
-
- public static final short ATTRNODE_SRLG = 1097;
-
- /* Shared Risk Link Group */
- private List<Integer> sRlg = new ArrayList<Integer>();
-
- /**
- * Constructor to initialize the date.
- *
- * @param sRlg Shared Risk link group data
- */
- public BgpLinkAttrSrlg(List<Integer> sRlg) {
- this.sRlg = sRlg;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param sRlg Shared Risk link group data
- * @return object of BgpLinkAttrSrlg
- */
- public static BgpLinkAttrSrlg of(ArrayList<Integer> sRlg) {
- return new BgpLinkAttrSrlg(sRlg);
- }
-
- /**
- * Reads the BGP link attributes Shared Risk link group data.
- *
- * @param cb Channel buffer
- * @return object of type BgpLinkAttrSrlg
- * @throws BgpParseException while parsing BgpLinkAttrSrlg
- */
- public static BgpLinkAttrSrlg read(ChannelBuffer cb)
- throws BgpParseException {
- int tempSrlg;
- ArrayList<Integer> sRlg = new ArrayList<Integer>();
-
- short lsAttrLength = cb.readShort();
- int len = lsAttrLength / Integer.SIZE; // each element is of 4 octets
-
- if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- for (int i = 0; i < len; i++) {
- tempSrlg = cb.readInt();
- sRlg.add(new Integer(tempSrlg));
- }
-
- return BgpLinkAttrSrlg.of(sRlg);
- }
-
- /**
- * Returns the Shared Risk link group data.
- *
- * @return array of Shared Risk link group data
- */
- public List<Integer> attrSrlg() {
- return sRlg;
- }
-
- @Override
- public short getType() {
- return ATTRNODE_SRLG;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(sRlg);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpLinkAttrSrlg) {
- BgpLinkAttrSrlg other = (BgpLinkAttrSrlg) obj;
- return Objects.equals(sRlg, other.sRlg);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues().add("sRlg", sRlg).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetric.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetric.java
deleted file mode 100644
index 1ae7ecc5..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetric.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP link state Default TE metric link attribute.
- */
-public class BgpLinkAttrTeDefaultMetric implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpLinkAttrTeDefaultMetric.class);
-
- public static final int ATTRLINK_TEDEFAULTMETRIC = 1092;
- public static final int TE_DATA_LEN = 4;
-
- /* TE Default Metric */
- private int linkTeMetric;
-
- /**
- * Constructor to initialize the value.
- *
- * @param linkTeMetric TE default metric
- *
- */
- public BgpLinkAttrTeDefaultMetric(int linkTeMetric) {
- this.linkTeMetric = linkTeMetric;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param linkTeMetric TE default metric
- * @return object of BgpLinkAttrTeDefaultMetric
- */
- public static BgpLinkAttrTeDefaultMetric of(final int linkTeMetric) {
- return new BgpLinkAttrTeDefaultMetric(linkTeMetric);
- }
-
- /**
- * Reads the BGP link attributes of TE default metric.
- *
- * @param cb Channel buffer
- * @return object of type BgpLinkAttrTeDefaultMetric
- * @throws BgpParseException while parsing BgpLinkAttrTeDefaultMetric
- */
- public static BgpLinkAttrTeDefaultMetric read(ChannelBuffer cb)
- throws BgpParseException {
- int linkTeMetric;
-
- short lsAttrLength = cb.readShort();
-
- if ((lsAttrLength != TE_DATA_LEN)
- || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- linkTeMetric = cb.readInt();
-
- return new BgpLinkAttrTeDefaultMetric(linkTeMetric);
- }
-
- /**
- * Returns the TE default metrics.
- *
- * @return link default metric
- */
- public int attrLinkDefTeMetric() {
- return linkTeMetric;
- }
-
- @Override
- public short getType() {
- return ATTRLINK_TEDEFAULTMETRIC;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(linkTeMetric);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpLinkAttrTeDefaultMetric) {
- BgpLinkAttrTeDefaultMetric other = (BgpLinkAttrTeDefaultMetric) obj;
- return Objects.equals(linkTeMetric, other.linkTeMetric);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("linkTEMetric", linkTeMetric).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidth.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidth.java
deleted file mode 100644
index c927eea5..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidth.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP unreserved bandwidth attribute.
- */
-public class BgpLinkAttrUnRsrvdLinkBandwidth implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpLinkAttrUnRsrvdLinkBandwidth.class);
-
- public static final int MAX_BANDWIDTH_LEN = 4;
- public static final int NO_OF_BITS = 8;
- public static final int NO_OF_PRIORITY = 8;
-
- public short sType;
-
- /* ISIS administrative group */
- private List<Float> maxUnResBandwidth = new ArrayList<Float>();
-
- /**
- * Constructor to initialize the values.
- *
- * @param maxUnResBandwidth Maximum Unreserved bandwidth
- * @param sType returns the tag value
- */
- public BgpLinkAttrUnRsrvdLinkBandwidth(List<Float> maxUnResBandwidth,
- short sType) {
- this.maxUnResBandwidth = maxUnResBandwidth;
- this.sType = sType;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param linkPfxMetric Prefix Metric
- * @param sType returns the tag value
- * @return object of BgpLinkAttrUnRsrvdLinkBandwidth
- */
- public static BgpLinkAttrUnRsrvdLinkBandwidth of(List<Float> linkPfxMetric, short sType) {
- return new BgpLinkAttrUnRsrvdLinkBandwidth(linkPfxMetric, sType);
- }
-
- /**
- * Reads the BGP link attributes of Maximum link bandwidth.
- *
- * @param cb Channel buffer
- * @return object of type BgpLinkAttrMaxLinkBandwidth
- * @throws BgpParseException while parsing BgpLinkAttrMaxLinkBandwidth
- */
- public static BgpLinkAttrUnRsrvdLinkBandwidth read(ChannelBuffer cb,
- short sType)
- throws BgpParseException {
- ArrayList<Float> maxUnResBandwidth = new ArrayList<Float>();
- float tmp;
- short lsAttrLength = cb.readShort();
-
- if ((lsAttrLength != MAX_BANDWIDTH_LEN * NO_OF_PRIORITY)
- || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- for (int i = 0; i < NO_OF_PRIORITY; i++) {
- tmp = ieeeToFloatRead(cb.readInt()) * NO_OF_BITS;
- maxUnResBandwidth.add(new Float(tmp));
- }
-
- return BgpLinkAttrUnRsrvdLinkBandwidth.of(maxUnResBandwidth, sType);
- }
-
- /**
- * Returns maximum unreserved bandwidth.
- *
- * @return unreserved bandwidth.
- */
- public List<Float> getLinkAttrUnRsrvdLinkBandwidth() {
- return maxUnResBandwidth;
- }
-
- /**
- * Parse the IEEE floating point notation and returns it in normal float.
- *
- * @param iVal IEEE floating point number
- * @return normal float
- */
- static float ieeeToFloatRead(int iVal) {
- iVal = (((iVal & 0xFF) << 24) | ((iVal & 0xFF00) << 8)
- | ((iVal & 0xFF0000) >> 8) | ((iVal >> 24) & 0xFF));
-
- return Float.intBitsToFloat(iVal);
- }
-
- @Override
- public short getType() {
- return this.sType;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(maxUnResBandwidth);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpLinkAttrUnRsrvdLinkBandwidth) {
- BgpLinkAttrUnRsrvdLinkBandwidth other = (BgpLinkAttrUnRsrvdLinkBandwidth) obj;
- return Objects.equals(maxUnResBandwidth, other.maxUnResBandwidth);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("maxUnResBandwidth", maxUnResBandwidth).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrExtRouteTag.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrExtRouteTag.java
deleted file mode 100644
index a2d7c57e..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrExtRouteTag.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP prefix route Extended tag attribute.
- */
-public class BgpPrefixAttrExtRouteTag implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpPrefixAttrExtRouteTag.class);
-
- public static final int ATTR_PREFIX_EXTROUTETAG = 1154;
- public static final int ATTR_PREFIX_EXT_LEN = 8;
-
- /* Prefix Route Tag */
- private List<Long> pfxExtRouteTag = new ArrayList<Long>();
-
- /**
- * Constructor to initialize the values.
- *
- * @param pfxExtRouteTag Extended route tag
- */
- public BgpPrefixAttrExtRouteTag(List<Long> pfxExtRouteTag) {
- this.pfxExtRouteTag = checkNotNull(pfxExtRouteTag);
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param pfxExtRouteTag Prefix Metric
- * @return object of BgpPrefixAttrMetric
- */
- public static BgpPrefixAttrExtRouteTag of(ArrayList<Long> pfxExtRouteTag) {
- return new BgpPrefixAttrExtRouteTag(pfxExtRouteTag);
- }
-
- /**
- * Reads the Extended Tag.
- *
- * @param cb ChannelBuffer
- * @return object of BgpPrefixAttrExtRouteTag
- * @throws BgpParseException while parsing BgpPrefixAttrExtRouteTag
- */
- public static BgpPrefixAttrExtRouteTag read(ChannelBuffer cb)
- throws BgpParseException {
- ArrayList<Long> pfxExtRouteTag = new ArrayList<Long>();
- long temp;
-
- short lsAttrLength = cb.readShort();
- int len = lsAttrLength / ATTR_PREFIX_EXT_LEN;
-
- if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- for (int i = 0; i < len; i++) {
- temp = cb.readLong();
- pfxExtRouteTag.add(new Long(temp));
- }
-
- return new BgpPrefixAttrExtRouteTag(pfxExtRouteTag);
- }
-
- /**
- * Returns Extended route tag.
- *
- * @return route tag
- */
- public List<Long> pfxExtRouteTag() {
- return pfxExtRouteTag;
- }
-
- @Override
- public short getType() {
- return ATTR_PREFIX_EXTROUTETAG;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(pfxExtRouteTag);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpPrefixAttrExtRouteTag) {
- BgpPrefixAttrExtRouteTag other = (BgpPrefixAttrExtRouteTag) obj;
- return Objects.equals(pfxExtRouteTag, other.pfxExtRouteTag);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("pfxExtRouteTag", pfxExtRouteTag).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java
deleted file mode 100644
index 4e84191a..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP prefix IGP Flag attribute.
- */
-public final class BgpPrefixAttrIgpFlags implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpPrefixAttrIgpFlags.class);
-
- public static final int ATTR_PREFIX_FLAGBIT = 1152;
- public static final int ATTR_PREFIX_FLAG_LEN = 1;
-
- public static final byte FIRST_BIT = (byte) 0x80;
- public static final byte SECOND_BIT = 0x40;
- public static final byte THIRD_BIT = 0x20;
- public static final byte FOURTH_BIT = 0x01;
-
- /* Prefix IGP flag bit TLV */
- private final boolean bisisUpDownBit;
- private final boolean bOspfNoUnicastBit;
- private final boolean bOspfLclAddrBit;
- private final boolean bOspfNSSABit;
-
- /**
- * Constructor to initialize the value.
- *
- * @param bisisUpDownBit IS-IS Up/Down Bit
- * @param bOspfNoUnicastBit OSPF no unicast Bit
- * @param bOspfLclAddrBit OSPF local address Bit
- * @param bOspfNSSABit OSPF propagate NSSA Bit
- */
- BgpPrefixAttrIgpFlags(boolean bisisUpDownBit,
- boolean bOspfNoUnicastBit,
- boolean bOspfLclAddrBit, boolean bOspfNSSABit) {
- this.bisisUpDownBit = bisisUpDownBit;
- this.bOspfNoUnicastBit = bOspfNoUnicastBit;
- this.bOspfLclAddrBit = bOspfLclAddrBit;
- this.bOspfNSSABit = bOspfNSSABit;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param bisisUpDownBit IS-IS Up/Down Bit
- * @param bOspfNoUnicastBit OSPF no unicast Bit
- * @param bOspfLclAddrBit OSPF local address Bit
- * @param bOspfNSSABit OSPF propagate NSSA Bit
- * @return object of BgpPrefixAttrIGPFlags
- */
- public static BgpPrefixAttrIgpFlags of(final boolean bisisUpDownBit,
- final boolean bOspfNoUnicastBit,
- final boolean bOspfLclAddrBit,
- final boolean bOspfNSSABit) {
- return new BgpPrefixAttrIgpFlags(bisisUpDownBit, bOspfNoUnicastBit,
- bOspfLclAddrBit, bOspfNSSABit);
- }
-
- /**
- * Reads the IGP Flags.
- *
- * @param cb ChannelBuffer
- * @return object of BgpPrefixAttrIGPFlags
- * @throws BgpParseException while parsing BgpPrefixAttrIGPFlags
- */
- public static BgpPrefixAttrIgpFlags read(ChannelBuffer cb)
- throws BgpParseException {
- boolean bisisUpDownBit = false;
- boolean bOspfNoUnicastBit = false;
- boolean bOspfLclAddrBit = false;
- boolean bOspfNSSABit = false;
-
- short lsAttrLength = cb.readShort();
-
- if ((lsAttrLength != ATTR_PREFIX_FLAG_LEN)
- || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- byte nodeFlagBits = cb.readByte();
-
- bisisUpDownBit = ((nodeFlagBits & FIRST_BIT) == FIRST_BIT);
- bOspfNoUnicastBit = ((nodeFlagBits & SECOND_BIT) == SECOND_BIT);
- bOspfLclAddrBit = ((nodeFlagBits & THIRD_BIT) == THIRD_BIT);
- bOspfNSSABit = ((nodeFlagBits & FOURTH_BIT) == FOURTH_BIT);
-
- return BgpPrefixAttrIgpFlags.of(bisisUpDownBit, bOspfNoUnicastBit,
- bOspfLclAddrBit, bOspfNSSABit);
- }
-
- /**
- * Returns the IS-IS Up/Down Bit set or not.
- *
- * @return IS-IS Up/Down Bit set or not
- */
- public boolean isisUpDownBit() {
- return bisisUpDownBit;
- }
-
- /**
- * Returns the OSPF no unicast Bit set or not.
- *
- * @return OSPF no unicast Bit set or not
- */
- public boolean ospfNoUnicastBit() {
- return bOspfNoUnicastBit;
- }
-
- /**
- * Returns the OSPF local address Bit set or not.
- *
- * @return OSPF local address Bit set or not
- */
- public boolean ospfLclAddrBit() {
- return bOspfLclAddrBit;
- }
-
- /**
- * Returns the OSPF propagate NSSA Bit set or not.
- *
- * @return OSPF propagate NSSA Bit set or not
- */
- public boolean ospfNSSABit() {
- return bOspfNSSABit;
- }
-
- @Override
- public short getType() {
- return ATTR_PREFIX_FLAGBIT;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(bisisUpDownBit, bOspfNoUnicastBit, bOspfLclAddrBit,
- bOspfNSSABit);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpPrefixAttrIgpFlags) {
- BgpPrefixAttrIgpFlags other = (BgpPrefixAttrIgpFlags) obj;
- return Objects.equals(bisisUpDownBit, other.bisisUpDownBit)
- && Objects.equals(bOspfNoUnicastBit,
- other.bOspfNoUnicastBit)
- && Objects.equals(bOspfLclAddrBit, other.bOspfLclAddrBit)
- && Objects.equals(bOspfNSSABit, other.bOspfNSSABit);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("bisisUpDownBit", bisisUpDownBit)
- .add("bOspfNoUnicastBit", bOspfNoUnicastBit)
- .add("bOspfLclAddrBit", bOspfLclAddrBit)
- .add("bOspfNSSABit", bOspfNSSABit).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetric.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetric.java
deleted file mode 100644
index 1886102c..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetric.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP prefix metric attribute.
- */
-public class BgpPrefixAttrMetric implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpPrefixAttrMetric.class);
-
- public static final int ATTR_PREFIX_METRIC = 1155;
- public static final int ATTR_PREFIX_LEN = 4;
-
- /* TE Default Metric */
- private final int linkPfxMetric;
-
- /**
- * Constructor to initialize value.
- *
- * @param linkPfxMetric Prefix Metric
- */
- public BgpPrefixAttrMetric(int linkPfxMetric) {
- this.linkPfxMetric = linkPfxMetric;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param linkPfxMetric Prefix Metric
- * @return object of BgpPrefixAttrMetric
- */
- public static BgpPrefixAttrMetric of(final int linkPfxMetric) {
- return new BgpPrefixAttrMetric(linkPfxMetric);
- }
-
- /**
- * Reads the Prefix Metric.
- *
- * @param cb ChannelBuffer
- * @return object of BgpPrefixAttrMetric
- * @throws BgpParseException while parsing BgpPrefixAttrMetric
- */
- public static BgpPrefixAttrMetric read(ChannelBuffer cb)
- throws BgpParseException {
- int linkPfxMetric;
-
- short lsAttrLength = cb.readShort(); // 4 Bytes
-
- if ((lsAttrLength != ATTR_PREFIX_LEN)
- || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- linkPfxMetric = cb.readInt();
-
- return BgpPrefixAttrMetric.of(linkPfxMetric);
- }
-
- /**
- * Returns the Prefix Metric.
- *
- * @return Prefix Metric
- */
- public int attrPfxMetric() {
- return linkPfxMetric;
- }
-
- @Override
- public short getType() {
- return ATTR_PREFIX_METRIC;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(linkPfxMetric);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpPrefixAttrMetric) {
- BgpPrefixAttrMetric other = (BgpPrefixAttrMetric) obj;
- return Objects.equals(linkPfxMetric, other.linkPfxMetric);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("linkPfxMetric", linkPfxMetric).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueData.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueData.java
deleted file mode 100644
index 6f7a74bb..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueData.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP prefix opaque data attribute.
- */
-public final class BgpPrefixAttrOpaqueData implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpPrefixAttrOpaqueData.class);
-
- public static final int ATTR_PREFIX_OPAQUEDATA = 1157;
-
- /* Opaque Node Attribute */
- private final byte[] opaquePrefixAttribute;
-
- /**
- * Constructor to initialize the values.
- *
- * @param opaquePrefixAttribute opaque prefix data
- */
- public BgpPrefixAttrOpaqueData(byte[] opaquePrefixAttribute) {
- this.opaquePrefixAttribute = Arrays
- .copyOf(opaquePrefixAttribute, opaquePrefixAttribute.length);
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param opaquePrefixAttribute opaque prefix data
- * @return object of BgpPrefixAttrOpaqueData
- */
- public static BgpPrefixAttrOpaqueData of(final byte[] opaquePrefixAttribute) {
- return new BgpPrefixAttrOpaqueData(opaquePrefixAttribute);
- }
-
- /**
- * Reads the Opaque Prefix Attribute.
- *
- * @param cb ChannelBuffer
- * @return object of BgpPrefixAttrOpaqueData
- * @throws BgpParseException while parsing BgpPrefixAttrOpaqueData
- */
- public static BgpPrefixAttrOpaqueData read(ChannelBuffer cb)
- throws BgpParseException {
- byte[] opaquePrefixAttribute;
-
- short lsAttrLength = cb.readShort();
- opaquePrefixAttribute = new byte[lsAttrLength];
-
- if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- cb.readBytes(opaquePrefixAttribute);
-
- return BgpPrefixAttrOpaqueData.of(opaquePrefixAttribute);
- }
-
- /**
- * Returns the Opaque prefix attribute name.
- *
- * @return opaque prefix name
- */
- public byte[] getOpaquePrefixAttribute() {
- return opaquePrefixAttribute;
- }
-
- @Override
- public short getType() {
- return ATTR_PREFIX_OPAQUEDATA;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(opaquePrefixAttribute);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpPrefixAttrOpaqueData) {
- BgpPrefixAttrOpaqueData other = (BgpPrefixAttrOpaqueData) obj;
- return Arrays.equals(opaquePrefixAttribute,
- other.opaquePrefixAttribute);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("opaquePrefixAttribute", getOpaquePrefixAttribute())
- .toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddr.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddr.java
deleted file mode 100644
index 4e9db1ee..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddr.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip6Address;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP prefix OSPF Forwarding address attribute.
- */
-public class BgpPrefixAttrOspfFwdAddr implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpPrefixAttrOspfFwdAddr.class);
-
- public static final int ATTR_PREFIX_OSPFFWDADDR = 1156;
- public static final int IPV4_LEN = 4;
- public static final int IPV6_LEN = 16;
-
- /* OSPF Forwarding Address */
- private final short lsAttrLength;
- private final Ip4Address ip4RouterId;
- private final Ip6Address ip6RouterId;
-
- /**
- * Constructor to initialize the value.
- *
- * @param lsAttrLength length of the IP address
- * @param ip4RouterId Valid IPV4 address if length is 4 else null
- * @param ip6RouterId Valid IPV6 address if length is 16 else null
- */
- public BgpPrefixAttrOspfFwdAddr(short lsAttrLength, Ip4Address ip4RouterId,
- Ip6Address ip6RouterId) {
- this.lsAttrLength = lsAttrLength;
- this.ip4RouterId = ip4RouterId;
- this.ip6RouterId = ip6RouterId;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param lsAttrLength length of the IP address
- * @param ip4RouterId Valid IPV4 address if length is 4 else null
- * @param ip6RouterId Valid IPV6 address if length is 16 else null
- * @return object of BgpPrefixAttrOspfFwdAddr
- */
- public static BgpPrefixAttrOspfFwdAddr of(final short lsAttrLength,
- final Ip4Address ip4RouterId,
- final Ip6Address ip6RouterId) {
- return new BgpPrefixAttrOspfFwdAddr(lsAttrLength, ip4RouterId,
- ip6RouterId);
- }
-
- /**
- * Reads the OSPF Forwarding Address.
- *
- * @param cb ChannelBuffer
- * @return object of BgpPrefixAttrOSPFFwdAddr
- * @throws BgpParseException while parsing BgpPrefixAttrOspfFwdAddr
- */
- public static BgpPrefixAttrOspfFwdAddr read(ChannelBuffer cb)
- throws BgpParseException {
- short lsAttrLength;
- byte[] ipBytes;
- Ip4Address ip4RouterId = null;
- Ip6Address ip6RouterId = null;
-
- lsAttrLength = cb.readShort();
- ipBytes = new byte[lsAttrLength];
-
- if ((cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- cb.readBytes(ipBytes);
-
- if (IPV4_LEN == lsAttrLength) {
- ip4RouterId = Ip4Address.valueOf(ipBytes);
- } else if (IPV6_LEN == lsAttrLength) {
- ip6RouterId = Ip6Address.valueOf(ipBytes);
- }
-
- return BgpPrefixAttrOspfFwdAddr.of(lsAttrLength, ip4RouterId,
- ip6RouterId);
- }
-
- /**
- * Returns IPV4 Address of OSPF forwarding address.
- *
- * @return IPV4 address
- */
- public Ip4Address ospfv4FwdAddr() {
- return ip4RouterId;
- }
-
- /**
- * Returns IPV6 Address of OSPF forwarding address.
- *
- * @return IPV6 address
- */
- public Ip6Address ospfv6FwdAddr() {
- return ip6RouterId;
- }
-
- /**
- * Returns OSPF forwarding address length.
- *
- * @return length of the ip address
- */
- public short ospfFwdAddrLen() {
- return lsAttrLength;
- }
-
- @Override
- public short getType() {
- return ATTR_PREFIX_OSPFFWDADDR;
- }
-
- @Override
- public int hashCode() {
- if (IPV4_LEN == lsAttrLength) {
- return Objects.hash(ip4RouterId);
- } else {
- return Objects.hash(ip6RouterId);
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpPrefixAttrOspfFwdAddr) {
- BgpPrefixAttrOspfFwdAddr other = (BgpPrefixAttrOspfFwdAddr) obj;
- if (IPV4_LEN == lsAttrLength) {
- return Objects.equals(ip4RouterId, other.ip4RouterId);
- } else {
- return Objects.equals(ip6RouterId, other.ip6RouterId);
- }
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- if (IPV4_LEN == lsAttrLength) {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("ip4RouterId", ip4RouterId).toString();
- } else {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("ip6RouterId", ip6RouterId).toString();
- }
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java
deleted file mode 100644
index 3894c003..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implements BGP prefix route tag attribute.
- */
-public class BgpPrefixAttrRouteTag implements BgpValueType {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpPrefixAttrRouteTag.class);
-
- public static final short ATTR_PREFIX_ROUTETAG = 1153;
-
- /* Prefix Route Tag */
- private List<Integer> pfxRouteTag = new ArrayList<Integer>();
-
- /**
- * Constructor to initialize the values.
- *
- * @param pfxRouteTag prefix route tag
- */
- public BgpPrefixAttrRouteTag(List<Integer> pfxRouteTag) {
- this.pfxRouteTag = pfxRouteTag;
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param pfxRouteTag Prefix Metric
- * @return object of BgpPrefixAttrRouteTag
- */
- public static BgpPrefixAttrRouteTag of(ArrayList<Integer> pfxRouteTag) {
- return new BgpPrefixAttrRouteTag(pfxRouteTag);
- }
-
- /**
- * Reads the Route Tag.
- *
- * @param cb ChannelBuffer
- * @return object of BgpPrefixAttrRouteTag
- * @throws BgpParseException while parsing BgpPrefixAttrRouteTag
- */
- public static BgpPrefixAttrRouteTag read(ChannelBuffer cb)
- throws BgpParseException {
- int tmp;
- ArrayList<Integer> pfxRouteTag = new ArrayList<Integer>();
-
- short lsAttrLength = cb.readShort();
- int len = lsAttrLength / Integer.SIZE;
-
- if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
- lsAttrLength);
- }
-
- for (int i = 0; i < len; i++) {
- tmp = cb.readInt();
- pfxRouteTag.add(new Integer(tmp));
- }
-
- return BgpPrefixAttrRouteTag.of(pfxRouteTag);
- }
-
- /**
- * Returns the prefix route tag.
- *
- * @return route tag
- */
- public List<Integer> getPfxRouteTag() {
- return pfxRouteTag;
- }
-
- @Override
- public short getType() {
- return ATTR_PREFIX_ROUTETAG;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(pfxRouteTag);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof BgpPrefixAttrRouteTag) {
- BgpPrefixAttrRouteTag other = (BgpPrefixAttrRouteTag) obj;
- return Objects.equals(pfxRouteTag, other.pfxRouteTag);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- // TODO This will be implemented in the next version
- return 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("pfxRouteTag", pfxRouteTag).toString();
- }
-
- @Override
- public int compareTo(Object o) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/package-info.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/package-info.java
deleted file mode 100755
index e2a74dbc..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of BGP Link state attribute Tlvs.
- */
-package org.onosproject.bgpio.types.attr;
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/package-info.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/package-info.java
deleted file mode 100755
index 1f2ed95e..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of Tlvs, Attributes and Descriptors.
- */
-package org.onosproject.bgpio.types;
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Constants.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Constants.java
deleted file mode 100644
index 9649bf16..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Constants.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.util;
-
-/**
- * Provides Constants usage for BGP.
- */
-public final class Constants {
- private Constants() {
- }
-
- public static final short TYPE_AND_LEN = 4;
- public static final short TYPE_AND_LEN_AS_SHORT = 4;
- public static final short TYPE_AND_LEN_AS_BYTE = 3;
- public static final int ISIS_LEVELONE = 1;
- public static final int ISIS_LEVELTWO = 2;
- public static final int OSPFV2 = 3;
- public static final int DIRECT = 4;
- public static final int STATIC_CONFIGURATION = 5;
- public static final int OSPFV3 = 6;
- public static final short AFI_VALUE = 16388;
- public static final byte VPN_SAFI_VALUE = (byte) 0x80;
- public static final byte SAFI_VALUE = 71;
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/UnSupportedAttribute.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/UnSupportedAttribute.java
deleted file mode 100644
index 663b1e9a..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/UnSupportedAttribute.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.util;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Provides methods to handle UnSupportedAttribute.
- */
-public final class UnSupportedAttribute {
- protected static final Logger log = LoggerFactory.getLogger(UnSupportedAttribute.class);
-
- private UnSupportedAttribute() {
- }
-
- /**
- * Reads channel buffer parses attribute header and skips specified length.
- *
- * @param cb channelBuffer
- */
- public static void read(ChannelBuffer cb) {
- Validation parseFlags = Validation.parseAttributeHeader(cb);
- cb.skipBytes(parseFlags.getLength());
- }
-
- /**
- * Skip specified bytes in channel buffer.
- *
- * @param cb channelBuffer
- * @param length to be skipped
- */
- public static void skipBytes(ChannelBuffer cb, short length) {
- cb.skipBytes(length);
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Validation.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Validation.java
deleted file mode 100644
index 23dd1a75..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Validation.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgpio.util;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.primitives.Ints;
-
-/**
- * Provides methods to parse attribute header, validate length and type.
- */
-public class Validation {
- private static final Logger log = LoggerFactory.getLogger(Validation.class);
- public static final byte FIRST_BIT = (byte) 0x80;
- public static final byte SECOND_BIT = 0x40;
- public static final byte THIRD_BIT = 0x20;
- public static final byte FOURTH_BIT = (byte) 0x10;
- public static final byte IPV4_SIZE = 4;
- private boolean firstBit;
- private boolean secondBit;
- private boolean thirdBit;
- private boolean fourthBit;
- private int len;
- private boolean isShort;
-
- /**
- * Constructor to initialize parameter.
- *
- * @param firstBit in AttributeFlags
- * @param secondBit in AttributeFlags
- * @param thirdBit in AttributeFlags
- * @param fourthBit in AttributeFlags
- * @param len length
- * @param isShort true if length is read as short otherwise false
- */
- Validation(boolean firstBit, boolean secondBit, boolean thirdBit, boolean fourthBit, int len, boolean isShort) {
- this.firstBit = firstBit;
- this.secondBit = secondBit;
- this.thirdBit = thirdBit;
- this.fourthBit = fourthBit;
- this.len = len;
- this.isShort = isShort;
- }
-
- /**
- * Parses attribute Header.
- *
- * @param cb ChannelBuffer
- * @return object of Validation
- */
- public static Validation parseAttributeHeader(ChannelBuffer cb) {
-
- boolean firstBit;
- boolean secondBit;
- boolean thirdBit;
- boolean fourthBit;
- boolean isShort;
- byte flags = cb.readByte();
- byte typeCode = cb.readByte();
- byte temp = flags;
- //first Bit : Optional (1) or well-known (0)
- firstBit = ((temp & FIRST_BIT) == FIRST_BIT);
- //second Bit : Transitive (1) or non-Transitive (0)
- secondBit = ((temp & SECOND_BIT) == SECOND_BIT);
- //third Bit : partial (1) or complete (0)
- thirdBit = ((temp & THIRD_BIT) == THIRD_BIT);
- //forth Bit(Extended Length bit) : Attribute Length is 1 octects (0) or 2 octects (1)
- fourthBit = ((temp & FOURTH_BIT) == FOURTH_BIT);
- int len;
- if (fourthBit) {
- isShort = true;
- short length = cb.readShort();
- len = length;
- } else {
- isShort = false;
- byte length = cb.readByte();
- len = length;
- }
- return new Validation(firstBit, secondBit, thirdBit, fourthBit, len, isShort);
- }
-
- /**
- * Throws exception if length is not correct.
- *
- * @param errorCode Error code
- * @param subErrCode Sub Error Code
- * @param length erroneous length
- * @throws BgpParseException for erroneous length
- */
- public static void validateLen(byte errorCode, byte subErrCode, int length) throws BgpParseException {
- byte[] errLen = Ints.toByteArray(length);
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errLen);
- throw new BgpParseException(errorCode, subErrCode, buffer);
- }
-
- /**
- * Throws exception if type is not correct.
- *
- * @param errorCode Error code
- * @param subErrCode Sub Error Code
- * @param type erroneous type
- * @throws BgpParseException for erroneous type
- */
- public static void validateType(byte errorCode, byte subErrCode, int type) throws BgpParseException {
- byte[] errType = Ints.toByteArray(type);
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errType);
- throw new BgpParseException(errorCode, subErrCode, buffer);
- }
-
- /**
- * Convert byte array to InetAddress.
- *
- * @param length of IpAddress
- * @param cb channelBuffer
- * @return InetAddress
- */
- public static InetAddress toInetAddress(int length, ChannelBuffer cb) {
- byte[] address = new byte[length];
- cb.readBytes(address, 0, length);
- InetAddress ipAddress = null;
- try {
- ipAddress = InetAddress.getByAddress(address);
- } catch (UnknownHostException e) {
- log.info("InetAddress convertion failed");
- }
- return ipAddress;
- }
-
- /**
- * Returns first bit in type flags.
- *
- * @return first bit in type flags
- */
- public boolean getFirstBit() {
- return this.firstBit;
- }
-
- /**
- * Returns second bit in type flags.
- *
- * @return second bit in type flags
- */
- public boolean getSecondBit() {
- return this.secondBit;
- }
-
- /**
- * Returns third bit in type flags.
- *
- * @return third bit in type flags
- */
- public boolean getThirdBit() {
- return this.thirdBit;
- }
-
- /**
- * Returns fourth bit in type flags.
- *
- * @return fourth bit in type flags
- */
- public boolean getFourthBit() {
- return this.fourthBit;
- }
-
- /**
- * Returns attribute length.
- *
- * @return attribute length
- */
- public int getLength() {
- return this.len;
- }
-
- /**
- * Returns whether attribute length read in short or byte.
- *
- * @return whether attribute length read in short or byte
- */
- public boolean isShort() {
- return this.isShort;
- }
-
- /**
- * Converts byte array of prefix value to IpPrefix object.
- *
- * @param value byte array of prefix value
- * @param length prefix length in bits
- * @return object of IpPrefix
- */
- public static IpPrefix bytesToPrefix(byte[] value, int length) {
- if (value.length != IPV4_SIZE) {
- value = Arrays.copyOf(value, IPV4_SIZE);
- }
- IpPrefix ipPrefix = IpPrefix.valueOf(IpAddress.Version.INET, value, length);
- return ipPrefix;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/package-info.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/package-info.java
deleted file mode 100755
index 3229d89a..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of BGP utility functions.
- */
-package org.onosproject.bgpio.util;
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrMaxLinkBandwidthTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrMaxLinkBandwidthTest.java
deleted file mode 100644
index d4c3b610..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrMaxLinkBandwidthTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp;
-
-import org.junit.Test;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGP link max bandwidth attribute.
- */
-public class BgpLinkAttrMaxLinkBandwidthTest {
- private final float val = 0x010203;
- private final short valLen = 3;
- private final float val1 = 0x01020304;
- private final short val1Len = 4;
-
- private final BgpLinkAttrMaxLinkBandwidth data = BgpLinkAttrMaxLinkBandwidth
- .of(val, valLen);
- private final BgpLinkAttrMaxLinkBandwidth sameAsData = BgpLinkAttrMaxLinkBandwidth
- .of(val, valLen);
- private final BgpLinkAttrMaxLinkBandwidth diffData = BgpLinkAttrMaxLinkBandwidth
- .of(val1, val1Len);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(data, sameAsData)
- .addEqualityGroup(diffData).testEquals();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrTeDefaultMetricTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrTeDefaultMetricTest.java
deleted file mode 100644
index b6453c45..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrTeDefaultMetricTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp;
-
-import org.junit.Test;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGP link TE default metric attribute.
- */
-public class BgpLinkAttrTeDefaultMetricTest {
- private final int val = 0x010203;
- private final int val1 = 0x01020304;
-
- private final BgpLinkAttrTeDefaultMetric data = BgpLinkAttrTeDefaultMetric
- .of(val);
- private final BgpLinkAttrTeDefaultMetric sameAsData = BgpLinkAttrTeDefaultMetric
- .of(val);
- private final BgpLinkAttrTeDefaultMetric diffData = BgpLinkAttrTeDefaultMetric
- .of(val1);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(data, sameAsData)
- .addEqualityGroup(diffData).testEquals();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrOpaqueDataTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrOpaqueDataTest.java
deleted file mode 100644
index 7ba6a880..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrOpaqueDataTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp;
-
-import org.junit.Test;
-import org.onosproject.bgpio.types.attr.BgpPrefixAttrOpaqueData;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for prefix attribute opaque data Tlv.
- */
-public class BgpPrefixAttrOpaqueDataTest {
- private final byte[] array = new byte[] {0x01, 0x02, 0x03, 0x04};
- private final byte[] array1 = new byte[] {0x01, 0x02, 0x03, 0x01};
-
- private final BgpPrefixAttrOpaqueData isisData = BgpPrefixAttrOpaqueData
- .of(array);
- private final BgpPrefixAttrOpaqueData sameAsIsisData = BgpPrefixAttrOpaqueData
- .of(array);
- private final BgpPrefixAttrOpaqueData isisDiff = BgpPrefixAttrOpaqueData
- .of(array1);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(isisData, sameAsIsisData)
- .addEqualityGroup(isisDiff).testEquals();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpKeepaliveMsgTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpKeepaliveMsgTest.java
deleted file mode 100755
index 682c1bc0..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpKeepaliveMsgTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-/**
- * Test case for BGP KEEPALIVE Message.
- */
-public class BgpKeepaliveMsgTest {
-
- /**
- * This test case checks BGP Keepalive message.
- */
- @Test
- public void keepaliveMessageTest1() throws BgpParseException {
-
- // BGP KEEPALIVE Message
- byte[] keepaliveMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- 0x00, 0x13, 0x04};
-
- byte[] testKeepaliveMsg;
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(keepaliveMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpKeepaliveMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testKeepaliveMsg = new byte[readLen];
- buf.readBytes(testKeepaliveMsg, 0, readLen);
-
- assertThat(testKeepaliveMsg, is(keepaliveMsg));
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpNotificationMsgTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpNotificationMsgTest.java
deleted file mode 100644
index 6dfa57ee..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpNotificationMsgTest.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-/**
- * Test for Notification message.
- */
-public class BgpNotificationMsgTest {
-
- /**
- * Notification message with error code, error subcode and data.
- *
- * @throws BgpParseException while decoding and encoding notification message
- */
- @Test
- public void bgpNotificationMessageTest1() throws BgpParseException {
- byte[] notificationMsg = new byte[] {(byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00,
- 0x17, 0x03, 0x02, 0x02,
- (byte) 0xfe, (byte) 0xb0};
-
- byte[] testNotificationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(notificationMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message = null;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
- assertThat(message, instanceOf(BgpNotificationMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testNotificationMsg = buf.array();
-
- int iReadLen = buf.writerIndex() - 0;
- testNotificationMsg = new byte[iReadLen];
- buf.readBytes(testNotificationMsg, 0, iReadLen);
- assertThat(testNotificationMsg, is(notificationMsg));
- }
-
- /**
- * Notification message without data.
- *
- * @throws BgpParseException while decoding and encoding notification message
- */
- @Test
- public void bgpNotificationMessageTest2() throws BgpParseException {
- byte[] notificationMsg = new byte[] {(byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00,
- 0x15, 0x03, 0x02, 0x00};
-
- byte[] testNotificationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(notificationMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message = null;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
- assertThat(message, instanceOf(BgpNotificationMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testNotificationMsg = buf.array();
-
- int iReadLen = buf.writerIndex() - 0;
- testNotificationMsg = new byte[iReadLen];
- buf.readBytes(testNotificationMsg, 0, iReadLen);
- assertThat(testNotificationMsg, is(notificationMsg));
- }
-
- //Negative scenarios
- /**
- * Notification message with wrong maker value.
- *
- * @throws BgpParseException while decoding and encoding notification message
- */
- @Test(expected = BgpParseException.class)
- public void bgpNotificationMessageTest3() throws BgpParseException {
- byte[] notificationMsg = new byte[] {(byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- 0x01, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00,
- 0x15, 0x03, 0x02, 0x00};
-
- byte[] testNotificationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(notificationMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message = null;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
- assertThat(message, instanceOf(BgpNotificationMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testNotificationMsg = buf.array();
-
- int iReadLen = buf.writerIndex() - 0;
- testNotificationMsg = new byte[iReadLen];
- buf.readBytes(testNotificationMsg, 0, iReadLen);
- assertThat(testNotificationMsg, is(notificationMsg));
- }
-
- /**
- * Notification message without error subcode.
- *
- * @throws BgpParseException while decoding and encoding notification message
- */
- @Test(expected = BgpParseException.class)
- public void bgpNotificationMessageTest4() throws BgpParseException {
- byte[] notificationMsg = new byte[] {(byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00,
- 0x14, 0x03, 0x02};
-
- byte[] testNotificationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(notificationMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message = null;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
- assertThat(message, instanceOf(BgpNotificationMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testNotificationMsg = buf.array();
-
- int iReadLen = buf.writerIndex() - 0;
- testNotificationMsg = new byte[iReadLen];
- buf.readBytes(testNotificationMsg, 0, iReadLen);
- assertThat(testNotificationMsg, is(notificationMsg));
- }
-
- /**
- * Notification message with wrong message length.
- *
- * @throws BgpParseException while decoding and encoding notification message
- */
- @Test(expected = BgpParseException.class)
- public void bgpNotificationMessageTest5() throws BgpParseException {
- byte[] notificationMsg = new byte[] {(byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00,
- 0x14, 0x03, 0x02, 0x02};
-
- byte[] testNotificationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(notificationMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message = null;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
- assertThat(message, instanceOf(BgpNotificationMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testNotificationMsg = buf.array();
-
- int iReadLen = buf.writerIndex() - 0;
- testNotificationMsg = new byte[iReadLen];
- buf.readBytes(testNotificationMsg, 0, iReadLen);
- assertThat(testNotificationMsg, is(notificationMsg));
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpOpenMsgTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpOpenMsgTest.java
deleted file mode 100755
index 1fe4036f..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpOpenMsgTest.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.types.BgpHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-/**
- * Test cases for BGP Open Message.
- */
-public class BgpOpenMsgTest {
-
- /**
- * This test case checks open message without optional parameter.
- */
- @Test
- public void openMessageTest1() throws BgpParseException {
- //Open message without optional parameter
- byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- 0x00, 0x1d, 0x01, 0X04, (byte) 0xfe, 0x09, 0x00,
- (byte) 0xb4, (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f,
- 0x00};
-
- byte[] testOpenMsg;
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
- }
-
- /**
- * This test case checks open message with Multiprotocol extension
- * capability.
- */
- @Test
- public void openMessageTest2() throws BgpParseException {
-
- // OPEN Message (MultiProtocolExtension-CAPABILITY).
- byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, 0x00, 0x25,
- 0x01, //BGP Header
- 0X04, //Version
- (byte) 0x00, (byte) 0xc8, // AS Number
- 0x00, (byte) 0xb4, // Hold time
- (byte) 0xb6, (byte) 0x02, 0x5d,
- (byte) 0xc8, // BGP Identifier
- 0x08, 0x02, 0x06, // Opt Parameter length
- 0x01, 0x04, 0x00, 0x00, 0x00, (byte) 0xc8}; // Multiprotocol CAPABILITY
-
- byte[] testOpenMsg;
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
- }
-
- /**
- * This test case checks open message with Four-octet AS number
- * capability.
- */
- @Test
- public void openMessageTest3() throws BgpParseException {
-
- // OPEN Message (Four-Octet AS number capability).
- byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, 0x00, 0x25,
- 0x01, //BGPHeader
- 0X04, //Version
- (byte) 0x00, (byte) 0xc8, //AS Number
- 0x00, (byte) 0xb4, //Hold Time
- (byte) 0xb6, (byte) 0x02, 0x5d,
- (byte) 0xc8, //BGP Identifier
- 0x08, 0x02, 0x06, //Opt Parameter Length
- 0x41, 0x04, 0x00, 0x01, 0x00, 0x01}; //Four Octet AS Number-CAPABILITY-TLV
-
- byte[] testOpenMsg;
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
- }
-
- /**
- * This test case checks open message with capabilities.
- */
- @Test
- public void openMessageTest4() throws BgpParseException {
-
- // OPEN Message with capabilities.
- byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, 0x00, 0x2b,
- 0x01, //BGPHeader
- 0X04, //Version
- (byte) 0x00, (byte) 0xc8, //AS Number
- 0x00, (byte) 0xb4, //Hold Time
- (byte) 0xb6, (byte) 0x02, 0x5d, (byte) 0xc8, //BGP Identifier
- 0x0e, 0x02, 0x0c, //Opt Parameter Length
- 0x01, 0x04, 0x00, 0x00, 0x00, (byte) 0xc8, // Multiprotocol extension capability
- 0x41, 0x04, 0x00, 0x01, 0x00, 0x01}; //Four Octet AS Number-CAPABILITY-TLV
-
- byte[] testOpenMsg;
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpOpenMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
- }
-
- /**
- * In this test case, Invalid version is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void openMessageTest5() throws BgpParseException {
-
- // OPEN Message with invalid version number.
- byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, 0x00, 0x1d, 0x01, 0X05,
- (byte) 0xfe, 0x09, 0x00, (byte) 0xb4,
- (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f,
- 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpOpenMsg.class));
- }
-
- /**
- * In this test case, Marker is set as 0 in input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void openMessageTest6() throws BgpParseException {
-
- // OPEN Message with marker set to 0.
- byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0x00, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- 0x00, 0x00, 0x1d, 0x01, 0X04,
- (byte) 0xfe, 0x09, 0x00, (byte) 0xb4,
- (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f,
- 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpOpenMsg.class));
- }
-
- /**
- * In this test case, Invalid message length is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void openMessageTest7() throws BgpParseException {
-
- // OPEN Message with invalid header length.
- byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, 0x00, 0x1e, 0x01, 0X04,
- (byte) 0xfe, 0x09, 0x00, (byte) 0xb4,
- (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f,
- 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpOpenMsg.class));
- }
-
- /**
- * In this test case, Invalid message type is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void openMessageTest8() throws BgpParseException {
-
- // OPEN Message with invalid message type.
- byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, 0x00, 0x1d, 0x05, 0X04,
- (byte) 0xfe, 0x09, 0x00, (byte) 0xb4,
- (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f,
- 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpOpenMsg.class));
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpUpdateMsgTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpUpdateMsgTest.java
deleted file mode 100755
index 8e1cd202..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpUpdateMsgTest.java
+++ /dev/null
@@ -1,1496 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.protocol;
-
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType;
-import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors;
-import org.onosproject.bgpio.protocol.ver4.BgpPathAttributes;
-import org.onosproject.bgpio.types.As4Path;
-import org.onosproject.bgpio.types.AsPath;
-import org.onosproject.bgpio.types.AutonomousSystemTlv;
-import org.onosproject.bgpio.types.BgpHeader;
-import org.onosproject.bgpio.types.BgpLSIdentifierTlv;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.IPReachabilityInformationTlv;
-import org.onosproject.bgpio.types.IsIsNonPseudonode;
-import org.onosproject.bgpio.types.IsIsPseudonode;
-import org.onosproject.bgpio.types.Med;
-import org.onosproject.bgpio.types.MpReachNlri;
-import org.onosproject.bgpio.types.MpUnReachNlri;
-import org.onosproject.bgpio.types.Origin;
-import org.onosproject.bgpio.types.NextHop;
-import org.onosproject.bgpio.types.LocalPref;
-import org.onosproject.bgpio.types.Origin.ORIGINTYPE;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- * Test cases for BGP update Message.
- */
-public class BgpUpdateMsgTest {
- protected static final Logger log = LoggerFactory.getLogger(BgpUpdateMsgTest.class);
- public static final byte[] MARKER = new byte[]{(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff};
- public static final byte UPDATE_MSG_TYPE = 0x2;
-
- /**
- * This test case checks update message with no withdrawn routes
- * and path attributes.
- */
- @Test
- public void bgpUpdateMessageTest01() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x17, 0x02, 0x00, 0x00, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- BgpUpdateMsg other = (BgpUpdateMsg) message;
-
- assertThat(other.getHeader().getMarker(), is(MARKER));
- assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
- assertThat(other.getHeader().getLength(), is((short) 23));
- }
-
- /**
- * In this test case, Marker is set as 0 in input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest02() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- 0x00, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x17, 0x02, 0x00, 0x00, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid message length is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest03() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x00, 0x18, 0x02, 0x00, 0x00, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid message type is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest04() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x00, 0x17, 0x06, 0x00, 0x00, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * This test case checks update message with withdrawn routes.
- */
- @Test
- public void bgpUpdateMessageTest05() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x1b, 0x02, 0x00, 0x04, 0x18, 0x0a, 0x01, 0x01, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- BgpUpdateMsg other = (BgpUpdateMsg) message;
-
- assertThat(other.getHeader().getMarker(), is(MARKER));
- assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
- assertThat(other.getHeader().getLength(), is((short) 27));
-
- ListIterator<IpPrefix> listIterator1 = other.withdrawnRoutes().listIterator();
- byte[] prefix = new byte[] {0x0a, 0x01, 0x01, 0x00};
-
- IpPrefix testPrefixValue = listIterator1.next();
- assertThat(testPrefixValue.prefixLength(), is((int) 24));
- assertThat(testPrefixValue.address().toOctets(), is(prefix));
- }
-
- /**
- * In this test case, Invalid withdrawn route length is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest06() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x1b, 0x02, 0x00, 0x04, 0x19, 0x0a, 0x01, 0x01, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * This test case checks update message with path attributes.
- */
- @Test
- public void bgpUpdateMessageTest07() throws BgpParseException {
- byte[] updateMsg = new byte [] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x3f, 0x02, 0x00, 0x00, 0x00, 0x1c, 0x40, 0x01, 0x01,
- 0x00, 0x40, 0x02, 0x00, 0x40, 0x03, 0x04, 0x03, 0x03, 0x03, 0x03, (byte) 0x80, 0x04, 0x04, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x05, 0x04, 0x00, 0x00, 0x00, 0x64, 0x18, 0x0a, 0x1e, 0x03, 0x18, 0x0a, 0x1e,
- 0x02, 0x18, 0x0a, 0x1e, 0x01};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- BgpUpdateMsg other = (BgpUpdateMsg) message;
-
- assertThat(other.getHeader().getMarker(), is(MARKER));
- assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
- assertThat(other.getHeader().getLength(), is((short) 63));
-
- BgpValueType testPathAttribute;
- Origin origin;
- AsPath asPath;
- NextHop nexthop;
- Med med;
- LocalPref localPref;
-
- List<BgpValueType> pathAttributes = new LinkedList<>();
- BgpPathAttributes actualpathAttribute = other.bgpPathAttributes();
- pathAttributes = actualpathAttribute.pathAttributes();
- ListIterator<BgpValueType> listIterator = pathAttributes.listIterator();
- ORIGINTYPE originValue = org.onosproject.bgpio.types.Origin.ORIGINTYPE.IGP;
-
- testPathAttribute = listIterator.next();
- origin = (Origin) testPathAttribute;
- assertThat(origin.origin(), is(originValue));
-
- testPathAttribute = listIterator.next(); // AS PATH value is empty in hex dump
- asPath = (AsPath) testPathAttribute;
- List<Short> asPathValues = asPath.asPathSeq();
- assertThat(asPathValues.isEmpty(), is(true));
-
- testPathAttribute = listIterator.next();
- nexthop = (NextHop) testPathAttribute;
- byte[] nextHopAddr = new byte[] {0x03, 0x03, 0x03, 0x03};
- assertThat(nexthop.nextHop().toOctets(), is(nextHopAddr));
-
- testPathAttribute = listIterator.next();
- med = (Med) testPathAttribute;
- assertThat(med.med(), is(0));
-
- testPathAttribute = listIterator.next();
- localPref = (LocalPref) testPathAttribute;
- assertThat(localPref.localPref(), is(100));
-
- ListIterator<IpPrefix> listIterator1 = other.nlri().listIterator();
- byte[] prefix = new byte[] {0x0a, 0x1e, 0x03, 0x00};
-
- IpPrefix testPrefixValue = listIterator1.next();
- assertThat(testPrefixValue.prefixLength(), is((int) 24));
- assertThat(testPrefixValue.address().toOctets(), is(prefix));
- }
-
- /**
- * In this test case, Invalid ORIGIN flags is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest08() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x60, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x49, //path attribute len
- (byte) 0xff, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0e, 0x34, 0x40, 0x04, 0x47, //mpreach with safi = 71
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x01, 0x00,
- 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
- 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid ORIGIN value is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest09() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x60, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x49, //path attribute len
- (byte) 0xff, 0x01, 0x04, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0e, 0x34, 0x40, 0x04, 0x47, //mpreach with safi = 71
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x01, 0x00,
- 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
- 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, update message without path attribute is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest10() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x1a, 0x02, 0x00, 0x04, 0x18, 0x0a, 0x01, 0x01, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, update message with incorrect path attribute length is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest11() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x1b, 0x02, 0x00, 0x04, 0x18, 0x0a, 0x01, 0x01, 0x00, 0x01};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid MED flags is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest12() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x60, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x49, //path attribute len
- (byte) 0xff, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0xff, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0e, 0x34, 0x40, 0x04, 0x47, //mpreach with safi = 71
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x01, 0x00,
- 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
- 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid AS Path flags is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest13() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x60, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x49, //path attribute len
- (byte) 0xff, 0x01, 0x01, 0x00, //origin
- (byte) 0xff, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0e, 0x34, 0x40, 0x04, 0x47, //mpreach with safi = 71
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x01, 0x00,
- 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
- 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid MP reach flags is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest14() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x60, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x49, //path attribute len
- (byte) 0xff, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0xff, 0x0e, 0x34, 0x40, 0x04, 0x47, //mpreach with safi = 71
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x01, 0x00,
- 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
- 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid SAFI is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest15() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x60, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x49, //path attribute len
- (byte) 0xff, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0e, 0x34, 0x40, 0x04, 0x49, //mpreach with safi = 71
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x01, 0x00,
- 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
- 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid AFI is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest16() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x60, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x49, //path attribute len
- (byte) 0xff, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0e, 0x34, 0x40, 0x06, 0x47, //mpreach with safi = 71
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x01, 0x00,
- 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
- 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid res is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest17() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x60, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x49, //path attribute len
- (byte) 0xff, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0e, 0x34, 0x40, 0x04, 0x47, //mpreach with safi = 71
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x01, //reserved
- 0x00, 0x01, 0x00,
- 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
- 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * This test case checks update message with node NLRI.
- */
- @Test
- public void bgpUpdateMessageTest18() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x60, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x49, //path attribute len
- 0x04, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0e, 0x34, 0x40, 0x04, 0x47, //mpreach with safi = 71
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x01, 0x00,
- 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
- 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- BgpUpdateMsg other = (BgpUpdateMsg) message;
-
- assertThat(other.getHeader().getMarker(), is(MARKER));
- assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
- assertThat(other.getHeader().getLength(), is((short) 96));
-
- BgpValueType testPathAttribute;
- Origin origin;
- AsPath asPath;
- Med med;
- MpReachNlri mpReach;
- List<BgpValueType> pathAttributes = new LinkedList<>();
- BgpPathAttributes actualpathAttribute = other.bgpPathAttributes();
- pathAttributes = actualpathAttribute.pathAttributes();
- ListIterator<BgpValueType> listIterator = pathAttributes.listIterator();
- ORIGINTYPE originValue = org.onosproject.bgpio.types.Origin.ORIGINTYPE.IGP;
-
- testPathAttribute = listIterator.next();
- origin = (Origin) testPathAttribute;
- assertThat(origin.origin(), is(originValue));
-
- testPathAttribute = listIterator.next();
- asPath = (AsPath) testPathAttribute;
- ListIterator<Short> listIterator2 = asPath.asPathSeq().listIterator();
- assertThat(listIterator2.next(), is((short) 65001));
-
- testPathAttribute = listIterator.next();
- med = (Med) testPathAttribute;
- assertThat(med.med(), is(0));
-
- testPathAttribute = listIterator.next();
- mpReach = (MpReachNlri) testPathAttribute;
- assertThat(mpReach.mpReachNlriLen(), is((int) 52));
- assertThat(mpReach.getType(), is((short) 14));
-
- List<BgpLSNlri> testMpReachNlri = new LinkedList<>();
- testMpReachNlri = mpReach.mpReachNlri();
-
- ListIterator<BgpLSNlri> list1 = testMpReachNlri.listIterator();
- BgpLSNlri testnlri = list1.next();
- NlriType nlriType = org.onosproject.bgpio.protocol.NlriType.NODE;
- ProtocolType protocolId = org.onosproject.bgpio.protocol.linkstate.
- BgpNodeLSNlriVer4.ProtocolType.ISIS_LEVEL_TWO;
- assertThat(testnlri.getIdentifier(), is((long) 0));
- assertThat(testnlri.getNlriType(), is(nlriType));
- assertThat(testnlri.getProtocolId(), is(protocolId));
-
- BgpNodeLSNlriVer4 testNodenlri = (BgpNodeLSNlriVer4) testnlri;
-
- BgpNodeLSIdentifier testLocalNodeDescriptors = testNodenlri.getLocalNodeDescriptors();
-
- List<BgpValueType> testSubTlvs = new LinkedList<>();
- NodeDescriptors localNodeDescriptors = testLocalNodeDescriptors.getNodedescriptors();
- testSubTlvs = localNodeDescriptors.getSubTlvs();
- ListIterator<BgpValueType> subtlvlist1 = testSubTlvs.listIterator();
-
- AutonomousSystemTlv testAutonomousSystemTlv = (AutonomousSystemTlv) subtlvlist1.next();
- assertThat(testAutonomousSystemTlv.getAsNum(), is(2222));
- assertThat(testAutonomousSystemTlv.getType(), is((short) 512));
-
- BgpLSIdentifierTlv testBGPLSIdentifierTlv = (BgpLSIdentifierTlv) subtlvlist1.next();
- assertThat(testBGPLSIdentifierTlv.getBgpLsIdentifier(), is(33686018));
- assertThat(testBGPLSIdentifierTlv.getType(), is((short) 513));
-
- IsIsNonPseudonode testIsIsNonPseudonode = (IsIsNonPseudonode) subtlvlist1.next();
- byte[] expISONodeID = new byte[] {0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58};
- assertThat(testIsIsNonPseudonode.getISONodeID(), is(expISONodeID));
- assertThat(testIsIsNonPseudonode.getType(), is((short) 515));
-
- }
-
- /**
- * This test case checks update message with prefix NLRI.
- */
- @Test
- public void bgpUpdateMessageTest19() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, (byte) 0xd6, 0x02, 0x00, 0x04,
- 0x18, 0x0a, 0x01, 0x01, //withdrawn routes
- 0x00, (byte) 0xbb, //path attribute len
- 0x04, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x90, 0x0e, 0x00, (byte) 0xa5, 0x40, 0x04, 0x47, //mpreach
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x03, 0x00, 0x30, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x1a, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08,
- (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x03, 0x00, 0x06, 0x19, 0x21, 0x68,
- 0x07, 0x70, 0x01, 0x01, 0x09, 0x00, 0x05, 0x20,
- (byte) 0xc0, (byte) 0xa8, 0x4d, 0x01, 0x00, 0x03, 0x00, 0x30,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00,
- 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00,
- 0x06, 0x19, 0x00, (byte) 0x95, 0x02, 0x50, 0x21, 0x01,
- 0x09, 0x00, 0x05, 0x20, 0x15, 0x15, 0x15, 0x15,
- 0x00, 0x03, 0x00, 0x30, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x1a, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08,
- (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x03, 0x00, 0x06, 0x02, 0x20, 0x22,
- 0x02, 0x20, 0x22, 0x01, 0x09, 0x00, 0x05, 0x20,
- 0x16, 0x16, 0x16, 0x16}; // prefix nlri
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- BgpUpdateMsg other = (BgpUpdateMsg) message;
-
- assertThat(other.getHeader().getMarker(), is(MARKER));
- assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
- assertThat(other.getHeader().getLength(), is((short) 214));
-
- ListIterator<IpPrefix> listIterator1 = other.withdrawnRoutes().listIterator();
- byte[] prefix = new byte[] {0x0a, 0x01, 0x01, 0x00};
-
- IpPrefix testPrefixValue = listIterator1.next();
- assertThat(testPrefixValue.prefixLength(), is((int) 24));
- assertThat(testPrefixValue.address().toOctets(), is(prefix));
-
- BgpValueType testPathAttribute;
- Origin origin;
- AsPath asPath;
- Med med;
- MpReachNlri mpReach;
- List<BgpValueType> pathAttributes = new LinkedList<>();
- BgpPathAttributes actualpathAttribute = other.bgpPathAttributes();
- pathAttributes = actualpathAttribute.pathAttributes();
- ListIterator<BgpValueType> listIterator = pathAttributes.listIterator();
- ORIGINTYPE originValue = org.onosproject.bgpio.types.Origin.ORIGINTYPE.IGP;
-
- testPathAttribute = listIterator.next();
- origin = (Origin) testPathAttribute;
- assertThat(origin.origin(), is(originValue));
-
- testPathAttribute = listIterator.next();
- asPath = (AsPath) testPathAttribute;
- ListIterator<Short> listIterator2 = asPath.asPathSeq().listIterator();
- assertThat(listIterator2.next(), is((short) 65001));
-
- testPathAttribute = listIterator.next();
- med = (Med) testPathAttribute;
- assertThat(med.med(), is(0));
-
- testPathAttribute = listIterator.next();
- mpReach = (MpReachNlri) testPathAttribute;
- assertThat(mpReach.mpReachNlriLen(), is((int) 165));
- assertThat(mpReach.getType(), is((short) 14));
-
- List<BgpLSNlri> testMpReachNlri = new LinkedList<>();
- testMpReachNlri = mpReach.mpReachNlri();
-
- ListIterator<BgpLSNlri> list1 = testMpReachNlri.listIterator();
- BgpLSNlri testnlri = list1.next();
- NlriType nlriType = org.onosproject.bgpio.protocol.NlriType.PREFIX_IPV4;
- ProtocolType protocolId = org.onosproject.bgpio.protocol.linkstate.
- BgpNodeLSNlriVer4.ProtocolType.ISIS_LEVEL_TWO;
- assertThat(testnlri.getIdentifier(), is((long) 0));
- assertThat(testnlri.getNlriType(), is(nlriType));
- assertThat(testnlri.getProtocolId(), is(protocolId));
-
- BgpPrefixLSNlri testprefixnlri = (BgpPrefixLSNlri) testnlri;
-
- NodeDescriptors testLocalNodeDescriptors = testprefixnlri.getLocalNodeDescriptors();
-
- List<BgpValueType> testSubTlvs = new LinkedList<>();
- testSubTlvs = testLocalNodeDescriptors.getSubTlvs();
- ListIterator<BgpValueType> subtlvlist1 = testSubTlvs.listIterator();
-
- AutonomousSystemTlv testAutonomousSystemTlv = (AutonomousSystemTlv) subtlvlist1.next();
- assertThat(testAutonomousSystemTlv.getAsNum(), is(2222));
- assertThat(testAutonomousSystemTlv.getType(), is((short) 512));
-
- BgpLSIdentifierTlv testBGPLSIdentifierTlv = (BgpLSIdentifierTlv) subtlvlist1.next();
- assertThat(testBGPLSIdentifierTlv.getBgpLsIdentifier(), is(33686018));
- assertThat(testBGPLSIdentifierTlv.getType(), is((short) 513));
-
- IsIsNonPseudonode testIsIsNonPseudonode = (IsIsNonPseudonode) subtlvlist1.next();
- byte[] expISONodeID = new byte[] {0x19, 0x21, 0x68, 0x07, 0x70, 0x01};
- assertThat(testIsIsNonPseudonode.getISONodeID(), is(expISONodeID));
- assertThat(testIsIsNonPseudonode.getType(), is((short) 515));
-
- List<BgpValueType> testPrefixDescriptors = new LinkedList<>();
- testPrefixDescriptors = testprefixnlri.getPrefixdescriptor();
- ListIterator<BgpValueType> subtlvlist2 = testPrefixDescriptors.listIterator();
- IPReachabilityInformationTlv testIPReachabilityInformationTlv = (IPReachabilityInformationTlv)
- subtlvlist2.next();
- byte[] address = new byte[] {(byte) 0xc0, (byte) 0xa8, 0x4d, 0x01};
- IpPrefix prefix1 = IpPrefix.valueOf(IpAddress.Version.INET, address, 32);
- assertThat(testIPReachabilityInformationTlv.getPrefixValue(), is(prefix1));
- assertThat(testIPReachabilityInformationTlv.getPrefixLen(), is((byte) 32));
- }
-
- /**
- * This test case checks update message with link NLRI.
- */
- @Test
- public void bgpUpdateMessageTest20() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, (byte) 0x83, 0x02, 0x00, 0x04,
- 0x18, 0x0a, 0x01, 0x01, //withdrawn routes
- 0x00, 0x68, //path attribute len
- 0x04, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0e, 0x53, 0x40, 0x04, 0x47, //mpreach
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x02, 0x00, 0x46, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1b, 0x02, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00, 0x07, 0x19, 0x00,
- (byte) 0x95, 0x02, 0x50, 0x21, 0x03, 0x01, 0x01, 0x00, 0x1a, 0x02,
- 0x00, 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00,
- 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00, 0x06, 0x19,
- 0x00, (byte) 0x95, 0x02, 0x50, 0x21//link nlri
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message = null;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- BgpUpdateMsg other = (BgpUpdateMsg) message;
-
- assertThat(other.getHeader().getMarker(), is(MARKER));
- assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
- assertThat(other.getHeader().getLength(), is((short) 131));
-
- ListIterator<IpPrefix> listIterator1 = other.withdrawnRoutes().listIterator();
- byte[] prefix = new byte[] {0x0a, 0x01, 0x01, 0x00};
-
- IpPrefix testPrefixValue = listIterator1.next();
- assertThat(testPrefixValue.prefixLength(), is((int) 24));
- assertThat(testPrefixValue.address().toOctets(), is(prefix));
-
- BgpValueType testPathAttribute;
- Origin origin;
- AsPath asPath;
- Med med;
- MpReachNlri mpReach;
-
- List<BgpValueType> pathAttributes = new LinkedList<>();
- BgpPathAttributes actualpathAttribute = other.bgpPathAttributes();
- pathAttributes = actualpathAttribute.pathAttributes();
- ListIterator<BgpValueType> listIterator = pathAttributes.listIterator();
- ORIGINTYPE originValue = org.onosproject.bgpio.types.Origin.ORIGINTYPE.IGP;
-
- testPathAttribute = listIterator.next();
- origin = (Origin) testPathAttribute;
- assertThat(origin.origin(), is(originValue));
-
- testPathAttribute = listIterator.next();
- asPath = (AsPath) testPathAttribute;
- ListIterator<Short> listIterator2 = asPath.asPathSeq().listIterator();
- assertThat(listIterator2.next(), is((short) 65001));
-
- testPathAttribute = listIterator.next();
- med = (Med) testPathAttribute;
- assertThat(med.med(), is(0));
-
- testPathAttribute = listIterator.next();
- mpReach = (MpReachNlri) testPathAttribute;
- assertThat(mpReach.mpReachNlriLen(), is((int) 83));
- assertThat(mpReach.getType(), is((short) 14));
-
- List<BgpLSNlri> testMpReachNlri = new LinkedList<>();
- testMpReachNlri = mpReach.mpReachNlri();
-
- ListIterator<BgpLSNlri> list1 = testMpReachNlri.listIterator();
- BgpLSNlri testnlri = list1.next();
- NlriType nlriType = org.onosproject.bgpio.protocol.NlriType.LINK;
- ProtocolType protocolId = org.onosproject.bgpio.protocol.linkstate.
- BgpNodeLSNlriVer4.ProtocolType.ISIS_LEVEL_TWO;
- assertThat(testnlri.getIdentifier(), is((long) 0));
- assertThat(testnlri.getNlriType(), is(nlriType));
- assertThat(testnlri.getProtocolId(), is(protocolId));
-
- BgpLinkLsNlriVer4 testlinknlri = (BgpLinkLsNlriVer4) testnlri;
-
- NodeDescriptors testLocalNodeDescriptors = testlinknlri.localNodeDescriptors();
-
- List<BgpValueType> testSubTlvs = new LinkedList<>();
- testSubTlvs = testLocalNodeDescriptors.getSubTlvs();
- ListIterator<BgpValueType> subtlvlist1 = testSubTlvs.listIterator();
-
- AutonomousSystemTlv testAutonomousSystemTlv = (AutonomousSystemTlv) subtlvlist1.next();
-
- assertThat(testAutonomousSystemTlv.getAsNum(), is(2222));
- assertThat(testAutonomousSystemTlv.getType(), is((short) 512));
-
- BgpLSIdentifierTlv testBGPLSIdentifierTlv = (BgpLSIdentifierTlv) subtlvlist1.next();
- assertThat(testBGPLSIdentifierTlv.getBgpLsIdentifier(), is(33686018));
- assertThat(testBGPLSIdentifierTlv.getType(), is((short) 513));
-
- IsIsPseudonode testIsIsPseudonode = (IsIsPseudonode) subtlvlist1.next();
- assertThat(testIsIsPseudonode.getPSNIdentifier(), is((byte) 3));
- assertThat(testIsIsPseudonode.getType(), is((short) 515));
-
- NodeDescriptors testRemoteNodeDescriptors = testlinknlri.remoteNodeDescriptors();
- testSubTlvs = testRemoteNodeDescriptors.getSubTlvs();
- ListIterator<BgpValueType> subtlvlist2 = testSubTlvs.listIterator();
-
- testAutonomousSystemTlv = (AutonomousSystemTlv) subtlvlist2.next();
-
- assertThat(testAutonomousSystemTlv.getAsNum(), is(2222));
- assertThat(testAutonomousSystemTlv.getType(), is((short) 512));
-
- testBGPLSIdentifierTlv = (BgpLSIdentifierTlv) subtlvlist2.next();
- assertThat(testBGPLSIdentifierTlv.getBgpLsIdentifier(), is(33686018));
- assertThat(testBGPLSIdentifierTlv.getType(), is((short) 513));
-
- IsIsNonPseudonode testIsIsNonPseudonode = (IsIsNonPseudonode) subtlvlist2.next();
- byte[] expISONodeID = new byte[] {0x19, 0x00, (byte) 0x95, 0x02, 0x50, 0x21};
- assertThat(testIsIsNonPseudonode.getISONodeID(), is(expISONodeID));
- assertThat(testIsIsNonPseudonode.getType(), is((short) 515));
- }
-
- /**
- * In this test case, Invalid withdrawn route length is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest21() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x1b, 0x02, 0x00, 0x07, 0x18, 0x0a, 0x01, 0x01, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid withdrawn route length is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest22() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x25, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x0e, //path attribute len
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00}; //med
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Mandatory attributes are not given in input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest23() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x29, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x12, //path attribute len
- 0x0e, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00}; //med
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid origin length is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest24() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x29, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x12, //path attribute len
- 0x04, 0x01, 0x02, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00}; //med
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid origin value is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest25() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x29, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x12, //path attribute len
- 0x04, 0x01, 0x01, 0x04, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00}; //med
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid descriptor type in node nlri is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest26() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x60, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x49, //path attribute len
- 0x04, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0e, 0x34, 0x40, 0x04, 0x47, //mpreach with safi = 71
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x01, 0x00,
- 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x1a, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
- 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, Invalid node nlri length field in is given as input and expecting
- * an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest27() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x60, 0x02, 0x00, 0x00, //withdrawn len
- 0x00, 0x49, //path attribute len
- 0x04, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0e, 0x34, 0x40, 0x04, 0x47, //mpreach with safi = 71
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x01, 0x00,
- 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1b, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
- 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, withdrawn routes with prefix length 0 is given as input and expecting
- * an exception.
- */
- @Test
- public void bgpUpdateMessageTest28() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, //marker
- 0x00, 0x18, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * In this test case, update message without total Path Attribute Length field is given as
- * input and expecting an exception.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest29() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, //marker
- 0x00, 0x16, 0x02, 0x00, 0x01, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * This test case checks update message with as4 path attribute.
- */
- @Test
- public void bgpUpdateMessageTest30() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- 0x00, 0x3a, 0x02, 0x00, 0x00, 0x00, 0x21, 0x40, 0x01, 0x01, 0x00, (byte) 0xc0,
- 0x11, 0x0a, 0x02, 0x02, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x28, 0x00, 0x01, 0x40,
- 0x02, 0x06, 0x02, 0x02, 0x5b, (byte) 0xa0, 0x5b, (byte) 0xa0, 0x40, 0x03, 0x04,
- (byte) 0xac, 0x10, 0x03, 0x01, 0x08, 0x28};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message = null;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- BgpUpdateMsg other = (BgpUpdateMsg) message;
-
- assertThat(other.getHeader().getMarker(), is(MARKER));
- assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
- assertThat(other.getHeader().getLength(), is((short) 58));
-
- BgpValueType testPathAttribute;
- Origin origin;
- As4Path as4Path;
- AsPath asPath;
- NextHop nextHop;
-
- List<BgpValueType> pathAttributes = new LinkedList<>();
- BgpPathAttributes actualpathAttribute = other.bgpPathAttributes();
- pathAttributes = actualpathAttribute.pathAttributes();
- ListIterator<BgpValueType> listIterator = pathAttributes.listIterator();
- ORIGINTYPE originValue = org.onosproject.bgpio.types.Origin.ORIGINTYPE.IGP;
-
- testPathAttribute = listIterator.next();
- origin = (Origin) testPathAttribute;
- assertThat(origin.origin(), is(originValue));
-
- testPathAttribute = listIterator.next();
- as4Path = (As4Path) testPathAttribute;
- ListIterator<Integer> listIterator2 = as4Path.as4PathSEQ().listIterator();
- assertThat(listIterator2.next(), is(655361));
-
- testPathAttribute = listIterator.next();
- asPath = (AsPath) testPathAttribute;
- ListIterator<Short> listIterator3 = asPath.asPathSeq().listIterator();
- assertThat(listIterator3.next(), is((short) 23456));
-
- testPathAttribute = listIterator.next();
- nextHop = (NextHop) testPathAttribute;
- byte[] nextHopAddr = new byte[] {(byte) 0xac, 0x10, 0x03, 0x01};
- assertThat(nextHop.nextHop().toOctets(), is(nextHopAddr));
-
- ListIterator<IpPrefix> listIterator1 = other.nlri().listIterator();
- byte[] prefix = new byte[] {0x28, 0x00, 0x00, 0x00};
-
- IpPrefix testPrefixValue = listIterator1.next();
- assertThat(testPrefixValue.prefixLength(), is((int) 8));
- assertThat(testPrefixValue.address().toOctets(), is(prefix));
- }
-
- /**
- * This test case checks update message with MPUnreach.
- */
- @Test
- public void bgpUpdateMessageTest31() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x5e, 0x02, 0x00, 0x04, 0x18, 0x0a, 0x01, 0x01, //withdrawn routes
- 0x00, 0x43, //path attribute len
- 0x04, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0f, 0x2e, 0x40, 0x04, 0x47, //mpunreach with safi = 71
- 0x00, 0x01, 0x00,
- 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
- 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- BgpUpdateMsg other = (BgpUpdateMsg) message;
-
- assertThat(other.getHeader().getMarker(), is(MARKER));
- assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
- assertThat(other.getHeader().getLength(), is((short) 94));
-
- ListIterator<IpPrefix> listIterator1 = other.withdrawnRoutes().listIterator();
- byte[] prefix = new byte[] {0x0a, 0x01, 0x01, 0x00};
-
- IpPrefix testPrefixValue = listIterator1.next();
- assertThat(testPrefixValue.prefixLength(), is((int) 24));
- assertThat(testPrefixValue.address().toOctets(), is(prefix));
-
- BgpValueType testPathAttribute;
- Origin origin;
- AsPath asPath;
- Med med;
- MpUnReachNlri mpUnReach;
- List<BgpValueType> pathAttributes = new LinkedList<>();
- BgpPathAttributes actualpathAttribute = other.bgpPathAttributes();
- pathAttributes = actualpathAttribute.pathAttributes();
- ListIterator<BgpValueType> listIterator = pathAttributes.listIterator();
- ORIGINTYPE originValue = org.onosproject.bgpio.types.Origin.ORIGINTYPE.IGP;
-
- testPathAttribute = listIterator.next();
- origin = (Origin) testPathAttribute;
- assertThat(origin.origin(), is(originValue));
-
- testPathAttribute = listIterator.next();
- asPath = (AsPath) testPathAttribute;
- ListIterator<Short> listIterator2 = asPath.asPathSeq().listIterator();
- assertThat(listIterator2.next(), is((short) 65001));
-
- testPathAttribute = listIterator.next();
- med = (Med) testPathAttribute;
- assertThat(med.med(), is(0));
-
- testPathAttribute = listIterator.next();
- mpUnReach = (MpUnReachNlri) testPathAttribute;
- assertThat(mpUnReach.mpUnReachNlriLen(), is((int) 46));
- assertThat(mpUnReach.getType(), is((short) 15));
-
- List<BgpLSNlri> testMpUnReachNlri = new LinkedList<>();
- testMpUnReachNlri = mpUnReach.mpUnReachNlri();
-
- ListIterator<BgpLSNlri> list1 = testMpUnReachNlri.listIterator();
- BgpLSNlri testnlri = list1.next();
- NlriType nlriType = org.onosproject.bgpio.protocol.NlriType.NODE;
- ProtocolType protocolId = org.onosproject.bgpio.protocol.linkstate.
- BgpNodeLSNlriVer4.ProtocolType.ISIS_LEVEL_TWO;
- assertThat(testnlri.getIdentifier(), is((long) 0));
- assertThat(testnlri.getNlriType(), is(nlriType));
- assertThat(testnlri.getProtocolId(), is(protocolId));
-
- BgpNodeLSNlriVer4 testNodenlri = (BgpNodeLSNlriVer4) testnlri;
-
- BgpNodeLSIdentifier testLocalNodeDescriptors = testNodenlri.getLocalNodeDescriptors();
-
- List<BgpValueType> testSubTlvs = new LinkedList<>();
- NodeDescriptors localNodeDescriptors = testLocalNodeDescriptors.getNodedescriptors();
- testSubTlvs = localNodeDescriptors.getSubTlvs();
- ListIterator<BgpValueType> subtlvlist1 = testSubTlvs.listIterator();
-
- AutonomousSystemTlv testAutonomousSystemTlv = (AutonomousSystemTlv) subtlvlist1.next();
-
- assertThat(testAutonomousSystemTlv.getAsNum(), is(2222));
- assertThat(testAutonomousSystemTlv.getType(), is((short) 512));
-
- BgpLSIdentifierTlv testBGPLSIdentifierTlv = (BgpLSIdentifierTlv) subtlvlist1.next();
- assertThat(testBGPLSIdentifierTlv.getBgpLsIdentifier(), is(33686018));
- assertThat(testBGPLSIdentifierTlv.getType(), is((short) 513));
-
- IsIsNonPseudonode testIsIsNonPseudonode = (IsIsNonPseudonode) subtlvlist1.next();
- byte[] expISONodeID = new byte[] {0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58};
- assertThat(testIsIsNonPseudonode.getISONodeID(), is(expISONodeID));
- assertThat(testIsIsNonPseudonode.getType(), is((short) 515));
- }
-
- /**
- * This test case checks update message with invalid mpreach packet.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest32() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, (byte) 0xd6, 0x02, 0x00, 0x04,
- 0x18, 0x0a, 0x01, 0x01, //withdrawn routes
- 0x00, (byte) 0xbb, //path attribute len
- 0x04, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x90, 0x0e, 0x00, (byte) 0xa5, 0x40, 0x04, 0x47, //mpreach
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x03, 0x00, 0x30, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x1a, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08,
- (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x03, 0x00, 0x06, 0x19, 0x21, 0x68,
- 0x07, 0x70, 0x01, 0x01, 0x09, 0x00, 0x05, 0x20,
- (byte) 0xc0, (byte) 0xa8, 0x4d, 0x01, 0x00, 0x03, 0x00, 0x30,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00,
- 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00,
- 0x06, 0x19, 0x00, (byte) 0x95, 0x02, 0x50, 0x21, 0x01,
- 0x09, 0x00, 0x05, 0x20, 0x15, 0x15, 0x15, 0x15,
- 0x00, 0x03, 0x00, 0x30, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x1a, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08,
- (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x03, 0x00, 0x06, 0x02, 0x20, 0x22,
- 0x02, 0x20, 0x22, 0x01, 0x09, 0x00, 0x05, 0x20,
- 0x16, 0x16, 0x16, 0x16}; // prefix nlri
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * This test case checks update message with invalid prefix nlri length in input.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest33() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, (byte) 0xd6, 0x02, 0x00, 0x04,
- 0x18, 0x0a, 0x01, 0x01, //withdrawn routes
- 0x00, (byte) 0xbb, //path attribute len
- 0x04, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x90, 0x0e, 0x00, (byte) 0xa5, 0x40, 0x04, 0x47, //mpreach
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x03, 0x00, 0x35, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x1a, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08,
- (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x03, 0x00, 0x06, 0x19, 0x21, 0x68,
- 0x07, 0x70, 0x01, 0x01, 0x09, 0x00, 0x05, 0x20,
- (byte) 0xc0, (byte) 0xa8, 0x4d, 0x01, 0x00, 0x03, 0x00, 0x30,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00,
- 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00,
- 0x06, 0x19, 0x00, (byte) 0x95, 0x02, 0x50, 0x21, 0x01,
- 0x09, 0x00, 0x05, 0x20, 0x15, 0x15, 0x15, 0x15,
- 0x00, 0x03, 0x00, 0x30, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x1a, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08,
- (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x03, 0x00, 0x06, 0x02, 0x20, 0x22,
- 0x02, 0x20, 0x22, 0x01, 0x09, 0x00, 0x05, 0x20,
- 0x16, 0x16, 0x16, 0x16}; // prefix nlri
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-
- /**
- * This test case checks update message with invalid link nlri length in input.
- */
- @Test(expected = BgpParseException.class)
- public void bgpUpdateMessageTest34() throws BgpParseException {
- byte[] updateMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, (byte) 0x83, 0x02, 0x00, 0x04,
- 0x18, 0x0a, 0x01, 0x01, //withdrawn routes
- 0x00, 0x68, //path attribute len
- 0x04, 0x01, 0x01, 0x00, //origin
- 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
- (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
- (byte) 0x80, 0x0e, 0x53, 0x40, 0x04, 0x47, //mpreach
- 0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
- 0x00, //reserved
- 0x00, 0x02, 0x00, 0x48, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1b, 0x02, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00, 0x07, 0x19, 0x00,
- (byte) 0x95, 0x02, 0x50, 0x21, 0x03, 0x01, 0x01, 0x00, 0x1a, 0x02,
- 0x00, 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00,
- 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00, 0x06, 0x19,
- 0x00, (byte) 0x95, 0x02, 0x50, 0x21}; //link nlri
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- BgpMessage message;
- BgpHeader bgpHeader = new BgpHeader();
-
- message = reader.readFrom(buffer, bgpHeader);
-
- assertThat(message, instanceOf(BgpUpdateMsg.class));
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AreaIdTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AreaIdTest.java
deleted file mode 100644
index e11564ab..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AreaIdTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for AreaID Tlv.
- */
-public class AreaIdTest {
- private final int value1 = 10;
- private final int value2 = 20;
- private final AreaIDTlv tlv1 = AreaIDTlv.of(value1);
- private final AreaIDTlv sameAsTlv1 = AreaIDTlv.of(value1);
- private final AreaIDTlv tlv2 = AreaIDTlv.of(value2);
-
- @Test
- public void testEquality() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/As4PathTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/As4PathTest.java
deleted file mode 100755
index 3ea56b64..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/As4PathTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for As4Path BGP Path Attribute.
- */
-public class As4PathTest {
- //Two scenarios as4path set and sequence
- private final List<Integer> as4pathSet1 = new ArrayList<>();
- private final List<Integer> as4pathSeq1 = new ArrayList<>();
- private final List<Integer> as4pathSet2 = new ArrayList<>();
- private final List<Integer> as4pathSeq2 = new ArrayList<>();
- private final As4Path attr1 = new As4Path(as4pathSet1, null);
- private final As4Path sameAsAttr1 = new As4Path(as4pathSet1, null);
- private final As4Path attr2 = new As4Path(as4pathSet2, null);
- private final As4Path attr3 = new As4Path(null, as4pathSeq1);
- private final As4Path sameAsAttr3 = new As4Path(null, as4pathSeq1);
- private final As4Path attr4 = new As4Path(null, as4pathSeq2);
-
- @Test
- public void basics() {
- as4pathSet1.add(197358);
- as4pathSet1.add(12883);
- as4pathSet2.add(2008989);
- as4pathSeq1.add(3009009);
- as4pathSeq2.add(409900);
- new EqualsTester()
- .addEqualityGroup(attr1, sameAsAttr1)
- .addEqualityGroup(attr2)
- .addEqualityGroup(attr3, sameAsAttr3)
- .addEqualityGroup(attr4)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AsPathTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AsPathTest.java
deleted file mode 100644
index e56ec5a5..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AsPathTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for AsPath BGP Path Attribute.
- */
-public class AsPathTest {
- //Two scenarios aspath set and sequence
- private final List<Short> aspathSet1 = new ArrayList<>();
- private final List<Short> aspathSet2 = new ArrayList<>();
- private final List<Short> aspathSeq1 = new ArrayList<>();
- private final List<Short> aspathSeq2 = new ArrayList<>();
- private final AsPath attr1 = new AsPath(aspathSet1, null);
- private final AsPath sameAsAttr1 = new AsPath(aspathSet1, null);
- private final AsPath attr2 = new AsPath(aspathSet2, null);
- private final AsPath attr3 = new AsPath(null, aspathSeq1);
- private final AsPath sameAsAttr3 = new AsPath(null, aspathSeq1);
- private final AsPath attr4 = new AsPath(null, aspathSeq2);
-
- @Test
- public void basics() {
- aspathSet1.add((short) 100);
- aspathSet1.add((short) 300);
- aspathSet2.add((short) 200);
- aspathSeq2.add((short) 400);
- aspathSeq1.add((short) 300);
- new EqualsTester()
- .addEqualityGroup(attr1, sameAsAttr1)
- .addEqualityGroup(attr2)
- .addEqualityGroup(attr3, sameAsAttr3)
- .addEqualityGroup(attr4)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AutonomousSystemTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AutonomousSystemTest.java
deleted file mode 100644
index 1695583b..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AutonomousSystemTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for AutonomousSystem Tlv.
- */
-public class AutonomousSystemTest {
- private final int value1 = 101;
- private final int value2 = 201;
- private final AutonomousSystemTlv tlv1 = AutonomousSystemTlv.of(value1);
- private final AutonomousSystemTlv sameAsTlv1 = AutonomousSystemTlv.of(value1);
- private final AutonomousSystemTlv tlv2 = AutonomousSystemTlv.of(value2);
-
- @Test
- public void testEquality() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/BgpLSIdentifierTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/BgpLSIdentifierTest.java
deleted file mode 100644
index 59cf96fa..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/BgpLSIdentifierTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGPLSIdentifier Tlv.
- */
-public class BgpLSIdentifierTest {
- private final int value1 = 8738;
- private final int value2 = 13107;
- private final BgpLSIdentifierTlv tlv1 = BgpLSIdentifierTlv.of(value1);
- private final BgpLSIdentifierTlv sameAsTlv1 = new BgpLSIdentifierTlv(value1);
- private final BgpLSIdentifierTlv tlv2 = new BgpLSIdentifierTlv(value2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPReachabilityInformationTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPReachabilityInformationTest.java
deleted file mode 100644
index 7bea518a..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPReachabilityInformationTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for IPReachabilityInformation Tlv.
- */
-public class IPReachabilityInformationTest {
- private final byte[] value1 = new byte[] {(byte) 0xc0, (byte) 0xa8, 0x4d, 0x01};
- private final byte[] value2 = new byte[] {(byte) 0xc0};
- private final IPReachabilityInformationTlv tlv1 = IPReachabilityInformationTlv.of((byte) 0x17, value1, (short) 4);
- private final IPReachabilityInformationTlv sameAsTlv1 = IPReachabilityInformationTlv
- .of((byte) 0x17, value1, (short) 4);
- private final IPReachabilityInformationTlv tlv2 = IPReachabilityInformationTlv.of((byte) 0x05, value2, (short) 1);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv4AddressTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv4AddressTest.java
deleted file mode 100755
index fdb71189..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv4AddressTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for IPv4Address Tlv.
- */
-public class IPv4AddressTest {
- private final Ip4Address value1 = Ip4Address.valueOf("127.0.0.1");
- private final Ip4Address value2 = Ip4Address.valueOf("127.0.0.1");
- private final IPv4AddressTlv tlv1 = IPv4AddressTlv.of(value1, (short) 259);
- private final IPv4AddressTlv sameAsTlv1 = IPv4AddressTlv.of(value1, (short) 259);
- private final IPv4AddressTlv tlv2 = IPv4AddressTlv.of(value2, (short) 260);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv6AddressTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv6AddressTest.java
deleted file mode 100644
index 781935b4..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv6AddressTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-import org.onlab.packet.Ip6Address;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for IPv6Address Tlv.
- */
-public class IPv6AddressTest {
- private final Ip6Address value1 = Ip6Address.valueOf("2001:db8:0:0:0:0:2:1");
- private final Ip6Address value2 = Ip6Address.valueOf("2001:db8:0:0:0:0:2:1");
- private final IPv6AddressTlv tlv1 = IPv6AddressTlv.of(value1, (short) 261);
- private final IPv6AddressTlv sameAsTlv1 = IPv6AddressTlv.of(value1, (short) 261);
- private final IPv6AddressTlv tlv2 = IPv6AddressTlv.of(value2, (short) 262);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IsIsNonPseudonodeTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IsIsNonPseudonodeTest.java
deleted file mode 100644
index 7ce4d5d3..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IsIsNonPseudonodeTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for IsIsNonPseudonode Tlv.
- */
-public class IsIsNonPseudonodeTest {
- private final byte[] value1 = new byte[] {0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58};
- private final byte[] value2 = new byte[] {0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x59};
- private final IsIsNonPseudonode tlv1 = IsIsNonPseudonode.of(value1);
- private final IsIsNonPseudonode sameAsTlv1 = IsIsNonPseudonode.of(value1);
- private final IsIsNonPseudonode tlv2 = IsIsNonPseudonode.of(value2);
-
- @Test
- public void testEquality() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IsIsPseudonodeTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IsIsPseudonodeTest.java
deleted file mode 100644
index a2a7c2b5..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IsIsPseudonodeTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for IsIsPseudonode Tlv.
- */
-public class IsIsPseudonodeTest {
- private final byte[] value1 = new byte[] {0x01, 0x02, 0x01, 0x02, 0x01, 0x02};
- private final byte[] value2 = new byte[] {0x01, 0x02, 0x01, 0x02, 0x01, 0x03};
- private final IsIsPseudonode tlv1 = IsIsPseudonode.of(value1, (byte) 1);
- private final IsIsPseudonode sameAsTlv1 = IsIsPseudonode.of(value1, (byte) 1);
- private final IsIsPseudonode tlv2 = IsIsPseudonode.of(value2, (byte) 1);
-
- @Test
- public void testEquality() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTest.java
deleted file mode 100644
index f1510b17..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for LinkLocalRemoteIdentifiers Tlv.
- */
-public class LinkLocalRemoteIdentifiersTest {
- private final int value1 = 0x12101010;
- private final int value2 = 0x12101012;
- private final LinkLocalRemoteIdentifiersTlv tlv1 = LinkLocalRemoteIdentifiersTlv.of(value1, value2);
- private final LinkLocalRemoteIdentifiersTlv sameAsTlv1 = LinkLocalRemoteIdentifiersTlv.of(value1, value2);
- private final LinkLocalRemoteIdentifiersTlv tlv2 = LinkLocalRemoteIdentifiersTlv.of(value2, value1);
-
- @Test
- public void testEquality() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/LocalPrefTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/LocalPrefTest.java
deleted file mode 100644
index 1bd34385..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/LocalPrefTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for LocalPref BGP Path Attribute.
- */
-public class LocalPrefTest {
- private final int value1 = 800;
- private final int value2 = 300;
- private final LocalPref attr1 = new LocalPref(value1);
- private final LocalPref sameAsAttr1 = new LocalPref(value1);
- private final LocalPref attr2 = new LocalPref(value2);
-
- @Test
- public void testEquality() {
- new EqualsTester().addEqualityGroup(attr1, sameAsAttr1).addEqualityGroup(attr2).testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/MedTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/MedTest.java
deleted file mode 100644
index 2ee5b33f..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/MedTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for MED BGP Path Attribute.
- */
-public class MedTest {
- private final int value1 = 800;
- private final int value2 = 200;
- private final Med attr1 = new Med(value1);
- private final Med sameAsAttr1 = new Med(value1);
- private final Med attr2 = new Med(value2);
-
- @Test
- public void testEquality() {
- new EqualsTester().addEqualityGroup(attr1, sameAsAttr1).addEqualityGroup(attr2).testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/NextHopTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/NextHopTest.java
deleted file mode 100755
index 799419a1..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/NextHopTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for NextHop BGP Path Attribute.
- */
-public class NextHopTest {
- private final Ip4Address value1 = Ip4Address.valueOf("12.12.12.12");
- private final Ip4Address value2 = Ip4Address.valueOf("12.12.12.13");
- private final NextHop attr1 = new NextHop(value1);
- private final NextHop sameAsAttr1 = new NextHop(value1);
- private final NextHop attr2 = new NextHop(value2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(attr1, sameAsAttr1)
- .addEqualityGroup(attr2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OriginTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OriginTest.java
deleted file mode 100644
index da7b5570..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OriginTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for Origin BGP Path Attribute.
- */
-public class OriginTest {
- private final byte value1 = 0x01;
- private final byte value2 = 0x02;
- private final Origin attr1 = new Origin(value1);
- private final Origin sameAsAttr1 = new Origin(value1);
- private final Origin attr2 = new Origin(value2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(attr1, sameAsAttr1)
- .addEqualityGroup(attr2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfPseudonodeTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfPseudonodeTest.java
deleted file mode 100644
index a8002311..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfPseudonodeTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for OSPFPseudonode Tlv.
- */
-public class OspfPseudonodeTest {
- private final int value1 = 0xc3223409;
- private final int value2 = 0xc3223406;
- private final Ip4Address drInterface1 = Ip4Address.valueOf(0xaf91e01);
- private final Ip4Address drInterface2 = Ip4Address.valueOf(0xaf91e02);
- private final OSPFPseudonode tlv1 = OSPFPseudonode.of(value1, drInterface1);
- private final OSPFPseudonode sameAsTlv1 = OSPFPseudonode.of(value1, drInterface1);
- private final OSPFPseudonode tlv2 = OSPFPseudonode.of(value2, drInterface2);
-
- @Test
- public void testEquality() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfRouteTypeTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfRouteTypeTest.java
deleted file mode 100644
index 859bdbe5..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfRouteTypeTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for OSPFRouteType Tlv.
- */
-public class OspfRouteTypeTest {
- private final byte value1 = 5;
- private final byte value2 = 4;
- private final OSPFRouteTypeTlv tlv1 = OSPFRouteTypeTlv.of(value1);
- private final OSPFRouteTypeTlv sameAsTlv1 = OSPFRouteTypeTlv.of(value1);
- private final OSPFRouteTypeTlv tlv2 = OSPFRouteTypeTlv.of(value2);
-
- @Test
- public void testEquality() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlvTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlvTest.java
deleted file mode 100644
index 4efb7f5b..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlvTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGP attribute node flag.
- */
-public class BgpAttrNodeFlagBitTlvTest {
-
- private final boolean bOverloadBit = true;
- private final boolean bAttachedBit = true;
- private final boolean bExternalBit = true;
- private final boolean bABRBit = true;
-
- private final boolean bOverloadBit1 = false;
- private final boolean bAttachedBit1 = false;
- private final boolean bExternalBit1 = false;
- private final boolean bABRBit1 = false;
-
- private final BgpAttrNodeFlagBitTlv data = BgpAttrNodeFlagBitTlv
- .of(bOverloadBit, bAttachedBit, bExternalBit, bABRBit);
- private final BgpAttrNodeFlagBitTlv sameAsData = BgpAttrNodeFlagBitTlv
- .of(bOverloadBit, bAttachedBit, bExternalBit, bABRBit);
- private final BgpAttrNodeFlagBitTlv diffData = BgpAttrNodeFlagBitTlv
- .of(bOverloadBit1, bAttachedBit1, bExternalBit1, bABRBit1);
-
- @Test
- public void basics() {
-
- new EqualsTester().addEqualityGroup(data, sameAsData)
- .addEqualityGroup(diffData).testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6Test.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6Test.java
deleted file mode 100644
index 16ca58ee..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6Test.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-import org.onlab.packet.Ip6Address;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGP attribute node router ID.
- */
-public class BgpAttrRouterIdV6Test {
-
- private final short sType = 1;
- private final Ip6Address ip6RouterId = Ip6Address
- .valueOf("2001:0db8:0a0b:12f0:0000:0000:0000:0001");
-
- private final short sType1 = 2;
- private final Ip6Address ip6RouterId1 = Ip6Address
- .valueOf("2004:0db8:0a0b:12f0:0000:0000:0000:0004");
-
- private final BgpAttrRouterIdV6 data = BgpAttrRouterIdV6.of(ip6RouterId,
- sType);
- private final BgpAttrRouterIdV6 sameAsData = BgpAttrRouterIdV6
- .of(ip6RouterId, sType);
- private final BgpAttrRouterIdV6 diffData = BgpAttrRouterIdV6
- .of(ip6RouterId1, sType1);
-
- @Test
- public void basics() {
-
- new EqualsTester().addEqualityGroup(data, sameAsData)
- .addEqualityGroup(diffData).testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetricTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetricTest.java
deleted file mode 100644
index ef1cfcea..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetricTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGP link IGP metric attribute.
- */
-public class BgpLinkAttrIgpMetricTest {
- private final int val = 0x010203;
- private final int valLen = 3;
- private final int val1 = 0x01020304;
- private final int val1Len = 4;
-
- private final BgpLinkAttrIgpMetric data = BgpLinkAttrIgpMetric.of(val,
- valLen);
- private final BgpLinkAttrIgpMetric sameAsData = BgpLinkAttrIgpMetric
- .of(val, valLen);
- private final BgpLinkAttrIgpMetric diffData = BgpLinkAttrIgpMetric
- .of(val1, val1Len);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(data, sameAsData)
- .addEqualityGroup(diffData).testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidthTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidthTest.java
deleted file mode 100644
index 06fecc92..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidthTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGP link max bandwidth attribute.
- */
-public class BgpLinkAttrMaxLinkBandwidthTest {
- private final float val = 0x010203;
- private final short valLen = 3;
- private final float val1 = 0x01020304;
- private final short val1Len = 4;
-
- private final BgpLinkAttrMaxLinkBandwidth data = BgpLinkAttrMaxLinkBandwidth
- .of(val, valLen);
- private final BgpLinkAttrMaxLinkBandwidth sameAsData = BgpLinkAttrMaxLinkBandwidth
- .of(val, valLen);
- private final BgpLinkAttrMaxLinkBandwidth diffData = BgpLinkAttrMaxLinkBandwidth
- .of(val1, val1Len);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(data, sameAsData)
- .addEqualityGroup(diffData).testEquals();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMaskTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMaskTest.java
deleted file mode 100644
index c0d7f986..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMaskTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for MPLS protocol mask attribute.
- */
-public class BgpLinkAttrMplsProtocolMaskTest {
- private final boolean val = true;
- private final boolean val1 = false;
-
- private final BgpLinkAttrMplsProtocolMask data = BgpLinkAttrMplsProtocolMask
- .of(val, val);
- private final BgpLinkAttrMplsProtocolMask sameAsData = BgpLinkAttrMplsProtocolMask
- .of(val, val);
- private final BgpLinkAttrMplsProtocolMask diffData = BgpLinkAttrMplsProtocolMask
- .of(val, val1);
-
- @Test
- public void basics() {
-
- new EqualsTester().addEqualityGroup(data, sameAsData)
- .addEqualityGroup(diffData).testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrNameTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrNameTest.java
deleted file mode 100644
index 45048527..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrNameTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for Link attribute name Tlv.
- */
-public class BgpLinkAttrNameTest {
- private final byte[] array = new byte[] {0x01, 0x02, 0x03, 0x04};
- private final byte[] array1 = new byte[] {0x01, 0x02, 0x03, 0x01};
-
- private final BgpLinkAttrName isisData = BgpLinkAttrName.of(array);
- private final BgpLinkAttrName sameAsIsisData = BgpLinkAttrName.of(array);
- private final BgpLinkAttrName isisDiff = BgpLinkAttrName.of(array1);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(isisData, sameAsIsisData)
- .addEqualityGroup(isisDiff).testEquals();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttribTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttribTest.java
deleted file mode 100644
index 71d05f85..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttribTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for Opaque Link attribute Tlv.
- */
-public class BgpLinkAttrOpaqLnkAttribTest {
- private final byte[] array = new byte[] {0x01, 0x02, 0x03, 0x04};
- private final byte[] array1 = new byte[] {0x01, 0x02, 0x03, 0x01};
-
- private final BgpLinkAttrOpaqLnkAttrib isisData = BgpLinkAttrOpaqLnkAttrib
- .of(array);
- private final BgpLinkAttrOpaqLnkAttrib sameAsIsisData = BgpLinkAttrOpaqLnkAttrib
- .of(array);
- private final BgpLinkAttrOpaqLnkAttrib isisDiff = BgpLinkAttrOpaqLnkAttrib
- .of(array1);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(isisData, sameAsIsisData)
- .addEqualityGroup(isisDiff).testEquals();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionTypeTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionTypeTest.java
deleted file mode 100644
index 2fb76352..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionTypeTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for MPLS protocol mask attribute.
- */
-public class BgpLinkAttrProtectionTypeTest {
- boolean bExtraTraffic = true;
- boolean bUnprotected = true;
- boolean bShared = true;
- boolean bDedOneIstoOne = true;
- boolean bDedOnePlusOne = true;
- boolean bEnhanced = true;
-
- boolean bExtraTraffic1 = false;
- boolean bUnprotected1 = false;
- boolean bShared1 = false;
- boolean bDedOneIstoOne1 = false;
- boolean bDedOnePlusOne1 = false;
- boolean bEnhanced1 = false;
-
- private final BgpLinkAttrProtectionType data = BgpLinkAttrProtectionType
- .of(bExtraTraffic, bUnprotected, bShared, bDedOneIstoOne,
- bDedOnePlusOne, bEnhanced);
- private final BgpLinkAttrProtectionType sameAsData = BgpLinkAttrProtectionType
- .of(bExtraTraffic, bUnprotected, bShared, bDedOneIstoOne,
- bDedOnePlusOne, bEnhanced);
- private final BgpLinkAttrProtectionType diffData = BgpLinkAttrProtectionType
- .of(bExtraTraffic1, bUnprotected1, bShared1, bDedOneIstoOne1,
- bDedOnePlusOne1, bEnhanced1);
-
- @Test
- public void basics() {
-
- new EqualsTester().addEqualityGroup(data, sameAsData)
- .addEqualityGroup(diffData).testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetricTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetricTest.java
deleted file mode 100644
index 9f3a7fad..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetricTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGP link TE default metric attribute.
- */
-public class BgpLinkAttrTeDefaultMetricTest {
- private final int val = 0x010203;
- private final int val1 = 0x01020304;
-
- private final BgpLinkAttrTeDefaultMetric data = BgpLinkAttrTeDefaultMetric
- .of(val);
- private final BgpLinkAttrTeDefaultMetric sameAsData = BgpLinkAttrTeDefaultMetric
- .of(val);
- private final BgpLinkAttrTeDefaultMetric diffData = BgpLinkAttrTeDefaultMetric
- .of(val1);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(data, sameAsData)
- .addEqualityGroup(diffData).testEquals();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidthTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidthTest.java
deleted file mode 100644
index f1d2a1fa..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidthTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.ArrayList;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGP unreserved bandwidth attribute.
- */
-public class BgpLinkAttrUnRsrvdLinkBandwidthTest {
- ArrayList<Float> maxUnResBandwidth = new ArrayList<Float>();
- ArrayList<Float> maxUnResBandwidth1 = new ArrayList<Float>();
- short sType = 10;
-
- private final BgpLinkAttrUnRsrvdLinkBandwidth isisData = BgpLinkAttrUnRsrvdLinkBandwidth
- .of(maxUnResBandwidth, sType);
- private final BgpLinkAttrUnRsrvdLinkBandwidth sameAsIsisData = BgpLinkAttrUnRsrvdLinkBandwidth
- .of(maxUnResBandwidth, sType);
- private final BgpLinkAttrUnRsrvdLinkBandwidth isisDiff = BgpLinkAttrUnRsrvdLinkBandwidth
- .of(maxUnResBandwidth1, sType);
-
- @Test
- public void basics() {
-
- maxUnResBandwidth.add(new Float(1));
- maxUnResBandwidth.add(new Float(2));
- maxUnResBandwidth.add(new Float(3));
- maxUnResBandwidth.add(new Float(4));
-
- maxUnResBandwidth1.add(new Float(1));
- maxUnResBandwidth1.add(new Float(2));
- maxUnResBandwidth1.add(new Float(3));
- maxUnResBandwidth1.add(new Float(1));
-
- new EqualsTester().addEqualityGroup(isisData, sameAsIsisData)
- .addEqualityGroup(isisDiff).testEquals();
-
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlagsTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlagsTest.java
deleted file mode 100644
index 535518f8..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlagsTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGP prefix IGP Flag attribute.
- */
-public class BgpPrefixAttrIgpFlagsTest {
-
- private final boolean bisisUpDownBit = true;
- private final boolean bOspfNoUnicastBit = true;
- private final boolean bOspfLclAddrBit = true;
- private final boolean bOspfNSSABit = true;
-
- private final boolean bisisUpDownBit1 = false;
- private final boolean bOspfNoUnicastBit1 = false;
- private final boolean bOspfLclAddrBit1 = false;
- private final boolean bOspfNSSABit1 = false;
-
- private final BgpPrefixAttrIgpFlags data = BgpPrefixAttrIgpFlags
- .of(bisisUpDownBit, bOspfNoUnicastBit, bOspfLclAddrBit,
- bOspfNSSABit);
- private final BgpPrefixAttrIgpFlags sameAsData = BgpPrefixAttrIgpFlags
- .of(bisisUpDownBit, bOspfNoUnicastBit, bOspfLclAddrBit,
- bOspfNSSABit);
- private final BgpPrefixAttrIgpFlags diffData = BgpPrefixAttrIgpFlags
- .of(bisisUpDownBit1, bOspfNoUnicastBit1, bOspfLclAddrBit1,
- bOspfNSSABit1);
-
- @Test
- public void basics() {
-
- new EqualsTester().addEqualityGroup(data, sameAsData)
- .addEqualityGroup(diffData).testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetricTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetricTest.java
deleted file mode 100644
index fe6079fd..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetricTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGP prefix metric attribute.
- */
-public class BgpPrefixAttrMetricTest {
- private final int val = 1111;
- private final int val1 = 2222;
-
- private final BgpPrefixAttrMetric data = BgpPrefixAttrMetric.of(val);
- private final BgpPrefixAttrMetric sameAsData = BgpPrefixAttrMetric.of(val);
- private final BgpPrefixAttrMetric diffData = BgpPrefixAttrMetric.of(val1);
-
- @Test
- public void basics() {
-
- new EqualsTester().addEqualityGroup(data, sameAsData)
- .addEqualityGroup(diffData).testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueDataTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueDataTest.java
deleted file mode 100644
index 17dafbb7..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueDataTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for prefix attribute opaque data Tlv.
- */
-public class BgpPrefixAttrOpaqueDataTest {
- private final byte[] array = new byte[] {0x01, 0x02, 0x03, 0x04};
- private final byte[] array1 = new byte[] {0x01, 0x02, 0x03, 0x01};
-
- private final BgpPrefixAttrOpaqueData isisData = BgpPrefixAttrOpaqueData
- .of(array);
- private final BgpPrefixAttrOpaqueData sameAsIsisData = BgpPrefixAttrOpaqueData
- .of(array);
- private final BgpPrefixAttrOpaqueData isisDiff = BgpPrefixAttrOpaqueData
- .of(array1);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(isisData, sameAsIsisData)
- .addEqualityGroup(isisDiff).testEquals();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddrTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddrTest.java
deleted file mode 100644
index f6fe39f8..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddrTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip6Address;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGP prefix metric attribute.
- */
-public class BgpPrefixAttrOspfFwdAddrTest {
-
- private final short lsAttrLength = 4;
- private final Ip4Address ip4RouterId = Ip4Address.valueOf("192.168.1.1");
- private final Ip6Address ip6RouterId = Ip6Address
- .valueOf("2001:0db8:0a0b:12f0:0000:0000:0000:0001");
-
- private final short lsAttrLength1 = 16;
- private final Ip4Address ip4RouterId1 = Ip4Address.valueOf("192.168.1.2");
- private final Ip6Address ip6RouterId1 = Ip6Address
- .valueOf("1002:0db8:0a0b:12f0:0000:0000:0000:0002");
-
- private final BgpPrefixAttrOspfFwdAddr data = BgpPrefixAttrOspfFwdAddr
- .of(lsAttrLength, ip4RouterId, ip6RouterId);
- private final BgpPrefixAttrOspfFwdAddr sameAsData = BgpPrefixAttrOspfFwdAddr
- .of(lsAttrLength, ip4RouterId, ip6RouterId);
- private final BgpPrefixAttrOspfFwdAddr diffData = BgpPrefixAttrOspfFwdAddr
- .of(lsAttrLength1, ip4RouterId1, ip6RouterId1);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(data, sameAsData)
- .addEqualityGroup(diffData).testEquals();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTagTest.java b/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTagTest.java
deleted file mode 100644
index 25ced61f..00000000
--- a/framework/src/onos/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTagTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgpio.types.attr;
-
-import java.util.ArrayList;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Test for BGP prefix route tag attribute.
- */
-public class BgpPrefixAttrRouteTagTest {
- ArrayList<Integer> maxUnResBandwidth = new ArrayList<Integer>();
- ArrayList<Integer> maxUnResBandwidth1 = new ArrayList<Integer>();
-
- private final BgpPrefixAttrRouteTag isisData = BgpPrefixAttrRouteTag
- .of(maxUnResBandwidth);
- private final BgpPrefixAttrRouteTag sameAsIsisData = BgpPrefixAttrRouteTag
- .of(maxUnResBandwidth);
- private final BgpPrefixAttrRouteTag isisDiff = BgpPrefixAttrRouteTag
- .of(maxUnResBandwidth1);
-
- @Test
- public void basics() {
-
- maxUnResBandwidth.add(new Integer(1));
- maxUnResBandwidth.add(new Integer(2));
- maxUnResBandwidth.add(new Integer(3));
- maxUnResBandwidth.add(new Integer(4));
-
- maxUnResBandwidth1.add(new Integer(1));
- maxUnResBandwidth1.add(new Integer(2));
- maxUnResBandwidth1.add(new Integer(3));
- maxUnResBandwidth1.add(new Integer(1));
-
- new EqualsTester().addEqualityGroup(isisData, sameAsIsisData)
- .addEqualityGroup(isisDiff).testEquals();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/ctl/pom.xml b/framework/src/onos/protocols/bgp/ctl/pom.xml
deleted file mode 100755
index fd5f2b54..00000000
--- a/framework/src/onos/protocols/bgp/ctl/pom.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-bgp</artifactId>
- <version>1.4.0-rc1</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>onos-bgp-ctl</artifactId>
- <packaging>bundle</packaging>
-
- <description>ONOS BGP controller subsystem API</description>
-
- <dependencies>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-bgp-api</artifactId>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-scr-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/AdjRibIn.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/AdjRibIn.java
deleted file mode 100644
index 9cbfbf65..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/AdjRibIn.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgp.controller.impl;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.onosproject.bgpio.protocol.BgpLSNlri;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpPrefixLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implementation of Adj-RIB-In for each peer.
- */
-public class AdjRibIn {
- private Map<BgpNodeLSIdentifier, PathAttrNlriDetails> nodeTree = new TreeMap<>();
- private Map<BgpLinkLSIdentifier, PathAttrNlriDetails> linkTree = new TreeMap<>();
- private Map<BgpPrefixLSIdentifier, PathAttrNlriDetails> prefixTree = new TreeMap<>();
-
- /**
- * Returns the adjacency node.
- *
- * @return node adjacency RIB node
- */
- public Map<BgpNodeLSIdentifier, PathAttrNlriDetails> nodeTree() {
- return nodeTree;
- }
-
- /**
- * Returns the adjacency link.
- *
- * @return link adjacency RIB node
- */
- public Map<BgpLinkLSIdentifier, PathAttrNlriDetails> linkTree() {
- return linkTree;
- }
-
- /**
- * Returns the adjacency prefix.
- *
- * @return prefix adjacency RIB node
- */
- public Map<BgpPrefixLSIdentifier, PathAttrNlriDetails> prefixTree() {
- return prefixTree;
- }
-
- /**
- * Update nlri identifier into the tree if nlri identifier exists in tree otherwise add this to the tree.
- *
- * @param nlri NLRI Info
- * @param details has pathattribute , protocolID and identifier
- */
- public void add(BgpLSNlri nlri, PathAttrNlriDetails details) {
- if (nlri instanceof BgpNodeLSNlriVer4) {
- BgpNodeLSIdentifier nodeLSIdentifier = ((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors();
- if (nodeTree.containsKey(nodeLSIdentifier)) {
- nodeTree.replace(nodeLSIdentifier, details);
- } else {
- nodeTree.put(nodeLSIdentifier, details);
- }
- } else if (nlri instanceof BgpLinkLsNlriVer4) {
- BgpLinkLSIdentifier linkLSIdentifier = ((BgpLinkLsNlriVer4) nlri).getLinkIdentifier();
- if (linkTree.containsKey(linkLSIdentifier)) {
- linkTree.replace(linkLSIdentifier, details);
- } else {
- linkTree.put(linkLSIdentifier, details);
- }
- } else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
- BgpPrefixLSIdentifier prefixIdentifier = ((BgpPrefixIPv4LSNlriVer4) nlri).getPrefixIdentifier();
- if (prefixTree.containsKey(prefixIdentifier)) {
- prefixTree.replace(prefixIdentifier, details);
- } else {
- prefixTree.put(prefixIdentifier, details);
- }
- }
- }
-
- /**
- * Removes nlri identifier if it exists in the adjacency tree.
- *
- * @param nlri NLRI Info
- */
- public void remove(BgpLSNlri nlri) {
- if (nlri instanceof BgpNodeLSNlriVer4) {
- BgpNodeLSIdentifier nodeLSIdentifier = ((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors();
- if (nodeTree.containsKey(nodeLSIdentifier)) {
- nodeTree.remove(nodeLSIdentifier);
- }
- } else if (nlri instanceof BgpLinkLsNlriVer4) {
- BgpLinkLSIdentifier linkLSIdentifier = ((BgpLinkLsNlriVer4) nlri).getLinkIdentifier();
- if (linkTree.containsKey(linkLSIdentifier)) {
- linkTree.remove(linkLSIdentifier);
- }
- } else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
- BgpPrefixLSIdentifier prefixIdentifier = ((BgpPrefixIPv4LSNlriVer4) nlri).getPrefixIdentifier();
- if (prefixTree.containsKey(prefixIdentifier)) {
- prefixTree.remove(prefixIdentifier);
- }
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("nodeTree", nodeTree)
- .add("linkTree", linkTree)
- .add("prefixTree", prefixTree)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java
deleted file mode 100755
index 0c55eadc..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java
+++ /dev/null
@@ -1,896 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgp.controller.impl;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.net.UnknownHostException;
-import java.nio.channels.ClosedChannelException;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.concurrent.RejectedExecutionException;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.ExceptionEvent;
-import org.jboss.netty.channel.MessageEvent;
-import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
-import org.jboss.netty.handler.timeout.ReadTimeoutException;
-import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-import org.onosproject.bgp.controller.BgpCfg;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.bgp.controller.BgpId;
-import org.onosproject.bgp.controller.BgpPeer;
-import org.onosproject.bgp.controller.BgpPeerCfg;
-import org.onosproject.bgp.controller.impl.BgpControllerImpl.BgpPeerManagerImpl;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpFactory;
-import org.onosproject.bgpio.protocol.BgpMessage;
-import org.onosproject.bgpio.protocol.BgpOpenMsg;
-import org.onosproject.bgpio.protocol.BgpType;
-import org.onosproject.bgpio.protocol.BgpVersion;
-import org.onosproject.bgpio.types.BgpErrorType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv;
-import org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Channel handler deals with the bgp peer connection and dispatches messages from peer to the appropriate locations.
- */
-class BgpChannelHandler extends IdleStateAwareChannelHandler {
-
- private static final Logger log = LoggerFactory.getLogger(BgpChannelHandler.class);
- static final int BGP_MIN_HOLDTIME = 3;
- static final int BGP_MAX_KEEPALIVE_INTERVAL = 3;
- private BgpPeer bgpPeer;
- private BgpId thisbgpId;
- private Channel channel;
- private BgpKeepAliveTimer keepAliveTimer = null;
- private short peerHoldTime = 0;
- private short negotiatedHoldTime = 0;
- private long peerAsNum;
- private int peerIdentifier;
- private BgpPacketStatsImpl bgpPacketStats;
- static final int MAX_WRONG_COUNT_PACKET = 5;
- static final byte MULTI_PROTOCOL_EXTN_CAPA_TYPE = 1;
- static final byte FOUR_OCTET_AS_NUM_CAPA_TYPE = 65;
- static final int AS_TRANS = 23456;
- static final int MAX_AS2_NUM = 65535;
- static final short AFI = 16388;
- static final byte RES = 0;
- static final byte SAFI = 71;
-
- // State needs to be volatile because the HandshakeTimeoutHandler
- // needs to check if the handshake is complete
- private volatile ChannelState state;
-
- // When a bgp peer with a ip addresss is found (i.e we already have a
- // connected peer with the same ip), the new peer is immediately
- // disconnected. At that point netty callsback channelDisconnected() which
- // proceeds to cleaup peer state - we need to ensure that it does not
- // cleanup
- // peer state for the older (still connected) peer
- private volatile Boolean duplicateBGPIdFound;
- // Indicates the bgp version used by this bgp peer
- protected BgpVersion bgpVersion;
- private BgpController bgpController;
- protected BgpFactory factory4;
- private boolean isIbgpSession;
- private BgpSessionInfoImpl sessionInfo;
- private BgpPeerManagerImpl peerManager;
- private InetSocketAddress inetAddress;
- private IpAddress ipAddress;
- private SocketAddress address;
- private String peerAddr;
- private BgpCfg bgpconfig;
-
- /**
- * Create a new unconnected BGPChannelHandler.
- *
- * @param bgpController bgp controller
- */
- BgpChannelHandler(BgpController bgpController) {
- this.bgpController = bgpController;
- this.peerManager = (BgpPeerManagerImpl) bgpController.peerManager();
- this.state = ChannelState.IDLE;
- this.factory4 = Controller.getBgpMessageFactory4();
- this.duplicateBGPIdFound = Boolean.FALSE;
- this.bgpPacketStats = new BgpPacketStatsImpl();
- this.bgpconfig = bgpController.getConfig();
- }
-
- // To disconnect peer session.
- public void disconnectPeer() {
- bgpPeer.disconnectPeer();
- }
-
- // *************************
- // Channel State Machine
- // *************************
-
- /**
- * The state machine for handling the peer/channel state. All state transitions should happen from within the state
- * machine (and not from other parts of the code)
- */
- enum ChannelState {
- /**
- * Initial state before channel is connected.
- */
- IDLE(false) {
-
- },
-
- OPENSENT(false) {
- @Override
- void processBgpMessage(BgpChannelHandler h, BgpMessage m) throws IOException, BgpParseException {
- log.debug("message received in OPENSENT state");
- // check for OPEN message
- if (m.getType() != BgpType.OPEN) {
- // When the message type is not keep alive message increment the wrong packet statistics
- h.processUnknownMsg(BgpErrorType.FINITE_STATE_MACHINE_ERROR,
- BgpErrorType.RECEIVE_UNEXPECTED_MESSAGE_IN_OPENSENT_STATE,
- m.getType().getType());
- log.debug("Message is not OPEN message");
- } else {
- log.debug("Sending keep alive message in OPENSENT state");
- h.bgpPacketStats.addInPacket();
-
- BgpOpenMsg pOpenmsg = (BgpOpenMsg) m;
- h.peerIdentifier = pOpenmsg.getBgpId();
-
- // validate capabilities and open msg
- if (h.openMsgValidation(h, pOpenmsg)) {
- if (h.connectionCollisionDetection(BgpPeerCfg.State.OPENCONFIRM,
- h.peerIdentifier, h.peerAddr)) {
- h.channel.close();
- return;
- }
- log.debug("Sending handshake OPEN message");
-
- /*
- * RFC 4271, section 4.2: Upon receipt of an OPEN message, a BGP speaker MUST calculate the
- * value of the Hold Timer by using the smaller of its configured Hold Time and the Hold Time
- * received in the OPEN message
- */
- h.peerHoldTime = pOpenmsg.getHoldTime();
- if (h.peerHoldTime < h.bgpconfig.getHoldTime()) {
- h.channel.getPipeline().replace("holdTime",
- "holdTime",
- new ReadTimeoutHandler(BgpPipelineFactory.TIMER,
- h.peerHoldTime));
- }
-
- log.info("Hold Time : " + h.peerHoldTime);
-
- // update AS number
- h.peerAsNum = pOpenmsg.getAsNumber();
- }
-
- // Send keepalive message to peer.
- h.sendKeepAliveMessage();
- h.bgpPacketStats.addOutPacket();
- h.setState(OPENCONFIRM);
- h.bgpconfig.setPeerConnState(h.peerAddr, BgpPeerCfg.State.OPENCONFIRM);
- }
- }
- },
-
- OPENWAIT(false) {
- @Override
- void processBgpMessage(BgpChannelHandler h, BgpMessage m) throws IOException, BgpParseException {
- log.debug("Message received in OPEN WAIT State");
-
- // check for open message
- if (m.getType() != BgpType.OPEN) {
- // When the message type is not open message increment the wrong packet statistics
- h.processUnknownMsg(BgpErrorType.FINITE_STATE_MACHINE_ERROR, BgpErrorType.UNSPECIFIED_ERROR,
- m.getType().getType());
- log.debug("Message is not OPEN message");
- } else {
- h.bgpPacketStats.addInPacket();
-
- BgpOpenMsg pOpenmsg = (BgpOpenMsg) m;
- h.peerIdentifier = pOpenmsg.getBgpId();
-
- // Validate open message
- if (h.openMsgValidation(h, pOpenmsg)) {
- if (h.connectionCollisionDetection(BgpPeerCfg.State.OPENSENT,
- h.peerIdentifier, h.peerAddr)) {
- h.channel.close();
- return;
- }
- log.debug("Sending handshake OPEN message");
-
- /*
- * RFC 4271, section 4.2: Upon receipt of an OPEN message, a BGP speaker MUST calculate the
- * value of the Hold Timer by using the smaller of its configured Hold Time and the Hold Time
- * received in the OPEN message
- */
- h.peerHoldTime = pOpenmsg.getHoldTime();
- if (h.peerHoldTime < h.bgpconfig.getHoldTime()) {
- h.channel.getPipeline().replace("holdTime",
- "holdTime",
- new ReadTimeoutHandler(BgpPipelineFactory.TIMER,
- h.peerHoldTime));
- }
-
- log.debug("Hold Time : " + h.peerHoldTime);
-
- // update AS number
- h.peerAsNum = pOpenmsg.getAsNumber();
-
- h.sendHandshakeOpenMessage();
- h.bgpPacketStats.addOutPacket();
- h.setState(OPENCONFIRM);
- h.bgpconfig.setPeerConnState(h.peerAddr, BgpPeerCfg.State.OPENCONFIRM);
- }
- }
- }
- },
-
- OPENCONFIRM(false) {
- @Override
- void processBgpMessage(BgpChannelHandler h, BgpMessage m) throws IOException, BgpParseException {
- log.debug("Message received in OPENCONFIRM state");
- // check for keep alive message
- if (m.getType() != BgpType.KEEP_ALIVE) {
- // When the message type is not keep alive message handle the wrong packet
- h.processUnknownMsg(BgpErrorType.FINITE_STATE_MACHINE_ERROR,
- BgpErrorType.RECEIVE_UNEXPECTED_MESSAGE_IN_OPENCONFIRM_STATE,
- m.getType().getType());
- log.debug("Message is not KEEPALIVE message");
- } else {
-
- // Set the peer connected status
- h.bgpPacketStats.addInPacket();
- log.debug("Sending keep alive message in OPENCONFIRM state");
-
- final InetSocketAddress inetAddress = (InetSocketAddress) h.address;
- h.thisbgpId = BgpId.bgpId(IpAddress.valueOf(inetAddress.getAddress()));
-
- // set session parameters
- h.negotiatedHoldTime = (h.peerHoldTime < h.bgpconfig.getHoldTime()) ? h.peerHoldTime
- : h.bgpconfig.getHoldTime();
- h.sessionInfo = new BgpSessionInfoImpl(h.thisbgpId, h.bgpVersion, h.peerAsNum, h.peerHoldTime,
- h.peerIdentifier, h.negotiatedHoldTime, h.isIbgpSession);
-
- h.bgpPeer = h.peerManager.getBgpPeerInstance(h.bgpController, h.sessionInfo, h.bgpPacketStats);
- // set the status of bgp as connected
- h.bgpPeer.setConnected(true);
- h.bgpPeer.setChannel(h.channel);
-
- /*
- * RFC 4271, When an OPEN message is received, sends a KEEPALIVE message, If the negotiated hold
- * time value is zero, then the HoldTimer and KeepaliveTimer are not started. A reasonable maximum
- * time between KEEPALIVE messages would be one third of the Hold Time interval.
- */
-
- if (h.negotiatedHoldTime != 0) {
- h.keepAliveTimer = new BgpKeepAliveTimer(h,
- (h.negotiatedHoldTime / BGP_MAX_KEEPALIVE_INTERVAL));
- } else {
- h.sendKeepAliveMessage();
- }
-
- h.bgpPacketStats.addOutPacket();
-
- // set the state handshake completion.
- h.setHandshakeComplete(true);
-
- if (!h.peerManager.addConnectedPeer(h.thisbgpId, h.bgpPeer)) {
- disconnectDuplicate(h);
- } else {
- h.setState(ESTABLISHED);
- h.bgpconfig.setPeerConnState(h.peerAddr, BgpPeerCfg.State.ESTABLISHED);
- }
- }
- }
- },
-
- ESTABLISHED(true) {
- @Override
- void processBgpMessage(BgpChannelHandler h, BgpMessage m) throws IOException, BgpParseException {
- log.debug("Message received in established state " + m.getType());
- // dispatch the message
- h.dispatchMessage(m);
- }
- };
-
- private boolean handshakeComplete;
-
- ChannelState(boolean handshakeComplete) {
- this.handshakeComplete = handshakeComplete;
- }
-
- /**
- * Is this a state in which the handshake has completed?
- *
- * @return true if the handshake is complete
- */
- public boolean isHandshakeComplete() {
- return this.handshakeComplete;
- }
-
- /**
- * Disconnect duplicate peer connection.
- *
- * @param h channel handler
- */
- protected void disconnectDuplicate(BgpChannelHandler h) {
- log.error("Duplicated BGP IP or incompleted cleanup - " + "" + "disconnecting channel {}",
- h.getPeerInfoString());
- h.duplicateBGPIdFound = Boolean.TRUE;
- h.channel.disconnect();
- }
-
- // set handshake completion status
- public void setHandshakeComplete(boolean handshakeComplete) {
- this.handshakeComplete = handshakeComplete;
- }
-
- void processBgpMessage(BgpChannelHandler bgpChannelHandler, BgpMessage pm)
- throws IOException, BgpParseException {
- // TODO Auto-generated method stub
- log.debug("BGP message stub");
- }
-
- }
-
- // *************************
- // Channel handler methods
- // *************************
-
- @Override
- public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
-
- channel = e.getChannel();
- log.info("BGP connected from {}", channel.getRemoteAddress());
-
- address = channel.getRemoteAddress();
- if (!(address instanceof InetSocketAddress)) {
- throw new IOException("Invalid peer connection.");
- }
-
-
- inetAddress = (InetSocketAddress) address;
- peerAddr = IpAddress.valueOf(inetAddress.getAddress()).toString();
-
-
- // if connection is already established close channel
- if (peerManager.isPeerConnected(BgpId.bgpId(IpAddress.valueOf(peerAddr)))) {
- log.debug("Duplicate connection received, peer {}", peerAddr);
- channel.close();
- return;
- }
-
- if (null != channel.getPipeline().get("PassiveHandler")) {
- log.info("BGP handle connection request from peer");
- // Wait for open message from bgp peer
- setState(ChannelState.OPENWAIT);
- } else if (null != channel.getPipeline().get("ActiveHandler")) {
- log.info("BGP handle connection response from peer");
-
- sendHandshakeOpenMessage();
- bgpPacketStats.addOutPacket();
- setState(ChannelState.OPENSENT);
- bgpconfig.setPeerConnState(peerAddr, BgpPeerCfg.State.OPENSENT);
- }
- }
-
- @Override
- public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
-
- channel = e.getChannel();
- log.info("BGP disconnected callback for bgp:{}. Cleaning up ...", getPeerInfoString());
-
- address = channel.getRemoteAddress();
- if (!(address instanceof InetSocketAddress)) {
- throw new IOException("Invalid peer connection.");
- }
-
- inetAddress = (InetSocketAddress) address;
- peerAddr = IpAddress.valueOf(inetAddress.getAddress()).toString();
-
- if (thisbgpId != null) {
- if (!duplicateBGPIdFound) {
- // if the disconnected peer (on this ChannelHandler)
- // was not one with a duplicate, it is safe to remove all
- // state for it at the controller. Notice that if the disconnected
- // peer was a duplicate-ip, calling the method below would clear
- // all state for the original peer (with the same ip),
- // which we obviously don't want.
- log.debug("{}:removal called", getPeerInfoString());
- if (bgpPeer != null) {
- BgpPeerImpl peer = (BgpPeerImpl) bgpPeer;
- peerManager.removeConnectedPeer(thisbgpId);
- peer.updateLocalRIBOnPeerDisconnect();
- }
-
- // Retry connection if connection is lost to bgp speaker/peer
- if ((channel != null) && (null != channel.getPipeline().get("ActiveHandler"))) {
- BgpConnectPeerImpl connectPeer;
- BgpPeerCfg.State peerCfgState;
-
- peerCfgState = bgpconfig.getPeerConnState(peerAddr);
- // on session disconnect using configuration, do not retry
- if (!peerCfgState.equals(BgpPeerCfg.State.IDLE)) {
- log.debug("Connection reset by peer, retry, STATE:{}", peerCfgState);
- BgpPeerConfig peerConfig = (BgpPeerConfig) bgpconfig.displayPeers(peerAddr);
-
- bgpconfig.setPeerConnState(peerAddr, BgpPeerCfg.State.IDLE);
- connectPeer = new BgpConnectPeerImpl(bgpController, peerAddr, Controller.getBgpPortNum());
- peerConfig.setConnectPeer(connectPeer);
- }
- } else {
- bgpconfig.setPeerConnState(peerAddr, BgpPeerCfg.State.IDLE);
- }
- } else {
- // A duplicate was disconnected on this ChannelHandler,
- // this is the same peer reconnecting, but the original state was
- // not cleaned up - XXX check liveness of original ChannelHandler
- log.debug("{}:duplicate found", getPeerInfoString());
- duplicateBGPIdFound = Boolean.FALSE;
- }
-
- if (null != keepAliveTimer) {
- keepAliveTimer.getKeepAliveTimer().cancel();
- }
- } else {
- bgpconfig.setPeerConnState(peerAddr, BgpPeerCfg.State.IDLE);
- log.warn("No bgp ip in channelHandler registered for " + "disconnected peer {}", getPeerInfoString());
- }
- }
-
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
-
- log.info("[exceptionCaught]: " + e.toString());
-
- if (e.getCause() instanceof ReadTimeoutException) {
- if ((ChannelState.OPENWAIT == state) || (ChannelState.OPENSENT == state)) {
-
- // When ReadTimeout timer is expired in OPENWAIT/OPENSENT state, it is considered
- sendNotification(BgpErrorType.HOLD_TIMER_EXPIRED, (byte) 0, null);
- channel.close();
- state = ChannelState.IDLE;
- return;
- } else if (ChannelState.OPENCONFIRM == state) {
-
- // When ReadTimeout timer is expired in OPENCONFIRM state.
- sendNotification(BgpErrorType.HOLD_TIMER_EXPIRED, (byte) 0, null);
- channel.close();
- state = ChannelState.IDLE;
- return;
- }
- } else if (e.getCause() instanceof ClosedChannelException) {
- log.debug("Channel for bgp {} already closed", getPeerInfoString());
- } else if (e.getCause() instanceof IOException) {
- log.error("Disconnecting peer {} due to IO Error: {}", getPeerInfoString(), e.getCause().getMessage());
- if (log.isDebugEnabled()) {
- // still print stack trace if debug is enabled
- log.debug("StackTrace for previous Exception: ", e.getCause());
- }
- channel.close();
- } else if (e.getCause() instanceof BgpParseException) {
- byte[] data = new byte[] {};
- BgpParseException errMsg = (BgpParseException) e.getCause();
- byte errorCode = errMsg.getErrorCode();
- byte errorSubCode = errMsg.getErrorSubCode();
- ChannelBuffer tempCb = errMsg.getData();
- if (tempCb != null) {
- int dataLength = tempCb.capacity();
- data = new byte[dataLength];
- tempCb.readBytes(data, 0, dataLength);
- }
- sendNotification(errorCode, errorSubCode, data);
- } else if (e.getCause() instanceof RejectedExecutionException) {
- log.warn("Could not process message: queue full");
- } else {
- log.error("Error while processing message from peer " + getPeerInfoString() + "state " + this.state);
- channel.close();
- }
- }
-
- @Override
- public String toString() {
- return getPeerInfoString();
- }
-
- @Override
- public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
- if (e.getMessage() instanceof List) {
- @SuppressWarnings("Unchecked")
- List<BgpMessage> msglist = (List<BgpMessage>) e.getMessage();
- for (BgpMessage pm : msglist) {
- // Do the actual packet processing
- state.processBgpMessage(this, pm);
- }
- } else {
- state.processBgpMessage(this, (BgpMessage) e.getMessage());
- }
- }
-
- /**
- * Check for connection collision.
- *
- * @param state connection state
- * @param peerIdentifier BGP peer identifier
- * @param peerAddr BGP peer address
- * @return true if bgp spreakers initiated connection
- * @throws BgpParseException on error while procession collision detection
- * @throws IOException on error while procession collision detection
- */
- public boolean connectionCollisionDetection(BgpPeerCfg.State state, int peerIdentifier, String peerAddr)
- throws IOException, BgpParseException {
- /*
- * RFC 4271, Section 6.8, Based on the value of the BGP identifier, a convention is established for detecting
- * which BGP connection is to be preserved when a collision occurs. The convention is to compare the BGP
- * Identifiers of the peers involved in the collision and to retain only the connection initiated by the BGP
- * speaker with the higher-valued BGP Identifier..
- */
- BgpPeerCfg.State currentState = bgpconfig.getPeerConnState(peerAddr);
- if (currentState.equals(state)) {
- if (((Ip4Address.valueOf(bgpconfig.getRouterId())).compareTo(Ip4Address.valueOf(peerIdentifier))) > 0) {
- // send notification
- sendNotification(BgpErrorType.CEASE, BgpErrorType.CONNECTION_COLLISION_RESOLUTION, null);
- log.debug("Connection collision detected, local id: {}, peer id: {}, peer state:{}, in state:{}",
- (Ip4Address.valueOf(bgpconfig.getRouterId())), (Ip4Address.valueOf(peerIdentifier)),
- currentState, state);
- return true;
- }
- }
-
- return false;
- }
-
- // *************************
- // Channel utility methods
- // *************************
- /**
- * Set handshake status.
- *
- * @param handshakeComplete handshake complete status
- */
- public void setHandshakeComplete(boolean handshakeComplete) {
- this.state.setHandshakeComplete(handshakeComplete);
- }
-
- /**
- * Is this a state in which the handshake has completed?
- *
- * @return true if the handshake is complete
- */
- public boolean isHandshakeComplete() {
- return state.isHandshakeComplete();
- }
-
- /**
- * To handle the BGP message.
- *
- * @param m bgp message
- * @throws BgpParseException throw exception
- */
- private void dispatchMessage(BgpMessage m) throws BgpParseException {
- bgpPacketStats.addInPacket();
- bgpController.processBGPPacket(thisbgpId, m);
- }
-
- /**
- * Return a string describing this peer based on the already available information (ip address and/or remote
- * socket).
- *
- * @return display string
- */
- private String getPeerInfoString() {
- if (bgpPeer != null) {
- return bgpPeer.toString();
- }
- String channelString;
- if (channel == null || channel.getRemoteAddress() == null) {
- channelString = "?";
- } else {
- channelString = channel.getRemoteAddress().toString();
- }
- String bgpIpString;
- // TODO: implement functionality to get bgp id string
- bgpIpString = "?";
- return String.format("[%s BGP-IP[%s]]", channelString, bgpIpString);
- }
-
- /**
- * Update the channels state. Only called from the state machine. TODO: enforce restricted state transitions
- *
- * @param state
- */
- private void setState(ChannelState state) {
- this.state = state;
- }
-
- /**
- * get packet statistics.
- *
- * @return packet statistics
- */
- public BgpPacketStatsImpl getBgpPacketStats() {
- return bgpPacketStats;
- }
-
- /**
- * Send handshake open message to the peer.
- *
- * @throws IOException, BgpParseException
- */
- private void sendHandshakeOpenMessage() throws IOException, BgpParseException {
- int bgpId;
-
- InetSocketAddress localAddress = (InetSocketAddress) channel.getLocalAddress();
-
- bgpId = Ip4Address.valueOf(IpAddress.valueOf(localAddress.getAddress()).toString()).toInt();
- BgpMessage msg = factory4.openMessageBuilder().setAsNumber((short) peerAsNum)
- .setHoldTime(bgpconfig.getHoldTime()).setBgpId(bgpId).setLsCapabilityTlv(bgpconfig.getLsCapability())
- .setLargeAsCapabilityTlv(bgpconfig.getLargeASCapability()).build();
- log.debug("Sending open message to {}", channel.getRemoteAddress());
- channel.write(Collections.singletonList(msg));
-
- }
-
- /**
- * Send notification message to peer.
- *
- * @param errorCode error code send in notification
- * @param errorSubCode sub error code send in notification
- * @param data data to send in notification
- * @throws IOException, BgpParseException while building message
- */
- private void sendNotification(byte errorCode, byte errorSubCode, byte[] data)
- throws IOException, BgpParseException {
- BgpMessage msg = factory4.notificationMessageBuilder().setErrorCode(errorCode)
- .setErrorSubCode(errorSubCode).setData(data).build();
- log.debug("Sending notification message to {}", channel.getRemoteAddress());
- channel.write(Collections.singletonList(msg));
- }
-
- /**
- * Send keep alive message.
- *
- * @throws IOException when channel is disconnected
- * @throws BgpParseException while building keep alive message
- */
- synchronized void sendKeepAliveMessage() throws IOException, BgpParseException {
-
- BgpMessage msg = factory4.keepaliveMessageBuilder().build();
- log.debug("Sending keepalive message to {}", channel.getRemoteAddress());
- channel.write(Collections.singletonList(msg));
- }
-
- /**
- * Process unknown BGP message received.
- *
- * @param errorCode error code
- * @param errorSubCode error sub code
- * @param data message type
- * @throws BgpParseException while processing error messsage
- * @throws IOException while processing error message
- */
- public void processUnknownMsg(byte errorCode, byte errorSubCode, byte data) throws BgpParseException, IOException {
- log.debug("UNKNOWN message received");
- byte[] byteArray = new byte[1];
- byteArray[0] = data;
- sendNotification(errorCode, errorSubCode, byteArray);
- channel.close();
- }
-
- /**
- * BGP open message validation.
- *
- * @param h channel handler
- * @param openMsg open message
- * @return true if valid message, otherwise false
- * @throws BgpParseException throw exception
- */
- public boolean openMsgValidation(BgpChannelHandler h, BgpOpenMsg openMsg) throws BgpParseException {
- boolean result;
-
- // Validate BGP ID
- result = bgpIdValidation(openMsg);
- if (!result) {
- throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR, BgpErrorType.BAD_BGP_IDENTIFIER, null);
- }
-
-
- // Validate hold timer
- if ((openMsg.getHoldTime() != 0) && (openMsg.getHoldTime() < BGP_MIN_HOLDTIME)) {
- throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR, BgpErrorType.UNACCEPTABLE_HOLD_TIME, null);
- }
-
- // Validate capabilities
- result = capabilityValidation(h, openMsg);
- return result;
- }
-
- /**
- * Capability Validation.
- *
- * @param h channel handler
- * @param openmsg open message
- * @return success or failure
- * @throws BgpParseException
- */
- private boolean capabilityValidation(BgpChannelHandler h, BgpOpenMsg openmsg) throws BgpParseException {
- log.debug("capabilityValidation");
-
- boolean isMultiProtocolcapabilityExists = false;
- boolean isFourOctetCapabilityExits = false;
- int capAsNum = 0;
-
- List<BgpValueType> capabilityTlv = openmsg.getCapabilityTlv();
- ListIterator<BgpValueType> listIterator = capabilityTlv.listIterator();
- List<BgpValueType> unSupportedCapabilityTlv = new LinkedList<>();
- ListIterator<BgpValueType> unSupportedCaplistIterator = unSupportedCapabilityTlv.listIterator();
- BgpValueType tempTlv;
- boolean isLargeAsCapabilityCfg = h.bgpconfig.getLargeASCapability();
- boolean isLsCapabilityCfg = h.bgpconfig.getLsCapability();
-
- while (listIterator.hasNext()) {
- BgpValueType tlv = listIterator.next();
- if (tlv.getType() == MULTI_PROTOCOL_EXTN_CAPA_TYPE) {
- isMultiProtocolcapabilityExists = true;
- }
- if (tlv.getType() == FOUR_OCTET_AS_NUM_CAPA_TYPE) {
- isFourOctetCapabilityExits = true;
- capAsNum = ((FourOctetAsNumCapabilityTlv) tlv).getInt();
- }
- }
-
- if (isFourOctetCapabilityExits) {
- if (capAsNum > MAX_AS2_NUM) {
- if (openmsg.getAsNumber() != AS_TRANS) {
- throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR, BgpErrorType.BAD_PEER_AS, null);
- }
- } else {
- if (capAsNum != openmsg.getAsNumber()) {
- throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR, BgpErrorType.BAD_PEER_AS, null);
- }
- }
- }
-
- if ((isLsCapabilityCfg)) {
- if (!isMultiProtocolcapabilityExists) {
- tempTlv = new MultiProtocolExtnCapabilityTlv(AFI, RES, SAFI);
- unSupportedCapabilityTlv.add(tempTlv);
- }
- }
-
- if ((isLargeAsCapabilityCfg)) {
- if (!isFourOctetCapabilityExits) {
- tempTlv = new FourOctetAsNumCapabilityTlv(h.bgpconfig.getAsNumber());
- unSupportedCapabilityTlv.add(tempTlv);
- }
- }
-
- if (unSupportedCaplistIterator.hasNext()) {
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- while (unSupportedCaplistIterator.hasNext()) {
- BgpValueType tlv = unSupportedCaplistIterator.next();
- tlv.write(buffer);
- }
- throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR, BgpErrorType.UNSUPPORTED_CAPABILITY, buffer);
- } else {
- return true;
- }
- }
-
- /**
- * AS Number Validation.
- *
- * @param h channel Handler
- * @param openMsg open message
- * @return true or false
- */
- private boolean asNumberValidation(BgpChannelHandler h, BgpOpenMsg openMsg) {
- log.debug("AS Num validation");
-
- int capAsNum = 0;
- boolean isFourOctetCapabilityExits = false;
-
- BgpPeerCfg peerCfg = h.bgpconfig.displayPeers(peerAddr);
- List<BgpValueType> capabilityTlv = openMsg.getCapabilityTlv();
- ListIterator<BgpValueType> listIterator = capabilityTlv.listIterator();
-
- while (listIterator.hasNext()) {
- BgpValueType tlv = listIterator.next();
- if (tlv.getType() == FOUR_OCTET_AS_NUM_CAPA_TYPE) {
- isFourOctetCapabilityExits = true;
- capAsNum = ((FourOctetAsNumCapabilityTlv) tlv).getInt();
- }
- }
-
- if (peerCfg.getAsNumber() > MAX_AS2_NUM) {
- if (openMsg.getAsNumber() != AS_TRANS) {
- return false;
- }
-
- if (!isFourOctetCapabilityExits) {
- return false;
- }
-
- if (peerCfg.getAsNumber() != capAsNum) {
- return false;
- }
-
- isIbgpSession = peerCfg.getIsIBgp();
- if (isIbgpSession) {
- // IBGP - AS number should be same for Peer and local if it is IBGP
- if (h.bgpconfig.getAsNumber() != capAsNum) {
- return false;
- }
- }
- } else {
-
- if (openMsg.getAsNumber() != peerCfg.getAsNumber()) {
- return false;
- }
-
- if (isFourOctetCapabilityExits) {
- if (capAsNum != peerCfg.getAsNumber()) {
- return false;
- }
- }
-
- isIbgpSession = peerCfg.getIsIBgp();
- if (isIbgpSession) {
- // IBGP - AS number should be same for Peer and local if it is IBGP
- if (openMsg.getAsNumber() != h.bgpconfig.getAsNumber()) {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Validates BGP ID.
- *
- * @param openMsg open message
- * @return true or false
- */
- private boolean bgpIdValidation(BgpOpenMsg openMsg) {
- String openMsgBgpId = Ip4Address.valueOf(openMsg.getBgpId()).toString();
-
- InetAddress ipAddress;
- try {
- ipAddress = InetAddress.getByName(openMsgBgpId);
- if (ipAddress.isMulticastAddress()) {
- return false;
- }
- } catch (UnknownHostException e) {
- log.debug("InetAddress convertion failed");
- }
- return true;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConfig.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConfig.java
deleted file mode 100755
index 95a07ad5..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConfig.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.controller.impl;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-import org.onosproject.bgp.controller.BgpCfg;
-import org.onosproject.bgp.controller.BgpConnectPeer;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.bgp.controller.BgpId;
-import org.onosproject.bgp.controller.BgpPeer;
-import org.onosproject.bgp.controller.BgpPeerCfg;
-import org.onosproject.bgp.controller.impl.BgpControllerImpl.BgpPeerManagerImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Provides BGP configuration of this BGP speaker.
- */
-public class BgpConfig implements BgpCfg {
-
- protected static final Logger log = LoggerFactory.getLogger(BgpConfig.class);
-
- private static final short DEFAULT_HOLD_TIMER = 120;
- private static final short DEFAULT_CONN_RETRY_TIME = 120;
- private static final short DEFAULT_CONN_RETRY_COUNT = 5;
-
- private State state = State.INIT;
- private int localAs;
- private int maxSession;
- private boolean lsCapability;
- private short holdTime;
- private boolean largeAs = false;
- private int maxConnRetryTime;
- private int maxConnRetryCount;
-
- private Ip4Address routerId = null;
- private TreeMap<String, BgpPeerCfg> bgpPeerTree = new TreeMap<>();
- private BgpConnectPeer connectPeer;
- private BgpPeerManagerImpl peerManager;
- private BgpController bgpController;
-
- /*
- * Constructor to initialize the values.
- */
- public BgpConfig(BgpController bgpController) {
- this.bgpController = bgpController;
- this.peerManager = (BgpPeerManagerImpl) bgpController.peerManager();
- this.holdTime = DEFAULT_HOLD_TIMER;
- this.maxConnRetryTime = DEFAULT_CONN_RETRY_TIME;
- this.maxConnRetryCount = DEFAULT_CONN_RETRY_COUNT;
- this.lsCapability = true;
- }
-
- @Override
- public State getState() {
- return state;
- }
-
- @Override
- public void setState(State state) {
- this.state = state;
- }
-
- @Override
- public int getAsNumber() {
- return this.localAs;
- }
-
- @Override
- public void setAsNumber(int localAs) {
-
- State localState = getState();
- this.localAs = localAs;
-
- /* Set configuration state */
- if (localState == State.IP_CONFIGURED) {
- setState(State.IP_AS_CONFIGURED);
- } else {
- setState(State.AS_CONFIGURED);
- }
- }
-
- @Override
- public int getMaxSession() {
- return this.maxSession;
- }
-
- @Override
- public void setMaxSession(int maxSession) {
- this.maxSession = maxSession;
- }
-
- @Override
- public boolean getLsCapability() {
- return this.lsCapability;
- }
-
- @Override
- public void setLsCapability(boolean lsCapability) {
- this.lsCapability = lsCapability;
- }
-
- @Override
- public String getRouterId() {
- if (this.routerId != null) {
- return this.routerId.toString();
- } else {
- return null;
- }
- }
-
- @Override
- public void setRouterId(String routerId) {
- State localState = getState();
- this.routerId = Ip4Address.valueOf(routerId);
-
- /* Set configuration state */
- if (localState == State.AS_CONFIGURED) {
- setState(State.IP_AS_CONFIGURED);
- } else {
- setState(State.IP_CONFIGURED);
- }
- }
-
- @Override
- public boolean addPeer(String routerid, int remoteAs) {
- return addPeer(routerid, remoteAs, DEFAULT_HOLD_TIMER);
- }
-
- @Override
- public boolean addPeer(String routerid, short holdTime) {
- return addPeer(routerid, this.getAsNumber(), holdTime);
- }
-
- @Override
- public boolean addPeer(String routerid, int remoteAs, short holdTime) {
- BgpPeerConfig lspeer = new BgpPeerConfig();
- if (this.bgpPeerTree.get(routerid) == null) {
-
- lspeer.setPeerRouterId(routerid);
- lspeer.setAsNumber(remoteAs);
- lspeer.setHoldtime(holdTime);
- lspeer.setState(BgpPeerCfg.State.IDLE);
- lspeer.setSelfInnitConnection(false);
-
- if (this.getAsNumber() == remoteAs) {
- lspeer.setIsIBgp(true);
- } else {
- lspeer.setIsIBgp(false);
- }
-
- this.bgpPeerTree.put(routerid, lspeer);
- log.debug("added successfully");
- return true;
- } else {
- log.debug("already exists");
- return false;
- }
- }
-
- @Override
- public boolean connectPeer(String routerid) {
- BgpPeerCfg lspeer = this.bgpPeerTree.get(routerid);
-
- if (lspeer != null) {
- lspeer.setSelfInnitConnection(true);
-
- if (lspeer.connectPeer() == null) {
- connectPeer = new BgpConnectPeerImpl(bgpController, routerid, Controller.getBgpPortNum());
- lspeer.setConnectPeer(connectPeer);
- connectPeer.connectPeer();
- }
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean removePeer(String routerid) {
- BgpPeerCfg lspeer = this.bgpPeerTree.get(routerid);
-
- if (lspeer != null) {
-
- disconnectPeer(routerid);
- lspeer.setSelfInnitConnection(false);
- lspeer = this.bgpPeerTree.remove(routerid);
- log.debug("Deleted : " + routerid + " successfully");
-
- return true;
- } else {
- log.debug("Did not find : " + routerid);
- return false;
- }
- }
-
- @Override
- public boolean disconnectPeer(String routerid) {
- BgpPeerCfg lspeer = this.bgpPeerTree.get(routerid);
-
- if (lspeer != null) {
-
- BgpPeer disconnPeer = peerManager.getPeer(BgpId.bgpId(IpAddress.valueOf(routerid)));
- if (disconnPeer != null) {
- // TODO: send notification peer deconfigured
- disconnPeer.disconnectPeer();
- }
- lspeer.connectPeer().disconnectPeer();
- lspeer.setState(BgpPeerCfg.State.IDLE);
- lspeer.setSelfInnitConnection(false);
- log.debug("Disconnected : " + routerid + " successfully");
-
- return true;
- } else {
- log.debug("Did not find : " + routerid);
- return false;
- }
- }
-
- @Override
- public void setPeerConnState(String routerid, BgpPeerCfg.State state) {
- BgpPeerCfg lspeer = this.bgpPeerTree.get(routerid);
-
- if (lspeer != null) {
- lspeer.setState(state);
- log.debug("Peer : " + routerid + " is not available");
-
- return;
- } else {
- log.debug("Did not find : " + routerid);
- return;
- }
- }
-
- @Override
- public BgpPeerCfg.State getPeerConnState(String routerid) {
- BgpPeerCfg lspeer = this.bgpPeerTree.get(routerid);
-
- if (lspeer != null) {
- return lspeer.getState();
- } else {
- return BgpPeerCfg.State.INVALID; //No instance
- }
- }
-
- @Override
- public boolean isPeerConnectable(String routerid) {
- BgpPeerCfg lspeer = this.bgpPeerTree.get(routerid);
-
- if ((lspeer != null) && lspeer.getState().equals(BgpPeerCfg.State.IDLE)) {
- return true;
- }
-
- return false;
- }
-
- @Override
- public TreeMap<String, BgpPeerCfg> getPeerTree() {
- return this.bgpPeerTree;
- }
-
- @Override
- public TreeMap<String, BgpPeerCfg> displayPeers() {
- if (this.bgpPeerTree.isEmpty()) {
- log.debug("There are no BGP peers");
- } else {
- Set<Entry<String, BgpPeerCfg>> set = this.bgpPeerTree.entrySet();
- Iterator<Entry<String, BgpPeerCfg>> list = set.iterator();
- BgpPeerCfg lspeer;
-
- while (list.hasNext()) {
- Entry<String, BgpPeerCfg> me = list.next();
- lspeer = me.getValue();
- log.debug("Peer neighbor IP :" + me.getKey());
- log.debug(", AS Number : " + lspeer.getAsNumber());
- log.debug(", Hold Timer : " + lspeer.getHoldtime());
- log.debug(", Is iBGP : " + lspeer.getIsIBgp());
- }
- }
- return null;
- }
-
- @Override
- public BgpPeerCfg displayPeers(String routerid) {
-
- if (this.bgpPeerTree.isEmpty()) {
- log.debug("There are no Bgp peers");
- } else {
- return this.bgpPeerTree.get(routerid);
- }
- return null;
- }
-
- @Override
- public void setHoldTime(short holdTime) {
- this.holdTime = holdTime;
- }
-
- @Override
- public short getHoldTime() {
- return this.holdTime;
- }
-
- @Override
- public boolean getLargeASCapability() {
- return this.largeAs;
- }
-
- @Override
- public void setLargeASCapability(boolean largeAs) {
- this.largeAs = largeAs;
- }
-
- @Override
- public boolean isPeerConfigured(String routerid) {
- BgpPeerCfg lspeer = this.bgpPeerTree.get(routerid);
- return (lspeer != null) ? true : false;
- }
-
- @Override
- public boolean isPeerConnected(String routerid) {
- // TODO: is peer connected
- return true;
- }
-
- @Override
- public int getMaxConnRetryCount() {
- return this.maxConnRetryCount;
- }
-
- @Override
- public void setMaxConnRetryCout(int retryCount) {
- this.maxConnRetryCount = retryCount;
- }
-
- @Override
- public int getMaxConnRetryTime() {
- return this.maxConnRetryTime;
- }
-
- @Override
- public void setMaxConnRetryTime(int retryTime) {
- this.maxConnRetryTime = retryTime;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConnectPeerImpl.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConnectPeerImpl.java
deleted file mode 100755
index 27db618d..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConnectPeerImpl.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.onosproject.bgp.controller.impl;
-
-import java.net.InetSocketAddress;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import org.jboss.netty.bootstrap.ClientBootstrap;
-import org.jboss.netty.channel.ChannelFuture;
-import org.jboss.netty.channel.ChannelFutureListener;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.onosproject.bgp.controller.BgpCfg;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.bgp.controller.BgpPeerCfg;
-import org.onosproject.bgp.controller.BgpConnectPeer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implements connection initiation to peer on peer configuration and manage channel using netty channel handler.
- */
-public class BgpConnectPeerImpl implements BgpConnectPeer {
- private static final Logger log = LoggerFactory.getLogger(BgpConnectPeerImpl.class);
-
- private ScheduledExecutorService connectExecutor = null;
- private final String peerHost;
- private static final int RETRY_INTERVAL = 4;
- private final int peerPort;
- private int connectRetryCounter = 0;
- private int connectRetryTime;
- private ChannelPipelineFactory pfact;
- private ClientBootstrap peerBootstrap;
- private BgpCfg bgpconfig;
-
- /**
- * Initialize timer and initiate pipeline factory.
- *
- * @param bgpController parent BGP controller
- * @param remoteHost remote host to connect
- * @param remotePort remote port to connect
- */
- public BgpConnectPeerImpl(BgpController bgpController, String remoteHost, int remotePort) {
-
- this.bgpconfig = bgpController.getConfig();
- this.pfact = new BgpPipelineFactory(bgpController, false);
- this.peerBootstrap = Controller.peerBootstrap();
- this.peerBootstrap.setPipelineFactory(pfact);
- this.peerHost = remoteHost;
- this.peerPort = remotePort;
- this.connectRetryTime = 0;
- }
-
- @Override
- public void disconnectPeer() {
- if (connectExecutor != null) {
- connectExecutor.shutdown();
- connectExecutor = null;
- }
- }
-
- @Override
- public void connectPeer() {
- scheduleConnectionRetry(this.connectRetryTime);
- }
-
- /**
- * Retry connection with exponential back-off mechanism.
- *
- * @param retryDelay retry delay
- */
- private void scheduleConnectionRetry(long retryDelay) {
- if (this.connectExecutor == null) {
- this.connectExecutor = Executors.newSingleThreadScheduledExecutor();
- }
- this.connectExecutor.schedule(new ConnectionRetry(), retryDelay, TimeUnit.MINUTES);
- }
-
- /**
- * Implements BGP connection and manages connection to peer with back-off mechanism in case of failure.
- */
- class ConnectionRetry implements Runnable {
- @Override
- public void run() {
- log.debug("Connect to peer {}", peerHost);
-
- InetSocketAddress connectToSocket = new InetSocketAddress(peerHost, peerPort);
-
- try {
- bgpconfig.setPeerConnState(peerHost, BgpPeerCfg.State.CONNECT);
- peerBootstrap.connect(connectToSocket).addListener(new ChannelFutureListener() {
- @Override
- public void operationComplete(ChannelFuture future) throws Exception {
- if (!future.isSuccess()) {
- bgpconfig.setPeerConnState(peerHost, BgpPeerCfg.State.ACTIVE);
- connectRetryCounter++;
- log.error("Connection failed, ConnectRetryCounter {} remote host {}", connectRetryCounter,
- peerHost);
- /*
- * Reconnect to peer on failure is exponential till 4 mins, later on retry after every 4
- * mins.
- */
- if (connectRetryTime < RETRY_INTERVAL) {
- connectRetryTime = (connectRetryTime != 0) ? connectRetryTime * 2 : 1;
- }
- scheduleConnectionRetry(connectRetryTime);
- } else {
-
- connectRetryCounter++;
- log.info("Connected to remote host {}, Connect Counter {}", peerHost, connectRetryCounter);
- disconnectPeer();
- return;
- }
- }
- });
- } catch (Exception e) {
- log.info("Connect peer exception : " + e.toString());
- disconnectPeer();
- }
- }
- }
-}
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpControllerImpl.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpControllerImpl.java
deleted file mode 100755
index 51ab68be..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpControllerImpl.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgp.controller.impl;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Service;
-import org.onosproject.bgp.controller.BgpCfg;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.bgp.controller.BgpId;
-import org.onosproject.bgp.controller.BgpLocalRib;
-import org.onosproject.bgp.controller.BgpPeer;
-import org.onosproject.bgp.controller.BgpNodeListener;
-import org.onosproject.bgp.controller.BgpPeerManager;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpMessage;
-import org.onosproject.bgpio.protocol.BgpUpdateMsg;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.MpReachNlri;
-import org.onosproject.bgpio.types.MpUnReachNlri;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Component(immediate = true)
-@Service
-public class BgpControllerImpl implements BgpController {
-
- private static final Logger log = LoggerFactory.getLogger(BgpControllerImpl.class);
-
- protected ConcurrentHashMap<BgpId, BgpPeer> connectedPeers = new ConcurrentHashMap<BgpId, BgpPeer>();
-
- protected BgpPeerManagerImpl peerManager = new BgpPeerManagerImpl();
-
- private BgpLocalRib bgplocalRIB = new BgpLocalRibImpl(this);
- private BgpLocalRib bgplocalRIBVpn = new BgpLocalRibImpl(this);
-
- protected Set<BgpNodeListener> bgpNodeListener = new CopyOnWriteArraySet<>();
-
- final Controller ctrl = new Controller(this);
-
- private BgpConfig bgpconfig = new BgpConfig(this);
-
- @Activate
- public void activate() {
- this.ctrl.start();
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- // Close all connected peers
- closeConnectedPeers();
- this.ctrl.stop();
- log.info("Stopped");
- }
-
- @Override
- public Iterable<BgpPeer> getPeers() {
- return this.connectedPeers.values();
- }
-
- @Override
- public BgpPeer getPeer(BgpId bgpId) {
- return this.connectedPeers.get(bgpId);
- }
-
- @Override
- public void addListener(BgpNodeListener listener) {
- this.bgpNodeListener.add(listener);
- }
-
- @Override
- public void removeListener(BgpNodeListener listener) {
- this.bgpNodeListener.remove(listener);
- }
-
- @Override
- public Set<BgpNodeListener> listener() {
- return bgpNodeListener;
- }
-
- @Override
- public void writeMsg(BgpId bgpId, BgpMessage msg) {
- this.getPeer(bgpId).sendMessage(msg);
- }
-
- @Override
- public void processBGPPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException {
-
- BgpPeer peer = getPeer(bgpId);
-
- switch (msg.getType()) {
- case OPEN:
- // TODO: Process Open message
- break;
- case KEEP_ALIVE:
- // TODO: Process keepalive message
- break;
- case NOTIFICATION:
- // TODO: Process notificatoin message
- break;
- case UPDATE:
- BgpUpdateMsg updateMsg = (BgpUpdateMsg) msg;
- List<BgpValueType> pathAttr = updateMsg.bgpPathAttributes().pathAttributes();
- if (pathAttr == null) {
- log.debug("llPathAttr is null, cannot process update message");
- break;
- }
- Iterator<BgpValueType> listIterator = pathAttr.iterator();
- boolean isLinkstate = false;
- while (listIterator.hasNext()) {
- BgpValueType attr = listIterator.next();
- if ((attr instanceof MpReachNlri) || (attr instanceof MpUnReachNlri)) {
- isLinkstate = true;
- }
- }
- if (isLinkstate) {
- peer.buildAdjRibIn(pathAttr);
- }
- break;
- default:
- // TODO: Process other message
- break;
- }
- }
-
- @Override
- public void closeConnectedPeers() {
- BgpPeer bgpPeer;
- for (BgpId id : this.connectedPeers.keySet()) {
- bgpPeer = getPeer(id);
- bgpPeer.disconnectPeer();
- }
- }
-
- /**
- * Implementation of an BGP Peer which is responsible for keeping track of connected peers and the state in which
- * they are.
- */
- public class BgpPeerManagerImpl implements BgpPeerManager {
-
- private final Logger log = LoggerFactory.getLogger(BgpPeerManagerImpl.class);
- private final Lock peerLock = new ReentrantLock();
-
- @Override
- public boolean addConnectedPeer(BgpId bgpId, BgpPeer bgpPeer) {
-
- if (connectedPeers.get(bgpId) != null) {
- this.log.error("Trying to add connectedPeer but found previous " + "value for bgp ip: {}",
- bgpId.toString());
- return false;
- } else {
- this.log.debug("Added Peer {}", bgpId.toString());
- connectedPeers.put(bgpId, bgpPeer);
- return true;
- }
- }
-
- @Override
- public boolean isPeerConnected(BgpId bgpId) {
- if (connectedPeers.get(bgpId) == null) {
- this.log.error("Is peer connected: bgpIp {}.", bgpId.toString());
- return false;
- }
-
- return true;
- }
-
- @Override
- public void removeConnectedPeer(BgpId bgpId) {
- connectedPeers.remove(bgpId);
- }
-
- @Override
- public BgpPeer getPeer(BgpId bgpId) {
- return connectedPeers.get(bgpId);
- }
-
- /**
- * Gets bgp peer instance.
- *
- * @param bgpController controller instance.
- * @param sessionInfo bgp session info.
- * @param pktStats packet statistics.
- * @return BGPPeer peer instance.
- */
- public BgpPeer getBgpPeerInstance(BgpController bgpController, BgpSessionInfoImpl sessionInfo,
- BgpPacketStatsImpl pktStats) {
- BgpPeer bgpPeer = new BgpPeerImpl(bgpController, sessionInfo, pktStats);
- return bgpPeer;
- }
-
- }
-
- /**
- * Returns controller.
- *
- * @return controller
- */
- public Controller controller() {
- return this.ctrl;
- }
-
- @Override
- public ConcurrentHashMap<BgpId, BgpPeer> connectedPeers() {
- return connectedPeers;
- }
-
- @Override
- public BgpPeerManagerImpl peerManager() {
- return peerManager;
- }
-
- @Override
- public BgpCfg getConfig() {
- return this.bgpconfig;
- }
-
- @Override
- public int connectedPeerCount() {
- return connectedPeers.size();
- }
-
- /**
- * Gets the BGP local RIB.
- *
- * @return bgplocalRIB BGP local RIB.
- */
- @Override
- public BgpLocalRib bgpLocalRib() {
- return bgplocalRIB;
- }
-
- /**
- * Gets the BGP local RIB with VPN.
- *
- * @return bgplocalRIBVpn BGP VPN local RIB .
- */
- @Override
- public BgpLocalRib bgpLocalRibVpn() {
- return bgplocalRIBVpn;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpKeepAliveTimer.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpKeepAliveTimer.java
deleted file mode 100755
index 524ac4c1..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpKeepAliveTimer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgp.controller.impl;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implement sending keepalive message to connected peer periodically based on negotiated holdtime.
- */
-public class BgpKeepAliveTimer {
-
- private Timer keepAliveTimer;
- private BgpChannelHandler handler;
- private static final Logger log = LoggerFactory.getLogger(BgpKeepAliveTimer.class);
-
- /**
- * Gets keepalive timer object.
- *
- * @return keepAliveTimer keepalive timer.
- */
- public Timer getKeepAliveTimer() {
- return keepAliveTimer;
- }
-
- /**
- * Initialize timer to send keepalive message periodically.
- *
- * @param h channel handler
- * @param seconds time interval.
- */
- public BgpKeepAliveTimer(BgpChannelHandler h, int seconds) {
- this.handler = h;
- this.keepAliveTimer = new Timer();
- this.keepAliveTimer.schedule(new SendKeepAlive(), 0, seconds * 1000);
- }
-
- /**
- * Send keepalive message to connected peer on schedule.
- */
- class SendKeepAlive extends TimerTask {
- @Override
- public void run() {
- log.debug("Sending periodic KeepAlive");
-
- try {
- // Send keep alive message
- handler.sendKeepAliveMessage();
- handler.getBgpPacketStats().addOutPacket();
- } catch (Exception e) {
- log.info("Exception occured while sending keepAlive message" + e.toString());
- }
- }
- }
-}
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java
deleted file mode 100755
index 44b19057..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java
+++ /dev/null
@@ -1,603 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package org.onosproject.bgp.controller.impl;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.bgp.controller.BgpId;
-import org.onosproject.bgp.controller.BgpLocalRib;
-import org.onosproject.bgp.controller.BgpNodeListener;
-import org.onosproject.bgp.controller.BgpSessionInfo;
-import org.onosproject.bgpio.protocol.BgpLSNlri;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpPrefixLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib;
-import org.onosproject.bgpio.types.RouteDistinguisher;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.base.MoreObjects;
-
-/**
- * Implementation of local RIB.
- */
-public class BgpLocalRibImpl implements BgpLocalRib {
-
- private static final Logger log = LoggerFactory.getLogger(BgpLocalRibImpl.class);
- private BgpController bgpController;
-
- private Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> nodeTree = new TreeMap<>();
- private Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib> linkTree = new TreeMap<>();
- private Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib> prefixTree = new TreeMap<>();
-
- private Map<RouteDistinguisher, Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnNodeTree
- = new TreeMap<>();
- private Map<RouteDistinguisher, Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnLinkTree
- = new TreeMap<>();
- private Map<RouteDistinguisher, Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnPrefixTree
- = new TreeMap<>();
-
- public BgpLocalRibImpl(BgpController bgpController) {
- this.bgpController = bgpController;
- }
-
- /**
- * Gets node NLRI tree.
- *
- * @return node tree
- */
- public Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> nodeTree() {
- return nodeTree;
- }
-
- /**
- * Gets link NLRI tree.
- *
- * @return link tree
- */
- public Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib> linkTree() {
- return linkTree;
- }
-
- /**
- * Gets prefix NLRI tree.
- *
- * @return prefix tree
- */
- public Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib> prefixTree() {
- return prefixTree;
- }
-
- /**
- * Gets VPN node NLRI tree.
- *
- * @return vpn node NLRI tree
- */
- public Map<RouteDistinguisher, Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnNodeTree() {
- return vpnNodeTree;
- }
-
- /**
- * Gets VPN link NLRI tree.
- *
- * @return vpn link NLRI Tree
- */
- public Map<RouteDistinguisher, Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnLinkTree() {
- return vpnLinkTree;
- }
-
- /**
- * Gets VPN prefix NLRI tree.
- *
- * @return vpn prefix NLRI Tree
- */
- public Map<RouteDistinguisher, Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnPrefixTree() {
- return vpnPrefixTree;
- }
-
- @Override
- public void add(BgpSessionInfo sessionInfo, BgpLSNlri nlri, PathAttrNlriDetails details) {
- int decisionResult;
-
- log.debug("Add to local RIB {}", details.toString());
-
- PathAttrNlriDetailsLocalRib detailsLocRib = new PathAttrNlriDetailsLocalRib(
- sessionInfo.remoteBgpId().ipAddress(),
- sessionInfo.remoteBgpIdentifier(),
- sessionInfo.remoteBgpASNum(),
- sessionInfo.isIbgpSession(), details);
- if (nlri instanceof BgpNodeLSNlriVer4) {
- BgpNodeLSIdentifier nodeLsIdentifier = ((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors();
- if (nodeTree.containsKey(nodeLsIdentifier)) {
- BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
- // Compare local RIB entry with the current attribute
- decisionResult = selectionAlgo.compare(nodeTree.get(nodeLsIdentifier), detailsLocRib);
- if (decisionResult < 0) {
- nodeTree.replace(nodeLsIdentifier, detailsLocRib);
- log.debug("Local RIB update node: {}", detailsLocRib.toString());
- }
- } else {
- nodeTree.put(nodeLsIdentifier, detailsLocRib);
- for (BgpNodeListener l : bgpController.listener()) {
- l.addNode((BgpNodeLSNlriVer4) nlri);
- }
- log.debug("Local RIB ad node: {}", detailsLocRib.toString());
- }
- } else if (nlri instanceof BgpLinkLsNlriVer4) {
- BgpLinkLSIdentifier linkLsIdentifier = ((BgpLinkLsNlriVer4) nlri).getLinkIdentifier();
- if (linkTree.containsKey(linkLsIdentifier)) {
- BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
- // Compare local RIB entry with the current attribute
- decisionResult = selectionAlgo.compare(linkTree.get(linkLsIdentifier), detailsLocRib);
- if (decisionResult < 0) {
- linkTree.replace(linkLsIdentifier, detailsLocRib);
- log.debug("Local RIB update link: {}", detailsLocRib.toString());
- }
- } else {
- linkTree.put(linkLsIdentifier, detailsLocRib);
- log.debug("Local RIB add link: {}", detailsLocRib.toString());
- }
- } else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
- BgpPrefixLSIdentifier prefixIdentifier = ((BgpPrefixIPv4LSNlriVer4) nlri).getPrefixIdentifier();
- if (prefixTree.containsKey(prefixIdentifier)) {
- BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
- // Compare local RIB entry with the current attribute
- decisionResult = selectionAlgo.compare(prefixTree.get(prefixIdentifier), detailsLocRib);
- if (decisionResult < 0) {
- prefixTree.replace(prefixIdentifier, detailsLocRib);
- log.debug("Local RIB update prefix: {}", detailsLocRib.toString());
- }
- } else {
- prefixTree.put(prefixIdentifier, detailsLocRib);
- log.debug("Local RIB add prefix: {}", detailsLocRib.toString());
- }
- }
- }
-
- @Override
- public void delete(BgpLSNlri nlri) {
- log.debug("Delete from local RIB.");
-
- // Update local RIB
- decisionProcess(nlri);
- }
-
- /**
- * Update local RIB based on selection algorithm.
- *
- * @param nlri NLRI to update
- */
- public void decisionProcess(BgpLSNlri nlri) {
- checkNotNull(nlri);
- if (nlri instanceof BgpNodeLSNlriVer4) {
- selectionProcessNode(nlri, false);
- } else if (nlri instanceof BgpLinkLsNlriVer4) {
- selectionProcessLink(nlri, false);
- } else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
- selectionProcessPrefix(nlri, false);
- }
- }
-
- /**
- * Update VPN local RIB .
- *
- * @param nlri NLRI to update
- * @param routeDistinguisher VPN id to update
- */
- public void decisionProcess(BgpLSNlri nlri, RouteDistinguisher routeDistinguisher) {
- checkNotNull(nlri);
- if (nlri instanceof BgpNodeLSNlriVer4) {
- if (vpnNodeTree.containsKey(routeDistinguisher)) {
- selectionProcessNode(nlri, true);
- if (nodeTree.size() == 0) {
- vpnNodeTree.remove(routeDistinguisher);
- }
- }
- } else if (nlri instanceof BgpLinkLsNlriVer4) {
- if (vpnLinkTree.containsKey(routeDistinguisher)) {
- selectionProcessLink(nlri, true);
- if (linkTree.size() == 0) {
- vpnLinkTree.remove(routeDistinguisher);
- }
- }
- } else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
- if (vpnPrefixTree.containsKey(routeDistinguisher)) {
- selectionProcessPrefix(nlri, true);
- if (prefixTree.size() == 0) {
- vpnPrefixTree.remove(routeDistinguisher);
- }
- }
- }
- }
-
- /**
- * Selection process for local RIB node.
- *
- * @param nlri NLRI to update
- * @param isVpnRib true if VPN local RIB, otherwise false
- */
- public void selectionProcessNode(BgpLSNlri nlri, boolean isVpnRib) {
- BgpPeerImpl peer;
- BgpSessionInfo sessionInfo;
- int decisionResult;
- boolean containsKey;
-
- BgpNodeLSIdentifier nodeLsIdentifier = ((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors();
-
- if (nodeTree.containsKey(nodeLsIdentifier)) {
- for (BgpNodeListener l : bgpController.listener()) {
- l.deleteNode((BgpNodeLSNlriVer4) nlri);
- }
- log.debug("Local RIB delete node: {}", nodeLsIdentifier.toString());
- nodeTree.remove(nodeLsIdentifier);
- }
-
- for (BgpId bgpId : bgpController.connectedPeers().keySet()) {
- peer = (BgpPeerImpl) (bgpController.getPeer(bgpId));
-
- if (nodeTree.containsKey(nodeLsIdentifier)) {
- containsKey = (!isVpnRib) ? (peer.adjacencyRib().nodeTree().containsKey(nodeLsIdentifier)) :
- (peer.vpnAdjacencyRib().nodeTree().containsKey(nodeLsIdentifier));
-
- if (!containsKey) {
- continue;
- }
- sessionInfo = peer.sessionInfo();
- PathAttrNlriDetailsLocalRib detailsLocRib = new PathAttrNlriDetailsLocalRib(
- sessionInfo.remoteBgpId().ipAddress(),
- sessionInfo.remoteBgpIdentifier(),
- sessionInfo.remoteBgpASNum(),
- sessionInfo.isIbgpSession(),
- (!isVpnRib) ?
- (peer.adjacencyRib().nodeTree()
- .get(nodeLsIdentifier)) :
- (peer.vpnAdjacencyRib().nodeTree()
- .get(nodeLsIdentifier)));
- BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
- decisionResult = selectionAlgo.compare(nodeTree.get(nodeLsIdentifier), detailsLocRib);
- if (decisionResult < 0) {
- nodeTree.replace(nodeLsIdentifier, detailsLocRib);
- log.debug("Local RIB node updated: {}", detailsLocRib.toString());
- }
- } else {
- if (!isVpnRib) {
- if (peer.adjacencyRib().nodeTree().containsKey(nodeLsIdentifier)) {
- add(peer.sessionInfo(), nlri, peer.adjacencyRib().nodeTree().get(nodeLsIdentifier));
- }
- } else {
- if (peer.vpnAdjacencyRib().nodeTree().containsKey(nodeLsIdentifier)) {
- add(peer.sessionInfo(), nlri, peer.vpnAdjacencyRib().nodeTree().get(nodeLsIdentifier));
- }
- }
- }
- }
- }
-
- /**
- * Selection process for local RIB link.
- *
- * @param nlri NLRI to update
- * @param isVpnRib true if VPN local RIB, otherwise false
- */
- public void selectionProcessLink(BgpLSNlri nlri, boolean isVpnRib) {
- BgpPeerImpl peer;
- BgpSessionInfo sessionInfo;
- int decisionResult;
- boolean containsKey;
-
- BgpLinkLSIdentifier linkLsIdentifier = ((BgpLinkLsNlriVer4) nlri).getLinkIdentifier();
-
- if (linkTree.containsKey(linkLsIdentifier)) {
- log.debug("Local RIB remove link: {}", linkLsIdentifier.toString());
- linkTree.remove(linkLsIdentifier);
- }
-
- for (BgpId bgpId : bgpController.connectedPeers().keySet()) {
- peer = (BgpPeerImpl) (bgpController.getPeer(bgpId));
-
- if (linkTree.containsKey(linkLsIdentifier)) {
-
- containsKey = (!isVpnRib) ? (peer.adjacencyRib().linkTree().containsKey(linkLsIdentifier)) :
- (peer.vpnAdjacencyRib().linkTree().containsKey(linkLsIdentifier));
-
- if (!containsKey) {
- continue;
- }
-
- sessionInfo = peer.sessionInfo();
-
- PathAttrNlriDetailsLocalRib detailsLocRib = new PathAttrNlriDetailsLocalRib(
- sessionInfo.remoteBgpId().ipAddress(),
- sessionInfo.remoteBgpIdentifier(),
- sessionInfo.remoteBgpASNum(),
- sessionInfo.isIbgpSession(),
- ((!isVpnRib) ?
- (peer.adjacencyRib().linkTree().get(linkLsIdentifier)) :
- (peer.vpnAdjacencyRib().linkTree()
- .get(linkLsIdentifier))));
-
- BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
- decisionResult = selectionAlgo.compare(linkTree.get(linkLsIdentifier), detailsLocRib);
- if (decisionResult < 0) {
- linkTree.replace(linkLsIdentifier, detailsLocRib);
- log.debug("Local RIB link updated: {}", detailsLocRib.toString());
- }
- } else {
- if (!isVpnRib) {
- if (peer.adjacencyRib().linkTree().containsKey(linkLsIdentifier)) {
- add(peer.sessionInfo(), nlri, peer.adjacencyRib().linkTree().get(linkLsIdentifier));
- }
- } else {
- if (peer.vpnAdjacencyRib().linkTree().containsKey(linkLsIdentifier)) {
- add(peer.sessionInfo(), nlri, peer.vpnAdjacencyRib().linkTree().get(linkLsIdentifier));
- }
- }
- }
- }
- }
-
- /**
- * Selection process for local RIB prefix.
- *
- * @param nlri NLRI to update
- * @param isVpnRib true if VPN local RIB, otherwise false
- */
- public void selectionProcessPrefix(BgpLSNlri nlri, boolean isVpnRib) {
- BgpPeerImpl peer;
- BgpSessionInfo sessionInfo;
- int decisionResult;
- boolean containsKey;
-
- BgpPrefixLSIdentifier prefixIdentifier = ((BgpPrefixIPv4LSNlriVer4) nlri).getPrefixIdentifier();
- if (prefixTree.containsKey(prefixIdentifier)) {
- log.debug("Local RIB remove prefix: {}", prefixIdentifier.toString());
- prefixTree.remove(prefixIdentifier);
- }
-
- for (BgpId bgpId : bgpController.connectedPeers().keySet()) {
- peer = (BgpPeerImpl) (bgpController.getPeer(bgpId));
-
- if (prefixTree.containsKey(prefixIdentifier)) {
-
- containsKey = (!isVpnRib) ? (peer.adjacencyRib().prefixTree().containsKey(prefixIdentifier)) :
- (peer.vpnAdjacencyRib().prefixTree().containsKey(prefixIdentifier));
- if (!containsKey) {
- continue;
- }
- sessionInfo = peer.sessionInfo();
-
- PathAttrNlriDetailsLocalRib detailsLocRib = new PathAttrNlriDetailsLocalRib(
- sessionInfo.remoteBgpId().ipAddress(),
- sessionInfo.remoteBgpIdentifier(),
- sessionInfo.remoteBgpASNum(),
- sessionInfo.isIbgpSession(),
- ((!isVpnRib) ?
- (peer.adjacencyRib().prefixTree()
- .get(prefixIdentifier)) :
- (peer.vpnAdjacencyRib().prefixTree()
- .get(prefixIdentifier))));
-
- BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
- decisionResult = selectionAlgo.compare(prefixTree.get(prefixIdentifier), detailsLocRib);
- if (decisionResult < 0) {
- prefixTree.replace(prefixIdentifier, detailsLocRib);
- log.debug("local RIB prefix updated: {}", detailsLocRib.toString());
- }
- } else {
- if (!isVpnRib) {
- if (peer.adjacencyRib().prefixTree().containsKey(prefixIdentifier)) {
- add(peer.sessionInfo(), nlri, peer.adjacencyRib().prefixTree().get(prefixIdentifier));
- } else {
- if (peer.vpnAdjacencyRib().prefixTree().containsKey(prefixIdentifier)) {
- add(peer.sessionInfo(), nlri, peer.vpnAdjacencyRib().prefixTree().get(prefixIdentifier));
- }
- }
- }
- }
- }
- }
-
- @Override
- public void add(BgpSessionInfo sessionInfo, BgpLSNlri nlri, PathAttrNlriDetails details,
- RouteDistinguisher routeDistinguisher) {
- add(sessionInfo, nlri, details);
- if (nlri instanceof BgpNodeLSNlriVer4) {
- if (!vpnNodeTree.containsKey(routeDistinguisher)) {
- vpnNodeTree.put(routeDistinguisher, nodeTree);
- }
- } else if (nlri instanceof BgpLinkLsNlriVer4) {
- if (!vpnLinkTree.containsKey(routeDistinguisher)) {
- vpnLinkTree.put(routeDistinguisher, linkTree);
- }
- } else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
- if (!vpnPrefixTree.containsKey(routeDistinguisher)) {
- vpnPrefixTree.put(routeDistinguisher, prefixTree);
- }
- }
- }
-
- @Override
- public void delete(BgpLSNlri nlri, RouteDistinguisher routeDistinguisher) {
- // Update local RIB
- decisionProcess(nlri, routeDistinguisher);
- }
-
- /**
- * Update local RIB node based on avaliable peer adjacency RIB.
- *
- * @param o adjacency-in/VPN adjacency-in
- */
- public void localRIBUpdateNode(Object o) {
-
- if (o instanceof AdjRibIn) {
- AdjRibIn adjRib = (AdjRibIn) o;
- log.debug("Update local RIB node.");
-
- Set<BgpNodeLSIdentifier> nodeKeys = adjRib.nodeTree().keySet();
- for (BgpNodeLSIdentifier key : nodeKeys) {
- PathAttrNlriDetails pathAttrNlri = adjRib.nodeTree().get(key);
-
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(pathAttrNlri.identifier(), pathAttrNlri
- .protocolID().getType(), key, false, null);
- decisionProcess(nodeNlri);
- }
- }
-
- if (o instanceof VpnAdjRibIn) {
- VpnAdjRibIn vpnAdjRib = (VpnAdjRibIn) o;
- log.debug("Update local RIB VPN node.");
- Set<RouteDistinguisher> nodeKeysVpn = vpnAdjRib.vpnNodeTree().keySet();
- Map<BgpNodeLSIdentifier, PathAttrNlriDetails> node;
- for (RouteDistinguisher keyVpnNode : nodeKeysVpn) {
- node = vpnAdjRib.vpnNodeTree().get(keyVpnNode);
-
- Set<BgpNodeLSIdentifier> vpnNodeKeys = node.keySet();
- for (BgpNodeLSIdentifier key : vpnNodeKeys) {
- PathAttrNlriDetails pathAttrNlri = vpnAdjRib.nodeTree().get(key);
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(pathAttrNlri.identifier(),
- pathAttrNlri.protocolID().getType(),
- key, true, keyVpnNode);
- decisionProcess(nodeNlri, keyVpnNode);
- }
- }
- }
- }
-
- /**
- * Update localRIB link based on avaliable peer adjacency RIB.
- *
- * @param o adjacency-in/VPN adjacency-in
- */
- public void localRIBUpdateLink(Object o) {
-
- if (o instanceof AdjRibIn) {
- AdjRibIn adjRib = (AdjRibIn) o;
- log.debug("Update local RIB link.");
-
- Set<BgpLinkLSIdentifier> linkKeys = adjRib.linkTree().keySet();
- for (BgpLinkLSIdentifier key : linkKeys) {
- PathAttrNlriDetails pathAttrNlri = adjRib.linkTree().get(key);
- BgpLinkLsNlriVer4 linkNlri = new BgpLinkLsNlriVer4(pathAttrNlri.protocolID().getType(),
- pathAttrNlri.identifier(), key, null, false);
- decisionProcess(linkNlri);
- }
- }
-
- if (o instanceof VpnAdjRibIn) {
- VpnAdjRibIn vpnAdjRib = (VpnAdjRibIn) o;
- log.debug("Update local RIB VPN link");
-
- Set<RouteDistinguisher> linkKeysVpn = vpnAdjRib.vpnLinkTree().keySet();
- Map<BgpLinkLSIdentifier, PathAttrNlriDetails> link;
- for (RouteDistinguisher keyVpnLink : linkKeysVpn) {
- link = vpnAdjRib.vpnLinkTree().get(keyVpnLink);
-
- Set<BgpLinkLSIdentifier> vpnLinkKeys = link.keySet();
- for (BgpLinkLSIdentifier key : vpnLinkKeys) {
- PathAttrNlriDetails pathAttrNlri = vpnAdjRib.linkTree().get(key);
- BgpLinkLsNlriVer4 linkNlri = new BgpLinkLsNlriVer4(pathAttrNlri.protocolID().getType(),
- pathAttrNlri.identifier(), key, keyVpnLink,
- true);
- decisionProcess(linkNlri, keyVpnLink);
- }
- }
- }
- }
-
- /**
- * Update localRIB prefix based on avaliable peer adjacency RIB.
- *
- * @param o instance of adjacency-in/VPN adjacency-in
- */
- public void localRIBUpdatePrefix(Object o) {
-
- if (o instanceof AdjRibIn) {
- AdjRibIn adjRib = (AdjRibIn) o;
- log.debug("Update local RIB prefix.");
-
- Set<BgpPrefixLSIdentifier> prefixKeys = adjRib.prefixTree().keySet();
- for (BgpPrefixLSIdentifier key : prefixKeys) {
- PathAttrNlriDetails pathAttrNlri = adjRib.prefixTree().get(key);
- BgpPrefixIPv4LSNlriVer4 prefixNlri = new BgpPrefixIPv4LSNlriVer4(
- pathAttrNlri.identifier(),
- pathAttrNlri.protocolID().getType(),
- key, null, false);
- decisionProcess(prefixNlri);
- }
- }
-
- if (o instanceof VpnAdjRibIn) {
- VpnAdjRibIn vpnAdjRib = (VpnAdjRibIn) o;
- log.debug("Update local RIB VPN prefix.");
-
- Set<RouteDistinguisher> prefixKeysVpn = vpnAdjRib.vpnPrefixTree().keySet();
- Map<BgpPrefixLSIdentifier, PathAttrNlriDetails> prefix;
- for (RouteDistinguisher keyVpnPrefix : prefixKeysVpn) {
- prefix = vpnAdjRib.vpnPrefixTree().get(keyVpnPrefix);
-
- Set<BgpPrefixLSIdentifier> vpnPrefixKeys = prefix.keySet();
- for (BgpPrefixLSIdentifier key : vpnPrefixKeys) {
- PathAttrNlriDetails pathAttrNlri = vpnAdjRib.prefixTree().get(key);
- BgpPrefixIPv4LSNlriVer4 prefixNlri = new BgpPrefixIPv4LSNlriVer4(pathAttrNlri.identifier(),
- pathAttrNlri.protocolID()
- .getType(), key,
- keyVpnPrefix, true);
- decisionProcess(prefixNlri, keyVpnPrefix);
- }
- }
- }
- }
-
- /**
- * Update localRIB.
- *
- * @param adjRibIn adjacency RIB-in
- */
- public void localRIBUpdate(AdjRibIn adjRibIn) {
- log.debug("Update local RIB.");
-
- localRIBUpdateNode(adjRibIn);
- localRIBUpdateLink(adjRibIn);
- localRIBUpdatePrefix(adjRibIn);
- }
-
- /**
- * Update localRIB.
- *
- * @param vpnAdjRibIn VPN adjacency RIB-in
- */
- public void localRIBUpdate(VpnAdjRibIn vpnAdjRibIn) {
- log.debug("Update VPN local RIB.");
-
- localRIBUpdateNode(vpnAdjRibIn);
- localRIBUpdateLink(vpnAdjRibIn);
- localRIBUpdatePrefix(vpnAdjRibIn);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues().add("nodeTree", nodeTree)
- .add("linkTree", linkTree).add("prefixTree", prefixTree).add("vpnNodeTree", vpnNodeTree)
- .add("vpnLinkTree", vpnLinkTree).add("vpnPrefixTree", vpnPrefixTree).toString();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpMessageDecoder.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpMessageDecoder.java
deleted file mode 100755
index 431c6210..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpMessageDecoder.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.controller.impl;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.onosproject.bgpio.protocol.BgpMessage;
-import org.onlab.util.HexDump;
-import org.onosproject.bgpio.protocol.BgpFactories;
-import org.onosproject.bgpio.protocol.BgpMessageReader;
-import org.onosproject.bgpio.types.BgpHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Decode an bgp message from a Channel, for use in a netty pipeline.
- */
-public class BgpMessageDecoder extends FrameDecoder {
-
- protected static final Logger log = LoggerFactory.getLogger(BgpMessageDecoder.class);
-
- @Override
- protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
- log.debug("MESSAGE IS RECEIVED.");
- if (!channel.isConnected()) {
- log.info("Channel is not connected.");
- return null;
- }
-
- HexDump.dump(buffer);
-
- BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
- List<BgpMessage> msgList = new LinkedList<BgpMessage>();
-
- while (buffer.readableBytes() > 0) {
- BgpHeader bgpHeader = new BgpHeader();
- BgpMessage message = reader.readFrom(buffer, bgpHeader);
- msgList.add(message);
- }
- return msgList;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpMessageEncoder.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpMessageEncoder.java
deleted file mode 100755
index 3e56d6ff..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpMessageEncoder.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.controller.impl;
-
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
-import org.onosproject.bgpio.protocol.BgpMessage;
-import org.onlab.util.HexDump;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Encode an bgp message for output into a ChannelBuffer, for use in a
- * netty pipeline.
- */
-public class BgpMessageEncoder extends OneToOneEncoder {
- protected static final Logger log = LoggerFactory.getLogger(BgpMessageEncoder.class);
-
- @Override
- protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
- log.debug("BGPMessageEncoder::encode");
- if (!(msg instanceof List)) {
- log.debug("Invalid msg.");
- return msg;
- }
-
- @SuppressWarnings("unchecked")
- List<BgpMessage> msglist = (List<BgpMessage>) msg;
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- log.debug("SENDING MESSAGE");
- for (BgpMessage pm : msglist) {
- pm.writeTo(buf);
- }
-
- HexDump.dump(buf);
-
- return buf;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPacketStatsImpl.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPacketStatsImpl.java
deleted file mode 100755
index 7494c814..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPacketStatsImpl.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.controller.impl;
-
-import org.onosproject.bgp.controller.BgpPacketStats;
-
-/**
- * A representation of a packet context which allows any provider
- * to view a packet in event, but may block the response to the
- * event if blocked has been called. This packet context can be used
- * to react to the packet in event with a packet out.
- */
-public class BgpPacketStatsImpl implements BgpPacketStats {
-
- private int inPacketCount;
- private int outPacketCount;
- private int wrongPacketCount;
- private long time;
-
- /**
- * Resets parameter.
- */
- public BgpPacketStatsImpl() {
- this.inPacketCount = 0;
- this.outPacketCount = 0;
- this.wrongPacketCount = 0;
- this.time = 0;
- }
-
- /**
- * Get the outgoing packet count number.
- *
- * @return packet count
- */
- public int outPacketCount() {
- return outPacketCount;
- }
-
- /**
- * Get the incoming packet count number.
- *
- * @return packet count
- */
- public int inPacketCount() {
- return inPacketCount;
- }
-
- /**
- * Get the wrong packet count number.
- *
- * @return packet count
- */
- public int wrongPacketCount() {
- return wrongPacketCount;
- }
-
- /**
- * Increments the received packet counter.
- */
- public void addInPacket() {
- this.inPacketCount++;
- }
-
- /**
- * Increments the sent packet counter.
- */
- public void addOutPacket() {
- this.outPacketCount++;
- }
-
- /**
- * Increments the sent packet counter by specified value.
- *
- * @param value of no of packets sent
- */
- public void addOutPacket(int value) {
- this.outPacketCount = this.outPacketCount + value;
- }
-
- /**
- * Increments the wrong packet counter.
- */
- public void addWrongPacket() {
- this.wrongPacketCount++;
- }
-
- /**
- * Resets wrong packet count.
- */
- public void resetWrongPacket() {
- this.wrongPacketCount = 0;
- }
-
- /**
- * Get the time.
- *
- * @return time
- */
- public long getTime() {
- return this.time;
- }
-
- /**
- * Sets the time.
- *
- * @param time value to set
- */
- public void setTime(long time) {
- this.time = time;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerConfig.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerConfig.java
deleted file mode 100755
index a8eaee3c..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerConfig.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.controller.impl;
-
-import org.onlab.packet.Ip4Address;
-import org.onosproject.bgp.controller.BgpConnectPeer;
-import org.onosproject.bgp.controller.BgpPeerCfg;
-
-/**
- * BGP Peer configuration information.
- */
-public class BgpPeerConfig implements BgpPeerCfg {
- private int asNumber;
- private short holdTime;
- private boolean isIBgp;
- private Ip4Address peerId = null;
- private State state;
- private boolean selfInitiated;
- private BgpConnectPeer connectPeer;
-
- /**
- * Constructor to initialize the values.
- */
- BgpPeerConfig() {
- state = State.IDLE;
- selfInitiated = false;
- }
-
- @Override
- public int getAsNumber() {
- return this.asNumber;
- }
-
- @Override
- public void setAsNumber(int asNumber) {
- this.asNumber = asNumber;
- }
-
- @Override
- public short getHoldtime() {
- return this.holdTime;
- }
-
- @Override
- public void setHoldtime(short holdTime) {
- this.holdTime = holdTime;
- }
-
- @Override
- public boolean getIsIBgp() {
- return this.isIBgp;
- }
-
- @Override
- public void setIsIBgp(boolean isIBgp) {
- this.isIBgp = isIBgp;
- }
-
- @Override
- public String getPeerRouterId() {
- if (this.peerId != null) {
- return this.peerId.toString();
- } else {
- return null;
- }
- }
-
- @Override
- public void setPeerRouterId(String peerId) {
- this.peerId = Ip4Address.valueOf(peerId);
- }
-
- @Override
- public void setPeerRouterId(String peerId, int asNumber) {
- this.peerId = Ip4Address.valueOf(peerId);
- this.asNumber = asNumber;
- }
-
- @Override
- public State getState() {
- return this.state;
- }
-
- @Override
- public void setState(State state) {
- this.state = state;
- }
-
- @Override
- public boolean getSelfInnitConnection() {
- return this.selfInitiated;
- }
-
- @Override
- public void setSelfInnitConnection(boolean selfInit) {
- this.selfInitiated = selfInit;
- }
-
- @Override
- public BgpConnectPeer connectPeer() {
- return this.connectPeer;
- }
-
- @Override
- public void setConnectPeer(BgpConnectPeer connectPeer) {
- this.connectPeer = connectPeer;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerImpl.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerImpl.java
deleted file mode 100644
index e3f09f30..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerImpl.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgp.controller.impl;
-
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.Collections;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.concurrent.RejectedExecutionException;
-
-import org.jboss.netty.channel.Channel;
-import org.onlab.packet.IpAddress;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.bgp.controller.BgpPeer;
-import org.onosproject.bgp.controller.BgpSessionInfo;
-import org.onosproject.bgp.controller.BgpLocalRib;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpFactories;
-import org.onosproject.bgpio.protocol.BgpFactory;
-import org.onosproject.bgpio.protocol.BgpLSNlri;
-import org.onosproject.bgpio.protocol.BgpMessage;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.MpReachNlri;
-import org.onosproject.bgpio.types.MpUnReachNlri;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * BGPPeerImpl implements BGPPeer, maintains peer information and store updates in RIB .
- */
-public class BgpPeerImpl implements BgpPeer {
-
- protected final Logger log = LoggerFactory.getLogger(BgpPeerImpl.class);
-
- private static final String SHUTDOWN_MSG = "Worker has already been shutdown";
-
- private BgpController bgpController;
- private Channel channel;
- protected String channelId;
- private boolean connected;
- protected boolean isHandShakeComplete = false;
- private BgpSessionInfo sessionInfo;
- private BgpPacketStatsImpl pktStats;
- private BgpLocalRib bgplocalRIB;
- private BgpLocalRib bgplocalRIBVpn;
- private AdjRibIn adjRib;
- private VpnAdjRibIn vpnAdjRib;
-
- /**
- * Return the adjacency RIB-IN.
- *
- * @return adjRib the adjacency RIB-IN
- */
- public AdjRibIn adjacencyRib() {
- return adjRib;
- }
-
- /**
- * Return the adjacency RIB-IN with VPN.
- *
- * @return vpnAdjRib the adjacency RIB-IN with VPN
- */
- public VpnAdjRibIn vpnAdjacencyRib() {
- return vpnAdjRib;
- }
-
- @Override
- public BgpSessionInfo sessionInfo() {
- return sessionInfo;
- }
-
- /**
- * Initialize peer.
- *
- *@param bgpController controller instance
- *@param sessionInfo bgp session info
- *@param pktStats packet statistics
- */
- public BgpPeerImpl(BgpController bgpController, BgpSessionInfo sessionInfo, BgpPacketStatsImpl pktStats) {
- this.bgpController = bgpController;
- this.sessionInfo = sessionInfo;
- this.pktStats = pktStats;
- this.bgplocalRIB = bgpController.bgpLocalRib();
- this.bgplocalRIBVpn = bgpController.bgpLocalRibVpn();
- this.adjRib = new AdjRibIn();
- this.vpnAdjRib = new VpnAdjRibIn();
- }
-
-
- @Override
- public void buildAdjRibIn(List<BgpValueType> pathAttr) throws BgpParseException {
- ListIterator<BgpValueType> iterator = pathAttr.listIterator();
- while (iterator.hasNext()) {
- BgpValueType attr = iterator.next();
- if (attr instanceof MpReachNlri) {
- List<BgpLSNlri> nlri = ((MpReachNlri) attr).mpReachNlri();
- callAdd(this, nlri, pathAttr);
- }
- if (attr instanceof MpUnReachNlri) {
- List<BgpLSNlri> nlri = ((MpUnReachNlri) attr).mpUnReachNlri();
- callRemove(this, nlri);
- }
- }
- }
-
- /**
- * Updates NLRI identifier node in a tree separately based on afi and safi.
- *
- * @param peerImpl BGP peer instance
- * @param nlri MpReachNlri path attribute
- * @param pathAttr list of BGP path attributes
- * @throws BgpParseException throws exception
- */
- public void callAdd(BgpPeerImpl peerImpl, List<BgpLSNlri> nlri, List<BgpValueType> pathAttr)
- throws BgpParseException {
- ListIterator<BgpLSNlri> listIterator = nlri.listIterator();
- while (listIterator.hasNext()) {
- BgpLSNlri nlriInfo = listIterator.next();
- if (nlriInfo instanceof BgpNodeLSNlriVer4) {
- PathAttrNlriDetails details = setPathAttrDetails(nlriInfo, pathAttr);
- if (!((BgpNodeLSNlriVer4) nlriInfo).isVpnPresent()) {
- adjRib.add(nlriInfo, details);
- bgplocalRIB.add(sessionInfo(), nlriInfo, details);
- } else {
- vpnAdjRib.addVpn(nlriInfo, details, ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher());
- bgplocalRIBVpn.add(sessionInfo(), nlriInfo, details,
- ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher());
- }
- } else if (nlriInfo instanceof BgpLinkLsNlriVer4) {
- PathAttrNlriDetails details = setPathAttrDetails(nlriInfo, pathAttr);
- if (!((BgpLinkLsNlriVer4) nlriInfo).isVpnPresent()) {
- adjRib.add(nlriInfo, details);
- bgplocalRIB.add(sessionInfo(), nlriInfo, details);
- } else {
- vpnAdjRib.addVpn(nlriInfo, details, ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher());
- bgplocalRIBVpn.add(sessionInfo(), nlriInfo, details,
- ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher());
- }
- } else if (nlriInfo instanceof BgpPrefixIPv4LSNlriVer4) {
- PathAttrNlriDetails details = setPathAttrDetails(nlriInfo, pathAttr);
- if (!((BgpPrefixIPv4LSNlriVer4) nlriInfo).isVpnPresent()) {
- adjRib.add(nlriInfo, details);
- bgplocalRIB.add(sessionInfo(), nlriInfo, details);
- } else {
- vpnAdjRib.addVpn(nlriInfo, details, ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher());
- bgplocalRIBVpn.add(sessionInfo(), nlriInfo, details,
- ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher());
- }
- }
- }
- }
-
- /**
- * Sets BGP path attribute and NLRI details.
- *
- * @param nlriInfo MpReachNlri path attribute
- * @param pathAttr list of BGP path attributes
- * @return details object of PathAttrNlriDetails
- * @throws BgpParseException throw exception
- */
- public PathAttrNlriDetails setPathAttrDetails(BgpLSNlri nlriInfo, List<BgpValueType> pathAttr)
- throws BgpParseException {
- PathAttrNlriDetails details = new PathAttrNlriDetails();
- details.setProtocolID(nlriInfo.getProtocolId());
- details.setIdentifier(nlriInfo.getIdentifier());
- details.setPathAttribute(pathAttr);
- return details;
- }
-
- /**
- * Removes NLRI identifier node in a tree separately based on afi and safi.
- *
- * @param peerImpl BGP peer instance
- * @param nlri NLRI information
- */
- public void callRemove(BgpPeerImpl peerImpl, List<BgpLSNlri> nlri) {
- ListIterator<BgpLSNlri> listIterator = nlri.listIterator();
- while (listIterator.hasNext()) {
- BgpLSNlri nlriInfo = listIterator.next();
- if (nlriInfo instanceof BgpNodeLSNlriVer4) {
- if (!((BgpNodeLSNlriVer4) nlriInfo).isVpnPresent()) {
- adjRib.remove(nlriInfo);
- bgplocalRIB.delete(nlriInfo);
- } else {
- vpnAdjRib.removeVpn(nlriInfo, ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher());
- bgplocalRIBVpn.delete(nlriInfo, ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher());
- }
- } else if (nlriInfo instanceof BgpLinkLsNlriVer4) {
- if (!((BgpLinkLsNlriVer4) nlriInfo).isVpnPresent()) {
- adjRib.remove(nlriInfo);
- bgplocalRIB.delete(nlriInfo);
- } else {
- vpnAdjRib.removeVpn(nlriInfo, ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher());
- bgplocalRIBVpn.delete(nlriInfo, ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher());
- }
- } else if (nlriInfo instanceof BgpPrefixIPv4LSNlriVer4) {
- if (!((BgpPrefixIPv4LSNlriVer4) nlriInfo).isVpnPresent()) {
- adjRib.remove(nlriInfo);
- bgplocalRIB.delete(nlriInfo);
- } else {
- vpnAdjRib.removeVpn(nlriInfo, ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher());
- bgplocalRIBVpn.delete(nlriInfo, ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher());
- }
- }
- }
- }
-
- /**
- * Return the adjacency RIB-IN.
- *
- * @return adjRib the adjacency RIB-IN
- */
- public AdjRibIn adjRib() {
- return adjRib;
- }
-
- /**
- * Return the adjacency RIB-IN with VPN.
- *
- * @return vpnAdjRib the adjacency RIB-IN with VPN
- */
- public VpnAdjRibIn vpnAdjRib() {
- return vpnAdjRib;
- }
-
- /**
- * Update localRIB on peer disconnect.
- *
- */
- public void updateLocalRIBOnPeerDisconnect() {
- BgpLocalRibImpl localRib = (BgpLocalRibImpl) bgplocalRIB;
- BgpLocalRibImpl localRibVpn = (BgpLocalRibImpl) bgplocalRIBVpn;
-
- localRib.localRIBUpdate(adjacencyRib());
- localRibVpn.localRIBUpdate(vpnAdjacencyRib());
- }
-
- // ************************
- // Channel related
- // ************************
-
- @Override
- public final void disconnectPeer() {
- this.channel.close();
- }
-
- @Override
- public final void sendMessage(BgpMessage m) {
- log.debug("Sending message to {}", channel.getRemoteAddress());
- try {
- channel.write(Collections.singletonList(m));
- this.pktStats.addOutPacket();
- } catch (RejectedExecutionException e) {
- log.warn(e.getMessage());
- if (!e.getMessage().contains(SHUTDOWN_MSG)) {
- throw e;
- }
- }
- }
-
- @Override
- public final void sendMessage(List<BgpMessage> msgs) {
- try {
- channel.write(msgs);
- this.pktStats.addOutPacket(msgs.size());
- } catch (RejectedExecutionException e) {
- log.warn(e.getMessage());
- if (!e.getMessage().contains(SHUTDOWN_MSG)) {
- throw e;
- }
- }
- }
-
- @Override
- public final boolean isConnected() {
- return this.connected;
- }
-
- @Override
- public final void setConnected(boolean connected) {
- this.connected = connected;
- };
-
- @Override
- public final void setChannel(Channel channel) {
- this.channel = channel;
- final SocketAddress address = channel.getRemoteAddress();
- if (address instanceof InetSocketAddress) {
- final InetSocketAddress inetAddress = (InetSocketAddress) address;
- final IpAddress ipAddress = IpAddress.valueOf(inetAddress.getAddress());
- if (ipAddress.isIp4()) {
- channelId = ipAddress.toString() + ':' + inetAddress.getPort();
- } else {
- channelId = '[' + ipAddress.toString() + "]:" + inetAddress.getPort();
- }
- }
- };
-
- @Override
- public final Channel getChannel() {
- return this.channel;
- };
-
- @Override
- public String channelId() {
- return channelId;
- }
-
- @Override
- public BgpFactory factory() {
- return BgpFactories.getFactory(sessionInfo.remoteBgpVersion());
- }
-
- @Override
- public boolean isHandshakeComplete() {
- return isHandShakeComplete;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("channel", channelId())
- .add("BgpId", sessionInfo().remoteBgpId()).toString();
- }
-}
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPipelineFactory.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPipelineFactory.java
deleted file mode 100755
index 28e1041c..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPipelineFactory.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgp.controller.impl;
-
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.Channels;
-import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
-import org.jboss.netty.util.ExternalResourceReleasable;
-import org.jboss.netty.util.HashedWheelTimer;
-import org.jboss.netty.util.Timer;
-import org.onosproject.bgp.controller.BgpController;
-
-/**
- * Creates a ChannelPipeline for a server-side bgp channel.
- */
-public class BgpPipelineFactory
- implements ChannelPipelineFactory, ExternalResourceReleasable {
-
- static final Timer TIMER = new HashedWheelTimer();
- protected ReadTimeoutHandler readTimeoutHandler;
- private boolean isBgpServ;
- private BgpController bgpController;
-
- /**
- * Constructor to initialize the values.
- *
- * @param bgpController parent controller
- * @param isBgpServ if it is a server or remote peer
- */
- public BgpPipelineFactory(BgpController bgpController, boolean isBgpServ) {
- super();
- this.isBgpServ = isBgpServ;
- this.bgpController = bgpController;
- /* hold time */
- this.readTimeoutHandler = new ReadTimeoutHandler(TIMER, bgpController.getConfig().getHoldTime());
- }
-
- @Override
- public ChannelPipeline getPipeline() throws Exception {
- BgpChannelHandler handler = new BgpChannelHandler(bgpController);
-
- ChannelPipeline pipeline = Channels.pipeline();
- pipeline.addLast("bgpmessagedecoder", new BgpMessageDecoder());
- pipeline.addLast("bgpmessageencoder", new BgpMessageEncoder());
- pipeline.addLast("holdTime", readTimeoutHandler);
- if (isBgpServ) {
- pipeline.addLast("PassiveHandler", handler);
- } else {
- pipeline.addLast("ActiveHandler", handler);
- }
-
- return pipeline;
- }
-
- @Override
- public void releaseExternalResources() {
- TIMER.stop();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpSelectionAlgo.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpSelectionAlgo.java
deleted file mode 100644
index d3065f43..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpSelectionAlgo.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.controller.impl;
-
-import java.util.Comparator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib;
-import org.onosproject.bgpio.types.AsPath;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.LocalPref;
-import org.onosproject.bgpio.types.Med;
-import org.onosproject.bgpio.types.Origin;
-import org.onosproject.bgpio.types.Origin.ORIGINTYPE;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of BGP best path Selection process.
- */
-public final class BgpSelectionAlgo implements Comparator<PathAttrNlriDetailsLocalRib> {
- private static final Logger log = LoggerFactory.getLogger(BgpSelectionAlgo.class);
- LocalPref obj1LocPref = null;
- AsPath obj1Aspath = null;
- Origin obj1Origin = null;
- Med obj1Med = null;
- LocalPref obj2LocPref = null;
- AsPath obj2Aspath = null;
- Origin obj2Origin = null;
- Med obj2Med = null;
-
- @Override
- public int compare(PathAttrNlriDetailsLocalRib pathNlriDetails1, PathAttrNlriDetailsLocalRib pathNlriDetails2) {
- if (pathNlriDetails1 == null) {
- return -1;
- }
- if (pathNlriDetails2 == null) {
- return 1;
- }
- if (pathNlriDetails1.equals(pathNlriDetails2)) {
- return 0;
- }
-
- List<BgpValueType> o1 = pathNlriDetails1.localRibNlridetails().pathAttributes();
- List<BgpValueType> o2 = pathNlriDetails2.localRibNlridetails().pathAttributes();
- ListIterator<BgpValueType> listIteratorObj1 = o1.listIterator();
- ListIterator<BgpValueType> listIteratorObj2 = o2.listIterator();
- storeAttr(listIteratorObj1, listIteratorObj2);
-
- // prefer attribute with higher local preference
- if (obj1LocPref != null || obj2LocPref != null && (obj1LocPref != null && !obj1LocPref.equals(obj2LocPref))) {
- return compareLocalPref(obj1LocPref, obj2LocPref);
- }
-
- // prefer attribute with shortest Aspath
- if (!obj1Aspath.equals(obj2Aspath)) {
- Integer obj1Size = countASSize(obj1Aspath);
- Integer obj2Size = countASSize(obj2Aspath);
- if (obj1Size != obj2Size) {
- return compareAsPath(obj1Size, obj2Size);
- }
- }
-
- // prefer attribute with lowest origin type
- if (!obj1Origin.equals(obj2Origin)) {
- return compareOrigin(obj1Origin, obj2Origin);
- }
-
- // prefer attribute with lowest MED
- if (obj1Med != null || obj2Med != null && (obj1Med != null && !obj1Med.equals(obj2Med))) {
- return compareMed(obj1Med, obj2Med);
- }
-
- if ((pathNlriDetails1 != null || pathNlriDetails2 != null) && (pathNlriDetails1 != null && !pathNlriDetails1
- .equals(pathNlriDetails2))) {
- return comparePeerDetails(pathNlriDetails1, pathNlriDetails2);
- }
- return 0;
- }
-
- /**
- * Compares local preference of two objects and returns object with higher preference.
- *
- * @param obj1LocPref local preference object1
- * @param obj2LocPref local preference object2
- * @return object with higher preference
- */
- int compareLocalPref(LocalPref obj1LocPref, LocalPref obj2LocPref) {
- return ((Integer) (obj1LocPref.localPref())).compareTo((Integer) (obj2LocPref.localPref()));
- }
-
- /**
- * Compares AsPath of two objects and returns object with shortest AsPath.
- *
- * @param obj1Size object1 AS count
- * @param obj2Size object2 AS count
- * @return
- */
- int compareAsPath(Integer obj1Size, Integer obj2Size) {
- return obj1Size.compareTo(obj2Size);
- }
-
- /**
- * Compare Origin of two objects and returns object with lowest origin value.
- *
- * @param obj1Origin Origin object1
- * @param obj2Origin Origin object1
- * @return object with lowest origin value
- */
- int compareOrigin(Origin obj1Origin, Origin obj2Origin) {
- if (obj1Origin.origin() == ORIGINTYPE.IGP) {
- return 1;
- }
- if (obj2Origin.origin() == ORIGINTYPE.IGP) {
- return -1;
- }
- if (obj1Origin.origin() == ORIGINTYPE.EGP) {
- return 1;
- } else {
- return -1;
- }
- }
-
- /**
- * Compare Med of two objects and returns object with lowestMed value.
- *
- * @param obj1Med Med object1
- * @param obj2Med Med object2
- * @return returns object with lowestMed value
- */
- int compareMed(Med obj1Med, Med obj2Med) {
- return ((Integer) (obj2Med.med())).compareTo((Integer) (obj1Med.med()));
- }
-
- /**
- * Compares EBGP over IBGP, BGP identifier value and peer address.
- *
- * @param pathNlriDetails1 PathAttrNlriDetailsLocalRib object1
- * @param pathNlriDetails2 PathAttrNlriDetailsLocalRib object2
- * @return object which as EBGP over IBGP, lowest BGP identifier value and lowest peer address
- */
- int comparePeerDetails(PathAttrNlriDetailsLocalRib pathNlriDetails1, PathAttrNlriDetailsLocalRib pathNlriDetails2) {
- // consider EBGP over IBGP
- if (pathNlriDetails1.isLocalRibIbgpSession() != pathNlriDetails2.isLocalRibIbgpSession()) {
- if (pathNlriDetails1 == null || pathNlriDetails1.isLocalRibIbgpSession()) {
- return -1;
- }
- if (pathNlriDetails2 == null || pathNlriDetails2.isLocalRibIbgpSession()) {
- return 1;
- }
- }
- // prefer lowest BGP identifier value.
- if (pathNlriDetails1.localRibIdentifier() != pathNlriDetails2.localRibIdentifier()) {
- return ((Integer) pathNlriDetails2.localRibIdentifier())
- .compareTo(pathNlriDetails1.localRibIdentifier());
- }
- //prefer lowest peer address
- if (pathNlriDetails1.localRibIpAddress() != pathNlriDetails2.localRibIpAddress()) {
- return pathNlriDetails2.localRibIpAddress().compareTo(pathNlriDetails1.localRibIpAddress());
- }
- return 0;
- }
-
- /**
- * Returns ASes count of AsPath attribute , if AS_SET is present then count as 1.
- *
- * @param aspath object of AsPath
- * @return count of ASes
- */
- Integer countASSize(AsPath aspath) {
- boolean isASSet = false;
- int count = 0;
- if (!aspath.asPathSet().isEmpty()) {
- isASSet = true;
- }
- if (!aspath.asPathSeq().isEmpty()) {
- count = aspath.asPathSeq().size();
- }
- return isASSet ? ++count : count;
- }
-
- /**
- * Stores BGP basic attributes of two objects.
- *
- * @param listIteratorObj1 list iterator of object1
- * @param listIteratorObj2 list iterator of object2
- */
- void storeAttr(ListIterator<BgpValueType> listIteratorObj1, ListIterator<BgpValueType> listIteratorObj2) {
- while (listIteratorObj1.hasNext()) {
- BgpValueType pathAttributeObj1 = listIteratorObj1.next();
- switch (pathAttributeObj1.getType()) {
- case LocalPref.LOCAL_PREF_TYPE:
- obj1LocPref = (LocalPref) pathAttributeObj1;
- break;
- case AsPath.ASPATH_TYPE:
- obj1Aspath = (AsPath) pathAttributeObj1;
- break;
- case Origin.ORIGIN_TYPE:
- obj1Origin = (Origin) pathAttributeObj1;
- break;
- case Med.MED_TYPE:
- obj1Med = (Med) pathAttributeObj1;
- break;
- default:
- log.debug("Got other type, Not required: " + pathAttributeObj1.getType());
- }
- }
- while (listIteratorObj2.hasNext()) {
- BgpValueType pathAttributeObj2 = listIteratorObj2.next();
- switch (pathAttributeObj2.getType()) {
- case LocalPref.LOCAL_PREF_TYPE:
- obj2LocPref = (LocalPref) pathAttributeObj2;
- break;
- case AsPath.ASPATH_TYPE:
- obj2Aspath = (AsPath) pathAttributeObj2;
- break;
- case Origin.ORIGIN_TYPE:
- obj2Origin = (Origin) pathAttributeObj2;
- break;
- case Med.MED_TYPE:
- obj2Med = (Med) pathAttributeObj2;
- break;
- default:
- log.debug("Got other type, Not required: " + pathAttributeObj2.getType());
- }
- }
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpSessionInfoImpl.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpSessionInfoImpl.java
deleted file mode 100755
index 33623dc2..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpSessionInfoImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package org.onosproject.bgp.controller.impl;
-
-import org.onosproject.bgp.controller.BgpId;
-import org.onosproject.bgp.controller.BgpSessionInfo;
-import org.onosproject.bgpio.protocol.BgpVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class maintains BGP peer session info.
- */
-public class BgpSessionInfoImpl implements BgpSessionInfo {
-
- protected final Logger log = LoggerFactory.getLogger(BgpSessionInfoImpl.class);
- private BgpId remoteBgpId;
- private BgpVersion remoteBgpVersion;
- private long remoteBgpASNum;
- private short remoteBgpholdTime;
- private int remoteBgpIdentifier;
- private short negotiatedholdTime;
- private boolean isIbgpSession;
-
- /**
- * Initialize session info.
- *
- *@param remoteBgpId remote peer id
- *@param remoteBgpVersion remote peer version
- *@param remoteBgpASNum remote peer AS number
- *@param remoteBgpholdTime remote peer hold time
- *@param remoteBgpIdentifier remote peer identifier
- *@param negotiatedholdTime negotiated hold time
- *@param isIbgpSession session type ibgp/ebgp
- */
- public BgpSessionInfoImpl(BgpId remoteBgpId, BgpVersion remoteBgpVersion, long remoteBgpASNum,
- short remoteBgpholdTime, int remoteBgpIdentifier, short negotiatedholdTime,
- boolean isIbgpSession) {
- this.remoteBgpId = remoteBgpId;
- this.remoteBgpVersion = remoteBgpVersion;
- this.remoteBgpASNum = remoteBgpASNum;
- this.remoteBgpholdTime = remoteBgpholdTime;
- this.remoteBgpIdentifier = remoteBgpIdentifier;
- this.negotiatedholdTime = negotiatedholdTime;
- this.isIbgpSession = isIbgpSession;
- }
-
- @Override
- public boolean isIbgpSession() {
- return isIbgpSession;
- }
-
- @Override
- public short negotiatedholdTime() {
- return negotiatedholdTime;
- }
-
- @Override
- public BgpId remoteBgpId() {
- return remoteBgpId;
- }
-
- @Override
- public BgpVersion remoteBgpVersion() {
- return remoteBgpVersion;
- }
-
- @Override
- public long remoteBgpASNum() {
- return remoteBgpASNum;
- }
-
- @Override
- public short remoteBgpHoldTime() {
- return remoteBgpholdTime;
- }
-
- @Override
- public int remoteBgpIdentifier() {
- return remoteBgpIdentifier;
- }
-}
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/Controller.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/Controller.java
deleted file mode 100755
index f02cee8a..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/Controller.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.controller.impl;
-
-import static org.onlab.util.Tools.groupedThreads;
-
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
-import java.net.InetSocketAddress;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.Executors;
-
-import org.jboss.netty.bootstrap.ClientBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.group.ChannelGroup;
-import org.jboss.netty.channel.group.DefaultChannelGroup;
-import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
-import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.bgpio.protocol.BgpFactories;
-import org.onosproject.bgpio.protocol.BgpFactory;
-import org.onosproject.bgpio.protocol.BgpVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The main controller class. Handles all setup and network listeners - Distributed ownership control of bgp peer
- * through IControllerRegistryService
- */
-public class Controller {
-
- private static final Logger log = LoggerFactory.getLogger(Controller.class);
-
- private static final BgpFactory FACTORY4 = BgpFactories.getFactory(BgpVersion.BGP_4);
-
- private ChannelGroup cg;
- public Channel serverChannel;
-
- // Configuration options
- private static final short BGP_PORT_NUM = 179;
- private static final short PORT_NUM_ZERO = 0;
- private static boolean isPortNumSet = false;
- private final int workerThreads = 16;
- private final int peerWorkerThreads = 16;
-
- // Start time of the controller
- private long systemStartTime;
-
- private NioServerSocketChannelFactory serverExecFactory;
- private NioClientSocketChannelFactory peerExecFactory;
- private static ClientBootstrap peerBootstrap;
- private BgpController bgpController;
-
- // Perf. related configuration
- private static final int SEND_BUFFER_SIZE = 4 * 1024 * 1024;
-
- /**
- * Constructor to initialize the values.
- *
- * @param bgpController bgp controller instance
- */
- public Controller(BgpController bgpController) {
- this.bgpController = bgpController;
- }
-
- /**
- * Returns factory version for processing BGP messages.
- *
- * @return instance of factory version
- */
- static BgpFactory getBgpMessageFactory4() {
- return FACTORY4;
- }
-
- /**
- * To get system start time.
- *
- * @return system start time in milliseconds
- */
- public long getSystemStartTime() {
- return (this.systemStartTime);
- }
-
- /**
- * Tell controller that we're ready to accept bgp peer connections.
- */
- public void run() {
-
- try {
-
- peerBootstrap = createPeerBootStrap();
-
- peerBootstrap.setOption("reuseAddr", true);
- peerBootstrap.setOption("child.keepAlive", true);
- peerBootstrap.setOption("child.tcpNoDelay", true);
- peerBootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE);
-
- final ServerBootstrap bootstrap = createServerBootStrap();
-
- bootstrap.setOption("reuseAddr", true);
- bootstrap.setOption("child.keepAlive", true);
- bootstrap.setOption("child.tcpNoDelay", true);
- bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE);
-
- ChannelPipelineFactory pfact = new BgpPipelineFactory(bgpController, true);
-
- bootstrap.setPipelineFactory(pfact);
- InetSocketAddress sa = new InetSocketAddress(getBgpPortNum());
- cg = new DefaultChannelGroup();
- serverChannel = bootstrap.bind(sa);
- cg.add(serverChannel);
- log.info("Listening for Peer connection on {}", sa);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Creates server boot strap.
- *
- * @return ServerBootStrap
- */
- private ServerBootstrap createServerBootStrap() {
-
- if (workerThreads == 0) {
- serverExecFactory = new NioServerSocketChannelFactory(
- Executors.newCachedThreadPool(groupedThreads("onos/bgp", "boss-%d")),
- Executors.newCachedThreadPool(groupedThreads("onos/bgp", "worker-%d")));
- return new ServerBootstrap(serverExecFactory);
- } else {
- serverExecFactory = new NioServerSocketChannelFactory(
- Executors.newCachedThreadPool(groupedThreads("onos/bgp", "boss-%d")),
- Executors.newCachedThreadPool(groupedThreads("onos/bgp", "worker-%d")),
- workerThreads);
- return new ServerBootstrap(serverExecFactory);
- }
- }
-
- /**
- * Creates peer boot strap.
- *
- * @return ClientBootstrap
- */
- private ClientBootstrap createPeerBootStrap() {
-
- if (peerWorkerThreads == 0) {
- peerExecFactory = new NioClientSocketChannelFactory(
- Executors.newCachedThreadPool(groupedThreads("onos/bgp", "boss-%d")),
- Executors.newCachedThreadPool(groupedThreads("onos/bgp", "worker-%d")));
- return new ClientBootstrap(peerExecFactory);
- } else {
- peerExecFactory = new NioClientSocketChannelFactory(
- Executors.newCachedThreadPool(groupedThreads("onos/bgp", "boss-%d")),
- Executors.newCachedThreadPool(groupedThreads("onos/bgp", "worker-%d")),
- peerWorkerThreads);
- return new ClientBootstrap(peerExecFactory);
- }
- }
-
- /**
- * Gets peer bootstrap.
- *
- * @return peer bootstrap
- */
- public static ClientBootstrap peerBootstrap() {
- return peerBootstrap;
- }
-
- /**
- * Initialize internal data structures.
- */
- public void init() {
- // These data structures are initialized here because other
- // module's startUp() might be called before ours
- this.systemStartTime = System.currentTimeMillis();
- }
-
- /**
- * Gets run time memory.
- *
- * @return m run time memory
- */
- public Map<String, Long> getMemory() {
- Map<String, Long> m = new HashMap<>();
- Runtime runtime = Runtime.getRuntime();
- m.put("total", runtime.totalMemory());
- m.put("free", runtime.freeMemory());
- return m;
- }
-
- /**
- * Gets UP time.
- *
- * @return UP time
- */
- public Long getUptime() {
- RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
- return rb.getUptime();
- }
-
- /**
- * Starts the BGP controller.
- */
- public void start() {
- log.info("Started");
- this.init();
- this.run();
- }
-
- /**
- * Stops the BGP controller.
- */
- public void stop() {
- log.info("Stopped");
- serverExecFactory.shutdown();
- peerExecFactory.shutdown();
- cg.close();
- }
-
- /**
- * Returns port number.
- *
- * @return port number
- */
- public static short getBgpPortNum() {
- if (isPortNumSet) {
- return PORT_NUM_ZERO;
- }
- return BGP_PORT_NUM;
- }
-
- /**
- * sets the isPortNumSet as true.
- */
- public void setBgpPortNum() {
- isPortNumSet = true;
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/VpnAdjRibIn.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/VpnAdjRibIn.java
deleted file mode 100644
index 8a9ea91c..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/VpnAdjRibIn.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.bgp.controller.impl;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.onosproject.bgpio.protocol.BgpLSNlri;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpPrefixLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
-import org.onosproject.bgpio.types.RouteDistinguisher;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implementation of Adj-RIB-In with VPN for each peer.
- */
-public class VpnAdjRibIn {
- private Map<BgpNodeLSIdentifier, PathAttrNlriDetails> nodeTree = new TreeMap<>();
- private Map<BgpLinkLSIdentifier, PathAttrNlriDetails> linkTree = new TreeMap<>();
- private Map<BgpPrefixLSIdentifier, PathAttrNlriDetails> prefixTree = new TreeMap<>();
-
- private Map<RouteDistinguisher, Map<BgpNodeLSIdentifier, PathAttrNlriDetails>> vpnNodeTree
- = new TreeMap<>();
- private Map<RouteDistinguisher, Map<BgpLinkLSIdentifier, PathAttrNlriDetails>> vpnLinkTree
- = new TreeMap<>();
- private Map<RouteDistinguisher, Map<BgpPrefixLSIdentifier, PathAttrNlriDetails>> vpnPrefixTree
- = new TreeMap<>();
- /**
- * Returns the adjacency node.
- *
- * @return node adjacency RIB node
- */
- public Map<BgpNodeLSIdentifier, PathAttrNlriDetails> nodeTree() {
- return nodeTree;
- }
-
- /**
- * Returns the adjacency link.
- *
- * @return link adjacency RIB node
- */
- public Map<BgpLinkLSIdentifier, PathAttrNlriDetails> linkTree() {
- return linkTree;
- }
-
- /**
- * Returns the adjacency prefix.
- *
- * @return prefix adjacency RIB node
- */
- public Map<BgpPrefixLSIdentifier, PathAttrNlriDetails> prefixTree() {
- return prefixTree;
- }
-
- /**
- * Returns the adjacency vpnNode.
- *
- * @return vpnNode adjacency RIB node
- */
- public Map<RouteDistinguisher, Map<BgpNodeLSIdentifier, PathAttrNlriDetails>> vpnNodeTree() {
- return vpnNodeTree;
- }
-
- /**
- * Returns the adjacency vpnLink.
- *
- * @return vpnLink adjacency RIB node
- */
- public Map<RouteDistinguisher, Map<BgpLinkLSIdentifier, PathAttrNlriDetails>> vpnLinkTree() {
- return vpnLinkTree;
- }
-
- /**
- * Returns the adjacency vpnPrefix.
- *
- * @return vpnPrefix adjacency RIB node
- */
- public Map<RouteDistinguisher, Map<BgpPrefixLSIdentifier, PathAttrNlriDetails>> vpnPrefixTree() {
- return vpnPrefixTree;
- }
-
- /**
- * Update vpn nlri identifier into the tree if nlri identifier exists in tree otherwise add this to the tree.
- *
- * @param nlri NLRI info
- * @param details has pathattribute , protocolID and identifier
- */
- public void add(BgpLSNlri nlri, PathAttrNlriDetails details) {
- if (nlri instanceof BgpNodeLSNlriVer4) {
- BgpNodeLSIdentifier nodeLSIdentifier = ((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors();
- if (nodeTree.containsKey(nodeLSIdentifier)) {
- nodeTree.replace(nodeLSIdentifier, details);
- } else {
- nodeTree.put(nodeLSIdentifier, details);
- }
- } else if (nlri instanceof BgpLinkLsNlriVer4) {
- BgpLinkLSIdentifier linkLSIdentifier = ((BgpLinkLsNlriVer4) nlri).getLinkIdentifier();
- if (linkTree.containsKey(linkLSIdentifier)) {
- linkTree.replace(linkLSIdentifier, details);
- } else {
- linkTree.put(linkLSIdentifier, details);
- }
- } else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
- BgpPrefixLSIdentifier prefixIdentifier = ((BgpPrefixIPv4LSNlriVer4) nlri).getPrefixIdentifier();
- if (prefixTree.containsKey(prefixIdentifier)) {
- prefixTree.replace(prefixIdentifier, details);
- } else {
- prefixTree.put(prefixIdentifier, details);
- }
- }
- }
-
- /**
- * Update nlri identifier mapped with route distinguisher if it exists in tree otherwise add nlri infomation mapped
- * to respective route distinguisher in tree.
- *
- * @param nlri NLRI info
- * @param details has pathattribute , protocolID and identifier
- * @param routeDistinguisher unique for for each vpn
- */
- public void addVpn(BgpLSNlri nlri, PathAttrNlriDetails details, RouteDistinguisher routeDistinguisher) {
- add(nlri, details);
- if (nlri instanceof BgpNodeLSNlriVer4) {
- if (!vpnNodeTree.containsKey(routeDistinguisher)) {
- vpnNodeTree.put(routeDistinguisher, nodeTree);
- }
- } else if (nlri instanceof BgpLinkLsNlriVer4) {
- if (!vpnLinkTree.containsKey(routeDistinguisher)) {
- vpnLinkTree.put(routeDistinguisher, linkTree);
- }
- } else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
- if (!vpnPrefixTree.containsKey(routeDistinguisher)) {
- vpnPrefixTree.put(routeDistinguisher, prefixTree);
- }
- }
- }
-
- /**
- * Removes vpn nlri identifier mapped to route distinguisher if it exists in tree.
- *
- * @param nlri NLRI Info
- * @param routeDistinguisher unique for for each vpn
- */
- public void removeVpn(BgpLSNlri nlri, RouteDistinguisher routeDistinguisher) {
- if (nlri instanceof BgpNodeLSNlriVer4) {
- if (vpnNodeTree.containsKey(routeDistinguisher)) {
- BgpNodeLSIdentifier nodeLSIdentifier = ((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors();
- if (nodeTree.containsKey(nodeLSIdentifier)) {
- nodeTree.remove(nodeLSIdentifier);
- }
- if ((vpnNodeTree.get(routeDistinguisher)).isEmpty()) {
- vpnNodeTree.remove(routeDistinguisher);
- }
- }
- } else if (nlri instanceof BgpLinkLsNlriVer4) {
- if (vpnLinkTree.containsKey(routeDistinguisher)) {
- BgpLinkLSIdentifier linkLSIdentifier = ((BgpLinkLsNlriVer4) nlri).getLinkIdentifier();
- if (linkTree.containsKey(linkLSIdentifier)) {
- linkTree.remove(linkLSIdentifier);
- }
- if ((vpnLinkTree.get(routeDistinguisher)).isEmpty()) {
- vpnLinkTree.remove(routeDistinguisher);
- }
- }
- } else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
- if (vpnPrefixTree.containsKey(routeDistinguisher)) {
- BgpPrefixLSIdentifier prefixIdentifier = ((BgpPrefixIPv4LSNlriVer4) nlri).getPrefixIdentifier();
- if (prefixTree.containsKey(prefixIdentifier)) {
- prefixTree.remove(prefixIdentifier);
- }
- if ((vpnPrefixTree.get(routeDistinguisher)).isEmpty()) {
- vpnPrefixTree.remove(routeDistinguisher);
- }
- }
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues().add("nodeTree", nodeTree)
- .add("linkTree", linkTree)
- .add("prefixTree", prefixTree)
- .add("vpnNodeTree", vpnNodeTree)
- .add("vpnLinkTree", vpnLinkTree)
- .add("vpnPrefixTree", vpnPrefixTree)
- .toString();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/package-info.java b/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/package-info.java
deleted file mode 100755
index fd4e9506..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the BGP controller IO subsystem.
- */
-package org.onosproject.bgp.controller.impl;
diff --git a/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpControllerImplTest.java b/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpControllerImplTest.java
deleted file mode 100755
index 7549b922..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpControllerImplTest.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp;
-
-import com.google.common.net.InetAddresses;
-import org.jboss.netty.bootstrap.ClientBootstrap;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelFactory;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.Channels;
-import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-import org.onlab.junit.TestUtils;
-
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.LinkedList;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.onosproject.bgp.controller.BgpCfg;
-import org.onosproject.bgp.controller.impl.BgpControllerImpl;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv;
-import org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv;
-
-/**
- * Test case for BGPControllerImpl.
- */
-public class BgpControllerImplTest {
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpControllerImplTest.class);
-
- private static final String IP_LOOPBACK_ID1 = "127.0.0.1";
-
- private static final int MESSAGE_TIMEOUT_MS = 3000;
- public byte version;
- public short asNumber;
- public short holdTime;
- public int bgpId = InetAddresses.coerceToInteger(InetAddresses.forString(IP_LOOPBACK_ID1));
- public boolean isLargeAsCapabilitySet = false;
- public LinkedList<BgpValueType> capabilityTlv = new LinkedList<>();
-
- @Before
- public void setUp() throws Exception {
- peer1 = new BgpPeerTest(version, asNumber,
- holdTime, bgpId, isLargeAsCapabilitySet,
- capabilityTlv);
-
- bgpControllerImpl = new BgpControllerImpl();
-
- // NOTE: We use port 0 to bind on any available port
- bgpControllerImpl.controller().setBgpPortNum();
- bgpControllerImpl.activate();
-
- Channel serverChannel = TestUtils.getField(bgpControllerImpl.controller(),
- "serverChannel");
- SocketAddress socketAddress = serverChannel.getLocalAddress();
- InetSocketAddress inetSocketAddress =
- (InetSocketAddress) socketAddress;
- InetAddress connectToAddress = InetAddresses.forString("127.0.0.1");
- connectToSocket = new InetSocketAddress(connectToAddress,
- inetSocketAddress.getPort());
-
- bgpControllerImpl.getConfig().setRouterId("1.1.1.1");
- bgpControllerImpl.getConfig().setAsNumber(200);
- bgpControllerImpl.getConfig().setHoldTime((short) 120);
- bgpControllerImpl.getConfig().setState(BgpCfg.State.IP_AS_CONFIGURED);
-
- bgpControllerImpl.getConfig().addPeer("127.0.0.1", 200);
- }
-
- @After
- public void tearDown() throws Exception {
- bgpControllerImpl.deactivate();
- bgpControllerImpl = null;
- }
-
- private BgpControllerImpl bgpControllerImpl;
-
- BgpPeerTest peer1;
-
- // The socket that the remote peers should connect to
- private InetSocketAddress connectToSocket;
-
- @Test
- public void bgpOpenMessageTest1() throws InterruptedException {
- short afi = 16388;
- byte res = 0;
- byte safi = 71;
- peer1.peerChannelHandler.asNumber = 200;
- peer1.peerChannelHandler.version = 4;
- peer1.peerChannelHandler.holdTime = 120;
- bgpControllerImpl.getConfig().setLsCapability(true);
- BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
- peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
- peer1.connect(connectToSocket);
- boolean result;
- result = peer1.peerFrameDecoder.receivedOpenMessageLatch.await(
- MESSAGE_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- assertThat(result, is(true));
- result = peer1.peerFrameDecoder.receivedKeepaliveMessageLatch.await(
- MESSAGE_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- assertThat(result, is(true));
- }
-
- @Test
- public void bgpOpenMessageTest2() throws InterruptedException {
- // Open message with as number which is not configured at peer
- short afi = 16388;
- byte res = 0;
- byte safi = 71;
- peer1.peerChannelHandler.asNumber = 500;
- peer1.peerChannelHandler.version = 4;
- peer1.peerChannelHandler.holdTime = 120;
- bgpControllerImpl.getConfig().setLsCapability(true);
- BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
- peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
- peer1.connect(connectToSocket);
-
- boolean result;
- result = peer1.peerFrameDecoder.receivedOpenMessageLatch.await(MESSAGE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
- assertThat(result, is(true));
- result = peer1.peerFrameDecoder.receivedKeepaliveMessageLatch.await(MESSAGE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
- assertThat(result, is(true));
- result = peer1.peerFrameDecoder.receivedNotificationMessageLatch.await(
- MESSAGE_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- assertThat(result, is(false));
- }
-
- @Test
- public void bgpOpenMessageTest3() throws InterruptedException {
- // Open message with invalid hold time value
- peer1.peerChannelHandler.asNumber = 200;
- peer1.peerChannelHandler.version = 4;
- peer1.peerChannelHandler.holdTime = 1;
- peer1.connect(connectToSocket);
-
- boolean result;
- result = peer1.peerFrameDecoder.receivedNotificationMessageLatch.await(
- MESSAGE_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- assertThat(result, is(true));
- }
-
- @Test
- public void bgpOpenMessageTest4() throws InterruptedException {
- // Open message with invalid as number
- peer1.peerChannelHandler.asNumber = 200;
- peer1.peerChannelHandler.version = 4;
- peer1.peerChannelHandler.holdTime = 120;
- peer1.peerChannelHandler.isLargeAsCapabilitySet = true;
- BgpValueType tempTlv = new FourOctetAsNumCapabilityTlv(766545);
- peer1.peerChannelHandler.capabilityTlv.add(tempTlv);
- peer1.connect(connectToSocket);
-
- boolean result;
- result = peer1.peerFrameDecoder.receivedNotificationMessageLatch.await(
- MESSAGE_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- assertThat(result, is(true));
- }
-
- @Test
- public void bgpOpenMessageTest5() throws InterruptedException {
- // Open message with LS capability
- short afi = 16388;
- byte res = 0;
- byte safi = 71;
- peer1.peerChannelHandler.asNumber = 200;
- peer1.peerChannelHandler.version = 4;
- peer1.peerChannelHandler.holdTime = 120;
- bgpControllerImpl.getConfig().setLsCapability(true);
- BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
- peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
- peer1.connect(connectToSocket);
-
- boolean result;
- result = peer1.peerFrameDecoder.receivedOpenMessageLatch.await(
- MESSAGE_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- assertThat(result, is(true));
- result = peer1.peerFrameDecoder.receivedKeepaliveMessageLatch.await(
- MESSAGE_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- assertThat(result, is(true));
- }
-
- @Test
- public void bgpOpenMessageTest6() throws InterruptedException {
- // Open message with as4 capability
- short afi = 16388;
- byte res = 0;
- byte safi = 71;
- peer1.peerChannelHandler.asNumber = 200;
- peer1.peerChannelHandler.version = 4;
- peer1.peerChannelHandler.holdTime = 120;
- peer1.peerChannelHandler.isLargeAsCapabilitySet = true;
- bgpControllerImpl.getConfig().setLargeASCapability(true);
- BgpValueType tempTlv = new FourOctetAsNumCapabilityTlv(200);
- peer1.peerChannelHandler.capabilityTlv.add(tempTlv);
- bgpControllerImpl.getConfig().setLsCapability(true);
- BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
- peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
- peer1.connect(connectToSocket);
-
- boolean result;
- result = peer1.peerFrameDecoder.receivedOpenMessageLatch.await(
- MESSAGE_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- assertThat(result, is(true));
- result = peer1.peerFrameDecoder.receivedKeepaliveMessageLatch.await(
- MESSAGE_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- assertThat(result, is(true));
-
- result = peer1.peerFrameDecoder.receivedKeepaliveMessageLatch.await(
- MESSAGE_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- assertThat(result, is(true));
- }
-
- @Test
- public void bgpOpenMessageTest7() throws InterruptedException {
- // Open message with both LS capability and as4 capability
- short afi = 16388;
- byte res = 0;
- byte safi = 71;
- peer1.peerChannelHandler.asNumber = 200;
- peer1.peerChannelHandler.version = 4;
- peer1.peerChannelHandler.holdTime = 120;
-
- peer1.peerChannelHandler.isLargeAsCapabilitySet = true;
- bgpControllerImpl.getConfig().setLargeASCapability(true);
- BgpValueType tempTlv = new FourOctetAsNumCapabilityTlv(200);
- peer1.peerChannelHandler.capabilityTlv.add(tempTlv);
-
- bgpControllerImpl.getConfig().setLsCapability(true);
- BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
- peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
- peer1.connect(connectToSocket);
-
- boolean result;
- result = peer1.peerFrameDecoder.receivedOpenMessageLatch.await(
- MESSAGE_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- assertThat(result, is(true));
- }
-
- /**
- * A class to capture the state for a BGP peer.
- */
- private final class BgpPeerTest {
- private ClientBootstrap peerBootstrap;
- private BgpPeerFrameDecoderTest peerFrameDecoder =
- new BgpPeerFrameDecoderTest();
- private BgpPeerChannelHandlerTest peerChannelHandler;
-
- private BgpPeerTest(byte version, short asNumber,
- short holdTime, int bgpId, boolean isLargeAsCapabilitySet,
- LinkedList<BgpValueType> capabilityTlv) {
- peerChannelHandler = new BgpPeerChannelHandlerTest(version,
- asNumber, holdTime, bgpId, isLargeAsCapabilitySet, capabilityTlv);
- }
-
- /**
- * Starts the BGP peer.
- *
- * @param connectToSocket the socket to connect to
- */
- private void connect(InetSocketAddress connectToSocket)
- throws InterruptedException {
-
- ChannelFactory channelFactory =
- new NioClientSocketChannelFactory(
- Executors.newCachedThreadPool(),
- Executors.newCachedThreadPool());
- ChannelPipelineFactory pipelineFactory = () -> {
- ChannelPipeline pipeline = Channels.pipeline();
- pipeline.addLast("BgpPeerFrameDecoderTest",
- peerFrameDecoder);
- pipeline.addLast("BgpPeerChannelHandlerTest",
- peerChannelHandler);
- return pipeline;
- };
-
- peerBootstrap = new ClientBootstrap(channelFactory);
- peerBootstrap.setOption("child.keepAlive", true);
- peerBootstrap.setOption("child.tcpNoDelay", true);
- peerBootstrap.setPipelineFactory(pipelineFactory);
- peerBootstrap.connect(connectToSocket);
- }
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerChannelHandlerTest.java b/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerChannelHandlerTest.java
deleted file mode 100755
index 26ed36d8..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerChannelHandlerTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp;
-
-import java.util.LinkedList;
-import java.util.concurrent.TimeUnit;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.SimpleChannelHandler;
-import org.onosproject.bgpio.protocol.ver4.BgpKeepaliveMsgVer4;
-import org.onosproject.bgpio.protocol.ver4.BgpOpenMsgVer4;
-import org.onosproject.bgpio.types.BgpHeader;
-import org.onosproject.bgpio.types.BgpValueType;
-
-public class BgpPeerChannelHandlerTest extends SimpleChannelHandler {
- public static final int OPEN_MSG_MINIMUM_LENGTH = 29;
- public static final byte[] MARKER = new byte[] {(byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff};
- public static final BgpHeader DEFAULT_OPEN_HEADER = new BgpHeader(MARKER,
- (short) OPEN_MSG_MINIMUM_LENGTH, (byte) 0X01);
- LinkedList<BgpValueType> capabilityTlv = new LinkedList<>();
- public byte version;
- public short asNumber;
- public short holdTime;
- public int bgpId;
- public boolean isLargeAsCapabilitySet;
-
- final BgpOpenMsgVer4 openMessage = new BgpOpenMsgVer4();
- ChannelHandlerContext savedCtx;
-
- /**
- * Constructor to initialize all variables of BGP Open message.
- *
- * @param version BGP version in open message
- * @param asNumber AS number in open message
- * @param holdTime hold time in open message
- * @param bgpId BGP identifier in open message
- * @param capabilityTlv capabilities in open message
- */
- public BgpPeerChannelHandlerTest(byte version,
- short asNumber,
- short holdTime,
- int bgpId,
- boolean isLargeAsCapabilitySet,
- LinkedList<BgpValueType> capabilityTlv) {
- this.version = version;
- this.asNumber = asNumber;
- this.holdTime = holdTime;
- this.bgpId = bgpId;
- this.isLargeAsCapabilitySet = isLargeAsCapabilitySet;
- this.capabilityTlv = capabilityTlv;
- }
-
- /**
- * closes the channel.
- */
- void closeChannel() {
- savedCtx.getChannel().close();
- }
-
- @Override
- public void channelConnected(ChannelHandlerContext ctx,
- ChannelStateEvent channelEvent) throws InterruptedException {
- this.savedCtx = ctx;
-
- BgpOpenMsgVer4 openMsg = new BgpOpenMsgVer4(DEFAULT_OPEN_HEADER,
- this.version,
- this.asNumber,
- this.holdTime,
- this.bgpId,
- this.capabilityTlv);
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- openMsg.writeTo(buffer);
- ctx.getChannel().write(buffer);
-
- TimeUnit.MILLISECONDS.sleep(100);
-
- BgpKeepaliveMsgVer4 keepaliveMsg = new BgpKeepaliveMsgVer4();
- ChannelBuffer buffer1 = ChannelBuffers.dynamicBuffer();
- keepaliveMsg.writeTo(buffer1);
- ctx.getChannel().write(buffer1);
- }
-
- @Override
- public void channelDisconnected(ChannelHandlerContext ctx,
- ChannelStateEvent channelEvent) {
- //Do Nothing
- }
-}
diff --git a/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerFrameDecoderTest.java b/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerFrameDecoderTest.java
deleted file mode 100755
index 7767053f..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerFrameDecoderTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * Class to decode the message received.
- */
-public class BgpPeerFrameDecoderTest extends FrameDecoder {
- static final byte OPEN_MSG_TYPE = 0x1;
- static final byte KEEPALIVE_MSG_TYPE = 0x4;
- static final byte UPDATE_MSG_TYPE = 0x2;
- static final byte NOTIFICATION_MSG_TYPE = 0x3;
- static final int MINIMUM_COMMON_HEADER_LENGTH = 19;
- static final int MINIMUM_OPEN_MSG_LENGTH = 29;
- static final int MINIMUM_HEADER_MARKER_LENGTH = 16;
- static final int HEADER_AND_MSG_LEN = 18;
-
- protected static final Logger log = LoggerFactory
- .getLogger(BgpPeerFrameDecoderTest.class);
- final CountDownLatch receivedOpenMessageLatch = new CountDownLatch(1);
- final CountDownLatch receivedKeepaliveMessageLatch = new CountDownLatch(1);
- final CountDownLatch receivedNotificationMessageLatch = new CountDownLatch(1);
-
- @Override
- protected Object decode(ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer cb) throws Exception {
-
- if (cb.readableBytes() < MINIMUM_COMMON_HEADER_LENGTH) {
- log.debug("Error: Packet length is less then minimum length");
- return null;
- }
-
- byte[] marker = new byte[MINIMUM_HEADER_MARKER_LENGTH];
- cb.readBytes(marker);
- for (int i = 0; i < marker.length; i++) {
- if (marker[i] != (byte) 0xff) {
- log.debug("Error: Marker must be set all ones");
- ctx.getChannel().close();
- return null;
- }
- }
-
- short length = cb.readShort();
- if (length < MINIMUM_COMMON_HEADER_LENGTH) {
- log.debug("Error: Bad message length");
- ctx.getChannel().close();
- return null;
- }
-
- if (length != (cb.readableBytes() + HEADER_AND_MSG_LEN)) {
- log.debug("Error: Bad message length");
- ctx.getChannel().close();
- return null;
- }
-
- byte type = cb.readByte();
- int len = length - MINIMUM_COMMON_HEADER_LENGTH;
-
- ChannelBuffer message = cb.readBytes(len);
-
- switch (type) {
- case OPEN_MSG_TYPE:
- processBgpOpen(ctx, message);
- break;
- case UPDATE_MSG_TYPE:
- break;
- case NOTIFICATION_MSG_TYPE:
- processBgpNotification(ctx, message);
- break;
- case KEEPALIVE_MSG_TYPE:
- processBgpKeepalive(ctx, message);
- break;
- default:
- ctx.getChannel().close();
- return null;
- }
-
- return null;
- }
-
- /**
- * Processes BGP open message.
- *
- * @param ctx Channel handler context
- * @param message open message
- */
- private void processBgpOpen(ChannelHandlerContext ctx,
- ChannelBuffer message) {
- int minLength =
- MINIMUM_OPEN_MSG_LENGTH - MINIMUM_COMMON_HEADER_LENGTH;
- if (message.readableBytes() < minLength) {
- log.debug("Error: Bad message length");
- ctx.getChannel().close();
- return;
- }
-
- message.readByte(); // read version
- message.readShort(); // read AS number
- message.readShort(); // read Hold timer
- message.readInt(); // read BGP Identifier
- // Optional Parameters
- int optParamLen = message.readUnsignedByte();
- if (message.readableBytes() < optParamLen) {
- log.debug("Error: Bad message length");
- ctx.getChannel().close();
- return;
- }
- message.readBytes(optParamLen);
-
- // Open message received
- receivedOpenMessageLatch.countDown();
- }
-
- /**
- * Processes BGP keepalive message.
- *
- * @param ctx Channel handler context
- * @param message keepalive message
- */
- private void processBgpKeepalive(ChannelHandlerContext ctx,
- ChannelBuffer message) {
-
- // Keepalive message received
- receivedKeepaliveMessageLatch.countDown();
- }
-
- /**
- * Processes BGP notification message.
- *
- * @param ctx Channel handler context
- * @param message notification message
- */
- private void processBgpNotification(ChannelHandlerContext ctx,
- ChannelBuffer message) {
- byte[] data;
- message.readByte(); //read error code
- message.readByte(); // read error sub code
- if (message.readableBytes() > 0) {
- data = new byte[message.readableBytes()];
- message.readBytes(data, 0, message.readableBytes());
- }
-
- // Notification message received
- receivedNotificationMessageLatch.countDown();
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/controller/impl/BgpSelectionAlgoTest.java b/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/controller/impl/BgpSelectionAlgoTest.java
deleted file mode 100644
index 7c0fa417..00000000
--- a/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/controller/impl/BgpSelectionAlgoTest.java
+++ /dev/null
@@ -1,595 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.controller.impl;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType;
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib;
-import org.onosproject.bgpio.types.AsPath;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.LocalPref;
-import org.onosproject.bgpio.types.Med;
-import org.onosproject.bgpio.types.Origin;
-import org.onosproject.bgp.controller.impl.BgpSelectionAlgo;
-
-/**
- * Test cases for BGP Selection Algorithm.
- */
-public class BgpSelectionAlgoTest {
-
- /**
- * firstPathAttribute and secondPathAttribute has same AS count and firstPathAttribute
- * has shortest Origin value than secondPathAttribute.
- */
- @Test
- public void selectionAlgoTest1() throws BgpParseException {
- byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
- LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
- BgpValueType pathAttribute1;
- //origin with IGP
- byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute1 = Origin.read(buffer);
- pathAttributes1.add(pathAttribute1);
- //AsPath with AS_SEQ with one AS
- byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xea };
- buffer.writeBytes(asPath);
- pathAttribute1 = AsPath.read(buffer);
- pathAttributes1.add(pathAttribute1);
-
- IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- int bgpId = 168427777;
- short locRIBASNum = 100;
- boolean isIbgp = false;
- PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
- attrList1.setIdentifier(0);
- attrList1.setPathAttribute(pathAttributes1);
- attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
- PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList1);
-
- peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
- LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
- BgpValueType pathAttribute2;
- //origin with INCOMPLETE
- origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
- buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute2 = Origin.read(buffer);
- pathAttributes2.add(pathAttribute2);
- //AsPath with AS_SEQ with one AS
- asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute2 = AsPath.read(buffer);
- pathAttributes2.add(pathAttribute2);
-
- ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- bgpId = 536936448;
- locRIBASNum = 200;
- isIbgp = true;
- PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
- attrList2.setIdentifier(0);
- attrList2.setPathAttribute(pathAttributes2);
- attrList2.setProtocolID(ProtocolType.OSPF_V2);
- PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList2);
- BgpSelectionAlgo algo = new BgpSelectionAlgo();
- int result = algo.compare(list1, list2);
- assertThat(result, is(1));
- }
-
- /**
- * firstPathAttribute has 1 AS count and secondPathAttribute has 2 AS count
- * and firstPathAttribute has shortest Origin value than secondPathAttribute.
- */
- @Test
- public void selectionAlgoTest2() throws BgpParseException {
-
- byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
- LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
- BgpValueType pathAttribute1;
- byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute1 = Origin.read(buffer);
- pathAttributes1.add(pathAttribute1);
- byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute1 = AsPath.read(buffer);
- pathAttributes1.add(pathAttribute1);
-
- IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- int bgpId = 168427777;
- short locRIBASNum = 100;
- boolean isIbgp = false;
- PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
- attrList1.setIdentifier(0);
- attrList1.setPathAttribute(pathAttributes1);
- attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
- PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList1);
-
- peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
- LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
- BgpValueType pathAttribute2;
- origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
- buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute2 = Origin.read(buffer);
- pathAttributes2.add(pathAttribute2);
- asPath = new byte[] {0x40, 0x02, 0x08, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xea, 0x02, 0x01, (byte) 0xfd, (byte) 0xea };
- buffer.writeBytes(asPath);
- pathAttribute2 = AsPath.read(buffer);
- pathAttributes2.add(pathAttribute2);
-
- ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- bgpId = 536936448;
- locRIBASNum = 200;
- isIbgp = true;
- PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
- attrList2.setIdentifier(0);
- attrList2.setPathAttribute(pathAttributes2);
- attrList2.setProtocolID(ProtocolType.OSPF_V2);
- PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList2);
- BgpSelectionAlgo algo = new BgpSelectionAlgo();
- int result = algo.compare(list1, list2);
- assertThat(result, is(-1));
- }
-
- /**
- * firstPathAttribute and secondPathAttribute has same AS value
- * and firstPathAttribute has shortest Origin value than secondPathAttribute.
- */
- @Test
- public void selectionAlgoTest3() throws BgpParseException {
-
- byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
- LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
- BgpValueType pathAttribute1;
- byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute1 = Origin.read(buffer);
- pathAttributes1.add(pathAttribute1);
- byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute1 = AsPath.read(buffer);
- pathAttributes1.add(pathAttribute1);
-
- IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- int bgpId = 168427777;
- short locRIBASNum = 100;
- boolean isIbgp = false;
- PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
- attrList1.setIdentifier(0);
- attrList1.setPathAttribute(pathAttributes1);
- attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
- PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList1);
-
- peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
- LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
- BgpValueType pathAttribute2;
- origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
- buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute2 = Origin.read(buffer);
- pathAttributes2.add(pathAttribute2);
- asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute2 = AsPath.read(buffer);
- pathAttributes2.add(pathAttribute2);
-
- ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- bgpId = 536936448;
- locRIBASNum = 200;
- isIbgp = true;
- PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
- attrList2.setIdentifier(0);
- attrList2.setPathAttribute(pathAttributes2);
- attrList2.setProtocolID(ProtocolType.OSPF_V2);
- PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList2);
- BgpSelectionAlgo algo = new BgpSelectionAlgo();
- int result = algo.compare(list1, list2);
- assertThat(result, is(1));
- }
-
- /**
- * firstPathAttribute has lowest med than secondPathAttribute.
- */
- @Test
- public void selectionAlgoTest4() throws BgpParseException {
-
- byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
- LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
- BgpValueType pathAttribute1;
- byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute1 = Origin.read(buffer);
- pathAttributes1.add(pathAttribute1);
- byte[] med = new byte[] {(byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00,
- 0x00 };
- buffer.writeBytes(med);
- pathAttribute1 = Med.read(buffer);
- pathAttributes1.add(pathAttribute1);
- byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute1 = AsPath.read(buffer);
- pathAttributes1.add(pathAttribute1);
-
- IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- int bgpId = 168427777;
- short locRIBASNum = 100;
- boolean isIbgp = false;
- PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
- attrList1.setIdentifier(0);
- attrList1.setPathAttribute(pathAttributes1);
- attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
- PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList1);
-
- peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
- LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
- BgpValueType pathAttribute2;
- origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
- buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute2 = Origin.read(buffer);
- pathAttributes2.add(pathAttribute2);
- med = new byte[] {(byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x01 };
- buffer.writeBytes(med);
- pathAttribute2 = Med.read(buffer);
- pathAttributes2.add(pathAttribute2);
- asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute2 = AsPath.read(buffer);
- pathAttributes2.add(pathAttribute2);
-
- ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- bgpId = 536936448;
- locRIBASNum = 200;
- isIbgp = true;
- PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
- attrList2.setIdentifier(0);
- attrList2.setPathAttribute(pathAttributes2);
- attrList2.setProtocolID(ProtocolType.OSPF_V2);
- PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList2);
- BgpSelectionAlgo algo = new BgpSelectionAlgo();
- int result = algo.compare(list1, list2);
- assertThat(result, is(1));
- }
-
- /**
- * secondPathAttribute has higher local preference than firstPathAttribute.
- */
- @Test
- public void selectionAlgoTest5() throws BgpParseException {
-
- byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
- LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
- BgpValueType pathAttribute1;
- byte[] locPref = new byte[] {(byte) 0x00, 0x05, 0x04, 0x00, 0x00,
- 0x00, 0x01 };
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(locPref);
- pathAttribute1 = LocalPref.read(buffer);
- pathAttributes1.add(pathAttribute1);
-
- IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- int bgpId = 168427777;
- short locRIBASNum = 100;
- boolean isIbgp = false;
- PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
- attrList1.setIdentifier(0);
- attrList1.setPathAttribute(pathAttributes1);
- attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
- PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList1);
-
- peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
- LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
- BgpValueType pathAttribute2;
- locPref = new byte[] {(byte) 0x00, 0x05, 0x04, 0x00, 0x00, 0x00, 0x0a };
- buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(locPref);
- pathAttribute2 = LocalPref.read(buffer);
- pathAttributes2.add(pathAttribute2);
-
- ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- bgpId = 536936448;
- locRIBASNum = 200;
- isIbgp = true;
- PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
- attrList2.setIdentifier(0);
- attrList2.setPathAttribute(pathAttributes2);
- attrList2.setProtocolID(ProtocolType.OSPF_V2);
- PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList2);
- BgpSelectionAlgo algo = new BgpSelectionAlgo();
- int result = algo.compare(list1, list2);
- assertThat(result, is(-1));
- }
-
- /**
- * secondPathAttribute is EBGP than firstPathAttribute is IBGP.
- */
- @Test
- public void selectionAlgoTest6() throws BgpParseException {
-
- byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
- LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
- BgpValueType pathAttribute1;
- byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute1 = Origin.read(buffer);
- pathAttributes1.add(pathAttribute1);
- byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute1 = AsPath.read(buffer);
- pathAttributes1.add(pathAttribute1);
-
- IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- int bgpId = 168427777;
- short locRIBASNum = 100;
- boolean isIbgp = true;
- PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
- attrList1.setIdentifier(0);
- attrList1.setPathAttribute(pathAttributes1);
- attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
- PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList1);
-
- peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
- LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
- BgpValueType pathAttribute2;
- origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
- buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute2 = Origin.read(buffer);
- pathAttributes2.add(pathAttribute2);
- asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute2 = AsPath.read(buffer);
- pathAttributes2.add(pathAttribute2);
-
- ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- bgpId = 536936448;
- locRIBASNum = 200;
- isIbgp = false;
- PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
- attrList2.setIdentifier(0);
- attrList2.setPathAttribute(pathAttributes2);
- attrList2.setProtocolID(ProtocolType.OSPF_V2);
- PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, false, attrList2);
- BgpSelectionAlgo algo = new BgpSelectionAlgo();
- int result = algo.compare(list1, list2);
- assertThat(result, is(-1));
- }
-
- /**
- * firstPathAttribute has lower BGPID than secondPathAttribute.
- */
- @Test
- public void selectionAlgoTest7() throws BgpParseException {
-
- byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
- LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
- BgpValueType pathAttribute1;
- byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute1 = Origin.read(buffer);
- pathAttributes1.add(pathAttribute1);
- byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute1 = AsPath.read(buffer);
- pathAttributes1.add(pathAttribute1);
-
- IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- //A0A0A00
- Integer bgpId = 168430080;
- short locRIBASNum = 100;
- boolean isIbgp = false;
- PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
- attrList1.setIdentifier(0);
- attrList1.setPathAttribute(pathAttributes1);
- attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
- PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList1);
-
- peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
- LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
- BgpValueType pathAttribute2;
- origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
- buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute2 = Origin.read(buffer);
- pathAttributes2.add(pathAttribute2);
- asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute2 = AsPath.read(buffer);
- pathAttributes2.add(pathAttribute2);
-
- ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- //B0A0A00
- bgpId = 185207296;
- locRIBASNum = 200;
- isIbgp = false;
- PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
- attrList2.setIdentifier(0);
- attrList2.setPathAttribute(pathAttributes2);
- attrList2.setProtocolID(ProtocolType.OSPF_V2);
- PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList2);
- BgpSelectionAlgo algo = new BgpSelectionAlgo();
- int result = algo.compare(list1, list2);
- assertThat(result, is(1));
- }
-
- /**
- * secondPathAttribute has lowest peer address than firstPathAttribute.
- */
- @Test
- public void selectionAlgoTest8() throws BgpParseException {
-
- byte[] peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
- LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
- BgpValueType pathAttribute1;
- byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute1 = Origin.read(buffer);
- pathAttributes1.add(pathAttribute1);
- byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute1 = AsPath.read(buffer);
- pathAttributes1.add(pathAttribute1);
-
- IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- //A0A0A00
- Integer bgpId = 168430080;
- short locRIBASNum = 100;
- boolean isIbgp = false;
- PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
- attrList1.setIdentifier(0);
- attrList1.setPathAttribute(pathAttributes1);
- attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
- PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList1);
-
- peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
- LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
- BgpValueType pathAttribute2;
- origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
- buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute2 = Origin.read(buffer);
- pathAttributes2.add(pathAttribute2);
- asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute2 = AsPath.read(buffer);
- pathAttributes2.add(pathAttribute2);
-
- ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- //A0A0A00
- bgpId = 168430080;
- locRIBASNum = 200;
- isIbgp = false;
- PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
- attrList2.setIdentifier(0);
- attrList2.setPathAttribute(pathAttributes2);
- attrList2.setProtocolID(ProtocolType.OSPF_V2);
- PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList2);
- BgpSelectionAlgo algo = new BgpSelectionAlgo();
- int result = algo.compare(list1, list2);
- assertThat(result, is(-1));
- }
-
- /**
- * firstPathAttribute and secondPathAttribute are same.
- */
- @Test
- public void selectionAlgoTest9() throws BgpParseException {
-
- byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
- LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
- BgpValueType pathAttribute1;
- byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute1 = Origin.read(buffer);
- pathAttributes1.add(pathAttribute1);
- byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute1 = AsPath.read(buffer);
- pathAttributes1.add(pathAttribute1);
-
- IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- //A0A0A00
- Integer bgpId = 168430080;
- short locRIBASNum = 100;
- boolean isIbgp = false;
- PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
- attrList1.setIdentifier(0);
- attrList1.setPathAttribute(pathAttributes1);
- attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
- PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList1);
-
- peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
- LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
- BgpValueType pathAttribute2;
- origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
- buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(origin);
- pathAttribute2 = Origin.read(buffer);
- pathAttributes2.add(pathAttribute2);
- asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
- (byte) 0xe9 };
- buffer.writeBytes(asPath);
- pathAttribute2 = AsPath.read(buffer);
- pathAttributes2.add(pathAttribute2);
-
- ipAddress = IpAddress.valueOf(Version.INET, peerIp);
- //A0A0A00
- bgpId = 168430080;
- locRIBASNum = 200;
- isIbgp = false;
- PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
- attrList2.setIdentifier(0);
- attrList2.setPathAttribute(pathAttributes2);
- attrList2.setProtocolID(ProtocolType.OSPF_V2);
- PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
- ipAddress, bgpId, locRIBASNum, isIbgp, attrList2);
- BgpSelectionAlgo algo = new BgpSelectionAlgo();
- int result = algo.compare(list1, list2);
- assertThat(result, is(0));
- }
-}
diff --git a/framework/src/onos/protocols/bgp/pom.xml b/framework/src/onos/protocols/bgp/pom.xml
deleted file mode 100755
index 64062a66..00000000
--- a/framework/src/onos/protocols/bgp/pom.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-protocols</artifactId>
- <version>1.4.0-rc1</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>onos-bgp</artifactId>
- <packaging>pom</packaging>
-
- <description>ONOS BGP Protocol subsystem</description>
-
- <modules>
- <module>api</module>
- <module>ctl</module>
- <module>bgpio</module>
- </modules>
-
-</project>