1 /*
2 ** Copyright (C) 2006 Olivier DEMBOUR
3 ** $Id: packet.h,v 1.9.4.1 2010/01/06 12:50:40 dembour Exp $
4 **
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20 
21 #ifndef __PACKET_H__
22 #define __PACKET_H__
23 
24 #ifndef _WIN32
25 #include <netdb.h>
26 #include <netinet/in.h>
27 #include <sys/time.h>
28 #include <sys/types.h>
29 #else
30 #include "mywin32.h"
31 #endif
32 
33 #include "list.h"
34 #include "memdump.h"
35 
36 /* type */
37 
38 
39 
40 
41 /* end type */
42 
43 /*
44 Error MSG
45 */
46 #define MAX_ERROR_SIZE	64
47 
48 #define ERR_RESOURCE		"Resource Unknown"
49 #define ERR_CONN_REFUSED	"Connexion refused"
50 #define ERR_AUTH_FAILED		"Authentication Failed"
51 #define ERR_BAD_SEQ		"Bad seq number"
52 
53 
54 #undef MIN
55 #define MIN(a,b)	((a) > (b) ? (b) : (a))
56 
57 #define	PACKET_LEN	(sizeof(t_packet))
58 
59 #define MAX_SEQ 0xffff
60 
61 typedef struct		s_trace {
62   uint16_t		max_packet_size;
63   uint16_t		session_reply_size;
64   uint16_t		data_reply_size;
65   uint8_t		enable_multi_reply;
66   uint16_t		len_request;
67   uint8_t		request_type;
68 #define	SEND_ONCE	0
69 #define	SEND_FRAG	1
70 } __attribute__((packed)) t_trace;
71 
72 
73 typedef struct		s_packet {
74   uint16_t		session_id;
75   uint16_t		ack_seq;
76   uint16_t		seq;
77   uint8_t		type;
78 #define OK		0x0
79 #define DESAUTH		0x1
80 #define ERR		0x2
81 #define	NOP		0x4
82 #define CHECK_MTU	0x6
83 
84 #define DATA		(1 << 3)
85 #define ACK		(1 << 4)
86 #define NACK		(1 << 5)
87 #define USE_COMPRESS	(1 << 6)
88 } __attribute__((packed)) t_packet;
89 
90 /* DATA goes  after */
91 
92 typedef struct		s_data {
93   char			*buffer;
94   int			len;
95 }			t_data;
96 
97 #endif
98