AdapterControlPort_Pki.partC 2.63 KB
Newer Older
Yann Garcia's avatar
Yann Garcia committed
1
2
3
4
5
#include <TTCN3.hh>

#include "loggers.hh"
#include "registration.hh"

Yann Garcia's avatar
Yann Garcia committed
6
//#include "pki_layer.hh"
Yann Garcia's avatar
Yann Garcia committed
7
8
9
10

//=============================================================================
namespace LibItsPki__TestSystem {

11
12
  AdapterControlPort::AdapterControlPort(const char *par_port_name)
    : AdapterControlPort_BASE(par_port_name), _params()
Yann Garcia's avatar
Yann Garcia committed
13
  {
14
    loggers::get_instance().log("AdapterControlPort::AdapterControlPort");
Yann Garcia's avatar
Yann Garcia committed
15
16
17
18


  }

19
  AdapterControlPort::~AdapterControlPort()
Yann Garcia's avatar
Yann Garcia committed
20
21
22
23
  {

  }

24
  void AdapterControlPort::set_parameter(const char * parameter_name, const char * parameter_value)
Yann Garcia's avatar
Yann Garcia committed
25
  {
26
    loggers::get_instance().log("AdapterControlPort::set_parameter: %s=%s", parameter_name, parameter_value);
Yann Garcia's avatar
Yann Garcia committed
27
28
29

  }

30
  /*void AdapterControlPort::Handle_Fd_Event(int fd, boolean is_readable,
Yann Garcia's avatar
Yann Garcia committed
31
32
    boolean is_writable, boolean is_error) {}*/

33
  void AdapterControlPort::Handle_Fd_Event_Error(int /*fd*/)
Yann Garcia's avatar
Yann Garcia committed
34
35
36
37
  {

  }

38
  void AdapterControlPort::Handle_Fd_Event_Writable(int /*fd*/)
Yann Garcia's avatar
Yann Garcia committed
39
40
41
42
  {

  }

43
  void AdapterControlPort::Handle_Fd_Event_Readable(int /*fd*/)
Yann Garcia's avatar
Yann Garcia committed
44
45
46
47
  {

  }

48
  /*void AdapterControlPort::Handle_Timeout(double time_since_last_call) {}*/
Yann Garcia's avatar
Yann Garcia committed
49

50
  void AdapterControlPort::user_map(const char * system_port)
Yann Garcia's avatar
Yann Garcia committed
51
  {
52
    loggers::get_instance().log(">>> AdapterControlPort::user_map: %s", system_port);
Yann Garcia's avatar
Yann Garcia committed
53
54
55

  }

56
  void AdapterControlPort::user_unmap(const char * system_port)
Yann Garcia's avatar
Yann Garcia committed
57
  {
58
    loggers::get_instance().log(">>> AdapterControlPort::user_unmap: %s", system_port);
Yann Garcia's avatar
Yann Garcia committed
59
60
61

  }

62
  void AdapterControlPort::user_start()
Yann Garcia's avatar
Yann Garcia committed
63
64
65
66
  {

  }

67
  void AdapterControlPort::user_stop()
Yann Garcia's avatar
Yann Garcia committed
68
69
70
71
  {

  }

72
  void AdapterControlPort::outgoing_send(const LibItsPki__TypesAndValues::AcPkiPrimitive& send_par)
Yann Garcia's avatar
Yann Garcia committed
73
  {
74
    loggers::get_instance().log_msg(">>> AdapterControlPort::outgoing_send: ", send_par);
Yann Garcia's avatar
Yann Garcia committed
75
    
76
    // Register this object for AdapterControlPort
Yann Garcia's avatar
Yann Garcia committed
77
    pki_layer* p = registration<pki_layer>::get_instance().get_item(std::string("PKI"));
Yann Garcia's avatar
Yann Garcia committed
78
    if (p != NULL) {
79
      loggers::get_instance().log("AdapterControlPort::outgoing_send: Got PKI layer %p", p);
Yann Garcia's avatar
Yann Garcia committed
80
      LibItsPki__TypesAndValues::AcPkiResponse response;
81
      response.result() = BOOLEAN(false);
Yann Garcia's avatar
Yann Garcia committed
82
      if (send_par.ischosen(LibItsPki__TypesAndValues::AcPkiPrimitive::ALT_acSetSecurityData)) {
83
        loggers::get_instance().log("AdapterControlPort::outgoing_send: AcSetSecurityData");
Yann Garcia's avatar
Yann Garcia committed
84
        p->set_pki_keys(send_par.acSetSecurityData());
85
        response.result() = BOOLEAN(true);
Yann Garcia's avatar
Yann Garcia committed
86
87
      }
      // Send response
88
      loggers::get_instance().log_msg("AdapterControlPort::outgoing_send: Send response: ", response);
Yann Garcia's avatar
Yann Garcia committed
89
90
      incoming_message(response);
    } else {
91
      loggers::get_instance().error("AdapterControlPort::outgoing_send: pkiPort not registered");
Yann Garcia's avatar
Yann Garcia committed
92
93
94
95
    }
  }

} /* end of namespace */