Daniele Moro | 94660a0 | 2019-12-02 12:02:07 -0800 | [diff] [blame] | 1 | /* |
Joey Armstrong | 0964a2c | 2023-01-05 14:26:05 -0500 | [diff] [blame] | 2 | * Copyright 2019-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Daniele Moro | 94660a0 | 2019-12-02 12:02:07 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.opencord.bng; |
| 18 | |
| 19 | import org.onlab.packet.IpAddress; |
| 20 | import org.onlab.packet.MacAddress; |
| 21 | import org.onlab.packet.VlanId; |
| 22 | import org.onosproject.core.ApplicationId; |
| 23 | import org.onosproject.net.ConnectPoint; |
| 24 | import org.onosproject.net.behaviour.BngProgrammable; |
| 25 | |
| 26 | /** |
| 27 | * Contains all the information about an attachment in the PPPoE BNG context. |
| 28 | */ |
| 29 | public 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 | |
Daniele Moro | 94660a0 | 2019-12-02 12:02:07 -0800 | [diff] [blame] | 52 | |
| 53 | @Override |
| 54 | public BngProgrammable.Attachment.AttachmentType type() { |
| 55 | return BngProgrammable.Attachment.AttachmentType.PPPoE; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public short pppoeSessionId() { |
| 60 | return this.pppoeSessionId; |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public String toString() { |
| 65 | return this.toStringHelper() |
| 66 | .add("pppoeSessionId", pppoeSessionId()) |
| 67 | .toString(); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Builder of PPPoE attachments. |
| 72 | */ |
| 73 | public static final class Builder extends BngBuilder { |
| 74 | private short pppoeSessionId = 0; |
| 75 | |
| 76 | private Builder() { |
| 77 | super(); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Sets the PPPoE session ID. |
| 82 | * |
| 83 | * @param pppoeSessionId The PPPoE session ID |
| 84 | * @return self |
| 85 | */ |
| 86 | public Builder withPppoeSessionId(short pppoeSessionId) { |
| 87 | this.pppoeSessionId = pppoeSessionId; |
| 88 | return this; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Returns a new PPPoE attachment. |
| 93 | * |
| 94 | * @return PPPoE attachment |
| 95 | */ |
| 96 | public PppoeBngAttachment build() { |
| 97 | return new PppoeBngAttachment(this.appId, |
| 98 | this.sTag, |
| 99 | this.cTag, |
| 100 | this.macAddress, |
| 101 | this.ipAddress, |
| 102 | this.lineActivated, |
| 103 | this.pppoeSessionId, |
| 104 | this.oltconnectPoint, |
| 105 | this.onuSerial, |
| 106 | this.qinqTpid); |
| 107 | } |
| 108 | } |
| 109 | } |