Debian Codegraph @

src/afc.h

raw
1 /*
2 * afc.h
3 * Defines and structs and the like for the built-in AFC client
4 *
5 * Copyright (c) 2014 Martin Szulecki All Rights Reserved.
6 * Copyright (c) 2008 Zach C. All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #ifndef __AFC_H
24 #define __AFC_H
25
26 #include <stdint.h>
27
28 #include "libimobiledevice/afc.h"
29 #include "service.h"
30 #include "endianness.h"
31 #include <libimobiledevice-glue/thread.h>
32
33 #define AFC_MAGIC "CFA6LPAA"
34 #define AFC_MAGIC_LEN (8)
35
36 typedef struct {
37 char magic[AFC_MAGIC_LEN];
38 uint64_t entire_length, this_length, packet_num, operation;
39 } AFCPacket;
40
41 #define AFCPacket_to_LE(x) \
42 (x)->entire_length = htole64((x)->entire_length); \
43 (x)->this_length = htole64((x)->this_length); \
44 (x)->packet_num = htole64((x)->packet_num); \
45 (x)->operation = htole64((x)->operation);
46
47 #define AFCPacket_from_LE(x) \
48 (x)->entire_length = le64toh((x)->entire_length); \
49 (x)->this_length = le64toh((x)->this_length); \
50 (x)->packet_num = le64toh((x)->packet_num); \
51 (x)->operation = le64toh((x)->operation);
52
53 struct afc_client_private {
54 service_client_t parent;
55 AFCPacket *afc_packet;
56 uint32_t packet_extra;
57 mutex_t mutex;
58 int free_parent;
59 };
60
61 /* AFC Operations */
62 enum {
63 AFC_OP_INVALID = 0x00000000, /* Invalid */
64 AFC_OP_STATUS = 0x00000001, /* Status */
65 AFC_OP_DATA = 0x00000002, /* Data */
66 AFC_OP_READ_DIR = 0x00000003, /* ReadDir */
67 AFC_OP_READ_FILE = 0x00000004, /* ReadFile */
68 AFC_OP_WRITE_FILE = 0x00000005, /* WriteFile */
69 AFC_OP_WRITE_PART = 0x00000006, /* WritePart */
70 AFC_OP_TRUNCATE = 0x00000007, /* TruncateFile */
71 AFC_OP_REMOVE_PATH = 0x00000008, /* RemovePath */
72 AFC_OP_MAKE_DIR = 0x00000009, /* MakeDir */
73 AFC_OP_GET_FILE_INFO = 0x0000000A, /* GetFileInfo */
74 AFC_OP_GET_DEVINFO = 0x0000000B, /* GetDeviceInfo */
75 AFC_OP_WRITE_FILE_ATOM = 0x0000000C, /* WriteFileAtomic (tmp file+rename) */
76 AFC_OP_FILE_OPEN = 0x0000000D, /* FileRefOpen */
77 AFC_OP_FILE_OPEN_RES = 0x0000000E, /* FileRefOpenResult */
78 AFC_OP_FILE_READ = 0x0000000F, /* FileRefRead */
79 AFC_OP_FILE_WRITE = 0x00000010, /* FileRefWrite */
80 AFC_OP_FILE_SEEK = 0x00000011, /* FileRefSeek */
81 AFC_OP_FILE_TELL = 0x00000012, /* FileRefTell */
82 AFC_OP_FILE_TELL_RES = 0x00000013, /* FileRefTellResult */
83 AFC_OP_FILE_CLOSE = 0x00000014, /* FileRefClose */
84 AFC_OP_FILE_SET_SIZE = 0x00000015, /* FileRefSetFileSize (ftruncate) */
85 AFC_OP_GET_CON_INFO = 0x00000016, /* GetConnectionInfo */
86 AFC_OP_SET_CON_OPTIONS = 0x00000017, /* SetConnectionOptions */
87 AFC_OP_RENAME_PATH = 0x00000018, /* RenamePath */
88 AFC_OP_SET_FS_BS = 0x00000019, /* SetFSBlockSize (0x800000) */
89 AFC_OP_SET_SOCKET_BS = 0x0000001A, /* SetSocketBlockSize (0x800000) */
90 AFC_OP_FILE_LOCK = 0x0000001B, /* FileRefLock */
91 AFC_OP_MAKE_LINK = 0x0000001C, /* MakeLink */
92 AFC_OP_GET_FILE_HASH = 0x0000001D, /* GetFileHash */
93 AFC_OP_SET_FILE_MOD_TIME = 0x0000001E, /* SetModTime */
94 AFC_OP_GET_FILE_HASH_RANGE = 0x0000001F, /* GetFileHashWithRange */
95 /* iOS 6+ */
96 AFC_OP_FILE_SET_IMMUTABLE_HINT = 0x00000020, /* FileRefSetImmutableHint */
97 AFC_OP_GET_SIZE_OF_PATH_CONTENTS = 0x00000021, /* GetSizeOfPathContents */
98 AFC_OP_REMOVE_PATH_AND_CONTENTS = 0x00000022, /* RemovePathAndContents */
99 AFC_OP_DIR_OPEN = 0x00000023, /* DirectoryEnumeratorRefOpen */
100 AFC_OP_DIR_OPEN_RESULT = 0x00000024, /* DirectoryEnumeratorRefOpenResult */
101 AFC_OP_DIR_READ = 0x00000025, /* DirectoryEnumeratorRefRead */
102 AFC_OP_DIR_CLOSE = 0x00000026, /* DirectoryEnumeratorRefClose */
103 /* iOS 7+ */
104 AFC_OP_FILE_READ_OFFSET = 0x00000027, /* FileRefReadWithOffset */
105 AFC_OP_FILE_WRITE_OFFSET = 0x00000028 /* FileRefWriteWithOffset */
106 };
107
108 afc_error_t afc_client_new_with_service_client(service_client_t service_client, afc_client_t *client);
109
110 #endif