Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Here come the proper GRAS RPC
[simgrid.git] / src / gras / Msg / msg_private.h
1 /* $Id$ */
2
3 /* messaging - high level communication (send/receive messages)             */
4
5 /* module's private interface masked even to other parts of GRAS.           */
6
7 /* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved.            */
8
9 /* This program is free software; you can redistribute it and/or modify it
10  * under the terms of the license (GNU LGPL) which comes with this package. */
11
12 #ifndef GRAS_MESSAGE_PRIVATE_H
13 #define GRAS_MESSAGE_PRIVATE_H
14
15 #include "gras_config.h"
16
17 #include "xbt/sysdep.h"
18 #include "xbt/log.h"
19 #include "xbt/dynar.h"
20 #include "xbt/set.h"
21 #include "gras/transport.h"
22 #include "gras/datadesc.h"
23 #include "gras/virtu.h"
24
25 #include "gras/messages.h"
26 #include "gras/timer.h"
27 #include "gras_modinter.h"
28
29 #include "gras/Msg/msg_interface.h"
30
31 extern char _GRAS_header[6];
32
33 extern int gras_msg_libdata_id; /* The identifier of our libdata */
34  
35 typedef enum {
36   e_gras_msg_kind_unknown = 0,
37   e_gras_msg_kind_oneway  = 1
38   /* future:
39        method call (answer expected; sessionID attached)
40        successful return (usual datatype attached, with sessionID)
41        error return (payload = exception)
42        [+ call cancel, and others]
43      even after: 
44        forwarding request and other application level routing stuff
45        group communication
46   */
47   
48 } e_gras_msg_kind_t;
49  
50 /** @brief Message instance */
51 typedef struct {
52     gras_socket_t   expe;
53   e_gras_msg_kind_t kind;
54     gras_msgtype_t  type;
55     void           *payl;
56     int             payl_size;
57 } s_gras_msg_t, *gras_msg_t;
58
59 /**
60  * gras_msgtype_t:
61  *
62  * Message type descriptor. There one of these for each registered version.
63  */
64 typedef struct s_gras_msgtype {
65   /* headers for the data set */
66   unsigned int   code;
67   char          *name;
68   unsigned int   name_len;
69         
70   /* payload */
71   short int version;
72   gras_datadesc_type_t ctn_type;
73 } s_gras_msgtype_t;
74
75 extern xbt_set_t _gras_msgtype_set; /* of gras_msgtype_t */
76 void gras_msgtype_free(void *msgtype);
77
78
79 /* functions to extract msg from socket or put it on wire (depend RL vs SG) */
80 void gras_msg_recv(gras_socket_t   sock,
81                    gras_msg_t      msg/*OUT*/);
82 void gras_msg_send_ext(gras_socket_t   sock,
83                      e_gras_msg_kind_t kind,
84                        gras_msgtype_t  msgtype,
85                        void           *payload);
86
87 /**
88  * gras_cblist_t:
89  *
90  * association between msg ID and cb list for a given process
91  */
92 struct s_gras_cblist {
93   long int id;
94   xbt_dynar_t cbs; /* of gras_msg_cb_t */
95 };
96
97 typedef struct s_gras_cblist gras_cblist_t;
98 void gras_cbl_free(void *); /* used to free the memory at the end */
99 void gras_cblist_free(void *cbl);
100
101
102 /* ********* *
103  * * TIMER * *
104  * ********* */
105 typedef struct {
106   double expiry;
107   double period;
108   void_f_void_t action;
109   int repeat;
110 } s_gras_timer_t, *gras_timer_t;
111
112 /* returns 0 if it handled a timer, or the delay until next timer, or -1 if no armed timer */
113 double gras_msg_timer_handle(void);
114
115
116 #endif  /* GRAS_MESSAGE_PRIVATE_H */