iPXE
iphone.h
Go to the documentation of this file.
1#ifndef _IPHONE_H
2#define _IPHONE_H
3
4/** @file
5 *
6 * iPhone USB Ethernet driver
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <ipxe/usb.h>
15#include <ipxe/usbnet.h>
16#include <ipxe/process.h>
17#include <ipxe/timer.h>
18#include <ipxe/retry.h>
19#include <ipxe/tcp.h>
20#include <ipxe/x509.h>
21#include <ipxe/privkey.h>
22
23/******************************************************************************
24 *
25 * iPhone pairing certificates
26 *
27 ******************************************************************************
28 */
29
30/** An iPhone pairing certificate set */
31struct icert {
32 /** "Private" key */
34 /** Root certificate */
36 /** Host certificate */
38 /** Device certificate */
40};
41
42/******************************************************************************
43 *
44 * iPhone USB multiplexer
45 *
46 ******************************************************************************
47 */
48
49/** An iPhone USB multiplexed packet header */
51 /** Protocol */
53 /** Length (including this header) */
55 /** Reserved */
57 /** Output sequence number */
59 /** Input sequence number */
61} __attribute__ (( packed ));
62
63/** iPhone USB multiplexer protocols */
65 /** Version number */
67 /** Log message */
69 /** TCP packet */
71};
72
73/** An iPhone USB multiplexed version message header */
75 /** Multiplexed packet header */
77 /** Reserved */
79} __attribute__ (( packed ));
80
81/** An iPhone USB multiplexed log message header */
83 /** Multiplexed packet header */
85 /** Log level */
87 /** Message */
88 char msg[0];
89} __attribute__ (( packed ));
90
91/** An iPhone USB multiplexed pseudo-TCP message header */
93 /** Multiplexed packet header */
95 /** Pseudo-TCP header */
97} __attribute__ (( packed ));
98
99/** Local port number
100 *
101 * This is a policy decision.
102 */
103#define IMUX_PORT_LOCAL 0x18ae
104
105/** Lockdown daemon port number */
106#define IMUX_PORT_LOCKDOWND 62078
107
108/** Advertised TCP window
109 *
110 * This is a policy decision.
111 */
112#define IMUX_WINDOW 0x0200
113
114/** An iPhone USB multiplexer */
115struct imux {
116 /** Reference counter */
118 /** USB device */
120 /** USB bus */
121 struct usb_bus *bus;
122 /** USB network device */
124 /** List of USB multiplexers */
126
127 /** Polling process */
129 /** Pending action
130 *
131 * @v imux USB multiplexer
132 * @ret rc Return status code
133 */
134 int ( * action ) ( struct imux *imux );
135
136 /** Input sequence */
138 /** Output sequence */
140 /** Pseudo-TCP sequence number */
142 /** Pseudo-TCP acknowledgement number */
144 /** Pseudo-TCP local port number */
146
147 /** Pseudo-TCP lockdown socket interface */
149 /** Pairing flags */
150 unsigned int flags;
151 /** Pairing status */
152 int rc;
153};
154
155/** Multiplexer bulk IN maximum fill level
156 *
157 * This is a policy decision.
158 */
159#define IMUX_IN_MAX_FILL 1
160
161/** Multiplexer bulk IN buffer size
162 *
163 * This is a policy decision.
164 */
165#define IMUX_IN_MTU 4096
166
167/******************************************************************************
168 *
169 * iPhone pairing client
170 *
171 ******************************************************************************
172 */
173
174/** An iPhone USB multiplexed pseudo-TCP XML message header */
176 /** Message length */
178 /** Message */
179 char msg[0];
180} __attribute__ (( packed ));
181
182/** An iPhone pairing client */
183struct ipair {
184 /** Reference counter */
186 /** Data transfer interface */
188
189 /** Pairing timer */
191 /** Transmit message
192 *
193 * @v ipair Pairing client
194 * @ret rc Return status code
195 */
196 int ( * tx ) ( struct ipair *ipair );
197 /** Receive message
198 *
199 * @v ipair Pairing client
200 * @v msg XML message
201 * @ret rc Return status code
202 */
203 int ( * rx ) ( struct ipair *ipair, char *msg );
204 /** State flags */
205 unsigned int flags;
206
207 /** Pairing certificates */
208 struct icert icert;
209};
210
211/** Pairing client state flags */
213 /** Request a new pairing */
215 /** Standalone length has been received */
216 IPAIR_RX_LEN = 0x0002,
217 /** TLS session has been started */
218 IPAIR_TLS = 0x0004,
219};
220
221/** Pairing retry delay
222 *
223 * This is a policy decision.
224 */
225#define IPAIR_RETRY_DELAY ( 1 * TICKS_PER_SEC )
226
227/******************************************************************************
228 *
229 * iPhone USB networking
230 *
231 ******************************************************************************
232 */
233
234/** Get MAC address */
235#define IPHONE_GET_MAC \
236 ( USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE | \
237 USB_REQUEST_TYPE ( 0x00 ) )
238
239/** Get link status */
240#define IPHONE_GET_LINK \
241 ( USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE | \
242 USB_REQUEST_TYPE ( 0x45 ) )
243
244/** An iPhone link status */
246 /** Personal Hotspot is disabled */
248 /** Link up */
250 /** Link not yet determined */
252};
253
254/** An iPhone network device */
255struct iphone {
256 /** USB device */
258 /** USB bus */
259 struct usb_bus *bus;
260 /** Network device */
262 /** USB network device */
264
265 /** List of iPhone network devices */
267 /** Link status check timer */
269};
270
271/** Bulk IN padding */
272#define IPHONE_IN_PAD 2
273
274/** Bulk IN buffer size
275 *
276 * This is a policy decision.
277 */
278#define IPHONE_IN_MTU ( ETH_FRAME_LEN + IPHONE_IN_PAD )
279
280/** Bulk IN maximum fill level
281 *
282 * This is a policy decision.
283 */
284#define IPHONE_IN_MAX_FILL 8
285
286/** Link check interval
287 *
288 * This is a policy decision.
289 */
290#define IPHONE_LINK_CHECK_INTERVAL ( 5 * TICKS_PER_SEC )
291
292#endif /* _IPHONE_H */
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define IP_TCP
Definition in.h:14
#define __attribute__(x)
Definition compiler.h:10
iPXE timers
Universal Serial Bus (USB)
ipair_flags
Pairing client state flags.
Definition iphone.h:212
@ IPAIR_TLS
TLS session has been started.
Definition iphone.h:218
@ IPAIR_RX_LEN
Standalone length has been received.
Definition iphone.h:216
@ IPAIR_REQUEST
Request a new pairing.
Definition iphone.h:214
iphone_link_status
An iPhone link status.
Definition iphone.h:245
@ IPHONE_LINK_UNKNOWN
Link not yet determined.
Definition iphone.h:251
@ IPHONE_LINK_UP
Link up.
Definition iphone.h:249
@ IPHONE_LINK_DISABLED
Personal Hotspot is disabled.
Definition iphone.h:247
imux_protocol
iPhone USB multiplexer protocols
Definition iphone.h:64
@ IMUX_LOG
Log message.
Definition iphone.h:68
@ IMUX_TCP
TCP packet.
Definition iphone.h:70
@ IMUX_VERSION
Version number.
Definition iphone.h:66
void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition message.c:62
Private key.
Processes.
Retry timers.
An iPhone pairing certificate set.
Definition iphone.h:31
struct x509_certificate * device
Device certificate.
Definition iphone.h:39
struct private_key * key
"Private" key
Definition iphone.h:33
struct x509_certificate * host
Host certificate.
Definition iphone.h:37
struct x509_certificate * root
Root certificate.
Definition iphone.h:35
An iPhone USB multiplexed log message header.
Definition iphone.h:82
struct imux_header hdr
Multiplexed packet header.
Definition iphone.h:84
uint8_t level
Log level.
Definition iphone.h:86
char msg[0]
Message.
Definition iphone.h:88
An iPhone USB multiplexed pseudo-TCP message header.
Definition iphone.h:92
struct imux_header hdr
Multiplexed packet header.
Definition iphone.h:94
struct tcp_header tcp
Pseudo-TCP header.
Definition iphone.h:96
An iPhone USB multiplexed version message header.
Definition iphone.h:74
struct imux_header hdr
Multiplexed packet header.
Definition iphone.h:76
uint32_t reserved
Reserved.
Definition iphone.h:78
An iPhone USB multiplexed packet header.
Definition iphone.h:50
uint32_t reserved
Reserved.
Definition iphone.h:56
uint32_t len
Length (including this header)
Definition iphone.h:54
uint32_t protocol
Protocol.
Definition iphone.h:52
uint16_t in_seq
Input sequence number.
Definition iphone.h:60
uint16_t out_seq
Output sequence number.
Definition iphone.h:58
An iPhone USB multiplexer.
Definition iphone.h:115
struct process process
Polling process.
Definition iphone.h:128
uint16_t in_seq
Input sequence.
Definition iphone.h:137
uint16_t out_seq
Output sequence.
Definition iphone.h:139
struct usbnet_device usbnet
USB network device.
Definition iphone.h:123
uint16_t port
Pseudo-TCP local port number.
Definition iphone.h:145
int(* action)(struct imux *imux)
Pending action.
Definition iphone.h:134
struct refcnt refcnt
Reference counter.
Definition iphone.h:117
struct usb_bus * bus
USB bus.
Definition iphone.h:121
int rc
Pairing status.
Definition iphone.h:152
struct usb_device * usb
USB device.
Definition iphone.h:119
struct list_head list
List of USB multiplexers.
Definition iphone.h:125
uint32_t tcp_ack
Pseudo-TCP acknowledgement number.
Definition iphone.h:143
struct interface tcp
Pseudo-TCP lockdown socket interface.
Definition iphone.h:148
uint32_t tcp_seq
Pseudo-TCP sequence number.
Definition iphone.h:141
unsigned int flags
Pairing flags.
Definition iphone.h:150
An object interface.
Definition interface.h:125
An iPhone USB multiplexed pseudo-TCP XML message header.
Definition iphone.h:175
uint32_t len
Message length.
Definition iphone.h:177
char msg[0]
Message.
Definition iphone.h:179
An iPhone pairing client.
Definition iphone.h:183
struct interface xfer
Data transfer interface.
Definition iphone.h:187
struct retry_timer timer
Pairing timer.
Definition iphone.h:190
unsigned int flags
State flags.
Definition iphone.h:205
int(* tx)(struct ipair *ipair)
Transmit message.
Definition iphone.h:196
struct refcnt refcnt
Reference counter.
Definition iphone.h:185
int(* rx)(struct ipair *ipair, char *msg)
Receive message.
Definition iphone.h:203
struct icert icert
Pairing certificates.
Definition iphone.h:208
An iPhone network device.
Definition iphone.h:255
struct usb_device * usb
USB device.
Definition iphone.h:257
struct net_device * netdev
Network device.
Definition iphone.h:261
struct list_head list
List of iPhone network devices.
Definition iphone.h:266
struct retry_timer timer
Link status check timer.
Definition iphone.h:268
struct usb_bus * bus
USB bus.
Definition iphone.h:259
struct usbnet_device usbnet
USB network device.
Definition iphone.h:263
A doubly-linked list entry (or list head)
Definition list.h:19
A network device.
Definition netdevice.h:353
A private key.
Definition privkey.h:17
A retry timer.
Definition retry.h:22
A TCP header.
Definition tcp.h:20
A USB bus.
Definition usb.h:966
A USB device.
Definition usb.h:723
A USB network device.
Definition usbnet.h:16
An X.509 certificate.
Definition x509.h:216
TCP protocol.
USB network devices.
X.509 certificates.