4
%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
23
-export([compile/3,main/2,msg11/0]).
25
-include("test_server.hrl").
26
-define(MID, {ip4Address, #'IP4Address'{address = [124, 124, 124, 222],
27
portNumber = 55555}}).
28
-define(A4444, ["11111111"]).
30
-record('MegacoMessage',
32
authHeader = asn1_NOVALUE,
41
}). % with extension mark
46
portNumber = asn1_NOVALUE
49
-record('TransactionRequest',
53
}). % with extension mark
55
-record('ActionRequest',
58
contextRequest = asn1_NOVALUE,
59
contextAttrAuditReq = asn1_NOVALUE,
63
-record('CommandRequest',
66
optional = asn1_NOVALUE,
67
wildcardReturn = asn1_NOVALUE
68
}). % with extension mark
70
-record('NotifyRequest',
73
observedEventsDescriptor,
74
errorDescriptor = asn1_NOVALUE
75
}). % with extension mark
77
-record('ObservedEventsDescriptor',
83
-record('ObservedEvent',
86
streamID = asn1_NOVALUE,
88
timeNotation = asn1_NOVALUE
89
}). % with extension mark
91
-record('EventParameter',
97
-record('TimeNotation',
103
-record(megaco_term_id, {contains_wildcards = ["f"], id}).
106
compile(_Config,ber,[optimize]) ->
107
{ok,no_module,no_module};
108
compile(_Config,per,[optimize]) ->
109
{ok,no_module,no_module};
110
compile(Config,Erule,Options) ->
111
?line DataDir = ?config(data_dir,Config),
112
?line OutDir = ?config(priv_dir,Config),
113
?line true = code:add_patha(?config(priv_dir,Config)),
115
?line ok = asn1ct:compile(DataDir ++
116
"MEDIA-GATEWAY-CONTROL.asn",
117
[Erule,{outdir,OutDir}]++Options),
119
?line ok = asn1ct:compile(DataDir ++
120
"OLD-MEDIA-GATEWAY-CONTROL.asn",
121
[Erule,{outdir,OutDir}]++Options),
122
{ok,'OLD-MEDIA-GATEWAY-CONTROL','MEDIA-GATEWAY-CONTROL'}.
125
main(no_module,_) -> ok;
126
main('OLD-MEDIA-GATEWAY-CONTROL',_) ->
128
{ok,Msg} = asn1ct:value('OLD-MEDIA-GATEWAY-CONTROL','MegacoMessage'),
129
?line {ok,Bytes} = asn1_wrapper:encode('OLD-MEDIA-GATEWAY-CONTROL',
130
'MegacoMessage',Msg),
131
?line {ok,Msg} = asn1_wrapper:decode('OLD-MEDIA-GATEWAY-CONTROL',
135
main(Mod='MEDIA-GATEWAY-CONTROL',Config) ->
136
?line DataDir = ?config(data_dir,Config),
137
io:format("DataDir:~p~n",[DataDir]),
138
?line {ok,FilenameList} = file:list_dir(filename:join([DataDir,
140
%% remove any junk files that may be in the megacomessage directory
142
case lists:reverse(X) of
143
[$l,$a,$v,$.|_R] ->true;
147
MegacoMsgFilenameList = lists:filter(Pred,FilenameList),
150
M = read_msg(filename:join([DataDir,megacomessages,F])),
151
{ok,B} = asn1_wrapper:encode(Mod,element(1,M),M),
152
{ok,M} = asn1_wrapper:decode(Mod,element(1,M),B)
154
?line lists:foreach(Fun,MegacoMsgFilenameList),
158
case file:read_file(File) of
162
io:format("couldn't read file ~p~n",[File])
166
request(Mid, TransId, ContextId, CmdReq) when list(CmdReq) ->
167
Actions = [#'ActionRequest'{contextId = ContextId,
168
commandRequests = CmdReq}],
170
[{transactionRequest,
171
#'TransactionRequest'{transactionId = TransId,
172
actions = Actions}}]},
173
#'MegacoMessage'{mess = #'Message'{version = 1,
178
TimeStamp = #'TimeNotation'{date = "19990729",
180
Parm = #'EventParameter'{eventParameterName = "ds",
181
value = "916135551212"},
183
Event = #'ObservedEvent'{eventName = "ddce",
184
timeNotation = TimeStamp,
185
eventParList = [Parm]},
186
Desc = #'ObservedEventsDescriptor'{requestId = 2223,
187
observedEventLst = [Event]},
188
NotifyReq = #'NotifyRequest'{terminationID = [#megaco_term_id{id = ?A4444}],
189
observedEventsDescriptor = Desc},
190
CmdReq = #'CommandRequest'{command = {notifyReq, NotifyReq}},
191
request(?MID, 10002, 0, [CmdReq]).