summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/AV/FlowSpec_Entry.h
blob: e171286341a7761a6faf18d30927d7b5df48fdec (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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/* -*- C++ -*- */


// ============================================================================
/**
 *  @file    FlowSpec_Entry.h
 *
 *  $Id$
 *
 *  @author  Nagarajan Surendran <naga@cs.wustl.edu>
 *
 */
// ============================================================================

#ifndef TAO_AV_FLOWSPEC_ENTRY_H
#define TAO_AV_FLOWSPEC_ENTRY_H
#include /**/ "ace/pre.h"

#include "orbsvcs/AV/AV_export.h"
#include "AV_Core.h"
#include "ace/Addr.h"
#include "ace/Containers.h"
#include "ace/SString.h"

/**
 * @class TAO_Tokenizer
 * @brief
 */
class TAO_AV_Export TAO_Tokenizer
{
public:
  /// constructor.
  TAO_Tokenizer (const char *string,char delimiter);

  /// destructor.
  ~TAO_Tokenizer ();

  /// parses the string and tokenizes it.
  int parse (const char *string,char delimiter);

  /// Returns the next token.
  char *token (void);

  /// Number of tokens.
  int num_tokens (void);

  const char *operator [] (size_t index) const;

protected:
  ACE_Array<char*> token_array_;
  size_t count_;
  size_t num_tokens_;
  char string_ [BUFSIZ];
};

// Forward declaration.
class TAO_AV_Transport;
class TAO_AV_Flow_Handler;
class TAO_AV_Protocol_Object;

/**
 * @class TAO_FlowSpec_Entry
 * @brief  A helper entry class in the flow spec sequence passed to
 *         bind_devs.
 */
class TAO_AV_Export TAO_FlowSpec_Entry
{
public:

  enum Direction
  {
    TAO_AV_INVALID   = -1,
    TAO_AV_DIR_IN    =  0,
    TAO_AV_DIR_OUT   =  1
  };

  enum Role
  {
    TAO_AV_INVALID_ROLE = -1,
    TAO_AV_PRODUCER = 0,
    TAO_AV_CONSUMER = 1
  };

  /// default constructor.
  TAO_FlowSpec_Entry (void);

  /// constructor to construct an entry from the arguments.
  TAO_FlowSpec_Entry (const char *flowname,
                      const char *direction,
                      const char *format_name,
                      const char *flow_protocol,
                      const char *carrier_protocol,
                      ACE_Addr *fwd_address,
                      //ACE_Addr *peer_address,
                      ACE_Addr *control_address = 0);

  TAO_FlowSpec_Entry (const char *flowname,
                      const char *direction,
                      const char *format_name,
                      const char *flow_protocol,
                      const char *fwd_address);
                      //const char *peer_address);

  /// construct the entry from a string specified by the flowSpec grammar.
  virtual int parse (const char* flowSpec_entry) = 0;

  /// virtual destructor.
  virtual ~TAO_FlowSpec_Entry (void);

  /// accessor to the direction.
  int direction (void);

  virtual Role role (void) = 0;
  void role (Role role);
  /// accessor to string version of direction .
  const char * direction_str (void) const;

  /// accessor to the flow protocol string.
  const char *flow_protocol_str (void) const;

  /// set the flow protocol string.
  void flow_protocol_str (const char *flow_protocol_str);

  /// accessor to address of the carrier protocol.
  //ACE_Addr *fwd_address (void);
  ACE_Addr *address (void);
  ACE_Addr *control_address (void);
  void address (ACE_Addr *address);
  void control_address (ACE_Addr *address);

  /// Address in string format i. hostname:port.
  const char *address_str (void) const;
  //  const char * peer_address_str (void) const;

  /// accessor to carrier protocol i.e TCP,UDP,RTP/UDP.
  TAO_AV_Core::Protocol carrier_protocol (void);

  /// accessor to string version of carrier protocol.
  const char * carrier_protocol_str (void) const;

  /// accessor to format to be used for this flow.
  const char *format (void) const;

  /// accessor to name of this flow.
  const char *flowname (void) const;

  /// converts the entry to a string.
  virtual const char *entry_to_string (void) = 0;

  int set_peer_addr (ACE_Addr *peer_addr);
  ACE_Addr *get_peer_addr (void);
  int set_peer_control_addr (ACE_Addr *peer_control_addr);
  ACE_Addr *get_peer_control_addr (void);

  int set_local_sec_addr (char** local_sec_addr, int size);
  char** get_local_sec_addr (void);
  int num_local_sec_addrs (void);

  int set_peer_sec_addr (char** peer_sec_addr, int size);
  char** get_peer_sec_addr (void);
  int num_peer_sec_addrs (void);
  
  int set_local_addr (ACE_Addr *local_addr);
  ACE_Addr *get_local_addr (void);
  char *get_local_addr_str (void);
  int set_local_control_addr (ACE_Addr *local_control_addr);
  ACE_Addr *get_local_control_addr (void);
  char *get_local_control_addr_str (void);

  TAO_AV_Transport *transport (void);
  void transport (TAO_AV_Transport *transport);
  TAO_AV_Transport *control_transport (void);
  void control_transport (TAO_AV_Transport *control_transport);

  TAO_AV_Flow_Handler* handler (void);
  void handler (TAO_AV_Flow_Handler *handler);
  TAO_AV_Flow_Handler* control_handler (void);
  void control_handler (TAO_AV_Flow_Handler *control_handler);

  TAO_AV_Protocol_Object* protocol_object (void);
  void protocol_object (TAO_AV_Protocol_Object *object);
  TAO_AV_Protocol_Object* control_protocol_object (void);
  void control_protocol_object (TAO_AV_Protocol_Object *object);

  /// sets the address for this flow.
  int parse_address (const char *format_string,
                     TAO_AV_Core::Flow_Component flow_component);

  /// returns true for a multicast address.
  int is_multicast (void);

protected:

  /// parses the flow protocol string with tokens separated by :
  int parse_flow_protocol_string (const char *flow_options_string);

  /// sets the direction flag.
  int set_direction (const char *direction_string);

  /// sets the protocol_ enum from the carrier_protocol_ string.
  int set_protocol (void);

  /// Addr information for the carrier protocol.
  ACE_Addr *address_;
  int clean_up_address_;         // added to clean up a memory leak
  ACE_Addr *control_address_;
  int clean_up_control_address_; // added to clean up a memory leak

  /// Fwd Addr in string format i.e hostname:port.
  ACE_CString address_str_;

  /// Peer Addr in string format i.e hostname:port.
  ACE_CString peer_address_str_;

  /// format string.
  ACE_CString format_;

  /// Direction of this flow.
  Direction direction_;

  /// string representation of the direction.
  ACE_CString direction_str_;

  /// name of this flow.
  ACE_CString flowname_;

  /// name of the protocol used.
  TAO_AV_Core::Protocol protocol_;

  /// carrier protocol string.
  ACE_CString carrier_protocol_;

  /// flow protocol string.
  ACE_CString flow_protocol_;

  int use_flow_protocol_;

  /// The flowspec entry;
  ACE_CString entry_;

  int is_multicast_;
  ACE_Addr *peer_addr_;
  char** local_sec_addr_;
  int num_local_sec_addrs_;
  char** peer_sec_addr_;
  int num_peer_sec_addrs_;
  ACE_Addr *peer_control_addr_;
  ACE_Addr *local_addr_;
  ACE_Addr *local_control_addr_;
  TAO_AV_Transport *transport_;
  TAO_AV_Transport *control_transport_;
  TAO_AV_Flow_Handler *handler_;
  TAO_AV_Flow_Handler *control_handler_;
  TAO_AV_Protocol_Object *protocol_object_;
  TAO_AV_Protocol_Object *control_protocol_object_;
  Role role_;
};


/**
 * @class TAO_Forward_FlowSpec_Entry
 * @brief
 */
class TAO_AV_Export TAO_Forward_FlowSpec_Entry
  :public TAO_FlowSpec_Entry
{
public:
  enum Position {TAO_AV_FLOWNAME = 0,
                 TAO_AV_DIRECTION = 1,
                 TAO_AV_FORMAT = 2,
                 TAO_AV_FLOW_PROTOCOL = 3,
                 TAO_AV_ADDRESS = 4,
		 TAO_AV_PEER_ADDR = 5};

  /// default constructor.
  TAO_Forward_FlowSpec_Entry (void);

  /// constructor to construct an entry from the arguments.
  TAO_Forward_FlowSpec_Entry (const char *flowname,
                              const char *direction,
                              const char *format_name,
                              const char *flow_protocol,
                              const char *carrier_protocol,
                              ACE_Addr *address,
                              ACE_Addr *control_address = 0);

  TAO_Forward_FlowSpec_Entry (const char *flowname,
                              const char *direction,
                              const char *format_name,
                              const char *flow_protocol,
                              const char *address);

  virtual ~TAO_Forward_FlowSpec_Entry (void);

  /// converts the entry to a string.
  virtual const char *entry_to_string (void);

  virtual Role role (void);

  /// construct the entry from a string specified by the flowSpec grammar.
  virtual int parse (const char* flowSpec_entry);
};

/**
 * @class TAO_Reverse_FlowSpec_Entry
 * @brief
 */
class TAO_AV_Export TAO_Reverse_FlowSpec_Entry
  :public TAO_FlowSpec_Entry
{
public:
  enum Position {TAO_AV_FLOWNAME = 0,
                 TAO_AV_ADDRESS = 1,
                 TAO_AV_FLOW_PROTOCOL = 2,
                 TAO_AV_DIRECTION = 3,
                 TAO_AV_FORMAT = 4};

  // default constructor.
  TAO_Reverse_FlowSpec_Entry (void);

  // constructor to construct an entry from the arguments.
  TAO_Reverse_FlowSpec_Entry (const char *flowname,
                              const char *direction,
                              const char *format_name,
                              const char *flow_protocol,
                              const char *carrier_protocol,
                              ACE_Addr *address,
                              ACE_Addr *control_address = 0);

  // Takes the address in protocol=endpoint form.
  TAO_Reverse_FlowSpec_Entry (const char *flowname,
                              const char *direction,
                              const char *format_name,
                              const char *flow_protocol,
                              const char *address);

  virtual ~TAO_Reverse_FlowSpec_Entry (void);

  /// converts the entry to a string.
  virtual const char *entry_to_string (void);

  virtual Role role (void);

  /// construct the entry from a string specified by the flowSpec grammar.
  virtual int parse (const char* flowSpec_entry);
};

#include "Transport.h"

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

#include /**/ "ace/post.h"
#endif /* TAO_AV_FLOWSPEC_ENTRY_H */