1 /*
2  * Copyright (C) 1998,1999  Ross Combs (rocombs@cs.nmsu.edu)
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
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 #ifndef INCLUDED_FILE_PROTOCOL_TYPES
19 #define INCLUDED_FILE_PROTOCOL_TYPES
20 
21 #ifdef JUST_NEED_TYPES
22 # include "common/bn_type.h"
23 #else
24 # define JUST_NEED_TYPES
25 # include "common/bn_type.h"
26 # undef JUST_NEED_TYPES
27 #endif
28 
29 
30 /******************************************************/
31 typedef struct
32 {
33     bn_short size;
34     bn_short type;
35 } PACKED_ATTR() t_file_header;
36 /******************************************************/
37 
38 
39 /******************************************************/
40 typedef struct
41 {
42     t_file_header h;
43 } PACKED_ATTR() t_file_generic;
44 /******************************************************/
45 
46 
47 /******************************************************/
48 /*
49 CLIENT FILE MPQ REQ
50                           2D 00 00 01 36 38 58 49            -...68XI
51 50 58 45 53 00 00 00 00   00 00 00 00 00 00 00 00    PXES............
52 00 2C 58 E1 09 28 BC 01   49 58 38 36 76 65 72 31    .,X..(..IX86ver1
53 2E 6D 70 71 00                                       .mpq.
54 
55 CLIENT FILE TOS REQ
56                           28 00 00 01 36 38 58 49            (...68XI
57 50 58 45 53 00 00 00 00   00 00 00 00 00 00 00 00    PXES............
58 30 C3 89 86 09 4F BD 01   74 6F 73 2E 74 78 74 00    0....O..tos.txt.
59 
60 CLIENT FILE AD REQ
61                           2D 00 00 01 36 38 58 49            -...68XI
62 50 58 45 53 2B 51 02 00   2E 70 63 78 00 00 00 00    PXES+Q...pcx....
63 00 00 00 00 58 01 B2 00   61 64 30 32 35 31 32 62    ....X...ad02512b
64 2E 70 63 78 00                                       .pcx.
65 */
66 #define CLIENT_FILE_REQ 0x0100
67 typedef struct
68 {
69     t_file_header h;
70     bn_int        archtag;
71     bn_int        clienttag;
72     bn_int        adid;
73     bn_int        extensiontag; /* unlike other tags, this one is "forward" */
74     bn_int        startoffset; /* is this actually used in the original clients? */
75     bn_long       timestamp;
76     /* filename */
77 } PACKED_ATTR() t_client_file_req;
78 /******************************************************/
79 
80 /*
81 the next 2 file requests appeared on w3 first. first it sends filereq2 then
82 server replies with some rnadom int then client sends filereq3 (which is a
83 raw packet with no valuable header) then filename then server replies with
84 normal file_reply and sends the contents
85 
86 12: recv class=file[0x03] type=unknown[0x0200] length=20
87 0000:   14 00 00 02 36 38 58 49   33 52 41 57 00 00 00 00    ....68XI3RAW....
88 0010:   00 00 00 00                                          ....
89 */
90 #define CLIENT_FILE_REQ2		0x0200
91 typedef struct
92 {
93     t_file_header h;
94     bn_int        archtag;
95     bn_int        clienttag;
96     bn_long       unknown1;
97 } PACKED_ATTR() t_client_file_req2;
98 
99 #define CLIENT_FILE_REQ3		0x0000
100 typedef struct
101 {
102     bn_int	unknown1;
103     bn_long	timestamp;
104     bn_long	unknown2;
105     bn_long	unknown3;
106     bn_long	unknown4;
107     bn_long	unknown5;
108     bn_long	unknown6;
109     /* filename */
110 } PACKED_ATTR() t_client_file_req3;
111 
112 /******************************************************/
113 /* SERVER FILE MPQ REPLY
114                           25 00 00 00 33 1B 00 00            %...3...
115 00 00 00 00 00 00 00 00   00 2C 58 E1 09 28 BC 01    .........,X..(..
116 49 58 38 36 76 65 72 31   2E 6D 70 71 00             IX86ver1.mpq.
117 
118 SERVER FILE TOS REPLY
119                           20 00 00 00 E4 00 00 00    P."..... .......
120 00 00 00 00 00 00 00 00   30 C3 89 86 09 4F BD 01    ........0....O..
121 74 6F 73 2E 74 78 74 00                              tos.txt.
122 
123 SERVER FILE AD REPLY
124                           25 00 00 00 30 2E 00 00            %...0...
125 2B 51 02 00 2E 70 63 78   00 00 00 00 58 01 B2 00    +Q...pcx....X...
126 61 64 30 32 35 31 32 62   2E 70 63 78 00             ad02512b.pcx.
127 */
128 #define SERVER_FILE_REPLY 0x0000
129 typedef struct
130 {
131     t_file_header h;
132     bn_int        filelen;
133     bn_int        adid;
134     bn_int        extensiontag; /* unlike other tags, this one is "forward" */
135     bn_long       timestamp;
136     /* filename */
137 } PACKED_ATTR() t_server_file_reply;
138 /******************************************************/
139 
140 #define SERVER_FILE_UNKNOWN1 0xdeadbeef
141 typedef struct
142 {
143     bn_int	unknown;
144 } PACKED_ATTR() t_server_file_unknown1;
145 
146 #endif
147