summaryrefslogtreecommitdiff
path: root/TAO/tao/GIOP_Message_Base.h
blob: 5238f9e63d43b84841d03471de67d835cb83d063 (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
// -*- C++ -*-
// $Id$

// ============================================================================
//
// = LIBRARY
//     TAO
//
// = FILENAME
//     GIOP_Message.h
//
// = DESCRIPTION
//     Interface for the GIOP messaging protocol
//
// = AUTHOR
//     Copyright 1994-1995 by Sun Microsystems Inc.,
//     Balachandran Natarajan <bala@cs.wustl.edu>
//
// ============================================================================
#ifndef _TAO_GIOP_MESSAGE_H_
#define _TAO_GIOP_MESSAGE_H_

#include "tao/Pluggable_Messaging.h"
#include "tao/GIOP_Utils.h"


class TAO_Export TAO_GIOP_Message_Base :
  public TAO_Pluggable_Messaging_Interface
{
  // = TITLE
  //   Definitions of client side of the GIOP specific stuff
  //
  // = DESCRIPTION
  //   This class will hold the specific details common to all the
  //   GIOP versions. Some of them which are here may be shifted if
  //   things start changing between versions

  // IMPORTANT: This code was based on the GIOP.h & GIOP.cpp
  
public:
  TAO_GIOP_Message_Base (void);
  
  virtual ~TAO_GIOP_Message_Base (void);
  // Dtor

  virtual CORBA::Boolean write_protocol_header (TAO_Pluggable_Message_Type t,
                                                TAO_OutputCDR &msg);
  // Shouldnt be needed here but for compilation

  int handle_input (TAO_Transport *transport,
                    TAO_ORB_Core *orb_core,
                    TAO_Message_State_Factory &mesg_state,
                    ACE_Time_Value *max_time_value = 0);
  
  virtual CORBA::Boolean 
  write_message_header (const TAO_Pluggable_Connector_Params &params,
                        TAO_Pluggable_Header_Type header_type,
                        TAO_Target_Specification &spec,
                        TAO_OutputCDR &msg);
  // Write the  header.

  int send_message (TAO_Transport *transport,
                    TAO_OutputCDR &stream,
                    ACE_Time_Value *max_wait_time = 0,
                    TAO_Stub *stub = 0);
  
  virtual int parse_reply (TAO_Message_State_Factory &mesg_state,
                           TAO_Pluggable_Connector_Params &params,
                           CORBA::ULong &reply_status) = 0;
  // Parse the reply message from the server

  int process_connector_messages (TAO_Transport *transport,
                                  TAO_ORB_Core *orb_core,
                                  TAO_InputCDR &input,
                                  CORBA::Octet message_type) = 0;
  // Processes the messages from the connectors so that they can be
  // passed on to the appropriate states.

protected:
  virtual const size_t header_len (void);
  // This will give the size of the header for different versions of
  // GIOP. 
  
  virtual const size_t message_size_offset (void);
  // This will give the message_size offset as specified by different
  // versions of GIOP

  virtual const size_t major_version_offset (void);
  // This will give the major_version offset as specified by different
  // versions of GIOP
  
  virtual const size_t minor_version_offset (void);
  // This will give the minor_version offset as specified by different
  // versions of GIOP
  
  virtual const size_t flags_offset (void);
  // This will give the flags  offset as specified by different
  // versions of GIOP

  //  virtual const size_t message_size_offset (void);
  // This will give the message size offset as specified by different
  // versions of GIOP

  virtual const size_t message_type_offset (void);
  // This will give the message type offset as specified by different
  // versions of GIOP
  // @@The above  methods may not be required. But we have it for a
  // later date use wherein things can changes in GIOP

  int  send_error (TAO_Transport *transport);

private:


  virtual CORBA::Octet major_version (void) = 0;
  virtual CORBA::Octet minor_version (void) = 0;

  virtual CORBA::Boolean 
  write_request_header (const IOP::ServiceContextList& svc_ctx,
                        CORBA::ULong request_id,
                        CORBA::Octet response_flags,
                        TAO_Target_Specification &spec,
                        const char* opname,
                        TAO_OutputCDR &msg) = 0;
  // Write the GIOP request header.
  
  virtual CORBA::Boolean 
  write_locate_request_header (CORBA::ULong request_id,
                               TAO_Target_Specification &spec,
                               TAO_OutputCDR &msg) = 0;
  // Write the GIOP locate request header.
  

  int read_bytes_input (TAO_Transport *transport,
                        TAO_InputCDR &input,
                        CORBA::ULong read_size,
                        ACE_Time_Value *max_wait_time);

  virtual int validate_version (TAO_GIOP_Message_State *state) = 0;

  virtual int parse_header (TAO_GIOP_Message_State *state);

  virtual int parse_magic_bytes (TAO_GIOP_Message_State *state);

  ssize_t read_buffer (TAO_Transport *transport,
                       char *buf,
                       size_t len,
                       ACE_Time_Value *max_wait_time);
  // The above method seems to be redundant with read_input_bytes. I
  // will trim it down in the next iteration... @@Bala



  void send_close_connection (const TAO_GIOP_Version &version,
                              TAO_Transport *transport,
                              void *ctx);
  // Close a connection, first sending GIOP::CloseConnection.
};

const size_t TAO_GIOP_HEADER_LEN = 12;
const size_t TAO_GIOP_MESSAGE_SIZE_OFFSET = 8;
const size_t TAO_GIOP_VERSION_MINOR_OFFSET = 5;
const size_t TAO_GIOP_VERSION_MAJOR_OFFSET = 4;
const size_t TAO_GIOP_MESSAGE_FLAGS_OFFSET = 6;
const size_t TAO_GIOP_MESSAGE_TYPE_OFFSET  = 7;
//const size_t TAO_GIOP_MESSAGE_SIZE_OFFSET  = 8;

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

#endif /*_TAO_GIOP_MESSAGE_H_*/