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