1%%
2%% %CopyrightBegin%
3%%
4%% Copyright Ericsson AB 2006-2019. All Rights Reserved.
5%%
6%% Licensed under the Apache License, Version 2.0 (the "License");
7%% you may not use this file except in compliance with the License.
8%% You may obtain a copy of the License at
9%%
10%%     http://www.apache.org/licenses/LICENSE-2.0
11%%
12%% Unless required by applicable law or agreed to in writing, software
13%% distributed under the License is distributed on an "AS IS" BASIS,
14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15%% See the License for the specific language governing permissions and
16%% limitations under the License.
17%%
18%% %CopyrightEnd%
19%%
20
21%%
22%%----------------------------------------------------------------------
23%% Purpose: Test encoding/decoding (codec) module of Megaco/H.248
24%%----------------------------------------------------------------------
25
26-module(megaco_codec_prev3c_SUITE).
27
28%% ----
29
30-include_lib("megaco/include/megaco.hrl").
31-include_lib("megaco/include/megaco_message_prev3c.hrl").
32-include("megaco_test_lib.hrl").
33
34%% ----
35
36-export([msgs/0]).
37-export([rfc3525_msgs_display/0, rfc3525_msgs_test/0]).
38
39-export([
40 	 suite/0, all/0, groups/0,
41         init_per_suite/1, end_per_suite/1,
42         init_per_group/2, end_per_group/2,
43         init_per_testcase/2, end_per_testcase/2,
44
45	 pretty_test_msgs/1,
46
47	 compact_test_msgs/1,
48
49	 flex_pretty_init/1,
50	 flex_pretty_finish/1,
51	 flex_pretty_test_msgs/1,
52
53
54	 flex_compact_init/1,
55	 flex_compact_finish/1,
56	 flex_compact_test_msgs/1,
57
58	 flex_compact_dm_timers1/1,
59	 flex_compact_dm_timers2/1,
60	 flex_compact_dm_timers3/1,
61	 flex_compact_dm_timers4/1,
62	 flex_compact_dm_timers5/1,
63	 flex_compact_dm_timers6/1,
64	 flex_compact_dm_timers7/1,
65	 flex_compact_dm_timers8/1,
66
67	 bin_test_msgs/1,
68
69	 ber_test_msgs/1,
70
71	 per_test_msgs/1,
72
73	 erl_dist_m_test_msgs/1,
74
75	 compact_otp4011_msg1/1,
76	 compact_otp4011_msg2/1,
77	 compact_otp4011_msg3/1,
78	 compact_otp4013_msg1/1,
79	 compact_otp4085_msg1/1,
80	 compact_otp4085_msg2/1,
81	 compact_otp4280_msg1/1,
82	 compact_otp4299_msg1/1,
83	 compact_otp4359_msg1/1,
84	 compact_otp4920_msg0/1,
85	 compact_otp4920_msg1/1,
86	 compact_otp4920_msg2/1,
87	 compact_otp4920_msg3/1,
88	 compact_otp4920_msg4/1,
89	 compact_otp4920_msg5/1,
90	 compact_otp4920_msg6/1,
91	 compact_otp4920_msg7/1,
92	 compact_otp4920_msg8/1,
93	 compact_otp4920_msg9/1,
94	 compact_otp4920_msg10/1,
95	 compact_otp4920_msg11/1,
96	 compact_otp4920_msg12/1,
97	 compact_otp4920_msg20/1,
98	 compact_otp4920_msg21/1,
99	 compact_otp4920_msg22/1,
100	 compact_otp4920_msg23/1,
101	 compact_otp4920_msg24/1,
102	 compact_otp4920_msg25/1,
103	 compact_otp5186_msg01/1,
104	 compact_otp5186_msg02/1,
105	 compact_otp5186_msg03/1,
106	 compact_otp5186_msg04/1,
107	 compact_otp5186_msg05/1,
108	 compact_otp5186_msg06/1,
109	 compact_otp5793_msg01/1,
110	 compact_otp5836_msg01/1,
111         compact_otp5993_msg01/1,
112         compact_otp5993_msg02/1,
113         compact_otp5993_msg03/1,
114         compact_otp6017_msg01/1,
115         compact_otp6017_msg02/1,
116         compact_otp6017_msg03/1,
117
118	 flex_compact_otp4299_msg1/1,
119         flex_compact_otp7431_msg01/1,
120         flex_compact_otp7431_msg02/1,
121         flex_compact_otp7431_msg03/1,
122         flex_compact_otp7431_msg04/1,
123         flex_compact_otp7431_msg05/1,
124         flex_compact_otp7431_msg06/1,
125         flex_compact_otp7431_msg07/1,
126
127	 pretty_otp4632_msg1/1,
128	 pretty_otp4632_msg2/1,
129	 pretty_otp4632_msg3/1,
130	 pretty_otp4632_msg4/1,
131	 pretty_otp4710_msg1/1,
132	 pretty_otp4710_msg2/1,
133	 pretty_otp4945_msg1/1,
134	 pretty_otp4945_msg2/1,
135	 pretty_otp4945_msg3/1,
136	 pretty_otp4945_msg4/1,
137	 pretty_otp4945_msg5/1,
138	 pretty_otp4945_msg6/1,
139	 pretty_otp4949_msg1/1,
140	 pretty_otp4949_msg2/1,
141	 pretty_otp4949_msg3/1,
142	 pretty_otp5042_msg1/1,
143	 pretty_otp5068_msg1/1,
144	 pretty_otp5085_msg1/1,
145	 pretty_otp5085_msg2/1,
146	 pretty_otp5085_msg3/1,
147	 pretty_otp5085_msg4/1,
148	 pretty_otp5085_msg5/1,
149	 pretty_otp5085_msg6/1,
150	 pretty_otp5085_msg7/1,
151	 pretty_otp5085_msg8/1,
152         pretty_otp5600_msg1/1,
153         pretty_otp5600_msg2/1,
154         pretty_otp5601_msg1/1,
155         pretty_otp5793_msg01/1,
156	 pretty_otp5803_msg01/1,
157	 pretty_otp5803_msg02/1,
158	 pretty_otp5805_msg01/1,
159	 pretty_otp5836_msg01/1,
160	 pretty_otp5882_msg01/1,
161	 pretty_otp6490_msg01/1,
162	 pretty_otp6490_msg02/1,
163	 pretty_otp6490_msg03/1,
164	 pretty_otp6490_msg04/1,
165	 pretty_otp6490_msg05/1,
166	 pretty_otp6490_msg06/1,
167         pretty_otp7671_msg01/1,
168         pretty_otp7671_msg02/1,
169         pretty_otp7671_msg03/1,
170         pretty_otp7671_msg04/1,
171         pretty_otp7671_msg05/1,
172         pretty_otp8114_msg01/1,
173
174	 flex_pretty_otp5042_msg1/1,
175	 flex_pretty_otp5085_msg1/1,
176	 flex_pretty_otp5085_msg2/1,
177	 flex_pretty_otp5085_msg3/1,
178	 flex_pretty_otp5085_msg4/1,
179	 flex_pretty_otp5085_msg5/1,
180	 flex_pretty_otp5085_msg6/1,
181	 flex_pretty_otp5085_msg7/1,
182	 flex_pretty_otp5085_msg8/1,
183         flex_pretty_otp5600_msg1/1,
184         flex_pretty_otp5600_msg2/1,
185         flex_pretty_otp5601_msg1/1,
186         flex_pretty_otp5793_msg01/1,
187	 flex_pretty_otp5803_msg01/1,
188	 flex_pretty_otp5803_msg02/1,
189	 flex_pretty_otp5805_msg01/1,
190	 flex_pretty_otp5836_msg01/1,
191         flex_pretty_otp7431_msg01/1,
192         flex_pretty_otp7431_msg02/1,
193         flex_pretty_otp7431_msg03/1,
194         flex_pretty_otp7431_msg04/1,
195         flex_pretty_otp7431_msg05/1,
196         flex_pretty_otp7431_msg06/1,
197         flex_pretty_otp7431_msg07/1
198        ]).
199
200-export([display_text_messages/0, generate_text_messages/0]).
201
202
203%% ----
204
205-define(V3,    prev3c).
206-define(EC_V3, {version3,?V3}).
207-define(EC,    [?EC_V3]).
208
209-define(VERSION,      3).
210-define(VERSION_STR,  "3").
211-define(MSG_LIB,      megaco_test_msg_prev3c_lib).
212-define(DEFAULT_PORT, 55555).
213-define(MG1_MID_NO_PORT, {ip4Address,
214                          #'IP4Address'{address = [124, 124, 124, 222]}}).
215-define(MG1_MID, {ip4Address, #'IP4Address'{address = [124, 124, 124, 222],
216                                            portNumber = ?DEFAULT_PORT}}).
217-define(MG2_MID, {ip4Address, #'IP4Address'{address = [125, 125, 125, 111],
218                                            portNumber = ?DEFAULT_PORT}}).
219-define(MGC_MID, {ip4Address, #'IP4Address'{address = [123, 123, 123, 4],
220                                            portNumber = ?DEFAULT_PORT}}).
221
222-define(A4444, ["11111111", "00000000", "00000000"]).
223-define(A4445, ["11111111", "00000000", "11111111"]).
224-define(A5555, ["11111111", "11111111", "00000000"]).
225-define(A5556, ["11111111", "11111111", "11111111"]).
226
227
228%%======================================================================
229%% Common Test interface functions
230%%======================================================================
231
232suite() ->
233    [{ct_hooks, [ts_install_cth]}].
234
235all() ->
236    [
237     {group, text},
238     {group, binary},
239     {group, erl_dist},
240     {group, tickets}
241    ].
242
243groups() ->
244    [
245     {text,                 [], text_cases()},
246     {binary,               [], binary_cases()},
247     {erl_dist,             [], erl_dist_cases()},
248     {pretty,               [], pretty_cases()},
249     {compact,              [], compact_cases()},
250     {flex_pretty,          [], flex_pretty_cases()},
251     {flex_compact,         [], flex_compact_cases()},
252     {bin,                  [], bin_cases()},
253     {ber,                  [], ber_cases()},
254     {per,                  [], per_cases()},
255     {erl_dist_m,           [], erl_dist_m_cases()},
256     {tickets,              [], tickets_cases()},
257     {compact_tickets,      [], compact_tickets_cases()},
258     {flex_compact_tickets, [], flex_compact_tickets_cases()},
259     {pretty_tickets,       [], pretty_tickets_cases()},
260     {flex_pretty_tickets,  [], flex_pretty_tickets_cases()}
261    ].
262
263text_cases() ->
264    [
265     {group, pretty},
266     {group, flex_pretty},
267     {group, compact},
268     {group, flex_compact}
269    ].
270
271binary_cases() ->
272    [
273     {group, bin},
274     {group, ber},
275     {group, per}
276    ].
277
278erl_dist_cases() ->
279    [
280     {group, erl_dist_m}
281    ].
282
283pretty_cases() ->
284    [
285     pretty_test_msgs
286    ].
287
288compact_cases() ->
289    [
290     compact_test_msgs
291    ].
292
293flex_pretty_cases() ->
294    [
295     flex_pretty_test_msgs
296    ].
297
298flex_compact_cases() ->
299    [
300     flex_compact_test_msgs,
301     flex_compact_dm_timers1,
302     flex_compact_dm_timers2,
303     flex_compact_dm_timers3,
304     flex_compact_dm_timers4,
305     flex_compact_dm_timers5,
306     flex_compact_dm_timers6,
307     flex_compact_dm_timers7,
308     flex_compact_dm_timers8
309    ].
310
311bin_cases() ->
312    [
313     bin_test_msgs
314    ].
315
316ber_cases() ->
317    [
318     ber_test_msgs
319    ].
320
321per_cases() ->
322    [
323     per_test_msgs
324    ].
325
326erl_dist_m_cases() ->
327    [
328     erl_dist_m_test_msgs
329    ].
330
331tickets_cases() ->
332    [
333     {group, compact_tickets},
334     {group, flex_compact_tickets},
335     {group, pretty_tickets},
336     {group, flex_pretty_tickets}
337    ].
338
339compact_tickets_cases() ->
340    [
341     compact_otp4011_msg1,
342     compact_otp4011_msg2,
343     compact_otp4011_msg3,
344     compact_otp4013_msg1,
345     compact_otp4085_msg1,
346     compact_otp4085_msg2,
347     compact_otp4280_msg1,
348     compact_otp4299_msg1,
349     compact_otp4359_msg1,
350     compact_otp4920_msg0,
351     compact_otp4920_msg1,
352     compact_otp4920_msg2,
353     compact_otp4920_msg3,
354     compact_otp4920_msg4,
355     compact_otp4920_msg5,
356     compact_otp4920_msg6,
357     compact_otp4920_msg7,
358     compact_otp4920_msg8,
359     compact_otp4920_msg9,
360     compact_otp4920_msg10,
361     compact_otp4920_msg11,
362     compact_otp4920_msg12,
363     compact_otp4920_msg20,
364     compact_otp4920_msg21,
365     compact_otp4920_msg22,
366     compact_otp4920_msg23,
367     compact_otp4920_msg24,
368     compact_otp4920_msg25,
369     compact_otp5186_msg01,
370     compact_otp5186_msg02,
371     compact_otp5186_msg03,
372     compact_otp5186_msg04,
373     compact_otp5186_msg05,
374     compact_otp5186_msg06,
375     compact_otp5793_msg01,
376     compact_otp5836_msg01,
377     compact_otp5993_msg01,
378     compact_otp5993_msg02,
379     compact_otp5993_msg03,
380     compact_otp6017_msg01,
381     compact_otp6017_msg02,
382     compact_otp6017_msg03
383    ].
384
385flex_compact_tickets_cases() ->
386    [
387     flex_compact_otp4299_msg1,
388     flex_compact_otp7431_msg01,
389     flex_compact_otp7431_msg02,
390     flex_compact_otp7431_msg03,
391     flex_compact_otp7431_msg04,
392     flex_compact_otp7431_msg05,
393     flex_compact_otp7431_msg06,
394     flex_compact_otp7431_msg07
395    ].
396
397pretty_tickets_cases() ->
398    [
399     pretty_otp4632_msg1,
400     pretty_otp4632_msg2,
401     pretty_otp4632_msg3,
402     pretty_otp4632_msg4,
403     pretty_otp4710_msg1,
404     pretty_otp4710_msg2,
405     pretty_otp4945_msg1,
406     pretty_otp4945_msg2,
407     pretty_otp4945_msg3,
408     pretty_otp4945_msg4,
409     pretty_otp4945_msg5,
410     pretty_otp4945_msg6,
411     pretty_otp4949_msg1,
412     pretty_otp4949_msg2,
413     pretty_otp4949_msg3,
414     pretty_otp5042_msg1,
415     pretty_otp5068_msg1,
416     pretty_otp5085_msg1,
417     pretty_otp5085_msg2,
418     pretty_otp5085_msg3,
419     pretty_otp5085_msg4,
420     pretty_otp5085_msg5,
421     pretty_otp5085_msg6,
422     pretty_otp5085_msg7,
423     pretty_otp5085_msg8,
424     pretty_otp5600_msg1,
425     pretty_otp5600_msg2,
426     pretty_otp5601_msg1,
427     pretty_otp5793_msg01,
428     pretty_otp5803_msg01,
429     pretty_otp5803_msg02,
430     pretty_otp5805_msg01,
431     pretty_otp5836_msg01,
432     pretty_otp5882_msg01,
433     pretty_otp6490_msg01,
434     pretty_otp6490_msg02,
435     pretty_otp6490_msg03,
436     pretty_otp6490_msg04,
437     pretty_otp6490_msg05,
438     pretty_otp6490_msg06,
439     pretty_otp7671_msg01,
440     pretty_otp7671_msg02,
441     pretty_otp7671_msg03,
442     pretty_otp7671_msg04,
443     pretty_otp7671_msg05,
444     pretty_otp8114_msg01
445    ].
446
447flex_pretty_tickets_cases() ->
448    [
449     flex_pretty_otp5042_msg1,
450     flex_pretty_otp5085_msg1,
451     flex_pretty_otp5085_msg2,
452     flex_pretty_otp5085_msg3,
453     flex_pretty_otp5085_msg4,
454     flex_pretty_otp5085_msg5,
455     flex_pretty_otp5085_msg6,
456     flex_pretty_otp5085_msg7,
457     flex_pretty_otp5085_msg8,
458     flex_pretty_otp5600_msg1,
459     flex_pretty_otp5600_msg2,
460     flex_pretty_otp5601_msg1,
461     flex_pretty_otp5793_msg01,
462     flex_pretty_otp5803_msg01,
463     flex_pretty_otp5803_msg02,
464     flex_pretty_otp5805_msg01,
465     flex_pretty_otp5836_msg01,
466     flex_pretty_otp7431_msg01,
467     flex_pretty_otp7431_msg02,
468     flex_pretty_otp7431_msg03,
469     flex_pretty_otp7431_msg04,
470     flex_pretty_otp7431_msg05,
471     flex_pretty_otp7431_msg06,
472     flex_pretty_otp7431_msg07
473    ].
474
475
476%%
477%% -----
478%%
479
480init_per_suite(suite) ->
481    [];
482init_per_suite(doc) ->
483    [];
484init_per_suite(Config0) when is_list(Config0) ->
485
486    ?ANNOUNCE_SUITE_INIT(),
487
488    p("init_per_suite -> entry with"
489      "~n      Config: ~p"
490      "~n      Nodes:  ~p", [Config0, erlang:nodes()]),
491
492    case ?LIB:init_per_suite(Config0) of
493        {skip, _} = SKIP ->
494            SKIP;
495
496        Config1 when is_list(Config1) ->
497
498            %% We need a (local) monitor on this node also
499            megaco_test_sys_monitor:start(),
500
501            p("init_per_suite -> end when"
502              "~n      Config: ~p"
503              "~n      Nodes:  ~p", [Config1, erlang:nodes()]),
504
505            Config1
506    end.
507
508end_per_suite(suite) -> [];
509end_per_suite(doc) -> [];
510end_per_suite(Config0) when is_list(Config0) ->
511
512    p("end_per_suite -> entry with"
513      "~n      Config: ~p"
514      "~n      Nodes:  ~p", [Config0, erlang:nodes()]),
515
516    megaco_test_sys_monitor:stop(),
517    Config1 = ?LIB:end_per_suite(Config0),
518
519    p("end_per_suite -> end when"
520      "~n      Nodes:  ~p", [erlang:nodes()]),
521
522    Config1.
523
524
525%%
526%% -----
527%%
528
529init_per_group(flex_pretty_tickets = Group, Config) ->
530    ?ANNOUNCE_GROUP_INIT(Group),
531    flex_pretty_init(Config);
532init_per_group(flex_compact_tickets = Group, Config) ->
533    ?ANNOUNCE_GROUP_INIT(Group),
534    flex_compact_init(Config);
535init_per_group(flex_compact = Group, Config) ->
536    ?ANNOUNCE_GROUP_INIT(Group),
537    flex_compact_init(Config);
538init_per_group(flex_pretty = Group, Config) ->
539    ?ANNOUNCE_GROUP_INIT(Group),
540    flex_pretty_init(Config);
541init_per_group(Group, Config) ->
542    ?ANNOUNCE_GROUP_INIT(Group),
543    Config.
544
545end_per_group(flex_pretty_tickets = _Group, Config) ->
546    flex_pretty_finish(Config);
547end_per_group(flex_compact_tickets = _Group, Config) ->
548    flex_compact_finish(Config);
549end_per_group(flex_compact, Config = _Group) ->
550    flex_compact_finish(Config);
551end_per_group(flex_pretty, Config = _Group) ->
552    flex_pretty_finish(Config);
553end_per_group(_Group, Config) ->
554    Config.
555
556
557
558%%
559%% -----
560%%
561
562init_per_testcase(Case, Config) ->
563    %% We do *not* reset events with each test case
564    %% The test cases are so short we don't bother,
565    %% and also we would drown in mprintouts...
566    put(verbosity,trc),
567    megaco_test_lib:init_per_testcase(Case, Config).
568
569end_per_testcase(Case, Config) ->
570    erase(verbosity),
571    megaco_test_lib:end_per_testcase(Case, Config).
572
573
574%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
575
576display_text_messages() ->
577    Msgs =
578	msgs1a(text) ++
579	msgs5(text) ++
580	msgs6(text) ++
581	msgs7(text),
582    megaco_codec_test_lib:display_text_messages(?VERSION, ?EC, Msgs).
583
584
585generate_text_messages() ->
586    Msgs =
587	msgs1a(text) ++
588	msgs5(text) ++
589	msgs6(text) ++
590	msgs7(text),
591    megaco_codec_test_lib:generate_text_messages(?V3, ?VERSION, ?EC, Msgs).
592
593
594%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
595
596pretty_test_msgs(suite) ->
597    [];
598pretty_test_msgs(Config) when is_list(Config) ->
599    ?ACQUIRE_NODES(1, Config),
600    Msgs =
601   	msgs1a(text) ++
602   	msgs1b(text) ++
603   	msgs3525(text) ++
604   	msgs5(text) ++
605   	msgs6(text) ++
606	msgs7(text),
607    %% Msgs = msgs1a(text),
608    %% Msgs = msgs1b(text),
609    %% Msgs = msgs35525(text),
610    %% Msgs = msgs5(text),
611    %% Msgs = msgs6(text),
612    %% Msgs = msgs7(text),
613    DynamicDecode = false,
614    test_msgs(megaco_pretty_text_encoder, DynamicDecode, ?EC, Msgs).
615
616
617%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
618
619flex_pretty_init(Config) ->
620    flex_init(Config).
621
622flex_pretty_finish(Config) ->
623    flex_finish(Config).
624
625flex_pretty_test_msgs(suite) ->
626    [];
627flex_pretty_test_msgs(Config) when is_list(Config) ->
628    ?ACQUIRE_NODES(1, Config),
629    Msgs =
630	msgs1a(text) ++
631	msgs1b(text) ++
632	msgs3525(text) ++
633	msgs5(text) ++
634	msgs6(text) ++
635	msgs7(text),
636    Conf = flex_scanner_conf(Config),
637    DynamicDecode = false,
638    test_msgs(megaco_pretty_text_encoder, DynamicDecode, [?EC_V3,Conf], Msgs).
639
640
641%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
642
643compact_test_msgs(suite) ->
644    [];
645compact_test_msgs(Config) when is_list(Config) ->
646    ?ACQUIRE_NODES(1, Config),
647    Msgs =
648	msgs1a(text) ++
649	msgs1b(text) ++
650	msgs3525(text) ++
651	msgs5(text) ++
652 	msgs6(text) ++
653	msgs7(text),
654    %% Msgs = msgs7(text),
655    DynamicDecode = false,
656    test_msgs(megaco_compact_text_encoder, DynamicDecode, ?EC, Msgs).
657
658
659%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
660
661flex_compact_init(Config) ->
662    flex_init(Config).
663
664flex_compact_finish(Config) ->
665    flex_finish(Config).
666
667flex_compact_test_msgs(suite) ->
668    [];
669flex_compact_test_msgs(Config) when is_list(Config) ->
670    ?ACQUIRE_NODES(1, Config),
671    Msgs =
672	msgs1a(text) ++
673	msgs1b(text) ++
674	msgs3525(text) ++
675	msgs5(text) ++
676	msgs6(text) ++
677	msgs7(text),
678    Conf = flex_scanner_conf(Config),
679    DynamicDecode = true,
680    test_msgs(megaco_compact_text_encoder, DynamicDecode, [?EC_V3,Conf], Msgs).
681
682
683flex_compact_dm_timers1(suite) ->
684    [];
685flex_compact_dm_timers1(Config) when is_list(Config) ->
686    ?ACQUIRE_NODES(1, Config),
687    M = build_dm_timers_message("1", "2", "3"),
688    B = list_to_binary(M),
689    Conf = flex_scanner_conf(Config),
690    case decode_message(megaco_compact_text_encoder, false,
691			[?EC_V3,Conf], B) of
692	{ok, M1} when is_record(M1,'MegacoMessage') ->
693	    t("flex_compact_dm_timers1 -> "
694	      "~n   M:  ~s"
695	      "~n   M1: ~p", [M, M1]),
696	    verify_dm_timers({1,2,3}, M1);
697	Else ->
698	    exit({decode_failed, M, Else})
699    end.
700
701
702flex_compact_dm_timers2(suite) ->
703    [];
704flex_compact_dm_timers2(Config) when is_list(Config) ->
705    ?ACQUIRE_NODES(1, Config),
706    M = build_dm_timers_message("02", "03", "04"),
707    B = list_to_binary(M),
708    Conf = flex_scanner_conf(Config),
709    case decode_message(megaco_compact_text_encoder, false,
710			[?EC_V3,Conf], B) of
711	{ok, M1} when is_record(M1,'MegacoMessage') ->
712	    t("flex_compact_dm_timers2 -> "
713	      "~n   M:  ~s"
714	      "~n   M1: ~p", [M, M1]),
715	    verify_dm_timers({2,3,4}, M1);
716	Else ->
717	    exit({decode_failed, M, Else})
718    end.
719
720
721flex_compact_dm_timers3(suite) ->
722    [];
723flex_compact_dm_timers3(Config) when is_list(Config) ->
724    ?ACQUIRE_NODES(1, Config),
725    M = build_dm_timers_message("1", "02", "31"),
726    B = list_to_binary(M),
727    Conf = flex_scanner_conf(Config),
728    case decode_message(megaco_compact_text_encoder, false,
729			[?EC_V3,Conf], B) of
730	{ok, M1} when is_record(M1,'MegacoMessage') ->
731	    t("flex_compact_dm_timers3 -> "
732	      "~n   M:  ~s"
733	      "~n   M1: ~p", [M, M1]),
734	    verify_dm_timers({1,2,31}, M1);
735	Else ->
736	    exit({decode_failed, M, Else})
737    end.
738
739
740flex_compact_dm_timers4(suite) ->
741    [];
742flex_compact_dm_timers4(Config) when is_list(Config) ->
743    ?ACQUIRE_NODES(1, Config),
744    M = build_dm_timers_message("10", "21", "99"),
745    B = list_to_binary(M),
746    Conf = flex_scanner_conf(Config),
747    case decode_message(megaco_compact_text_encoder, false,
748			[?EC_V3,Conf], B) of
749	{ok, M1} when is_record(M1,'MegacoMessage') ->
750	    t("flex_compact_dm_timers4 -> "
751	      "~n   M:  ~s"
752	      "~n   M1: ~p", [M, M1]),
753	    verify_dm_timers({10,21,99}, M1);
754	Else ->
755	    exit({decode_failed, M, Else})
756    end.
757
758
759flex_compact_dm_timers5(suite) ->
760    [];
761flex_compact_dm_timers5(Config) when is_list(Config) ->
762    ?ACQUIRE_NODES(1, Config),
763    M = build_dm_timers_message("99", "23", "11"),
764    B = list_to_binary(M),
765    Conf = flex_scanner_conf(Config),
766    case decode_message(megaco_compact_text_encoder, false,
767			[?EC_V3,Conf], B) of
768	{ok, M1} when is_record(M1,'MegacoMessage') ->
769	    t("flex_compact_dm_timers5 -> "
770	      "~n   M:  ~s"
771	      "~n   M1: ~p", [M, M1]),
772	    verify_dm_timers({99,23,11}, M1);
773	Else ->
774	    exit({decode_failed, M, Else})
775    end.
776
777
778flex_compact_dm_timers6(suite) ->
779    [];
780flex_compact_dm_timers6(Config) when is_list(Config) ->
781    ?ACQUIRE_NODES(1, Config),
782    M = build_dm_timers_message("77", "09", "1"),
783    B = list_to_binary(M),
784    Conf = flex_scanner_conf(Config),
785    case decode_message(megaco_compact_text_encoder, false,
786			[?EC_V3,Conf], B) of
787	{ok, M1} when is_record(M1,'MegacoMessage') ->
788	    t("flex_compact_dm_timers6 -> "
789	      "~n   M:  ~s"
790	      "~n   M1: ~p", [M, M1]),
791	    verify_dm_timers({77,9,1}, M1);
792	Else ->
793	    exit({decode_failed, M, Else})
794    end.
795
796
797flex_compact_dm_timers7(suite) ->
798    [];
799flex_compact_dm_timers7(Config) when is_list(Config) ->
800    ?ACQUIRE_NODES(1, Config),
801    M = build_dm_timers_message("77", "09", "1", "99"),
802    B = list_to_binary(M),
803    Conf = flex_scanner_conf(Config),
804    case decode_message(megaco_compact_text_encoder, false,
805			[?EC_V3,Conf], B) of
806	{ok, M1} when is_record(M1,'MegacoMessage') ->
807	    t("flex_compact_dm_timers7 -> "
808	      "~n   M:  ~s"
809	      "~n   M1: ~p", [M, M1]),
810	    verify_dm_timers({77,9,1,99}, M1);
811	Else ->
812	    exit({decode_failed, M, Else})
813    end.
814
815
816flex_compact_dm_timers8(suite) ->
817    [];
818flex_compact_dm_timers8(Config) when is_list(Config) ->
819    ?ACQUIRE_NODES(1, Config),
820    M = build_dm_timers_message("01", "09", "01", "02"),
821    B = list_to_binary(M),
822    Conf = flex_scanner_conf(Config),
823    case decode_message(megaco_compact_text_encoder, false,
824			[?EC_V3,Conf], B) of
825	{ok, M1} when is_record(M1,'MegacoMessage') ->
826	    t("flex_compact_dm_timers8 -> "
827	      "~n   M:  ~s"
828	      "~n   M1: ~p", [M, M1]),
829	    verify_dm_timers({1,9,1,2}, M1);
830	Else ->
831	    exit({decode_failed, M, Else})
832    end.
833
834
835build_dm_timers_message(T, S, L) ->
836    TMRs = lists:flatten(io_lib:format("T:~s,S:~s,L:~s", [T, S, L])),
837    build_dm_timers_message(TMRs).
838
839build_dm_timers_message(T, S, L, Z) ->
840    TMRs = lists:flatten(io_lib:format("T:~s,S:~s,L:~s,Z:~s", [T, S, L,Z])),
841    build_dm_timers_message(TMRs).
842
843build_dm_timers_message(TMRs) ->
844    M = io_lib:format("!/" ?VERSION_STR " [123.123.123.4]:55555\nT=10001{C=-{MF=11111111/00000000/00000000{E=2223{al/on,dd/ce{DM=dialplan00}},SG{cg/rt},DM=dialplan00{~s,(0s| 00s|[1-7]xlxx|8lxxxxxxx|#xxxxxxx|*xx|9l1xxxxxxxxxx|9l011x.s)}}}}", [TMRs]),
845    lists:flatten(M).
846
847
848verify_dm_timers(TMRs, #'MegacoMessage'{mess = Mess}) ->
849    #'Message'{messageBody = Body} = Mess,
850    case get_dm_timers(Body) of
851	TMRs ->
852	    ok;
853	{error, Reason} ->
854	    exit({invalid_timer, {TMRs, Reason}});
855	TMRs1 ->
856	    exit({invalid_timer_values, {TMRs, TMRs1}})
857    end.
858
859get_dm_timers({transactions, T}) when is_list(T) ->
860    get_dm_timers1(T);
861get_dm_timers(Other) ->
862    {error, {invalid_transactions, Other}}.
863
864get_dm_timers1([{transactionRequest,T}|Ts])
865  when is_record(T,'TransactionRequest') ->
866    case get_dm_timers2(T) of
867	{ok, Timers} ->
868	    Timers;
869	_ ->
870	    get_dm_timers1(Ts)
871    end;
872get_dm_timers1([_|Ts]) ->
873    get_dm_timers1(Ts);
874get_dm_timers1([]) ->
875    {error, {no_timers, 'TransactionRequest'}}.
876
877
878get_dm_timers2(#'TransactionRequest'{actions = Actions}) when is_list(Actions) ->
879    get_dm_timers3(Actions).
880
881
882get_dm_timers3([#'ActionRequest'{commandRequests = Cmds}|Ars]) when is_list(Cmds) ->
883    case get_dm_timers4(Cmds) of
884	{ok, Timers} ->
885	    {ok, Timers};
886	_ ->
887	    get_dm_timers3(Ars)
888    end;
889get_dm_timers3([_|Ars]) ->
890    get_dm_timers3(Ars);
891get_dm_timers3([]) ->
892    {error, {no_timers, 'ActionRequest'}}.
893
894get_dm_timers4([#'CommandRequest'{command = Cmd}|Cmds]) ->
895    case get_dm_timers5(Cmd) of
896	{ok, Timers} ->
897	    {ok, Timers};
898	_ ->
899	    get_dm_timers4(Cmds)
900    end;
901get_dm_timers4([_|Cmds]) ->
902    get_dm_timers4(Cmds);
903get_dm_timers4([]) ->
904    {error, {no_timers, 'CommandRequest'}}.
905
906
907get_dm_timers5({modReq, #'AmmRequest'{descriptors = Descriptors}}) ->
908    get_dm_timers6(Descriptors);
909get_dm_timers5(R) ->
910    {error, {no_modReq, R}}.
911
912
913get_dm_timers6([{digitMapDescriptor, #'DigitMapDescriptor'{digitMapValue = Val}}|_]) ->
914    case Val of
915	#'DigitMapValue'{startTimer    = T,
916			 shortTimer    = S,
917			 longTimer     = L,
918			 durationTimer = asn1_NOVALUE} ->
919	    {ok, {T, S, L}};
920	#'DigitMapValue'{startTimer    = T,
921			 shortTimer    = S,
922			 longTimer     = L,
923			 durationTimer = Z} ->
924	    {ok, {T, S, L, Z}};
925	_ ->
926	    {error, no_value_in_dm}
927    end;
928get_dm_timers6([_|Descs]) ->
929    get_dm_timers6(Descs);
930get_dm_timers6([]) ->
931    {error, {no_timers, descriptors}}.
932
933
934%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
935
936bin_test_msgs(suite) ->
937    [];
938bin_test_msgs(Config) when is_list(Config) ->
939    ?ACQUIRE_NODES(1, Config),
940    Msgs =
941	msgs1a(binary) ++
942	msgs5(binary) ++
943	msgs6(binary) ++
944	msgs7(binary),
945    %% Msgs = msgs6(binary),
946    DynamicDecode = false,
947    test_msgs(megaco_binary_encoder, DynamicDecode, ?EC, Msgs).
948
949
950%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
951
952ber_test_msgs(suite) ->
953    [];
954ber_test_msgs(Config) when is_list(Config) ->
955    ?ACQUIRE_NODES(1, Config),
956    Msgs =
957	msgs1a(binary) ++
958	msgs5(binary) ++
959	msgs6(binary) ++
960	msgs7(binary),
961    %% Msgs = msgs7(binary),
962    DynamicDecode = false,
963    test_msgs(megaco_ber_encoder, DynamicDecode, ?EC, Msgs).
964
965
966%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
967
968per_test_msgs(suite) ->
969    [];
970per_test_msgs(Config) when is_list(Config) ->
971    ?ACQUIRE_NODES(1, Config),
972    Msgs =
973	msgs1a(binary) ++
974	msgs5(binary) ++
975	msgs6(binary) ++
976	msgs7(binary),
977    DynamicDecode = false,
978    test_msgs(megaco_per_encoder, DynamicDecode, ?EC, Msgs).
979
980
981%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
982
983erl_dist_m_test_msgs(suite) ->
984    [];
985erl_dist_m_test_msgs(Config) when is_list(Config) ->
986    ?ACQUIRE_NODES(1, Config),
987    Msgs =
988	msgs1a(erlang) ++
989	msgs1b(erlang) ++
990	msgs3525(erlang) ++
991	msgs5(erlang) ++
992	msgs6(erlang) ++
993	msgs7(erlang),
994    DynamicDecode = false,
995    Conf = [megaco_compressed],
996    test_msgs(megaco_erl_dist_encoder, DynamicDecode, Conf, Msgs).
997
998
999%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1000
1001%% # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1002%% Ticket test cases:
1003
1004
1005%% --------------------------------------------------------------
1006%% Observe that this decode SHALL fail
1007compact_otp4011_msg1(suite) ->
1008    [];
1009compact_otp4011_msg1(Config) when is_list(Config) ->
1010    %%     put(severity,trc),
1011    %%     put(dbg,true),
1012    d("compact_otp4011_msg1 -> entry", []),
1013    ?ACQUIRE_NODES(1, Config),
1014    M = "!/" ?VERSION_STR " ML T=233350{C=${A=stedevice/01{M{O{MO=SR,RV=OFF,RG=OFF,tdmc/ec=OFF,MO=SR}}}}}",
1015    ok = compact_otp4011(M),
1016    %%     erase(severity),
1017    %%     erase(dbg),
1018    ok.
1019
1020
1021%% --------------------------------------------------------------
1022%% Observe that this decode SHALL fail
1023compact_otp4011_msg2(suite) ->
1024    [];
1025compact_otp4011_msg2(Config) when is_list(Config) ->
1026    %%     put(severity,trc),
1027    %%     put(dbg,true),
1028    d("compact_otp4011_msg2 -> entry", []),
1029    ?ACQUIRE_NODES(1, Config),
1030    M = "!/" ?VERSION_STR " ML T=233350{C=${A=stedevice/01{M{O{MO=SO,RV=OFF,RG=OFF,tdmc/ec=OFF,MO=SR}}}}}",
1031    ok = compact_otp4011(M),
1032    %%     erase(severity),
1033    %%     erase(dbg),
1034    ok.
1035
1036%% --------------------------------------------------------------
1037%% Observe that this decode SHALL fail
1038%%
1039
1040compact_otp4011_msg3(suite) ->
1041    [];
1042compact_otp4011_msg3(Config) when is_list(Config) ->
1043    %%     put(severity,trc),
1044    %%     put(dbg,true),
1045    d("compact_otp4011_msg3 -> entry", []),
1046    ?ACQUIRE_NODES(1, Config),
1047    M = "!/" ?VERSION_STR " ML T=233350{C=${A=stedevice/01{M{O{MO=SR,RV=OFF,RG=OFF,tdmc/ec=OFF,MO=SO}}}}}",
1048    ok = compact_otp4011(M),
1049    %%     erase(severity),
1050    %%     erase(dbg),
1051    ok.
1052
1053compact_otp4011(Msg) ->
1054    compact_otp4011(Msg, ?EC).
1055
1056compact_otp4011(Msg, Conf) ->
1057    Codec  = megaco_compact_text_encoder,
1058    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
1059    Check  = fun(Reason) when is_list(Reason) ->
1060		     compact_otp4011_chk1(Reason);
1061		(Crap) ->
1062		     {error, {unexpected_decode_result, Crap}}
1063	     end,
1064    megaco_codec_test_lib:expect_decode(Msg, Decode, Check).
1065
1066compact_otp4011_chk1(R1) ->
1067    case lists:keysearch(reason, 1, R1) of
1068	{value, {reason, R2}} ->
1069	    compact_otp4011_chk2(R2);
1070	false ->
1071	    {error, {unexpected_result, R1}}
1072    end.
1073
1074compact_otp4011_chk2({0, ParserMod, {ParserFunc, [A, B]}})
1075  when (ParserMod  =:= megaco_text_parser_prev3c) andalso
1076       (ParserFunc =:= do_merge_control_streamParms) andalso
1077       is_list(A) andalso
1078       is_record(B, 'LocalControlDescriptor') ->
1079    SM = B#'LocalControlDescriptor'.streamMode,
1080    case lists:keysearch(mode, 1, A) of
1081	{value, {mode, _Mode}} when SM /= asn1_NOVALUE ->
1082	    ok;
1083	{value, {mode, _Mode}} ->
1084	    {error, {unexpected_streamMode_reason, {A, B}}};
1085	false ->
1086	    {error, {unexpected_mode_reason, {A, B}}}
1087    end;
1088compact_otp4011_chk2(Bad) ->
1089    {error, {unexpected_reason, Bad}}.
1090
1091
1092%% --------------------------------------------------------------
1093%% Note that this decode SHALL fail, because of the misspelled
1094%% MEGCAO instead of the correct MEGACO.
1095compact_otp4013_msg1(suite) ->
1096    [];
1097compact_otp4013_msg1(Config) when is_list(Config) ->
1098    %%     put(severity,trc),
1099    %%     put(dbg,true),
1100    d("compact_otp4013_msg1 -> entry", []),
1101    ?ACQUIRE_NODES(1, Config),
1102    M = "MEGCAO/3 MG1 T=12345678{C=-{SC=root{SV{MT=RS,RE=901}}}}",
1103    ok = compact_otp4013(M),
1104    %%     erase(severity),
1105    %%     erase(dbg),
1106    ok.
1107
1108compact_otp4013(Msg) ->
1109    compact_otp4013(Msg, ?EC).
1110
1111compact_otp4013(Msg, Conf) ->
1112    Codec  = megaco_compact_text_encoder,
1113    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
1114    Check  = fun(Reason) when is_list(Reason) ->
1115		     compact_otp4013_chk1(Reason);
1116		(Crap) ->
1117		     {error, {unexpected_decode_result, Crap}}
1118	     end,
1119    megaco_codec_test_lib:expect_decode(Msg, Decode, Check).
1120
1121compact_otp4013_chk1(Reason) ->
1122    case lists:keysearch(reason, 1, Reason) of
1123	{value, {reason, no_version_found, _}} ->
1124	    case lists:keysearch(token, 1, Reason) of
1125		{value, {token, [{'SafeChars',_,"megcao/3"}|_]}} ->
1126		    ok;
1127		{value, {token, Tokens}} ->
1128		    {error, {unexpected_tokens, Tokens}};
1129		false ->
1130		    {error, {tokens_not_found, Reason}}
1131	    end;
1132	{value, {reason, BadReason, _}} ->
1133	    {error, {unexpected_reason, BadReason}};
1134	false ->
1135	    {error, {reason_not_found, Reason}}
1136    end.
1137
1138
1139%% --------------------------------------------------------------
1140%%
1141%%
1142compact_otp4085_msg1(suite) ->
1143    [];
1144compact_otp4085_msg1(Config) when is_list(Config) ->
1145    %% put(severity,trc),
1146    %% put(dbg,true),
1147    d("compact_otp4085_msg1 -> entry", []),
1148    ?ACQUIRE_NODES(1, Config),
1149    M = compact_otp4085_erroneous_msg(),
1150    ok = compact_otp4085_1(M),
1151    %% erase(severity),
1152    %% erase(dbg),
1153    ok.
1154
1155compact_otp4085_1(Msg) ->
1156    compact_otp4085_1(Msg, ?EC).
1157
1158compact_otp4085_1(Msg, Conf) ->
1159    Codec  = megaco_compact_text_encoder,
1160    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
1161    Check  = fun(Reason) when is_list(Reason) ->
1162		     compact_otp4085_1_chk1(Reason);
1163		(Crap) ->
1164		     {error, {unexpected_decode_result, Crap}}
1165	     end,
1166    megaco_codec_test_lib:expect_decode(Msg, Decode, Check).
1167
1168compact_otp4085_1_chk1(Reason) ->
1169    case lists:keysearch(reason, 1, Reason) of
1170	{value, {reason, {Line, Module, Crap}}} when is_integer(Line) and
1171						     is_atom(Module) ->
1172	    Crap2 =
1173		case (catch lists:flatten(Crap)) of
1174		    L when is_list(L) ->
1175			L;
1176		    _ ->
1177			Crap
1178		end,
1179	    t("compact_otp4085_1_chk1 -> Expected: "
1180	      "~n   Line:   ~p"
1181	      "~n   Module: ~p"
1182	      "~n   Crap2:  ~p", [Line, Module, Crap2]),
1183	    ok;
1184	{value, BadReason} ->
1185	    e("compact_otp4085_1_chk1 -> error: "
1186	      "~n   BadReason:   ~p", [BadReason]),
1187	    {error, {unexpected_reason, Reason}};
1188	false ->
1189	    {error, {reason_not_found, Reason}}
1190    end.
1191
1192
1193%% --------------------------------------------------------------
1194%% This test case is just to show that the message used in
1195%% compact_otp4085_msg1 is actually ok when you add '}' at the end.
1196compact_otp4085_msg2(suite) ->
1197    [];
1198compact_otp4085_msg2(Config) when is_list(Config) ->
1199    %% put(severity,trc),
1200    %% put(dbg,true),
1201    d("compact_otp4085_msg1 -> entry", []),
1202    ?ACQUIRE_NODES(1, Config),
1203    M = compact_otp4085_erroneous_msg() ++ "}",
1204    ok = compact_otp4085_2(M),
1205    %% erase(severity),
1206    %% erase(dbg),
1207    ok.
1208
1209compact_otp4085_2(Msg) ->
1210    compact_otp4085_2(Msg, ?EC).
1211
1212compact_otp4085_2(Msg, Conf) ->
1213    Codec  = megaco_compact_text_encoder,
1214    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
1215    Check  = fun(M) when is_record(M, 'MegacoMessage') ->
1216		     ok;
1217		(Crap) ->
1218		     {error, {unexpected_decode_result, Crap}}
1219	     end,
1220    megaco_codec_test_lib:expect_decode_only(Msg, Decode, Check).
1221
1222
1223%% This message lack the ending parentesis (}).
1224compact_otp4085_erroneous_msg() ->
1225    M = "!/"
1226	?VERSION_STR
1227	" ML T=11223342{C=${A=${M{O{MO=SR,RV=OFF,RG=OFF},L{v=0,"
1228	"c=ATM NSAP $ ,"
1229	"a=eecid:$ ,"
1230	"m=audio - AAL1/ATMF -,"
1231	"}}},A=stee1181/01{M{O{MO=SR,RV=OFF,RG=OFF,tdmc/ec=off}}}}",
1232    M.
1233
1234%% --------------------------------------------------------------
1235%%
1236%%
1237compact_otp4280_msg1(suite) ->
1238    [];
1239compact_otp4280_msg1(Config) when is_list(Config) ->
1240    %% put(severity,trc),
1241    %% put(dbg,true),
1242    d("compact_otp4280_msg1 -> entry", []),
1243    ?ACQUIRE_NODES(1, Config),
1244    M = compact_otp4280_msg(),
1245    ok = compact_otp4280(M),
1246    %% erase(severity),
1247    %% erase(dbg),
1248    ok.
1249
1250compact_otp4280(Msg) ->
1251    compact_otp4280(Msg, ?EC).
1252
1253compact_otp4280(Msg, Conf) ->
1254    Codec  = megaco_compact_text_encoder,
1255    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
1256    Check  = fun(M) when is_record(M, 'MegacoMessage') ->
1257		     ok;
1258		(Crap) ->
1259		     {error, {unexpected_decode_result, Crap}}
1260	     end,
1261    megaco_codec_test_lib:expect_decode_only(Msg, Decode, Check).
1262
1263compact_otp4280_msg() ->
1264    M = "!/"
1265	?VERSION_STR
1266	" mgw1 P=71853646{C=-{AV=root{M{TS{root/maxnumberofcontexts=49500,"
1267	"root/maxterminationspercontext=2,root/normalmgexecutiontime=200,"
1268	"root/normalmgcexecutiontime=150,"
1269	"root/provisionalresponsetimervalue=2000,BF=OFF,SI=IV}}}}}",
1270    M.
1271
1272
1273%% --------------------------------------------------------------
1274%% This ticket is about comments in a message
1275%%
1276compact_otp4299_msg1(suite) ->
1277    [];
1278compact_otp4299_msg1(Config) when is_list(Config) ->
1279    %% put(severity,trc),
1280    %% put(dbg,true),
1281    d("compact_otp4299_msg1 -> entry", []),
1282    ?ACQUIRE_NODES(1, Config),
1283    Msg = compact_otp4299_msg(),
1284    ok = compact_otp4299(Msg),
1285    %% erase(severity),
1286    %% erase(dbg),
1287    ok.
1288
1289compact_otp4299(Msg) ->
1290    compact_otp4299(Msg, ?EC).
1291
1292compact_otp4299(Msg, Conf) ->
1293    Codec  = megaco_compact_text_encoder,
1294    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
1295    Check  = fun(M) when is_record(M, 'MegacoMessage') ->
1296		     ok;
1297		(Crap) ->
1298		     {error, {unexpected_decode_result, Crap}}
1299	     end,
1300    megaco_codec_test_lib:expect_decode_only(Msg, Decode, Check).
1301
1302compact_otp4299_msg() ->
1303    M = ";KALLE\n"
1304	"!/"
1305	?VERSION_STR
1306	" mg58_1 P=005197711{; YET ANOTHER COMMENT\n"
1307	"C=035146207{A=mg58_1_1_4_1_23/19; BEFORE COMMA\n"
1308	",; AFTER COMMA\n"
1309	"A=eph58_1/0xA4023371{M{L{\n"
1310	"v=0\n"
1311	"c=ATM NSAP 39.0102.0304.0506.0708.090a.0b58.0100.0000.0000.00\n"
1312	"m=audio - AAL1/ATMF -\n"
1313	"a=eecid:A4023371\n"
1314	"}}; HOBBE\n}; KALLE \"HOBBE \n}}"
1315	";KALLE\n\n",
1316    M.
1317
1318
1319%% --------------------------------------------------------------
1320%%
1321
1322compact_otp4359_msg1(suite) ->
1323    [];
1324compact_otp4359_msg1(Config) when is_list(Config) ->
1325    %% put(severity,trc),
1326    %% put(dbg,true),
1327    d("compact_otp4359_msg1 -> entry", []),
1328    ?ACQUIRE_NODES(1, Config),
1329    Msg = compact_otp4359_msg(),
1330    ok = compact_otp4359(Msg),
1331    %% erase(severity),
1332    %% erase(dbg),
1333    ok.
1334
1335compact_otp4359_msg() ->
1336    M = "!/" ?VERSION_STR " ml2 T={C=${A=${M{O {MO=SR,RG=OFF,RV=OFF}}}}}",
1337    M.
1338
1339compact_otp4359(Msg) ->
1340    compact_otp4359(Msg, ?EC).
1341
1342compact_otp4359(Msg, Conf) ->
1343    Codec  = megaco_compact_text_encoder,
1344    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
1345    Check  = fun(M) when is_record(M, 'MegacoMessage') ->
1346		     compact_otp4359_chk(M);
1347		(Crap) ->
1348		     {error, {unexpected_decode_result, Crap}}
1349	     end,
1350    megaco_codec_test_lib:expect_decode_only(Msg, Decode, Check).
1351
1352compact_otp4359_chk(#'MegacoMessage'{mess = Mess}) ->
1353    case Mess#'Message'.messageBody of
1354	{transactions, Trans} ->
1355	    case Trans of
1356		[{transactionRequest, TR}] ->
1357		    case TR of
1358			#'TransactionRequest'{transactionId = asn1_NOVALUE} ->
1359			    ok;
1360			_ ->
1361			    {error, {unexpected_trans_req, TR}}
1362		    end;
1363		_ ->
1364		    {error, {unexpected_trans, Trans}}
1365	    end;
1366	Body ->
1367	    {error, {unexpected_messageBody, Body}}
1368    end.
1369
1370
1371%% --------------------------------------------------------------
1372%%
1373compact_otp4920_msg0(suite) ->
1374    [];
1375compact_otp4920_msg0(Config) when is_list(Config) ->
1376    %% put(severity,trc),
1377    %% put(dbg,true),
1378    d("compact_otp4920_msg0 -> entry", []),
1379    ?ACQUIRE_NODES(1, Config),
1380    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg0() ),
1381    %% erase(severity),
1382    %% erase(dbg),
1383    ok.
1384
1385compact_otp4920_msg1(suite) ->
1386    [];
1387compact_otp4920_msg1(Config) when is_list(Config) ->
1388    %% put(severity,trc),
1389    %% put(dbg,true),
1390    d("compact_otp4920_msg1 -> entry", []),
1391    ?ACQUIRE_NODES(1, Config),
1392    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg1() ),
1393    %% erase(severity),
1394    %% erase(dbg),
1395    ok.
1396
1397compact_otp4920_msg2(suite) ->
1398    [];
1399compact_otp4920_msg2(Config) when is_list(Config) ->
1400    %% put(severity,trc),
1401    %% put(dbg,true),
1402    d("compact_otp4920_msg2 -> entry", []),
1403    ?ACQUIRE_NODES(1, Config),
1404    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg2() ),
1405    %% erase(severity),
1406    %% erase(dbg),
1407    ok.
1408
1409compact_otp4920_msg3(suite) ->
1410    [];
1411compact_otp4920_msg3(Config) when is_list(Config) ->
1412    %% put(severity,trc),
1413    %% put(dbg,true),
1414    d("compact_otp4920_msg3 -> entry", []),
1415    ?ACQUIRE_NODES(1, Config),
1416    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg3() ),
1417    %% erase(severity),
1418    %% erase(dbg),
1419    ok.
1420
1421compact_otp4920_msg4(suite) ->
1422    [];
1423compact_otp4920_msg4(Config) when is_list(Config) ->
1424    %% put(severity,trc),
1425    %% put(dbg,true),
1426    d("compact_otp4920_msg4 -> entry", []),
1427    ?ACQUIRE_NODES(1, Config),
1428    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg4() ),
1429    %% erase(severity),
1430    %% erase(dbg),
1431    ok.
1432
1433compact_otp4920_msg5(suite) ->
1434    [];
1435compact_otp4920_msg5(Config) when is_list(Config) ->
1436    %% put(severity,trc),
1437    %% put(dbg,true),
1438    d("compact_otp4920_msg5 -> entry", []),
1439    ?ACQUIRE_NODES(1, Config),
1440    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg5() ),
1441    %% erase(severity),
1442    %% erase(dbg),
1443    ok.
1444
1445compact_otp4920_msg6(suite) ->
1446    [];
1447compact_otp4920_msg6(Config) when is_list(Config) ->
1448    %% put(severity,trc),
1449    %% put(dbg,true),
1450    d("compact_otp4920_msg6 -> entry", []),
1451    ?ACQUIRE_NODES(1, Config),
1452    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg6() ),
1453    %% erase(severity),
1454    %% erase(dbg),
1455    ok.
1456
1457compact_otp4920_msg7(suite) ->
1458    [];
1459compact_otp4920_msg7(Config) when is_list(Config) ->
1460    %% put(severity,trc),
1461    %% put(dbg,true),
1462    d("compact_otp4920_msg7 -> entry", []),
1463    ?ACQUIRE_NODES(1, Config),
1464    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg7() ),
1465    %% erase(severity),
1466    %% erase(dbg),
1467    ok.
1468
1469compact_otp4920_msg8(suite) ->
1470    [];
1471compact_otp4920_msg8(Config) when is_list(Config) ->
1472    %% put(severity,trc),
1473    %% put(dbg,true),
1474    d("compact_otp4920_msg8 -> entry", []),
1475    ?ACQUIRE_NODES(1, Config),
1476    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg8() ),
1477    %% erase(severity),
1478    %% erase(dbg),
1479    ok.
1480
1481compact_otp4920_msg9(suite) ->
1482    [];
1483compact_otp4920_msg9(Config) when is_list(Config) ->
1484    %% put(severity,trc),
1485    %% put(dbg,true),
1486    d("compact_otp4920_msg9 -> entry", []),
1487    ?ACQUIRE_NODES(1, Config),
1488    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg9() ),
1489    %% erase(severity),
1490    %% erase(dbg),
1491    ok.
1492
1493compact_otp4920_msg10(suite) ->
1494    [];
1495compact_otp4920_msg10(Config) when is_list(Config) ->
1496    %% put(severity,trc),
1497    %% put(dbg,true),
1498    d("compact_otp4920_msg10 -> entry", []),
1499    ?ACQUIRE_NODES(1, Config),
1500    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg10() ),
1501    %% erase(severity),
1502    %% erase(dbg),
1503    ok.
1504
1505compact_otp4920_msg11(suite) ->
1506    [];
1507compact_otp4920_msg11(Config) when is_list(Config) ->
1508    %% put(severity,trc),
1509    %% put(dbg,true),
1510    d("compact_otp4920_msg11 -> entry", []),
1511    ?ACQUIRE_NODES(1, Config),
1512    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg11() ),
1513    %% erase(severity),
1514    %% erase(dbg),
1515    ok.
1516
1517compact_otp4920_msg12(suite) ->
1518    [];
1519compact_otp4920_msg12(Config) when is_list(Config) ->
1520    %% put(severity,trc),
1521    %% put(dbg,true),
1522    d("compact_otp4920_msg12 -> entry", []),
1523    ?ACQUIRE_NODES(1, Config),
1524    ok = ticket_compact_decode_encode_ok( compact_otp4920_msg12() ),
1525    %% erase(severity),
1526    %% erase(dbg),
1527    ok.
1528
1529%% Duplicate padding
1530compact_otp4920_msg20(suite) ->
1531    [];
1532compact_otp4920_msg20(Config) when is_list(Config) ->
1533    %% put(severity,trc),
1534    %% put(dbg,true),
1535    d("compact_otp4920_msg20 -> entry", []),
1536    ?ACQUIRE_NODES(1, Config),
1537    ok = compact_otp4920(compact_otp4920_msg20(), bad_mid_duplicate_padding),
1538    %% erase(severity),
1539    %% erase(dbg),
1540    ok.
1541
1542%% Length
1543compact_otp4920_msg21(suite) ->
1544    [];
1545compact_otp4920_msg21(Config) when is_list(Config) ->
1546    %% put(severity,trc),
1547    %% put(dbg,true),
1548    d("compact_otp4920_msg21 -> entry", []),
1549    ?ACQUIRE_NODES(1, Config),
1550    ok = compact_otp4920(compact_otp4920_msg21(), bad_mid_ip6addr_length),
1551    %% erase(severity),
1552    %% erase(dbg),
1553    ok.
1554
1555%% Length
1556compact_otp4920_msg22(suite) ->
1557    [];
1558compact_otp4920_msg22(Config) when is_list(Config) ->
1559    %% put(severity,trc),
1560    %% put(dbg,true),
1561    d("compact_otp4920_msg22 -> entry", []),
1562    ?ACQUIRE_NODES(1, Config),
1563    ok = compact_otp4920(compact_otp4920_msg22(), bad_mid_ip6addr_length),
1564    %% erase(severity),
1565    %% erase(dbg),
1566    ok.
1567
1568%% Length
1569compact_otp4920_msg23(suite) ->
1570    [];
1571compact_otp4920_msg23(Config) when is_list(Config) ->
1572    %% put(severity,trc),
1573    %% put(dbg,true),
1574    d("compact_otp4920_msg23 -> entry", []),
1575    ?ACQUIRE_NODES(1, Config),
1576    ok = compact_otp4920(compact_otp4920_msg23(), bad_mid_ip6addr_length),
1577    %% erase(severity),
1578    %% erase(dbg),
1579    ok.
1580
1581%% Length
1582compact_otp4920_msg24(suite) ->
1583    [];
1584compact_otp4920_msg24(Config) when is_list(Config) ->
1585    %% put(severity,trc),
1586    %% put(dbg,true),
1587    d("compact_otp4920_msg24 -> entry", []),
1588    ?ACQUIRE_NODES(1, Config),
1589    ok = compact_otp4920(compact_otp4920_msg24(), bad_mid_ip6addr_length),
1590    %% erase(severity),
1591    %% erase(dbg),
1592    ok.
1593
1594%% Length
1595compact_otp4920_msg25(suite) ->
1596    [];
1597compact_otp4920_msg25(Config) when is_list(Config) ->
1598    %% put(severity,trc),
1599    %% put(dbg,true),
1600    d("compact_otp4920_msg25 -> entry", []),
1601    ?ACQUIRE_NODES(1, Config),
1602    ok = compact_otp4920(compact_otp4920_msg25(), bad_mid_ip6addr_length),
1603    %% erase(severity),
1604    %% erase(dbg),
1605    ok.
1606
1607
1608compact_otp4920(Msg, ExpectedReason) ->
1609    compact_otp4920(Msg, ?EC, ExpectedReason).
1610
1611compact_otp4920(Msg, Conf, ExpectedReason) ->
1612    Codec  = megaco_compact_text_encoder,
1613    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
1614    Check  = fun(Reason) when is_list(Reason) ->
1615		     compact_otp4920_chk(Reason, ExpectedReason);
1616		(Crap) ->
1617		     {error, {unexpected_decode_result, Crap}}
1618	     end,
1619    megaco_codec_test_lib:expect_decode(Msg, Decode, Check).
1620
1621compact_otp4920_chk(Reason, ExpectedReason) ->
1622    case lists:keysearch(reason, 1, Reason) of
1623	{value, {reason, {__Line, _Mod, ActualReason}}} ->
1624	    case element(1, ActualReason) of
1625		ExpectedReason ->
1626		    ok;
1627		_ ->
1628		    {error, {unexpected_decode_reason,
1629			     {ActualReason, ExpectedReason}}}
1630	    end;
1631	{value, {reason, {_Mod, ActualReason}}} ->
1632	    case element(1, ActualReason) of
1633		ExpectedReason ->
1634		    ok;
1635		_ ->
1636		    {error, {unexpected_decode_reason,
1637			     {ActualReason, ExpectedReason}}}
1638	    end;
1639	{value, UnknownReason} ->
1640	    {error, {unexpected_decode_reason, UnknownReason}};
1641	false ->
1642	    {error, {reason_not_found, Reason}}
1643    end.
1644
1645compact_otp4920_msg0() ->
1646    M = "!/" ?VERSION_STR " [192.168.30.1]\nT=100{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1647    M.
1648
1649compact_otp4920_msg1() ->
1650    M = "!/" ?VERSION_STR " [2031:0000:130F:0000:0000:09C0:876A:130B]\nT=101{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1651    M.
1652
1653compact_otp4920_msg2() ->
1654    M = "!/" ?VERSION_STR " [2031:0:130F:0:0:9C0:876A:130B]\nT=102{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1655    M.
1656
1657compact_otp4920_msg3() ->
1658    M = "!/" ?VERSION_STR " [2031:0:130F::9C0:876A:130B]\nT=103{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1659    M.
1660
1661compact_otp4920_msg4() ->
1662    M = "!/" ?VERSION_STR " [::1]\nT=104{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1663    M.
1664
1665compact_otp4920_msg5() ->
1666    M = "!/" ?VERSION_STR " [::]\nT=105{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1667    M.
1668
1669compact_otp4920_msg6() ->
1670    M = "!/" ?VERSION_STR " [1::]\nT=106{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1671    M.
1672
1673compact_otp4920_msg7() ->
1674    M = "!/" ?VERSION_STR " [FEDC:1::]\nT=107{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1675    M.
1676
1677compact_otp4920_msg8() ->
1678    M = "!/" ?VERSION_STR " [2031:0:130F:0:0:9C0:135.106.19.11]\nT=108{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1679    M.
1680
1681compact_otp4920_msg9() ->
1682    M = "!/" ?VERSION_STR " [2031:0:130F::9C0:135.106.19.11]\nT=109{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1683    M.
1684
1685compact_otp4920_msg10() ->
1686    M = "!/" ?VERSION_STR " [::FFFF:192.168.30.1]\nT=110{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1687    M.
1688
1689compact_otp4920_msg11() ->
1690    M = "!/" ?VERSION_STR " [::192.168.30.1]\nT=111{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1691    M.
1692
1693compact_otp4920_msg12() ->
1694    M = "!/" ?VERSION_STR " [::C0A8:1E01]\nT=112{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1695    M.
1696
1697%% Illegal: only one :: allowed
1698compact_otp4920_msg20() ->
1699    M = "!/" ?VERSION_STR " [2031::130F::9C0]\nT=120{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1700    M.
1701
1702%% Illegal: length
1703compact_otp4920_msg21() ->
1704    M = "!/" ?VERSION_STR " [2031:FFEE:0000:130F:0000:0000:09C0:876A:130B]\nT=121{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1705    M.
1706
1707%% Illegal: length
1708compact_otp4920_msg22() ->
1709    M = "!/" ?VERSION_STR " [2031:FFEE:0:130F:0:0:9C0:135.106.19.11]\nT=122{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1710    M.
1711
1712%% Illegal: length
1713compact_otp4920_msg23() ->
1714    M = "!/" ?VERSION_STR " [2031:FFEE:0000:130F:2132:4354::09C0:876A:130B]\nT=123{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1715    M.
1716
1717%% Illegal: length
1718compact_otp4920_msg24() ->
1719    M = "!/" ?VERSION_STR " [::2031:FFEE:0000:130F:2132:4354:09C0:876A:130B]\nT=124{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1720    M.
1721
1722%% Illegal: length
1723compact_otp4920_msg25() ->
1724    M = "!/" ?VERSION_STR " [2031:FFEE:0000:130F:2132:4354:09C0:876A:130B::]\nT=125{C=${A=${M{O{MO=SR,RG=OFF,RV=OFF}}}}}",
1725    M.
1726
1727
1728%% --------------------------------------------------------------
1729%%
1730
1731compact_otp5186_msg01(suite) ->
1732    [];
1733compact_otp5186_msg01(Config) when is_list(Config) ->
1734    %% put(severity,trc),
1735    %% put(dbg,true),
1736    d("compact_otp5186_msg01 -> entry", []),
1737    ?ACQUIRE_NODES(1, Config),
1738    ok = ticket_compact_decode_error( compact_otp5186_msg01() ),
1739    %% erase(severity),
1740    %% erase(dbg),
1741    ok.
1742
1743compact_otp5186_msg02(suite) ->
1744    [];
1745compact_otp5186_msg02(Config) when is_list(Config) ->
1746    %% put(severity,trc),
1747    %% put(dbg,true),
1748    d("compact_otp5186_msg02 -> entry", []),
1749    ?ACQUIRE_NODES(1, Config),
1750    ok = ticket_compact_decode_encode_ok( compact_otp5186_msg02() ),
1751    %% erase(severity),
1752    %% erase(dbg),
1753    ok.
1754
1755compact_otp5186_msg03(suite) ->
1756    [];
1757compact_otp5186_msg03(Config) when is_list(Config) ->
1758    %% put(severity,trc),
1759    %% put(dbg,true),
1760    d("compact_otp5186_msg03 -> entry", []),
1761    ?ACQUIRE_NODES(1, Config),
1762    %% ok = compact_otp5186_msg_2(compact_otp5186_msg03(), ok, ok),
1763    ok = ticket_compact_encode_decode_ok( compact_otp5186_msg03() ),
1764    %% erase(severity),
1765    %% erase(dbg),
1766    ok.
1767
1768compact_otp5186_msg04(suite) ->
1769    [];
1770compact_otp5186_msg04(Config) when is_list(Config) ->
1771    %% put(severity,trc),
1772    %% put(dbg,true),
1773    d("compact_otp5186_msg04 -> entry", []),
1774    ?ACQUIRE_NODES(1, Config),
1775    %% ok = compact_otp5186_msg_2(compact_otp5186_msg04(), ok, ok),
1776    ok = ticket_compact_encode_decode_ok( compact_otp5186_msg04() ),
1777    %% erase(severity),
1778    %% erase(dbg),
1779    ok.
1780
1781compact_otp5186_msg05(suite) ->
1782    [];
1783compact_otp5186_msg05(Config) when is_list(Config) ->
1784    %% put(severity,trc),
1785    %% put(dbg,true),
1786    d("compact_otp5186_msg05 -> entry", []),
1787    ?ACQUIRE_NODES(1, Config),
1788    %% ok = compact_otp5186_msg_2(compact_otp5186_msg05(), ok, ok),
1789    ok = ticket_compact_encode_decode_ok( compact_otp5186_msg05() ),
1790    %% erase(severity),
1791    %% erase(dbg),
1792    ok.
1793
1794compact_otp5186_msg06(suite) ->
1795    [];
1796compact_otp5186_msg06(Config) when is_list(Config) ->
1797    %% put(severity,trc),
1798    %% put(dbg,true),
1799    d("compact_otp5186_msg06 -> entry", []),
1800    ?ACQUIRE_NODES(1, Config),
1801    %% ok = compact_otp5186_msg_2(compact_otp5186_msg06(), ok, ok),
1802    ok = ticket_compact_encode_decode_ok( compact_otp5186_msg06() ),
1803    %% erase(severity),
1804    %% erase(dbg),
1805    ok.
1806
1807%% --
1808
1809compact_otp5186_msg01() ->
1810    "!/" ?VERSION_STR " <mg5>\nP=67111298{C=2699{AV=mg5_ipeph/0x0f0001{}}}".
1811
1812compact_otp5186_msg02() ->
1813    "!/" ?VERSION_STR " <mg5>\nP=67111298{C=2699{AV=mg5_ipeph/0x0f0001}}".
1814
1815compact_otp5186_msg03() ->
1816    {'MegacoMessage',
1817     asn1_NOVALUE,
1818     {'Message',
1819      ?VERSION,
1820      {domainName,{'DomainName',"mg5",asn1_NOVALUE}},
1821      {transactions,
1822       [{transactionReply,
1823	 {'TransactionReply',67111298,asn1_NOVALUE,
1824	  {actionReplies,[
1825			  {'ActionReply',2699,asn1_NOVALUE,asn1_NOVALUE,
1826			   [
1827			    {auditValueReply,
1828			     {auditResult,
1829			      {'AuditResult',
1830			       {megaco_term_id,false,["mg5_ipeph","0x0f0001"]},
1831			       [
1832			       ]
1833			      }
1834			     }
1835			    }
1836			   ]
1837			  }
1838			 ]
1839	  },asn1_NOVALUE,asn1_NOVALUE
1840	 }
1841	}
1842       ]
1843      }
1844     }
1845    }.
1846
1847compact_otp5186_msg04() ->
1848    {'MegacoMessage',asn1_NOVALUE,
1849     {'Message',?VERSION,{domainName,{'DomainName',"mg5",asn1_NOVALUE}},
1850      {transactions,
1851       [{transactionReply,
1852	 {'TransactionReply',67111298,asn1_NOVALUE,
1853	  {actionReplies,[
1854			  {'ActionReply',2699,asn1_NOVALUE,asn1_NOVALUE,
1855			   [
1856			    {auditValueReply,
1857			     {auditResult,
1858			      {'AuditResult',
1859			       {megaco_term_id,false,["mg5_ipeph","0x0f0001"]},
1860			       [
1861				{emptyDescriptors,
1862				 {'AuditDescriptor',asn1_NOVALUE,asn1_NOVALUE}
1863				}
1864			       ]
1865			      }
1866			     }
1867			    }
1868			   ]
1869			  }
1870			 ]
1871	  },asn1_NOVALUE,asn1_NOVALUE
1872	 }
1873	}
1874       ]
1875      }
1876     }
1877    }.
1878
1879compact_otp5186_msg05() ->
1880    {'MegacoMessage',
1881     asn1_NOVALUE,
1882     {'Message',
1883      ?VERSION,
1884      {domainName,{'DomainName',"mg5",asn1_NOVALUE}},
1885      {transactions,
1886       [{transactionReply,
1887	 {'TransactionReply',67111298,asn1_NOVALUE,
1888	  {actionReplies,[
1889			  {'ActionReply',2699,asn1_NOVALUE,asn1_NOVALUE,
1890			   [
1891			    {addReply,
1892			     {'AmmsReply',
1893			      [
1894			       {megaco_term_id,false,["mg5_ipeph","0x0f0001"]}
1895			      ],
1896			      [
1897			      ]
1898			     }
1899			    }
1900			   ]
1901			  }
1902			 ]
1903	  },asn1_NOVALUE,asn1_NOVALUE
1904	 }
1905	}
1906       ]
1907      }
1908     }
1909    }.
1910
1911compact_otp5186_msg06() ->
1912    {'MegacoMessage',asn1_NOVALUE,
1913     {'Message',?VERSION,{domainName,{'DomainName',"mg5",asn1_NOVALUE}},
1914      {transactions,
1915       [{transactionReply,
1916	 {'TransactionReply',67111298,asn1_NOVALUE,
1917	  {actionReplies,[
1918			  {'ActionReply',2699,asn1_NOVALUE,asn1_NOVALUE,
1919			   [
1920			    {addReply,
1921			     {'AmmsReply',
1922			      [
1923			       {megaco_term_id,false,["mg5_ipeph","0x0f0001"]}
1924			      ],
1925			      [
1926			       {emptyDescriptors,
1927				{'AuditDescriptor',asn1_NOVALUE,asn1_NOVALUE}
1928			       }
1929			      ]
1930			     }
1931			    }
1932			   ]
1933			  }
1934			 ]
1935	  },asn1_NOVALUE,asn1_NOVALUE
1936	 }
1937	}
1938       ]
1939      }
1940     }
1941    }.
1942
1943
1944%% --------------------------------------------------------------
1945
1946compact_otp5793_msg01(suite) ->
1947    [];
1948compact_otp5793_msg01(Config) when is_list(Config) ->
1949    %% put(severity,trc),
1950    %% put(dbg,true),
1951    d("compact_otp5793_msg01 -> entry", []),
1952    ?ACQUIRE_NODES(1, Config),
1953    ok = ticket_compact_encode_decode_ok(pretty_otp5793_msg1()),
1954    %% erase(severity),
1955    %% erase(dbg),
1956    ok.
1957
1958
1959%% --------------------------------------------------------------
1960
1961compact_otp5836_msg01(suite) ->
1962    [];
1963compact_otp5836_msg01(Config) when is_list(Config) ->
1964    %%     put(severity,trc),
1965    %%     put(dbg,true),
1966    d("compact_otp5836_msg01 -> entry", []),
1967    ?ACQUIRE_NODES(1, Config),
1968    ok = ticket_compact_encode_decode_ok(compact_otp5836_msg1()),
1969    %% erase(severity),
1970    %% erase(dbg),
1971    ok.
1972
1973
1974compact_otp5836_msg1() ->
1975    {'MegacoMessage',
1976     asn1_NOVALUE,
1977     {'Message',
1978      3,
1979      {deviceName,"bs_sbg_4/34"},
1980      {transactions,
1981       [{transactionReply,
1982	 {'TransactionReply',
1983	  12,
1984	  asn1_NOVALUE,
1985	  {actionReplies,
1986	   [{'ActionReply',
1987	     4294967295,
1988	     asn1_NOVALUE,
1989	     asn1_NOVALUE,
1990	     [{auditValueReply,
1991	       {error, {'ErrorDescriptor', 431, asn1_NOVALUE}}}
1992	     ]
1993	    }
1994	   ]
1995	  },asn1_NOVALUE,asn1_NOVALUE
1996	 }
1997	}
1998       ]
1999      }
2000     }
2001    }.
2002
2003
2004%% --------------------------------------------------------------
2005
2006compact_otp5993_msg01(suite) ->
2007    [];
2008compact_otp5993_msg01(Config) when is_list(Config) ->
2009    %% put(severity,trc),
2010    %% put(dbg,true),
2011    d("compact_otp5993_msg01 -> entry", []),
2012    ?ACQUIRE_NODES(1, Config),
2013    ok = ticket_compact_encode_decode_ok( compact_otp5993_msg01() ),
2014    %% erase(severity),
2015    %% erase(dbg),
2016    ok.
2017
2018compact_otp5993_msg01() ->
2019    MT = h221,
2020    T  = #megaco_term_id{id = ?A4444},
2021    TL = [T],
2022    MD = #'MuxDescriptor'{muxType  = MT,
2023                          termList = TL},
2024    compact_otp5993_msg(MD).
2025
2026
2027compact_otp5993_msg02(suite) ->
2028    [];
2029compact_otp5993_msg02(Config) when is_list(Config) ->
2030    %% put(severity,trc),
2031    %% put(dbg,true),
2032    d("compact_otp5993_msg02 -> entry", []),
2033    ?ACQUIRE_NODES(1, Config),
2034    ok = ticket_compact_encode_decode_ok( compact_otp5993_msg02() ),
2035    %% erase(severity),
2036    %% erase(dbg),
2037    ok.
2038
2039compact_otp5993_msg02() ->
2040    MT = h223,
2041    T1 = #megaco_term_id{id = ?A4445},
2042    T2 = #megaco_term_id{id = ?A5556},
2043    TL = [T1, T2],
2044    MD = #'MuxDescriptor'{muxType  = MT,
2045                          termList = TL},
2046    compact_otp5993_msg(MD).
2047
2048
2049compact_otp5993_msg03(suite) ->
2050    [];
2051compact_otp5993_msg03(Config) when is_list(Config) ->
2052    %% put(severity,trc),
2053    %% put(dbg,true),
2054    d("compact_otp5993_msg03 -> entry", []),
2055    ?ACQUIRE_NODES(1, Config),
2056    ok = ticket_compact_encode_decode_ok( compact_otp5993_msg03() ),
2057    %% erase(severity),
2058    %% erase(dbg),
2059    ok.
2060
2061compact_otp5993_msg03() ->
2062    T1       = #megaco_term_id{id = ?A4445},
2063    T2       = #megaco_term_id{id = ?A5556},
2064    TIDs     = [T1, T2],
2065    AudRep   = {contextAuditResult, TIDs},
2066    CmdRep   = {auditValueReply, AudRep},
2067    ActRep   = #'ActionReply'{contextId    = 5993,
2068                              commandReply = [CmdRep]},
2069    TransRes = {actionReplies, [ActRep]},
2070    TransRep = #'TransactionReply'{transactionId     = 3995,
2071                                   transactionResult = TransRes},
2072    Trans    = {transactionReply, TransRep},
2073    Body     = {transactions, [Trans]},
2074    Msg      = #'Message'{version     = ?VERSION,
2075                          mId         = ?MG1_MID,
2076                          messageBody = Body},
2077    #'MegacoMessage'{mess = Msg}.
2078
2079
2080compact_otp5993_msg(MD) when is_record(MD, 'MuxDescriptor') ->
2081    AmmDesc  = {muxDescriptor, MD},
2082    AmmReq   = #'AmmRequest'{terminationID = [hd(MD#'MuxDescriptor'.termList)],
2083                             descriptors   = [AmmDesc]},
2084    Cmd      = {addReq, AmmReq},
2085    CmdReq   = #'CommandRequest'{command = Cmd},
2086    ActReq   = #'ActionRequest'{contextId       = 5993,
2087                                commandRequests = [CmdReq]},
2088    TransReq = #'TransactionRequest'{transactionId = 3995,
2089                                     actions       = [ActReq]},
2090    Trans    = {transactionRequest, TransReq},
2091    Body     = {transactions, [Trans]},
2092    Msg      = #'Message'{version = ?VERSION,
2093                          mId     = ?MG1_MID,
2094                          messageBody = Body},
2095    #'MegacoMessage'{mess = Msg}.
2096
2097
2098%% --------------------------------------------------------------
2099
2100compact_otp6017_msg01(suite) ->
2101    [];
2102compact_otp6017_msg01(Config) when is_list(Config) ->
2103    d("compact_otp6017_msg01 -> entry", []),
2104    ?ACQUIRE_NODES(1, Config),
2105    ok = compact_otp6017(0),
2106    ok.
2107
2108compact_otp6017_msg02(suite) ->
2109    [];
2110compact_otp6017_msg02(Config) when is_list(Config) ->
2111    d("compact_otp6017_msg02 -> entry", []),
2112    ?ACQUIRE_NODES(1, Config),
2113    ok = compact_otp6017(16#FFFFFFFE),
2114    ok.
2115
2116compact_otp6017_msg03(suite) ->
2117    [];
2118compact_otp6017_msg03(Config) when is_list(Config) ->
2119    d("compact_otp6017_msg03 -> entry", []),
2120    ?ACQUIRE_NODES(1, Config),
2121    ok = compact_otp6017(16#FFFFFFFF),
2122    ok.
2123
2124compact_otp6017(BadCID) ->
2125    Conf = ?EC,
2126    M   = compact_otp6017_msg(BadCID),
2127    Bin = list_to_binary(M),
2128    case decode_message(megaco_compact_text_encoder, false, Conf, Bin) of
2129        {ok, Msg} ->
2130            exit({unexpected_decode_success, {Msg, M}});
2131        {error, Reason} when is_list(Reason) -> % Expected result
2132            case lists:keysearch(reason, 1, Reason) of
2133                {value, {reason, {_Line, _Mod, {bad_ContextID, BadCID}}}} ->
2134                    io:format(" ~w", [BadCID]),
2135                    ok;
2136                {value, {reason, ActualReason}} ->
2137                    exit({unexpected_reason, ActualReason});
2138                false ->
2139                    exit({reason_not_found, Reason})
2140            end;
2141        Crap ->
2142            exit({unexpected_decode_result, Crap})
2143    end.
2144
2145compact_otp6017_msg(CID) when is_integer(CID) ->
2146    "MEGACO/" ?VERSION_STR " MG1 T=12345678{C=" ++
2147        integer_to_list(CID) ++
2148        "{SC=root{SV{MT=RS,RE=901}}}}".
2149
2150
2151%% ==============================================================
2152%%
2153%% F l e x   C o m p a c t   T e s t c a s e s
2154%%
2155
2156flex_compact_otp4299_msg1(suite) ->
2157    [];
2158flex_compact_otp4299_msg1(Config) when is_list(Config) ->
2159    %% put(severity,trc),
2160    %% put(dbg,true),
2161    d("flex_comppact_otp4299_msg1 -> entry", []),
2162    ?ACQUIRE_NODES(1, Config),
2163    Msg  = compact_otp4299_msg(),
2164    Conf = flex_scanner_conf(Config),
2165    ok = compact_otp4299(Msg, [?EC_V3,Conf]),
2166    %% erase(severity),
2167    %% erase(dbg),
2168    ok.
2169
2170
2171flex_compact_otp7431_msg01(suite) ->
2172    [];
2173flex_compact_otp7431_msg01(Config) when is_list(Config) ->
2174    %% put(severity,trc),
2175    %% put(dbg,true),
2176    d("flex_comppact_otp7431_msg01 -> entry", []),
2177    Conf = flex_scanner_conf(Config),
2178    flex_compact_otp7431(ok, flex_compact_otp7431_msg1(), [Conf]).
2179
2180flex_compact_otp7431_msg02(suite) ->
2181    [];
2182flex_compact_otp7431_msg02(Config) when is_list(Config) ->
2183    %% put(severity,trc),
2184    %% put(dbg,true),
2185    d("flex_comppact_otp7431_msg02 -> entry", []),
2186    Conf = flex_scanner_conf(Config),
2187    flex_compact_otp7431(error, flex_compact_otp7431_msg2(), [Conf]).
2188
2189flex_compact_otp7431_msg03(suite) ->
2190    [];
2191flex_compact_otp7431_msg03(Config) when is_list(Config) ->
2192    %% put(severity,trc),
2193    %% put(dbg,true),
2194    d("flex_comppact_otp7431_msg03 -> entry", []),
2195    Conf = flex_scanner_conf(Config),
2196    flex_compact_otp7431(error, flex_compact_otp7431_msg3(), [Conf]).
2197
2198flex_compact_otp7431_msg04(suite) ->
2199    [];
2200flex_compact_otp7431_msg04(Config) when is_list(Config) ->
2201    %% put(severity,trc),
2202    %% put(dbg,true),
2203    d("flex_comppact_otp7431_msg04 -> entry", []),
2204    Conf = flex_scanner_conf(Config),
2205    flex_compact_otp7431(error, flex_compact_otp7431_msg4(), [Conf]).
2206
2207flex_compact_otp7431_msg05(suite) ->
2208    [];
2209flex_compact_otp7431_msg05(Config) when is_list(Config) ->
2210    %% put(severity,trc),
2211    %% put(dbg,true),
2212    d("flex_comppact_otp7431_msg05 -> entry", []),
2213    Conf = flex_scanner_conf(Config),
2214    flex_compact_otp7431(error, flex_compact_otp7431_msg5(), [Conf]).
2215
2216flex_compact_otp7431_msg06(suite) ->
2217    [];
2218flex_compact_otp7431_msg06(Config) when is_list(Config) ->
2219    %% put(severity,trc),
2220    %% put(dbg,true),
2221    d("flex_comppact_otp7431_msg06 -> entry", []),
2222    Conf = flex_scanner_conf(Config),
2223    flex_compact_otp7431(error, flex_compact_otp7431_msg6(), [Conf]).
2224
2225flex_compact_otp7431_msg07(suite) ->
2226    [];
2227flex_compact_otp7431_msg07(Config) when is_list(Config) ->
2228    %% put(severity,trc),
2229    %% put(dbg,true),
2230    d("flex_comppact_otp7431_msg07 -> entry", []),
2231    Conf = flex_scanner_conf(Config),
2232    flex_compact_otp7431(error, flex_compact_otp7431_msg7(), [Conf]).
2233
2234
2235flex_compact_otp7431(Expected, Msg, Conf) ->
2236    otp7431(Expected, megaco_compact_text_encoder, Msg, Conf).
2237
2238flex_compact_otp7431_msg1() ->
2239    "!/1 [124.124.124.222]:55555
2240P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
2241v=0
2242o=- 2890844526 2890842807 IN IP4 124.124.124.222
2243s=-
2244t= 0 0
2245c=IN IP4 124.124.124.222
2246m=audio 2222 RTP/AVP 4
2247a=ptime:30
2248a=recvonly
2249}}}}}}".
2250
2251flex_compact_otp7431_msg2() ->
2252    "!/1 [124.124.124.222]:55555
2253P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
2254v=0
2255o=- 2890844526 2890842807 IN IP4 124.124.124.222
2256s=-
2257t= 0 0
2258c=IN IP4 124.124.124.222
2259m=audio 2222 RTP/AVP 4
2260a=ptime:30
2261a=     }
2262}}}}}".
2263
2264
2265flex_compact_otp7431_msg3() ->
2266    "!/1 [124.124.124.222]:55555
2267P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
2268v=0
2269o=- 2890844526 2890842807 IN IP4 124.124.124.222
2270s=-
2271t= 0 0
2272c=IN IP4 124.124.124.222
2273m=audio 2222 RTP/AVP 4
2274a=ptime:30
2275a     }
2276}}}}}".
2277
2278
2279flex_compact_otp7431_msg4() ->
2280    "!/1 [124.124.124.222]:55555
2281P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
2282v=0
2283o=- 2890844526 2890842807 IN IP4 124.124.124.222
2284s=-
2285t= 0 0
2286c=IN IP4 124.124.124.222
2287m=audio 2222 RTP/AVP 4
2288a=ptime:30
2289a}
2290}}}}}".
2291
2292
2293flex_compact_otp7431_msg5() ->
2294    "!/1 [124.124.124.222]:55555
2295P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
2296v=       }
2297}}}}}".
2298
2299
2300flex_compact_otp7431_msg6() ->
2301    "!/1 [124.124.124.222]:55555
2302P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
2303v       }
2304}}}}}".
2305
2306flex_compact_otp7431_msg7() ->
2307    "!/1 [124.124.124.222]:55555
2308P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
2309v}
2310}}}}}".
2311
2312
2313%% ==============================================================
2314%%
2315%% P r e t t y   T e s t c a s e s
2316%%
2317
2318pretty_otp4632_msg1(suite) ->
2319    [];
2320pretty_otp4632_msg1(Config) when is_list(Config) ->
2321    %% put(severity,trc),
2322    %% put(dbg,true),
2323    d("pretty_otp4632_msg1 -> entry", []),
2324    ?ACQUIRE_NODES(1, Config),
2325    ok = ticket_pretty_encode_decode_ok( pretty_otp4632_msg1() ),
2326    %% erase(severity),
2327    %% erase(dbg),
2328    ok.
2329
2330pretty_otp4632_msg1() ->
2331    msg4(?MG1_MID_NO_PORT, "901 mg col boot").
2332
2333pretty_otp4632_msg2(suite) ->
2334    [];
2335pretty_otp4632_msg2(Config) when is_list(Config) ->
2336    %% put(severity,trc),
2337    %% put(dbg,true),
2338    d("pretty_otp4632_msg2 -> entry", []),
2339    ?ACQUIRE_NODES(1, Config),
2340    ok = ticket_pretty_encode_decode_ok( pretty_otp4632_msg2() ),
2341    %% erase(severity),
2342    %% erase(dbg),
2343    ok.
2344
2345pretty_otp4632_msg2() ->
2346    msg4(?MG1_MID_NO_PORT, "901").
2347
2348
2349pretty_otp4632_msg3(suite) ->
2350    [];
2351pretty_otp4632_msg3(Config) when is_list(Config) ->
2352    %% put(severity,trc),
2353    %% put(dbg,true),
2354    d("pretty_otp4632_msg3 -> entry", []),
2355    ?ACQUIRE_NODES(1, Config),
2356    ok = ticket_pretty_decode_encode_ok( pretty_otp4632_msg3() ),
2357    %% erase(severity),
2358    %% erase(dbg),
2359    ok.
2360
2361pretty_otp4632_msg3() ->
2362    M = "MEGACO/" ?VERSION_STR " [124.124.124.222]\nTransaction = 9998 {\n\tContext = - {\n\t\tServiceChange = root {\n\t\t\tServices {\n\t\t\t\tMethod = Restart,\n\t\t\t\tServiceChangeAddress = 55555,\n\t\t\t\tProfile = resgw/1,\n\t\t\t\tReason = \"901\"\n\t\t\t}\n\t\t}\n\t}\n}",
2363    M.
2364
2365
2366pretty_otp4632_msg4(suite) ->
2367    [];
2368pretty_otp4632_msg4(Config) when is_list(Config) ->
2369    %% put(severity,trc),
2370    %% put(dbg,true),
2371    d("pretty_otp4632_msg4 -> entry", []),
2372    ?ACQUIRE_NODES(1, Config),
2373    Check = fun(B2, B1) -> pretty_otp4632_msg4_chk(B1, B2) end,
2374    ok = ticket_pretty_decode_encode_only(pretty_otp4632_msg4(), Check),
2375    %% erase(severity),
2376    %% erase(dbg),
2377    ok.
2378
2379
2380pretty_otp4632_msg4() ->
2381    M = "MEGACO/" ?VERSION_STR " [124.124.124.222]\nTransaction = 9998 {\n\tContext = - {\n\t\tServiceChange = root {\n\t\t\tServices {\n\t\t\t\tMethod = Restart,\n\t\t\t\tServiceChangeAddress = 55555,\n\t\t\t\tProfile = resgw/1,\n\t\t\t\tReason = 901\n\t\t\t}\n\t\t}\n\t}\n}",
2382    M.
2383
2384pretty_otp4632_msg4_chk(B1, B2) when is_binary(B1) and is_binary(B2) ->
2385    S1 = binary_to_list(B1),
2386    S2 = binary_to_list(B2),
2387    %%     io:format("~n"
2388    %% 		 "S1: ~s~n"
2389    %% 		 "S2: ~s~n", [S1, S2]),
2390    pretty_otp4632_msg4_chk(S1, S2);
2391
2392pretty_otp4632_msg4_chk([], []) ->
2393    messages_not_eq;
2394pretty_otp4632_msg4_chk([], Rest2) ->
2395    {messages_not_eq2, Rest2};
2396pretty_otp4632_msg4_chk(Rest1, []) ->
2397    {messages_not_eq1, Rest1};
2398pretty_otp4632_msg4_chk([$R,$e,$a,$s,$o,$n,$ ,$=,$ ,$",$9,$0,$1,$"|_Rest1],
2399			[$R,$e,$a,$s,$o,$n,$ ,$=,$ ,$9,$0,$1|_Rest2]) ->
2400    ok;
2401pretty_otp4632_msg4_chk([_H1|Rest1], [_H2|Rest2]) ->
2402    pretty_otp4632_msg4_chk(Rest1, Rest2).
2403
2404
2405%% --------------------------------------------------------------
2406%%
2407pretty_otp4710_msg1(suite) ->
2408    [];
2409pretty_otp4710_msg1(Config) when is_list(Config) ->
2410    %% put(severity,trc),
2411    %% put(dbg,true),
2412    d("pretty_otp4710_msg1 -> entry", []),
2413    ?ACQUIRE_NODES(1, Config),
2414    ok = ticket_pretty_encode_decode_ok( pretty_otp4710_msg1() ),
2415    %% erase(severity),
2416    %% erase(dbg),
2417    ok.
2418
2419pretty_otp4710_msg1() ->
2420    msg40().
2421
2422
2423pretty_otp4710_msg2(suite) ->
2424    [];
2425pretty_otp4710_msg2(Config) when is_list(Config) ->
2426    %% put(severity,trc),
2427    %% put(dbg,true),
2428    d("pretty_otp4710_msg2 -> entry", []),
2429    ?ACQUIRE_NODES(1, Config),
2430    Check = fun(B1, B2) -> pretty_otp4710_msg2_chk(B1, B2) end,
2431    ok = ticket_pretty_decode_encode_only(pretty_otp4710_msg2(), Check),
2432    %% erase(severity),
2433    %% erase(dbg),
2434    ok.
2435
2436pretty_otp4710_msg2() ->
2437    "Authentication = 0xEFCDAB89:0x12345678:0x1234567889ABCDEF76543210\nMEGACO/" ?VERSION_STR " [124.124.124.222]\nTransaction = 9998 {\n\tContext = - {\n\t\tServiceChange = root {\n\t\t\tServices {\n\t\t\t\tMethod = Restart,\n\t\t\t\tServiceChangeAddress = 55555,\n\t\t\t\tProfile = resgw/1,\n\t\t\t\tReason = \"901 mg col boot\"\n\t\t\t}\n\t\t}\n\t}\n}".
2438
2439pretty_otp4710_msg2_chk(B1, B2) when is_binary(B1) and is_binary(B2) ->
2440    S1 = binary_to_list(B1),
2441    S2 = binary_to_list(B2),
2442    pretty_otp4710_msg2_chk(S1, S2);
2443
2444pretty_otp4710_msg2_chk(Msg, Msg) ->
2445    ok;
2446
2447pretty_otp4710_msg2_chk(
2448  [$A,$u,$t,$h,$e,$n,$t,$i,$c,$a,$t,$i,$o,$n,$=,$ |Msg0],
2449  [$A,$u,$t,$h,$e,$n,$t,$i,$c,$a,$t,$i,$o,$n,$=,$ |Msg1]) ->
2450    {AH0, Rest0} = pretty_otp4710_msg2_chk_ah(Msg0, []),
2451    {AH1, Rest1} = pretty_otp4710_msg2_chk_ah(Msg1, []),
2452    case AH0 == AH1 of
2453	true ->
2454	    exit({message_not_equal, Rest0, Rest1});
2455	false ->
2456	    exit({auth_header_not_equal, AH0, AH1})
2457    end.
2458
2459pretty_otp4710_msg2_chk_ah([], _Acc) ->
2460    exit(no_auth_header_found);
2461pretty_otp4710_msg2_chk_ah([$M,$E,$G,$A,$C,$O,$/,_|Rest], Acc) ->
2462    {lists:reverse(Acc), Rest};
2463pretty_otp4710_msg2_chk_ah([C|R], Acc) ->
2464    pretty_otp4710_msg2_chk_ah(R, [C|Acc]).
2465
2466
2467%% --------------------------------------------------------------
2468%%
2469pretty_otp4945_msg1(suite) ->
2470    [];
2471pretty_otp4945_msg1(Config) when is_list(Config) ->
2472    %% put(severity,trc),
2473    %% put(dbg,true),
2474    d("pretty_otp4945_msg1 -> entry", []),
2475    ?ACQUIRE_NODES(1, Config),
2476    Check = fun(R) -> pretty_otp4945_msg1_chk(R) end,
2477    ok = ticket_pretty_decode_error(pretty_otp4945_msg1(), Check),
2478    %% erase(severity),
2479    %% erase(dbg),
2480    ok.
2481
2482pretty_otp4945_msg1() ->
2483"MEGACO/" ?VERSION_STR " [124.124.124.222] Transaction = 9998 {
2484   Context = - {
2485      ServiceChange = ROOT {
2486         Services {
2487            Method = Restart,
2488            ServiceChangeAddress = 55555,
2489            Profile = ResGW/1
2490         }
2491      }
2492   }
2493}".
2494
2495pretty_otp4945_msg1_chk(R) when is_list(R) ->
2496    ExpMissing = [serviceChangeReason],
2497    Check = fun(Reason) ->
2498		    pretty_otp4945_chk(Reason, ExpMissing)
2499	    end,
2500    ticket_check_decode_only_error_reason(R, Check).
2501
2502
2503pretty_otp4945_msg2(suite) ->
2504    [];
2505pretty_otp4945_msg2(Config) when is_list(Config) ->
2506    %% put(severity,trc),
2507    %% put(dbg,true),
2508    d("pretty_otp4945_msg2 -> entry", []),
2509    ?ACQUIRE_NODES(1, Config),
2510    Check = fun(R) -> pretty_otp4945_msg2_chk(R) end,
2511    ok = ticket_pretty_decode_error(pretty_otp4945_msg2(), Check),
2512    %% erase(severity),
2513    %% erase(dbg),
2514    ok.
2515
2516pretty_otp4945_msg2() ->
2517"MEGACO/" ?VERSION_STR " [124.124.124.222] Transaction = 9998 {
2518   Context = - {
2519      ServiceChange = ROOT {
2520         Services {
2521            Reason = 901,
2522            ServiceChangeAddress = 55555,
2523            Profile = ResGW/1
2524         }
2525      }
2526   }
2527}".
2528
2529pretty_otp4945_msg2_chk(R) when is_list(R) ->
2530    ExpMissing = [serviceChangeMethod],
2531    Check = fun(Reason) ->
2532		    pretty_otp4945_chk(Reason, ExpMissing)
2533	    end,
2534    ticket_check_decode_only_error_reason(R, Check).
2535
2536
2537pretty_otp4945_msg3(suite) ->
2538    [];
2539pretty_otp4945_msg3(Config) when is_list(Config) ->
2540    %% put(severity,trc),
2541    %% put(dbg,true),
2542    d("pretty_otp4945_msg3 -> entry", []),
2543    ?ACQUIRE_NODES(1, Config),
2544    Check = fun(R) -> pretty_otp4945_msg3_chk(R) end,
2545    ok = ticket_pretty_decode_error(pretty_otp4945_msg3(), Check),
2546    %% erase(severity),
2547    %% erase(dbg),
2548    ok.
2549
2550pretty_otp4945_msg3() ->
2551"MEGACO/" ?VERSION_STR " [124.124.124.222] Transaction = 9998 {
2552   Context = - {
2553      ServiceChange = ROOT {
2554         Services {
2555            ServiceChangeAddress = 55555,
2556            Profile = ResGW/1
2557         }
2558      }
2559   }
2560}".
2561
2562pretty_otp4945_msg3_chk(R) when is_list(R) ->
2563    ExpMissing = [serviceChangeReason, serviceChangeMethod],
2564    Check = fun(Reason) ->
2565		    pretty_otp4945_chk(Reason, ExpMissing)
2566	    end,
2567    ticket_check_decode_only_error_reason(R, Check).
2568
2569
2570pretty_otp4945_msg4(suite) ->
2571    [];
2572pretty_otp4945_msg4(Config) when is_list(Config) ->
2573    %% put(severity,trc),
2574    %% put(dbg,true),
2575    d("pretty_otp4945_msg4 -> entry", []),
2576    ?ACQUIRE_NODES(1, Config),
2577    ok = ticket_pretty_decode_only( pretty_otp4945_msg4() ),
2578    %% erase(severity),
2579    %% erase(dbg),
2580    ok.
2581
2582pretty_otp4945_msg4() ->
2583"MEGACO/" ?VERSION_STR " [124.124.124.222] Transaction = 9998 {
2584   Context = - {
2585      ServiceChange = ROOT {
2586         Services {
2587            Method = Restart,
2588            Reason = 901,
2589            ServiceChangeAddress = 55555,
2590            Profile = ResGW/1
2591         }
2592      }
2593   }
2594}".
2595
2596
2597pretty_otp4945_msg5(suite) ->
2598    [];
2599pretty_otp4945_msg5(Config) when is_list(Config) ->
2600    %% put(severity,trc),
2601    %% put(dbg,true),
2602    d("pretty_otp4945_msg5 -> entry", []),
2603    ?ACQUIRE_NODES(1, Config),
2604    Check = fun(R) -> pretty_otp4945_msg5_chk(R) end,
2605    ok = ticket_pretty_decode_error(pretty_otp4945_msg5(), Check),
2606    %% erase(severity),
2607    %% erase(dbg),
2608    ok.
2609
2610pretty_otp4945_msg5() ->
2611"MEGACO/" ?VERSION_STR " [124.124.124.222] Transaction = 9998 {
2612   Context = - {
2613      ServiceChange = ROOT {
2614         Services {
2615            Method = Restart,
2616            Reason = 901,
2617            Profile = ResGW/1,
2618            ServiceChangeAddress = 55555,
2619            Profile = ResGW/2
2620         }
2621      }
2622   }
2623}".
2624
2625pretty_otp4945_msg5_chk(R) when is_list(R) ->
2626    Check = fun({at_most_once_serviceChangeParm, {profile, _, _}}) ->
2627		    ok;
2628	       (Reason) ->
2629		    {error, {unexpected_reason, Reason}}
2630	    end,
2631    ticket_check_decode_only_error_reason(R, Check).
2632
2633
2634pretty_otp4945_msg6(suite) ->
2635    [];
2636pretty_otp4945_msg6(Config) when is_list(Config) ->
2637    %% put(severity,trc),
2638    %% put(dbg,true),
2639    d("pretty_otp4945_msg6 -> entry", []),
2640    ?ACQUIRE_NODES(1, Config),
2641    Check = fun(R) -> pretty_otp4945_msg6_chk(R) end,
2642    ok = ticket_pretty_decode_error(pretty_otp4945_msg6(), Check),
2643    %% erase(severity),
2644    %% erase(dbg),
2645    ok.
2646
2647pretty_otp4945_msg6() ->
2648"MEGACO/" ?VERSION_STR " [124.124.124.222] Transaction = 9998 {
2649   Context = - {
2650      ServiceChange = ROOT {
2651         Services {
2652            Method = Restart,
2653               Reason = 901,
2654               ServiceChangeAddress = 55555,
2655               MgcIdToTry = kalle,
2656               Profile = ResGW/1
2657            }
2658         }
2659   }
2660}".
2661
2662pretty_otp4945_msg6_chk(R) when is_list(R) ->
2663    Check = fun({not_both_address_mgcid_serviceChangeParm, _, _}) ->
2664		    ok;
2665	       (Reason) ->
2666		    {error, {unexpected_reason, Reason}}
2667	    end,
2668    ticket_check_decode_only_error_reason(R, Check).
2669
2670
2671pretty_otp4945_chk({missing_required_serviceChangeParm, Missing},
2672		    ExpMissing) when is_list(Missing) ->
2673    case ExpMissing -- Missing of
2674	[] ->
2675	    ok;
2676	Diff ->
2677	    {error, {unexpected_missing_serviceChangeParm, Diff}}
2678    end;
2679pretty_otp4945_chk(Reason, _ExpMissing) ->
2680    {error, {unexpected_reason, Reason}}.
2681
2682
2683%% --------------------------------------------------------------
2684%%
2685pretty_otp4949_msg1(suite) ->
2686    [];
2687pretty_otp4949_msg1(Config) when is_list(Config) ->
2688    %% put(severity,trc),
2689    %% put(dbg,true),
2690    d("pretty_otp4949_msg1 -> entry", []),
2691    ?ACQUIRE_NODES(1, Config),
2692    ok = ticket_pretty_decode_only( pretty_otp4949_msg1() ),
2693    %% erase(severity),
2694    %% erase(dbg),
2695    ok.
2696
2697pretty_otp4949_msg1() ->
2698"MEGACO/" ?VERSION_STR " [124.124.124.222] Reply = 9998 {
2699   Context = - {
2700      ServiceChange = ROOT {
2701         Services {
2702            ServiceChangeAddress = 55555,
2703            Profile = ResGW/1
2704         }
2705      }
2706   }
2707}".
2708
2709
2710pretty_otp4949_msg2(suite) ->
2711    [];
2712pretty_otp4949_msg2(Config) when is_list(Config) ->
2713    %% put(severity,trc),
2714    %% put(dbg,true),
2715    d("pretty_otp4949_msg2 -> entry", []),
2716    ?ACQUIRE_NODES(1, Config),
2717    Check = fun(R) -> pretty_otp4949_msg2_chk(R) end,
2718    ok = ticket_pretty_decode_error( pretty_otp4949_msg2(), Check),
2719    %% erase(severity),
2720    %% erase(dbg),
2721    ok.
2722
2723pretty_otp4949_msg2() ->
2724"MEGACO/" ?VERSION_STR " [124.124.124.222] Reply = 9998 {
2725   Context = - {
2726      ServiceChange = ROOT {
2727         Services {
2728            Profile = ResGW/1,
2729            ServiceChangeAddress = 55555,
2730            Profile = ResGW/2
2731         }
2732      }
2733   }
2734}".
2735
2736pretty_otp4949_msg2_chk(R) when is_list(R) ->
2737    Check = fun({at_most_once_servChgReplyParm, {profile, _, _}}) ->
2738		    ok;
2739	       (Reason) ->
2740		    {error, {unexpected_reason, Reason}}
2741	    end,
2742    ticket_check_decode_only_error_reason(R, Check).
2743
2744
2745pretty_otp4949_msg3(suite) ->
2746    [];
2747pretty_otp4949_msg3(Config) when is_list(Config) ->
2748    %% put(severity,trc),
2749    %% put(dbg,true),
2750    d("pretty_otp4949_msg3 -> entry", []),
2751    ?ACQUIRE_NODES(1, Config),
2752    Check = fun(R) -> pretty_otp4949_msg3_chk(R) end,
2753    ok = ticket_pretty_decode_error( pretty_otp4949_msg3(), Check ),
2754    %% erase(severity),
2755    %% erase(dbg),
2756    ok.
2757
2758pretty_otp4949_msg3() ->
2759"MEGACO/" ?VERSION_STR " [124.124.124.222] Reply = 9998 {
2760   Context = - {
2761      ServiceChange = ROOT {
2762         Services {
2763            ServiceChangeAddress = 55555,
2764            MgcIdToTry = kalle,
2765            Profile = ResGW/1
2766         }
2767      }
2768   }
2769}".
2770
2771pretty_otp4949_msg3_chk(R) when is_list(R) ->
2772    Check = fun({not_both_address_mgcid_servChgReplyParm, _, _}) ->
2773		    ok;
2774	       (Reason) ->
2775		    {error, {unexpected_reason, Reason}}
2776	    end,
2777    ticket_check_decode_only_error_reason(R, Check).
2778
2779
2780%% --------------------------------------------------------------
2781%%
2782pretty_otp5042_msg1(suite) ->
2783    [];
2784pretty_otp5042_msg1(Config) when is_list(Config) ->
2785    %% put(severity,trc),
2786    %% put(dbg,true),
2787    d("pretty_otp5042_msg1 -> entry", []),
2788    ?ACQUIRE_NODES(1, Config),
2789    ok = ticket_pretty_decode_only( pretty_otp5042_msg1() ),
2790    %% erase(severity),
2791    %% erase(dbg),
2792    ok.
2793
2794pretty_otp5042_msg1() ->
2795"MEGACO/" ?VERSION_STR " <CATAPULT>:2944
2796Transaction = 102 {
2797Context =  5 { Notify =  MUX/1 { ObservedEvents = 1 {
2798h245bh/h245msgin { Stream =  1
2799, h245enc =
28000270020600088175000653401004100403E802E00180018001780680000034301160000700088175010101007A0100020001800001320000C0000219D005027F0070500100040100021080000319D005027F00504001008000041C001250000700088175010000400280010003000880000518AA027F400006850130008011020100000001030002000300040005000006
2801 }  }
2802 }  }  }".
2803
2804
2805%% --------------------------------------------------------------
2806%%
2807pretty_otp5068_msg1(suite) ->
2808    [];
2809pretty_otp5068_msg1(Config) when is_list(Config) ->
2810    %% put(severity,trc),
2811    %% put(dbg,true),
2812    d("pretty_otp5068_msg1 -> entry", []),
2813    ?ACQUIRE_NODES(1, Config),
2814    ok = ticket_pretty_encode_decode_only( pretty_otp5068_msg1() ),
2815    %% erase(severity),
2816    %% erase(dbg),
2817    ok.
2818
2819pretty_otp5068_msg1() ->
2820{'MegacoMessage',
2821 asn1_NOVALUE,
2822 {'Message',
2823  2,
2824  {deviceName,[109,103,51,51]},
2825  {transactions,
2826   [{transactionReply,
2827     {'TransactionReply',
2828      190,
2829      asn1_NOVALUE,
2830      {actionReplies,
2831       [{'ActionReply',  %% Comments: This is repeated many times.
2832	 0,
2833	 asn1_NOVALUE,
2834	 asn1_NOVALUE,
2835	 [{auditValueReply,
2836	   {auditResult,
2837	    {'AuditResult',
2838	     {megaco_term_id,false,
2839	      [[99,101,100,101,118,49,47,52,47,49,47,49],[51,49]]},
2840	     [{mediaDescriptor,
2841	       {'MediaDescriptor',
2842		{'TerminationStateDescriptor',
2843		 [],
2844		 asn1_NOVALUE,
2845		 inSvc},
2846		asn1_NOVALUE
2847	       }
2848	      }
2849	     ]
2850	    }
2851	   }
2852	  }
2853	 ]
2854	}
2855       ]
2856      },asn1_NOVALUE,asn1_NOVALUE
2857     }
2858    }
2859   ]
2860  }
2861 }
2862}.
2863
2864
2865
2866%% --------------------------------------------------------------
2867%%
2868pretty_otp5085_msg1(suite) ->
2869    [];
2870pretty_otp5085_msg1(Config) when is_list(Config) ->
2871    %% put(severity,trc),
2872    %% put(dbg,true),
2873    d("pretty_otp5085_msg1 -> entry", []),
2874    ?ACQUIRE_NODES(1, Config),
2875    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg1() ),
2876    %% erase(severity),
2877    %% erase(dbg),
2878    ok.
2879
2880pretty_otp5085_msg1() ->
2881    {'MegacoMessage',
2882     asn1_NOVALUE,
2883     {'Message',
2884      ?VERSION,
2885      {deviceName,"mg36"},
2886      {transactions,
2887       [{transactionReply,
2888	 {'TransactionReply',
2889	  230,
2890	  asn1_NOVALUE,
2891	  {actionReplies,
2892	   [{'ActionReply',
2893	     400,
2894	     {'ErrorDescriptor',504,asn1_NOVALUE},
2895	     asn1_NOVALUE,
2896	     []
2897	    }
2898	   ]
2899	  },asn1_NOVALUE,asn1_NOVALUE
2900	 }
2901	}
2902       ]
2903      }
2904     }
2905    }.
2906
2907
2908pretty_otp5085_msg2(suite) ->
2909    [];
2910pretty_otp5085_msg2(Config) when is_list(Config) ->
2911    %% put(severity,trc),
2912    %% put(dbg,true),
2913    d("pretty_otp5085_msg2 -> entry", []),
2914    ?ACQUIRE_NODES(1, Config),
2915    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg2() ),
2916    %% erase(severity),
2917    %% erase(dbg),
2918    ok.
2919
2920pretty_otp5085_msg2() ->
2921    {'MegacoMessage',
2922     asn1_NOVALUE,
2923     {'Message',
2924      ?VERSION,
2925      {deviceName,"mg36"},
2926      {transactions,
2927       [{transactionReply,
2928	 {'TransactionReply',
2929	  230,
2930	  asn1_NOVALUE,
2931	  {actionReplies,
2932	   [{'ActionReply',
2933	     400,
2934	     asn1_NOVALUE,
2935	     asn1_NOVALUE,
2936	     []
2937	    }
2938	   ]
2939	  },asn1_NOVALUE,asn1_NOVALUE
2940	 }
2941	}
2942       ]
2943      }
2944     }
2945    }.
2946
2947
2948pretty_otp5085_msg3(suite) ->
2949    [];
2950pretty_otp5085_msg3(Config) when is_list(Config) ->
2951    %% put(severity,trc),
2952    %% put(dbg,true),
2953    d("pretty_otp5085_msg3 -> entry", []),
2954    ?ACQUIRE_NODES(1, Config),
2955    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg3() ),
2956    %% erase(severity),
2957    %% erase(dbg),
2958    ok.
2959
2960pretty_otp5085_msg3() ->
2961    {'MegacoMessage',
2962     asn1_NOVALUE,
2963     {'Message',
2964      ?VERSION,
2965      {deviceName,"mg36"},
2966      {transactions,
2967       [{transactionReply,
2968	 {'TransactionReply',
2969	  230,
2970	  asn1_NOVALUE,
2971	  {actionReplies,
2972	   [{'ActionReply',
2973	     400,
2974	     asn1_NOVALUE,
2975	     #'ContextRequest'{priority = 3},
2976	     []
2977	    }
2978	   ]
2979	  },asn1_NOVALUE,asn1_NOVALUE
2980	 }
2981	}
2982       ]
2983      }
2984     }
2985    }.
2986
2987
2988pretty_otp5085_msg4(suite) ->
2989    [];
2990pretty_otp5085_msg4(Config) when is_list(Config) ->
2991    %% put(severity,trc),
2992    %% put(dbg,true),
2993    d("pretty_otp5085_msg4 -> entry", []),
2994    ?ACQUIRE_NODES(1, Config),
2995    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg4() ),
2996    %% erase(severity),
2997    %% erase(dbg),
2998    ok.
2999
3000pretty_otp5085_msg4() ->
3001    {'MegacoMessage',
3002     asn1_NOVALUE,
3003     {'Message',
3004      ?VERSION,
3005      {deviceName,"mg36"},
3006      {transactions,
3007       [{transactionReply,
3008	 {'TransactionReply',
3009	  230,
3010	  asn1_NOVALUE,
3011	  {actionReplies,
3012	   [{'ActionReply',
3013	     400,
3014	     asn1_NOVALUE,
3015	     asn1_NOVALUE,
3016	     [{addReply,    cre_AmmsReply([#megaco_term_id{id = ?A4444}])},
3017	      {notifyReply, cre_NotifyRep([#megaco_term_id{id = ?A5555}])}]
3018	    }
3019	   ]
3020	  },asn1_NOVALUE,asn1_NOVALUE
3021	 }
3022	}
3023       ]
3024      }
3025     }
3026    }.
3027
3028
3029pretty_otp5085_msg5(suite) ->
3030    [];
3031pretty_otp5085_msg5(Config) when is_list(Config) ->
3032    %% put(severity,trc),
3033    %% put(dbg,true),
3034    d("pretty_otp5085_msg5 -> entry", []),
3035    ?ACQUIRE_NODES(1, Config),
3036    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg5() ),
3037    %% erase(severity),
3038    %% erase(dbg),
3039    ok.
3040
3041pretty_otp5085_msg5() ->
3042    {'MegacoMessage',
3043     asn1_NOVALUE,
3044     {'Message',
3045      ?VERSION,
3046      {deviceName,"mg36"},
3047      {transactions,
3048       [{transactionReply,
3049	 {'TransactionReply',
3050	  230,
3051	  asn1_NOVALUE,
3052	  {actionReplies,
3053	   [{'ActionReply',
3054	     400,
3055	     asn1_NOVALUE,
3056	     #'ContextRequest'{priority = 5},
3057	     [{addReply,    cre_AmmsReply([#megaco_term_id{id = ?A4444}])},
3058	      {notifyReply, cre_NotifyRep([#megaco_term_id{id = ?A5555}])}]
3059	    }
3060	   ]
3061	  },asn1_NOVALUE,asn1_NOVALUE
3062	 }
3063	}
3064       ]
3065      }
3066     }
3067    }.
3068
3069
3070pretty_otp5085_msg6(suite) ->
3071    [];
3072pretty_otp5085_msg6(Config) when is_list(Config) ->
3073    %% put(severity,trc),
3074    %% put(dbg,true),
3075    d("pretty_otp5085_msg6 -> entry", []),
3076    ?ACQUIRE_NODES(1, Config),
3077    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg6() ),
3078    %% erase(severity),
3079    %% erase(dbg),
3080    ok.
3081
3082pretty_otp5085_msg6() ->
3083    {'MegacoMessage',
3084     asn1_NOVALUE,
3085     {'Message',
3086      ?VERSION,
3087      {deviceName,"msg36"},
3088      {transactions,
3089       [{transactionReply,
3090	 {'TransactionReply',
3091	  230,
3092	  asn1_NOVALUE,
3093	  {actionReplies,
3094	   [{'ActionReply',
3095	     400,
3096	     {'ErrorDescriptor',504,asn1_NOVALUE},
3097	     #'ContextRequest'{priority = 6},
3098	     [{addReply,    cre_AmmsReply([#megaco_term_id{id = ?A4444}])},
3099	      {notifyReply, cre_NotifyRep([#megaco_term_id{id = ?A5555}])}]
3100	    }
3101	   ]
3102	  },asn1_NOVALUE,asn1_NOVALUE
3103	 }
3104	}
3105       ]
3106      }
3107     }
3108    }.
3109
3110
3111pretty_otp5085_msg7(suite) ->
3112    [];
3113pretty_otp5085_msg7(Config) when is_list(Config) ->
3114    %% put(severity,trc),
3115    %% put(dbg,true),
3116    d("pretty_otp5085_msg7 -> entry", []),
3117    ?ACQUIRE_NODES(1, Config),
3118    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg7() ),
3119    %% erase(severity),
3120    %% erase(dbg),
3121    ok.
3122
3123pretty_otp5085_msg7() ->
3124    {'MegacoMessage',
3125     asn1_NOVALUE,
3126     {'Message',
3127      ?VERSION,
3128      {deviceName,"msg36"},
3129      {transactions,
3130       [{transactionReply,
3131	 {'TransactionReply',
3132	  230,
3133	  asn1_NOVALUE,
3134	  {actionReplies,
3135	   [{'ActionReply',
3136	     400,
3137	     {'ErrorDescriptor',504,asn1_NOVALUE},
3138	     #'ContextRequest'{priority = 7},
3139	     [{notifyReply, cre_NotifyRep([#megaco_term_id{id = ?A5555}])}]
3140	    }
3141	   ]
3142	  },asn1_NOVALUE,asn1_NOVALUE
3143	 }
3144	}
3145       ]
3146      }
3147     }
3148    }.
3149
3150
3151pretty_otp5085_msg8(suite) ->
3152    [];
3153pretty_otp5085_msg8(Config) when is_list(Config) ->
3154    %% put(severity,trc),
3155    %% put(dbg,true),
3156    d("pretty_otp5085_msg8 -> entry", []),
3157    ?ACQUIRE_NODES(1, Config),
3158    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg8() ),
3159    %% erase(severity),
3160    %% erase(dbg),
3161    ok.
3162
3163pretty_otp5085_msg8() ->
3164    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
3165    To1 = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
3166    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
3167    To2 = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
3168    {'MegacoMessage',
3169     asn1_NOVALUE,
3170     {'Message',
3171      ?VERSION,
3172      {deviceName,"msg36"},
3173      {transactions,
3174       [{transactionReply,
3175	 {'TransactionReply',
3176	  230,
3177	  asn1_NOVALUE,
3178	  {actionReplies,
3179	   [{'ActionReply',
3180	     400,
3181	     {'ErrorDescriptor',504,asn1_NOVALUE},
3182	     #'ContextRequest'{priority = 8,
3183			       emergency = true,
3184			       topologyReq =
3185			       [#'TopologyRequest'{terminationFrom = From1,
3186						   terminationTo   = To1,
3187						   topologyDirection = bothway},
3188				#'TopologyRequest'{terminationFrom = From2,
3189						   terminationTo   = To2,
3190						   topologyDirection = oneway}
3191			       ],
3192			       iepscallind = true,
3193			       contextProp = [cre_PropParm("tdmc/gain", "2")]},
3194	     [{notifyReply, cre_NotifyRep([#megaco_term_id{id = ?A5555}])}]
3195	    }
3196	   ]
3197	  },asn1_NOVALUE,asn1_NOVALUE
3198	 }
3199	}
3200       ]
3201      }
3202     }
3203    }.
3204
3205
3206%% --------------------------------------------------------------
3207%%
3208pretty_otp5600_msg1(suite) ->
3209    [];
3210pretty_otp5600_msg1(Config) when is_list(Config) ->
3211    %% put(severity,trc),
3212    %% put(dbg,true),
3213    d("pretty_otp5600_msg1 -> entry", []),
3214    ?ACQUIRE_NODES(1, Config),
3215    ok = ticket_pretty_encode_decode_ok( pretty_otp5600_msg1() ),
3216    %% erase(severity),
3217    %% erase(dbg),
3218    ok.
3219
3220pretty_otp5600_msg1() ->
3221    SRE = #'SecondRequestedEvent'{ pkgdName = "al/on",
3222                                   evParList = [] },
3223
3224    SED = #'SecondEventsDescriptor'{ requestID = 2,
3225                                     eventList = [ SRE ] },
3226
3227    SIG = { signal, #'Signal'{ signalName = "cg/dt",
3228                               sigParList = [] } },
3229
3230    RA = #'RequestedActions'{ secondEvent = SED,
3231                              signalsDescriptor = [ SIG ] },
3232
3233    RE = #'RequestedEvent'{ pkgdName = "al/of",
3234                            eventAction = RA,
3235                            evParList = [] },
3236
3237    EV = #'EventsDescriptor'{ requestID = 1, eventList = [ RE ] },
3238
3239    TermID = {megaco_term_id, true, [[$*]] },
3240
3241    AMMR = #'AmmRequest'{ terminationID = [ TermID ],
3242                          descriptors = [ { eventsDescriptor, EV } ] },
3243
3244    CR = #'CommandRequest'{command = {modReq, AMMR}},
3245
3246    AR = #'ActionRequest'{contextId = ?megaco_null_context_id,
3247                          commandRequests = [CR]},
3248    ARs = [AR],
3249    TR = #'TransactionRequest'{transactionId = 5600, actions = ARs},
3250    TRs = [{transactionRequest, TR}],
3251    Mess = #'Message'{version = ?VERSION,
3252                      mId = ?MGC_MID,
3253                      messageBody = {transactions, TRs}},
3254    #'MegacoMessage'{mess = Mess}.
3255
3256
3257pretty_otp5600_msg2(suite) ->
3258    [];
3259pretty_otp5600_msg2(Config) when is_list(Config) ->
3260    %% put(severity,trc),
3261    %% put(dbg,true),
3262    d("pretty_otp5600_msg2 -> entry", []),
3263    ?ACQUIRE_NODES(1, Config),
3264    ok = ticket_pretty_encode_decode_ok( pretty_otp5600_msg2() ),
3265    %% erase(severity),
3266    %% erase(dbg),
3267    ok.
3268
3269pretty_otp5600_msg2() ->
3270    SIG = { signal, #'Signal'{ signalName = "cg/dt",
3271                               sigParList = [] } },
3272
3273    SRA = #'SecondRequestedActions'{ signalsDescriptor = [ SIG ] },
3274
3275    SRE = #'SecondRequestedEvent'{ pkgdName    = "al/on",
3276                                   eventAction = SRA,
3277                                   evParList   = [] },
3278
3279    SED = #'SecondEventsDescriptor'{ requestID = 2,
3280				     eventList = [ SRE ] },
3281
3282    RA = #'RequestedActions'{ secondEvent = SED },
3283
3284    RE = #'RequestedEvent'{ pkgdName = "al/of",
3285			    eventAction = RA,
3286			    evParList = [] },
3287
3288    EV = #'EventsDescriptor'{ requestID = 1, eventList = [ RE ] },
3289
3290    TermID = {megaco_term_id, true, [[$*]] },
3291
3292    AMMR = #'AmmRequest'{ terminationID = [ TermID ],
3293			  descriptors = [ { eventsDescriptor, EV } ] },
3294
3295    CR = #'CommandRequest'{command = {modReq, AMMR}},
3296
3297    AR = #'ActionRequest'{contextId = ?megaco_null_context_id,
3298                          commandRequests = [CR]},
3299    ARs = [AR],
3300    TR = #'TransactionRequest'{transactionId = 5600, actions = ARs},
3301    TRs = [{transactionRequest, TR}],
3302    Mess = #'Message'{version = ?VERSION,
3303                      mId = ?MGC_MID,
3304                      messageBody = {transactions, TRs}},
3305    #'MegacoMessage'{mess = Mess}.
3306
3307
3308%% --------------------------------------------------------------
3309%%
3310pretty_otp5601_msg1(suite) ->
3311    [];
3312pretty_otp5601_msg1(Config) when is_list(Config) ->
3313    %% put(severity,trc),
3314    %% put(dbg,true),
3315    d("pretty_otp5601_msg1 -> entry", []),
3316    ?ACQUIRE_NODES(1, Config),
3317    ok = ticket_pretty_encode_decode_ok( pretty_otp5601_msg1() ),
3318    %% erase(severity),
3319    %% erase(dbg),
3320    ok.
3321
3322pretty_otp5601_msg1() ->
3323    SRE1 = #'SecondRequestedEvent'{ pkgdName = "al/on",
3324				    evParList = [] },
3325
3326    SRA = #'SecondRequestedActions'{ eventDM = { digitMapName, "dialllan0" }},
3327
3328    SRE2 = #'SecondRequestedEvent'{ pkgdName = "dd/ce",
3329				    eventAction = SRA,
3330				    evParList = [] },
3331
3332    SED = #'SecondEventsDescriptor'{ requestID = 2,
3333				     eventList = [ SRE1, SRE2 ] },
3334
3335    RA = #'RequestedActions'{ secondEvent = SED },
3336
3337    RE = #'RequestedEvent'{ pkgdName = "al/of",
3338			    eventAction = RA,
3339			    evParList = [] },
3340
3341    EV = #'EventsDescriptor'{ requestID = 1, eventList = [ RE ] },
3342
3343    TermID = {megaco_term_id, true, [[$*]] },
3344
3345    AMMR = #'AmmRequest'{ terminationID = [ TermID ],
3346			  descriptors = [ { eventsDescriptor, EV } ] },
3347
3348    CR = #'CommandRequest'{command = {modReq, AMMR}},
3349
3350    AR = #'ActionRequest'{contextId = ?megaco_null_context_id,
3351			  commandRequests = [CR]},
3352    ARs = [AR],
3353    TR = #'TransactionRequest'{transactionId = 5600, actions = ARs},
3354    TRs = [{transactionRequest, TR}],
3355    Mess = #'Message'{version = ?VERSION,
3356		      mId = ?MGC_MID,
3357		      messageBody = {transactions, TRs}},
3358    #'MegacoMessage'{mess = Mess}.
3359
3360
3361%% --------------------------------------------------------------
3362%%
3363pretty_otp5793_msg01(suite) ->
3364    [];
3365pretty_otp5793_msg01(Config) when is_list(Config) ->
3366    %% put(severity,trc),
3367    %% put(dbg,true),
3368    d("pretty_otp5793_msg01 -> entry", []),
3369    ?ACQUIRE_NODES(1, Config),
3370    ok = ticket_pretty_encode_decode_ok( pretty_otp5793_msg1() ),
3371    %% erase(severity),
3372    %% erase(dbg),
3373    ok.
3374
3375pretty_otp5793_msg1() ->
3376    {'MegacoMessage',asn1_NOVALUE,
3377     {'Message',3,
3378      {deviceName,"bs_sbg_4/99"},
3379      {transactions,
3380       [{transactionReply,
3381	 {'TransactionReply',
3382	  370,
3383	  asn1_NOVALUE,
3384	  {actionReplies,
3385	   [{'ActionReply',
3386	     3,
3387	     asn1_NOVALUE,
3388	     asn1_NOVALUE,
3389	     [{auditValueReply,
3390	       {contextAuditResult,
3391		[{megaco_term_id,
3392		  false,
3393		  ["ip",
3394		   "104",
3395		   "1",
3396		   "18"]}]}},
3397	      {auditValueReply,
3398	       {contextAuditResult,
3399		[{megaco_term_id,
3400		  false,
3401		  ["ip",
3402		   "104",
3403		   "2",
3404		   "19"]
3405		 }
3406		]
3407	       }
3408	      }
3409	     ]
3410	    }
3411	   ]
3412	  },asn1_NOVALUE,asn1_NOVALUE
3413	 }
3414	}
3415       ]
3416      }
3417     }
3418    }.
3419
3420
3421
3422%% --------------------------------------------------------------
3423%%
3424pretty_otp5803_msg01(suite) ->
3425    [];
3426pretty_otp5803_msg01(Config) when is_list(Config) ->
3427    %% put(severity,trc),
3428    %% put(dbg,true),
3429    d("pretty_otp5803_msg01 -> entry", []),
3430    ?ACQUIRE_NODES(1, Config),
3431    ok = ticket_pretty_decode_encode_ok( pretty_otp5803_msg1() ),
3432    %% erase(severity),
3433    %% erase(dbg),
3434    ok.
3435
3436pretty_otp5803_msg1() ->
3437"MEGACO/" ?VERSION_STR " [134.138.234.29]Transaction=384{
3438  Context=27{
3439    Modify=ip/104/1/76{
3440      Media{
3441        Stream=1{
3442          Local{},
3443          Remote{}
3444        },
3445        Stream=2{
3446          Local{},
3447          Remote{}
3448        }
3449      },
3450      Audit{
3451        Media{
3452          Stream=1{
3453            Statistics{*/*}
3454          },
3455          Stream=2{
3456            Statistics{*/*}
3457          }
3458        }
3459      }
3460    },
3461    Modify=ip/104/2/77{
3462      Media{
3463        Stream=1{
3464          Local{},
3465          Remote{}
3466        },
3467        Stream=2{
3468          Local{},
3469          Remote{}
3470        }
3471      }
3472    }
3473  }
3474}".
3475
3476
3477pretty_otp5803_msg02(suite) ->
3478    [];
3479pretty_otp5803_msg02(Config) when is_list(Config) ->
3480    %% put(severity,trc),
3481    %% put(dbg,true),
3482    d("pretty_otp5803_msg02 -> entry", []),
3483    ?ACQUIRE_NODES(1, Config),
3484    ok = ticket_pretty_decode_encode_ok( pretty_otp5803_msg2() ),
3485    %% erase(severity),
3486    %% erase(dbg),
3487    ok.
3488
3489pretty_otp5803_msg2() ->
3490"MEGACO/" ?VERSION_STR " [134.138.234.29]Transaction=384{
3491  Context=27{
3492    Modify=ip/104/1/76{
3493      Media{
3494        Stream=1{
3495           Local{},
3496           Remote{}
3497        },
3498        Stream=2{
3499          Local{},
3500          Remote{}
3501        }
3502      },
3503      Audit{
3504        Media{
3505          Stream=1{
3506            Statistics{*/*}
3507          }
3508        }
3509      }
3510    },
3511    Modify=ip/104/2/77{
3512      Media{
3513        Stream=1{
3514          Local{},
3515          Remote{}
3516        },
3517        Stream=2{
3518          Local{},
3519          Remote{}
3520        }
3521      }
3522    }
3523  }
3524}".
3525
3526
3527%% --------------------------------------------------------------
3528%%
3529pretty_otp5805_msg01(suite) ->
3530    [];
3531pretty_otp5805_msg01(Config) when is_list(Config) ->
3532    %% put(severity,trc),
3533    %% put(dbg,true),
3534    d("pretty_otp5805_msg01 -> entry", []),
3535    ?ACQUIRE_NODES(1, Config),
3536    ok = ticket_pretty_decode_error( pretty_otp5805_msg1() ),
3537    %% erase(severity),
3538    %% erase(dbg),
3539    ok.
3540
3541pretty_otp5805_msg1() ->
3542"MEGACO/4 [134.138.234.29]
3543Transaction=1{
3544  Context=*{
3545    AuditValue=ip/0/*{
3546      Audit{}
3547    }
3548  }
3549}".
3550
3551
3552%% --------------------------------------------------------------
3553%%
3554pretty_otp5836_msg01(suite) ->
3555    [];
3556pretty_otp5836_msg01(Config) when is_list(Config) ->
3557    %% put(severity,trc),
3558    %% put(dbg,true),
3559    d("pretty_otp5836_msg01 -> entry", []),
3560    ?ACQUIRE_NODES(1, Config),
3561    ok = ticket_pretty_encode_decode_ok( compact_otp5836_msg1() ),
3562    %% erase(severity),
3563    %% erase(dbg),
3564    ok.
3565
3566
3567%% --------------------------------------------------------------
3568%%
3569pretty_otp5882_msg01(suite) ->
3570    [];
3571pretty_otp5882_msg01(Config) when is_list(Config) ->
3572    %% put(severity,trc),
3573    %% put(dbg,true),
3574    d("pretty_otp5882_msg01 -> entry", []),
3575    ?ACQUIRE_NODES(1, Config),
3576    Check = fun(R) -> pretty_otp5882_msg01_chk(R) end,
3577    ok = ticket_pretty_encode_error( pretty_otp5882_msg01(), Check ),
3578    %% erase(severity),
3579    %% erase(dbg),
3580    ok.
3581
3582pretty_otp5882_msg01_chk({message_encode_failed, {error, {Reason, _}}, _}) ->
3583    case Reason of
3584	{invalid_LocalControlDescriptor, empty} ->
3585	    ok;
3586	_ ->
3587	    {error, {unexpected_error_actual_reason, Reason}}
3588    end;
3589pretty_otp5882_msg01_chk(Reason) ->
3590    {error, {unexpected_reason, Reason}}.
3591
3592
3593pretty_otp5882_msg01() ->
3594    LCD = #'LocalControlDescriptor'{}, % Create illegal LCD
3595    Parms      = cre_StreamParms(LCD),
3596    StreamDesc = cre_StreamDesc(1, Parms),
3597    MediaDesc  = cre_MediaDesc(StreamDesc),
3598    AmmReq     = cre_AmmReq([#megaco_term_id{id = ?A4445}],
3599			    [{mediaDescriptor, MediaDesc}]),
3600    CmdReq     = cre_CmdReq({modReq, AmmReq}),
3601    CID        = cre_CtxID(7301),
3602    ActReq     = cre_ActReq(CID, [CmdReq]),
3603    Actions    = [ActReq],
3604    TransId    = cre_TransId(7302),
3605    TransReq   = cre_TransReq(TransId, Actions),
3606    Trans      = cre_Trans(TransReq),
3607    Mid        = ?MG1_MID,
3608    Mess       = cre_Msg(Mid, [Trans]),
3609    cre_MegacoMessage(Mess).
3610
3611
3612
3613%% --------------------------------------------------------------
3614%%
3615pretty_otp6490_msg01(suite) ->
3616    [];
3617pretty_otp6490_msg01(Config) when is_list(Config) ->
3618    %% put(severity, trc),
3619    %% put(dbg,      true),
3620    d("pretty_otp6490_msg01 -> entry", []),
3621    %% ?ACQUIRE_NODES(1, Config),
3622    ok = ticket_pretty_encode_decode_ok( pretty_otp6490_msg01(), [] ),
3623    %% erase(dbg),
3624    erase(severity),
3625    ok.
3626
3627pretty_otp6490_msg02(suite) ->
3628    [];
3629pretty_otp6490_msg02(Config) when is_list(Config) ->
3630    %% put(severity, trc),
3631    %% put(dbg,      true),
3632    d("pretty_otp6490_msg02 -> entry", []),
3633    %% ?ACQUIRE_NODES(1, Config),
3634    ok = ticket_pretty_encode_decode_ok( pretty_otp6490_msg02(), [] ),
3635    %% erase(severity),
3636    %% erase(dbg),
3637    ok.
3638
3639pretty_otp6490_msg03(suite) ->
3640    [];
3641pretty_otp6490_msg03(Config) when is_list(Config) ->
3642    %% put(severity, trc),
3643    %% put(dbg,      true),
3644    d("pretty_otp6490_msg03 -> entry", []),
3645    %% ?ACQUIRE_NODES(1, Config),
3646    ok = ticket_pretty_encode_decode_ok( pretty_otp6490_msg03(), [] ),
3647    %% erase(severity),
3648    %% erase(dbg),
3649    ok.
3650
3651pretty_otp6490_msg04(suite) ->
3652    [];
3653pretty_otp6490_msg04(Config) when is_list(Config) ->
3654    %% put(severity, trc),
3655    %% put(dbg,      true),
3656    d("pretty_otp6490_msg04 -> entry", []),
3657    %% ?ACQUIRE_NODES(1, Config),
3658    ok = ticket_pretty_encode_decode_ok( pretty_otp6490_msg04(), [] ),
3659    %% erase(severity),
3660    %% erase(dbg),
3661    ok.
3662
3663pretty_otp6490_msg05(suite) ->
3664    [];
3665pretty_otp6490_msg05(Config) when is_list(Config) ->
3666    %% put(severity, trc),
3667    %% put(dbg,      true),
3668    d("pretty_otp6490_msg05 -> entry", []),
3669    %% ?ACQUIRE_NODES(1, Config),
3670    ok = ticket_pretty_encode_decode_ok( pretty_otp6490_msg05(), [] ),
3671    %% erase(severity),
3672    %% erase(dbg),
3673    ok.
3674
3675pretty_otp6490_msg06(suite) ->
3676    [];
3677pretty_otp6490_msg06(Config) when is_list(Config) ->
3678    %% put(severity, trc),
3679    %% put(dbg,      true),
3680    d("pretty_otp6490_msg06 -> entry", []),
3681    %% ?ACQUIRE_NODES(1, Config),
3682    ok = ticket_pretty_encode_decode_ok( pretty_otp6490_msg06(), [] ),
3683    %% erase(severity),
3684    %% erase(dbg),
3685    ok.
3686
3687pretty_otp6490_msg(EBD) ->
3688    AmmDesc    = ?MSG_LIB:cre_AmmDescriptor(EBD),
3689    AmmReq     = cre_AmmReq([#megaco_term_id{id = ?A4445}], [AmmDesc]),
3690    CmdReq     = cre_CmdReq({modReq, AmmReq}),
3691    CID        = cre_CtxID(64901),
3692    ActReq     = cre_ActReq(CID, [CmdReq]),
3693    Actions    = [ActReq],
3694    TransId    = cre_TransId(64902),
3695    TransReq   = cre_TransReq(TransId, Actions),
3696    Trans      = cre_Trans(TransReq),
3697    Mid        = ?MG1_MID,
3698    Mess       = cre_Msg(Mid, [Trans]),
3699    cre_MegacoMessage(Mess).
3700
3701pretty_otp6490_msg01() ->
3702    EvSpecs = [], % This will result in an error
3703    EBD     = EvSpecs, % This is because the lib checks that the size is valid
3704    pretty_otp6490_msg(EBD).
3705
3706pretty_otp6490_msg02() ->
3707    EvPar    = ?MSG_LIB:cre_EventParameter("sune", ["mangs"]),
3708    PkgdName = ?MSG_LIB:cre_PkgdName("foo", "a"),
3709    EvName   = ?MSG_LIB:cre_EventName(PkgdName),
3710    EvSpec   = ?MSG_LIB:cre_EventSpec(EvName, [EvPar]),
3711    EvSpecs  = [EvSpec],
3712    EBD      = ?MSG_LIB:cre_EventBufferDescriptor(EvSpecs),
3713    pretty_otp6490_msg(EBD).
3714
3715pretty_otp6490_msg03() ->
3716    EvPar1   = ?MSG_LIB:cre_EventParameter("sune",   ["mangs"]),
3717    EvPar2   = ?MSG_LIB:cre_EventParameter("kalle",  ["anka"]),
3718    EvPar3   = ?MSG_LIB:cre_EventParameter("flippa", ["ur"]),
3719    PkgdName = ?MSG_LIB:cre_PkgdName("foo", "a"),
3720    EvName   = ?MSG_LIB:cre_EventName(PkgdName),
3721    EvSpec   = ?MSG_LIB:cre_EventSpec(EvName, [EvPar1,EvPar2,EvPar3]),
3722    EvSpecs  = [EvSpec],
3723    EBD      = ?MSG_LIB:cre_EventBufferDescriptor(EvSpecs),
3724    pretty_otp6490_msg(EBD).
3725
3726pretty_otp6490_msg04() ->
3727    EvPar1    = ?MSG_LIB:cre_EventParameter("sune",   ["mangs"]),
3728    EvPar2    = ?MSG_LIB:cre_EventParameter("kalle",  ["anka"]),
3729    EvPar3    = ?MSG_LIB:cre_EventParameter("flippa", ["ur"]),
3730    PkgdName1 = ?MSG_LIB:cre_PkgdName("foo", "a"),
3731    EvName1   = ?MSG_LIB:cre_EventName(PkgdName1),
3732    EvSpec1   = ?MSG_LIB:cre_EventSpec(EvName1, [EvPar1,EvPar2,EvPar3]),
3733    EvPar4    = ?MSG_LIB:cre_EventParameter("hej",    ["hopp"]),
3734    PkgdName2 = ?MSG_LIB:cre_PkgdName("bar", "b"),
3735    EvName2   = ?MSG_LIB:cre_EventName(PkgdName2),
3736    EvSpec2   = ?MSG_LIB:cre_EventSpec(EvName2, [EvPar4]),
3737    EvSpecs   = [EvSpec1,EvSpec2],
3738    EBD       = ?MSG_LIB:cre_EventBufferDescriptor(EvSpecs),
3739    pretty_otp6490_msg(EBD).
3740
3741pretty_otp6490_msg05() ->
3742    EvPar    = ?MSG_LIB:cre_EventParameter("sune", ["mangs"]),
3743    PkgdName = ?MSG_LIB:cre_PkgdName("foo", root),
3744    EvName   = ?MSG_LIB:cre_EventName(PkgdName),
3745    EvSpec   = ?MSG_LIB:cre_EventSpec(EvName, [EvPar]),
3746    EvSpecs  = [EvSpec],
3747    EBD      = ?MSG_LIB:cre_EventBufferDescriptor(EvSpecs),
3748    pretty_otp6490_msg(EBD).
3749
3750pretty_otp6490_msg06() ->
3751    EvPar    = ?MSG_LIB:cre_EventParameter("sune", ["mangs"]),
3752    PkgdName = ?MSG_LIB:cre_PkgdName(root, root),
3753    EvName   = ?MSG_LIB:cre_EventName(PkgdName),
3754    EvSpec   = ?MSG_LIB:cre_EventSpec(EvName, [EvPar]),
3755    EvSpecs  = [EvSpec],
3756    EBD      = ?MSG_LIB:cre_EventBufferDescriptor(EvSpecs),
3757    pretty_otp6490_msg(EBD).
3758
3759
3760%% --------------------------------------------------------------
3761%%
3762
3763pretty_otp7671_msg01(suite) ->
3764    [];
3765pretty_otp7671_msg01(Config) when is_list(Config) ->
3766%%     put(severity, trc),
3767%%     put(dbg,      true),
3768    d("pretty_otp7671_msg01 -> entry", []),
3769    %% ?ACQUIRE_NODES(1, Config),
3770    ok = pretty_otp7671( pretty_otp7671_msg01(), [] ),
3771%%     erase(dbg),
3772%%     erase(severity),
3773    ok.
3774
3775pretty_otp7671_msg02(suite) ->
3776    [];
3777pretty_otp7671_msg02(Config) when is_list(Config) ->
3778%%     put(severity, trc),
3779%%     put(dbg,      true),
3780    d("pretty_otp7671_msg02 -> entry", []),
3781    %% ?ACQUIRE_NODES(1, Config),
3782    ok = pretty_otp7671( pretty_otp7671_msg02(), [] ),
3783%%     erase(dbg),
3784%%     erase(severity),
3785   ok.
3786
3787pretty_otp7671_msg03(suite) ->
3788    [];
3789pretty_otp7671_msg03(Config) when is_list(Config) ->
3790%%     put(severity, trc),
3791%%     put(dbg,      true),
3792    d("pretty_otp7671_msg03 -> entry", []),
3793    %% ?ACQUIRE_NODES(1, Config),
3794    ok = pretty_otp7671( pretty_otp7671_msg03(), [] ),
3795%%     erase(dbg),
3796%%     erase(severity),
3797    ok.
3798
3799pretty_otp7671_msg04(suite) ->
3800    [];
3801pretty_otp7671_msg04(Config) when is_list(Config) ->
3802%%     put(severity, trc),
3803%%     put(dbg,      true),
3804    d("pretty_otp7671_msg04 -> entry", []),
3805    %% ?ACQUIRE_NODES(1, Config),
3806    ok = pretty_otp7671( pretty_otp7671_msg04(), [] , error, ignore),
3807%%     erase(dbg),
3808%%     erase(severity),
3809    ok.
3810
3811pretty_otp7671_msg05(suite) ->
3812    [];
3813pretty_otp7671_msg05(Config) when is_list(Config) ->
3814%%     put(severity, trc),
3815%%     put(dbg,      true),
3816    d("pretty_otp7671_msg05 -> entry", []),
3817    Check = fun(M1, M2) -> cmp_otp7671_msg05(M1, M2) end,
3818    ok = pretty_otp7671( pretty_otp7671_msg05(), [] , ok, ok, Check),
3819%%     erase(dbg),
3820%%     erase(severity),
3821    ok.
3822
3823
3824pretty_otp7671(Msg, Conf) ->
3825    pretty_otp7671(Msg, Conf, ok).
3826
3827pretty_otp7671(Msg, Conf, ExpectedEncode) ->
3828    pretty_otp7671(Msg, Conf, ExpectedEncode, ok).
3829
3830pretty_otp7671(Msg, Conf, ExpectedEncode, ExpectedDecode) ->
3831    otp7671(Msg, megaco_pretty_text_encoder, Conf,
3832            ExpectedEncode, ExpectedDecode).
3833
3834pretty_otp7671(Msg, Conf, ExpectedEncode, ExpectedDecode, Check) ->
3835    otp7671(Msg, megaco_pretty_text_encoder, Conf,
3836            ExpectedEncode, ExpectedDecode, Check).
3837
3838otp7671(Msg, Codec, Conf, ExpectedEncode, ExpectedDecode) ->
3839    Check = fun(M1, M2) ->
3840		    exit({unexpected_decode_result, M1, M2})
3841	    end,
3842    otp7671(Msg, Codec, Conf, ExpectedEncode, ExpectedDecode, Check).
3843
3844otp7671(Msg, Codec, Conf, ExpectedEncode, ExpectedDecode, Check) ->
3845    case (catch encode_message(Codec, Conf, Msg)) of
3846        {error, _Reason} when ExpectedEncode =:= error ->
3847            ok;
3848        {error, Reason} when ExpectedEncode =:= ok ->
3849            exit({unexpected_encode_failure, Reason});
3850        {ok, Bin} when ExpectedEncode =:= error ->
3851            exit({unexpected_encode_success, Msg, binary_to_list(Bin)});
3852        {ok, Bin} when ExpectedEncode =:= ok ->
3853            case decode_message(Codec, false, Conf, Bin) of
3854                {ok, Msg} when ExpectedDecode =:= ok ->
3855		    ok;
3856                {ok, Msg2} when ExpectedDecode =:= ok ->
3857		    Check(Msg, Msg2);
3858                {ok, Msg} when ExpectedDecode =:= error ->
3859                    exit({unexpected_decode_success, Msg});
3860                {ok, Msg2} when ExpectedDecode =:= error ->
3861                    exit({unexpected_decode_success, Msg, Msg2});
3862                {error, _Reason} when ExpectedDecode =:= error ->
3863                    ok;
3864                {error, Reason} when ExpectedDecode == ok ->
3865                    exit({unexpected_decode_failure, Msg, Reason})
3866            end
3867    end.
3868
3869
3870pretty_otp7671_msg(DigitMapDesc) ->
3871    AmmReq = cre_AmmReq([#megaco_term_id{id = ?A4444}],
3872			[{digitMapDescriptor, DigitMapDesc}]),
3873    CmdReq = cre_CmdReq({modReq, AmmReq}),
3874    msg_request(?MGC_MID, 10001, ?megaco_null_context_id, [CmdReq]).
3875
3876pretty_otp7671_msg01() ->
3877    Name         = "dialplan01",
3878    DigitMapDesc = cre_DigitMapDesc(Name),
3879    pretty_otp7671_msg(DigitMapDesc).
3880
3881pretty_otp7671_msg02() ->
3882    Name         = "dialplan02",
3883    Body         = "(0s| 00s|[1-7]xlxx|8lxxxxxxx|#xxxxxxx|*xx|9l1xxxxxxxxxx|9l011x.s)",
3884    Value        = cre_DigitMapValue(Body),
3885    DigitMapDesc = cre_DigitMapDesc(Name, Value),
3886    pretty_otp7671_msg(DigitMapDesc).
3887
3888pretty_otp7671_msg03() ->
3889    Body         = "(0s| 00s|[1-7]xlxx|8lxxxxxxx|#xxxxxxx|*xx|9l1xxxxxxxxxx|9l011x.s)",
3890    Value        = cre_DigitMapValue(Body),
3891    DigitMapDesc = cre_DigitMapDesc(Value),
3892    pretty_otp7671_msg(DigitMapDesc).
3893
3894pretty_otp7671_msg04() ->
3895    DigitMapDesc = cre_DigitMapDesc(),
3896    pretty_otp7671_msg(DigitMapDesc).
3897
3898pretty_otp7671_msg05() ->
3899    {'MegacoMessage',asn1_NOVALUE,
3900     {'Message',?VERSION,
3901      {domainName,{'DomainName',"tgc",asn1_NOVALUE}},
3902      {transactions,
3903       [{transactionRequest,
3904	 {'TransactionRequest',12582952,
3905	  [{'ActionRequest',0,asn1_NOVALUE,asn1_NOVALUE,
3906	    [{'CommandRequest',
3907	      {modReq,
3908	       {'AmmRequest',
3909		[{megaco_term_id,false,["root"]}],
3910		[{digitMapDescriptor,
3911		  {'DigitMapDescriptor',"dialplan1",
3912		   {'DigitMapValue',asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,[],
3913		    asn1_NOVALUE}}}]}},
3914	      asn1_NOVALUE,asn1_NOVALUE}]}]}}]}}}.
3915
3916cmp_otp7671_msg05(#'MegacoMessage'{authHeader = asn1_NOVALUE,
3917				   mess       = M1},
3918		  #'MegacoMessage'{authHeader = asn1_NOVALUE,
3919				   mess       = M2}) ->
3920    #'Message'{messageBody = Body1} = M1,
3921    #'Message'{messageBody = Body2} = M2,
3922    {transactions, Trans1} = Body1,
3923    {transactions, Trans2} = Body2,
3924    [{transactionRequest, TR1}] = Trans1,
3925    [{transactionRequest, TR2}] = Trans2,
3926    #'TransactionRequest'{actions = Acts1} = TR1,
3927    #'TransactionRequest'{actions = Acts2} = TR2,
3928    [#'ActionRequest'{commandRequests = CR1}] = Acts1,
3929    [#'ActionRequest'{commandRequests = CR2}] = Acts2,
3930    [#'CommandRequest'{command = Cmd1}] = CR1,
3931    [#'CommandRequest'{command = Cmd2}] = CR2,
3932    {modReq, #'AmmRequest'{descriptors = Descs1}} = Cmd1,
3933    {modReq, #'AmmRequest'{descriptors = Descs2}} = Cmd2,
3934    [{digitMapDescriptor,
3935      #'DigitMapDescriptor'{digitMapName = Name,
3936			    digitMapValue = Value1}}] = Descs1,
3937    [{digitMapDescriptor,
3938      #'DigitMapDescriptor'{digitMapName = Name,
3939			    digitMapValue = Value2}}] = Descs2,
3940    #'DigitMapValue'{startTimer    = asn1_NOVALUE,
3941		     shortTimer    = asn1_NOVALUE,
3942		     longTimer     = asn1_NOVALUE,
3943		     digitMapBody  = [],
3944		     durationTimer = asn1_NOVALUE} = Value1,
3945    asn1_NOVALUE = Value2,
3946    ok.
3947
3948
3949%% --------------------------------------------------------------
3950%%
3951
3952
3953pretty_otp8114_msg01(suite) ->
3954    [];
3955pretty_otp8114_msg01(Config) when is_list(Config) ->
3956    put(severity, trc),
3957    put(dbg,      true),
3958    d("pretty_otp8114_msg01 -> entry", []),
3959    ok = otp8114( pretty_otp8114_msg01(), megaco_pretty_text_encoder, ?EC),
3960    erase(dbg),
3961    erase(severity),
3962    ok.
3963
3964pretty_otp8114_msg01() ->
3965    "MEGACO/" ?VERSION_STR  " [10.10.10.10]:1234\nTransaction = 1 {\n\tContext =\n1 {\n\t\tModify = ip/1/1/1 {\n\t\t\tMedia {\n\t\t\t\tStream = 1\n{\n\t\t\t\t\t\tLocalControl {\n\t\t\t\t\t\tMode =\nSendReceive\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tEvents = 1\n{\n\t\t\t\tadid/ipstop\n{\n\t\t\t\t\tdt=30,\n\t\t\t\t\tdir=\"BOTH\"\n\t\t\t\t},\n\t\t\t\tg/cause\n\n\t\t\t}\n\t\t}\n\t}\n}".
3966
3967
3968otp8114(InitialMessage, Codec, Conf) ->
3969    Decode = fun(M) -> Codec:decode_message(Conf, M) end,
3970    Encode = fun(B) -> Codec:encode_message(Conf, B) end,
3971    InitialData = InitialMessage,
3972    Instructions =
3973	[
3974	 %% List to binary
3975	 megaco_codec_test_lib:expect_instruction(
3976	   "Convert (initial) message to a binary",
3977	   fun(Msg) when is_list(Msg) ->
3978		   %% io:format("~s~n", [Msg]),
3979		   {ok, list_to_binary(Msg)};
3980	      (Bad) ->
3981		   {error, {invalid_data, Bad}}
3982	   end,
3983	   fun({ok, Bin}, _Msg) when is_binary(Bin) ->
3984		   {ok, Bin};
3985	      (Bad, _Msg) ->
3986		   {error, {failed_to_binary, Bad}}
3987	   end),
3988
3989	 %% Initial decode
3990	 megaco_codec_test_lib:expect_instruction(
3991	   "Decode (initial) message",
3992	   fun(Bin) when is_binary(Bin) ->
3993		   (catch Decode(Bin));
3994	      (Bad) ->
3995		   {error, {invalid_data, Bad}}
3996	   end,
3997	   fun({ok, Msg}, _Bin) when is_record(Msg, 'MegacoMessage') ->
3998		   %% io:format("~p~n", [Msg]),
3999		   {ok, Msg};
4000	      (Bad, _) ->
4001		   {error, {initial_decode_failed, Bad}}
4002	   end),
4003
4004	 %% Encode
4005	 megaco_codec_test_lib:expect_instruction(
4006	   "Encode message",
4007	   fun(Msg) when is_record(Msg, 'MegacoMessage') ->
4008		   (catch Encode(Msg));
4009	      (Bad) ->
4010		   {error, {invalid_data, Bad}}
4011	   end,
4012	   fun({ok, Bin}, _Msg) when is_binary(Bin) ->
4013		   %% io:format("~s~n", [binary_to_list(Bin)]),
4014		   {ok, Bin};
4015	      (Bad, _) ->
4016		   {error, {encode_failed, Bad}}
4017	   end),
4018
4019	 %% Decode
4020	 megaco_codec_test_lib:expect_instruction(
4021	   "(final) Decode message",
4022	   fun(Bin) when is_binary(Bin) ->
4023		   (catch Decode(Bin));
4024	      (Bad) ->
4025		   {error, {invalid_data, Bad}}
4026	   end,
4027	   fun({ok, Msg}, _Bin) when is_record(Msg, 'MegacoMessage') ->
4028		   %% io:format("~p~n", [Msg]),
4029		   {ok, Msg};
4030	      (Bad, _) ->
4031		   {error, {decode_failed, Bad}}
4032	   end)
4033	],
4034    megaco_codec_test_lib:expect_exec(Instructions, InitialData).
4035
4036
4037%% ==============================================================
4038%%
4039%% F l e x   P r e t t y   T e s t c a s e s
4040%%
4041
4042flex_pretty_otp5042_msg1(suite) ->
4043    [];
4044flex_pretty_otp5042_msg1(Config) when is_list(Config) ->
4045    %% put(severity,trc),
4046    %% put(dbg,true),
4047    d("flex_pretty_otp5042_msg1 -> entry", []),
4048    ?ACQUIRE_NODES(1, Config),
4049    ok = ticket_pretty_decode_only( pretty_otp5042_msg1() ),
4050    %% erase(severity),
4051    %% erase(dbg),
4052    ok.
4053
4054
4055%% --------------------------------------------------------------
4056%%
4057flex_pretty_otp5085_msg1(suite) ->
4058    [];
4059flex_pretty_otp5085_msg1(Config) when is_list(Config) ->
4060    %% put(severity,trc),
4061    %% put(dbg,true),
4062    d("flex_pretty_otp5085_msg1 -> entry", []),
4063    ?ACQUIRE_NODES(1, Config),
4064    Conf = flex_scanner_conf(Config),
4065    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg1(), [Conf] ),
4066    %% erase(severity),
4067    %% erase(dbg),
4068    ok.
4069
4070flex_pretty_otp5085_msg2(suite) ->
4071    [];
4072flex_pretty_otp5085_msg2(Config) when is_list(Config) ->
4073    %% put(severity,trc),
4074    %% put(dbg,true),
4075    d("flex_pretty_otp5085_msg2 -> entry", []),
4076    ?ACQUIRE_NODES(1, Config),
4077    Conf = flex_scanner_conf(Config),
4078    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg1(), [Conf] ),
4079    %% erase(severity),
4080    %% erase(dbg),
4081    ok.
4082
4083flex_pretty_otp5085_msg3(suite) ->
4084    [];
4085flex_pretty_otp5085_msg3(Config) when is_list(Config) ->
4086    %% put(severity,trc),
4087    %% put(dbg,true),
4088    d("flex_pretty_otp5085_msg3 -> entry", []),
4089    ?ACQUIRE_NODES(1, Config),
4090    Conf = flex_scanner_conf(Config),
4091    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg1(), [Conf] ),
4092    %% erase(severity),
4093    %% erase(dbg),
4094    ok.
4095
4096flex_pretty_otp5085_msg4(suite) ->
4097    [];
4098flex_pretty_otp5085_msg4(Config) when is_list(Config) ->
4099    %% put(severity,trc),
4100    %% put(dbg,true),
4101    d("flex_pretty_otp5085_msg4 -> entry", []),
4102    ?ACQUIRE_NODES(1, Config),
4103    Conf = flex_scanner_conf(Config),
4104    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg1(), [Conf] ),
4105    %% erase(severity),
4106    %% erase(dbg),
4107    ok.
4108
4109flex_pretty_otp5085_msg5(suite) ->
4110    [];
4111flex_pretty_otp5085_msg5(Config) when is_list(Config) ->
4112    %% put(severity,trc),
4113    %% put(dbg,true),
4114    d("flex_pretty_otp5085_msg5 -> entry", []),
4115    ?ACQUIRE_NODES(1, Config),
4116    Conf = flex_scanner_conf(Config),
4117    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg1(), [Conf] ),
4118    %% erase(severity),
4119    %% erase(dbg),
4120    ok.
4121
4122flex_pretty_otp5085_msg6(suite) ->
4123    [];
4124flex_pretty_otp5085_msg6(Config) when is_list(Config) ->
4125    %% put(severity,trc),
4126    %% put(dbg,true),
4127    d("flex_pretty_otp5085_msg6 -> entry", []),
4128    ?ACQUIRE_NODES(1, Config),
4129    Conf = flex_scanner_conf(Config),
4130    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg1(), [Conf] ),
4131    %% erase(severity),
4132    %% erase(dbg),
4133    ok.
4134
4135flex_pretty_otp5085_msg7(suite) ->
4136    [];
4137flex_pretty_otp5085_msg7(Config) when is_list(Config) ->
4138    %% put(severity,trc),
4139    %% put(dbg,true),
4140    d("flex_pretty_otp5085_msg7 -> entry", []),
4141    ?ACQUIRE_NODES(1, Config),
4142    Conf = flex_scanner_conf(Config),
4143    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg1(), [Conf] ),
4144    %% erase(severity),
4145    %% erase(dbg),
4146    ok.
4147
4148flex_pretty_otp5085_msg8(suite) ->
4149    [];
4150flex_pretty_otp5085_msg8(Config) when is_list(Config) ->
4151    %% put(severity,trc),
4152    %% put(dbg,true),
4153    d("flex_pretty_otp5085_msg8 -> entry", []),
4154    ?ACQUIRE_NODES(1, Config),
4155    Conf = flex_scanner_conf(Config),
4156    ok = ticket_pretty_encode_decode_ok( pretty_otp5085_msg1(), [Conf] ),
4157    %% erase(severity),
4158    %% erase(dbg),
4159    ok.
4160
4161
4162%% --------------------------------------------------------------
4163%%
4164flex_pretty_otp5600_msg1(suite) ->
4165    [];
4166flex_pretty_otp5600_msg1(Config) when is_list(Config) ->
4167    %% put(severity,trc),
4168    %% put(dbg,true),
4169    d("flex_pretty_otp5600_msg1 -> entry", []),
4170    ?ACQUIRE_NODES(1, Config),
4171    Conf = flex_scanner_conf(Config),
4172    ok = ticket_pretty_encode_decode_ok( pretty_otp5600_msg1(), [Conf] ),
4173    %% erase(severity),
4174    %% erase(dbg),
4175    ok.
4176
4177flex_pretty_otp5600_msg2(suite) ->
4178    [];
4179flex_pretty_otp5600_msg2(Config) when is_list(Config) ->
4180    %% put(severity,trc),
4181    %% put(dbg,true),
4182    d("flex_pretty_otp5600_msg2 -> entry", []),
4183    ?ACQUIRE_NODES(1, Config),
4184    Conf = flex_scanner_conf(Config),
4185    ok = ticket_pretty_encode_decode_ok( pretty_otp5600_msg2(), [Conf] ),
4186    %% erase(severity),
4187    %% erase(dbg),
4188    ok.
4189
4190
4191%% --------------------------------------------------------------
4192%%
4193flex_pretty_otp5601_msg1(suite) ->
4194    [];
4195flex_pretty_otp5601_msg1(Config) when is_list(Config) ->
4196    %% put(severity,trc),
4197    %% put(dbg,true),
4198    d("flex_pretty_otp5601_msg1 -> entry", []),
4199    ?ACQUIRE_NODES(1, Config),
4200    Conf = flex_scanner_conf(Config),
4201    ok = ticket_pretty_encode_decode_ok( pretty_otp5601_msg1(), [Conf] ),
4202    %% erase(severity),
4203    %% erase(dbg),
4204    ok.
4205
4206
4207%% --------------------------------------------------------------
4208%%
4209flex_pretty_otp5793_msg01(suite) ->
4210    [];
4211flex_pretty_otp5793_msg01(Config) when is_list(Config) ->
4212    %% put(severity,trc),
4213    %% put(dbg,true),
4214    d("flex_pretty_otp5793_msg01 -> entry", []),
4215    ?ACQUIRE_NODES(1, Config),
4216    Conf = flex_scanner_conf(Config),
4217    ok = ticket_pretty_encode_decode_ok( pretty_otp5793_msg1(), [Conf] ),
4218    %% erase(severity),
4219    %% erase(dbg),
4220    ok.
4221
4222
4223%% --------------------------------------------------------------
4224%%
4225flex_pretty_otp5803_msg01(suite) ->
4226    [];
4227flex_pretty_otp5803_msg01(Config) when is_list(Config) ->
4228    %% put(severity,trc),
4229    %% put(dbg,true),
4230    d("flex_pretty_otp5803_msg01 -> entry", []),
4231    ?ACQUIRE_NODES(1, Config),
4232    Conf = flex_scanner_conf(Config),
4233    ok = ticket_pretty_decode_encode_ok( pretty_otp5803_msg1(), [Conf] ),
4234    %% erase(severity),
4235    %% erase(dbg),
4236    ok.
4237
4238flex_pretty_otp5803_msg02(suite) ->
4239    [];
4240flex_pretty_otp5803_msg02(Config) when is_list(Config) ->
4241    %% put(severity,trc),
4242    %% put(dbg,true),
4243    d("flex_pretty_otp5803_msg02 -> entry", []),
4244    ?ACQUIRE_NODES(1, Config),
4245    Conf = flex_scanner_conf(Config),
4246    ok = ticket_pretty_decode_encode_ok( pretty_otp5803_msg2(), [Conf] ),
4247    %% erase(severity),
4248    %% erase(dbg),
4249    ok.
4250
4251
4252%% --------------------------------------------------------------
4253%%
4254flex_pretty_otp5805_msg01(suite) ->
4255    [];
4256flex_pretty_otp5805_msg01(Config) when is_list(Config) ->
4257    %% put(severity,trc),
4258    %% put(dbg,true),
4259    d("flex_pretty_otp5805_msg01 -> entry", []),
4260    ?ACQUIRE_NODES(1, Config),
4261    Conf = flex_scanner_conf(Config),
4262    ok = ticket_pretty_decode_error( pretty_otp5805_msg1(), [Conf] ),
4263    %% erase(severity),
4264    %% erase(dbg),
4265    ok.
4266
4267
4268%% --------------------------------------------------------------
4269%%
4270flex_pretty_otp5836_msg01(suite) ->
4271    [];
4272flex_pretty_otp5836_msg01(Config) when is_list(Config) ->
4273    %% put(severity,trc),
4274    %% put(dbg,true),
4275    d("flex_pretty_otp5836_msg01 -> entry", []),
4276    ?ACQUIRE_NODES(1, Config),
4277    Conf = flex_scanner_conf(Config),
4278    ok = ticket_pretty_encode_decode_ok( compact_otp5836_msg1(), [Conf] ),
4279    %% erase(severity),
4280    %% erase(dbg),
4281    ok.
4282
4283
4284flex_pretty_otp7431_msg01(suite) ->
4285    [];
4286flex_pretty_otp7431_msg01(Config) when is_list(Config) ->
4287    d("flex_pretty_otp7431_msg01 -> entry", []),
4288    ?ACQUIRE_NODES(1, Config),
4289    Conf = flex_scanner_conf(Config),
4290    flex_pretty_otp7431(ok, flex_pretty_otp7431_msg1(), [Conf]).
4291
4292flex_pretty_otp7431_msg02(suite) ->
4293    [];
4294flex_pretty_otp7431_msg02(Config) when is_list(Config) ->
4295    %%     put(severity,trc),
4296    %%     put(dbg,true),
4297    d("flex_pretty_otp7431_msg02 -> entry", []),
4298    ?ACQUIRE_NODES(1, Config),
4299    Conf = flex_scanner_conf(Config),
4300    flex_pretty_otp7431(error, flex_pretty_otp7431_msg2(), [?EC_V3,Conf]).
4301
4302flex_pretty_otp7431_msg03(suite) ->
4303    [];
4304flex_pretty_otp7431_msg03(Config) when is_list(Config) ->
4305    %%     put(severity,trc),
4306    %%     put(dbg,true),
4307    d("flex_pretty_otp7431_msg03 -> entry", []),
4308    ?ACQUIRE_NODES(1, Config),
4309    Conf = flex_scanner_conf(Config),
4310    flex_pretty_otp7431(error, flex_pretty_otp7431_msg3(), [?EC_V3,Conf]).
4311
4312flex_pretty_otp7431_msg04(suite) ->
4313    [];
4314flex_pretty_otp7431_msg04(Config) when is_list(Config) ->
4315    d("flex_pretty_otp7431_msg04 -> entry", []),
4316    ?ACQUIRE_NODES(1, Config),
4317    Conf = flex_scanner_conf(Config),
4318    flex_pretty_otp7431(error, flex_pretty_otp7431_msg4(), [?EC_V3,Conf]).
4319
4320flex_pretty_otp7431_msg05(suite) ->
4321    [];
4322flex_pretty_otp7431_msg05(Config) when is_list(Config) ->
4323    d("flex_pretty_otp7431_msg05 -> entry", []),
4324    ?ACQUIRE_NODES(1, Config),
4325    Conf = flex_scanner_conf(Config),
4326    flex_pretty_otp7431(error, flex_pretty_otp7431_msg5(), [?EC_V3,Conf]).
4327
4328flex_pretty_otp7431_msg06(suite) ->
4329    [];
4330flex_pretty_otp7431_msg06(Config) when is_list(Config) ->
4331    d("flex_pretty_otp7431_msg06 -> entry", []),
4332    ?ACQUIRE_NODES(1, Config),
4333    Conf = flex_scanner_conf(Config),
4334    flex_pretty_otp7431(error, flex_pretty_otp7431_msg6(), [?EC_V3,Conf]).
4335
4336flex_pretty_otp7431_msg07(suite) ->
4337    [];
4338flex_pretty_otp7431_msg07(Config) when is_list(Config) ->
4339    d("flex_pretty_otp7431_msg07 -> entry", []),
4340    ?ACQUIRE_NODES(1, Config),
4341    Conf = flex_scanner_conf(Config),
4342    flex_pretty_otp7431(error, flex_pretty_otp7431_msg7(), [?EC_V3,Conf]).
4343
4344flex_pretty_otp7431(Expected, Msg, Conf) ->
4345    otp7431(Expected, megaco_pretty_text_encoder, Msg, Conf).
4346
4347otp7431(Expected, Codec, Msg0, Conf) ->
4348    Bin0 = list_to_binary(Msg0),
4349    case decode_message(Codec, false, Conf, Bin0) of
4350	{ok, _Msg1} when Expected =:= ok ->
4351 	    io:format(" decoded", []);
4352	{error, {bad_property_parm, Reason}} when (Expected =:= error) andalso
4353						  is_list(Reason) ->
4354	    io:format("expected result: ~s", [Reason]),
4355	    ok;
4356	Else ->
4357	    io:format("unexpected result", []),
4358	    exit({unexpected_decode_result, Else})
4359    end.
4360
4361
4362flex_pretty_otp7431_msg1() ->
4363    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
4364   Context = 2000 {
4365	       Add = A4444,
4366	       Add = A4445 {
4367		       Media {
4368			 Stream = 1 {
4369				    Local {
4370				      v=0
4371				      o=- 2890844526 2890842807 IN IP4 124.124.124.222
4372				      s=-
4373				      t= 0 0
4374				      c=IN IP4 124.124.124.222
4375				      m=audio 2222 RTP/AVP 4
4376				      a=ptime:30
4377				      a=recvonly
4378				     } ; RTP profile for G.723.1 is 4
4379				   }
4380			}
4381		      }
4382	      }
4383       }".
4384
4385flex_pretty_otp7431_msg2() ->
4386    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
4387   Context = 2000 {
4388	       Add = A4444,
4389	       Add = A4445 {
4390		       Media {
4391			 Stream = 1 {
4392				    Local {
4393				      v=0
4394				      o=- 2890844526 2890842807 IN IP4 124.124.124.222
4395				      s=-
4396				      t= 0 0
4397				      c=IN IP4 124.124.124.222
4398				      m=audio 2222 RTP/AVP 4
4399				      a=ptime:30
4400				      a=             }
4401				   }
4402			}
4403		      }
4404	      }
4405       }".
4406
4407flex_pretty_otp7431_msg3() ->
4408    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
4409   Context = 2000 {
4410	       Add = A4444,
4411	       Add = A4445 {
4412		       Media {
4413			 Stream = 1 {
4414				    Local {
4415				      v=0
4416				      o=- 2890844526 2890842807 IN IP4 124.124.124.222
4417				      s=-
4418				      t= 0 0
4419				      c=IN IP4 124.124.124.222
4420				      m=audio 2222 RTP/AVP 4
4421				      a=ptime:30
4422				      a             }
4423				   }
4424			}
4425		      }
4426	      }
4427       }".
4428
4429flex_pretty_otp7431_msg4() ->
4430    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
4431   Context = 2000 {
4432	       Add = A4444,
4433	       Add = A4445 {
4434		       Media {
4435			 Stream = 1 {
4436				    Local {
4437				      v=0
4438				      o=- 2890844526 2890842807 IN IP4 124.124.124.222
4439				      s=-
4440				      t= 0 0
4441				      c=IN IP4 124.124.124.222
4442				      m=audio 2222 RTP/AVP 4
4443				      a=ptime:30
4444				      a}
4445				   }
4446			}
4447		      }
4448	      }
4449       }".
4450
4451flex_pretty_otp7431_msg5() ->
4452    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
4453   Context = 2000 {
4454	       Add = A4444,
4455	       Add = A4445 {
4456		       Media {
4457			 Stream = 1 {
4458				    Local {
4459				      v=            }
4460				   }
4461			}
4462		      }
4463	      }
4464       }".
4465
4466flex_pretty_otp7431_msg6() ->
4467    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
4468   Context = 2000 {
4469	       Add = A4444,
4470	       Add = A4445 {
4471		       Media {
4472			 Stream = 1 {
4473				    Local {
4474				      v            }
4475				   }
4476			}
4477		      }
4478	      }
4479       }".
4480
4481flex_pretty_otp7431_msg7() ->
4482    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
4483   Context = 2000 {
4484	       Add = A4444,
4485	       Add = A4445 {
4486		       Media {
4487			 Stream = 1 {
4488				    Local {
4489				      v}
4490				   }
4491			}
4492		      }
4493	      }
4494       }".
4495
4496
4497
4498%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4499
4500msgs() ->
4501    [M || {_, M, _, _} <- msgs(text)].
4502
4503msgs(Encoding) ->
4504    msgs1a(Encoding) ++
4505	msgs1b(Encoding) ++
4506	msgs3525(Encoding) ++
4507	msgs5(Encoding) ++
4508	msgs6(Encoding) ++
4509	msgs7(Encoding).
4510
4511msgs1a(_) ->
4512    Plain =
4513	fun(Codec, DD, Ver, EC, M) ->
4514		megaco_codec_test_lib:plain_encode_decode(Codec, DD, Ver,
4515							  EC, M)
4516	end,
4517    [
4518     {msg01a, msg1a(),  Plain, [{dbg,false}]},
4519     {msg01b, msg1b(),  Plain, [{dbg,false}]},
4520     {msg02,  msg2(),   Plain, [{dbg,false}]},
4521     {msg03,  msg3(),   Plain, [{dbg,false}]},
4522     {msg04,  msg4(),   Plain, [{dbg,false}]},
4523     {msg05,  msg5(),   Plain, [{dbg,false}]},
4524     {msg06a, msg6a(),  Plain, [{dbg,false}]},
4525     {msg06b, msg6b(),  Plain, [{dbg,false}]},
4526     {msg07,  msg7(),   Plain, [{dbg,false}]},
4527     {msg08a, msg8a(),  Plain, [{dbg,false}]},
4528     {msg08b, msg8b(),  Plain, [{dbg,false}]},
4529     {msg09,  msg9(),   Plain, [{dbg,false}]},
4530     {msg10,  msg10(),  Plain, [{dbg,false}]},
4531     {msg11,  msg11(),  Plain, [{dbg,false}]},
4532     {msg12,  msg12(),  Plain, [{dbg,false}]},
4533     {msg13,  msg13(),  Plain, [{dbg,false}]},
4534     {msg14,  msg14(),  Plain, [{dbg,false}]},
4535     {msg15,  msg15(),  Plain, [{dbg,false}]},
4536     {msg16,  msg16(),  Plain, [{dbg,false}]},
4537     {msg17,  msg17(),  Plain, [{dbg,false}]},
4538     {msg18,  msg18(),  Plain, [{dbg,false}]},
4539     {msg19,  msg19(),  Plain, [{dbg,false}]},
4540     {msg20,  msg20(),  Plain, [{dbg,false}]},
4541     {msg21,  msg21(),  Plain, [{dbg,false}]},
4542     {msg22a, msg22a(), Plain, [{dbg,false}]},
4543     {msg22b, msg22b(), Plain, [{dbg,false}]},
4544     {msg22c, msg22c(), Plain, [{dbg,false}]},
4545     {msg22d, msg22d(), Plain, [{dbg,false}]},
4546     {msg22e, msg22e(), Plain, [{dbg,false}]},
4547     {msg22f, msg22f(), Plain, [{dbg,false}]},
4548     {msg23a, msg23a(), Plain, [{dbg,false}]},
4549     {msg23b, msg23b(), Plain, [{dbg,false}]},
4550     {msg23c, msg23c(), Plain, [{dbg,false}]},
4551     {msg23d, msg23d(), Plain, [{dbg,false}]},
4552     {msg24,  msg24(),  Plain, [{dbg,false}]},
4553     {msg25,  msg25(),  Plain, [{dbg,false}]},
4554     {msg30a, msg30a(), Plain, [{dbg,false}]},
4555     {msg30b, msg30b(), Plain, [{dbg,false}]},
4556     {msg30c, msg30c(), Plain, [{dbg,false}]},
4557     {msg30d, msg30d(), Plain, [{dbg,false}]}
4558    ].
4559
4560
4561msgs1b(_) ->
4562    TransFirst =
4563	fun(Codec, DD, Ver, EC, M) ->
4564		megaco_codec_test_lib:trans_first_encode_decode(Codec, DD,
4565								Ver, EC, M)
4566	end,
4567    ActionsFirst =
4568	fun(Codec, DD, Ver, EC, M) ->
4569		megaco_codec_test_lib:actions_first_encode_decode(Codec, DD,
4570								  Ver, EC, M)
4571	end,
4572    ActionFirst =
4573	fun(Codec, DD, Ver, EC, M) ->
4574		megaco_codec_test_lib:action_first_encode_decode(Codec, DD,
4575								 Ver, EC, M)
4576	end,
4577    [
4578     {msg01a_tf,  msg1a(),  TransFirst,   [{dbg,false}]},
4579     {msg02_tf,   msg2(),   TransFirst,   [{dbg,false}]},
4580     {msg10_tf,   msg10(),  TransFirst,   [{dbg,false}]},
4581     {msg11_tf,   msg11(),  TransFirst,   [{dbg,false}]},
4582     {msg23d_tf,  msg23d(), TransFirst,   [{dbg,false}]},
4583     {msg30b_tf,  msg30b(), TransFirst,   [{dbg,false}]},
4584     {msg30c_tf,  msg30c(), TransFirst,   [{dbg,false}]},
4585     {msg01a_asf, msg1a(),  ActionsFirst, [{dbg,false}]},
4586     {msg02_asf,  msg2(),   ActionsFirst, [{dbg,false}]},
4587     {msg10_asf,  msg10(),  ActionsFirst, [{dbg,false}]},
4588     {msg23d_asf, msg23d(), ActionsFirst, [{dbg,false}]},
4589     {msg01a_af,  msg1a(),  ActionFirst,  [{dbg,false}]},
4590     {msg02_af,   msg2(),   ActionFirst,  [{dbg,false}]},
4591     {msg10_af,   msg10(),  ActionFirst,  [{dbg,false}]},
4592     {msg23d_af,  msg23d(), ActionFirst,  [{dbg,false}]}
4593    ].
4594
4595
4596msgs3525(_) ->
4597    Plain =
4598	fun(Codec, DD, Ver, EC, M) ->
4599		megaco_codec_test_lib:plain_encode_decode(Codec, DD, Ver,
4600							  EC, M)
4601	end,
4602    [{msgs3_name(Name), rfc3525_decode(M), Plain, [{dbg, false}]} ||
4603	{Name, M} <- rfc3525_msgs()].
4604
4605msgs3_name(N) ->
4606    list_to_atom("rfc3525_" ++ atom_to_list(N)).
4607
4608rfc3525_decode(M) when is_list(M) ->
4609    rfc3525_decode(list_to_binary(M));
4610rfc3525_decode(M) when is_binary(M) ->
4611    case (catch decode_message(megaco_pretty_text_encoder, false, ?EC, M)) of
4612	{ok, Msg} ->
4613	    Msg;
4614	Error ->
4615	    {error, {rfc3525_decode_error, Error}}
4616    end.
4617
4618
4619msgs5(_) ->
4620    Plain =
4621	fun(Codec, DD, Ver, EC, M) ->
4622		megaco_codec_test_lib:plain_encode_decode(Codec, DD, Ver,
4623							  EC, M)
4624	end,
4625    [
4626     {msg51a, msg51a(), Plain, [{dbg, false}]},
4627     {msg51b, msg51b(), Plain, [{dbg, false}]},
4628     {msg51c, msg51c(), Plain, [{dbg, false}]},
4629     {msg51d, msg51d(), Plain, [{dbg, false}]},
4630     {msg51e, msg51e(), Plain, [{dbg, false}]},
4631     {msg51f, msg51f(), Plain, [{dbg, false}]},
4632     {msg51g, msg51g(), Plain, [{dbg, false}]},
4633     {msg51h, msg51h(), Plain, [{dbg, false}]},
4634     {msg51i, msg51i(), Plain, [{dbg, false}]},
4635     {msg52,  msg52(),  Plain, [{dbg, false}]},
4636     {msg53,  msg53(),  Plain, [{dbg, false}]},
4637     {msg54a, msg54a(), Plain, [{dbg, false}]},
4638     {msg54b, msg54b(), Plain, [{dbg, false}]},
4639     {msg54c, msg54c(), Plain, [{dbg, false}]},
4640     {msg55,  msg55(),  Plain, [{dbg, false}]},
4641     {msg56,  msg56(),  Plain, [{dbg, false}]},
4642     {msg57,  msg57(),  Plain, [{dbg, false}]},
4643     {msg58a, msg58a(), Plain, [{dbg, false}]},
4644     {msg58b, msg58b(), Plain, [{dbg, false}]}
4645    ].
4646
4647
4648msgs6(Encoding) ->
4649    Plain =
4650	fun(Codec, DD, Ver, EC, M) ->
4651		megaco_codec_test_lib:plain_encode_decode(Codec, DD, Ver,
4652							  EC, M)
4653	end,
4654
4655    PlainEDFail =
4656	fun(Codec, DD, Ver, EC, M) ->
4657		Res =
4658		    megaco_codec_test_lib:plain_encode_decode(Codec, DD, Ver,
4659							      EC, M),
4660		case Res of
4661		    {error, {message_encode_failed, Reason, _M}} ->
4662			case Reason of
4663			    {error, {{deprecated, _}, _}} ->
4664				ok;
4665			    _ ->
4666				Res
4667			end;
4668		    _ ->
4669			Res
4670		end
4671	end,
4672
4673    PlainDE =
4674	fun(Codec, _DD, Ver, EC, B) ->
4675		Res =
4676		    megaco_codec_test_lib:decode_message(Codec, false, Ver,
4677							 EC, B),
4678		case Res of
4679		    {ok, M} ->
4680			#'MegacoMessage'{mess = Mess} = M,
4681			#'Message'{messageBody = {transactions, TRs}} = Mess,
4682			[{transactionRequest, TR}] = TRs,
4683			#'TransactionRequest'{actions = Actions} = TR,
4684			[Action] = Actions,
4685			#'ActionRequest'{commandRequests = CmdReqs} = Action,
4686			[CmdReq] = CmdReqs,
4687			#'CommandRequest'{command = Cmd} = CmdReq,
4688			{addReq,AmmReq} = Cmd,
4689			#'AmmRequest'{descriptors = []} = AmmReq,
4690			ok;
4691		    _ ->
4692			Res
4693		end
4694	end,
4695
4696    Msgs =
4697	[
4698	 {msg61a, msg61a(), Plain,       [{dbg,false}],[text,binary,erlang]},
4699	 {msg61b, msg61b(), Plain,       [{dbg,false}],[text,binary,erlang]},
4700	 {msg61c, msg61c(), Plain,       [{dbg,false}],[text,binary,erlang]},
4701	 {msg62a, msg62a(), PlainEDFail, [{dbg,false}],[text,binary,erlang]},
4702	 {msg62b, msg62b(), PlainDE,     [{dbg,false}],[text]}
4703	],
4704    [{N,M,F,C}||{N,M,F,C,E} <- Msgs,lists:member(Encoding,E)].
4705
4706
4707msgs7(Encoding) ->
4708    Plain =
4709	fun(Codec, DD, Ver, EC, M) ->
4710		megaco_codec_test_lib:plain_encode_decode(Codec, DD, Ver,
4711							  EC, M)
4712	end,
4713
4714    Msgs =
4715	[
4716  	 {msg71a,   msg71a(),   Plain, [{dbg,false}],[text,binary,erlang]},
4717  	 {msg71b01, msg71b01(), Plain, [{dbg,false}],[text,binary,erlang]},
4718  	 {msg71b02, msg71b02(), Plain, [{dbg,false}],[text,binary,erlang]},
4719  	 {msg71b03, msg71b03(), Plain, [{dbg,false}],[text,binary,erlang]},
4720  	 {msg71b04, msg71b04(), Plain, [{dbg,false}],[text,binary,erlang]},
4721  	 {msg71b05, msg71b05(), Plain, [{dbg,false}],[text,binary,erlang]},
4722  	 {msg71b06, msg71b06(), Plain, [{dbg,false}],[text,binary,erlang]},
4723  	 {msg71b07, msg71b07(), Plain, [{dbg,false}],[text,binary,erlang]},
4724  	 {msg71b08, msg71b08(), Plain, [{dbg,false}],[text,binary,erlang]},
4725  	 {msg71b09, msg71b09(), Plain, [{dbg,false}],[text,binary,erlang]},
4726     	 {msg71b10, msg71b10(), Plain, [{dbg,false}],[text,binary,erlang]},
4727     	 {msg71b11, msg71b11(), Plain, [{dbg,false}],[text,binary,erlang]},
4728     	 {msg71b12, msg71b12(), Plain, [{dbg,false}],[text,binary,erlang]},
4729     	 {msg71b13, msg71b13(), Plain, [{dbg,false}],[text,binary,erlang]},
4730     	 {msg71b14, msg71b14(), Plain, [{dbg,false}],[text,binary,erlang]},
4731     	 {msg71b15, msg71b15(), Plain, [{dbg,false}],[text,binary,erlang]},
4732     	 {msg71b16, msg71b16(), Plain, [{dbg,false}],[text,binary,erlang]},
4733     	 {msg71b17, msg71b17(), Plain, [{dbg,false}],[text,binary,erlang]},
4734     	 {msg71b18, msg71b18(), Plain, [{dbg,false}],[text,binary,erlang]},
4735     	 {msg71b19, msg71b19(), Plain, [{dbg,false}],[text,binary,erlang]},
4736     	 {msg71b20, msg71b20(), Plain, [{dbg,false}],[text,binary,erlang]},
4737     	 {msg71b21, msg71b21(), Plain, [{dbg,false}],[text,binary,erlang]},
4738     	 {msg71b22, msg71b22(), Plain, [{dbg,false}],[text,binary,erlang]},
4739     	 {msg71c01, msg71c01(), Plain, [{dbg,false}],[text,binary,erlang]},
4740     	 {msg71c02, msg71c02(), Plain, [{dbg,false}],[text,binary,erlang]},
4741     	 {msg71c03, msg71c03(), Plain, [{dbg,false}],[text,binary,erlang]},
4742     	 {msg71c04, msg71c04(), Plain, [{dbg,false}],[text,binary,erlang]},
4743     	 {msg71c05, msg71c05(), Plain, [{dbg,false}],[text,binary,erlang]},
4744     	 {msg71c06, msg71c06(), Plain, [{dbg,false}],[text,binary,erlang]},
4745     	 {msg71c07, msg71c07(), Plain, [{dbg,false}],[text,binary,erlang]},
4746     	 {msg71c08, msg71c08(), Plain, [{dbg,false}],[text,binary,erlang]},
4747   	 {msg71c09, msg71c09(), Plain, [{dbg,false}],[text,binary,erlang]},
4748   	 {msg71c10, msg71c10(), Plain, [{dbg,false}],[text,binary,erlang]},
4749   	 {msg71c11, msg71c11(), Plain, [{dbg,false}],[text,binary,erlang]},
4750   	 {msg71c12, msg71c12(), Plain, [{dbg,false}],[text,binary,erlang]},
4751   	 {msg71c13, msg71c13(), Plain, [{dbg,false}],[text,binary,erlang]},
4752   	 {msg71c14, msg71c14(), Plain, [{dbg,false}],[text,binary,erlang]},
4753   	 {msg71c15, msg71c15(), Plain, [{dbg,false}],[text,binary,erlang]},
4754     	 {msg71d01, msg71d01(), Plain, [{dbg,false}],[text,binary,erlang]},
4755     	 {msg71d02, msg71d02(), Plain, [{dbg,false}],[text,binary,erlang]},
4756     	 {msg71d03, msg71d03(), Plain, [{dbg,false}],[text,binary,erlang]},
4757     	 {msg71d04, msg71d04(), Plain, [{dbg,false}],[text,binary,erlang]},
4758     	 {msg72a01, msg72a01(), Plain, [{dbg,false}],[text,binary,erlang]},
4759     	 {msg72a02, msg72a02(), Plain, [{dbg,false}],[text,binary,erlang]},
4760     	 {msg72a03, msg72a03(), Plain, [{dbg,false}],[text,binary,erlang]},
4761     	 {msg72b01, msg72b01(), Plain, [{dbg,false}],[text,binary,erlang]},
4762     	 {msg72b02, msg72b02(), Plain, [{dbg,false}],[text,binary,erlang]},
4763     	 {msg72b03, msg72b03(), Plain, [{dbg,false}],[text,binary,erlang]},
4764     	 {msg72b04, msg72b04(), Plain, [{dbg,false}],[text,binary,erlang]},
4765     	 {msg72c01, msg72c01(), Plain, [{dbg,false}],[text,binary,erlang]},
4766     	 {msg72c02, msg72c02(), Plain, [{dbg,false}],[text,binary,erlang]},
4767     	 {msg72c03, msg72c03(), Plain, [{dbg,false}],[text,binary,erlang]},
4768     	 {msg72c04, msg72c04(), Plain, [{dbg,false}],[text,binary,erlang]},
4769     	 {msg73a,   msg73a(),   Plain, [{dbg,false}],[text,binary,erlang]},
4770     	 {msg73b01, msg73b01(), Plain, [{dbg,false}],[text,binary,erlang]},
4771     	 {msg73b02, msg73b02(), Plain, [{dbg,false}],[text,binary,erlang]},
4772     	 {msg73c01, msg73c01(), Plain, [{dbg,false}],[text,binary,erlang]},
4773     	 {msg73c02, msg73c02(), Plain, [{dbg,false}],[text,binary,erlang]},
4774     	 {msg74a01, msg74a01(), Plain, [{dbg,false}],[text,binary,erlang]},
4775     	 {msg74a02, msg74a02(), Plain, [{dbg,false}],[text,binary,erlang]},
4776     	 {msg74a03, msg74a03(), Plain, [{dbg,false}],[text,binary,erlang]},
4777     	 {msg74a04, msg74a04(), Plain, [{dbg,false}],[text,binary,erlang]},
4778     	 {msg74a05, msg74a05(), Plain, [{dbg,false}],[text,binary,erlang]},
4779     	 {msg74a06, msg74a06(), Plain, [{dbg,false}],[text,binary,erlang]},
4780     	 {msg75a01, msg75a01(), Plain, [{dbg,false}],[text,binary,erlang]},
4781     	 {msg75a02, msg75a02(), Plain, [{dbg,false}],[text,binary,erlang]},
4782     	 {msg76a01, msg76a01(), Plain, [{dbg,false}],[text,binary,erlang]},
4783     	 {msg76a02, msg76a02(), Plain, [{dbg,false}],[text,binary,erlang]},
4784     	 {msg76b01, msg76b01(), Plain, [{dbg,false}],[text,binary,erlang]},
4785  	 %% {msg76b02, msg76b02(), Plain, [{dbg,true}],[text,binary,erlang]},
4786     	 {msg77a01, msg77a01(), Plain, [{dbg,false}],[text,binary,erlang]},
4787     	 {msg78a01, msg78a01(), Plain, [{dbg,false}],[text,binary,erlang]},
4788     	 {msg78a02, msg78a02(), Plain, [{dbg,false}],[text,binary,erlang]},
4789     	 {msg78a03, msg78a03(), Plain, [{dbg,false}],[text,binary,erlang]},
4790     	 {msg78a04, msg78a04(), Plain, [{dbg,false}],[text,binary,erlang]},
4791     	 {msg78a05, msg78a05(), Plain, [{dbg,false}],[text,binary,erlang]},
4792     	 {msg78a06, msg78a06(), Plain, [{dbg,false}],[text,binary,erlang]},
4793     	 {msg78a07, msg78a07(), Plain, [{dbg,false}],[text,binary,erlang]},
4794     	 {msg78a08, msg78a08(), Plain, [{dbg,false}],[text,binary,erlang]},
4795     	 {msg78a09, msg78a09(), Plain, [{dbg,false}],[text,binary,erlang]},
4796  	 {msg79a01, msg79a01(), Plain, [{dbg,false}],[text,binary,erlang]}
4797	],
4798    [{N,M,F,C}||{N,M,F,C,E} <- Msgs,lists:member(Encoding,E)].
4799
4800
4801
4802%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4803
4804msg_actions([], Actions) ->
4805    lists:reverse(Actions);
4806msg_actions([{CtxId, CmdReqs}|ActionInfo], Actions) ->
4807    Action = ?MSG_LIB:cre_ActionRequest(CtxId,CmdReqs),
4808    msg_actions(ActionInfo, [Action|Actions]).
4809
4810megaco_trans_req([], Transactions) ->
4811    {transactions, lists:reverse(Transactions)};
4812megaco_trans_req([{TransId, ActionInfo}|TransInfo], Transactions) ->
4813    Actions = msg_actions(ActionInfo, []),
4814    TR      = ?MSG_LIB:cre_TransactionRequest(TransId, Actions),
4815    Trans   = ?MSG_LIB:cre_Transaction(TR),
4816    megaco_trans_req(TransInfo, [Trans|Transactions]).
4817
4818megaco_message(Version, Mid, Body) ->
4819    Mess = ?MSG_LIB:cre_Message(Version, Mid, Body),
4820    cre_MegacoMessage(Mess).
4821
4822msg_request(Mid, TransInfo) ->
4823    TransReq = megaco_trans_req(TransInfo, []),
4824    megaco_message(?VERSION, Mid, TransReq).
4825
4826msg_request(Mid, TransId, ContextId, CmdReq) ->
4827    Action  = ?MSG_LIB:cre_ActionRequest(ContextId, CmdReq),
4828    Actions = [Action],
4829    TR      = ?MSG_LIB:cre_TransactionRequest(TransId, Actions),
4830    Trans   = ?MSG_LIB:cre_Transaction(TR),
4831    Mess    = ?MSG_LIB:cre_Message(?VERSION, Mid, [Trans]),
4832    cre_MegacoMessage(Mess).
4833
4834msg_request(Auth, Mid, TransId, ContextId, CmdReq) ->
4835    Action  = ?MSG_LIB:cre_ActionRequest(ContextId, CmdReq),
4836    Actions = [Action],
4837    TR      = ?MSG_LIB:cre_TransactionRequest(TransId, Actions),
4838    Trans   = ?MSG_LIB:cre_Transaction(TR),
4839    Mess    = ?MSG_LIB:cre_Message(?VERSION, Mid, [Trans]),
4840    cre_MegacoMessage(Auth, Mess).
4841
4842msg_reply(Mid, TransId, Actions) ->
4843    TR    = cre_TransRep(TransId, Actions),
4844    Trans = ?MSG_LIB:cre_Transaction(TR),
4845    Mess  = ?MSG_LIB:cre_Message(?VERSION, Mid, [Trans]),
4846    cre_MegacoMessage(Mess).
4847
4848msg_reply(Mid, TransId, ContextId, CmdReply) ->
4849    Action  = cre_ActRep(ContextId, CmdReply),
4850    Actions = [Action],
4851    msg_reply(Mid, TransId, Actions).
4852
4853msg_ack(Mid, [Range|_] = Ranges) when is_tuple(Range) ->
4854    msg_ack(Mid, [Ranges]);
4855
4856msg_ack(Mid, Ranges) ->
4857    %% TRAs = make_tras(Ranges, []),
4858    TRAs = make_tras(Ranges),
4859    Req  = {transactions, TRAs},
4860    cre_MegacoMessage(?VERSION, Mid, Req).
4861
4862make_tras(TRARanges) ->
4863    F = fun(R) -> {transactionResponseAck, make_tra(R)} end,
4864    lists:map(F, TRARanges).
4865
4866make_tra(Ranges) ->
4867    F = fun({F,L}) -> cre_TransAck(F,L) end,
4868    lists:map(F, Ranges).
4869
4870
4871%% -------------------------------------------------------------------------
4872
4873
4874msg1(Mid, Tid) ->
4875    Gain  = cre_PropParm("tdmc/gain", "2"),
4876    Ec    = cre_PropParm("tdmc/ec", "g165"),
4877    LCD   = cre_LocalControlDesc(sendRecv,[Gain, Ec]),
4878    V     = cre_PropParm("v", "0"),
4879    %% C    = cre_PropParm("c", "IN IP4 $ "),
4880    C     = cre_PropParm("c", [$I,$N,$ ,$I,$P,$4,$ ,$$,$ ]),
4881    M     = cre_PropParm("m", "audio $ RTP/AVP 0"),
4882    A     = cre_PropParm("a", "fmtp:PCMU VAD=X-NNVAD"),
4883    LD    = cre_LocalRemoteDesc([[V, C, M, A]]),
4884    Parms = cre_StreamParms(LCD,LD),
4885    StreamDesc = cre_StreamDesc(1,Parms),
4886    MediaDesc  = cre_MediaDesc(StreamDesc),
4887    ReqEvent   = cre_ReqEv("al/of"),
4888    EventsDesc = cre_EvsDesc(2222,[ReqEvent]),
4889    AmmReq     = cre_AmmReq([#megaco_term_id{id = Tid}],
4890			    [{mediaDescriptor, MediaDesc},
4891			     {eventsDescriptor, EventsDesc}]),
4892    CmdReq     = cre_CmdReq({modReq, AmmReq}),
4893    Msg = msg_request(Mid, 9999, ?megaco_null_context_id, [CmdReq]),
4894    Msg.
4895
4896msg1a() ->
4897    msg1a(?MGC_MID).
4898msg1a(Mid) ->
4899    msg1(Mid, ?A4444).
4900
4901msg1b() ->
4902    msg1b(?MGC_MID).
4903msg1b(Mid) ->
4904    msg1(Mid, ?A4445).
4905
4906
4907%% --------------------------
4908
4909
4910msg2() ->
4911    msg2(?MGC_MID).
4912msg2(Mid) ->
4913    msg2(Mid, ?A4444).
4914msg2(Mid, Tid) ->
4915    Gain  = cre_PropParm("tdmc/gain", "2"),
4916    Ec    = cre_PropParm("tdmc/ec", "g165"),
4917    LCD   = cre_LocalControlDesc(sendRecv,[Gain, Ec]),
4918    V     = cre_PropParm("v", "0"),
4919    %% C    = cre_PropParm("c", "IN IP4 $ "),
4920    C     = cre_PropParm("c", [$I,$N,$ ,$I,$P,$4,$ ,$$,$ ]),
4921    M     = cre_PropParm("m", "audio $ RTP/AVP 0"),
4922    A     = cre_PropParm("a", "fmtp:PCMU VAD=X-NNVAD"),
4923    LD    = cre_LocalRemoteDesc([[V, C, M, A]]),
4924    Parms = cre_StreamParms(LCD,LD),
4925    StreamDesc = cre_StreamDesc(1,Parms),
4926    MediaDesc  = cre_MediaDesc(StreamDesc),
4927    EventParm  = cre_EvParm("strict",["exact"]),
4928    ReqEvent   = cre_ReqEv("al/of", [EventParm]),
4929    EventsDesc = cre_EvsDesc(2222,[ReqEvent]),
4930    AmmReq     = cre_AmmReq([#megaco_term_id{id = Tid}],
4931			    [{mediaDescriptor, MediaDesc},
4932			     {eventsDescriptor, EventsDesc}]),
4933    CmdReq     = cre_CmdReq({modReq, AmmReq}),
4934    msg_request(Mid, 9999, ?megaco_null_context_id, [CmdReq]).
4935
4936
4937%% --------------------------
4938
4939msg3() ->
4940    msg3(?MG1_MID).
4941msg3(Mid) ->
4942    TimeStamp = cre_TimeNot("19990729", "22000000"),
4943    Event     = cre_ObsEv("al/of",TimeStamp),
4944    Desc      = cre_ObsEvsDesc(2222,[Event]),
4945    NotifyReq = cre_NotifyReq([#megaco_term_id{id = ?A4444}],Desc),
4946    CmdReq    = cre_CmdReq({notifyReq, NotifyReq}),
4947    msg_request(Mid, 10000, ?megaco_null_context_id, [CmdReq]).
4948
4949
4950%% --------------------------
4951
4952msg4() ->
4953    msg4(?MG1_MID_NO_PORT, "901 mg col boot").
4954msg4(Mid, Reason) when is_list(Reason) ->
4955    Address = {portNumber, ?DEFAULT_PORT},
4956    Profile = cre_SvcChProf("resgw",1),
4957    Parm    = cre_SvcChParm(restart,Address,[Reason],Profile),
4958    Req     = cre_SvcChReq([?megaco_root_termination_id],Parm),
4959    CmdReq  = cre_CmdReq({serviceChangeReq, Req}),
4960    msg_request(Mid, 9998, ?megaco_null_context_id, [CmdReq]).
4961
4962
4963%% --------------------------
4964
4965msg5() ->
4966    msg5(?MGC_MID).
4967msg5(Mid) ->
4968    Address = {portNumber, ?DEFAULT_PORT},
4969    Profile = cre_SvcChProf("resgw",1),
4970    Parm    = cre_SvcChResParm(Address,Profile),
4971    Reply   = cre_SvcChRep([?megaco_root_termination_id],
4972			   {serviceChangeResParms,Parm}),
4973    msg_reply(Mid, 9998, ?megaco_null_context_id,
4974	      [{serviceChangeReply, Reply}]).
4975
4976
4977%% --------------------------
4978
4979msg6(Mid, Tid) ->
4980    Reply = cre_AmmsReply([#megaco_term_id{id = Tid}]),
4981    msg_reply(Mid, 9999, ?megaco_null_context_id, [{modReply, Reply}]).
4982
4983msg6a() ->
4984    msg6a(?MG1_MID).
4985msg6a(Mid) ->
4986    msg6(Mid, ?A4444).
4987
4988msg6b() ->
4989    msg6b(?MG2_MID).
4990msg6b(Mid) ->
4991    msg6(Mid, ?A5555).
4992
4993
4994%% --------------------------
4995
4996msg7() ->
4997    msg7(?MGC_MID).
4998msg7(Mid) ->
4999    Reply = cre_NotifyRep([#megaco_term_id{id = ?A4444}]),
5000    msg_reply(Mid, 10000, ?megaco_null_context_id, [{notifyReply, Reply}]).
5001
5002
5003%% --------------------------
5004
5005msg8(Mid, DigitMapValue) ->
5006    Strict = cre_EvParm("strict",["state"]),
5007    On     = cre_ReqEv("al/on", [Strict]),
5008    Name   = "dialplan00",
5009    EDM    = cre_EvDM(Name),
5010    Action = cre_ReqActs(EDM),
5011    Ce     = cre_ReqEv("dd/ce", Action),
5012    EventsDesc = cre_EvsDesc(2223, [On, Ce]),
5013    Signal     = cre_Sig("cg/rt"),
5014    DigMapDesc = cre_DigitMapDesc(Name, DigitMapValue),
5015    AmmReq     = cre_AmmReq([#megaco_term_id{id = ?A4444}],
5016                           [{eventsDescriptor, EventsDesc},
5017			    {signalsDescriptor, [{signal, Signal}]},
5018			    {digitMapDescriptor, DigMapDesc}]),
5019    CmdReq     = cre_CmdReq({modReq, AmmReq}),
5020    msg_request(Mid, 10001, ?megaco_null_context_id, [CmdReq]).
5021
5022msg8a() ->
5023    msg8a(?MGC_MID).
5024msg8a(Mid) ->
5025    Body = "(0s| 00s|[1-7]xlxx|8lxxxxxxx|#xxxxxxx|*xx|9l1xxxxxxxxxx|9l011x.s)",
5026    Value = cre_DigitMapValue(Body),
5027    msg8(Mid, Value).
5028
5029msg8b() ->
5030    msg8b(?MGC_MID).
5031msg8b(Mid) ->
5032    Body = "(0s| 00s|[1-7]xlxx|8lxxxxxxx|#xxxxxxx|*xx|9l1xxxxxxxxxx|9l011x.s)",
5033    Value = cre_DigitMapValue(Body, 1, 23, 99),
5034    msg8(Mid, Value).
5035
5036
5037%% --------------------------
5038
5039msg9() ->
5040    msg9(?MG1_MID).
5041msg9(Mid) ->
5042    TimeStamp = cre_TimeNot("19990729","22010001"),
5043    Parm      = cre_EvParm("ds",["916135551212"]),
5044    Event     = cre_ObsEv("dd/ce",TimeStamp,[Parm]),
5045    Desc      = cre_ObsEvsDesc(2223,[Event]),
5046    NotifyReq = cre_NotifyReq([#megaco_term_id{id = ?A4444}], Desc),
5047    CmdReq    = cre_CmdReq({notifyReq, NotifyReq}),
5048    msg_request(Mid, 10002, ?megaco_null_context_id, [CmdReq]).
5049
5050
5051%% --------------------------
5052
5053msg10() ->
5054    msg10(?MGC_MID).
5055msg10(Mid) ->
5056    AmmReq = cre_AmmReq([#megaco_term_id{id = ?A4444}],[]),
5057    CmdReq = cre_CmdReq({addReq, AmmReq}),
5058    Jit = cre_PropParm("nt/jit", "40"),
5059    LCD = cre_LocalControlDesc(recvOnly,[Jit]),
5060    V   = cre_PropParm("v", "0"),
5061    C   = cre_PropParm("c", "IN IP4 $ "),
5062    M   = cre_PropParm("m", "audio $ RTP/AVP 4"),
5063    A   = cre_PropParm("a", "ptime:30"),
5064    V2  = cre_PropParm("v", "0"),
5065    C2  = cre_PropParm("c", "IN IP4 $ "),
5066    M2  = cre_PropParm("m", "audio $ RTP/AVP 0"),
5067    LD  = cre_LocalRemoteDesc([[V, C, M, A], [V2, C2, M2]]),
5068    Parms      = cre_StreamParms(LCD, LD),
5069    StreamDesc = cre_StreamDesc(1,Parms),
5070    MediaDesc  = cre_MediaDesc(StreamDesc),
5071    ChooseTid  = #megaco_term_id{contains_wildcards = true,
5072				 id = [[?megaco_choose]]},
5073    AmmReq2    = cre_AmmReq([ChooseTid],[{mediaDescriptor, MediaDesc}]),
5074    CmdReq2    = cre_CmdReq({addReq, AmmReq2}),
5075    msg_request(Mid, 10003, ?megaco_choose_context_id, [CmdReq, CmdReq2]).
5076
5077
5078msg11() ->
5079    msg11(?MG1_MID).
5080msg11(Mid) ->
5081    V  = cre_PropParm("v", "0"),
5082    C  = cre_PropParm("c", "IN IP4 124.124.124.222"),
5083    M  = cre_PropParm("m", "audio 2222 RTP/AVP 4"),
5084    A  = cre_PropParm("a", "ptime:30"),
5085    A2 = cre_PropParm("a", "recvonly"),
5086    LD = cre_LocalRemoteDesc([[V, C, M, A, A2]]),
5087    Parms      = cre_StreamParmsL(LD),
5088    StreamDesc = cre_StreamDesc(1, Parms),
5089    MediaDesc  = cre_MediaDesc(StreamDesc),
5090    Reply  = cre_AmmsReply([#megaco_term_id{id = ?A4444}]),
5091    Reply2 = cre_AmmsReply([#megaco_term_id{id = ?A4445}],
5092			   [{mediaDescriptor, MediaDesc}]),
5093    msg_reply(Mid, 10003, 2000, [{addReply, Reply}, {addReply, Reply2}]).
5094
5095
5096%% --------------------------
5097
5098msg12() ->
5099    msg12(?MGC_MID).
5100msg12(Mid) ->
5101    LCD        = cre_LocalControlDesc(sendRecv),
5102    Parms      = cre_StreamParms(LCD),
5103    StreamDesc = cre_StreamDesc(1,Parms),
5104    MediaDesc  = cre_MediaDesc(StreamDesc),
5105    Signal     = cre_Sig("al/ri"),
5106    Descs      = [{mediaDescriptor, MediaDesc},
5107		  {signalsDescriptor, [{signal, Signal}]}],
5108    AmmReq     = cre_AmmReq([#megaco_term_id{id = ?A5555}], Descs),
5109    CmdReq     = cre_CmdReq({addReq, AmmReq}),
5110    Jit        = cre_PropParm("nt/jit", "40"),
5111    LCD2       = cre_LocalControlDesc(sendRecv, [Jit]),
5112    V      = cre_PropParm("v", "0"),
5113    C      = cre_PropParm("c", "IN IP4 $ "),
5114    M      = cre_PropParm("m", "audio $ RTP/AVP 4"),
5115    A      = cre_PropParm("a", "ptime:30"),
5116    LD2    = cre_LocalRemoteDesc([[V, C, M, A]]),
5117    V2     = cre_PropParm("v", "0"),
5118    C2     = cre_PropParm("c", "IN IP4 124.124.124.222"),
5119    M2     = cre_PropParm("m", "audio 2222 RTP/AVP 4"),
5120    RD2    = cre_LocalRemoteDesc([[V2, C2, M2]]),
5121    Parms2 = cre_StreamParms(LCD2,LD2,RD2),
5122    StreamDesc2 = cre_StreamDesc(1,Parms2),
5123    MediaDesc2  = cre_MediaDesc(StreamDesc2),
5124    ChooseTid   = #megaco_term_id{contains_wildcards = true,
5125				  id = [[?megaco_choose]]},
5126    AmmReq2     = cre_AmmReq([ChooseTid],[{mediaDescriptor, MediaDesc2}]),
5127    CmdReq2     = cre_CmdReq({addReq, AmmReq2}),
5128    msg_request(Mid, 50003, ?megaco_choose_context_id, [CmdReq, CmdReq2]).
5129
5130
5131%% --------------------------
5132
5133msg13() ->
5134    msg13(?MG2_MID).
5135msg13(Mid) ->
5136    V     = cre_PropParm("v", "0"),
5137    C     = cre_PropParm("c", "IN IP4 125.125.125.111"),
5138    M     = cre_PropParm("m", "audio 1111 RTP/AVP 4"),
5139    LD    = cre_LocalRemoteDesc([[V, C, M]]),
5140    Parms = cre_StreamParmsL(LD),
5141    StreamDesc = cre_StreamDesc(1,Parms),
5142    MediaDesc  = cre_MediaDesc(StreamDesc),
5143    Reply      = cre_AmmsReply([#megaco_term_id{id = ?A5556}],
5144			       [{mediaDescriptor, MediaDesc}]),
5145    msg_reply(Mid, 50003, 5000, [{addReply, Reply}]).
5146
5147
5148%% --------------------------
5149
5150msg14() ->
5151    msg14(?MGC_MID).
5152msg14(Mid) ->
5153    Signal  = cre_Sig("cg/rt"),
5154    AmmReq1 = cre_AmmReq([#megaco_term_id{id = ?A4444}],
5155			[{signalsDescriptor, [{signal, Signal}]}]),
5156    CmdReq1 = cre_CmdReq({modReq, AmmReq1}),
5157
5158    Gain    = cre_PropParm("tdmc/gain", "2"),
5159    Ec      = cre_PropParm("tdmc/ec", "g165"),
5160    LCD     = cre_LocalControlDesc(sendRecv, [Gain, Ec]),
5161    Parms2  = cre_StreamParms(LCD),
5162    StreamDesc2 = cre_StreamDesc(1,Parms2),
5163    MediaDesc2  = cre_MediaDesc(StreamDesc2),
5164    AmmReq2     = cre_AmmReq([#megaco_term_id{id = ?A4445}],
5165			     [{mediaDescriptor, MediaDesc2}]),
5166    CmdReq2     = cre_CmdReq({modReq, AmmReq2}),
5167
5168    V      = cre_PropParm("v", "0"),
5169    C      = cre_PropParm("c", "IN IP4 125.125.125.111"),
5170    M      = cre_PropParm("m", "audio 1111 RTP/AVP 4"),
5171    RD     = cre_LocalRemoteDesc([[V, C, M]]),
5172    Parms3 = cre_StreamParmsR(RD),
5173    StreamDesc3 = cre_StreamDesc(2,Parms3),
5174    MediaDesc3  = cre_MediaDesc(StreamDesc3),
5175    AmmReq3     = cre_AmmReq([#megaco_term_id{id = ?A4445}],
5176			     [{mediaDescriptor, MediaDesc3}]),
5177    CmdReq3     = cre_CmdReq({modReq, AmmReq3}),
5178    msg_request(Mid, 10005, 2000, [CmdReq1, CmdReq2, CmdReq3]).
5179
5180
5181%% --------------------------
5182
5183msg15() ->
5184    msg15(?MG1_MID).
5185msg15(Mid) ->
5186    Reply  = cre_AmmsReply([#megaco_term_id{id = ?A4444}]),
5187    Reply2 = cre_AmmsReply([#megaco_term_id{id = ?A4445}]),
5188    msg_reply(Mid, 10005, 2000, [{modReply, Reply}, {modReply, Reply2}]).
5189
5190
5191%% --------------------------
5192
5193msg16() ->
5194    msg16(?MG2_MID).
5195msg16(Mid) ->
5196    TimeStamp = cre_TimeNot("19990729","22020002"),
5197    Event     = cre_ObsEv("al/of",TimeStamp),
5198    Desc      = cre_ObsEvsDesc(1234,[Event]),
5199    NotifyReq = cre_NotifyReq([#megaco_term_id{id = ?A5555}],Desc),
5200    CmdReq    = cre_CmdReq({notifyReq, NotifyReq}),
5201    msg_request(Mid, 50005, 5000, [CmdReq]).
5202
5203
5204%% --------------------------
5205
5206msg17() ->
5207    msg17(?MGC_MID).
5208msg17(Mid) ->
5209    Reply = cre_NotifyRep([#megaco_term_id{id = ?A5555}]),
5210    msg_reply(Mid, 50005, ?megaco_null_context_id, [{notifyReply, Reply}]).
5211
5212
5213%% --------------------------
5214
5215msg18() ->
5216    msg18(?MGC_MID).
5217msg18(Mid) ->
5218    On         = cre_ReqEv("al/on"),
5219    EventsDesc = cre_EvsDesc(1235,[On]),
5220    AmmReq     = cre_AmmReq([#megaco_term_id{id = ?A5555}],
5221			    [{eventsDescriptor, EventsDesc},
5222			     {signalsDescriptor, []}]),
5223    CmdReq     = cre_CmdReq({modReq, AmmReq}),
5224    msg_request(Mid, 50006, 5000, [CmdReq]).
5225
5226
5227%% --------------------------
5228
5229msg19() ->
5230    msg19(?MG2_MID).
5231msg19(Mid) ->
5232    Reply = cre_AmmsReply([#megaco_term_id{id = ?A4445}]),
5233    msg_reply(Mid, 50006, 5000, [{modReply, Reply}]).
5234
5235
5236%% --------------------------
5237
5238msg20() ->
5239    msg20(?MGC_MID).
5240msg20(Mid) ->
5241    LCD        = cre_LocalControlDesc(sendRecv),
5242    Parms      = cre_StreamParms(LCD),
5243    StreamDesc = cre_StreamDesc(1,Parms),
5244    MediaDesc  = cre_MediaDesc(StreamDesc),
5245    AmmReq     = cre_AmmReq([#megaco_term_id{id = ?A4445}],
5246			    [{mediaDescriptor, MediaDesc}]),
5247    CmdReq     = cre_CmdReq({modReq, AmmReq}),
5248    AmmReq2    = cre_AmmReq([#megaco_term_id{id = ?A4444}],
5249                            [{signalsDescriptor, []}]),
5250    CmdReq2    = cre_CmdReq({modReq, AmmReq2}),
5251    msg_request(Mid, 10006, 2000, [CmdReq, CmdReq2]).
5252
5253
5254%% --------------------------
5255
5256msg21() ->
5257    msg21(?MGC_MID).
5258msg21(Mid) ->
5259    Tokens    = [mediaToken, eventsToken, signalsToken,
5260		 digitMapToken, statsToken, packagesToken],
5261    AuditDesc = cre_AuditDesc(Tokens),
5262    Req       = cre_AuditReq(#megaco_term_id{id = ?A5556},AuditDesc),
5263    CmdReq    = cre_CmdReq({auditValueRequest, Req}),
5264    msg_request(Mid, 50007, ?megaco_null_context_id, [CmdReq]).
5265
5266
5267%% --------------------------
5268
5269msg22a() ->
5270    msg22(1).
5271
5272msg22b() ->
5273    msg22(10).
5274
5275msg22c() ->
5276    msg22(25).
5277
5278msg22d() ->
5279    msg22(50).
5280
5281msg22e() ->
5282    msg22(75).
5283
5284msg22f() ->
5285    msg22(100).
5286
5287msg22(N) ->
5288    msg22(?MG2_MID, N).
5289msg22(Mid, N) ->
5290    Jit = cre_PropParm("nt/jit", "40"),
5291    LCD = cre_LocalControlDesc(sendRecv,[Jit]),
5292    LDV = cre_PropParm("v", "0"),
5293    LDC = cre_PropParm("c", "IN IP4 125.125.125.111"),
5294    LDM = cre_PropParm("m", "audio 1111 RTP/AVP  4"),
5295    LDA = cre_PropParm("a", "ptime:30"),
5296    LD  = cre_LocalRemoteDesc([[LDV, LDC, LDM, LDA]]),
5297    RDV = cre_PropParm("v", "0"),
5298    RDC = cre_PropParm("c", "IN IP4 124.124.124.222"),
5299    RDM = cre_PropParm("m", "audio 2222 RTP/AVP  4"),
5300    RDA = cre_PropParm("a", "ptime:30"),
5301    RD  = cre_LocalRemoteDesc([[RDV, RDC, RDM, RDA]]),
5302    StreamParms   = cre_StreamParms(LCD,LD,RD),
5303    StreamDesc    = cre_StreamDesc(1,StreamParms),
5304    Media         = cre_MediaDesc(StreamDesc),
5305    PackagesItem  = cre_PkgsItem("nt",1),
5306    PackagesItem2 = cre_PkgsItem("rtp",1),
5307    Stat       = cre_StatsParm("rtp/ps","1200"),
5308    Stat2      = cre_StatsParm("nt/os","62300"),
5309    Stat3      = cre_StatsParm("rtp/pr","700"),
5310    Stat4      = cre_StatsParm("nt/or","45100"),
5311    Stat5      = cre_StatsParm("rtp/pl","0.2"),
5312    Stat6      = cre_StatsParm("rtp/jit","20"),
5313    Stat7      = cre_StatsParm("rtp/delay","40"),
5314    Statistics = [Stat, Stat2, Stat3, Stat4, Stat5, Stat6, Stat7],
5315    Audits     = [{mediaDescriptor, Media},
5316		  {packagesDescriptor, [PackagesItem, PackagesItem2]},
5317		  {statisticsDescriptor, Statistics}],
5318    Reply      = {auditResult,
5319		  cre_AuditRes(#megaco_term_id{id = ?A5556},Audits)},
5320    msg_reply(Mid, 50007, ?megaco_null_context_id,
5321	      lists:duplicate(N,{auditValueReply, Reply})).
5322%%     msg_reply(Mid, 50007, ?megaco_null_context_id,
5323%% 	      lists.duplicate([{auditValueReply, Reply}]).
5324
5325
5326%% --------------------------
5327
5328msg23a() ->
5329    msg23a(?MG2_MID).
5330msg23a(Mid) ->
5331    TimeStamp = cre_TimeNot("19990729","24020002"),
5332    Event     = cre_ObsEv("al/on",TimeStamp),
5333    Desc      = cre_ObsEvsDesc(1235,[Event]),
5334    NotifyReq = cre_NotifyReq([#megaco_term_id{id = ?A5555}],Desc),
5335    CmdReq    = cre_CmdReq({notifyReq, NotifyReq}),
5336    msg_request(Mid, 50008, 5000, [CmdReq]).
5337
5338
5339msg23b() ->
5340    msg23b(?MG2_MID).
5341msg23b(Mid) ->
5342    TimeStamp  = cre_TimeNot("19990729","24020002"),
5343    Event      = cre_ObsEv("al/on",TimeStamp),
5344    Desc       = cre_ObsEvsDesc(1235,[Event]),
5345    NotifyReq1 = cre_NotifyReq([#megaco_term_id{id = ?A5555}],Desc),
5346    CmdReq1    = cre_CmdReq({notifyReq, NotifyReq1}),
5347    NotifyReq2 = cre_NotifyReq([#megaco_term_id{id = ?A5556}],Desc),
5348    CmdReq2    = cre_CmdReq({notifyReq, NotifyReq2}),
5349    ActionInfo = [{5000, [CmdReq1]}, {5001, [CmdReq2]}],
5350    TransInfo  = [{50008, ActionInfo}],
5351    msg_request(Mid, TransInfo).
5352
5353
5354msg23c() ->
5355    msg23c(?MG2_MID).
5356msg23c(Mid) ->
5357    TimeStamp  = cre_TimeNot("19990729","24020002"),
5358    Event      = cre_ObsEv("al/on",TimeStamp),
5359    Desc       = cre_ObsEvsDesc(1235,[Event]),
5360    NotifyReq1 = cre_NotifyReq([#megaco_term_id{id = ?A5555}],Desc),
5361    CmdReq1    = cre_CmdReq({notifyReq, NotifyReq1}),
5362    NotifyReq2 = cre_NotifyReq([#megaco_term_id{id = ?A5556}],Desc),
5363    CmdReq2    = cre_CmdReq({notifyReq, NotifyReq2}),
5364    ActionInfo1 = [{5000, [CmdReq1]}],
5365    ActionInfo2 = [{5001, [CmdReq2]}],
5366    TransInfo   = [{50008, ActionInfo1}, {50009, ActionInfo2}],
5367    msg_request(Mid, TransInfo).
5368
5369
5370msg23d() ->
5371    msg23d(?MG2_MID).
5372msg23d(Mid) ->
5373    TimeStamp  = cre_TimeNot("19990729","24020002"),
5374    Event      = cre_ObsEv("al/on",TimeStamp),
5375    Desc       = cre_ObsEvsDesc(1235,[Event]),
5376    NotifyReq1 = cre_NotifyReq([#megaco_term_id{id = ?A5555}],Desc),
5377    CmdReq1    = cre_CmdReq({notifyReq, NotifyReq1}),
5378    NotifyReq2 = cre_NotifyReq([#megaco_term_id{id = ?A5556}],Desc),
5379    CmdReq2    = cre_CmdReq({notifyReq, NotifyReq2}),
5380    NotifyReq3 = cre_NotifyReq([#megaco_term_id{id = ?A4444}],Desc),
5381    CmdReq3    = cre_CmdReq({notifyReq, NotifyReq3}),
5382    NotifyReq4 = cre_NotifyReq([#megaco_term_id{id = ?A4445}],Desc),
5383    CmdReq4    = cre_CmdReq({notifyReq, NotifyReq4}),
5384    ActionInfo1 = [{5000, [CmdReq1]}, {5001, [CmdReq2]}],
5385    ActionInfo2 = [{5003, [CmdReq3]}, {5004, [CmdReq4]}],
5386    TransInfo   = [{50008, ActionInfo1}, {50009, ActionInfo2}],
5387    msg_request(Mid, TransInfo).
5388
5389
5390%% --------------------------
5391
5392msg24() ->
5393    msg24(?MGC_MID).
5394msg24(Mid) ->
5395    AuditDesc = cre_AuditDesc([statsToken]),
5396    SubReq    = cre_SubReq([#megaco_term_id{id = ?A5555}], AuditDesc),
5397    SubReq2   = cre_SubReq([#megaco_term_id{id = ?A5556}], AuditDesc),
5398    CmdReq    = cre_CmdReq({subtractReq, SubReq}),
5399    CmdReq2   = cre_CmdReq({subtractReq, SubReq2}),
5400    msg_request(Mid, 50009, 5000, [CmdReq, CmdReq2]).
5401
5402
5403%% --------------------------
5404
5405msg25() ->
5406    msg25(?MG2_MID).
5407msg25(Mid) ->
5408    Stat11 = cre_StatsParm("nt/os","45123"),
5409    Stat12 = cre_StatsParm("nt/dur", "40"),
5410    Stats1 = [Stat11, Stat12],
5411    Reply1 = cre_AmmsReply([#megaco_term_id{id = ?A5555}],
5412			   [{statisticsDescriptor, Stats1}]),
5413    Stat21 = cre_StatsParm("rtp/ps","1245"),
5414    Stat22 = cre_StatsParm("nt/os", "62345"),
5415    Stat23 = cre_StatsParm("rtp/pr", "780"),
5416    Stat24 = cre_StatsParm("nt/or", "45123"),
5417    Stat25 = cre_StatsParm("rtp/pl", "10"),
5418    Stat26 = cre_StatsParm("rtp/jit", "27"),
5419    Stat27 = cre_StatsParm("rtp/delay","48"),
5420    Stats2 = [Stat21, Stat22, Stat23, Stat24, Stat25, Stat26, Stat27],
5421    Reply2 = cre_AmmsReply([#megaco_term_id{id = ?A5556}],
5422                          [{statisticsDescriptor, Stats2}]),
5423    msg_reply(Mid, 50009, 5000,
5424	      [{subtractReply, Reply1}, {subtractReply, Reply2}]).
5425
5426
5427msg30a() ->
5428    msg_ack(?MG2_MID, [{9,9}]).
5429
5430msg30b() ->
5431    msg_ack(?MG2_MID, [{9,13}]).
5432
5433msg30c() ->
5434    msg_ack(?MG2_MID,
5435	    [{9,13},   {15,15},  {33,40},  {50,60},  {70,80},  {85,90},
5436	     {101,105},{109,119},{121,130},{140,160},{170,175},{180,189},
5437	     {201,205},{209,219},{221,230},{240,260},{270,275},{280,289},
5438	     {301,305},{309,319},{321,330},{340,360},{370,375},{380,389},
5439	     {401,405},{409,419},{421,430},{440,460},{470,475},{480,489},
5440	     {501,505},{509,519},{521,530},{540,560},{570,575},{580,589}
5441	    ]).
5442
5443%% Don't think this will be used by the megaco stack, but since it
5444%% seem's to be a valid construction...
5445msg30d() ->
5446    msg_ack(?MG2_MID,
5447	    [[{9,13},   {15,15},  {33,40},  {50,60},  {70,80},  {85,90}],
5448	     [{101,105},{109,119},{121,130},{140,160},{170,175},{180,189}],
5449	     [{201,205},{209,219},{221,230},{240,260},{270,275},{280,289}],
5450	     [{301,305},{309,319},{321,330},{340,360},{370,375},{380,389}],
5451	     [{401,405},{409,419},{421,430},{440,460},{470,475},{480,489}],
5452	     [{501,505},{509,519},{521,530},{540,560},{570,575},{580,589}]
5453	    ]).
5454
5455
5456
5457msg40() ->
5458    msg40(?MG1_MID_NO_PORT, "901 mg col boot").
5459msg40(Mid, Reason) when is_list(Reason) ->
5460    Address = {portNumber, ?DEFAULT_PORT},
5461    Profile = cre_SvcChProf("resgw",1),
5462    Parm    = cre_SvcChParm(restart,Address,[Reason],Profile),
5463    Req     = cre_SvcChReq([?megaco_root_termination_id],Parm),
5464    CmdReq  = cre_CmdReq({serviceChangeReq, Req}),
5465    Auth    = cre_AuthHeader(),
5466    msg_request(Auth, Mid, 9998, ?megaco_null_context_id, [CmdReq]).
5467
5468
5469msg50(Mid, APT) ->
5470    AD     = cre_AuditDesc(asn1_NOVALUE, APT),
5471    Req    = cre_AuditReq(#megaco_term_id{id = ?A5556},AD),
5472    CmdReq = cre_CmdReq({auditValueRequest, Req}),
5473    msg_request(Mid, 50007, ?megaco_null_context_id, [CmdReq]).
5474
5475%% IndAudMediaDescriptor:
5476msg51(Mid, IATSDorStream) ->
5477    IAMD   = cre_IndAudMediaDesc(IATSDorStream),
5478    IAP    = cre_IndAudParam(IAMD),
5479    APT    = [IAP],
5480    msg50(Mid, APT).
5481
5482msg51a() ->
5483    msg51a(?MG2_MID).
5484msg51a(Mid) ->
5485    PP    = cre_IndAudPropertyParm("tdmc/gain"),
5486    PPs   = [PP],
5487    IATSD = cre_IndAudTermStateDesc(PPs),
5488    msg51(Mid, IATSD).
5489
5490msg51b() ->
5491    msg51b(?MG2_MID).
5492msg51b(Mid) ->
5493    PP    = cre_IndAudPropertyParm("nt/jit"),
5494    PPs   = [PP],
5495    IATSD = cre_IndAudTermStateDesc(PPs),
5496    msg51(Mid, IATSD).
5497
5498msg51c() ->
5499    msg51c(?MG2_MID).
5500msg51c(Mid) ->
5501    IATSD = cre_IndAudTermStateDesc([], asn1_NOVALUE, 'NULL'),
5502    msg51(Mid, IATSD).
5503
5504msg51d() ->
5505    msg51d(?MG2_MID).
5506msg51d(Mid) ->
5507    IATSD = cre_IndAudTermStateDesc([], 'NULL', asn1_NOVALUE),
5508    msg51(Mid, IATSD).
5509
5510msg51e() ->
5511    msg51e(?MG2_MID).
5512msg51e(Mid) ->
5513    IALCD = cre_IndAudLocalControlDesc('NULL', asn1_NOVALUE,
5514				       asn1_NOVALUE, asn1_NOVALUE),
5515    IASP = cre_IndAudStreamParms(IALCD),
5516    msg51(Mid, IASP).
5517
5518msg51f() ->
5519    msg51f(?MG2_MID).
5520msg51f(Mid) ->
5521    IALCD = cre_IndAudLocalControlDesc(asn1_NOVALUE, 'NULL',
5522				       asn1_NOVALUE, asn1_NOVALUE),
5523    IASP = cre_IndAudStreamParms(IALCD),
5524    msg51(Mid, IASP).
5525
5526msg51g() ->
5527    msg51g(?MG2_MID).
5528msg51g(Mid) ->
5529    IALCD = cre_IndAudLocalControlDesc(asn1_NOVALUE, asn1_NOVALUE,
5530				       'NULL', asn1_NOVALUE),
5531    IASP  = cre_IndAudStreamParms(IALCD),
5532    msg51(Mid, IASP).
5533
5534msg51h() ->
5535    msg51h(?MG2_MID).
5536msg51h(Mid) ->
5537    Name  = "nt/jit",
5538    IAPP  = cre_IndAudPropertyParm(Name),
5539    IALCD = cre_IndAudLocalControlDesc(asn1_NOVALUE, asn1_NOVALUE,
5540				       asn1_NOVALUE, [IAPP]),
5541    IASP  = cre_IndAudStreamParms(IALCD),
5542    SID   = 123,
5543    IASD  = cre_IndAudStreamDesc(SID, IASP),
5544    msg51(Mid, [IASD]).
5545
5546
5547msg51i() ->
5548    msg51i(?MG2_MID).
5549msg51i(Mid) ->
5550    Name  = "nt/jit",
5551    Name2 = "tdmc/ec",
5552    IAPP  = cre_IndAudPropertyParm(Name),
5553    IAPP2 = cre_IndAudPropertyParm(Name2),
5554    IALCD = cre_IndAudLocalControlDesc('NULL', 'NULL', 'NULL',
5555				       [IAPP, IAPP2]),
5556    IASP  = cre_IndAudStreamParms(IALCD),
5557    SID   = 123,
5558    IASD  = cre_IndAudStreamDesc(SID, IASP),
5559    msg51(Mid, [IASD]).
5560
5561
5562%% IndAudEventsDescriptor:
5563msg52() ->
5564    msg52(?MG2_MID).
5565msg52(Mid) ->
5566    RequestID = 1235,
5567    PkgdName  = "tonedet/std",
5568    IAED = cre_IndAudEvsDesc(RequestID, PkgdName),
5569    IAP  = cre_IndAudParam(IAED),
5570    APT  = [IAP],
5571    msg50(Mid, APT).
5572
5573%% IndAudEventBufferDescriptor:
5574msg53() ->
5575    msg53(?MG2_MID).
5576msg53(Mid) ->
5577    EN    = "tonedet/std",
5578    SID   = 1,
5579    IAEBD = cre_IndAudEvBufDesc(EN, SID),
5580    IAP   = cre_IndAudParam(IAEBD),
5581    APT   = [IAP],
5582    msg50(Mid, APT).
5583
5584%% IndAudSignalsDescriptor:
5585msg54(Mid, Sig) ->
5586    IASD = cre_IndAudSigsDesc(Sig),
5587    IAP  = cre_IndAudParam(IASD),
5588    APT  = [IAP],
5589    msg50(Mid, APT).
5590
5591msg54a() ->
5592    msg54a(?MG2_MID).
5593msg54a(Mid) ->
5594    SN  = "tonegen/pt",
5595    Sig = cre_IndAudSig(SN),
5596    msg54(Mid, Sig).
5597
5598msg54b() ->
5599    msg54b(?MG2_MID).
5600msg54b(Mid) ->
5601    SN  = "dg/d0",
5602    Sig = cre_IndAudSig(SN),
5603    msg54(Mid, Sig).
5604
5605msg54c() ->
5606    msg54c(?MG2_MID).
5607msg54c(Mid) ->
5608    SN  = "ct/ct",
5609    Sig = cre_IndAudSig(SN),
5610    ID  = 4321,
5611    SSL = cre_IndAudSeqSigList(ID, Sig),
5612    msg54(Mid, SSL).
5613
5614%% IndAudDigitMapDescriptor:
5615msg55() ->
5616    msg55(?MG2_MID).
5617msg55(Mid) ->
5618    DMN   = "dialplan00",
5619    IADMD = cre_IndAudDigitMapDesc(DMN),
5620    IAP   = cre_IndAudParam(IADMD),
5621    APT   = [IAP],
5622    msg50(Mid, APT).
5623
5624%% IndAudStatisticsDescriptor:
5625msg56() ->
5626    msg56(?MG2_MID).
5627msg56(Mid) ->
5628    SN   = "nt/dur",
5629    IASD = cre_IndAudStatsDesc(SN),
5630    IAP  = cre_IndAudParam(IASD),
5631    APT  = [IAP],
5632    msg50(Mid, APT).
5633
5634%% IndAudPackagesDescriptor:
5635msg57() ->
5636    msg57(?MG2_MID).
5637msg57(Mid) ->
5638    PN   = "al",
5639    PV   = 1,
5640    IAPD = cre_IndAudPkgsDesc(PN, PV),
5641    IAP  = cre_IndAudParam(IAPD),
5642    APT  = [IAP],
5643    msg50(Mid, APT).
5644
5645%% Sum it up:
5646msg58_iaMediaDesc_iap(IATSD) ->
5647    IAMD  = cre_IndAudMediaDesc(IATSD),
5648    cre_IndAudParam(IAMD).
5649
5650msg58_iaMediaDesc_iap_a() ->
5651    PP    = cre_IndAudPropertyParm("tdmc/gain"),
5652    PPs   = [PP],
5653    IATSD = cre_IndAudTermStateDesc(PPs),
5654    msg58_iaMediaDesc_iap(IATSD).
5655
5656msg58_iaMediaDesc_iap_b() ->
5657    IATSD = cre_IndAudTermStateDesc([], 'NULL', asn1_NOVALUE),
5658    msg58_iaMediaDesc_iap(IATSD).
5659
5660msg58_iaEvsDesc_iap() ->
5661    RequestID = 1235,
5662    PkgdName  = "tonedet/std",
5663    IAED = cre_IndAudEvsDesc(RequestID, PkgdName),
5664    cre_IndAudParam(IAED).
5665
5666msg58_iaEvBufDesc_iap() ->
5667    EN    = "tonedet/std",
5668    SID   = 1,
5669    IAEBD = cre_IndAudEvBufDesc(EN, SID),
5670    cre_IndAudParam(IAEBD).
5671
5672msg58_iaSigsDesc_iap(S) ->
5673    IASD = cre_IndAudSigsDesc(S),
5674    cre_IndAudParam(IASD).
5675
5676msg58_iaSigsDesc_iap_a() ->
5677    SN  = "tonegen/pt",
5678    Sig = cre_IndAudSig(SN),
5679    msg58_iaSigsDesc_iap(Sig).
5680
5681msg58_iaSigsDesc_iap_b() ->
5682    SN  = "ct/ct",
5683    Sig = cre_IndAudSig(SN),
5684    ID  = 4321,
5685    SSL = cre_IndAudSeqSigList(ID, Sig),
5686    msg58_iaSigsDesc_iap(SSL).
5687
5688msg58_iaDigMapDesc_iap() ->
5689    DMN   = "dialplan00",
5690    IADMD = cre_IndAudDigitMapDesc(DMN),
5691    cre_IndAudParam(IADMD).
5692
5693msg58_iaStatsDesc_iap() ->
5694    SN   = "nt/dur",
5695    IASD = cre_IndAudStatsDesc(SN),
5696    cre_IndAudParam(IASD).
5697
5698msg58_iaPacksDesc_iap() ->
5699    PN   = "al",
5700    PV   = 1,
5701    IAPD = cre_IndAudPkgsDesc(PN, PV),
5702    cre_IndAudParam(IAPD).
5703
5704msg58a() ->
5705    msg58a(?MG2_MID).
5706msg58a(Mid) ->
5707    IAMD  = msg58_iaMediaDesc_iap_a(),
5708    IAED  = msg58_iaEvsDesc_iap(),
5709    IAEBD = msg58_iaEvBufDesc_iap(),
5710    IASiD = msg58_iaSigsDesc_iap_a(),
5711    IADMD = msg58_iaDigMapDesc_iap(),
5712    IAStD = msg58_iaStatsDesc_iap(),
5713    IAPD  = msg58_iaPacksDesc_iap(),
5714    APT   = [IAMD, IAED, IAEBD, IASiD, IADMD, IAStD, IAPD],
5715    msg50(Mid, APT).
5716
5717msg58b() ->
5718    msg58b(?MG2_MID).
5719msg58b(Mid) ->
5720    IAMD  = msg58_iaMediaDesc_iap_b(),
5721    IAED  = msg58_iaEvsDesc_iap(),
5722    IAEBD = msg58_iaEvBufDesc_iap(),
5723    IASiD = msg58_iaSigsDesc_iap_b(),
5724    IADMD = msg58_iaDigMapDesc_iap(),
5725    IAStD = msg58_iaStatsDesc_iap(),
5726    IAPD  = msg58_iaPacksDesc_iap(),
5727    APT   = [IAMD, IAED, IAEBD, IASiD, IADMD, IAStD, IAPD],
5728    msg50(Mid, APT).
5729
5730
5731%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5732%% Tests some of the changes in the v2 corr 1 (EmergencyOff and ModemDesc)
5733
5734%% Emergency On/Off (optional) tests
5735msg61(EM) ->
5736    TS     = cre_TimeNot("19990729", "22000000"),
5737    Event  = cre_ObsEv("al/of",TS),
5738    Desc   = cre_ObsEvsDesc(2222,[Event]),
5739    NotReq = cre_NotifyReq([#megaco_term_id{id = ?A4444}],Desc),
5740    Cmd    = ?MSG_LIB:cre_Command(notifyReq, NotReq),
5741    CmdReq = cre_CmdReq(Cmd),
5742    CtxReq = cre_CtxReq(15, EM),
5743    ActReq = ?MSG_LIB:cre_ActionRequest(1, CtxReq, [CmdReq]),
5744    Acts   = [ActReq],
5745    TR     = ?MSG_LIB:cre_TransactionRequest(9898, Acts),
5746    Trans  = ?MSG_LIB:cre_Transaction(TR),
5747    Mess   = ?MSG_LIB:cre_Message(?VERSION, ?MG1_MID, [Trans]),
5748    cre_MegacoMessage(Mess).
5749
5750msg61a() ->
5751    msg61(false).
5752
5753msg61b() ->
5754    msg61(true).
5755
5756msg61c() ->
5757    msg61(asn1_NOVALUE).
5758
5759
5760msg62a() ->
5761    MT      = ?MSG_LIB:cre_ModemType(v18),
5762    PP      = cre_PropParm("c", "IN IP4 $ "),
5763    MD      = ?MSG_LIB:cre_ModemDescriptor([MT], [PP]),
5764    AmmDesc = ?MSG_LIB:cre_AmmDescriptor(MD),
5765    TermIDs = [#megaco_term_id{id = ?A4444}],
5766    AmmReq  = ?MSG_LIB:cre_AmmRequest(TermIDs, [AmmDesc]),
5767    Cmd     = ?MSG_LIB:cre_Command(addReq, AmmReq),
5768    CmdReq  = ?MSG_LIB:cre_CommandRequest(Cmd),
5769    ActReq  = ?MSG_LIB:cre_ActionRequest(2, [CmdReq]),
5770    Acts    = [ActReq],
5771    TR      = ?MSG_LIB:cre_TransactionRequest(9898, Acts),
5772    Trans   = ?MSG_LIB:cre_Transaction(TR),
5773    Mess    = ?MSG_LIB:cre_Message(?VERSION, ?MG1_MID, [Trans]),
5774    cre_MegacoMessage(Mess).
5775
5776msg62b() ->
5777    MP =
5778"MEGACO/" ?VERSION_STR " [124.124.124.222]:55555
5779Transaction = 9898 {
5780        Context = 2 {
5781                Add = 11111111/00000000/00000000 {
5782                        Modem[V18] {
5783                                tdmc/gain=2
5784                        }
5785                }
5786        }
5787}",
5788%     MC =
5789% "!/" ?VERSION_STR " [124.124.124.222]:55555\nT=9898{C=2{A=11111111/00000000/00000000{MD[V18]{tdmc/gain=2}}}}",
5790    list_to_binary(MP).
5791
5792%% ActionRequest with various combinations of ContextRequest and
5793%% ContextAttrAuditRequest
5794msg71(CR, CAAR) ->
5795    TS1    = cre_TimeNot("19990729", "22000000"),
5796    TS2    = cre_TimeNot("19990729", "22000111"),
5797    Event1 = cre_ObsEv("al/of",TS1),
5798    Event2 = cre_ObsEv("al/on",TS2),
5799    Desc1  = cre_ObsEvsDesc(2222,[Event1]),
5800    Desc2  = cre_ObsEvsDesc(2222,[Event2]),
5801    NR1    = cre_NotifyReq([#megaco_term_id{id = ?A4444}],Desc1),
5802    NR2    = cre_NotifyReq([#megaco_term_id{id = ?A4444}],Desc2),
5803    Cmd1   = ?MSG_LIB:cre_Command(notifyReq, NR1),
5804    Cmd2   = ?MSG_LIB:cre_Command(notifyReq, NR2),
5805    CR1    = cre_CmdReq(Cmd1),
5806    CR2    = cre_CmdReq(Cmd2),
5807    ActReq = ?MSG_LIB:cre_ActionRequest(1, CR, CAAR, [CR1, CR2]),
5808    Acts   = [ActReq],
5809    TR     = ?MSG_LIB:cre_TransactionRequest(9898, Acts),
5810    Trans  = ?MSG_LIB:cre_Transaction(TR),
5811    Mess   = ?MSG_LIB:cre_Message(?VERSION, ?MG1_MID, [Trans]),
5812    cre_MegacoMessage(Mess).
5813
5814msg71a() ->
5815    CR   = cre_CtxReq(),
5816    CAAR = cre_CtxAttrAuditReq(),
5817    msg71(CR, CAAR).
5818
5819msg71b(CR) ->
5820    CAAR = asn1_NOVALUE,
5821    msg71(CR, CAAR).
5822
5823msg71b01() ->
5824    CR = cre_CtxReq(15),
5825    msg71b(CR).
5826
5827msg71b02() ->
5828    CR = cre_CtxReq(true),
5829    msg71b(CR).
5830
5831msg71b03() ->
5832    CR = cre_CtxReq(false),
5833    msg71b(CR).
5834
5835msg71b04() ->
5836    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
5837    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
5838    Dir1  = bothway,
5839    Top1  = cre_TopologyRequest(From1, To1, Dir1),
5840    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
5841    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
5842    Dir2  = isolate,
5843    Top2  = cre_TopologyRequest(From2, To2, Dir2),
5844    Top   = [Top1, Top2],
5845    CR    = cre_CtxReq(Top),
5846    msg71b(CR).
5847
5848msg71b05() ->
5849    CR = cre_CtxReq(15, true),
5850    msg71b(CR).
5851
5852msg71b06() ->
5853    CR = cre_CtxReq(15, false),
5854    msg71b(CR).
5855
5856msg71b07() ->
5857    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
5858    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
5859    Dir1  = bothway,
5860    Top1  = cre_TopologyRequest(From1, To1, Dir1),
5861    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
5862    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
5863    Dir2  = oneway,
5864    Top2  = cre_TopologyRequest(From2, To2, Dir2),
5865    Top   = [Top1, Top2],
5866    CR    = cre_CtxReq(15, Top),
5867    msg71b(CR).
5868
5869msg71b08() ->
5870    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
5871    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
5872    Dir1  = bothway,
5873    Top1  = cre_TopologyRequest(From1, To1, Dir1),
5874    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
5875    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
5876    Dir2  = bothway,
5877    Top2  = cre_TopologyRequest(From2, To2, Dir2),
5878    Top   = [Top1, Top2],
5879    CR    = cre_CtxReq(15, true, Top),
5880    msg71b(CR).
5881
5882msg71b09() ->
5883    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
5884    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
5885    Dir1  = isolate,
5886    Top1  = cre_TopologyRequest(From1, To1, Dir1),
5887    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
5888    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
5889    Dir2  = oneway,
5890    Top2  = cre_TopologyRequest(From2, To2, Dir2),
5891    Top   = [Top1, Top2],
5892    CR    = cre_CtxReq(15, false, Top),
5893    msg71b(CR).
5894
5895msg71b10() ->
5896    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
5897    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
5898    Dir1  = isolate,
5899    Top1  = cre_TopologyRequest(From1, To1, Dir1),
5900    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
5901    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
5902    Dir2  = onewayboth,
5903    Top2  = cre_TopologyRequest(From2, To2, Dir2),
5904    Top   = [Top1, Top2],
5905    CR    = cre_CtxReq(15, false, Top),
5906    msg71b(CR).
5907
5908msg71b11() ->
5909    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
5910    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
5911    Dir1  = isolate,
5912    Top1  = cre_TopologyRequest(From1, To1, Dir1),
5913    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
5914    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
5915    Dir2  = onewayexternal,
5916    Top2  = cre_TopologyRequest(From2, To2, Dir2),
5917    Top   = [Top1, Top2],
5918    CR    = cre_CtxReq(15, false, Top),
5919    msg71b(CR).
5920
5921msg71b12() ->
5922    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
5923    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
5924    Dir1  = oneway,
5925    Top1  = cre_TopologyRequest(From1, To1, Dir1),
5926    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
5927    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
5928    Dir2  = bothway,
5929    Top2  = cre_TopologyRequest(From2, To2, Dir2),
5930    Top   = [Top1, Top2],
5931    CR    = cre_CtxReq(15, true, Top, true),
5932    msg71b(CR).
5933
5934msg71b13() ->
5935    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
5936    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
5937    Dir1  = bothway,
5938    Top1  = cre_TopologyRequest(From1, To1, Dir1),
5939    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
5940    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
5941    Dir2  = bothway,
5942    Top2  = cre_TopologyRequest(From2, To2, Dir2),
5943    Top   = [Top1, Top2],
5944    CR    = cre_CtxReq(15, true, Top, false),
5945    msg71b(CR).
5946
5947msg71b14() ->
5948    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
5949    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
5950    Dir1  = oneway,
5951    Top1  = cre_TopologyRequest(From1, To1, Dir1),
5952    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
5953    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
5954    Dir2  = oneway,
5955    Top2  = cre_TopologyRequest(From2, To2, Dir2),
5956    Top   = [Top1, Top2],
5957    PP    = cre_PropParm("tdmc/gain", "2"),
5958    Props = [PP],
5959    CR    = cre_CtxReq(15, true, Top, Props),
5960    msg71b(CR).
5961
5962msg71b15() ->
5963    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
5964    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
5965    Dir1  = isolate,
5966    Top1  = cre_TopologyRequest(From1, To1, Dir1),
5967    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
5968    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
5969    Dir2  = isolate,
5970    Top2  = cre_TopologyRequest(From2, To2, Dir2),
5971    Top   = [Top1, Top2],
5972    PP    = cre_PropParm("tdmc/gain", ["2"], relation, greaterThan),
5973    Props = [PP],
5974    CR    = cre_CtxReq(15, true, Top, Props),
5975    msg71b(CR).
5976
5977msg71b16() ->
5978    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
5979    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
5980    Dir1  = isolate,
5981    Top1  = cre_TopologyRequest(From1, To1, Dir1),
5982    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
5983    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
5984    Dir2  = bothway,
5985    Top2  = cre_TopologyRequest(From2, To2, Dir2),
5986    Top   = [Top1, Top2],
5987    PP    = cre_PropParm("tdmc/gain", ["2","10"], range, true),
5988    Props = [PP],
5989    CR    = cre_CtxReq(15, true, Top, Props),
5990    msg71b(CR).
5991
5992msg71b17() ->
5993    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
5994    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
5995    Dir1  = oneway,
5996    Top1  = cre_TopologyRequest(From1, To1, Dir1),
5997    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
5998    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
5999    Dir2  = bothway,
6000    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6001    Top   = [Top1, Top2],
6002    PP    = cre_PropParm("nt/jit", ["40","50","50"], sublist, true),
6003    Props = [PP],
6004    CR    = cre_CtxReq(15, true, Top, Props),
6005    msg71b(CR).
6006
6007msg71b18() ->
6008    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6009    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6010    Dir1  = oneway,
6011    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6012    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6013    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6014    Dir2  = isolate,
6015    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6016    Top   = [Top1, Top2],
6017    PP    = cre_PropParm("tdmc/gain", ["2","4","8"], sublist, false),
6018    Props = [PP],
6019    CR    = cre_CtxReq(15, true, Top, true, Props),
6020    msg71b(CR).
6021
6022msg71b19() ->
6023    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6024    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6025    Dir1  = oneway,
6026    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6027    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6028    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6029    Dir2  = bothway,
6030    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6031    Top   = [Top1, Top2],
6032    CR    = cre_CtxReq(15, true, Top, false),
6033    msg71b(CR).
6034
6035msg71b20() ->
6036    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6037    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6038    Dir1  = oneway,
6039    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6040    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6041    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6042    Dir2  = isolate,
6043    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6044    Top   = [Top1, Top2],
6045    PP    = cre_PropParm("tdmc/gain", ["2","4","8"], sublist, false),
6046    Props = [PP],
6047    CR    = cre_CtxReq(15, true, Top, false, Props),
6048    msg71b(CR).
6049
6050msg71b21() ->
6051    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6052    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6053    Dir1  = oneway,
6054    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6055    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6056    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6057    Dir2  = isolate,
6058    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6059    Top   = [Top1, Top2],
6060    CID1  = cre_CtxID(10191),
6061    CID2  = cre_CtxID(10192),
6062    CIDs  = [CID1, CID2],
6063    CR    = cre_CtxReq(15, true, Top, false, CIDs),
6064    msg71b(CR).
6065
6066msg71b22() ->
6067    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6068    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6069    Dir1  = oneway,
6070    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6071    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6072    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6073    Dir2  = isolate,
6074    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6075    Top   = [Top1, Top2],
6076    PP    = cre_PropParm("tdmc/gain", ["2","4","8"], sublist, false),
6077    Props = [PP],
6078    CID1  = cre_CtxID(10191),
6079    CID2  = cre_CtxID(10192),
6080    CIDs  = [CID1, CID2],
6081    CR    = cre_CtxReq(15, true, Top, false, Props, CIDs),
6082    msg71b(CR).
6083
6084msg71c(CAAR) ->
6085    CR = asn1_NOVALUE,
6086    msg71(CR, CAAR).
6087
6088msg71c01() ->
6089    CAAR = cre_CtxAttrAuditReq('NULL', 'NULL', 'NULL'),
6090    msg71c(CAAR).
6091
6092msg71c02() ->
6093    CAAR = cre_CtxAttrAuditReq('NULL', 'NULL', asn1_NOVALUE),
6094    msg71c(CAAR).
6095
6096msg71c03() ->
6097    CAAR = cre_CtxAttrAuditReq('NULL', asn1_NOVALUE, 'NULL'),
6098    msg71c(CAAR).
6099
6100msg71c04() ->
6101    CAAR = cre_CtxAttrAuditReq(asn1_NOVALUE, 'NULL', 'NULL'),
6102    msg71c(CAAR).
6103
6104msg71c05() ->
6105    CAAR = cre_CtxAttrAuditReq(asn1_NOVALUE, asn1_NOVALUE, 'NULL'),
6106    msg71c(CAAR).
6107
6108msg71c06() ->
6109    CAAR = cre_CtxAttrAuditReq(asn1_NOVALUE, 'NULL', asn1_NOVALUE),
6110    msg71c(CAAR).
6111
6112msg71c07() ->
6113    CAAR = cre_CtxAttrAuditReq('NULL', asn1_NOVALUE, asn1_NOVALUE),
6114    msg71c(CAAR).
6115
6116msg71c08() ->
6117    CAAR = cre_CtxAttrAuditReq('NULL', asn1_NOVALUE, 'NULL', 'NULL'),
6118    msg71c(CAAR).
6119
6120msg71c09() ->
6121    Top   = 'NULL',
6122    Em    = 'NULL',
6123    Prio  = 'NULL',
6124    Ieps  = 'NULL',
6125    IAPP1 = cre_IndAudPropertyParm("tdmc/gain"),
6126    IAPP2 = cre_IndAudPropertyParm("nt/jit"),
6127    CPA   = [IAPP1, IAPP2],
6128    CAAR  = cre_CtxAttrAuditReq(Top, Em, Prio, Ieps, CPA),
6129    msg71c(CAAR).
6130
6131msg71c10() ->
6132    Top   = 'NULL',
6133    Em    = 'NULL',
6134    Prio  = 'NULL',
6135    Ieps  = 'NULL',
6136    IAPP1 = cre_IndAudPropertyParm("tdmc/gain"),
6137    IAPP2 = cre_IndAudPropertyParm("nt/jit"),
6138    CPA   = [IAPP1, IAPP2],
6139    SPrio = 10,
6140    CAAR  = cre_CtxAttrAuditReq(Top, Em, Prio, Ieps, CPA, SPrio),
6141    msg71c(CAAR).
6142
6143msg71c11() ->
6144    Top   = 'NULL',
6145    Em    = 'NULL',
6146    Prio  = 'NULL',
6147    Ieps  = 'NULL',
6148    IAPP1 = cre_IndAudPropertyParm("tdmc/gain"),
6149    IAPP2 = cre_IndAudPropertyParm("nt/jit"),
6150    CPA   = [IAPP1, IAPP2],
6151    SPrio = 10,
6152    SEm   = true,
6153    CAAR  = cre_CtxAttrAuditReq(Top, Em, Prio, Ieps, CPA,
6154				SPrio, SEm, asn1_NOVALUE, asn1_NOVALUE),
6155    msg71c(CAAR).
6156
6157msg71c12() ->
6158    Top   = 'NULL',
6159    Em    = 'NULL',
6160    Prio  = 'NULL',
6161    Ieps  = 'NULL',
6162    IAPP1 = cre_IndAudPropertyParm("tdmc/gain"),
6163    IAPP2 = cre_IndAudPropertyParm("nt/jit"),
6164    CPA   = [IAPP1, IAPP2],
6165    SPrio = 10,
6166    SEm   = true,
6167    SIeps = false,
6168    CAAR  = cre_CtxAttrAuditReq(Top, Em, Prio, Ieps, CPA,
6169					SPrio, SEm, SIeps),
6170    msg71c(CAAR).
6171
6172msg71c13() ->
6173    Top   = 'NULL',
6174    Em    = 'NULL',
6175    Prio  = 'NULL',
6176    Ieps  = 'NULL',
6177    IAPP1 = cre_IndAudPropertyParm("tdmc/gain"),
6178    IAPP2 = cre_IndAudPropertyParm("nt/jit"),
6179    CPA   = [IAPP1, IAPP2],
6180    SPrio = 10,
6181    SEm   = false,
6182    SIeps = true,
6183    SLog  = cre_SelectLogic(andAUDITSelect),
6184    CAAR  = cre_CtxAttrAuditReq(Top, Em, Prio, Ieps, CPA,
6185				SPrio, SEm, SIeps, SLog),
6186    msg71c(CAAR).
6187
6188msg71c14() ->
6189    Top   = 'NULL',
6190    Em    = 'NULL',
6191    Prio  = 'NULL',
6192    Ieps  = 'NULL',
6193    IAPP1 = cre_IndAudPropertyParm("tdmc/gain"),
6194    IAPP2 = cre_IndAudPropertyParm("nt/jit"),
6195    CPA   = [IAPP1, IAPP2],
6196    SPrio = 10,
6197    SEm   = true,
6198    SIeps = true,
6199    SLog  = cre_SelectLogic(orAUDITSelect),
6200    CAAR  = cre_CtxAttrAuditReq(Top, Em, Prio, Ieps, CPA,
6201					SPrio, SEm, SIeps, SLog),
6202    msg71c(CAAR).
6203
6204msg71c15() ->
6205    Top   = 'NULL',
6206    Em    = 'NULL',
6207    Prio  = 'NULL',
6208    Ieps  = 'NULL',
6209    IAPP1 = cre_IndAudPropertyParm("tdmc/gain"),
6210    IAPP2 = cre_IndAudPropertyParm("nt/jit"),
6211    CPA   = [IAPP1, IAPP2],
6212    SPrio = 10,
6213    SLog  = cre_SelectLogic(orAUDITSelect),
6214    CAAR  = cre_CtxAttrAuditReq(Top, Em, Prio, Ieps, CPA,
6215				SPrio, SLog),
6216    msg71c(CAAR).
6217
6218msg71d01() ->
6219    CR   = cre_CtxReq(15, true),
6220    CAAR = cre_CtxAttrAuditReq('NULL', 'NULL', 'NULL'),
6221    msg71(CR, CAAR).
6222
6223msg71d02() ->
6224    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6225    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6226    Dir1  = bothway,
6227    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6228    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6229    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6230    Dir2  = oneway,
6231    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6232    Top   = [Top1, Top2],
6233    PP    = cre_PropParm("tdmc/gain", ["2"], relation, unequalTo),
6234    Props = [PP],
6235    CR    = cre_CtxReq(15, true, Top, true, Props),
6236
6237    CAAR_Top = 'NULL',
6238    Em   = 'NULL',
6239    Prio = 'NULL',
6240    Ieps = 'NULL',
6241    IAPP1 = cre_IndAudPropertyParm("tdmc/gain"),
6242    IAPP2 = cre_IndAudPropertyParm("nt/jit"),
6243    CPA   = [IAPP1, IAPP2],
6244    CAAR = cre_CtxAttrAuditReq(CAAR_Top, Em, Prio, Ieps, CPA),
6245
6246    msg71(CR, CAAR).
6247
6248msg71d03() ->
6249    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6250    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6251    Dir1  = bothway,
6252    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6253    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6254    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6255    Dir2  = oneway,
6256    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6257    Top   = [Top1, Top2],
6258    PP    = cre_PropParm("tdmc/gain", ["2"], relation, unequalTo),
6259    Props = [PP],
6260    CR    = cre_CtxReq(15, true, Top, false, Props),
6261
6262    CAAR_Top = 'NULL',
6263    Em   = 'NULL',
6264    Prio = 'NULL',
6265    Ieps = 'NULL',
6266    IAPP1 = cre_IndAudPropertyParm("tdmc/gain"),
6267    IAPP2 = cre_IndAudPropertyParm("nt/jit"),
6268    CPA   = [IAPP1, IAPP2],
6269    CAAR = cre_CtxAttrAuditReq(CAAR_Top, Em, Prio, Ieps, CPA),
6270
6271    msg71(CR, CAAR).
6272
6273msg71d04() ->
6274    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6275    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6276    Dir1  = bothway,
6277    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6278    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6279    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6280    Dir2  = oneway,
6281    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6282    Top   = [Top1, Top2],
6283    PP    = cre_PropParm("tdmc/gain", ["2"], relation, unequalTo),
6284    Props = [PP],
6285    CID1  = cre_CtxID(10191),
6286    CID2  = cre_CtxID(10192),
6287    CIDs  = [CID1, CID2],
6288    CR    = cre_CtxReq(15, true, Top, false, Props, CIDs),
6289
6290    CAAR_Top = 'NULL',
6291    Em   = 'NULL',
6292    Prio = 'NULL',
6293    Ieps = 'NULL',
6294    IAPP1 = cre_IndAudPropertyParm("tdmc/gain"),
6295    IAPP2 = cre_IndAudPropertyParm("nt/jit"),
6296    CPA   = [IAPP1, IAPP2],
6297    SPrio = 10,
6298    SEm   = true,
6299    SIeps = true,
6300    SLog  = cre_SelectLogic(orAUDITSelect),
6301    CAAR  = cre_CtxAttrAuditReq(CAAR_Top, Em, Prio, Ieps, CPA,
6302				SPrio, SEm, SIeps, SLog),
6303    msg71(CR, CAAR).
6304
6305msg72(ED, CR) ->
6306    V  = cre_PropParm("v", "0"),
6307    C  = cre_PropParm("c", "IN IP4 124.124.124.222"),
6308    M  = cre_PropParm("m", "audio 2222 RTP/AVP 4"),
6309    A  = cre_PropParm("a", "a=ptime:30"),
6310    A2 = cre_PropParm("a", "recvonly"),
6311    LD = cre_LocalRemoteDesc([[V, C, M, A, A2]]),
6312    Parms      = cre_StreamParmsL(LD),
6313    StreamDesc = cre_StreamDesc(1, Parms),
6314    MediaDesc  = cre_MediaDesc(StreamDesc),
6315    Reply  = cre_AmmsReply([#megaco_term_id{id = ?A4444}]),
6316    Reply2 = cre_AmmsReply([#megaco_term_id{id = ?A4445}],
6317			   [{mediaDescriptor, MediaDesc}]),
6318    CmdRep = [{addReply, Reply}, {addReply, Reply2}],
6319    Action = cre_ActRep(2000, ED, CR, CmdRep),
6320    msg_reply(?MGC_MID, 10003, [Action]).
6321
6322msg72a(CR) ->
6323    ED = asn1_NOVALUE,
6324    msg72(ED, CR).
6325
6326msg72a01() ->
6327    CR = cre_CtxReq(false),
6328    msg72a(CR).
6329
6330msg72a02() ->
6331    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6332    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6333    Dir1  = bothway,
6334    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6335    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6336    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6337    Dir2  = isolate,
6338    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6339    Top   = [Top1, Top2],
6340    CR    = cre_CtxReq(Top),
6341    msg72a(CR).
6342
6343msg72a03() ->
6344    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6345    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6346    Dir1  = bothway,
6347    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6348    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6349    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6350    Dir2  = oneway,
6351    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6352    Top   = [Top1, Top2],
6353    CR    = cre_CtxReq(15, Top),
6354    msg72a(CR).
6355
6356msg72b(CR) ->
6357    EC = ?MSG_LIB:cre_ErrorCode(?megaco_not_ready),
6358    ED = ?MSG_LIB:cre_ErrorDescriptor(EC),
6359    msg72(ED, CR).
6360
6361msg72b01() ->
6362    CR = cre_CtxReq(15, false),
6363    msg72b(CR).
6364
6365msg72b02() ->
6366    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6367    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6368    Dir1  = isolate,
6369    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6370    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6371    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6372    Dir2  = oneway,
6373    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6374    Top   = [Top1, Top2],
6375    CR    = cre_CtxReq(15, false, Top),
6376    msg72b(CR).
6377
6378msg72b03() ->
6379    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6380    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6381    Dir1  = oneway,
6382    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6383    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6384    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6385    Dir2  = bothway,
6386    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6387    Top   = [Top1, Top2],
6388    CR    = cre_CtxReq(15, true, Top, true),
6389    msg72b(CR).
6390
6391msg72b04() ->
6392    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6393    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6394    Dir1  = oneway,
6395    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6396    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6397    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6398    Dir2  = bothway,
6399    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6400    Top   = [Top1, Top2],
6401    CR    = cre_CtxReq(15, true, Top, false),
6402    msg72b(CR).
6403
6404msg72c(CR) ->
6405    EC = ?MSG_LIB:cre_ErrorCode(?megaco_not_ready),
6406    ET = ?MSG_LIB:cre_ErrorText("Just another error string"),
6407    ED = ?MSG_LIB:cre_ErrorDescriptor(EC, ET),
6408    msg72(ED, CR).
6409
6410msg72c01() ->
6411    CR = cre_CtxReq(15),
6412    msg72c(CR).
6413
6414msg72c02() ->
6415    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6416    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6417    Dir1  = oneway,
6418    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6419    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6420    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6421    Dir2  = oneway,
6422    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6423    Top   = [Top1, Top2],
6424    PP    = cre_PropParm("tdmc/gain", "2"),
6425    Props = [PP],
6426    CR    = cre_CtxReq(15, true, Top, Props),
6427    msg72c(CR).
6428
6429msg72c03() ->
6430    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6431    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6432    Dir1  = oneway,
6433    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6434    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6435    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6436    Dir2  = isolate,
6437    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6438    Top   = [Top1, Top2],
6439    PP    = cre_PropParm("tdmc/gain", ["2","4","8"], sublist, false),
6440    Props = [PP],
6441    CR    = cre_CtxReq(15, true, Top, true, Props),
6442    msg72c(CR).
6443
6444msg72c04() ->
6445    From1 = #megaco_term_id{id = ["11111111", "00000000", "00000000"]},
6446    To1   = #megaco_term_id{id = ["11111111", "00000000", "00001111"]},
6447    Dir1  = oneway,
6448    Top1  = cre_TopologyRequest(From1, To1, Dir1),
6449    From2 = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6450    To2   = #megaco_term_id{id = ["11111111", "00001111", "00001111"]},
6451    Dir2  = isolate,
6452    Top2  = cre_TopologyRequest(From2, To2, Dir2),
6453    Top   = [Top1, Top2],
6454    PP    = cre_PropParm("tdmc/gain", ["2","4","8"], sublist, false),
6455    Props = [PP],
6456    CR    = cre_CtxReq(15, true, Top, false, Props),
6457    msg72c(CR).
6458
6459
6460msg73() ->
6461    Stat1    = cre_StatsParm("rtp/ps"),
6462    Stat2    = cre_StatsParm("nt/os","62300"),
6463    Stat3    = cre_StatsParm("rtp/pr","700"),
6464    Stat4    = cre_StatsParm("nt/or","45100"),
6465    Stat5    = cre_StatsParm("rtp/pl","0.2"),
6466    Stat6    = cre_StatsParm("rtp/jit","20"),
6467    Stat7    = cre_StatsParm("rtp/delay","40"),
6468    Stats    = [Stat1, Stat2, Stat3, Stat4, Stat5, Stat6, Stat7],
6469    cre_StatsDesc(Stats).
6470
6471%% StatisticsDescriptor in AmmDescriptor
6472msg73a() ->
6473    StatDesc = msg73(),
6474    AmmDesc  = cre_AmmDesc(StatDesc),
6475    TermIDs  = [#megaco_term_id{id = ["11111111", "00001111", "00000000"]}],
6476    AmmReq   = cre_AmmReq(TermIDs, [AmmDesc]),
6477    Cmd      = cre_Cmd(addReq, AmmReq),
6478    CmdReq   = cre_CmdReq(Cmd),
6479    CID      = cre_CtxID(7301),
6480    ActReq   = cre_ActReq(CID, [CmdReq]),
6481    Actions  = [ActReq],
6482    TransId  = cre_TransId(7302),
6483    TransReq = cre_TransReq(TransId, Actions),
6484    Trans    = cre_Trans(TransReq),
6485    Mid      = ?MG1_MID,
6486    Mess     = cre_Msg(Mid, [Trans]),
6487    cre_MegacoMessage(Mess).
6488
6489
6490%% StatisticsDescriptor in IndAudStreamParms
6491msg73b1() ->
6492    IASD = cre_IndAudStatsDesc("nt/dur"),
6493    cre_IndAudStreamParms(IASD).
6494
6495msg73b2(IAMD) ->
6496    IAP      = cre_IndAudParam(IAMD),
6497    AD       = cre_AuditDesc([IAP]),
6498    TermID   = #megaco_term_id{id = ["11111111", "00001111", "00000000"]},
6499    AudReq   = cre_AuditReq(TermID, AD),
6500    Cmd      = cre_Cmd(auditValueRequest, AudReq),
6501    CmdReq   = cre_CmdReq(Cmd),
6502    CID      = cre_CtxID(7311),
6503    ActReq   = cre_ActReq(CID, [CmdReq]),
6504    Actions  = [ActReq],
6505    TransId  = cre_TransId(7312),
6506    TransReq = cre_TransReq(TransId, Actions),
6507    Trans    = cre_Trans(TransReq),
6508    Mid      = ?MG1_MID,
6509    Mess     = cre_Msg(Mid, [Trans]),
6510    cre_MegacoMessage(Mess).
6511
6512msg73b01() ->
6513    IASP = msg73b1(),
6514    IAMD = cre_IndAudMediaDesc(IASP),
6515    msg73b2(IAMD).
6516
6517msg73b02() ->
6518    IASP = msg73b1(),
6519    SID  = cre_StreamID(303),
6520    IASD = cre_IndAudStreamDesc(SID, IASP),
6521    IAMD = cre_IndAudMediaDesc([IASD]),
6522    msg73b2(IAMD).
6523
6524%% StatisticsDescriptor in StreamParms
6525msg73c1() ->
6526    StatDesc = msg73(),
6527    SP       = cre_StreamParms(StatDesc),
6528    SID      = cre_StreamID(505),
6529    cre_StreamDesc(SID, SP).
6530
6531msg73c2(MD) ->
6532    ARP      = cre_AuditRetParam(MD),
6533    TA       = cre_TermAudit([ARP]),
6534    TermIDs  = [#megaco_term_id{id = ["11111111", "00001111", "00000000"]}],
6535    AmmsRep  = cre_AmmsReply(TermIDs, TA),
6536    CmdRep   = cre_CmdRep(moveReply, AmmsRep),
6537    CID      = cre_CtxID(606),
6538    ActRep   = cre_ActRep(CID, [CmdRep]),
6539    TransId  = cre_TransId(8899),
6540    TransRep = cre_TransRep(TransId, [ActRep]),
6541    Trans    = cre_Trans(TransRep),
6542    Mid      = ?MG1_MID,
6543    Mess     = cre_Msg(Mid, [Trans]),
6544    cre_MegacoMessage(Mess).
6545
6546msg73c01() ->
6547    SD = msg73c1(),
6548    MD = cre_MediaDesc(SD),
6549    msg73c2(MD).
6550
6551msg73c02() ->
6552    SD = msg73c1(),
6553    MD = cre_MediaDesc([SD]),
6554    msg73c2(MD).
6555
6556
6557%% New Signal (direction and requestID); msg74
6558msg74a1(D) ->
6559    Dir = cre_SigDir(D),
6560    cre_Sig("cg/rt", Dir, asn1_NOVALUE).
6561
6562msg74a2(D, RID) ->
6563    Dir = cre_SigDir(D),
6564    cre_Sig("cg/rt", Dir, RID).
6565
6566msg74a3(D, RID) ->
6567    Name = "al/ri",
6568    SID  = cre_StreamID(7401),
6569    ST   = cre_SigType(brief),
6570    Dur  = 7499,
6571    NC   = cre_NotifCompl([onTimeOut,otherReason]),
6572    KA   = cre_BOOLEAN(true),
6573    SPL  = [],
6574    Dir  = cre_SigDir(D),
6575    cre_Sig(Name, SID, ST, Dur, NC, KA, SPL, Dir, RID).
6576
6577msg74a4(Sig) ->
6578    SR      = cre_SigReq(Sig),
6579    SD      = cre_SigsDesc([SR]),
6580    AD      = cre_AmmDesc(SD),
6581    TermIDs = [#megaco_term_id{id = ?A4444}],
6582    AR      = cre_AmmReq(TermIDs, [AD]),
6583    Cmd     = cre_Cmd(modReq, AR),
6584    cre_CmdReq(Cmd).
6585
6586msg74a01() ->
6587    Sig      = msg74a1(internal),
6588    CR       = msg74a4(Sig),
6589    CID      = cre_CtxID(7411),
6590    ActReq   = cre_ActReq(CID, [CR]),
6591    Actions  = [ActReq],
6592    TransId  = cre_TransId(7421),
6593    TransReq = cre_TransReq(TransId, Actions),
6594    Trans    = cre_Trans(TransReq),
6595    Mid      = ?MG1_MID,
6596    Mess     = cre_Msg(Mid, [Trans]),
6597    cre_MegacoMessage(Mess).
6598
6599msg74a02() ->
6600    Sig      = msg74a1(both),
6601    CR       = msg74a4(Sig),
6602    CID      = cre_CtxID(7412),
6603    ActReq   = cre_ActReq(CID, [CR]),
6604    Actions  = [ActReq],
6605    TransId  = cre_TransId(7422),
6606    TransReq = cre_TransReq(TransId, Actions),
6607    Trans    = cre_Trans(TransReq),
6608    Mid      = ?MG1_MID,
6609    Mess     = cre_Msg(Mid, [Trans]),
6610    cre_MegacoMessage(Mess).
6611
6612msg74a03() ->
6613    RID      = cre_ReqID(7433),
6614    Sig      = msg74a2(external, RID),
6615    CR       = msg74a4(Sig),
6616    CID      = cre_CtxID(7413),
6617    ActReq   = cre_ActReq(CID, [CR]),
6618    Actions  = [ActReq],
6619    TransId  = cre_TransId(7423),
6620    TransReq = cre_TransReq(TransId, Actions),
6621    Trans    = cre_Trans(TransReq),
6622    Mid      = ?MG1_MID,
6623    Mess     = cre_Msg(Mid, [Trans]),
6624    cre_MegacoMessage(Mess).
6625
6626msg74a04() ->
6627    RID      = cre_ReqID(7434),
6628    Sig      = msg74a2(both, RID),
6629    CR       = msg74a4(Sig),
6630    CID      = cre_CtxID(7414),
6631    ActReq   = cre_ActReq(CID, [CR]),
6632    Actions  = [ActReq],
6633    TransId  = cre_TransId(7424),
6634    TransReq = cre_TransReq(TransId, Actions),
6635    Trans    = cre_Trans(TransReq),
6636    Mid      = ?MG1_MID,
6637    Mess     = cre_Msg(Mid, [Trans]),
6638    cre_MegacoMessage(Mess).
6639
6640msg74a05() ->
6641    RID      = cre_ReqID(7435),
6642    Sig      = msg74a3(both, RID),
6643    CR       = msg74a4(Sig),
6644    CID      = cre_CtxID(7415),
6645    ActReq   = cre_ActReq(CID, [CR]),
6646    Actions  = [ActReq],
6647    TransId  = cre_TransId(7425),
6648    TransReq = cre_TransReq(TransId, Actions),
6649    Trans    = cre_Trans(TransReq),
6650    Mid      = ?MG1_MID,
6651    Mess     = cre_Msg(Mid, [Trans]),
6652    cre_MegacoMessage(Mess).
6653
6654msg74a06() ->
6655    RID      = cre_ReqID(7436),
6656    Sig      = msg74a3(internal, RID),
6657    CR       = msg74a4(Sig),
6658    CID      = cre_CtxID(7416),
6659    ActReq   = cre_ActReq(CID, [CR]),
6660    Actions  = [ActReq],
6661    TransId  = cre_TransId(7426),
6662    TransReq = cre_TransReq(TransId, Actions),
6663    Trans    = cre_Trans(TransReq),
6664    Mid      = ?MG1_MID,
6665    Mess     = cre_Msg(Mid, [Trans]),
6666    cre_MegacoMessage(Mess).
6667
6668
6669
6670%% New ServiceChangeParm (serviceChangeIncompleteFlag); msg75
6671msg75a(IncFlag) ->
6672    Method   = cre_SvcChMethod(restart),
6673    Address  = cre_SvcChAddr(portNumber, ?DEFAULT_PORT),
6674    Reason   = "901 mg col boot",
6675    Profile  = cre_SvcChProf("resgw",1),
6676    Parm     = cre_SvcChParm(Method, Address, [Reason], Profile, IncFlag),
6677    TermIDs  = [?megaco_root_termination_id],
6678    Req      = cre_SvcChReq(TermIDs, Parm),
6679    Cmd      = cre_Cmd(serviceChangeReq, Req),
6680    CR       = cre_CmdReq(Cmd),
6681    CID      = cre_CtxID(7501),
6682    ActReq   = cre_ActReq(CID, [CR]),
6683    Actions  = [ActReq],
6684    TransId  = cre_TransId(7502),
6685    TransReq = cre_TransReq(TransId, Actions),
6686    Trans    = cre_Trans(TransReq),
6687    Mid      = ?MG1_MID,
6688    Mess     = cre_Msg(Mid, [Trans]),
6689    cre_MegacoMessage(Mess).
6690
6691msg75a01() ->
6692    msg75a(asn1_NOVALUE).
6693
6694msg75a02() ->
6695    msg75a('NULL').
6696
6697
6698msg76(IAMD) ->
6699    IAP   = cre_IndAudParam(IAMD),
6700    AD    = cre_AuditDesc(asn1_NOVALUE, [IAP]),
6701    AR    = cre_AuditReq(#megaco_term_id{id = ?A5556}, AD),
6702    CR    = cre_CmdReq({auditValueRequest, AR}),
6703    msg_request(?MG2_MID, 50076, ?megaco_null_context_id, [CR]).
6704
6705%% IndAudLocalControlDescriptor and IndAudPropertyParm
6706msg76a(IALCD) when is_record(IALCD, 'IndAudLocalControlDescriptor') ->
6707    IASP  = cre_IndAudStreamParms(IALCD),
6708    SID   = 123,
6709    IASD  = cre_IndAudStreamDesc(SID, IASP),
6710    IAMD  = cre_IndAudMediaDesc([IASD]),
6711    msg76(IAMD).
6712
6713msg76a01() ->
6714    Name1 = "nt/jit",
6715    IAPP1 = cre_IndAudPropertyParm(Name1),
6716    Name2 = "tdmc/ec",
6717    IAPP2 = cre_IndAudPropertyParm(Name2),
6718    SMS   = cre_StreamMode(recvOnly),
6719    IALCD = cre_IndAudLocalControlDesc(asn1_NOVALUE, 'NULL', 'NULL',
6720				       [IAPP1, IAPP2], SMS),
6721    msg76a(IALCD).
6722
6723msg76a02() ->
6724    Name1 = "tdmc/gain",
6725    PP1   = cre_PropParm("tdmc/gain", "2"),
6726    IAPP1 = cre_IndAudPropertyParm(Name1, PP1),
6727    Name2 = "tdmc/gain",
6728    PP2   = cre_PropParm("tdmc/gain", "3"),
6729    IAPP2 = cre_IndAudPropertyParm(Name2, PP2),
6730    SMS   = cre_StreamMode(recvOnly),
6731    IALCD = cre_IndAudLocalControlDesc(asn1_NOVALUE, 'NULL', 'NULL',
6732				       [IAPP1, IAPP2], SMS),
6733    msg76a(IALCD).
6734
6735%% IndAudTerminationStateDescription + ServiceState
6736msg76b(IATSD) ->
6737    IAMD = cre_IndAudMediaDesc(IATSD),
6738    msg76(IAMD).
6739
6740msg76b01() ->
6741    SSS   = cre_ServiceState(outOfSvc),
6742    IATSD = cre_IndAudTermStateDesc([], asn1_NOVALUE, asn1_NOVALUE, SSS),
6743    msg76b(IATSD).
6744
6745%% msg76b02() ->
6746%%     PP    = cre_PropParm("tdmc/gain", "2"),
6747%%     IAPP  = cre_IndAudPropertyParm("nt/jit", PP),
6748%%     IAPPs = [IAPP],
6749%%     SSS   = cre_ServiceState(outOfSvc),
6750%%     IATSD = cre_IndAudTermStateDesc(IAPPs, 'NULL', asn1_NOVALUE, SSS),
6751%%     msg76b(IATSD).
6752
6753msg77a01() ->
6754    SN  = "tonegen/pt",
6755    Sig = cre_IndAudSig(SN, 7701),
6756    msg54(?MG2_MID, Sig).
6757
6758
6759msg78a(Events) ->
6760    EventsDesc = cre_EvsDesc(2223, Events),
6761    Signal     = cre_Sig("cg/rt"),
6762    Name       = "dialplan00",
6763    Body = "(0s| 00s|[1-7]xlxx|8lxxxxxxx|#xxxxxxx|*xx|9l1xxxxxxxxxx|9l011x.s)",
6764    DigitMapValue = cre_DigitMapValue(Body),
6765    DigMapDesc = cre_DigitMapDesc(Name, DigitMapValue),
6766    AmmReq     = cre_AmmReq([#megaco_term_id{id = ?A4444}],
6767                           [{eventsDescriptor, EventsDesc},
6768			    {signalsDescriptor, [{signal, Signal}]},
6769			    {digitMapDescriptor, DigMapDesc}]),
6770    CmdReq     = cre_CmdReq({modReq, AmmReq}),
6771    msg_request(?MG2_MID, 10001, ?megaco_null_context_id, [CmdReq]).
6772
6773msg78a01() ->
6774    Name1  = "al/on",
6775    Strict = cre_EvParm("strict", ["state"]),
6776    EPL1   = [Strict],
6777    RE1    = cre_ReqEv(Name1, EPL1),
6778    Name2  = "al/on",
6779    SID2   = 7801,
6780    KA2    = true,
6781    EDM2   = cre_EvDM("dialplan00"),
6782    NB2    = cre_NotifBehav(notifyImmediate, 'NULL'),
6783    RED2   = asn1_NOVALUE,
6784    RA2    = cre_ReqActs(KA2, EDM2, asn1_NOVALUE, asn1_NOVALUE, NB2, RED2),
6785    EPL2   = EPL1,
6786    RE2    = cre_ReqEv(Name2, SID2, RA2, EPL2),
6787    msg78a([RE1, RE2]).
6788
6789msg78a02() ->
6790    Name1  = "al/on",
6791    Strict = cre_EvParm("strict",["state"]),
6792    EPL1   = [Strict],
6793    RE1    = cre_ReqEv(Name1, EPL1),
6794    Name2  = "al/on",
6795    SID2   = 7802,
6796    KA2    = true,
6797    EDM2   = cre_EvDM("dialplan00"),
6798    NB2    = cre_NotifBehav(neverNotify, 'NULL'),
6799    RED2   = asn1_NOVALUE,
6800    RA2    = cre_ReqActs(KA2, EDM2, asn1_NOVALUE, asn1_NOVALUE, NB2, RED2),
6801    EPL2   = EPL1,
6802    RE2    = cre_ReqEv(Name2, SID2, RA2, EPL2),
6803    msg78a([RE1, RE2]).
6804
6805msg78a03() ->
6806    Name1  = "al/on",
6807    Strict = cre_EvParm("strict",["state"]),
6808    EPL1   = [Strict],
6809    RE1    = cre_ReqEv(Name1, EPL1),
6810    Name2  = "al/on",
6811    SID2   = 7803,
6812    KA2    = true,
6813    EDM2   = cre_EvDM("dialplan00"),
6814    RED2   = cre_RegEmbedDesc(),
6815    NB2    = cre_NotifBehav(notifyRegulated, RED2),
6816    REvD2  = asn1_NOVALUE,
6817    RA2    = cre_ReqActs(KA2, EDM2, asn1_NOVALUE, asn1_NOVALUE, NB2, REvD2),
6818    EPL2   = EPL1,
6819    RE2    = cre_ReqEv(Name2, SID2, RA2, EPL2),
6820    msg78a([RE1, RE2]).
6821
6822msg78a04() ->
6823    Name1  = "al/on",
6824    Strict = cre_EvParm("strict",["state"]),
6825    EPL1   = [Strict],
6826    RE1    = cre_ReqEv(Name1, EPL1),
6827    Name2  = "al/on",
6828    KA2    = true,
6829    EDM2   = cre_EvDM("dialplan00"),
6830    SRE2   = cre_SecReqEv("al/on"),
6831    SED2   = cre_SecEvsDesc(7814, [SRE2]),
6832    RED2   = cre_RegEmbedDesc(SED2),
6833    NB2    = cre_NotifBehav(notifyRegulated, RED2),
6834    REvD2  = asn1_NOVALUE,
6835    RA2    = cre_ReqActs(KA2, EDM2, asn1_NOVALUE, asn1_NOVALUE, NB2, REvD2),
6836    EPL2   = EPL1,
6837    RE2    = cre_ReqEv(Name2, 7824, RA2, EPL2),
6838    msg78a([RE1, RE2]).
6839
6840msg78a05() ->
6841    Name1  = "al/on",
6842    Strict = cre_EvParm("strict",["state"]),
6843    EPL1   = [Strict],
6844    RE1    = cre_ReqEv(Name1, EPL1),
6845    Name2  = "al/on",
6846    SID2   = 7805,
6847    KA2    = true,
6848    EDM2   = cre_EvDM("dialplan00"),
6849    SD2    = cre_SigsDesc(),
6850    RED2   = cre_RegEmbedDesc(SD2),
6851    NB2    = cre_NotifBehav(notifyRegulated, RED2),
6852    REvD2  = asn1_NOVALUE,
6853    RA2    = cre_ReqActs(KA2, EDM2, asn1_NOVALUE, asn1_NOVALUE, NB2, REvD2),
6854    EPL2   = EPL1,
6855    RE2    = cre_ReqEv(Name2, SID2, RA2, EPL2),
6856    msg78a([RE1, RE2]).
6857
6858msg78a06() ->
6859    Name1  = "al/on",
6860    Strict = cre_EvParm("strict",["state"]),
6861    EPL1   = [Strict],
6862    RE1    = cre_ReqEv(Name1, EPL1),
6863    Name2  = "al/on",
6864    KA2    = true,
6865    EDM2   = cre_EvDM("dialplan00"),
6866    SRE2   = cre_SecReqEv("al/on"),
6867    SED2   = cre_SecEvsDesc(7816, [SRE2]),
6868    Sig2   = cre_Sig("cg/rt", external, asn1_NOVALUE),
6869    SR2    = cre_SigReq(Sig2),
6870    SRs2   = [SR2],
6871    SD2    = cre_SigsDesc(SRs2),
6872    RED2   = cre_RegEmbedDesc(SED2, SD2),
6873    NB2    = cre_NotifBehav(notifyRegulated, RED2),
6874    REvD2  = asn1_NOVALUE,
6875    RA2    = cre_ReqActs(KA2, EDM2, asn1_NOVALUE, asn1_NOVALUE, NB2, REvD2),
6876    EPL2   = EPL1,
6877    RE2    = cre_ReqEv(Name2, 7826, RA2, EPL2),
6878    msg78a([RE1, RE2]).
6879
6880msg78a07() ->
6881    Name1  = "al/on",
6882    Strict = cre_EvParm("strict",["state"]),
6883    EPL1   = [Strict],
6884    RE1    = cre_ReqEv(Name1, EPL1),
6885    Name2  = "al/on",
6886    KA2    = true,
6887    EDM2   = cre_EvDM("dialplan00"),
6888    SRE2   = cre_SecReqEv("al/on"),
6889    SED2   = cre_SecEvsDesc(7817, [SRE2]),
6890    Sig2   = cre_Sig("cg/rt", external, asn1_NOVALUE),
6891    SR2    = cre_SigReq(Sig2),
6892    SRs2   = [SR2],
6893    SD2    = cre_SigsDesc(SRs2),
6894    RED2   = cre_RegEmbedDesc(SED2, SD2),
6895    NB2    = cre_NotifBehav(notifyRegulated, RED2),
6896    REvD2  = 'NULL',
6897    RA2    = cre_ReqActs(KA2, EDM2, asn1_NOVALUE, asn1_NOVALUE, NB2, REvD2),
6898    EPL2   = EPL1,
6899    RE2    = cre_ReqEv(Name2, 7827, RA2, EPL2),
6900    msg78a([RE1, RE2]).
6901
6902msg78a08() ->
6903    Name1  = "al/on",
6904    Strict = cre_EvParm("strict",["state"]),
6905    EPL1   = [Strict],
6906    RE1    = cre_ReqEv(Name1, EPL1),
6907
6908    Name2  = "al/on",
6909    KA2    = true,
6910    EDM2   = cre_EvDM("dialplan00"),
6911
6912    Sig21  = cre_Sig("al/ri", both, asn1_NOVALUE),
6913    SR21   = cre_SigReq(Sig21),
6914    SRs21  = [SR21],
6915    SD21   = cre_SigsDesc(SRs21),
6916    RED21  = cre_RegEmbedDesc(SD21),
6917    NB21   = cre_NotifBehav(notifyRegulated, RED21),
6918    SRA2   = cre_SecReqActs(KA2, EDM2, asn1_NOVALUE, NB21, 'NULL'),
6919    SRE2   = cre_SecReqEv("al/of", 7816, SRA2),
6920    SED2   = cre_SecEvsDesc(7826, [SRE2]),
6921
6922    Sig22  = cre_Sig("cg/rt", external, asn1_NOVALUE),
6923    SR22   = cre_SigReq(Sig22),
6924    SRs22  = [SR22],
6925    SD22   = cre_SigsDesc(SRs22),
6926    RED22  = cre_RegEmbedDesc(SED2, SD22),
6927    NB22   = cre_NotifBehav(notifyRegulated, RED22),
6928    REvD2  = 'NULL',
6929
6930    RA2    = cre_ReqActs(KA2, EDM2, asn1_NOVALUE, asn1_NOVALUE, NB22, REvD2),
6931    EPL2   = EPL1,
6932    RE2    = cre_ReqEv(Name2, 7836, RA2, EPL2),
6933    msg78a([RE1, RE2]).
6934
6935msg78a09() ->
6936    Name1  = "al/on",
6937    Strict = cre_EvParm("strict",["state"]),
6938    EPL1   = [Strict],
6939    RE1    = cre_ReqEv(Name1, EPL1),
6940
6941    Name2  = "al/on",
6942    KA2    = true,
6943    EDM2   = cre_EvDM("dialplan00"),
6944
6945    SID21  = cre_StreamID(7819),
6946    ST21   = cre_SigType(timeOut),
6947    Dur21  = 7898,
6948    NC21   = cre_NotifCompl([onTimeOut, onInterruptByEvent, otherReason]),
6949    KA21   = cre_BOOLEAN(false),
6950    SPL21  = [],
6951    Dir21  = cre_SigDir(both),
6952    RID21  = cre_ReqID(7829),
6953
6954    Sig21  = cre_Sig("cg/rt", SID21, ST21, Dur21, NC21, KA21, SPL21, Dir21,
6955		     RID21, 7839),
6956    SR21   = cre_SigReq(Sig21),
6957    SRs21  = [SR21],
6958    SD21   = cre_SigsDesc(SRs21),
6959    RED21  = cre_RegEmbedDesc(SD21),
6960    NB21   = cre_NotifBehav(notifyRegulated, RED21),
6961
6962    SRA2   = cre_SecReqActs(KA2, EDM2, asn1_NOVALUE, NB21, 'NULL'),
6963    SRE2   = cre_SecReqEv("al/of", 7849, SRA2),
6964    SED2   = cre_SecEvsDesc(7859, [SRE2]),
6965
6966    SID22  = cre_StreamID(7869),
6967    ST22   = cre_SigType(brief),
6968    Dur22  = 17809,
6969    NC22   = cre_NotifCompl([onTimeOut, otherReason]),
6970    KA22   = cre_BOOLEAN(true),
6971    SPL22  = [],
6972    Dir22  = cre_SigDir(external),
6973    RID22  = cre_ReqID(7879),
6974
6975    Sig22  = cre_Sig("cg/rt", SID22, ST22, Dur22, NC22, KA22, SPL22, Dir22,
6976		     RID22, 7889),
6977    SR22   = cre_SigReq(Sig22),
6978    SRs22  = [SR22],
6979    SD22   = cre_SigsDesc(SRs22),
6980    RED22  = cre_RegEmbedDesc(SED2, SD22),
6981
6982    NB22   = cre_NotifBehav(notifyRegulated, RED22),
6983    REvD2  = 'NULL',
6984
6985    RA2    = cre_ReqActs(KA2, EDM2, asn1_NOVALUE, asn1_NOVALUE, NB22, REvD2),
6986    EPL2   = EPL1,
6987    RE2    = cre_ReqEv(Name2, 7899, RA2, EPL2),
6988    msg78a([RE1, RE2]).
6989
6990
6991msg79a01() ->
6992    TID1 = #megaco_term_id{id = ?A4444},
6993    TID2 = #megaco_term_id{id = ?A4445},
6994    TID3 = #megaco_term_id{id = ?A5555},
6995    TIDs = cre_TermIDList([TID1, TID2, TID3]),
6996    ErC  = cre_ErrCode(?megaco_not_ready),
6997    ErD  = cre_ErrDesc(ErC),
6998    ARP1 = cre_AuditRetParam(ErD),
6999    RE   = cre_ReqEv("al/of"),
7000    EvD  = cre_EvsDesc(7911,[RE]),
7001    ARP2 = cre_AuditRetParam(EvD),
7002    Tks  = [mediaToken, digitMapToken, statsToken, packagesToken],
7003    AD   = cre_AuditDesc(Tks),
7004    ARP3 = cre_AuditRetParam(AD),
7005    TAR  = cre_TermAudit([ARP1, ARP2, ARP3]),
7006    TLAR = cre_TermListAuditRes(TIDs, TAR),
7007    AudR = cre_AuditRep(TLAR),
7008    CR   = cre_CmdRep(auditValueReply, AudR),
7009    ActR = cre_ActRep(7921, [CR]),
7010    Acts = [ActR],
7011    msg_reply(?MG2_MID, 7931, Acts).
7012
7013
7014%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7015%% Pretty RFC 3525 messages:
7016
7017%% Added Reason
7018rfc3525_msg1() ->
7019"MEGACO/" ?VERSION_STR " [124.124.124.222] Transaction = 9998 {
7020   Context = - {
7021      ServiceChange = ROOT {
7022         Services {
7023            Method = Restart,
7024            Reason = 901,
7025            ServiceChangeAddress = 55555,
7026            Profile = ResGW/1
7027         }
7028      }
7029   }
7030}".
7031
7032rfc3525_msg2() ->
7033"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Reply = 9998 {
7034   Context = - {
7035      ServiceChange = ROOT {
7036         Services {
7037            ServiceChangeAddress = 55555,
7038            Profile = ResGW/1
7039         }
7040      }
7041   }
7042}".
7043
7044
7045%% Removed "," after LocalControl ending "}"
7046rfc3525_msg3() ->
7047"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Transaction = 9999 {
7048   Context = - {
7049      Modify = A4444 {
7050         Media {
7051            Stream = 1 {
7052               LocalControl {
7053                  Mode = SendReceive,
7054                  tdmc/gain=2,  ; in dB,
7055                  tdmc/ec=on
7056               }
7057            }
7058         },
7059         Events = 2222 {
7060            al/of {strict=state}
7061         }
7062      }
7063   }
7064}".
7065
7066%% Removed the outermost "{}" pair (before the Reply token)
7067rfc3525_msg4() ->
7068"MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 9999 {
7069   Context = - {
7070      Modify = A4444
7071   }
7072}".
7073
7074rfc3525_msg6() ->
7075"MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Transaction = 10000 {
7076   Context = - {
7077      Notify = A4444 {
7078         ObservedEvents =2222 {
7079            19990729T22000000:al/of{init=false}
7080         }
7081      }
7082   }
7083}".
7084
7085
7086rfc3525_msg7() ->
7087"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Reply = 10000 {
7088   Context = - {
7089      Notify = A4444
7090   }
7091}".
7092
7093rfc3525_msg8() ->
7094"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Transaction = 10001 {
7095   Context = - {
7096      Modify = A4444 {
7097         Events = 2223 {
7098            al/on {strict=state},
7099            dd/ce {DigitMap=Dialplan0}
7100	 },
7101         Signals {cg/dt},
7102         DigitMap = Dialplan0 {
7103            (0| 00|[1-7]xxx|8xxxxxxx|fxxxxxxx|exx|91xxxxxxxxxx|9011x.)
7104         }
7105      }
7106   }
7107}".
7108
7109rfc3525_msg9() ->
7110"MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10001 {
7111   Context = - {
7112      Modify = A4444
7113   }
7114}".
7115
7116rfc3525_msg10() ->
7117"MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Transaction = 10002 {
7118   Context = - {
7119      Notify = A4444 {
7120         ObservedEvents =2223 {
7121            19990729T22010001:dd/ce {
7122               ds=\"916135551212\",
7123               Meth=UM
7124            }
7125         }
7126      }
7127   }
7128}".
7129
7130
7131rfc3525_msg11() ->
7132"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Reply = 10002 {
7133   Context = - {
7134      Notify = A4444
7135   }
7136}".
7137
7138%% Added ?
7139rfc3525_msg12() ->
7140"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Transaction = 10003 {
7141   Context = $ {
7142      Add = A4444,
7143      Add = $ {
7144         Media {
7145            Stream = 1 {
7146               LocalControl {
7147                  Mode = ReceiveOnly,
7148                  nt/jit=40 ; in ms
7149               },
7150               Local {
7151                  v=0 c=IN IP4 $ m=audio $ RTP/AVP 4 a=ptime:30 v=0 c=IN IP4 $ m=audio $ RTP/AVP 0
7152               }
7153            }
7154         }
7155      }
7156   }
7157}".
7158
7159%% Added ?
7160rfc3525_msg13() ->
7161"MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
7162   Context = 2000 {
7163      Add = A4444,
7164      Add = A4445 {
7165         Media {
7166            Stream = 1 {
7167               Local {
7168v=0
7169o=- 2890844526 2890842807 IN IP4 124.124.124.222
7170s=-
7171t= 0 0
7172c=IN IP4 124.124.124.222
7173m=audio 2222 RTP/AVP 4
7174a=ptime:30
7175a=recvonly
7176               } ; RTP profile for G.723.1 is 4
7177            }
7178         }
7179      }
7180   }
7181}".
7182
7183%%
7184%% Added ?
7185rfc3525_msg14() ->
7186"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Transaction = 50003 {
7187   Context = $ {
7188      Add = A5555 {
7189         Media {
7190            Stream = 1 {
7191               LocalControl {
7192                  Mode = SendReceive
7193               }
7194            }
7195         },
7196         Events = 1234 {
7197            al/of {strict=state}
7198         },
7199         Signals {al/ri}
7200      },
7201      Add = $ {
7202         Media {
7203            Stream = 1 {
7204               LocalControl {
7205                  Mode = SendReceive,
7206                  nt/jit=40 ; in ms
7207               },
7208               Local {
7209                  v=0 c=IN IP4 $ m=audio $ RTP/AVP 4 a=ptime:30
7210               },
7211               Remote {
7212                  v=0 c=IN IP4 124.124.124.222 m=audio 2222 RTP/AVP 4 a=ptime:30
7213               } ; RTP profile for G.723.1 is 4
7214            }
7215         }
7216      }
7217   }
7218}".
7219
7220%% Added ?
7221rfc3525_msg15() ->
7222"MEGACO/" ?VERSION_STR " [125.125.125.111]:55555 Reply = 50003 {
7223   Context = 5000 {
7224      Add = A5555,
7225      Add = A5556 {
7226         Media {
7227            Stream = 1 {
7228               Local {
7229                  v=0 o=- 7736844526 7736842807 IN IP4 125.125.125.111 s=- t= 0 0 c=IN IP4 125.125.125.111 m=audio 1111 RTP/AVP 4
7230               } ; RTP profile for G723.1 is 4
7231            }
7232         }
7233      }
7234   }
7235}".
7236
7237%% Added ?
7238rfc3525_msg16a() ->
7239"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Transaction = 10005 {
7240   Context = 2000 {
7241      Modify = A4444 {
7242         Signals {cg/rt}
7243      },
7244      Modify = A4445 {
7245         Media {
7246            Stream = 1 {
7247               Remote {
7248                  v=0 o=- 7736844526 7736842807 IN IP4 125.125.125.111 s=- t= 0 0 c=IN IP4 125.125.125.111 m=audio 1111 RTP/AVP 4
7249	       } ; RTP profile for G723.1 is 4
7250            }
7251         }
7252      }
7253   }
7254}".
7255
7256rfc3525_msg16b() ->
7257"MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10005 {
7258   Context = 2000 {
7259      Modify = A4444,
7260      Modify = A4445
7261   }
7262}".
7263
7264rfc3525_msg17a() ->
7265"MEGACO/" ?VERSION_STR " [125.125.125.111]:55555 Transaction = 50005 {
7266   Context = 5000 {
7267      Notify = A5555 {
7268         ObservedEvents = 1234 {
7269            19990729T22020002:al/of{init=false}
7270         }
7271      }
7272   }
7273}".
7274
7275rfc3525_msg17b() ->
7276"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Reply = 50005 {
7277   Context = - {
7278      Notify = A5555
7279   }
7280}".
7281
7282%% Removed "{ }" after Signals
7283rfc3525_msg17c() ->
7284"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Transaction = 50006 {
7285   Context = 5000 {
7286      Modify = A5555 {
7287         Events = 1235 {
7288            al/on{strict=state}
7289         },
7290         Signals ; to turn off ringing
7291      }
7292   }
7293}".
7294
7295rfc3525_msg17d() ->
7296"MEGACO/" ?VERSION_STR " [125.125.125.111]:55555 Reply = 50006 {
7297   Context = 5000 {
7298      Modify = A4445
7299   }
7300}".
7301
7302%% Removed "{ }" after Signals
7303rfc3525_msg18a() ->
7304"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Transaction = 10006 {
7305   Context = 2000 {
7306      Modify = A4445 {
7307         Media {
7308            Stream = 1 {
7309               LocalControl {
7310                  Mode = SendReceive
7311               }
7312            }
7313         }
7314      },
7315      Modify = A4444 {
7316         Signals
7317      }
7318   }
7319}".
7320
7321rfc3525_msg18b() ->
7322"MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10006 {
7323   Context = 2000 {
7324      Modify = A4445,
7325      Modify = A4444
7326   }
7327}".
7328
7329rfc3525_msg19() ->
7330"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Transaction = 50007 {
7331   Context = - {
7332      AuditValue = A5556 {
7333         Audit {
7334            Media, DigitMap, Events, Signals, Packages, Statistics
7335         }
7336      }
7337   }
7338}".
7339
7340%% Added ?
7341rfc3525_msg20() ->
7342"MEGACO/" ?VERSION_STR " [125.125.125.111]:55555 Reply = 50007 {
7343   Context = - {
7344      AuditValue = A5556 {
7345         Media {
7346            TerminationState {
7347               ServiceStates = InService,
7348               Buffer = OFF
7349            },
7350            Stream = 1 {
7351               LocalControl {
7352                  Mode = SendReceive,
7353                  nt/jit=40
7354               },
7355               Local {
7356                  v=0 o=- 7736844526 7736842807 IN IP4 125.125.125.111 s=- t= 0 0 c=IN IP4 125.125.125.111 m=audio 1111 RTP/AVP  4 a=ptime:30
7357               },
7358               Remote {
7359                  v=0 o=- 2890844526 2890842807 IN IP4 124.124.124.222 s=- t= 0 0 c=IN IP4 124.124.124.222 m=audio 2222 RTP/AVP  4 a=ptime:30
7360               }
7361            }
7362         },
7363         Events,
7364         Signals,
7365         DigitMap,
7366         Packages {nt-1, rtp-1},
7367         Statistics {
7368            rtp/ps=1200,  ; packets sent
7369            nt/os=62300, ; octets sent
7370            rtp/pr=700, ; packets received
7371            nt/or=45100, ; octets received
7372            rtp/pl=0.2,  ; % packet loss
7373            rtp/jit=20,
7374            rtp/delay=40 ; avg latency
7375         }
7376      }
7377   }
7378}".
7379
7380rfc3525_msg21a() ->
7381"MEGACO/" ?VERSION_STR " [125.125.125.111]:55555 Transaction = 50008 {
7382   Context = 5000 {
7383      Notify = A5555 {
7384         ObservedEvents =1235 {
7385            19990729T24020002:al/on {init=false}
7386         }
7387      }
7388   }
7389}".
7390
7391rfc3525_msg21b() ->
7392"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Reply = 50008 {
7393   Context = - {
7394      Notify = A5555
7395   }
7396}".
7397
7398rfc3525_msg22a() ->
7399"MEGACO/" ?VERSION_STR " [123.123.123.4]:55555 Transaction = 50009 {
7400   Context = 5000 {
7401      Subtract = A5555 {
7402         Audit {
7403            Statistics
7404         }
7405      },
7406      Subtract = A5556 {
7407         Audit {
7408            Statistics
7409         }
7410      }
7411   }
7412}".
7413
7414%% Added ?
7415rfc3525_msg22b() ->
7416"MEGACO/" ?VERSION_STR " [125.125.125.111]:55555 Reply = 50009 {
7417   Context = 5000 {
7418      Subtract = A5555 {
7419         Statistics {
7420            nt/os=45123, ; Octets Sent
7421            nt/dur=40 ; in seconds
7422         }
7423      },
7424      Subtract = A5556 {
7425         Statistics {
7426            rtp/ps=1245, ; packets sent
7427            nt/os=62345, ; octets sent
7428            rtp/pr=780, ; packets received
7429            nt/or=45123, ; octets received
7430            rtp/pl=10, ;  % packets lost
7431            rtp/jit=27,
7432            rtp/delay=48 ; average latency
7433         }
7434      }
7435   }
7436}".
7437
7438rfc3525_msgs() ->
7439    [
7440     {msg1,   rfc3525_msg1()},
7441     {msg2,   rfc3525_msg2()},
7442     {msg3,   rfc3525_msg3()},
7443     {msg4,   rfc3525_msg4()},
7444     {msg6,   rfc3525_msg6()},
7445     {msg7,   rfc3525_msg7()},
7446     {msg8,   rfc3525_msg8()},
7447     {msg9,   rfc3525_msg9()},
7448     {msg10,  rfc3525_msg10()},
7449     {msg11,  rfc3525_msg11()},
7450     {msg12,  rfc3525_msg12()},
7451     {msg13,  rfc3525_msg13()},
7452     {msg14,  rfc3525_msg14()},
7453     {msg15,  rfc3525_msg15()},
7454     {msg16a, rfc3525_msg16a()},
7455     {msg16b, rfc3525_msg16b()},
7456     {msg17a, rfc3525_msg17a()},
7457     {msg17b, rfc3525_msg17b()},
7458     {msg17c, rfc3525_msg17c()},
7459     {msg17d, rfc3525_msg17d()},
7460     {msg18a, rfc3525_msg18a()},
7461     {msg18b, rfc3525_msg18b()},
7462     {msg19,  rfc3525_msg19()},
7463     {msg20,  rfc3525_msg20()},
7464     {msg21a, rfc3525_msg21a()},
7465     {msg21b, rfc3525_msg21b()},
7466     {msg22a, rfc3525_msg22a()},
7467     {msg22b, rfc3525_msg22b()}
7468    ].
7469
7470rfc3525_msgs_display() ->
7471    Msgs = rfc3525_msgs(),
7472    Fun = fun({Name, Msg}) ->
7473		  io:format("~w: ~n~s~n~n", [Name, Msg])
7474	  end,
7475    lists:foreach(Fun, Msgs).
7476
7477rfc3525_msgs_test() ->
7478    put(dbg,true),
7479    Res = rfc3525_msgs_test(megaco_pretty_text_encoder, [], 2),
7480    erase(dbg),
7481    io:format("~w~n", [Res]).
7482
7483rfc3525_msgs_test(Codec, Config, Ver) ->
7484    io:format("-----------------------------------------"
7485	      "~ntesting with"
7486	      "~n   Codec:   ~w"
7487	      "~n   Config:  ~w"
7488	      "~n   Version: ~w"
7489	      "~n", [Codec, Config, Ver]),
7490    Msgs = rfc3525_msgs(),
7491    Test = fun({N,M1}) ->
7492		   %% io:format("testing ~w: ", [N]),
7493		   io:format("~n*** testing ~w *** ~n~s~n", [N,M1]),
7494		   Bin1 = erlang:list_to_binary(M1),
7495		   case (catch Codec:decode_message(Config, Ver, Bin1)) of
7496		       {ok, M2} ->
7497			   %% io:format("d", []),
7498			   io:format("decoded:~n~p~n", [M2]),
7499			   case (catch Codec:encode_message(Config, Ver, M2)) of
7500			       {ok, Bin2} when is_binary(Bin2) ->
7501				   %% io:format("e~n", []),
7502				   io:format("encode: ~n~s~n", [erlang:binary_to_list(Bin2)]),
7503				   {N,ok};
7504			       {ok, M3} ->
7505				   %% io:format("e~n", []),
7506				   io:format("encode: ~n~s~n", [M3]),
7507				   {N,ok};
7508			       E ->
7509				   io:format("~n~p~n", [E]),
7510				   {N,encode_error}
7511			   end;
7512		       E ->
7513			   io:format("~n~p~n", [E]),
7514			   {N,decode_error}
7515		   end
7516	  end,
7517    [Test(M) || M <- Msgs].
7518
7519%% --------------------------
7520
7521
7522%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7523
7524%% skip(Reason) ->
7525%%     megaco_codec_test_lib:skip(Reason).
7526
7527
7528%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7529
7530ticket_compact_encode_decode_ok(Msg) ->
7531    ticket_compact_encode_decode_ok(Msg, []).
7532
7533ticket_compact_encode_decode_ok(Msg, Conf) ->
7534    Codec  = megaco_compact_text_encoder,
7535    ticket_encode_decode_ok(Msg, Codec, Conf).
7536
7537ticket_pretty_encode_decode_ok(Msg) ->
7538    ticket_pretty_encode_decode_ok(Msg, []).
7539
7540ticket_pretty_encode_decode_ok(Msg, Conf) ->
7541    Codec  = megaco_pretty_text_encoder,
7542    ticket_encode_decode_ok(Msg, Codec, Conf).
7543
7544ticket_encode_decode_ok(Msg, Codec, Conf0) ->
7545    Conf   = [?EC_V3|Conf0],
7546    Encode = fun(M) -> encode_message(Codec, Conf, M) end,
7547    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
7548    Check  = fun(M1, M2) -> chk_MegacoMessage(M1, M2) end,
7549    megaco_codec_test_lib:expect_encode_decode(Msg, Encode, Decode, Check).
7550
7551%% --
7552
7553%% ticket_compact_encode_error(Msg) ->
7554%%     ticket_compact_encode_error(Msg, []).
7555
7556%% ticket_compact_encode_error(Msg, Conf) ->
7557%%     Codec  = megaco_compact_text_encoder,
7558%%     ticket_encode_error(Msg, Codec, Conf).
7559
7560%% ticket_pretty_encode_error(Msg) ->
7561%%     ticket_pretty_encode_error(Msg, []).
7562
7563ticket_pretty_encode_error(Msg, Conf) when is_list(Conf) ->
7564    Codec = megaco_pretty_text_encoder,
7565    ticket_encode_error(Msg, Codec, Conf);
7566ticket_pretty_encode_error(Msg, Check) when is_function(Check) ->
7567    ticket_pretty_encode_error(Msg, [], Check).
7568
7569ticket_pretty_encode_error(Msg, Conf, Check) when is_function(Check) ->
7570    Codec = megaco_pretty_text_encoder,
7571    ticket_encode_error(Msg, Codec, Conf, Check).
7572
7573ticket_encode_error(Msg, Codec, Conf) when is_list(Conf) ->
7574    Check = fun(_) -> ok end, % Only called when encode failes
7575    ticket_encode_error(Msg, Codec, Conf, Check).
7576
7577ticket_encode_error(Msg, Codec, Conf0, Check) ->
7578    Conf   = [?EC_V3|Conf0],
7579    Encode = fun(M) -> encode_message(Codec, Conf, M) end,
7580    megaco_codec_test_lib:expect_encode(Msg, Encode, Check).
7581
7582%% --
7583
7584ticket_compact_decode_encode_ok(Msg) ->
7585    ticket_compact_decode_encode_ok(Msg, []).
7586
7587ticket_compact_decode_encode_ok(Msg, Conf) ->
7588    Codec  = megaco_compact_text_encoder,
7589    ticket_decode_encode_ok(Msg, Codec, Conf).
7590
7591ticket_pretty_decode_encode_ok(Msg) ->
7592    ticket_pretty_decode_encode_ok(Msg, []).
7593
7594ticket_pretty_decode_encode_ok(Msg, Conf) ->
7595    Codec  = megaco_pretty_text_encoder,
7596    ticket_decode_encode_ok(Msg, Codec, Conf).
7597
7598ticket_decode_encode_ok(Msg, Codec, Conf0) ->
7599    Conf   = [?EC_V3|Conf0],
7600    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
7601    Encode = fun(M) -> encode_message(Codec, Conf, M) end,
7602    Check  = fun(M1, M2) -> chk_MegacoMessage(M1, M2) end,
7603    megaco_codec_test_lib:expect_decode_encode(Msg, Decode, Encode, Check).
7604
7605%% --
7606
7607ticket_pretty_decode_encode_only(Msg, Check) ->
7608    ticket_pretty_decode_encode_only(Msg, Check, []).
7609
7610ticket_pretty_decode_encode_only(Msg, Check, Conf) ->
7611    Codec  = megaco_pretty_text_encoder,
7612    ticket_decode_encode_only(Msg, Codec, Check, Conf).
7613
7614ticket_decode_encode_only(Msg, Codec, Check, Conf0) ->
7615    Conf   = [?EC_V3|Conf0],
7616    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
7617    Encode = fun(M) -> encode_message(Codec, Conf, M) end,
7618    megaco_codec_test_lib:expect_decode_encode_only(Msg, Decode, Encode,
7619						    Check).
7620
7621%% --
7622
7623ticket_pretty_encode_decode_only(Msg) ->
7624    ticket_pretty_encode_decode_only(Msg, []).
7625
7626ticket_pretty_encode_decode_only(Msg, Conf) when is_list(Conf) ->
7627    Codec = megaco_pretty_text_encoder,
7628    ticket_encode_decode_only(Msg, Codec, Conf);
7629ticket_pretty_encode_decode_only(Msg, Check) when is_function(Check) ->
7630    ticket_pretty_encode_decode_only(Msg, Check, []).
7631
7632ticket_pretty_encode_decode_only(Msg, Check, Conf) ->
7633    Codec = megaco_pretty_text_encoder,
7634    ticket_encode_decode_only(Msg, Codec, Check, Conf).
7635
7636ticket_encode_decode_only(Msg, Codec, Conf) ->
7637    Check = fun(_) -> ok end,
7638    ticket_encode_decode_only(Msg, Codec, Check, Conf).
7639
7640ticket_encode_decode_only(Msg, Codec, Check, Conf0) ->
7641    Conf   = [?EC_V3|Conf0],
7642    Encode = fun(M) -> encode_message(Codec, Conf, M) end,
7643    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
7644    megaco_codec_test_lib:expect_encode_decode_only(Msg, Encode, Decode,
7645						    Check).
7646
7647%% --
7648
7649ticket_pretty_decode_only(Msg) ->
7650    ticket_pretty_decode_only(Msg, []).
7651
7652ticket_pretty_decode_only(Msg, Conf) ->
7653    Codec = megaco_pretty_text_encoder,
7654    ticket_decode_only(Msg, Codec, Conf).
7655
7656ticket_decode_only(Msg, Codec, Conf) ->
7657    Check = fun(_) -> ok end,
7658    ticket_decode_only(Msg, Codec, Check, Conf).
7659
7660ticket_decode_only(Msg, Codec, Check, Conf0) ->
7661    Conf   = [?EC_V3|Conf0],
7662    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
7663    megaco_codec_test_lib:expect_decode_only(Msg, Decode, Check).
7664
7665ticket_check_decode_only_error_reason(R, Check)
7666  when is_list(R) and is_function(Check) ->
7667    case lists:keysearch(reason, 1, R) of
7668	{value, {reason, Reason}} ->
7669	    Check(Reason);
7670	false ->
7671	    {error, {reason_not_found, R}}
7672    end.
7673
7674
7675%% --
7676
7677ticket_compact_decode_error(Msg) ->
7678    ticket_compact_decode_error(Msg, []).
7679
7680ticket_compact_decode_error(Msg, Conf) ->
7681    Codec = megaco_compact_text_encoder,
7682    ticket_decode_error(Msg, Codec, Conf).
7683
7684ticket_pretty_decode_error(Msg) ->
7685    ticket_pretty_decode_error(Msg, []).
7686
7687ticket_pretty_decode_error(Msg, Conf) when is_list(Conf) ->
7688    Codec = megaco_pretty_text_encoder,
7689    ticket_decode_error(Msg, Codec, Conf);
7690ticket_pretty_decode_error(Msg, Check) when is_function(Check) ->
7691    ticket_pretty_decode_error(Msg, [], Check).
7692
7693ticket_pretty_decode_error(Msg, Conf, Check) ->
7694    Codec = megaco_pretty_text_encoder,
7695    ticket_decode_error(Msg, Codec, Conf, Check).
7696
7697ticket_decode_error(Msg, Codec, Conf) ->
7698    Check = fun(X) ->
7699		    d("decode error reason: ~n~p~n", [X]),
7700		    ok
7701	    end, % Only called when decode failes
7702    ticket_decode_error(Msg, Codec, Conf, Check).
7703
7704ticket_decode_error(Msg, Codec, Conf0, Check) ->
7705    Conf   = [?EC_V3|Conf0],
7706    Decode = fun(B) -> decode_message(Codec, false, Conf, B) end,
7707    megaco_codec_test_lib:expect_decode(Msg, Decode, Check).
7708
7709%% --
7710
7711%% ticket_expect_exec(Instructions, Msg) ->
7712%%     megaco_codec_test_lib:expect_exec(Instructions, Msg).
7713
7714%% ticket_expect_instruction(Desc, Cmd, Verify) ->
7715%%     megaco_codec_test_lib:expect_instruction(Desc, Cmd, Verify).
7716
7717
7718%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7719
7720%% pretty_decode_message(DynamicDecode, Conf, Bin) ->
7721%%     decode_message(megaco_pretty_text_encoder, DynamicDecode, Conf, Bin).
7722
7723%% compact_decode_message(DynamicDecode, Conf, Bin) ->
7724%%     decode_message(megaco_compact_text_encoder, DynamicDecode, Conf, Bin).
7725
7726decode_message(Codec, DynamicDecode, Conf, Bin) ->
7727    megaco_codec_test_lib:decode_message(Codec, DynamicDecode, ?VERSION,
7728					 Conf, Bin).
7729
7730%% pretty_encode_message(Conf, Msg) ->
7731%%     encode_message(megaco_pretty_text_encoder, Conf, Msg).
7732
7733%% compact_encode_message(Conf, Msg) ->
7734%%     encode_message(megaco_compact_text_encoder, Conf, Msg).
7735
7736encode_message(Codec, Conf, Msg) ->
7737    megaco_codec_test_lib:encode_message(Codec, ?VERSION, Conf, Msg).
7738
7739test_msgs(Codec, DynamicDecode, Conf, Msgs) ->
7740    megaco_codec_test_lib:test_msgs(Codec, DynamicDecode, ?VERSION, Conf,
7741				    fun chk_MegacoMessage/2, Msgs).
7742
7743
7744%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7745
7746chk_MegacoMessage(M1, M2) ->
7747    ?MSG_LIB:chk_MegacoMessage(M1, M2).
7748
7749
7750%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7751
7752cre_MegacoMessage(Mess) ->
7753    ?MSG_LIB:cre_MegacoMessage(Mess).
7754
7755cre_MegacoMessage(Auth, Mess) ->
7756    ?MSG_LIB:cre_MegacoMessage(Auth, Mess).
7757
7758cre_MegacoMessage(V, Mid, Body) ->
7759    Mess = ?MSG_LIB:cre_Message(V, Mid, Body),
7760    cre_MegacoMessage(Mess).
7761
7762cre_AuthHeader() ->
7763    SecParmIdx = [239, 205, 171, 137],
7764    SeqNum     = [18, 52, 86, 120],
7765    AD         = [18, 52, 86, 120, 137, 171, 205, 239, 118, 84, 50, 16],
7766    cre_AuthHeader(SecParmIdx, SeqNum, AD).
7767
7768cre_AuthHeader(Idx, Num, D) ->
7769    ?MSG_LIB:cre_AuthenticationHeader(Idx, Num, D).
7770
7771cre_Msg(Mid, Body) ->
7772    cre_Msg(?VERSION, Mid, Body).
7773
7774cre_Msg(V, Mid, Body) ->
7775    ?MSG_LIB:cre_Message(V, Mid, Body).
7776
7777cre_TransId(TransId) ->
7778    ?MSG_LIB:cre_TransactionId(TransId).
7779
7780cre_Trans(Trans) ->
7781    ?MSG_LIB:cre_Transaction(Trans).
7782
7783cre_TransReq(TransId, Actions) ->
7784    ?MSG_LIB:cre_TransactionRequest(TransId, Actions).
7785
7786cre_TransRep(TransId, Actions) ->
7787    ?MSG_LIB:cre_TransactionReply(TransId, Actions).
7788
7789cre_TransAck(First, Last) ->
7790    ?MSG_LIB:cre_TransactionAck(First, Last).
7791
7792cre_ActReq(CtxId, CmdReqs) ->
7793    ?MSG_LIB:cre_ActionRequest(CtxId, CmdReqs).
7794
7795cre_ActRep(CtxId, CmdReps) ->
7796    ?MSG_LIB:cre_ActionReply(CtxId, CmdReps).
7797
7798cre_ActRep(CtxId, ED, CR, CmdReps) ->
7799    ?MSG_LIB:cre_ActionReply(CtxId, ED, CR, CmdReps).
7800
7801cre_CtxReq() ->
7802    ?MSG_LIB:cre_ContextRequest().
7803
7804cre_CtxReq(A) ->
7805    ?MSG_LIB:cre_ContextRequest(A).
7806
7807cre_CtxReq(A, B) ->
7808    ?MSG_LIB:cre_ContextRequest(A, B).
7809
7810cre_CtxReq(A, B, C) ->
7811    ?MSG_LIB:cre_ContextRequest(A, B, C).
7812
7813cre_CtxReq(A, B, C, D) ->
7814    ?MSG_LIB:cre_ContextRequest(A, B, C, D).
7815
7816cre_CtxReq(A, B, C, D, E) ->
7817    ?MSG_LIB:cre_ContextRequest(A, B, C, D, E).
7818
7819cre_CtxReq(Prio, Em, Top, Ieps, CtxProp, CtxList) ->
7820    ?MSG_LIB:cre_ContextRequest(Prio, Em, Top, Ieps, CtxProp, CtxList).
7821
7822cre_CtxAttrAuditReq() ->
7823    ?MSG_LIB:cre_ContextAttrAuditRequest().
7824
7825% cre_CtxAttrAuditReq(A) ->
7826%     ?MSG_LIB:cre_ContextAttrAuditRequest(A).
7827
7828% cre_CtxAttrAuditReq(A, B) ->
7829%     ?MSG_LIB:cre_ContextAttrAuditRequest(A, B).
7830
7831cre_CtxAttrAuditReq(A, B, C) ->
7832    ?MSG_LIB:cre_ContextAttrAuditRequest(A, B, C).
7833
7834cre_CtxAttrAuditReq(A, B, C, D) ->
7835    ?MSG_LIB:cre_ContextAttrAuditRequest(A, B, C, D).
7836
7837cre_CtxAttrAuditReq(A, B, C, D, E) ->
7838    ?MSG_LIB:cre_ContextAttrAuditRequest(A, B, C, D, E).
7839
7840cre_CtxAttrAuditReq(Top, Em, Prio, Ieps, Ctx, SPrio) ->
7841    ?MSG_LIB:cre_ContextAttrAuditRequest(Top, Em, Prio, Ieps, Ctx, SPrio).
7842
7843cre_CtxAttrAuditReq(A, B, C, D, E, F, G) ->
7844    ?MSG_LIB:cre_ContextAttrAuditRequest(A, B, C, D, E, F, G).
7845
7846cre_CtxAttrAuditReq(Top, Em, Prio, Ieps, Ctx, SPrio, SEm, SIeps) ->
7847    ?MSG_LIB:cre_ContextAttrAuditRequest(Top, Em, Prio, Ieps, Ctx,
7848					 SPrio, SEm, SIeps).
7849
7850cre_CtxAttrAuditReq(Top, Em, Prio, Ieps, Ctx, SPrio, SEm, SIeps, SLog) ->
7851    ?MSG_LIB:cre_ContextAttrAuditRequest(Top, Em, Prio, Ieps, Ctx,
7852					 SPrio, SEm, SIeps, SLog).
7853
7854cre_TopologyRequest(From, To, Dir) ->
7855    ?MSG_LIB:cre_TopologyRequest(From, To, Dir).
7856
7857%% Ind Aud related:
7858
7859cre_IndAudParam(IAP) ->
7860    ?MSG_LIB:cre_IndAuditParameter(IAP).
7861
7862cre_IndAudMediaDesc(D) ->
7863    ?MSG_LIB:cre_IndAudMediaDescriptor(D).
7864
7865cre_IndAudStreamDesc(SID, SP) ->
7866    ?MSG_LIB:cre_IndAudStreamDescriptor(SID, SP).
7867
7868cre_IndAudStreamParms(LCD) ->
7869    ?MSG_LIB:cre_IndAudStreamParms(LCD).
7870
7871cre_IndAudLocalControlDesc(A, B, C, D) ->
7872    ?MSG_LIB:cre_IndAudLocalControlDescriptor(A, B, C, D).
7873
7874cre_IndAudLocalControlDesc(SM, RV, RG, PP, SMS) ->
7875    ?MSG_LIB:cre_IndAudLocalControlDescriptor(SM, RV, RG, PP, SMS).
7876
7877cre_IndAudPropertyParm(Name) ->
7878    ?MSG_LIB:cre_IndAudPropertyParm(Name).
7879
7880cre_IndAudPropertyParm(Name, PP) ->
7881    ?MSG_LIB:cre_IndAudPropertyParm(Name, PP).
7882
7883cre_IndAudTermStateDesc(PP) ->
7884    ?MSG_LIB:cre_IndAudTerminationStateDescriptor(PP).
7885
7886cre_IndAudTermStateDesc(PP, EBC, SS) ->
7887    ?MSG_LIB:cre_IndAudTerminationStateDescriptor(PP, EBC, SS).
7888
7889cre_IndAudTermStateDesc(PP, EBC, SS, SSS) ->
7890    ?MSG_LIB:cre_IndAudTerminationStateDescriptor(PP, EBC, SS, SSS).
7891
7892cre_IndAudEvsDesc(RID, PN)
7893  when is_integer(RID) ->
7894    ?MSG_LIB:cre_IndAudEventsDescriptor(RID, PN).
7895
7896cre_IndAudEvBufDesc(EN, SID) ->
7897    ?MSG_LIB:cre_IndAudEventBufferDescriptor(EN, SID).
7898
7899cre_IndAudSigsDesc(D) ->
7900    ?MSG_LIB:cre_IndAudSignalsDescriptor(D).
7901
7902cre_IndAudSig(SN) ->
7903    ?MSG_LIB:cre_IndAudSignal(SN).
7904
7905cre_IndAudSig(SN, SigRID) ->
7906    ?MSG_LIB:cre_IndAudSignal(SN, SigRID).
7907
7908cre_IndAudSeqSigList(ID, SL) ->
7909    ?MSG_LIB:cre_IndAudSeqSigList(ID, SL).
7910
7911cre_IndAudDigitMapDesc(DMN) ->
7912    ?MSG_LIB:cre_IndAudDigitMapDescriptor(DMN).
7913
7914cre_IndAudStatsDesc(SN) ->
7915    ?MSG_LIB:cre_IndAudStatisticsDescriptor(SN).
7916
7917cre_IndAudPkgsDesc(PN, PV) ->
7918    ?MSG_LIB:cre_IndAudPackagesDescriptor(PN, PV).
7919
7920%% Parameter related
7921cre_PropParm(Name, Val) ->
7922    ?MSG_LIB:cre_PropertyParm(Name, [Val]).
7923
7924cre_PropParm(Name, Vals, Tag, EI) ->
7925    ?MSG_LIB:cre_PropertyParm(Name, Vals, Tag, EI).
7926
7927
7928%% Statistics related
7929cre_StatsDesc(SPs) ->
7930    ?MSG_LIB:cre_StatisticsDescriptor(SPs).
7931
7932cre_StatsParm(Name) ->
7933    ?MSG_LIB:cre_StatisticsParameter(Name).
7934
7935cre_StatsParm(Name, Val) ->
7936    ?MSG_LIB:cre_StatisticsParameter(Name, [Val]).
7937
7938
7939% Event related
7940cre_EvParm(Name, Val) ->
7941    ?MSG_LIB:cre_EventParameter(Name, Val).
7942
7943cre_ObsEv(Name, Not) ->
7944    ?MSG_LIB:cre_ObservedEvent(Name, Not).
7945cre_ObsEv(Name, Not, Par) ->
7946    ?MSG_LIB:cre_ObservedEvent(Name, Par, Not).
7947
7948cre_ReqEv(Name) ->
7949    ?MSG_LIB:cre_RequestedEvent(Name).
7950cre_ReqEv(Name, EPL) ->
7951    ?MSG_LIB:cre_RequestedEvent(Name, EPL).
7952cre_ReqEv(Name, SID, RA, EPL) ->
7953    ?MSG_LIB:cre_RequestedEvent(Name, SID, RA, EPL).
7954
7955
7956cre_ObsEvsDesc(Id, EvList) ->
7957    ?MSG_LIB:cre_ObservedEventsDescriptor(Id, EvList).
7958
7959cre_EvsDesc(Id, EvList) ->
7960    ?MSG_LIB:cre_EventsDescriptor(Id, EvList).
7961
7962
7963%% Service change related
7964cre_SvcChParm(M, A, R, P) ->
7965    ?MSG_LIB:cre_ServiceChangeParm(M, A, P, R).
7966
7967cre_SvcChParm(M, A, R, P, IF) ->
7968    ?MSG_LIB:cre_ServiceChangeParm(M, A, asn1_NOVALUE, P, R, asn1_NOVALUE,
7969			  asn1_NOVALUE, asn1_NOVALUE, asn1_NOVALUE, IF).
7970
7971cre_SvcChResParm(A, P) ->
7972    ?MSG_LIB:cre_ServiceChangeResParm(A, P).
7973
7974cre_SvcChReq(Tids, P) ->
7975    ?MSG_LIB:cre_ServiceChangeRequest(Tids, P).
7976
7977cre_SvcChProf(Name, Ver) ->
7978    ?MSG_LIB:cre_ServiceChangeProfile(Name, Ver).
7979
7980cre_SvcChAddr(Tag, Val) ->
7981    ?MSG_LIB:cre_ServiceChangeAddress(Tag, Val).
7982
7983cre_SvcChMethod(M) ->
7984    ?MSG_LIB:cre_ServiceChangeMethod(M).
7985
7986cre_SvcChRep(Tids, Res) ->
7987    ?MSG_LIB:cre_ServiceChangeReply(Tids, Res).
7988
7989
7990%% Stream related
7991cre_StreamID(Id) ->
7992    ?MSG_LIB:cre_StreamID(Id).
7993
7994cre_StreamParms(Lcd) ->
7995    ?MSG_LIB:cre_StreamParms(Lcd).
7996cre_StreamParms(Lcd, Ld) ->
7997    ?MSG_LIB:cre_StreamParms(Lcd, Ld).
7998cre_StreamParms(Lcd, Ld, Rd) ->
7999    ?MSG_LIB:cre_StreamParms(Lcd, Ld, Rd).
8000cre_StreamParmsL(Ld) ->
8001    ?MSG_LIB:cre_StreamParms(asn1_NOVALUE, Ld, asn1_NOVALUE).
8002cre_StreamParmsR(Rd) ->
8003    ?MSG_LIB:cre_StreamParms(asn1_NOVALUE, asn1_NOVALUE, Rd).
8004
8005cre_StreamDesc(Id, P) ->
8006    ?MSG_LIB:cre_StreamDescriptor(Id, P).
8007
8008
8009%% "Local" related
8010cre_LocalControlDesc(Mode) ->
8011    ?MSG_LIB:cre_LocalControlDescriptor(Mode).
8012cre_LocalControlDesc(Mode, Parms) ->
8013    ?MSG_LIB:cre_LocalControlDescriptor(Mode, Parms).
8014
8015cre_LocalRemoteDesc(Grps) ->
8016    ?MSG_LIB:cre_LocalRemoteDescriptor(Grps).
8017
8018
8019%% DigitMap related
8020cre_DigitMapDesc() ->
8021    ?MSG_LIB:cre_DigitMapDescriptor().
8022cre_DigitMapDesc(NameOrVal) ->
8023    ?MSG_LIB:cre_DigitMapDescriptor(NameOrVal).
8024cre_DigitMapDesc(Name, Val) ->
8025    ?MSG_LIB:cre_DigitMapDescriptor(Name, Val).
8026
8027cre_DigitMapValue(Body) ->
8028    ?MSG_LIB:cre_DigitMapValue(Body).
8029
8030cre_DigitMapValue(Body, Start, Short, Long) ->
8031    ?MSG_LIB:cre_DigitMapValue(Start, Short, Long, Body).
8032
8033%% Media related
8034cre_MediaDesc(SD) when is_record(SD, 'StreamDescriptor') ->
8035    cre_MediaDesc([SD]);
8036cre_MediaDesc(SDs) ->
8037    ?MSG_LIB:cre_MediaDescriptor(SDs).
8038
8039
8040%% Notify related
8041cre_NotifyReq(Tids, EvsDesc) ->
8042    ?MSG_LIB:cre_NotifyRequest(Tids, EvsDesc).
8043
8044cre_NotifyRep(Tids) ->
8045    ?MSG_LIB:cre_NotifyReply(Tids).
8046
8047
8048%% Subtract related
8049cre_SubReq(Tids, Desc) ->
8050    ?MSG_LIB:cre_SubtractRequest(Tids, Desc).
8051
8052
8053%% Audit related
8054cre_AuditDesc(Tokens) ->
8055    ?MSG_LIB:cre_AuditDescriptor(Tokens).
8056
8057cre_AuditDesc(Tokens, PropertTokens) ->
8058    ?MSG_LIB:cre_AuditDescriptor(Tokens, PropertTokens).
8059
8060cre_AuditReq(Tid, Desc) ->
8061    ?MSG_LIB:cre_AuditRequest(Tid, Desc).
8062
8063cre_AuditRep(AR) ->
8064    ?MSG_LIB:cre_AuditReply(AR).
8065
8066cre_AuditRes(Tid, Res) ->
8067    ?MSG_LIB:cre_AuditResult(Tid, Res).
8068
8069cre_TermAudit(ARP) ->
8070    ?MSG_LIB:cre_TerminationAudit(ARP).
8071
8072cre_AuditRetParam(D) ->
8073    ?MSG_LIB:cre_AuditReturnParameter(D).
8074
8075cre_TermListAuditRes(TIDs, TA) ->
8076    ?MSG_LIB:cre_TermListAuditResult(TIDs, TA).
8077
8078%% AMM/AMMS related
8079cre_AmmDesc(D) ->
8080    ?MSG_LIB:cre_AmmDescriptor(D).
8081
8082cre_AmmReq(Tids, Descs) ->
8083    ?MSG_LIB:cre_AmmRequest(Tids, Descs).
8084
8085cre_AmmsReply(Tids) ->
8086    ?MSG_LIB:cre_AmmsReply(Tids).
8087cre_AmmsReply(Tids, Descs) ->
8088    ?MSG_LIB:cre_AmmsReply(Tids, Descs).
8089
8090
8091%% Command related
8092cre_Cmd(Tag, Req) ->
8093    ?MSG_LIB:cre_Command(Tag, Req).
8094
8095cre_CmdReq(Cmd) ->
8096    ?MSG_LIB:cre_CommandRequest(Cmd).
8097
8098cre_CmdRep(Tag, Rep) ->
8099    ?MSG_LIB:cre_CommandReply(Tag, Rep).
8100
8101
8102%% Actions related
8103cre_ReqActs(A) ->
8104    ?MSG_LIB:cre_RequestedActions(A).
8105
8106cre_ReqActs(KA, EDM, SE, SD, NB, RED) ->
8107    ?MSG_LIB:cre_RequestedActions(KA, EDM, SE, SD, NB, RED).
8108
8109%% cre_SecReqActs() ->
8110%%     ?MSG_LIB:cre_SecondRequestedActions().
8111
8112%% cre_SecReqActs(A) ->
8113%%     ?MSG_LIB:cre_SecondRequestedActions(A).
8114
8115cre_SecReqActs(KA, EDM, SD, NB, RED) ->
8116    ?MSG_LIB:cre_SecondRequestedActions(KA, EDM, SD, NB, RED).
8117
8118cre_EvDM(Name) when is_list(Name) ->
8119    ?MSG_LIB:cre_EventDM(Name).
8120
8121cre_RegEmbedDesc() ->
8122    ?MSG_LIB:cre_RegulatedEmbeddedDescriptor().
8123
8124cre_RegEmbedDesc(D) ->
8125    ?MSG_LIB:cre_RegulatedEmbeddedDescriptor(D).
8126
8127cre_RegEmbedDesc(SED, SD) ->
8128    ?MSG_LIB:cre_RegulatedEmbeddedDescriptor(SED, SD).
8129
8130%% cre_SecEvsDesc(REDs) ->
8131%%     ?MSG_LIB:cre_SecondEventsDescriptor(REDs).
8132
8133cre_SecEvsDesc(RID, REDs) ->
8134    ?MSG_LIB:cre_SecondEventsDescriptor(RID, REDs).
8135
8136cre_SecReqEv(N) ->
8137    cre_SecReqEv(N, []).
8138
8139cre_SecReqEv(N, EPL) ->
8140    ?MSG_LIB:cre_SecondRequestedEvent(N, EPL).
8141
8142cre_SecReqEv(N, SID, EA) when is_list(N) andalso
8143			      is_integer(SID) andalso
8144			      is_record(EA, 'SecondRequestedActions') ->
8145    cre_SecReqEv(N, SID, EA, []);
8146cre_SecReqEv(A, B, C) ->
8147    ?MSG_LIB:cre_SecondRequestedEvent(A, B, C).
8148
8149cre_SecReqEv(N, SID, EA, EPL) ->
8150    ?MSG_LIB:cre_SecondRequestedEvent(N, SID, EA, EPL).
8151
8152%% Signal related
8153cre_SigsDesc() ->
8154    cre_SigsDesc([]).
8155
8156cre_SigsDesc(SRs) ->
8157    ?MSG_LIB:cre_SignalsDescriptor(SRs).
8158
8159cre_SigDir(D) ->
8160    ?MSG_LIB:cre_SignalDirection(D).
8161
8162cre_Sig(Name) ->
8163    cre_Sig(Name, []).
8164
8165cre_Sig(Name, SPL) ->
8166    ?MSG_LIB:cre_Signal(Name, SPL).
8167
8168cre_Sig(Name, Dir, RID) ->
8169    cre_Sig(Name, [], Dir, RID).
8170
8171cre_Sig(Name, SPL, Dir, RID) ->
8172    cre_Sig(Name, asn1_NOVALUE, asn1_NOVALUE, asn1_NOVALUE, asn1_NOVALUE,
8173	    asn1_NOVALUE, SPL, Dir, RID).
8174
8175cre_Sig(Name, SID, ST, Dur, NC, KA, SPL, Dir, RID) ->
8176    ?MSG_LIB:cre_Signal(Name, SID, ST, Dur, NC, KA, SPL, Dir, RID).
8177
8178cre_Sig(Name, SID, ST, Dur, NC, KA, SPL, Dir, RID, ISD) ->
8179    ?MSG_LIB:cre_Signal(Name, SID, ST, Dur, NC, KA, SPL, Dir, RID, ISD).
8180
8181cre_SigReq(S) ->
8182    ?MSG_LIB:cre_SignalRequest(S).
8183
8184cre_NotifBehav(Tag, Val) ->
8185    ?MSG_LIB:cre_NotifyBehaviour(Tag, Val).
8186
8187cre_NotifCompl(NC) ->
8188    ?MSG_LIB:cre_NotifyCompletion(NC).
8189
8190cre_SigType(ST) ->
8191   ?MSG_LIB:cre_SignalType(ST).
8192
8193
8194%% Others
8195cre_ErrCode(EC) ->
8196    ?MSG_LIB:cre_ErrorCode(EC).
8197
8198cre_ErrDesc(EC) ->
8199    ?MSG_LIB:cre_ErrorDescriptor(EC).
8200
8201cre_TermIDList(TIDs) ->
8202    ?MSG_LIB:cre_TerminationIDList(TIDs).
8203
8204cre_ServiceState(SS) ->
8205    ?MSG_LIB:cre_ServiceState(SS).
8206
8207cre_StreamMode(SS) ->
8208    ?MSG_LIB:cre_StreamMode(SS).
8209
8210cre_SelectLogic(Tag) ->
8211    ?MSG_LIB:cre_SelectLogic(Tag).
8212
8213cre_CtxID(CID) ->
8214    ?MSG_LIB:cre_ContextID(CID).
8215
8216cre_ReqID(RID) ->
8217    ?MSG_LIB:cre_RequestID(RID).
8218
8219cre_TimeNot(D,T) ->
8220    ?MSG_LIB:cre_TimeNotation(D, T).
8221
8222cre_PkgsItem(Name, Ver) ->
8223    ?MSG_LIB:cre_PackagesItem(Name, Ver).
8224
8225cre_BOOLEAN(B) ->
8226    ?MSG_LIB:cre_BOOLEAN(B).
8227
8228
8229%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8230
8231flex_init(Config) ->
8232    megaco_codec_flex_lib:init(Config).
8233
8234flex_finish(Config) ->
8235    megaco_codec_flex_lib:finish(Config).
8236
8237flex_scanner_conf(Config) ->
8238    megaco_codec_flex_lib:scanner_conf(Config).
8239
8240%% start_flex_scanner() ->
8241%%     megaco_codec_flex_lib:start().
8242
8243%% stop_flex_scanner(Pid) ->
8244%%     megaco_codec_flex_lib:stop(Pid).
8245
8246
8247%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8248
8249t(F,A) ->
8250    p(printable(get(severity),trc),trc,F,A).
8251
8252d(F,A) ->
8253    p(printable(get(severity),dbg),dbg,F,A).
8254
8255%% l(F,A) ->
8256%%     p(printable(get(severity),log),log,F,A).
8257
8258e(F,A) ->
8259    p(printable(get(severity),err),err,F,A).
8260
8261
8262printable(trc,_) ->
8263    true;
8264printable(dbg,trc) ->
8265    false;
8266printable(dbg,_) ->
8267    true;
8268printable(log,log) ->
8269    true;
8270printable(log,err) ->
8271    true;
8272printable(err,err) ->
8273    true;
8274printable(_,_) ->
8275    false.
8276
8277
8278image_of(trc) ->
8279    "TRC";
8280image_of(dbg) ->
8281    "DBG";
8282image_of(log) ->
8283    "LOG";
8284image_of(err) ->
8285    "ERR";
8286image_of(L) ->
8287    io_lib:format("~p",[L]).
8288
8289
8290p(true,L,F,A) ->
8291    io:format("~s:" ++ F ++ "~n", [image_of(L)|A]);
8292p(_,_,_,_) ->
8293    ok.
8294
8295
8296p(F, A) ->
8297    io:format("*** [~s] ***"
8298	      "~n   " ++ F ++ "~n",
8299	      [?FTS() | A]).
8300
8301