Skip to content

Commit dea8dad

Browse files
auehay-higuchi
authored andcommitted
[ONOS-6445] PPPoE Manager (move from onos/apps)
Change-Id: Ica3ebef3b2e0fcda1ae9e899b2870d05523cbb57
1 parent d758630 commit dea8dad

37 files changed

+3062
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<module>patchpanel</module>
5050
<module>ovsdb-rest</module>
5151
<module>group-fwd</module>
52+
<module>pppoe</module>
5253
</modules>
5354

5455
</project>

pppoe/api/pom.xml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2017-present Open Networking Laboratory
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
22+
<parent>
23+
<artifactId>onos-pppoe</artifactId>
24+
<groupId>org.onosproject</groupId>
25+
<version>1.9.0-SNAPSHOT</version>
26+
<relativePath>../pom.xml</relativePath>
27+
</parent>
28+
29+
<artifactId>onos-apps-pppoe-api</artifactId>
30+
31+
<packaging>bundle</packaging>
32+
<description>PPPoE Management API</description>
33+
34+
<dependencies>
35+
</dependencies>
36+
37+
<build>
38+
<plugins>
39+
<plugin>
40+
<groupId>org.apache.felix</groupId>
41+
<artifactId>maven-bundle-plugin</artifactId>
42+
<extensions>true</extensions>
43+
</plugin>
44+
</plugins>
45+
</build>
46+
47+
</project>
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
/*
2+
* Copyright 2017-present Open Networking Laboratory
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the Client.
6+
* You may obtain a copy of the Client at
7+
*
8+
* http://www.apache.org/clients/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the Client is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the Client for the specific language governing permissions and
14+
* limitations under the Client.
15+
*/
16+
17+
package org.onosproject.pppoe.api;
18+
19+
import org.onosproject.net.DeviceId;
20+
21+
import static com.google.common.base.MoreObjects.toStringHelper;
22+
23+
24+
/**
25+
* Implementation of PPPoE client information.
26+
*/
27+
public class PppoeClientInfo implements PppoeDeviceInfo {
28+
29+
private DeviceId deviceId;
30+
private PppoeAdminState adminState;
31+
private String serviceSpecificId;
32+
private short sVlan;
33+
private short cVlan;
34+
private boolean endSession;
35+
private boolean configured;
36+
private String subscriber;
37+
private PppoeSessionInfo session;
38+
private PppoeDeviceType type;
39+
40+
public static enum PppoeAdminState {
41+
ENABLE,
42+
DISABLE
43+
}
44+
45+
/**
46+
* Generates a PPPoE client information instance.
47+
*/
48+
public PppoeClientInfo() {
49+
this.type = PppoeDeviceType.CLIENT;
50+
}
51+
52+
/**
53+
* Generates a PPPoE client information instance.
54+
*
55+
* @param state administrative state
56+
* @param sVlan service provider VLAN
57+
* @param cVlan customer VLAN
58+
*/
59+
public PppoeClientInfo(PppoeAdminState state, short sVlan, short cVlan) {
60+
this.type = PppoeDeviceType.CLIENT;
61+
this.adminState = state;
62+
this.sVlan = sVlan;
63+
this.cVlan = cVlan;
64+
}
65+
66+
/**
67+
* Generates a PPPoE client information instance.
68+
*
69+
* @param state administrative state
70+
*/
71+
public PppoeClientInfo(PppoeAdminState state) {
72+
this.type = PppoeDeviceType.CLIENT;
73+
this.adminState = state;
74+
this.configured = true;
75+
}
76+
77+
@Override
78+
public PppoeDeviceType type() {
79+
return type;
80+
}
81+
82+
@Override
83+
public DeviceId deviceId() {
84+
return deviceId;
85+
}
86+
87+
@Override
88+
public void setDeviceId(DeviceId deviceId) {
89+
this.deviceId = deviceId;
90+
}
91+
92+
/**
93+
* Returns administrative state.
94+
*
95+
* @return administrative state
96+
*/
97+
public PppoeAdminState adminState() {
98+
return adminState;
99+
}
100+
101+
/**
102+
* Sets administrative state.
103+
*
104+
* @param state administrative state
105+
*/
106+
public void setAdminState(PppoeAdminState state) {
107+
this.adminState = state;
108+
}
109+
110+
/**
111+
* Returns service specific ID.
112+
*
113+
* @return service specific ID
114+
*/
115+
public String serviceSpecificId() {
116+
return serviceSpecificId;
117+
}
118+
119+
/**
120+
* Sets service specific ID.
121+
*
122+
* @param ssid service specific ID
123+
*/
124+
public void setServiceSpecificId(String ssid) {
125+
this.serviceSpecificId = ssid;
126+
}
127+
128+
/**
129+
* Returns service provider VLAN.
130+
*
131+
* @return service provider VLAN
132+
*/
133+
public short sVlan() {
134+
return sVlan;
135+
}
136+
137+
/**
138+
* Returns customer VLAN.
139+
*
140+
* @return customer VLAN
141+
*/
142+
public short cVlan() {
143+
return cVlan;
144+
}
145+
146+
/**
147+
* Returns end session flag.
148+
*
149+
* @return end session flag
150+
*/
151+
public boolean endSession() {
152+
return endSession;
153+
}
154+
155+
/**
156+
* Sets end session flag.
157+
*
158+
* @param flag flag to end session
159+
*/
160+
public void setEndSession(boolean flag) {
161+
this.endSession = flag;
162+
}
163+
164+
/**
165+
* Returns configured flag.
166+
*
167+
* @return configured flag
168+
*/
169+
public boolean configured() {
170+
return configured;
171+
}
172+
173+
/**
174+
* Sets configured flag.
175+
*
176+
* @param flag flag for configured
177+
*/
178+
public void setConfigured(boolean flag) {
179+
this.configured = flag;
180+
}
181+
182+
/**
183+
* Sets associated subscriber information.
184+
*
185+
* @param info subscriber information
186+
*/
187+
public void setSubscriber(String info) {
188+
this.subscriber = info;
189+
}
190+
191+
/**
192+
* Clears information from remote.
193+
*/
194+
public void clear() {
195+
this.deviceId = null;
196+
this.sVlan = 0;
197+
this.cVlan = 0;
198+
this.subscriber = null;
199+
}
200+
201+
@Override
202+
public String toString() {
203+
if (deviceId == null) {
204+
return toStringHelper("")
205+
.add("ssid", serviceSpecificId)
206+
.add("adminState", adminState.name().toLowerCase())
207+
.toString();
208+
} else {
209+
return toStringHelper("")
210+
.add("id", deviceId)
211+
.add("ssid", serviceSpecificId)
212+
.add("adminState", adminState.name().toLowerCase())
213+
.add("sVlanId", sVlan)
214+
.add("cVlanId", cVlan)
215+
.add("subscriber", subscriber)
216+
.toString();
217+
}
218+
}
219+
220+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright 2017-present Open Networking Laboratory
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.onosproject.pppoe.api;
18+
19+
import com.fasterxml.jackson.databind.node.ObjectNode;
20+
import org.onosproject.codec.CodecContext;
21+
import org.onosproject.codec.JsonCodec;
22+
23+
import static com.google.common.base.Preconditions.checkNotNull;
24+
import static org.onosproject.pppoe.api.PppoeClientInfo.PppoeAdminState;
25+
26+
27+
/**
28+
* Codec for encoding/decoding a PppoeClientInfo object to/from JSON.
29+
*/
30+
public final class PppoeClientInfoCodec extends JsonCodec<PppoeClientInfo> {
31+
32+
// JSON field names
33+
private static final String ADMIN_STATE = "admin-state";
34+
private static final String END_SESSION = "end-session";
35+
private static final String SVLAN = "s-vlan";
36+
private static final String CVLAN = "c-vlan";
37+
38+
@Override
39+
public ObjectNode encode(PppoeClientInfo info, CodecContext context) {
40+
checkNotNull(info, "PppoeClientInfo cannot be null");
41+
42+
final ObjectNode result = context.mapper().createObjectNode()
43+
.put(ADMIN_STATE, info.adminState().name().toLowerCase())
44+
.put(END_SESSION, info.endSession());
45+
46+
return result;
47+
}
48+
49+
@Override
50+
public PppoeClientInfo decode(ObjectNode json, CodecContext context) {
51+
String state = json.path(ADMIN_STATE).asText();
52+
Integer sVlan = new Integer(json.path(SVLAN).asInt());
53+
Integer cVlan = new Integer(json.path(CVLAN).asInt());
54+
55+
checkNotNull(state);
56+
checkNotNull(sVlan);
57+
checkNotNull(cVlan);
58+
PppoeAdminState adminState = PppoeAdminState.valueOf(state.toUpperCase());
59+
60+
return new PppoeClientInfo(adminState, sVlan.shortValue(), cVlan.shortValue());
61+
}
62+
63+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2017-present Open Networking Laboratory
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.onosproject.pppoe.api;
18+
19+
import org.onosproject.net.DeviceId;
20+
21+
22+
/**
23+
* Implementation of PPPoE device information.
24+
*/
25+
public interface PppoeDeviceInfo {
26+
27+
static enum PppoeDeviceType {
28+
SERVER,
29+
CLIENT,
30+
UNKNOWN
31+
}
32+
33+
/**
34+
* Returns device type.
35+
*
36+
* @return device type
37+
*/
38+
public PppoeDeviceType type();
39+
40+
/**
41+
* Returns device identifier.
42+
*
43+
* @return device identifier
44+
*/
45+
public DeviceId deviceId();
46+
47+
/**
48+
* Sets device identifier.
49+
*
50+
* @param deviceId device identifier
51+
*/
52+
public void setDeviceId(DeviceId deviceId);
53+
54+
}

0 commit comments

Comments
 (0)