Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix (c) dates
[simgrid.git] / src / gras / RL / gras_rl.h
1 /* $Id$ */
2
3 /* gras_rl.h - private interface for GRAS when on real life                 */
4
5 /* Copyright (c) 2004 Martin Quinson. All rights reserved.                  */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 #ifndef GRAS_RL_H
11 #define GRAS_RL_H
12
13 #ifdef GRAS_SG_H
14 #error Impossible to load gras_sg.h and gras_rl.h at the same time
15 #endif
16
17 #include "gras_private.h"
18 //#include "diagnostic.h"
19
20 BEGIN_DECL
21
22 /****************************************************************************/
23 /****************************************************************************/
24 /* Openning/Maintaining/Closing connexions                                  */
25 /****************************************************************************/
26 /****************************************************************************/
27
28 /* Declaration of the socket type */
29 #define PEER_NAME_LEN 200
30 struct gras_sock_s {
31   int sock;
32   int port;         /* port on this side */
33   char peer_name[PEER_NAME_LEN];  /* buffer to use PeerName_r */
34   char *peer_addr;
35 };
36
37 struct gras_rawsock_s {
38    int sock;
39    int port;
40 };
41
42 /****************************************************************************/
43 /****************************************************************************/
44 /* Format convertion stuff (copied verbatim from formatutil.h because I need*/
45 /*            to put datadescriptor in gras.h and the functions only in RL) */
46 /****************************************************************************/
47 /****************************************************************************/
48
49 void ConvertData(void *destination,
50                  const void *source,
51                  const DataDescriptor *description,
52                  size_t length,
53                  FormatTypes sourceFormat);
54
55
56 int DifferentFormat(DataTypes whatType);
57 int DifferentOrder(void);
58 int DifferentSize(DataTypes whatType);
59 void HomogenousConvertData(void *destination,
60                            const void *source,
61                            DataTypes whatType,
62                            size_t repetitions,
63                            FormatTypes sourceFormat);
64 size_t HomogenousDataSize(DataTypes whatType,
65                           size_t repetitions,
66                           FormatTypes format);
67 void ReverseData(void *destination,
68                  const void *source,
69                  DataTypes whatType,
70                  int repetitions,
71                  FormatTypes format);
72
73
74 /****************************************************************************/
75 /****************************************************************************/
76 /* Messaging stuff (reimplementation of message.h)                          */
77 /****************************************************************************/
78 /****************************************************************************/
79 /**
80  * gras_msg_discard:
81  * @sd: Socket on which this message arrives
82  * @size: Size of the message to discard.
83  *
84  * Discard data on the socket because of failure on our side (out of mem or msg
85  * type unknown). 
86  */
87 void
88 gras_msg_discard(gras_sock_t *sd, size_t size);
89
90 /**
91  * grasRecvData:
92  * @sd: Socket to listen on
93  * @data: Where to store the data (allocated by this function)
94  * @description: What data to expect.
95  * @Returns: the number of bytes read for that.
96  *
97  * Receive data from the network on a buffer allocated by this function for that
98  */
99 int
100 grasDataRecv( gras_sock_t *sd,
101               void **data,
102               const DataDescriptor *description,
103               size_t description_length,
104               unsigned int repetition);
105
106 /**
107  * grasRecvData:
108  * @sd: Socket to write on
109  * @data: What to send
110  * @description: Format of the data
111  * @Returns: the number of bytes written
112  *
113  * Send a sequence of data across the network
114  */
115 xbt_error_t
116 grasDataSend(gras_sock_t *sd,
117              const void *data,
118              const DataDescriptor *description,
119              size_t description_length,
120              int repetition);
121
122 END_DECL
123
124 #endif /* GRAS_SG_H */