blob: eac33173c7d2e4924bfee4f26ccb54faf18da773 [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/*
2 * Copyright 2015-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
17package org.onosproject.xran.impl;
18
19import com.fasterxml.jackson.databind.JsonNode;
slowr13fa5b02017-08-08 16:32:31 -070020import org.onosproject.core.ApplicationId;
slowr13fa5b02017-08-08 16:32:31 -070021import org.onosproject.net.config.Config;
22import org.onosproject.xran.codecs.api.ECGI;
23import org.onosproject.xran.codecs.api.EUTRANCellIdentifier;
24import org.onosproject.xran.codecs.api.PLMNIdentity;
slowr60d4d102017-08-16 18:33:58 -070025import org.onosproject.xran.codecs.util.HexConverter;
slowr13fa5b02017-08-08 16:32:31 -070026import org.slf4j.Logger;
27import org.slf4j.LoggerFactory;
28
29import javax.xml.bind.DatatypeConverter;
30import java.io.ByteArrayInputStream;
31import java.io.IOException;
32import java.io.InputStream;
slowr13fa5b02017-08-08 16:32:31 -070033import java.util.Map;
34import java.util.concurrent.ConcurrentHashMap;
35
slowr13fa5b02017-08-08 16:32:31 -070036public class XranConfig extends Config<ApplicationId> {
37
38 private static final String CELLS = "active_cells";
39
40 private static final String PLMN_ID = "plmn_id";
slowrd337c932017-08-18 13:54:02 -070041
slowr13fa5b02017-08-08 16:32:31 -070042 private static final String ECI_ID = "eci";
43
44 private static final String IP_ADDR = "ip_addr";
45
46 private static final String XRANC_PORT = "xranc_port";
47
48 private static final String XRANC_CELLCONFIG_INTERVAL = "xranc_cellconfigrequest_interval_seconds";
49
slowrd337c932017-08-18 13:54:02 -070050 private static final String RX_SIGNAL_MEAS_REPORT_INTERVAL = "rx_signal_meas_report_interval_ms";
slowr13fa5b02017-08-08 16:32:31 -070051
52 private static final String L2_MEAS_REPORT_INTERVAL = "l2_meas_report_interval_ms";
53
slowr8ddc2b12017-08-14 14:13:38 -070054 private static final String ADMISSION_SUCCESS = "admission_success";
55
56 private static final String BEARER_SUCCESS = "bearer_success";
57
slowrd337c932017-08-18 13:54:02 -070058 private static final String NO_MEAS_LINK_REMOVAL = "no_meas_link_removal_ms";
59
60 private static final String IDLE_UE_REMOVAL = "idle_ue_removal_ms";
61
62 private static final String NORTHBOUND_TIMEOUT = "nb_response_timeout_ms";
63
slowr13fa5b02017-08-08 16:32:31 -070064 private final Logger log = LoggerFactory.getLogger(getClass());
65
66 public Map<String, ECGI> activeCellSet() {
67 Map<String, ECGI> cells = new ConcurrentHashMap<>();
68
69 JsonNode cellsNode = object.get(CELLS);
70 if (cellsNode == null) {
71 log.warn("no cells have been provided!");
72 return cells;
73 }
74
75 cellsNode.forEach(cellNode -> {
76 String plmn_id = cellNode.get(PLMN_ID).asText();
77 String eci = cellNode.get(ECI_ID).asText();
78
79 String ipAddress = cellNode.get(IP_ADDR).asText();
80
81 ECGI ecgi = hexToECGI(plmn_id, eci);
82 cells.put(ipAddress, ecgi);
83 });
84
85 return cells;
86 }
87
slowr8ddc2b12017-08-14 14:13:38 -070088 public boolean admissionFlag() {
89 JsonNode flag = object.get(ADMISSION_SUCCESS);
90 return flag != null && flag.asBoolean();
91 }
92
93 public boolean bearerFlag() {
94 JsonNode flag = object.get(BEARER_SUCCESS);
95 return flag != null && flag.asBoolean();
96 }
97
slowr13fa5b02017-08-08 16:32:31 -070098 public int getXrancPort() {
99 return object.get(XRANC_PORT).asInt();
100 }
101
102 public int getConfigRequestInterval() {
103 return object.get(XRANC_CELLCONFIG_INTERVAL).asInt();
104 }
105
106 public int getRxSignalInterval() {
107 return object.get(RX_SIGNAL_MEAS_REPORT_INTERVAL).asInt();
108 }
109
110 public int getL2MeasInterval() {
111 return object.get(L2_MEAS_REPORT_INTERVAL).asInt();
112 }
113
slowrd337c932017-08-18 13:54:02 -0700114 public int getNoMeasLinkRemoval() {
115 return object.get(NO_MEAS_LINK_REMOVAL).asInt();
116 }
117
118 public int getIdleUeRemoval() {
119 return object.get(IDLE_UE_REMOVAL).asInt();
120 }
121
122 public int getNorthBoundTimeout() {
123 return object.get(NORTHBOUND_TIMEOUT).asInt();
124 }
slowr13fa5b02017-08-08 16:32:31 -0700125
126 private ECGI hexToECGI(String plmn_id, String eci) {
127 byte[] bytes = HexConverter.fromShortHexString(plmn_id);
128 byte[] bytearray = DatatypeConverter.parseHexBinary(eci);
129
130 InputStream inputStream = new ByteArrayInputStream(bytearray);
131
132 PLMNIdentity plmnIdentity = new PLMNIdentity(bytes);
133 EUTRANCellIdentifier eutranCellIdentifier = new EUTRANCellIdentifier(bytearray, 28);
134
135 ECGI ecgi = new ECGI();
136 ecgi.setEUTRANcellIdentifier(eutranCellIdentifier);
137 ecgi.setPLMNIdentity(plmnIdentity);
138 try {
139 ecgi.decode(inputStream);
140 } catch (IOException e) {
141 e.printStackTrace();
142 }
143
144 return ecgi;
145 }
146}