Logo AND Algorithmique Numérique Distribuée

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