Updated license
[anna.git] / source / diameter / app / dcca / Message.cpp
1 // ANNA - Anna is Not Nothingness Anymore
2 //
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
4 //
5 // https://bitbucket.org/testillano/anna
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
10 //
11 //     * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 //     * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
16 // distribution.
17 //     * Neither the name of Google Inc. nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
33 // Authors: eduardo.ramos.testillano@gmail.com
34 //          cisco.tierra@gmail.com
35
36
37 // Local
38 #include <anna/diameter/app/dcca/Message.hpp>
39
40
41 using namespace anna::diameter::app::dcca;
42
43
44 const qosProfile_t & Message::decode3GPPGPRSNegQoSProfile() throw(anna::RuntimeException) {
45   const std::string & utf8 = get3GPPGPRSNegQoSProfile()->getValue();
46   a_qosProfile.reset();
47   return a_qosProfile;
48 }
49
50
51 //
52 //
53 //      5 - 3GPP-GPRS Negotiated QoS profile
54 //
55 //          Bits
56 //      Octets    8  7  6  5  4  3  2  1
57 //      1      3GPP type = 5
58 //      2      3GPP Length= L
59 //      3 - L     UTF-8 encoded QoS profile
60 //
61 //      3GPP Type: 5
62 //      Length: For GGSN, L ? 37 (release 7 or higher) or L ? 33 (release 6 or release 5) or L ? 27 (release 4 or release 99) or L = 11 (release 98). For P-GW, the length varies depending on the value of QCI. See below for details.
63 //      QoS profile value: Text type
64 //      UTF-8 encoded QoS profile syntax:
65 //      "<Release indicator> \96 <release specific QoS IE UTF-8 encoding>"
66 //      <Release indicator> = UTF-8 encoded number (two characters) :
67 //       For GGSN:
68 //      "98" = Release 98
69 //      "99"= Release 99 or release 4
70 //      "05"= Release 5 or release 6
71 //      "07"= Release 7 or higher
72 //      For P-GW:
73 //      "08"= Release 8 or higher
74 //         <release specific QoS profile UTF-8 encoding> = UTF-8 encoded QoS profile for the release indicated by          the release indicator.
75 //       The UTF-8 encoding of a QoS IE is defined as follows: each octet is described by 2 UTF-8 encoded characters, defining its hexadecimal representation.
76 //       For GGSN:
77 //       The QoS profile definition is in 3GPP TS 24.008 [54].
78 //          The release 98 QoS profile data is 3 octets long, which then results in a 6 octets UTF-8 encoded string.
79 //          The release 99 and release 4 QoS profile data is 11 octets long, which results in a 22 octets UTF-8 encoded string.
80 //       The release 5 and release 6 QoS profile data is 14 octets long, which results in a 28 octets UTF-8 encoded string.
81 //       The release 7 (and higher) QoS profile data is 16 octets long, which results in a 32 octets UTF-8 encoded string.
82 //      For P-GW:
83 //       It contains the following QoS parameters associated with the EPS bearer:
84 //      -   QCI
85 //      -   ARP
86 //      -   GBR QoS information (UL/DL MBR, UL/DL GBR) or UL/DL APN-AMBR. In other words if the value of QCI indicates a GBR bearer, the GBR QoS information shall be present. If the value of QCI indicates a non-GBR bearer, the APN-AMBR information shall be present.
87 //      The encoding of the EPS bearer QoS profile parameters is specified in 3GPP TS 29.274 [81]: ARP is specified in Bearer QoS IE; QCI, UL MBR, DL MBR, UL MBR and DL MBR are specified in Flow QoS IE; UL APN-AMBR and DL APN-AMBR are specified in AMBR IE.
88 //      For GBR QCIs, the encoding of UTF-8 encoded QoS Profile field shall be as follows:
89 //
90 //      1-3    <Release indicator> -" = "08-" (UTF-8 encoded)
91 //      4-5    ARP (UTF-8 encoded)
92 //      6-7    QCI (UTF-8 encoded)
93 //      8-m    UL MBR (UTF-8 encoded)
94 //      (m+1)-n      DL MBR (UTF-8 encoded)
95 //      (n+1)-o      UL GBR (UTF-8 encoded)
96 //      (o+1)-p      DL GBR (UTF-8 encoded)
97 //
98 //      For non-GBR QCIs, the UL/DL MBR and UL/DL GBR fields shall not be present; UL APN-AMBR and DL APN-AMBR fields shall be encoded (in UTF-8 encoded format) respectively after the QCI field.
99 //
100 //
101 //
102 //
103 //      // Obtiene los parametros trafficClass y handlingPriority a partir de la cadena de entrada(proviene del AVP de la peticion) y según la release
104 //      std::string analisisQoS::obtenerParamQoS(const char * GPRS_Neg_QoS_Profile)
105 //      {
106 //        TRACEAR_OPERACION (TrazarMetodoEx("analisisQoS","obtenerParamQoS",  FILE_LOCATION));
107 //
108 //        // Nos llega una cadena de caracteres
109 //        // Los dos primeros octetos son la release y el tercer octeto es un '-' ,
110 //        // el resto de octetos dependen de la release, se describen segun el caso
111 //        // RELEASE 99
112 //        char str_release[2];
113 //        strncpy( str_release,GPRS_Neg_QoS_Profile,2);
114 //        //qosProfile será el resto de la cadena ( a partir del guión)
115 //        char qosProfile[MAX_CADENA_QOS+1]="";
116 //        char cadena[MAX_CADENA_QOS+1]="";
117 //        // convierte el formato UTF8 a string,
118 //        strncpy(cadena,GPRS_Neg_QoS_Profile,MAX_CADENA_QOS+1);
119 //
120 //        // RELEASE_99;
121 //
122 //          if (cadena [0] =='9' && cadena [1]=='9')
123 //          {
124 //      10.5.6.5  Quality of service
125 //      The purpose of the quality of service information element is to specify the QoS parameters for a PDP context.
126 //      The QoS IE is defined to allow backward compatibility to earlier version of Session Management Protocol.
127 //      The quality of service is a type 4 information element with a minimum length of 14 octets and a maximum length of 18 octets. The QoS requested by the MS shall be encoded both in the QoS attributes specified in octets 3-5 and in the QoS attributes specified in octets 6-14.
128 //      In the MS to network direction and in the network to MS direction the following applies:
129 //      -   Octets 15-18 are optional. If octet 15 is included, then octet 16 shall also be included, and octets 17 and 18 may be included.
130 //      -   If octet 17 is included, then octet 18 shall also be included.
131 //      -   A QoS IE received without octets 6-18, without octets 14-18, without octets 15-18, or without octets 17-18 shall be accepted by the receiving entity.
132 //      NOTE:  This behavior is required for interworking with entities supporting an earlier version of the protocol, or when the Maximum bit rate for downlink or for downlink and uplink is negotiated to a value lower than 8700 kbps.
133 //      The quality of service information element is coded as shown in figure 10.5.138/3GPP TS 24.008 and table 10.5.156/3GPP TS 24.008.
134 //
135 //      Figure 10.5.138/3GPP TS 24.008: Quality of service information element
136 //            //          8           7           6           5           4           3           2           1
137 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
138 //            //    +                                   Quality of service IEI                                      +  Octet 1
139 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
140 //            //    +                               Length of quality of service IE                                 +  Octet 2
141 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
142 //            //    |         spare(00)     +          Delay class              +     Reliability class             +  Octet 3
143 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
144 //            //    +              Peak throughput                  +   spare   +    Precedence class               +  Octet 4
145 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
146 //            //    +             spare(000)            +                  Mean throughput                          +  Octet 5
147 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
148 //            //    +          Traffic class            +     Delivery order    +     Delivery of erroneus SDU      +  Octet 6 <---
149 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
150 //            //    +                                       Maximum SDU size                                        +  Octet 7
151 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
152 //            //    +                                  Maximum bit rate for uplink                                  +  Octet 8
153 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
154 //            //    +                                 Maximum bit rate for downlink                                 +  Octet 9
155 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
156 //            //    +                  Residual BER                 +               SDU error ratio                 +  Octet 10
157 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
158 //            //    +                      Transfer delay                                   +    Traffic Handling   +  Octet 11 <--
159 //            //    +                                                                       +        priority       +
160 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
161 //            //    +                                 Guaranteed bit rate for uplink                                +  Octet 12
162 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
163 //            //    +                                Guaranteed bit rate for downlink                               +  Octet 13
164 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
165 //            //    +             spare(000)            +Signalling +             Source Statistics Descriptor      +  Octet 14
166 //            //    +                                   +Indication +                                               +
167 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
168 //            //    +                             Maximum bit rate for downlink (extended)                          +  Octet 15
169 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
170 //            //    +                            Guaranteed bit rate for downlink (extended)                        +  Octet 16
171 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
172 //            //    +                              Maximum bit rate for uplink (extended)                           +  Octet 17
173 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
174 //            //    +                             Guaranteed bit rate for uplink (extended)                          +  Octet 18
175 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
176 //
177 //      Reliability class, octet 3 (see 3GPP TS 23.107 [81])
178 //      Bits
179 //      3 2 1
180 //      In MS to network direction:
181 //      0 0 0  Subscribed reliability class
182 //      In network to MS direction:
183 //      0 0 0  Reserved
184 //      In MS to network direction and in network to MS direction:
185 //      0 0 1  Unused. If received, it shall be interpreted as '010' (Note)
186 //      0 1 0  Unacknowledged GTP; Acknowledged LLC and RLC, Protected data
187 //      0 1 1  Unacknowledged GTP and LLC; Acknowledged RLC, Protected data
188 //      1 0 0  Unacknowledged GTP, LLC, and RLC, Protected data
189 //      1 0 1  Unacknowledged GTP, LLC, and RLC, Unprotected data
190 //      1 1 1  Reserved
191 //
192 //      All other values are interpreted as Unacknowledged GTP and LLC; Acknowledged RLC, Protected data in this version of the protocol.
193 //
194 //      If network supports EPS, then it should not assign Reliability class value \91010\92.
195 //
196 //      NOTE: this value was allocated in earlier versions of the protocol.
197 //
198 //      Delay class, octet 3 (see 3GPP TS 22.060 [73] and 3GPP TS 23.107 [81])
199 //      Bits
200 //      6 5 4
201 //      In MS to network direction:
202 //      0 0 0  Subscribed delay class
203 //      In network to MS direction:
204 //      0 0 0  Reserved
205 //      In MS to network direction and in network to MS direction:
206 //      0 0 1  Delay class 1
207 //      0 1 0  Delay class 2
208 //      0 1 1  Delay class 3
209 //      1 0 0  Delay class 4 (best effort)
210 //      1 1 1  Reserved
211 //
212 //
213 //
214 //      All other values are interpreted as Delay class 4 (best effort) in this version
215 //      of the protocol.
216 //      Bit 7 and 8 of octet 3 are spare and shall be coded all 0.
217 //      Precedence class, octet 4 (see 3GPP TS 23.107 [81])
218 //      Bits
219 //      3 2 1
220 //      In MS to network direction:
221 //      0 0 0  Subscribed precedence
222 //      In network to MS direction:
223 //      0 0 0  Reserved
224 //      In MS to network direction and in network to MS direction:
225 //      0 0 1  High priority
226 //      0 1 0  Normal priority
227 //      0 1 1  Low priority
228 //      1 1 1  Reserved
229 //
230 //
231 //      All other values are interpreted as Normal priority in this version of the protocol.
232 //
233 //      Bit 4 of octet 4 is spare and shall be coded as 0.
234 //
235 //      Peak throughput, octet 4 (see 3GPP TS 23.107 [81])
236 //      This field is the binary representation of the Peak Throughput Class (1 to 9). The corresponding peak throughput to each peak throughput class is indicated.
237 //      Bits
238 //      8 7 6 5
239 //      In MS to network direction:
240 //      0 0 0 0      Subscribed peak throughput
241 //      In network to MS direction:
242 //      0 0 0 0      Reserved
243 //      In MS to network direction and in network to MS direction:
244 //      0 0 0 1      Up to 1 000 octet/s
245 //      0 0 1 0      Up to 2 000 octet/s
246 //      0 0 1 1      Up to 4 000 octet/s
247 //      0 1 0 0      Up to 8 000 octet/s
248 //      0 1 0 1      Up to 16 000 octet/s
249 //      0 1 1 0      Up to 32 000 octet/s
250 //      0 1 1 1      Up to 64 000 octet/s
251 //      1 0 0 0      Up to 128 000 octet/s
252 //      1 0 0 1      Up to 256 000 octet/s
253 //      1 1 1 1      Reserved
254 //
255 //      All other values are interpreted as Up to 1 000 octet/s in this
256 //      version of the protocol.
257 //      Mean throughput, octet 5 (see 3GPP TS 23.107 [81])
258 //      This field is the binary representation of the Mean Throughput Class (1 to 18; mean throughput class 30 is reserved and 31 is best effort). The corresponding mean throughput to each mean throughput class is indicated.
259 //      Bits
260 //      5 4 3 2 1
261 //
262 //
263 //
264 //      In MS to network direction:
265 //      0 0 0 0 0    Subscribed mean throughput
266 //      In network to MS direction:
267 //      0 0 0 0 0    Reserved
268 //      In MS to network direction and in network to MS direction:
269 //      0 0 0 0 1    100 octet/h
270 //      0 0 0 1 0    200 octet/h
271 //      0 0 0 1 1    500 octet/h
272 //      0 0 1 0 0    1 000 octet/h
273 //      0 0 1 0 1    2 000 octet/h
274 //      0 0 1 1 0    5 000 octet/h
275 //      0 0 1 1 1    10 000 octet/h
276 //      0 1 0 0 0    20 000 octet/h
277 //      0 1 0 0 1    50 000 octet/h
278 //      0 1 0 1 0    100 000 octet/h
279 //      0 1 0 1 1    200 000 octet/h
280 //      0 1 1 0 0    500 000 octet/h
281 //      0 1 1 0 1    1 000 000 octet/h
282 //      0 1 1 1 0    2 000 000 octet/h
283 //      0 1 1 1 1    5 000 000 octet/h
284 //      1 0 0 0 0    10 000 000 octet/h
285 //      1 0 0 0 1    20 000 000 octet/h
286 //      1 0 0 1 0    50 000 000 octet/h
287 //      1 1 1 1 0    Reserved
288 //      1 1 1 1 1    Best effort
289 //      The value Best effort indicates that throughput shall be made available to the MS on a per need and availability basis.
290 //      All other values are interpreted as Best effort in this
291 //      version of the protocol.
292 //
293 //      Bits 8 to 6 of octet 5 are spare and shall be coded all 0.
294 //
295 //
296 //      Delivery of erroneous SDUs, octet 6 (see 3GPP TS 23.107 [81])
297 //      Bits
298 //      3 2 1
299 //      In MS to network direction:
300 //      0 0 0     Subscribed delivery of erroneous SDUs
301 //      In network to MS direction:
302 //      0 0 0     Reserved
303 //      In MS to network direction and in network to MS direction:
304 //      0 0 1     No detect ('-')
305 //      0 1 0     Erroneous SDUs are delivered ('yes')
306 //      0 1 1     Erroneous SDUs are not delivered ('no')
307 //      1 1 1     Reserved
308 //
309 //
310 //      The network shall map all other values not explicitly defined onto one of the values defined in this version of the protocol. The network shall return a negotiated value which is explicitly defined in this version of this protocol.
311 //
312 //      The MS shall consider all other values as reserved.
313 //
314 //      Delivery order, octet 6 (see 3GPP TS 23.107 [81])
315 //      Bits
316 //      5 4 3
317 //      In MS to network direction:
318 //      0 0    Subscribed delivery order
319 //      In network to MS direction:
320 //      0 0    Reserved
321 //      In MS to network direction and in network to MS direction:
322 //      0 1    With delivery order ('yes')
323 //      1 0    Without delivery order ('no')
324 //      1 1    Reserved
325 //
326 //
327 //
328 //
329 //      Traffic class, octet 6 (see 3GPP TS 23.107 [81])
330 //      Bits
331 //      8 7 6
332 //      In MS to network direction:
333 //      0 0 0     Subscribed traffic class
334 //      In network to MS direction:
335 //      0 0 0     Reserved
336 //      In MS to network direction and in network to MS direction:
337 //      0 0 1     Conversational class
338 //      0 1 0     Streaming class
339 //      0 1 1     Interactive class
340 //      1 0 0     Background class
341 //      1 1 1     Reserved
342 //
343 //      The network shall map all other values not explicitly defined onto one of the values defined in this version of the protocol. The network shall return a negotiated value which is explicitly defined in this version of this protocol.
344 //
345 //
346 //      The MS shall consider all other values as reserved.
347 //
348 //      Maximum SDU size, octet 7 (see 3GPP TS 23.107 [81])
349 //      In MS to network direction:
350 //      0 0 0 0 0 0 0 0    Subscribed maximum SDU size
351 //      1 1 1 1 1 1 1 1    Reserved
352 //      In network to MS direction:
353 //      0 0 0 0 0 0 0 0    Reserved
354 //      1 1 1 1 1 1 1 1    Reserved
355 //      In MS to network direction and in network to MS direction:
356 //
357 //      For values in the range 00000001 to 10010110 the Maximum SDU size value is binary coded in 8 bits, using a granularity of 10 octets, giving a range of values from 10 octets to 1500 octets.
358 //      Values above 10010110 are as below:
359 //      1 0 0 1 0 1 1 1    1502 octets
360 //      1 0 0 1 1 0 0 0    1510 octets
361 //      1 0 0 1 1 0 0 1    1520 octets
362 //
363 //
364 //      The network shall map all other values not explicitly defined onto one of the values defined in this version of the protocol. The network shall return a negotiated value which is explicitly defined in this version of this protocol.
365 //
366 //      The MS shall consider all other values as reserved.
367 //
368 //
369 //      Maximum bit rate for uplink, octet 8
370 //      Bits
371 //      8 7 6 5 4 3 2 1
372 //      In MS to network direction:
373 //      0 0 0 0 0 0 0 0 Subscribed maximum bit rate for uplink
374 //      In network to MS direction:
375 //      0 0 0 0 0 0 0 0 Reserved
376 //      In MS to network direction and in network to MS direction:
377 //      0 0 0 0 0 0 0 1    The maximum bit rate is binary coded in 8 bits, using a granularity of 1 kbps
378 //      0 0 1 1 1 1 1 1 giving a range of values from 1 kbps to 63 kbps in 1 kbps increments.
379 //
380 //      0 1 0 0 0 0 0 0    The maximum bit rate is 64 kbps + ((the binary coded value in 8 bits \9601000000) * 8 kbps)
381 //      0 1 1 1 1 1 1 1 giving a range of values from 64 kbps to 568 kbps in 8 kbps increments.
382 //
383 //      1 0 0 0 0 0 0 0    The maximum bit rate is 576 kbps + ((the binary coded value in 8 bits \9610000000) * 64 kbps)
384 //      1 1 1 1 1 1 1 0 giving a range of values from 576 kbps to 8640 kbps in 64 kbps increments.
385 //
386 //      1 1 1 1 1 1 1 1 0kbps
387 //
388 //      If the sending entity wants to indicate a Maximum bit rate for uplink higher than 8640 kbps, it shall set octet 8 to \9411111110\94, i.e. 8640 kbps, and shall encode the value for the Maximum bit rate in octet 17.
389 //
390 //
391 //      Maximum bit rate for downlink, octet 9 (see 3GPP TS 23.107 [81])
392 //
393 //      Coding is identical to that of Maximum bit rate for uplink.
394 //
395 //      If the sending entity wants to indicate a Maximum bit rate for downlink higher than 8640 kbps, it shall set octet 9 to \9411111110\94, i.e. 8640 kbps, and shall encode the value for the Maximum bit rate in octet 15.
396 //
397 //      In this version of the protocol, for messages specified in the present document, the sending entity shall not request 0 kbps for both the Maximum bitrate for downlink and the Maximum bitrate for uplink at the same time. Any entity receiving a request for 0 kbps in both the Maximum bitrate for downlink and the Maximum bitrate for uplink shall consider that as a syntactical error (see clause 8).
398 //
399 //
400 //
401 //      Residual Bit Error Rate (BER), octet 10 (see 3GPP TS 23.107 [81])
402 //      Bits
403 //      8 7 6 5
404 //      In MS to network direction:
405 //      0 0 0 0      Subscribed residual BER
406 //      In network to MS direction:
407 //      0 0 0 0      Reserved
408 //      In MS to network direction and in network to MS direction:
409 //      The Residual BER value consists of 4 bits. The range is from 5*10-2 to 6*10-8.
410 //      0 0 0 1      5*10-2
411 //      0 0 1 0      1*10-2
412 //      0 0 1 1      5*10-3
413 //      0 1 0 0      4*10-3
414 //      0 1 0 1      1*10-3
415 //      0 1 1 0      1*10-4
416 //      0 1 1 1      1*10-5
417 //      1 0 0 0      1*10-6
418 //      1 0 0 1      6*10-8
419 //      1 1 1 1      Reserved
420 //
421 //      The network shall map all other values not explicitly defined onto one of the values defined in this version of the protocol. The network shall return a negotiated value which is explicitly defined in this version of the protocol.
422 //
423 //      The MS shall consider all other values as reserved.
424 //
425 //      SDU error ratio, octet 10 (see 3GPP TS 23.107 [81])
426 //      Bits
427 //      4 3 2 1
428 //      In MS to network direction:
429 //      0 0 0 0      Subscribed SDU error ratio
430 //      In network to MS direction:
431 //      0 0 0 0      Reserved
432 //      In MS to network direction and in network to MS direction:
433 //      The SDU error ratio value consists of 4 bits. The range is is from 1*10-1 to 1*10-6.
434 //      0 0 0 1      1*10-2
435 //      0 0 1 0      7*10-3
436 //      0 0 1 1      1*10-3
437 //      0 1 0 0      1*10-4
438 //      0 1 0 1      1*10-5
439 //      0 1 1 0      1*10-6
440 //      0 1 1 1      1*10-1
441 //      1 1 1 1      Reserved
442 //
443 //      The network shall map all other values not explicitly defined onto one of the values defined in this version of the protocol. The network shall return a negotiated value which is explicitly defined in this version of the protocol.
444 //
445 //      The MS shall consider all other values as reserved.
446 //
447 //      Traffic handling priority, octet 11 (see 3GPP TS 23.107 [81])
448 //      Bits
449 //      2 1
450 //      In MS to network direction:
451 //      0 0    Subscribed traffic handling priority
452 //      In network to MS direction:
453 //      0 0    Reserved
454 //      In MS to network direction and in network to MS direction:
455 //      0 1    Priority level 1
456 //      1 0    Priority level 2
457 //      1 1    Priority level 3
458 //
459 //      The Traffic handling priority value is ignored if the Traffic Class is Conversational class, Streaming class or Background class.
460 //
461 //      Transfer delay, octet 11 (See 3GPP TS 23.107 [81])
462 //      Bits
463 //      8 7 6 5 4 3
464 //
465 //
466 //
467 //      In MS to network direction:
468 //      0 0 0 0 0 0     Subscribed transfer delay
469 //      In network to MS direction:
470 //      0 0 0 0 0 0     Reserved
471 //      In MS to network direction and in network to MS direction:
472 //
473 //
474 //      0 0 0 0 0 1  The Transfer delay is binary coded in 6 bits, using a granularity of 10 ms
475 //      0 0 1 1 1 1     giving a range of values from 10 ms to 150 ms in 10 ms increments
476 //
477 //      0 1 0 0 0 0  The transfer delay is 200 ms + ((the binary coded value in 6 bits \96 010000) * 50 ms)
478 //      0 1 1 1 1 1     giving a range of values from 200 ms to 950 ms in 50ms increments
479 //
480 //      1 0 0 0 0 0  The transfer delay is 1000 ms + ((the binary coded value in 6 bits \96 100000) * 100 ms)
481 //      1 1 1 1 1 0     giving a range of values from 1000 ms to 4000 ms in 100ms increments
482 //
483 //      1 1 1 1 1 1     Reserved
484 //
485 //      The Transfer delay value is ignored if the Traffic Class is Interactive class or Background class.
486 //
487 //      Guaranteed bit rate for uplink, octet 12 (See 3GPP TS 23.107 [81])
488 //
489 //      Coding is identical to that of Maximum bit rate for uplink.
490 //
491 //      If the sending entity wants to indicate a Guaranteed bit rate for uplink higher than 8640 kbps, it shall set octet 12 to \9411111110\94, i.e. 8640 kbps, and shall encode the value for the Guaranteed bit rate in octet 18.
492 //
493 //      The Guaranteed bit rate for uplink value is ignored if the Traffic Class is Interactive class or Background class, or Maximum bit rate for uplink is set to 0 kbps.
494 //
495 //      Guaranteed bit rate for downlink, octet 13(See 3GPP TS 23.107 [81])
496 //
497 //      Coding is identical to that of Maximum bit rate for uplink.
498 //
499 //      If the sending entity wants to indicate a Guaranteed bit rate for downlink higher than 8640 kbps, it shall set octet 13 to \9411111110\94, i.e. 8640 kbps, and shall encode the value for the Guaranteed bit rate in octet 16.
500 //
501 //      The Guaranteed bit rate for downlink value is ignored if the Traffic Class is Interactive class or Background class, or Maximum bit rate for downlink is set to 0 kbps.
502 //
503 //      Source Statistics Descriptor, octet 14 (see 3GPP TS 23.107 [81])
504 //      Bits
505 //      4 3 2 1
506 //      In MS to network direction
507 //      0 0 0 0   unknown
508 //      0 0 0 1      speech
509 //
510 //      The network shall consider all other values as unknown.
511 //
512 //      In network to MS direction
513 //      Bits 4 to 1 of octet 14 are spare and shall be coded all 0.
514 //
515 //      The Source Statistics Descriptor value is ignored if the Traffic Class is Interactive class or Background class.
516 //
517 //      Signalling Indication, octet 14 (see 3GPP TS 23.107 [81])
518 //      Bit
519 //      5
520 //      In MS to network direction and in network to MS direction:
521 //      0      Not optimised for signalling traffic
522 //      1      Optimised for signalling traffic
523 //
524 //      If set to '1' the QoS of the PDP context is optimised for signalling
525 //
526 //      The Signalling Indication value is ignored if the Traffic Class is Conversational class, Streaming class or Background class.
527 //
528 //      Bits 8 to 6 of octet 14 are spare and shall be coded all 0.
529 //
530 //      Maximum bit rate for downlink (extended), octet 15
531 //      Bits
532 //      8 7 6 5 4 3 2 1
533 //      In MS to network direction and in network to MS direction:
534 //      0 0 0 0 0 0 0 0 Use the value indicated by the Maximum bit rate for downlink in octet 9.
535 //
536 //                   For all other values: Ignore the value indicated by the Maximum bit rate for downlink in octet 9
537 //                   and use the following value:
538 //      0 0 0 0 0 0 0 1 The maximum bit rate is 8600 kbps + ((the binary coded value in 8 bits) * 100 kbps),
539 //      0 1 0 0 1 0 1 0 giving a range of values from 8700 kbps
540 //      to 16000 kbps in 100 kbps increments.
541 //
542 //      0 1 0 0 1 0 1 1 The maximum bit rate is 16 Mbps + ((the binary coded value in 8 bits - 01001010) * 1 Mbps),
543 //      1 0 1 1 1 0 1 0 giving a range of values from 17 Mbps to 128 Mbps in 1 Mbps increments.
544 //
545 //      1 0 1 1 1 0 1 1 The maximum bit rate is 128 Mbps + ((the binary coded value in 8 bits - 10111010) * 2 Mbps),
546 //      1 1 1 1 1 0 1 0 giving a range of values from 130 Mbps to 256 Mbps in 2 Mbps increments.
547 //
548 //      The network shall map all other values not explicitly defined onto one of the values defined in this version of the protocol. The network shall return a negotiated value which is explicitly defined in this version of the protocol.
549 //
550 //      The MS shall map all other values not explicitly defined onto the maximum value defined in this version of the protocol.
551 //
552 //      Guaranteed bit rate for downlink (extended), octet 16
553 //      Bits
554 //      8 7 6 5 4 3 2 1
555 //      In MS to network direction and in network to MS direction:
556 //      0 0 0 0 0 0 0 0 Use the value indicated by the Guaranteed bit rate for downlink in octet 13.
557 //
558 //                   For all other values: Ignore the value indicated by the Guaranteed bit rate for downlink in octet 9
559 //                   and use the following value:
560 //      0 0 0 0 0 0 0 1 The guaranteed bit rate is 8600 kbps + ((the binary coded value in 8 bits) * 100 kbps),
561 //      0 1 0 0 1 0 1 0 giving a range of values from 8700 kbps to 16000 kbps in 100 kbps increments.
562 //
563 //      0 1 0 0 1 0 1 1 The guaranteed bit rate is 16 Mbps + ((the binary coded value in 8 bits - 01001010) * 1 Mbps),
564 //      1 0 1 1 1 0 1 0 giving a range of values from 17 Mbps to 128 Mbps in 1 Mbps increments.
565 //
566 //      1 0 1 1 1 0 1 1 The guaranteed bit rate is 128 Mbps + ((the binary coded value in 8 bits - 10111010) * 2 Mbps),
567 //      1 1 1 1 1 0 1 0 giving a range of values from 130 Mbps to 256 Mbps in 2 Mbps increments.
568 //
569 //
570 //      The network shall map all other values not explicitly defined onto one of the values defined in this version of the protocol. The network shall return a negotiated value which is explicitly defined in this version of the protocol.
571 //
572 //      The MS shall map all other values not explicitly defined onto the maximum value defined in this version of the protocol.
573 //
574 //      Maximum bit rate for uplink (extended), octet 17
575 //
576 //      This field is an extension of the Maximum bit rate for uplink in octet 8. The coding is identical to that of the Maximum bit rate for downlink (extended).
577 //
578 //      The network shall map all other values not explicitly defined onto one of the values defined in this version of the protocol. The network shall return a negotiated value which is explicitly defined in this version of the protocol.
579 //
580 //      The MS shall map all other values not explicitly defined onto the maximum value defined in this version of the protocol.
581 //
582 //      Guaranteed bit rate for uplink (extended), octet 18
583 //
584 //      This field is an extension of the Guaranteed bit rate for uplink in octet 12. The coding is identical to that of the Guaranteed bit rate for downlink (extended).
585 //
586 //      The network shall map all other values not explicitly defined onto one of the values defined in this version of the protocol. The network shall return a negotiated value which is explicitly defined in this version of the protocol.
587 //
588 //      The MS shall map all other values not explicitly defined onto the maximum value defined in this version of the protocol.
589 //
590 //
591 //            //trafficClass: Octeto 4 , //strtok(cadena,"-");
592 //            //--------------------------------------------------------------------
593 //            a_release = 99;
594 //            char octeto4[3]= "\0";
595 //            // CADENA: caracteres 0,1, release, caracter 2 " - ", car. 3,4: octeto1, 4,5: octeto2....12,13: octeto11
596 //            //octetoi  se obtiene de cadena[2i+1] , cadena[2i+2], dos caracteres en hexadecimal
597 //
598 //            octeto4[0]=cadena[9];
599 //            octeto4[1]=cadena[10];
600 //            octeto4[2]='\0';
601 //            long i_octeto4;
602 //            // pasamos de hexadecimal a decimal
603 //            sscanf(octeto4,"%x",&i_octeto4);
604 //            a_trafficClass = (i_octeto4 & 0xE0)>>5;
605 //            TRACEAR_DEPURACION
606 //       (
607 //        trazaDebInt("Parametro TrafficClass recibido", a_trafficClass);
608 //        );
609 //            //trafficHandlingPriority : octeto 9, bits 1,2
610 //            //------------------------------------------------------------------
611 //            char octeto9[3]= "\0";
612 //            octeto9[0]=cadena[19];
613 //            octeto9[1]=cadena[20];
614 //            octeto9[2]='\0';
615 //            long i_octeto9;
616 //
617 //            // lo paso a decimal
618 //            sscanf(octeto9,"%x",&i_octeto9);
619 //            a_handlingPriority = (i_octeto9 & 0x03);
620 //            TRACEAR_DEPURACION
621 //       (
622 //        trazaDebInt("Parametro TrafficHandlingPriority recibido",a_handlingPriority);
623 //        );
624 //
625 //              //Maximum bit rate for uplink : octeto 6 completo
626 //            //------------------------------------------------------------------
627 //
628 //             char octeto6[3]= "\0";
629 //
630 //             octeto6[0]=cadena[13];
631 //             octeto6[1]=cadena[14];
632 //             octeto6[2]='\0';
633 //
634 //             a_maximumUplink = decodificaBitRate(octeto6);
635 //
636 //             trazaDebInt("Parametro Maximum bit rate for uplink recibido(en Kbps)",a_maximumUplink);
637 //
638 //              //Maximum bit rate for downlink : octeto 7 completo
639 //            //------------------------------------------------------------------
640 //
641 //             char octeto7[3]= "\0";
642 //
643 //             octeto7[0]=cadena[15];
644 //             octeto7[1]=cadena[16];
645 //             octeto7[2]='\0';
646 //
647 //             a_maximumDownlink = decodificaBitRate(octeto7);
648 //
649 //             trazaDebInt("Parametro Maximum bit rate for downlink recibido(en Kbps)",a_maximumDownlink);
650 //
651 //
652 //
653 //            // qosProfile es la cadena a quitando la release (tres primeros caracteres) 98-qosProfile o 99-qosProfile
654 //            //-----------------
655 //            strncpy(qosProfile,cadena+3,MAX_CADENA_QOS-2);
656 //            TRACEAR_DEPURACION
657 //       (
658 //        trazaDebStr("Parametro qosProfile recibido",qosProfile);
659 //        );
660 //
661 //            return std::string(qosProfile);
662 //          }
663 //
664 //        //RELEASE_98;
665 //        else if (cadena [0] =='9' && cadena [1]=='8')
666 //          {
667 //
668 //            //           8          7            6            5           4           3           2             1
669 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
670 //            //    |         spare        +          Delay class          +     Reliability class         +  Octeto 1
671 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
672 //            //    +              Peak throughput           + spare +    Precedence class        +  Octeto 2
673 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - -       +
674 //            //    +        spare(000)            +                  Mean throughput                    +  Octeto 3
675 //            //    + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - +
676 //
677 //            //Delay Class . Octeto 1 , bits 6,5,4
678 //            //------------------
679 //            a_release = 98;
680 //            char octeto1[3]= "\0";
681 //            //octetoi  es cadena[2i+1],cadena[2i+2] en hexadecimal
682 //            octeto1[0]=cadena[3];
683 //            octeto1[1]=cadena[4];
684 //            octeto1[2]='\0';
685 //            // lo paso a decimal
686 //            long i_octeto1=0;
687 //            sscanf(octeto1,"%x",&i_octeto1);
688 //            int delayClass = (i_octeto1 & 0x38)>>3;
689 //            TRACEAR_DEPURACION
690 //       (
691 //        trazaDebInt("Parametro DelayClass recibido",delayClass);
692 //        );
693 //            a_trafficClass = delayClass; // Devolvemos el valor en la var trafficClass
694 //            //Precedence Class . Octeto 2, bits 1,2,3
695 //            //--------------------------
696 //            char octeto2[3]= "\0";
697 //            octeto2[0]=cadena[5];
698 //            octeto2[1]=cadena[6];
699 //            octeto2[2]='\0';
700 //            //en decimal
701 //            long i_octeto2;
702 //            sscanf(octeto2,"%x",&i_octeto2);
703 //
704 //            int precedenceClass = i_octeto2 & 0x07;
705 //
706 //             TRACEAR_DEPURACION
707 //       (
708 //        trazaDebInt("Parametro precedenceClass recibido: ",precedenceClass);
709 //        );
710 //
711 //            a_handlingPriority =  precedenceClass; // Devolvemos el valor en la var trafficHandPriority
712 //            // qosProfile
713 //            strcpy(qosProfile, cadena+3);// qosProfile, es la cadena quitandole la release, ->"98-qosProfile"
714 //            TRACEAR_DEPURACION
715 //       (
716 //        trazaDebStr( "Parametro qosProfile recibido",qosProfile);
717 //        );
718 //
719 //            return std::string(qosProfile);
720 //          }//fin release98
721 //        else
722 //          {
723 //             TRACEAR_ERROR
724 //       (
725 //        trazaErrStr(TR("El parametro Release no es valido ( debe esr 98 o 99)"),str_release);
726 //        );
727 //             return std::string("");
728 //          }
729 //      }
730 //
731 //      int analisisQoS::decodificaBitRate(char * dato)
732 //      {
733 //       int cabecera=0;
734 //       int salida=0;
735 //       char octeto[3]= "\0";
736 //       long i_octeto;
737 //
738 //       strcpy(octeto,dato);
739 //
740 //           /*Codificacion de los bits de maxima tasa de bit
741 //          Maximum bit rate for uplink, octet 8
742 //          Bits
743 //          8 7 6 5 4 3 2 1
744 //          In MS to network direction:
745 //          0 0 0 0 0 0 0 0   Subscribed maximum bit rate for uplink
746 //          In network to MS direction:
747 //          0 0 0 0 0 0 0 0   Reserved
748 //          In MS to network direction and in network to MS direction :
749 //          0 0 0 0 0 0 0 1   The maximum bit rate is binary coded in 8 bits, using a granularity of 1 kbps
750 //          0 0 1 1 1 1 1 1   giving a range of values from 1 kbps to 63 kbps in 1 kbps increments.
751 //
752 //          0 1 0 0 0 0 0 0   The maximum bit rate is 64 kbps +  ((the binary coded value in 8 bits \9601000000) * 8 kbps)
753 //          0 1 1 1 1 1 1 1   giving a range of values from 64 kbps to 568 kbps in 8 kbps increments.
754 //
755 //          1 0 0 0 0 0 0 0   The maximum bit rate is 576 kbps + ((the binary coded value in 8 bits \9610000000) * 64 kbps)
756 //          1 1 1 1 1 1 1 0   giving a range of values from 576 kbps to 8640 kbps in 64 kbps increments.
757 //
758 //          1 1 1 1 1 1 1 1   0kbps
759 //
760 //
761 //          Maximum bit rate for downlink, octet 9 (see 3GPP TS 23.107)
762 //
763 //          Coding is identical to that of Maximum bit rate for uplink.
764 //
765 //         */
766 //
767 //       // lo paso a decimal
768 //       sscanf(octeto,"%x",&i_octeto);
769 //       cabecera = (i_octeto & 0xC0)>>6;
770 //
771 //       trazaDebStr("QoS, octeto: ", octeto);
772 //       trazaDebInt("QoS, i_octeto: ", i_octeto);
773 //       trazaDebInt("QoS, cabecera: ", cabecera);
774 //
775 //       //Casos especiales: El caso 00000000 se considera 0, por no poder definir ninguno de los dos
776 //       // casos de la especificacion(mirar codificacion arriba)
777 //
778 //       if(i_octeto != 255 && i_octeto != 0)
779 //       {
780 //          switch(cabecera)
781 //          {
782 //             case 0:
783 //                trazaDeb("Bitrate con granuralidad de 1 Kbps");
784 //                salida = (i_octeto & 0x3F);
785 //             break;
786 //
787 //             case 1:
788 //                trazaDeb("Bitrate con granuralidad de 8 Kbps");
789 //                salida = 64 + (i_octeto & 0x3F) * 8;
790 //             break;
791 //
792 //             case 2:
793 //             case 3:
794 //                trazaDeb("Bitrate con granuralidad de 64 Kbps");
795 //                salida = 576 + (i_octeto & 0x7E) * 64;
796 //             break;
797 //
798 //             default:
799 //                trazaErr("Valor de bitrate no contemplado. Revisar codificacion");
800 //                salida = 0;
801 //             break;
802 //          }
803 //       }
804 //       else
805 //       {
806 //          trazaDeb("Bitrate vale 255 o 0, valores no contemplados");
807 //          salida = 0;
808 //       }
809 //       return salida;
810 //      }
811