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