-
Notifications
You must be signed in to change notification settings - Fork 3
/
ros_pack.hpp
130 lines (112 loc) · 3.71 KB
/
ros_pack.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* VxWorks ROS Firmware Toolkit
* (c) Copyright 2015 TJ <[email protected]>
* https://github.com/iam-TJ/ros_pack
*
* Understands the payload of firmware updates for many switches, routers and other devices
* that use VxWorks Realtime Operating System (ROS) firmware update files.
*
* The header signature of such files is the string "PACK" at offset 0x18 (24).
*
* Licensed on the terms of the GMU General Public License version 2
* contained in the file COPYRIGHT
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#if !defined __ROS_PACK_HPP__
#define __ROS_PACK_HPP__
struct _version {
unsigned major;
unsigned minor;
};
/* The following structures map directly onto the stored file data.
* All fields are the same size in memory as in storage.
*/
struct ros_header_version { // 8 bytes
char arc_magic[4];
char arc_index[4];
};
struct ros_header_signature { // 4 bytes
char signature[4];
};
struct ros_header_timestamp { // 8 bytes
unsigned char link_second;
unsigned char link_minute;
unsigned char link_hour;
unsigned char unknown0;
unsigned char link_day;
unsigned char link_month;
unsigned short link_year;
};
struct ros_header_checksum { // 8 bytes
unsigned int length;
unsigned int checksum;
};
struct ros_header_directory { // 4 bytes
unsigned int dir_entries_qty;
};
struct ros_header_extended { // 4 bytes
unsigned int length;
};
/* Directory Entries for payload files */
struct ros_dirent { // 32 bytes
char filename[16];
unsigned int offset; // offset 16
unsigned int length;
unsigned int unknown1;
unsigned int unknown2;
};
/* Primary header of the entire ROS ARChive PACK file */
struct ros_header_v1 { // 32 bytes
struct ros_header_version version;
struct ros_header_timestamp timestamp;
struct ros_header_checksum payload_checksum_v1;
struct ros_header_signature signature; // offset 24 (0x18)
unsigned int unknown3;
struct ros_header_directory directory;
unsigned int unknown4;
unsigned int unknown5;
unsigned int unknown6;
} __attribute__((packed));
struct ros_header_v2 { // 80 bytes
struct ros_header_version version;
struct ros_header_checksum header_checksum;
struct ros_header_checksum payload_checksum_v1;
struct ros_header_signature signature; // offset 24 (0x18)
unsigned int unknown7;
struct ros_header_directory directory;
unsigned int unknown8;
struct ros_header_timestamp timestamp;
struct ros_header_checksum payload_checksum_v2;
unsigned int unknown9;
unsigned int unknown10;
char firmware_version[16];
} __attribute__((packed));
/* Sub-header at start of payload file data
* identified by its link_arc magic signature prefix */
struct ros_arc_header {
struct ros_header_version version;
struct ros_header_timestamp timestamp;
unsigned int unknown1; // offset 16
unsigned int uncompressed_length; // may be 64-bit (unsigned long): see https://github.com/iam-TJ/ros_pack/issues/1
unsigned int unknown2;
unsigned int unknown3;
};
/* Simple structure to specify commonly found payload data types */
struct data_sig {
char magic[16];
unsigned int magic_length;
const char *title;
};
#endif