Harald Welte | 9a8f503 | 2017-07-25 08:23:52 +0200 | [diff] [blame] | 1 | /////////////////////////////////////////////////////////////////////////////// |
| 2 | // |
| 3 | // Copyright Test Competence Center (TCC) ETH 2011 |
| 4 | // // |
| 5 | // The copyright to the computer program(s) herein is the property of TCC. // |
| 6 | // The program(s) may be used and/or copied only with the written permission // |
| 7 | // of TCC or in accordance with the terms and conditions stipulated in the // |
| 8 | // agreement/contract under which the program(s) have been supplied // |
| 9 | /////////////////////////////////////////////////////////////////////////////// |
| 10 | // |
| 11 | // File: ISUP_EncDec.cc |
| 12 | // Rev: R7D |
| 13 | // Prodnr: CNL 113 365 |
| 14 | // Updated: 2011-05-10 |
| 15 | // Contact: http://ttcn.ericsson.se |
| 16 | /////////////////////////////////////////////////////////////////////////////// |
| 17 | #include "ISUP_Types.hh" |
| 18 | |
| 19 | namespace ISUP__Types { |
| 20 | |
| 21 | OCTETSTRING enc__PDU__ISUP(const PDU__ISUP& pdu) |
| 22 | { |
| 23 | if (TTCN_Logger::log_this_event(TTCN_DEBUG)) { |
| 24 | TTCN_Logger::begin_event(TTCN_DEBUG); |
| 25 | TTCN_Logger::log_event("Encoding PDU_ISUP: "); |
| 26 | pdu.log(); |
| 27 | TTCN_Logger::end_event(); |
| 28 | } |
| 29 | |
| 30 | TTCN_Buffer buf; |
| 31 | pdu.encode(PDU__ISUP_descr_, buf, TTCN_EncDec::CT_RAW); |
| 32 | OCTETSTRING ret_val(buf.get_len(), buf.get_data()); |
| 33 | |
| 34 | if (TTCN_Logger::log_this_event(TTCN_DEBUG)) { |
| 35 | TTCN_Logger::begin_event(TTCN_DEBUG); |
| 36 | TTCN_Logger::log_event("PDU_ISUP after encoding: "); |
| 37 | ret_val.log(); |
| 38 | TTCN_Logger::end_event(); |
| 39 | } |
| 40 | return ret_val; |
| 41 | } |
| 42 | |
| 43 | PDU__ISUP dec__PDU__ISUP(const OCTETSTRING& stream) |
| 44 | { |
| 45 | if (TTCN_Logger::log_this_event(TTCN_DEBUG)) { |
| 46 | TTCN_Logger::begin_event(TTCN_DEBUG); |
| 47 | TTCN_Logger::log_event("Decoding PDU_ISUP: "); |
| 48 | stream.log(); |
| 49 | TTCN_Logger::end_event(); |
| 50 | } |
| 51 | |
| 52 | TTCN_Buffer buf; |
| 53 | buf.put_os(stream); |
| 54 | PDU__ISUP ret_val; |
| 55 | ret_val.decode(PDU__ISUP_descr_, buf, TTCN_EncDec::CT_RAW); |
| 56 | |
| 57 | if (TTCN_Logger::log_this_event(TTCN_DEBUG)) { |
| 58 | TTCN_Logger::begin_event(TTCN_DEBUG); |
| 59 | TTCN_Logger::log_event("Decoded PDU_ISUP: "); |
| 60 | ret_val.log(); |
| 61 | TTCN_Logger::end_event(); |
| 62 | } |
| 63 | return ret_val; |
| 64 | } |
| 65 | |
| 66 | PDU__ISUP dec__PDU__ISUP__noCIC(const OCTETSTRING& stream) |
| 67 | { |
| 68 | if (TTCN_Logger::log_this_event(TTCN_DEBUG)) { |
| 69 | TTCN_Logger::begin_event(TTCN_DEBUG); |
| 70 | TTCN_Logger::log_event("Decoding PDU_ISUP: "); |
| 71 | stream.log(); |
| 72 | TTCN_Logger::end_event(); |
| 73 | } |
| 74 | |
| 75 | OCTETSTRING mod_stream (int2oct(0,2) + stream); |
| 76 | TTCN_Buffer buf; |
| 77 | buf.put_os(mod_stream); |
| 78 | PDU__ISUP ret_val; |
| 79 | ret_val.decode(PDU__ISUP_descr_, buf, TTCN_EncDec::CT_RAW); |
| 80 | PDU__ISUP::union_selection_type msg_type = ret_val.get_selection(); |
| 81 | switch (msg_type) |
| 82 | { |
| 83 | case PDU__ISUP::ALT_ISUP__ACM: |
| 84 | { |
| 85 | ret_val.ISUP__ACM().cic() = OMIT_VALUE; break; |
| 86 | } |
| 87 | case PDU__ISUP::ALT_ISUP__ANM: |
| 88 | { |
| 89 | ret_val.ISUP__ANM().cic() = OMIT_VALUE; break; |
| 90 | } |
| 91 | case PDU__ISUP::ALT_ISUP__APM: |
| 92 | { |
| 93 | ret_val.ISUP__APM().cic() = OMIT_VALUE; break; |
| 94 | } |
| 95 | case PDU__ISUP::ALT_ISUP__BLO: |
| 96 | { |
| 97 | ret_val.ISUP__BLO().cic() = OMIT_VALUE; break; |
| 98 | } |
| 99 | case PDU__ISUP::ALT_ISUP__BLA: |
| 100 | { |
| 101 | ret_val.ISUP__BLA().cic() = OMIT_VALUE; break; |
| 102 | } |
| 103 | case PDU__ISUP::ALT_ISUP__CPG: |
| 104 | { |
| 105 | ret_val.ISUP__CPG().cic() = OMIT_VALUE; break; |
| 106 | } |
| 107 | case PDU__ISUP::ALT_ISUP__CGB: |
| 108 | { |
| 109 | ret_val.ISUP__CGB().cic() = OMIT_VALUE; break; |
| 110 | } |
| 111 | case PDU__ISUP::ALT_ISUP__CGBA: |
| 112 | { |
| 113 | ret_val.ISUP__CGBA().cic() = OMIT_VALUE; break; |
| 114 | } |
| 115 | case PDU__ISUP::ALT_ISUP__CQM: |
| 116 | { |
| 117 | ret_val.ISUP__CQM().cic() = OMIT_VALUE; break; |
| 118 | } |
| 119 | case PDU__ISUP::ALT_ISUP__CQR: |
| 120 | { |
| 121 | ret_val.ISUP__CQR().cic() = OMIT_VALUE; break; |
| 122 | } |
| 123 | case PDU__ISUP::ALT_ISUP__GRS: |
| 124 | { |
| 125 | ret_val.ISUP__GRS().cic() = OMIT_VALUE; break; |
| 126 | } |
| 127 | case PDU__ISUP::ALT_ISUP__GRA: |
| 128 | { |
| 129 | ret_val.ISUP__GRA().cic() = OMIT_VALUE; break; |
| 130 | } |
| 131 | case PDU__ISUP::ALT_ISUP__CGU: |
| 132 | { |
| 133 | ret_val.ISUP__CGU().cic() = OMIT_VALUE; break; |
| 134 | } |
| 135 | case PDU__ISUP::ALT_ISUP__CGUA: |
| 136 | { |
| 137 | ret_val.ISUP__CGUA().cic() = OMIT_VALUE; break; |
| 138 | } |
| 139 | case PDU__ISUP::ALT_ISUP__CRG: |
| 140 | { |
| 141 | ret_val.ISUP__CRG().cic() = OMIT_VALUE; break; |
| 142 | } |
| 143 | case PDU__ISUP::ALT_ISUP__CFN: |
| 144 | { |
| 145 | ret_val.ISUP__CFN().cic() = OMIT_VALUE; break; |
| 146 | } |
| 147 | case PDU__ISUP::ALT_ISUP__CON: |
| 148 | { |
| 149 | ret_val.ISUP__CON().cic() = OMIT_VALUE; break; |
| 150 | } |
| 151 | case PDU__ISUP::ALT_ISUP__COT: |
| 152 | { |
| 153 | ret_val.ISUP__COT().cic() = OMIT_VALUE; break; |
| 154 | } |
| 155 | case PDU__ISUP::ALT_ISUP__CCR: |
| 156 | { |
| 157 | ret_val.ISUP__CCR().cic() = OMIT_VALUE; break; |
| 158 | } |
| 159 | case PDU__ISUP::ALT_ISUP__FAC: |
| 160 | { |
| 161 | ret_val.ISUP__FAC().cic() = OMIT_VALUE; break; |
| 162 | } |
| 163 | case PDU__ISUP::ALT_ISUP__FAA: |
| 164 | { |
| 165 | ret_val.ISUP__FAA().cic() = OMIT_VALUE; break; |
| 166 | } |
| 167 | case PDU__ISUP::ALT_ISUP__FRJ: |
| 168 | { |
| 169 | ret_val.ISUP__FRJ().cic() = OMIT_VALUE; break; |
| 170 | } |
| 171 | case PDU__ISUP::ALT_ISUP__FAR: |
| 172 | { |
| 173 | ret_val.ISUP__FAR().cic() = OMIT_VALUE; break; |
| 174 | } |
| 175 | case PDU__ISUP::ALT_ISUP__FOT: |
| 176 | { |
| 177 | ret_val.ISUP__FOT().cic() = OMIT_VALUE; break; |
| 178 | } |
| 179 | case PDU__ISUP::ALT_ISUP__IDR: |
| 180 | { |
| 181 | ret_val.ISUP__IDR().cic() = OMIT_VALUE; break; |
| 182 | } |
| 183 | case PDU__ISUP::ALT_ISUP__IRS: |
| 184 | { |
| 185 | ret_val.ISUP__IRS().cic() = OMIT_VALUE; break; |
| 186 | } |
| 187 | case PDU__ISUP::ALT_ISUP__INF: |
| 188 | { |
| 189 | ret_val.ISUP__INF().cic() = OMIT_VALUE; break; |
| 190 | } |
| 191 | case PDU__ISUP::ALT_ISUP__INR: |
| 192 | { |
| 193 | ret_val.ISUP__INR().cic() = OMIT_VALUE; break; |
| 194 | } |
| 195 | case PDU__ISUP::ALT_ISUP__IAM: |
| 196 | { |
| 197 | ret_val.ISUP__IAM().cic() = OMIT_VALUE; break; |
| 198 | } |
| 199 | case PDU__ISUP::ALT_ISUP__LPA: |
| 200 | { |
| 201 | ret_val.ISUP__LPA().cic() = OMIT_VALUE; break; |
| 202 | } |
| 203 | case PDU__ISUP::ALT_ISUP__LOP: |
| 204 | { |
| 205 | ret_val.ISUP__LOP().cic() = OMIT_VALUE; break; |
| 206 | } |
| 207 | case PDU__ISUP::ALT_ISUP__NRM: |
| 208 | { |
| 209 | ret_val.ISUP__NRM().cic() = OMIT_VALUE; break; |
| 210 | } |
| 211 | case PDU__ISUP::ALT_ISUP__OLM: |
| 212 | { |
| 213 | ret_val.ISUP__OLM().cic() = OMIT_VALUE; break; |
| 214 | } |
| 215 | case PDU__ISUP::ALT_ISUP__OPR: |
| 216 | { |
| 217 | ret_val.ISUP__OPR().cic() = OMIT_VALUE; break; |
| 218 | } |
| 219 | case PDU__ISUP::ALT_ISUP__PAM: |
| 220 | { |
| 221 | ret_val.ISUP__PAM().cic() = OMIT_VALUE; break; |
| 222 | } |
| 223 | case PDU__ISUP::ALT_ISUP__PRI: |
| 224 | { |
| 225 | ret_val.ISUP__PRI().cic() = OMIT_VALUE; break; |
| 226 | } |
| 227 | case PDU__ISUP::ALT_ISUP__REL: |
| 228 | { |
| 229 | ret_val.ISUP__REL().cic() = OMIT_VALUE; break; |
| 230 | } |
| 231 | case PDU__ISUP::ALT_ISUP__RLC: |
| 232 | { |
| 233 | ret_val.ISUP__RLC().cic() = OMIT_VALUE; break; |
| 234 | } |
| 235 | case PDU__ISUP::ALT_ISUP__RSC: |
| 236 | { |
| 237 | ret_val.ISUP__RSC().cic() = OMIT_VALUE; break; |
| 238 | } |
| 239 | case PDU__ISUP::ALT_ISUP__RES: |
| 240 | { |
| 241 | ret_val.ISUP__RES().cic() = OMIT_VALUE; break; |
| 242 | } |
| 243 | case PDU__ISUP::ALT_ISUP__SGM: |
| 244 | { |
| 245 | ret_val.ISUP__SGM().cic() = OMIT_VALUE; break; |
| 246 | } |
| 247 | case PDU__ISUP::ALT_ISUP__SAM: |
| 248 | { |
| 249 | ret_val.ISUP__SAM().cic() = OMIT_VALUE; break; |
| 250 | } |
| 251 | case PDU__ISUP::ALT_ISUP__SCB: |
| 252 | { |
| 253 | ret_val.ISUP__SCB().cic() = OMIT_VALUE; break; |
| 254 | } |
| 255 | case PDU__ISUP::ALT_ISUP__SDM: |
| 256 | { |
| 257 | ret_val.ISUP__SDM().cic() = OMIT_VALUE; break; |
| 258 | } |
| 259 | case PDU__ISUP::ALT_ISUP__SUS: |
| 260 | { |
| 261 | ret_val.ISUP__SUS().cic() = OMIT_VALUE; break; |
| 262 | } |
| 263 | case PDU__ISUP::ALT_ISUP__UBL: |
| 264 | { |
| 265 | ret_val.ISUP__UBL().cic() = OMIT_VALUE; break; |
| 266 | } |
| 267 | case PDU__ISUP::ALT_ISUP__UBA: |
| 268 | { |
| 269 | ret_val.ISUP__UBA().cic() = OMIT_VALUE; break; |
| 270 | } |
| 271 | case PDU__ISUP::ALT_ISUP__UCIC: |
| 272 | { |
| 273 | ret_val.ISUP__UCIC().cic() = OMIT_VALUE; break; |
| 274 | } |
| 275 | case PDU__ISUP::ALT_ISUP__UPA: |
| 276 | { |
| 277 | ret_val.ISUP__UPA().cic() = OMIT_VALUE; break; |
| 278 | } |
| 279 | case PDU__ISUP::ALT_ISUP__UPT: |
| 280 | { |
| 281 | ret_val.ISUP__UPT().cic() = OMIT_VALUE; break; |
| 282 | } |
| 283 | case PDU__ISUP::ALT_ISUP__USR: |
| 284 | { |
| 285 | ret_val.ISUP__USR().cic() = OMIT_VALUE; break; |
| 286 | } |
| 287 | default: |
| 288 | break; |
| 289 | } |
| 290 | if (TTCN_Logger::log_this_event(TTCN_DEBUG)) { |
| 291 | TTCN_Logger::begin_event(TTCN_DEBUG); |
| 292 | TTCN_Logger::log_event("Decoded PDU_ISUP: "); |
| 293 | ret_val.log(); |
| 294 | TTCN_Logger::end_event(); |
| 295 | } |
| 296 | return ret_val; |
| 297 | } |
| 298 | |
| 299 | INTEGER dec__PDU__ISUP__backtrack__noCIC(const OCTETSTRING& stream, PDU__ISUP& pdu) |
| 300 | { |
| 301 | if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) { |
| 302 | TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC); |
| 303 | TTCN_Logger::log_event_str("dec_PDU_ISUP_backtrack(): Stream before decoding: "); |
| 304 | stream.log(); |
| 305 | TTCN_Logger::end_event(); |
| 306 | } |
| 307 | TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_WARNING); |
| 308 | TTCN_EncDec::clear_error(); |
| 309 | OCTETSTRING mod_stream (int2oct(0,2) + stream); |
| 310 | TTCN_Buffer ttcn_buffer; |
| 311 | ttcn_buffer.put_os(mod_stream); |
| 312 | pdu.decode(PDU__ISUP_descr_, ttcn_buffer, TTCN_EncDec::CT_RAW); |
| 313 | |
| 314 | |
| 315 | if (TTCN_EncDec::get_last_error_type() == TTCN_EncDec::ET_NONE) { |
| 316 | |
| 317 | PDU__ISUP::union_selection_type msg_type = pdu.get_selection(); |
| 318 | switch (msg_type) |
| 319 | { |
| 320 | case PDU__ISUP::ALT_ISUP__ACM: |
| 321 | { |
| 322 | pdu.ISUP__ACM().cic() = OMIT_VALUE; break; |
| 323 | } |
| 324 | case PDU__ISUP::ALT_ISUP__ANM: |
| 325 | { |
| 326 | pdu.ISUP__ANM().cic() = OMIT_VALUE; break; |
| 327 | } |
| 328 | case PDU__ISUP::ALT_ISUP__BLO: |
| 329 | { |
| 330 | pdu.ISUP__BLO().cic() = OMIT_VALUE; break; |
| 331 | } |
| 332 | case PDU__ISUP::ALT_ISUP__BLA: |
| 333 | { |
| 334 | pdu.ISUP__BLA().cic() = OMIT_VALUE; break; |
| 335 | } |
| 336 | case PDU__ISUP::ALT_ISUP__CPG: |
| 337 | { |
| 338 | pdu.ISUP__CPG().cic() = OMIT_VALUE; break; |
| 339 | } |
| 340 | case PDU__ISUP::ALT_ISUP__CGB: |
| 341 | { |
| 342 | pdu.ISUP__CGB().cic() = OMIT_VALUE; break; |
| 343 | } |
| 344 | case PDU__ISUP::ALT_ISUP__CGBA: |
| 345 | { |
| 346 | pdu.ISUP__CGBA().cic() = OMIT_VALUE; break; |
| 347 | } |
| 348 | case PDU__ISUP::ALT_ISUP__GRS: |
| 349 | { |
| 350 | pdu.ISUP__GRS().cic() = OMIT_VALUE; break; |
| 351 | } |
| 352 | case PDU__ISUP::ALT_ISUP__GRA: |
| 353 | { |
| 354 | pdu.ISUP__GRA().cic() = OMIT_VALUE; break; |
| 355 | } |
| 356 | case PDU__ISUP::ALT_ISUP__CGU: |
| 357 | { |
| 358 | pdu.ISUP__CGU().cic() = OMIT_VALUE; break; |
| 359 | } |
| 360 | case PDU__ISUP::ALT_ISUP__CGUA: |
| 361 | { |
| 362 | pdu.ISUP__CGUA().cic() = OMIT_VALUE; break; |
| 363 | } |
| 364 | case PDU__ISUP::ALT_ISUP__CQM: |
| 365 | { |
| 366 | pdu.ISUP__CQM().cic() = OMIT_VALUE; break; |
| 367 | } |
| 368 | case PDU__ISUP::ALT_ISUP__CQR: |
| 369 | { |
| 370 | pdu.ISUP__CQR().cic() = OMIT_VALUE; break; |
| 371 | } |
| 372 | case PDU__ISUP::ALT_ISUP__CFN: |
| 373 | { |
| 374 | pdu.ISUP__CFN().cic() = OMIT_VALUE; break; |
| 375 | } |
| 376 | case PDU__ISUP::ALT_ISUP__COT: |
| 377 | { |
| 378 | pdu.ISUP__COT().cic() = OMIT_VALUE; break; |
| 379 | } |
| 380 | case PDU__ISUP::ALT_ISUP__CCR: |
| 381 | { |
| 382 | pdu.ISUP__CCR().cic() = OMIT_VALUE; break; |
| 383 | } |
| 384 | case PDU__ISUP::ALT_ISUP__FAC: |
| 385 | { |
| 386 | pdu.ISUP__FAC().cic() = OMIT_VALUE; break; |
| 387 | } |
| 388 | case PDU__ISUP::ALT_ISUP__FOT: |
| 389 | { |
| 390 | pdu.ISUP__FOT().cic() = OMIT_VALUE; break; |
| 391 | } |
| 392 | case PDU__ISUP::ALT_ISUP__INF: |
| 393 | { |
| 394 | pdu.ISUP__INF().cic() = OMIT_VALUE; break; |
| 395 | } |
| 396 | case PDU__ISUP::ALT_ISUP__INR: |
| 397 | { |
| 398 | pdu.ISUP__INR().cic() = OMIT_VALUE; break; |
| 399 | } |
| 400 | case PDU__ISUP::ALT_ISUP__IAM: |
| 401 | { |
| 402 | pdu.ISUP__IAM().cic() = OMIT_VALUE; break; |
| 403 | } |
| 404 | case PDU__ISUP::ALT_ISUP__LPA: |
| 405 | { |
| 406 | pdu.ISUP__LPA().cic() = OMIT_VALUE; break; |
| 407 | } |
| 408 | case PDU__ISUP::ALT_ISUP__REL: |
| 409 | { |
| 410 | pdu.ISUP__REL().cic() = OMIT_VALUE; break; |
| 411 | } |
| 412 | case PDU__ISUP::ALT_ISUP__RLC: |
| 413 | { |
| 414 | pdu.ISUP__RLC().cic() = OMIT_VALUE; break; |
| 415 | } |
| 416 | case PDU__ISUP::ALT_ISUP__RSC: |
| 417 | { |
| 418 | pdu.ISUP__RSC().cic() = OMIT_VALUE; break; |
| 419 | } |
| 420 | case PDU__ISUP::ALT_ISUP__RES: |
| 421 | { |
| 422 | pdu.ISUP__RES().cic() = OMIT_VALUE; break; |
| 423 | } |
| 424 | case PDU__ISUP::ALT_ISUP__SUS: |
| 425 | { |
| 426 | pdu.ISUP__SUS().cic() = OMIT_VALUE; break; |
| 427 | } |
| 428 | case PDU__ISUP::ALT_ISUP__UBL: |
| 429 | { |
| 430 | pdu.ISUP__UBL().cic() = OMIT_VALUE; break; |
| 431 | } |
| 432 | case PDU__ISUP::ALT_ISUP__UBA: |
| 433 | { |
| 434 | pdu.ISUP__UBA().cic() = OMIT_VALUE; break; |
| 435 | } |
| 436 | case PDU__ISUP::ALT_ISUP__UCIC: |
| 437 | { |
| 438 | pdu.ISUP__UCIC().cic() = OMIT_VALUE; break; |
| 439 | } |
| 440 | default: |
| 441 | break; |
| 442 | } |
| 443 | |
| 444 | |
| 445 | if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) { |
| 446 | TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC); |
| 447 | TTCN_Logger::log_event_str("dec_PDU_ISUP_backtrack_noCIC(): Decoded @ISUP_Types.PDU_ISUP: "); |
| 448 | pdu.log(); |
| 449 | TTCN_Logger::end_event(); |
| 450 | } |
| 451 | |
| 452 | if (ttcn_buffer.get_pos() < ttcn_buffer.get_len() && TTCN_Logger::log_this_event(TTCN_WARNING)) { |
| 453 | ttcn_buffer.cut(); |
| 454 | OCTETSTRING remaining_stream; |
| 455 | ttcn_buffer.get_string(remaining_stream); |
| 456 | TTCN_Logger::begin_event(TTCN_WARNING); |
| 457 | TTCN_Logger::log_event_str("dec_PDU_ISUP_backtrack(): Warning: Data remained at the end of the stream after successful decoding: "); |
| 458 | remaining_stream.log(); |
| 459 | TTCN_Logger::end_event(); |
| 460 | } |
| 461 | return 0; |
| 462 | } else return 1; |
| 463 | } |
| 464 | |
| 465 | }//namespace |