po_hi_transport.c 1.33 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 * This is a part of PolyORB-HI-C distribution, a minimal
 * middleware written for generated code from AADL models.
 * You should use it with the Ocarina toolsuite.
 *
 * For more informations, please visit http://ocarina.enst.fr
 *
 * Copyright (C) 2007-2008, GET-Telecom Paris.
 */

#include <po_hi_config.h>
#include <po_hi_types.h>
#include <po_hi_debug.h>
#include <po_hi_transport.h>
15
#include <po_hi_transport_sockets.h>
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <po_hi_giop.h>
#include <po_hi_messages.h>
#include <po_hi_returns.h>

#include <deployment.h>
#include <activity.h>
#include <request.h>

/*
 * The following arrays are declared in the generated header
 * deployment.h.
 */

extern __po_hi_node_t 
entity_table[__PO_HI_NB_ENTITIES];

void __po_hi_initialize_transport ()
{
#if __PO_HI_NB_NODES > 1
35
  __po_hi_sockets_initialize ();
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#endif
}

int __po_hi_transport_send (__po_hi_entity_t from,
			    __po_hi_entity_t to,
			    __po_hi_msg_t* msg)
{
  if (entity_table[from] == entity_table[to])
    {
#ifdef __PO_HI_DEBUG
      __DEBUGMSG (" ... deliver locally ... \n");
#endif
      __po_hi_main_deliver(msg);
      return __PO_HI_SUCCESS;
    }
51
#if __PO_HI_NB_NODES > 1
52
53
54
55
56
  else
    {      
#ifdef __PO_HI_USE_GIOP
      return __po_hi_giop_send (from, to, msg); 
#else
57
      return __po_hi_sockets_send (from, to, msg); 
58
59
#endif
    }
60
61
#endif
  return __PO_HI_UNAVAILABLE;
62
}