Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
5766ffda9fc69f0bc1e3f66c19bc120c08da93f7
[simgrid.git] / src / gras / Transport / transport_interface.h
1 /* $Id$ */
2
3 /* transport - low level communication (send/receive bunches of bytes)      */
4
5 /* module's public interface exported within GRAS, but not to end user.     */
6
7 /* Copyright (c) 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_TRP_INTERFACE_H
13 #define GRAS_TRP_INTERFACE_H
14
15 /***
16  *** Main user functions
17  ***/
18 /* stable if we know the storage will keep as is until the next trp_flush */
19 void gras_trp_send(gras_socket_t sd, char *data, long int size, int stable);
20 void gras_trp_recv(gras_socket_t sd, char *data, long int size);
21 void gras_trp_flush(gras_socket_t sd);
22
23 /* Find which socket needs to be read next */
24 gras_socket_t gras_trp_select(double timeout);
25
26
27 /***
28  *** Plugin mechanism 
29  ***/
30
31 /* A plugin type */
32 typedef struct gras_trp_plugin_ s_gras_trp_plugin_t, *gras_trp_plugin_t;
33
34 /* A plugin type */
35 struct gras_trp_plugin_ {
36   char          *name;
37  
38   /* dst pointers are created and initialized with default values
39      before call to socket_client/server. 
40      Retrive the info you need from there. */
41   void (*socket_client)(gras_trp_plugin_t self,
42                         gras_socket_t    dst);
43   void (*socket_server)(gras_trp_plugin_t self,
44                         gras_socket_t    dst);
45    
46   gras_socket_t (*socket_accept)(gras_socket_t  from);
47    
48    
49    /* socket_close() is responsible of telling the OS that the socket is over,
50     but should not free the socket itself (beside the specific part) */
51   void (*socket_close)(gras_socket_t sd);
52     
53   /* send/recv may be buffered */
54   void (*send)(gras_socket_t sd,
55                const char *data,
56                unsigned long int size,
57                int stable /* storage will survive until flush*/);
58   int (*recv)(gras_socket_t sd,
59               char *data,
60               unsigned long int size);
61   /* raw_send/raw_recv is never buffered (use it for measurement stuff) */
62   void (*raw_send)(gras_socket_t sd,
63                    const char *data,
64                    unsigned long int size);
65   int (*raw_recv)(gras_socket_t sd,
66                   char *data,
67                   unsigned long int size);
68
69   /* flush has to make sure that the pending communications are achieved */
70   void (*flush)(gras_socket_t sd);
71
72   void *data; /* plugin-specific data */
73  
74    /* exit is responsible for freeing data and telling the OS this plugin goes */
75    /* exit=NULL, data gets freed. (ie exit function needed only when data contains pointers) */
76   void (*exit)(gras_trp_plugin_t);
77 };
78
79 gras_trp_plugin_t
80 gras_trp_plugin_get_by_name(const char *name);
81
82 /* Data of this module specific to each process
83  * (used by sg_process.c to cleanup the SG channel cruft)
84  */
85 typedef struct {
86    /* SG only elements. In RL, they are part of the OS ;) */
87    int chan;    /* Formated messages channel */
88    int measChan; /* Unformated echange channel for performance measurement*/
89    xbt_dynar_t sockets; /* all sockets known to this process */
90    
91 } s_gras_trp_procdata_t,*gras_trp_procdata_t;
92
93 #endif /* GRAS_TRP_INTERFACE_H */