package org.opendaylight.protocol.bgp.rib.impl.spi;
import java.util.List;
-
-import org.opendaylight.protocol.bgp.parser.BGPParameter;
-import org.opendaylight.protocol.concepts.ASNumber;
-import org.opendaylight.protocol.concepts.IPv4Address;
+import java.util.Optional;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.BgpParameters;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.BgpId;
/**
* DTO for BGP Session preferences, that contains BGP Open message.
*/
public final class BGPSessionPreferences {
- private final ASNumber as;
+ private final AsNumber as;
+
+ private final int hold;
+
+ private final BgpId bgpId;
+
+ private final List<BgpParameters> params;
+
+ private final AsNumber remoteAs;
- private final int hold;
+ private final Optional<byte[]> md5Password;
- private final IPv4Address bgpId;
+ /**
+ * Creates a new DTO for Open message.
+ *
+ * @param as local AS number
+ * @param hold preferred hold timer value, in seconds
+ * @param bgpId local BGP Identifier
+ * @param remoteAs expected remote As Number
+ * @param params list of advertised parameters
+ * @param md5Password - md5password
+ */
+ public BGPSessionPreferences(final AsNumber as, final int hold, final BgpId bgpId, final AsNumber remoteAs,
+ final List<BgpParameters> params, final Optional<byte[]> md5Password) {
+ this.as = as;
+ this.hold = hold;
+ this.bgpId = (bgpId != null) ? new BgpId(bgpId) : null;
+ this.remoteAs = remoteAs;
+ this.params = params;
+ this.md5Password = md5Password;
+ }
- private final List<BGPParameter> params;
+ public BGPSessionPreferences(final AsNumber as, final int hold, final BgpId bgpId, final AsNumber remoteAs,
+ final List<BgpParameters> params) {
+ this(as, hold, bgpId, remoteAs, params, Optional.empty());
+ }
+ /**
+ * Returns my AS number.
+ *
+ * @return AS number
+ */
+ public AsNumber getMyAs() {
+ return this.as;
+ }
- /**
- * Creates a new DTO for Open message.
- *
- * @param prefs BGP Open message
- */
- public BGPSessionPreferences(final ASNumber as, final int hold, final IPv4Address bgpId, final List<BGPParameter> params) {
- this.as = as;
- this.hold = hold;
- this.bgpId = bgpId;
- this.params = params;
- }
+ /**
+ * Returns initial value of HoldTimer.
+ *
+ * @return initial value of HoldTimer
+ */
+ public int getHoldTime() {
+ return this.hold;
+ }
- /**
- * Returns my AS number.
- *
- * @return AS number
- */
- public ASNumber getMyAs() {
- return this.as;
- }
+ /**
+ * Returns my BGP Identifier.
+ *
+ * @return BGP identifier
+ */
+ public BgpId getBgpId() {
+ return this.bgpId;
+ }
- /**
- * Returns initial value of HoldTimer.
- *
- * @return initial value of HoldTimer
- */
- public int getHoldTime() {
- return this.hold;
- }
+ /**
+ * Returns expected remote AS number.
+ *
+ * @return AS number
+ */
+ public AsNumber getExpectedRemoteAs() {
+ return this.remoteAs;
+ }
- /**
- * Returns my BGP Identifier.
- *
- * @return BGP identifier
- */
- public IPv4Address getBgpId() {
- return this.bgpId;
- }
+ /**
+ * Gets a list of advertised bgp parameters.
+ *
+ * @return a list of advertised bgp parameters
+ */
+ public List<BgpParameters> getParams() {
+ return this.params;
+ }
- public List<BGPParameter> getParams() {
- return this.params;
- }
+ /**
+ * Optionally returns peer's MD5 password.
+ * @return Encoded MD5 password.
+ */
+ public Optional<byte[]> getMd5Password() {
+ return this.md5Password;
+ }
}