summaryrefslogtreecommitdiff
path: root/TAO/tao/GIOP_Acceptors.cpp
blob: 6e77ea424d747bd46b5ef01911832d1edfe5d7b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//$Id$
#include "tao/GIOP_Acceptors.h"

#if !defined (__ACE_INLINE__)
# include "tao/GIOP_Acceptors.i"
#endif /* __ACE_INLINE__ */

int
TAO_GIOP_Acceptor_1_1::
parse_request_header (TAO_GIOP_ServerRequest &request) 
{
  // Tear out the service context ... we currently ignore it, but it
  // should probably be passed to each ORB service as appropriate
  // (e.g. transactions, security).
  //
  // NOTE: As security support kicks in, this is a good place to
  // verify a digital signature, if that is required in this security
  // environment.  It may be required even when using IPSEC security
  // infrastructure.

  // Get the input CDR in the request class
  TAO_InputCDR& input = request.incoming ();
  
  IOP::ServiceContextList service_info;
  input >> service_info;
  
  // This method is going to a copy?? Data copy?? Need to figure out a
  // way to avoid this 
  request.service_info (service_info);
  
  
  CORBA::Boolean hdr_status = (CORBA::Boolean) input.good_bit ();

  CORBA::ULong req_id; 
  // Get the rest of the request header ...
  hdr_status = hdr_status && input.read_ulong (req_id);
  
  request.request_id (req_id);
  
  CORBA::Octet response_flags;
  hdr_status = hdr_status && input.read_octet (response_flags);
  request.response_expected ((response_flags != 0));
  request.sync_with_server ((response_flags == 1));

  // We use ad-hoc demarshalling here: there is no need to increase
  // the reference count on the CDR message block, because this key
  // will not outlive the request (or the message block).

  CORBA::Long key_length = 0;
  hdr_status = hdr_status && input.read_long (key_length);
  if (hdr_status)
    {
      request.object_key ().replace (key_length, key_length,
                                     (CORBA::Octet*)input.rd_ptr (),
                                     0);
      input.skip_bytes (key_length);
    }

  ACE_CString operation_name;
  if (input.char_translator () == 0)
    {
      CORBA::ULong length = 0;
      hdr_status = hdr_status && input.read_ulong (length);
      if (hdr_status)
        {
          // Do not include NULL character at the end.
          // @@ This is not getting demarshaled using the codeset
          //    translators!
          operation_name.set (input.rd_ptr (),
                              length - 1,
                              0);
          request.operation (operation_name);
          hdr_status = input.skip_bytes (length);
        }
    }
  else
    {
      // @@ We could optimize for this case too, i.e. do in-place
      //    demarshaling of the string... But there is an issue
      //    pending on the OMG as to whether the operation should be
      //    sent in the connection negotiated codeset or always in
      //    ISO8859-1.
      CORBA::String_var tmp;
      hdr_status = hdr_status && input.read_string (tmp.inout ());
      operation_name.set (tmp._retn (), 1);
      request.operation (operation_name);
    }
  
  if (hdr_status)
    {
      CORBA::Principal_var principal;
      
      // Beware extra data copying
      input >> principal.out ();

      request.requesting_principal (principal.in ());
      
      hdr_status = (CORBA::Boolean) input.good_bit ();
    }

  // Set the header length info and offset info
  request.header_length (this->header_length ());
  request.message_size_offset (this->offset_length ());
  
  return hdr_status ? 0 : -1;
}


int
TAO_GIOP_Acceptor_1_1::
parse_locate_header (TAO_GIOP_Locate_Request_Header &request)
{
  // Get the stream 
  TAO_InputCDR &msg = request.incoming_stream ();

  CORBA::Boolean hdr_status = 1;
  
  // Get the request id
  CORBA::ULong req_id = 0;
  hdr_status = msg.read_ulong (req_id);
  
  // Store it in the Locate request classes
  request.request_id (req_id);

  TAO_ObjectKey object_key;
  
  // Note that here there are no unions and so no problems
  hdr_status = hdr_status && (msg >> object_key);
  
  // Get the underlying TargetAddress from the request class
  GIOP::TargetAddress &target = request.target_address ();

  // Put this object key in the target_adderss
  target.object_key (object_key);

  return hdr_status ? 0 : -1;
}

int
TAO_GIOP_Acceptor_1_1::make_reply (const TAO_GIOP_Version &version,
                                   TAO_GIOP_Message_Type t,
                                   CORBA::ULong request_id,
                                   TAO_OutputCDR &output)
                                   
{
  // Construct a REPLY header.
  TAO_GIOP_Utils::start_message (version,
                                 t,
                                 output);

  
  // create and write a dummy context
  IOP::ServiceContextList resp_ctx;
  resp_ctx.length (0);
  output << resp_ctx;
  
  // Write the request ID
  output.write_ulong (request_id);

  

  return 1;
}