summaryrefslogtreecommitdiff
path: root/TAO/tao/GIOP_Message_Accept_State.cpp
blob: 250adc7740a3a071b5a3a06cb31f2d1c40f865ff (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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
//$Id$
#include "tao/GIOP_Message_Accept_State.h"
#include "tao/debug.h"

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

////////////////////////////////////////////////////////////////////////////////
// TAO_GIOP_Message_Accept_State_11 methods 
////////////////////////////////////////////////////////////////////////////////
int
TAO_GIOP_Message_Accept_State_11::
  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));

  // The high bit of the octet has been set if the SyncScope policy
  // value is SYNC_WITH_SERVER. This is a temporary hack until all
  // of GIOP 1.2 is in place. Then we can check the version in the
  // message header instead.
  request.sync_with_server ((response_flags == 129));

  // 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;
}


CORBA::Boolean
TAO_GIOP_Message_Accept_State_11::
  write_reply_header (TAO_OutputCDR &output,
                      CORBA::ULong request_id)
{
  // 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;
}

int
TAO_GIOP_Message_Accept_State_11::
  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;
}

CORBA::Boolean
TAO_GIOP_Message_Accept_State_11::
write_locate_reply_mesg (TAO_OutputCDR &output,
                         CORBA::ULong request_id,
                         TAO_GIOP_Locate_Status_Msg &status_info)
{
  // Make the header for the locate request 
  output.write_ulong (request_id);
  output.write_ulong (status_info.status);
  
  if (status_info.status == TAO_GIOP_OBJECT_FORWARD)
    {
      CORBA::Object_ptr object_ptr = status_info.forward_location_var.in ();
      if ((output << object_ptr) == 0)
        {
          if (TAO_debug_level > 0)
            ACE_DEBUG ((LM_DEBUG,
                        ASYS_TEXT ("TAO (%P|%t|%N|%l) write_locate_reply_mesg-")
                        ASYS_TEXT (" cannot marshal object reference\n")));
        } 
    }
  
  return 1;
}

/*int
TAO_GIOP_Message_Accept_State_11::
  make_reply (const TAO_GIOP_Version &version,
              TAO_GIOP_Message_Type t,
              CORBA::ULong request_id,
              TAO_OutputCDR &);
{
  
}*/

///////////////////////////////////////////////////////////////
// TAO_GIOP_Message_Accept_Impl methods
//////////////////////////////////////////////////////////////
  
CORBA::Boolean
TAO_GIOP_Message_Accept_Impl::
  check_revision (CORBA::Octet incoming_major,
                  CORBA::Octet incoming_minor)
{
  // Need a better way to do this. @@Bala
  if (incoming_major > 1 ||
      incoming_minor > 2)
    return 0;

  return 1;
}