blob: 7d6c8eda916f206d97fa47eb7ca87ca6f4b47ad2 [file] [log] [blame]
Daniele Moro94660a02019-12-02 12:02:07 -08001/*
2 * Copyright 2019-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.opencord.bng;
18
19import org.onlab.packet.IpAddress;
20import org.onlab.packet.MacAddress;
21import org.onlab.packet.VlanId;
22import org.onosproject.core.ApplicationId;
23import org.onosproject.net.ConnectPoint;
24import org.onosproject.net.behaviour.BngProgrammable;
25
26/**
27 * Contains all the information about an attachment in the PPPoE BNG context.
28 */
29public final class PppoeBngAttachment extends BngAttachment {
30
31 // The PPPoE session ID
32 private final short pppoeSessionId;
33
34 private PppoeBngAttachment(ApplicationId appId, VlanId sTag, VlanId cTag,
35 MacAddress macAddress, IpAddress ipAddress, boolean lineActivated,
36 short pppoeSessionId, ConnectPoint oltConnectPoint, String onuSerial,
37 short qinqTpid) {
38 super(appId, sTag, cTag, macAddress, ipAddress, lineActivated,
39 oltConnectPoint, onuSerial, qinqTpid);
40 this.pppoeSessionId = pppoeSessionId;
41 }
42
43 /**
44 * Returns a builder for PPPoE BNG Attachemnt.
45 *
46 * @return The builder
47 */
48 public static Builder builder() {
49 return new Builder();
50 }
51
52 // TODO: remove when BngProgrammable API are updated!
53 @Override
54 public BngProgrammable.AttachmentId attachmentId() {
55 return null;
56 }
57
58 @Override
59 public BngProgrammable.Attachment.AttachmentType type() {
60 return BngProgrammable.Attachment.AttachmentType.PPPoE;
61 }
62
63 @Override
64 public short pppoeSessionId() {
65 return this.pppoeSessionId;
66 }
67
68 @Override
69 public String toString() {
70 return this.toStringHelper()
71 .add("pppoeSessionId", pppoeSessionId())
72 .toString();
73 }
74
75 /**
76 * Builder of PPPoE attachments.
77 */
78 public static final class Builder extends BngBuilder {
79 private short pppoeSessionId = 0;
80
81 private Builder() {
82 super();
83 }
84
85 /**
86 * Sets the PPPoE session ID.
87 *
88 * @param pppoeSessionId The PPPoE session ID
89 * @return self
90 */
91 public Builder withPppoeSessionId(short pppoeSessionId) {
92 this.pppoeSessionId = pppoeSessionId;
93 return this;
94 }
95
96 /**
97 * Returns a new PPPoE attachment.
98 *
99 * @return PPPoE attachment
100 */
101 public PppoeBngAttachment build() {
102 return new PppoeBngAttachment(this.appId,
103 this.sTag,
104 this.cTag,
105 this.macAddress,
106 this.ipAddress,
107 this.lineActivated,
108 this.pppoeSessionId,
109 this.oltconnectPoint,
110 this.onuSerial,
111 this.qinqTpid);
112 }
113 }
114}