Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
87680456589cebd7a53eadd35b2afdadcbdfe1e3
[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 xbt_error_t gras_trp_chunk_send(gras_socket_t sd,
19                                  char *data,
20                                  long int size);
21 xbt_error_t gras_trp_chunk_recv(gras_socket_t sd,
22                                  char *data,
23                                  long int size);
24 xbt_error_t gras_trp_flush(gras_socket_t sd);
25
26 /* Find which socket needs to be read next */
27 xbt_error_t 
28 gras_trp_select(double timeout,
29                 gras_socket_t *dst);
30
31
32 /***
33  *** Plugin mecanism 
34  ***/
35
36 /* A plugin type */
37 typedef struct gras_trp_plugin_ gras_trp_plugin_t;
38
39 /* A plugin type */
40 struct gras_trp_plugin_ {
41   char          *name;
42  
43   /* dst pointers are created and initialized with default values
44      before call to socket_client/server. 
45      Retrive the info you need from there. */
46   xbt_error_t (*socket_client)(gras_trp_plugin_t *self,
47                                 gras_socket_t      dst);
48   xbt_error_t (*socket_server)(gras_trp_plugin_t *self,
49                                 gras_socket_t      dst);
50    
51   xbt_error_t (*socket_accept)(gras_socket_t  sock,
52                                 gras_socket_t *dst);
53    
54    
55    /* socket_close() is responsible of telling the OS that the socket is over,
56     but should not free the socket itself (beside the specific part) */
57   void         (*socket_close)(gras_socket_t sd);
58     
59   xbt_error_t (*chunk_send)(gras_socket_t sd,
60                              const char *data,
61                              long int size);
62   xbt_error_t (*chunk_recv)(gras_socket_t sd,
63                              char *data,
64                              long int size);
65
66   /* flush has to make sure that the pending communications are achieved */
67   xbt_error_t (*flush)(gras_socket_t sd);
68
69   void          *data; /* plugin-specific data */
70  
71    /* exit is responsible for freeing data and telling the OS this plugin goes */
72    /* exit=NULL, data gets freed. (ie exit function needed only when data contains pointers) */
73   void         (*exit)(gras_trp_plugin_t *);
74 };
75
76 xbt_error_t
77 gras_trp_plugin_get_by_name(const char *name,
78                             gras_trp_plugin_t **dst);
79
80 #endif /* GRAS_TRP_INTERFACE_H */