Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Initial revision
[simgrid.git] / src / gras / SG / gras_sg.h
1 /* $Id$ */
2
3 /* gras_sg.h - private interface for GRAS when using the simulator          */
4
5 /* Authors: Martin Quinson                                                  */
6 /* Copyright (C) 2003 the OURAGAN project.                                  */
7
8 /* This program is free software; you can redistribute it and/or modify it
9    under the terms of the license (GNU LGPL) which comes with this package. */
10
11 #ifndef GRAS_SG_H
12 #define GRAS_SG_H
13
14 #ifdef GRAS_RL_H
15 #error Impossible to load gras_sg.h and gras_rl.h at the same time
16 #endif
17
18 #include "gras_private.h"
19 #include <msg.h>
20
21 BEGIN_DECL
22
23 /* Declaration of the socket type */
24 struct gras_sock_s {
25   int server_sock; /* boolean */
26   int raw_sock;    /* boolean. If true, socket for raw send/recv. 
27                                If false. socket for formated messages */
28
29   int from_PID;    /* process which sent this message */
30   int to_PID;      /* process to which this message is destinated */
31
32   m_host_t to_host;   /* Who's on other side */
33   int to_port;        /* port on which the server is earing */
34   m_channel_t to_chan;/* Channel on which the other side is earing */
35 };
36 struct gras_rawsock_s {
37   int server_sock; /* boolean */
38   int raw_sock;    /* boolean. If true, socket for raw send/recv. 
39                                If false. socket for formated messages */
40
41   int from_PID;    /* process which sent this message */
42   int to_PID;      /* process to which this message is destinated */
43
44   m_host_t to_host;   /* Who's on other side */
45   int to_port;        /* port on which the server is earing */
46   m_channel_t to_chan;/* Channel on which the other side is earing */
47 };
48
49 /* Data for each host */
50 typedef struct {
51   int proc[MAX_CHANNEL]; /* who's connected to each channel (its PID). If =0, then free */
52
53   int portLen;
54   int *port;             /* list of ports used by a server socket */
55   int *port2chan;        /* the channel it points to */
56   int *raw;              /* (boolean) the channel is in raw mode or for formatted messages */
57
58 } gras_hostdata_t;
59
60 /* prototype of private functions */
61 /**
62  * _gras_sock_server_open:
63  *
64  * Open a server socket either in raw or regular mode, depending on the @raw argument.
65  * In SG, bufSize is ignored.
66  */
67 gras_error_t
68 _gras_sock_server_open(unsigned short startingPort, unsigned short endingPort,
69                       int raw, unsigned int bufSize, /* OUT */ gras_sock_t **sock);
70
71 /**
72  * _gras_sock_client_open:
73  *
74  * Open a client socket either in raw or regular mode, depending on the @raw argument.
75  * In SG, bufSize is ignored.
76  */
77 gras_error_t
78 _gras_sock_client_open(const char *host, short port, int raw, unsigned int bufSize,
79                       /* OUT */ gras_sock_t **sock);
80
81
82 /**
83  * _gras_sock_close:
84  *
85  * Close a socket which were opened either in raw or regular mode, depending on the
86  * @raw argument.
87  */
88 gras_error_t _gras_sock_close(int raw, gras_sock_t *sd);
89
90
91 END_DECL
92
93 #endif /* GRAS_SG_H */