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