~rdoering/ubuntu/intrepid/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/snmp/test/snmp_test_mgr_misc.erl

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2007-05-01 16:57:10 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070501165710-2sapk0hp2gf3o0ip
Tags: 1:11.b.4-2ubuntu1
* Merge with Debian Unstable. Remaining changes:
  - Add -fno-stack-protector to fix broken crypto_drv.
* DebianMaintainerField update.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
%% 
16
16
%%     $Id$
17
17
%%
 
18
%% ts:run(snmp, snmp_agent_test, [batch]).
 
19
%% 
18
20
-module(snmp_test_mgr_misc).
19
21
 
20
22
%% API
98
100
init_debug(Dbg) when atom(Dbg) ->
99
101
    put(debug,Dbg),
100
102
    put(verbosity,silence);
 
103
    %% put(verbosity,trace);
101
104
init_debug(DbgOptions) when list(DbgOptions) ->
102
105
    case lists:keysearch(debug, 1, DbgOptions) of
103
106
        {value, {_, Dbg}} when atom(Dbg) ->
320
323
    getSysDescr(T).
321
324
    
322
325
handle_v3_msg(Packet, #message{vsn_hdr = V3Hdr, data = Data}) ->
 
326
    d("handle_v3_msg -> entry"),
323
327
    %% Code copied from snmp_mpd.erl
324
328
    #v3_hdr{msgID = MsgId, msgFlags = MsgFlags,
325
329
            msgSecurityModel = MsgSecurityModel,
326
330
            msgSecurityParameters = SecParams} = V3Hdr,
327
 
    SecModule = get_security_module(MsgSecurityModel),
 
331
    SecModule = get_security_module(MsgSecurityModel), 
 
332
    d("handle_v3_msg -> SecModule: ~p", [SecModule]),
328
333
    SecLevel = hd(MsgFlags) band 3,
 
334
    d("handle_v3_msg -> SecLevel: ~p", [SecLevel]),
329
335
    IsReportable = snmp_misc:is_reportable(MsgFlags),
330
336
    SecRes = (catch SecModule:process_incoming_msg(list_to_binary(Packet), 
331
337
                                                   Data,SecParams,SecLevel)),
344
350
    throw({error, {unknown_sec_model, SecModel}}).
345
351
 
346
352
check_sec_module_result(Res, V3Hdr, Data, IsReportable) ->
 
353
    d("check_sec_module_result -> entry with"
 
354
      "~n   Res: ~p", [Res]),
347
355
    case Res of
348
356
        {ok, X} -> 
349
357
            X;
364
372
    end.
365
373
 
366
374
generate_v3_report_msg(_MsgID, _MsgSecurityModel, Data, ErrorInfo) ->
 
375
    d("generate_v3_report_msg -> entry with"
 
376
      "~n   ErrorInfo: ~p", [ErrorInfo]),
367
377
    {Varbind, SecName, Opts} = ErrorInfo,
368
378
    ReqId =
369
379
        if record(Data, scopedPdu) -> (Data#scopedPdu.data)#pdu.request_id;
383
393
 
384
394
 
385
395
error(Format, Data) ->
386
 
    io:format("* Error: "),
 
396
    io:format("*** Error ***~n"),
387
397
    ok = io:format(Format, Data),
388
398
    io:format("~n").
389
399
 
434
444
 
435
445
mk_msg('version-3', Pdu, {Context, User, EngineID, CtxEngineId, SecLevel}, 
436
446
       MsgData) ->
 
447
    d("mk_msg(version-3) -> entry with"
 
448
      "~n   Pdu:         ~p"
 
449
      "~n   Context:     ~p"
 
450
      "~n   User:        ~p"
 
451
      "~n   EngineID:    ~p"
 
452
      "~n   CtxEngineID: ~p"
 
453
      "~n   SecLevel:    ~p", 
 
454
      [Pdu, Context, User, EngineID, CtxEngineId, SecLevel]),
437
455
    %% Code copied from snmp_mpd.erl
438
456
    {MsgId, SecName, SecData} =
439
457
        if
530
548
    snmpa_local_db:start_link(normal, Dir, [{verbosity,trace}]),
531
549
    NameDb = snmpa_agent:db(snmpEngineID),
532
550
    R = snmp_generic:variable_set(NameDb, "mgrEngine"),
533
 
    io:format("init_usm -> engine-id set result: ~p~n", [R]),
 
551
    io:format("~w:init_usm -> engine-id set result: ~p~n", [?MODULE,R]),
534
552
    snmp_framework_mib:set_engine_boots(1),
535
553
    snmp_framework_mib:set_engine_time(1),
536
554
    snmp_user_based_sm_mib:reconfigure(Dir);