a5726db7ab7d1970a4a3bb081e98fa441c4098e7
[udpgate.git] / src / packet.h
1 /* $Id$
2  * Include file for the packet assembly and disassembly layer
3  * Copyright (C) 2004 Jan Kratochvil <project-udpgate@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #ifndef _UDPGATE_PACKET_H
21 #define _UDPGATE_PACKET_H 1
22
23
24 #include <glib/gtypes.h>
25 #include <glib/ghash.h>
26
27
28 G_BEGIN_DECLS
29
30 #define PACKET_HEADER "UDPGate0"
31
32 #define PACKET_ELEM_ATTR_MANDATORY (0x80000000)
33 #define PACKET_ELEM_ATTR_OPTIONAL  (0x00000000)
34 enum packet_elem_type {
35         PACKET_ELEM_TYPE_PROGRAM_VERSION=(0x01|PACKET_ELEM_ATTR_MANDATORY),     /* 'VERSION' string */
36         PACKET_ELEM_TYPE_CLIENT_INADDR  =(0x02|PACKET_ELEM_ATTR_MANDATORY),     /* host order */
37         PACKET_ELEM_TYPE_CLIENT_PORT    =(0x03|PACKET_ELEM_ATTR_MANDATORY),     /* host order */
38         PACKET_ELEM_TYPE_DATA_GUINT32   =(0x04|PACKET_ELEM_ATTR_MANDATORY),     /* user data (e.g. unique id) */
39         };
40
41 gpointer packet_assembly(size_t *packet_length_pointer,GHashTable *values);
42 GHashTable *packet_disassembly(gconstpointer packet,size_t packet_length);
43 void packet_disassembly_destroy(GHashTable *hash);
44
45 G_END_DECLS
46
47
48 #endif /* _UDPGATE_PACKET_H */