Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
249db653939179e8415b46b5507a446c75aff052
[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 void gras_trp_chunk_send(gras_socket_t sd,
19                          char *data,
20                          long int size);
21 void gras_trp_chunk_recv(gras_socket_t sd,
22                          char *data,
23                          long int size);
24 void gras_trp_flush(gras_socket_t sd);
25
26 /* Find which socket needs to be read next */
27 gras_socket_t gras_trp_select(double timeout);
28
29
30 /***
31  *** Plugin mechanism 
32  ***/
33
34 /* A plugin type */
35 typedef struct gras_trp_plugin_ s_gras_trp_plugin_t, *gras_trp_plugin_t;
36
37 /* A plugin type */
38 struct gras_trp_plugin_ {
39   char          *name;
40  
41   /* dst pointers are created and initialized with default values
42      before call to socket_client/server. 
43      Retrive the info you need from there. */
44   void (*socket_client)(gras_trp_plugin_t self,
45                         gras_socket_t    dst);
46   void (*socket_server)(gras_trp_plugin_t self,
47                         gras_socket_t    dst);
48    
49   gras_socket_t (*socket_accept)(gras_socket_t  from);
50    
51    
52    /* socket_close() is responsible of telling the OS that the socket is over,
53     but should not free the socket itself (beside the specific part) */
54   void (*socket_close)(gras_socket_t sd);
55     
56   void (*chunk_send)(gras_socket_t sd,
57                      const char *data,
58                      unsigned long int size);
59   void (*chunk_recv)(gras_socket_t sd,
60                      char *data,
61                      unsigned long int size,
62                      unsigned long int bufsize);
63
64   /* flush has to make sure that the pending communications are achieved */
65   void (*flush)(gras_socket_t sd);
66
67   void *data; /* plugin-specific data */
68  
69    /* exit is responsible for freeing data and telling the OS this plugin goes */
70    /* exit=NULL, data gets freed. (ie exit function needed only when data contains pointers) */
71   void (*exit)(gras_trp_plugin_t);
72 };
73
74 gras_trp_plugin_t
75 gras_trp_plugin_get_by_name(const char *name);
76
77 /* Data of this module specific to each process
78  * (used by sg_process.c to cleanup the SG channel cruft)
79  */
80 typedef struct {
81    /* SG only elements. In RL, they are part of the OS ;) */
82    int chan;    /* Formated messages channel */
83    int measChan; /* Unformated echange channel for performance measurement*/
84    xbt_dynar_t sockets; /* all sockets known to this process */
85    
86 } s_gras_trp_procdata_t,*gras_trp_procdata_t;
87
88 #endif /* GRAS_TRP_INTERFACE_H */