blob: c4cbe64d972c1c94717a33866724db4efdbfb2b0 [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.net.ConnectPoint;
23
24public final class BngUtils {
25
26 private BngUtils() {
27
28 }
29
30 /**
31 * Extract the BNG attachment key given an event subject.
32 *
33 * @param eventInfo The event subsject
34 * @return BNG attachment ID
35 */
36 public static String calculateBngAttachmentKey(PppoeEventSubject eventInfo) {
37 return calculateBngAttachmentKey(eventInfo.getOnuSerialNumber(),
38 eventInfo.getcTag(), eventInfo.getsTag(),
39 eventInfo.getOltConnectPoint(), eventInfo.getIpAddress(),
40 eventInfo.getMacAddress());
41 }
42
43 /**
44 * Extract the BNG attachment key given some of the attachment fields.
45 *
46 * @param onuSerialNumber Serial number of the ONU
47 * @param cTag VLAN C-Tag
48 * @param sTag VLAN S-Tag
49 * @param oltConnectPoint The OLT-level connect point
50 * @param ipAddress The attachment IP address
51 * @param macAddress The attachment MAC address
52 * @return The built attachment ID
53 */
54 public static String calculateBngAttachmentKey(String onuSerialNumber,
55 VlanId cTag, VlanId sTag,
56 ConnectPoint oltConnectPoint,
57 IpAddress ipAddress,
58 MacAddress macAddress) {
59 return String.join("/", onuSerialNumber, cTag.toString(),
60 sTag.toString(), oltConnectPoint.toString(),
61 macAddress.toString()
62 );
63 }
64}