1 /*
2  *   LASH
3  *
4  *   Copyright (C) 2002, 2003 Robert Ham <rah@bash.sh>
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation; either version 2 of the License, or
9  *   (at your option) any later version.
10  *
11  *   This program is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with this program; if not, write to the Free Software
18  *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef __LASH_COMM_EVENT_H__
22 #define __LASH_COMM_EVENT_H__
23 
24 #include <uuid/uuid.h>
25 
26 #include <lash/loader.h>
27 #include <lash/internal_headers.h>
28 
29 /*
30  * Comm protocol versioning
31  *
32  * If the low-level protocol versions of client and
33  * server don't match, the socket is immediately closed.
34  *
35  * Protocol versions:
36  *
37  * 0.4.0:   2
38  * < 0.4.0: 1 (implied by LASH_Comm_Event_Connect,
39  *             which the protocol field replaces)
40  */
41 
42 #define LASH_COMM_PROTOCOL_VERSION 2
43 
44 
45 enum LASH_Comm_Event_Type
46 {
47   LASH_Comm_Event_Connect = 1,
48   LASH_Comm_Event_Iface_Connect,
49   LASH_Comm_Event_Event,
50   LASH_Comm_Event_Config,
51   LASH_Comm_Event_Exec,
52   LASH_Comm_Event_Ping,
53   LASH_Comm_Event_Pong,
54   LASH_Comm_Event_Close,
55   LASH_Comm_Event_Protocol_Mismatch
56 };
57 
58 struct _lash_comm_event
59 {
60   enum LASH_Comm_Event_Type type;
61   union
62   {
63     lash_connect_params_t *connect;
64     lash_event_t          *event;
65     lash_config_t         *config;
66     lash_exec_params_t    *exec;
67     char                 *string;
68     long                  number;
69   } event_data;
70 };
71 
72 
73 void lash_comm_event_init (lash_comm_event_t * event);
74 void lash_comm_event_free (lash_comm_event_t * event);
75 
76 lash_comm_event_t * lash_comm_event_new ();
77 void               lash_comm_event_destroy (lash_comm_event_t * event);
78 
79 void lash_comm_event_set_type              (lash_comm_event_t *, enum LASH_Comm_Event_Type);
80 void lash_comm_event_set_connect           (lash_comm_event_t *, lash_connect_params_t *);
81 void lash_comm_event_set_event             (lash_comm_event_t *, lash_event_t *);
82 void lash_comm_event_set_config            (lash_comm_event_t *, lash_config_t *);
83 void lash_comm_event_set_protocol_mismatch (lash_comm_event_t *, lash_protocol_t);
84 void lash_comm_event_set_exec              (lash_comm_event_t *, lash_exec_params_t *);
85 
86 enum LASH_Comm_Event_Type  lash_comm_event_get_type (lash_comm_event_t *);
87 
88 lash_connect_params_t * lash_comm_event_take_connect (lash_comm_event_t * event);
89 lash_event_t *          lash_comm_event_take_event   (lash_comm_event_t * event);
90 lash_config_t *         lash_comm_event_take_config  (lash_comm_event_t * event);
91 lash_exec_params_t *    lash_comm_event_take_exec    (lash_comm_event_t * event);
92 
93 #endif /* __LASH_COMM_EVENT_H__ */
94