Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[Messaging]
[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                                  size_t size);
22 gras_error_t gras_trp_chunk_recv(gras_socket_t *sd,
23                                  char *data,
24                                  size_t size);
25
26 /* Find which socket needs to be read next */
27 gras_error_t 
28 gras_trp_select(double timeout,
29                 gras_socket_t **dst);
30
31
32 /***
33  *** Module declaration 
34  ***/
35 gras_error_t gras_trp_init(void);
36 void         gras_trp_exit(void);
37
38 /***
39  *** Plugin mecanism 
40  ***/
41
42 /* A plugin type */
43 typedef struct gras_trp_plugin_ gras_trp_plugin_t;
44
45
46 /**
47  * e_gras_trp_plugin:
48  * 
49  * Caracterize each possible transport plugin
50  */
51 typedef enum e_gras_trp_plugin {
52    e_gras_trp_plugin_undefined = 0,
53      
54      e_gras_trp_plugin_tcp
55 } gras_trp_plugin_type_t;
56
57 /* A plugin type */
58 struct gras_trp_plugin_ {
59   char          *name;
60  
61   /* dst pointers are created and initialized with default values 
62      before call to socket_client/server*/
63   gras_error_t (*socket_client)(gras_trp_plugin_t *self,
64                                 const char *host,
65                                 unsigned short port,
66                                 /* OUT */ gras_socket_t *dst);
67   gras_error_t (*socket_server)(gras_trp_plugin_t *self,
68                                 unsigned short port,
69                                 /* OUT */ gras_socket_t *dst);
70    
71   gras_error_t (*socket_accept)(gras_socket_t  *sock,
72                                 /* OUT */gras_socket_t **dst);
73    
74    
75    /* socket_close() is responsible of telling the OS that the socket is over,
76     but should not free the socket itself (beside the specific part) */
77   void         (*socket_close)(gras_socket_t *sd);
78     
79   gras_error_t (*chunk_send)(gras_socket_t *sd,
80                              char *data,
81                              size_t size);
82   gras_error_t (*chunk_recv)(gras_socket_t *sd,
83                              char *Data,
84                              size_t size);
85
86   void          *specific;
87   void         (*free_specific)(void *);
88 };
89
90 gras_error_t
91 gras_trp_plugin_get_by_name(const char *name,
92                             gras_trp_plugin_t **dst);
93
94 #endif /* GRAS_TRP_INTERFACE_H */