52#define EPIPE_NO_MUX __einfo_error ( EINFO_EPIPE_NO_MUX )
53#define EINFO_EPIPE_NO_MUX \
54 __einfo_uniqify ( EINFO_EPIPE, 0x01, \
55 "No USB multiplexer" )
56#define EINPROGRESS_PAIRING __einfo_error ( EINFO_EINPROGRESS_PAIRING )
57#define EINFO_EINPROGRESS_PAIRING \
58 __einfo_uniqify ( EINFO_EINPROGRESS, 0x01, \
59 "Pairing in progress" )
60#define ENOTCONN_DISABLED __einfo_error ( EINFO_ENOTCONN_DISABLED )
61#define EINFO_ENOTCONN_DISABLED \
62 __einfo_uniqify ( EINFO_ENOTCONN, IPHONE_LINK_DISABLED, \
63 "Personal Hotspot disabled" )
64#define ENOTCONN_STATUS( status ) \
65 EUNIQ ( EINFO_ENOTCONN, ( (status) & 0x1f ), \
72 { .name =
"iphone.in" };
76 { .name =
"iphone.out" };
192 '1',
'9',
'7',
'8',
'1',
'2',
'1',
'0',
193 '2',
'2',
'0',
'0',
'0',
'0',
'Z' ),
196 '2',
'9',
'9',
'9',
'0',
'1',
'0',
'1',
197 '0',
'0',
'0',
'0',
'0',
'0',
'Z' ) )
230 'i',
'P',
'h',
'o',
'n',
'e' ) ) ) )
239 0x02, 0x81, 0x81, 0x00, 0xc9, 0xc0, 0xdd, 0xa6, 0xd5, 0xf9, 0x05, 0x3e,
240 0x1d, 0xcb, 0x67, 0x08, 0xa8, 0x50, 0x27, 0x63, 0x95, 0x87, 0x42, 0x7e,
241 0xfb, 0xff, 0x55, 0x55, 0xb8, 0xc0, 0x6f, 0x13, 0xcb, 0xf7, 0xc5, 0x1b,
242 0xda, 0x44, 0x3c, 0xbc, 0x1a, 0xe1, 0x15, 0x1e, 0xab, 0x56, 0x74, 0x02,
243 0x8b, 0xb3, 0xcd, 0x42, 0x56, 0xcd, 0x9c, 0xc3, 0x15, 0xe2, 0x33, 0x97,
244 0x6d, 0x77, 0xdd, 0x20, 0x3a, 0x74, 0xb1, 0x4c, 0xee, 0xeb, 0xe8, 0xaa,
245 0x20, 0x71, 0x5a, 0xa2, 0x5b, 0xf8, 0x1a, 0xcb, 0xd2, 0x7b, 0x96, 0xb6,
246 0x42, 0xb4, 0x7c, 0x7a, 0x13, 0xec, 0x55, 0xd3, 0x36, 0x8b, 0xe3, 0x17,
247 0xc5, 0xc4, 0xcc, 0xe0, 0x27, 0x8c, 0xed, 0xa1, 0x4c, 0x8a, 0x50, 0x4a,
248 0x1c, 0xc4, 0x58, 0xf6, 0xcd, 0xcc, 0xc3, 0x5f, 0xe6, 0x3c, 0xff, 0x97,
249 0x51, 0xed, 0xf5, 0xaa, 0x89, 0xcc, 0x3f, 0x63, 0x67, 0x46, 0x9f, 0xbf,
250 0x02, 0x03, 0x01, 0x00, 0x01
253 0x02, 0x81, 0x81, 0x00, 0xcd, 0x96, 0x81, 0x78, 0xbb, 0x2e, 0x64, 0xda,
254 0xd3, 0x7e, 0xd7, 0x3a, 0xac, 0x3f, 0x00, 0xe5, 0x41, 0x65, 0x56, 0xac,
255 0x2d, 0x77, 0xc0, 0x1a, 0xad, 0x32, 0xca, 0x0c, 0x72, 0xae, 0xdb, 0x57,
256 0xc1, 0xc7, 0x79, 0xef, 0xc6, 0x71, 0x9f, 0xad, 0x82, 0x14, 0x94, 0x4b,
257 0xf9, 0xd8, 0x78, 0xf1, 0xca, 0x99, 0xf5, 0x71, 0x07, 0x88, 0xd7, 0x55,
258 0xc7, 0xcb, 0x36, 0x5d, 0xdb, 0x84, 0x46, 0xac, 0x05, 0xea, 0xf1, 0xe1,
259 0xbe, 0x91, 0x50, 0x85, 0x1e, 0x64, 0xab, 0x02, 0x82, 0xab, 0xba, 0x42,
260 0x06, 0x5a, 0xe3, 0xc3, 0x25, 0xd0, 0x95, 0x04, 0x54, 0xb4, 0x44, 0x40,
261 0x5a, 0x42, 0x06, 0x04, 0x7d, 0x3b, 0x9e, 0xaf, 0x2e, 0xe9, 0xc8, 0xad,
262 0x46, 0x3a, 0xff, 0xe2, 0x39, 0xc8, 0x48, 0x0a, 0x49, 0xaa, 0xfe, 0x1f,
263 0x6c, 0x91, 0x5d, 0x1d, 0xd6, 0xb0, 0x04, 0xd1, 0x6c, 0xb2, 0x43, 0xaf,
264 0x02, 0x03, 0x01, 0x00, 0x01
284 0x02, 0x81, 0x80, 0x1d, 0x60, 0xb7, 0x25, 0xdf, 0x0c, 0x76, 0xc5, 0xf7,
285 0xc2, 0xb1, 0x8b, 0x22, 0x2f, 0x21, 0xbd, 0x2f, 0x7d, 0xd5, 0xa1, 0xf6,
286 0x01, 0xd5, 0x24, 0x39, 0x55, 0xd4, 0x16, 0xd6, 0xe1, 0x8a, 0x53, 0x26,
287 0xf2, 0x3e, 0xc1, 0xc9, 0x4c, 0x33, 0x2e, 0x17, 0x16, 0xec, 0xa7, 0x9e,
288 0x3e, 0x1d, 0x4a, 0x66, 0xa7, 0x64, 0x07, 0x48, 0x3d, 0x7a, 0xf3, 0xb6,
289 0xdd, 0xf8, 0x56, 0x04, 0x0d, 0x0f, 0xef, 0xf8, 0xbd, 0xbc, 0x73, 0xe2,
290 0xc2, 0xae, 0x1b, 0x87, 0x90, 0x18, 0x2a, 0x68, 0xff, 0xae, 0x49, 0xdf,
291 0x7c, 0xff, 0xe8, 0x44, 0xa8, 0x3e, 0x4e, 0x4f, 0xf5, 0xfa, 0x51, 0x96,
292 0xb8, 0x08, 0xf3, 0x18, 0xd6, 0x52, 0xdf, 0x3a, 0x8a, 0xed, 0xda, 0xcd,
293 0xb4, 0x06, 0x99, 0x41, 0xcb, 0x23, 0x17, 0xaf, 0xc3, 0x3e, 0xfe, 0xdf,
294 0x97, 0xf3, 0xd6, 0x18, 0x7e, 0x03, 0xaf, 0x62, 0xb2, 0xc8, 0xc9
297 0x02, 0x81, 0x80, 0x45, 0xbd, 0xc0, 0xbe, 0x0c, 0x01, 0x79, 0x05, 0x22,
298 0xa9, 0xec, 0xa9, 0x62, 0xb5, 0x1c, 0xc0, 0xa8, 0xa6, 0x8f, 0xf8, 0x68,
299 0x94, 0x2e, 0xfe, 0xdd, 0xb2, 0x55, 0x08, 0x53, 0xff, 0x2d, 0x39, 0x5f,
300 0xeb, 0x23, 0x5a, 0x4b, 0x9f, 0x4f, 0xe3, 0xb4, 0x34, 0xf6, 0xf9, 0xaf,
301 0x0f, 0xd8, 0x37, 0x6d, 0xdb, 0x3c, 0x7f, 0xd3, 0x66, 0x80, 0x66, 0x01,
302 0x18, 0xd6, 0xa0, 0x90, 0x4f, 0x17, 0x09, 0xb8, 0x68, 0x44, 0xf0, 0xde,
303 0x16, 0x4a, 0x8a, 0x0d, 0xa7, 0x5f, 0xb5, 0x4c, 0x53, 0xcc, 0x21, 0xdd,
304 0x4f, 0x05, 0x64, 0xa5, 0xc5, 0xac, 0x2c, 0xd8, 0x0a, 0x7b, 0xf5, 0xa4,
305 0x63, 0x32, 0xb0, 0x2c, 0xf8, 0xef, 0x8c, 0xf8, 0x2c, 0xba, 0x1c, 0x2c,
306 0xc7, 0x0a, 0xf3, 0xe9, 0x8f, 0xfb, 0x0a, 0x61, 0x1b, 0x3a, 0xdd, 0x9f,
307 0x74, 0x7d, 0xb3, 0x42, 0x59, 0x52, 0x07, 0x59, 0x8e, 0xb7, 0x41
315#define icert_key_suffix a
316#define icert_key_variable( prefix ) _C2 ( prefix, icert_key_suffix )
317#define icert_public icert_key_variable ( icert_public_ )
318#define icert_private icert_key_variable ( icert_private_ )
324static const char icert_end[] =
"\n-----END CERTIFICATE-----\n";
376 DBGC (
icert,
"ICERT %p could not build subjectPublicKeyInfo: "
391 DBGC (
icert,
"ICERT %p could not build tbsCertificate: %s\n",
402 if ( (
rc =
pubkey_sign ( pubkey,
private, digest, digest_out,
404 DBGC (
icert,
"ICERT %p could not sign: %s\n",
406 goto err_pubkey_sign;
417 DBGC (
icert,
"ICERT %p could not build certificate: %s\n",
424 DBGC (
icert,
"ICERT %p invalid certificate: %s\n",
474 DBGC (
icert,
"ICERT %p could not build private key: %s\n",
483 DBGC (
icert,
"ICERT %p could not build public key: %s\n",
533 size_t encencoded_len;
545 ( encoded_len - 1 ) +
560 DBGC2 (
icert,
"ICERT %p \"%s\" certificate:\n%s",
566 *encenc =
malloc ( encencoded_len );
569 goto err_alloc_encenc;
643 vers =
iob_put ( iobuf,
sizeof ( *vers ) );
646 memset ( vers, 0,
sizeof ( *vers ) );
675 tcp->tcp.
hlen = ( (
sizeof (
tcp->tcp ) / 4 ) << 4 );
703 syn =
iob_put ( iobuf,
sizeof ( *syn ) );
706 memset ( syn, 0,
sizeof ( *syn ) );
768 if (
len <
sizeof ( *log ) ) {
769 DBGC (
imux,
"IMUX %p malformed log message:\n",
imux );
779 msg_len = (
len -
sizeof ( *hdr ) );
815 if (
len <
sizeof ( *
tcp ) ) {
816 DBGC (
imux,
"IMUX %p malformed TCP message:\n",
imux );
823 DBGC (
imux,
"IMUX %p ignoring unexpected TCP port %d:\n",
879 DBGC (
imux,
"IMUX %p bulk IN failed: %s\n",
885 if (
len <
sizeof ( *
hdr ) ) {
897 switch (
hdr->protocol ) {
908 DBGC (
imux,
"IMUX %p unknown message type %d:\n",
936 DBGC (
imux,
"IMUX %p bulk OUT failed: %s\n",
1000 DBGC (
imux,
"IMUX %p retrying pairing: %s\n",
1130 DBGC (
imux,
"IMUX %p could not describe: %s\n",
1137 DBGC (
imux,
"IMUX %p could not open: %s\n",
1175 USB_ID ( 0x05ac, 0xffff,
"imux",
"iPhone (multiplexer)", 0 ),
1197 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1198 "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" "
1199 "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
1200 "<plist version=\"1.0\">\n"
1202 "<key>Label</key>\n"
1203 "<string>iPXE</string>\n"
1204 "<key>Request</key>\n";
1313 if ( (
msg[
len - 1 ] !=
'\0' ) && (
msg[
len - 1 ] !=
'\n' ) ) {
1361 DBGC (
ipair,
"IPAIR %p missing closing tag %s in:\n%s\n",
1414 "<string>GetValue</string>\n"
1416 "<string>DevicePublicKey</string>\n"
1444 DBGC (
ipair,
"IPAIR %p unexpected public key message:\n%s\n",
1452 decoded =
malloc ( max_len );
1460 DBGC (
ipair,
"IPAIR %p invalid outer public key:\n%s\n",
1469 DBGC (
ipair,
"IPAIR %p invalid inner public key:\n%s\n",
1534 "<string>Pair</string>\n"
1535 "<key>PairRecord</key>\n"
1537 "<key>RootCertificate</key>\n"
1539 "<key>HostCertificate</key>\n"
1541 "<key>DeviceCertificate</key>\n"
1543 "<key>SystemBUID</key>\n"
1544 "<string>%s</string>\n"
1545 "<key>HostID</key>\n"
1546 "<string>%s</string>\n"
1548 "<key>ProtocolVersion</key>\n"
1549 "<string>2</string>\n"
1550 "<key>PairingOptions</key>\n"
1552 "<key>ExtendedPairingErrors</key>\n"
1582 if (
strcmp (
error,
"PairingDialogResponsePending" ) != 0 ) {
1619 DBGC (
ipair,
"IPAIR %p unexpected pairing response:\n%s\n",
1645 "<string>StartSession</string>\n"
1646 "<key>SystemBUID</key>\n"
1647 "<string>%s</string>\n"
1648 "<key>HostID</key>\n"
1649 "<string>%s</string>\n"
1679 DBGC (
ipair,
"IPAIR %p unknown host: requesting pairing\n",
ipair );
1706 DBGC (
ipair,
"IPAIR %p unexpected session response:\n%s\n",
1711 DBGC (
ipair,
"IPAIR %p starting session \"%s\"\n",
ipair, session );
1716 DBGC (
ipair,
"IPAIR %p could not start TLS: %s\n",
1889 DBGC (
iphone,
"IPHONE %p bulk IN failed: %s\n",
1998 sizeof (
status ) ) ) != 0 ) {
1999 DBGC (
iphone,
"IPHONE %p could not get link status: %s\n",
2061 DBGC (
iphone,
"IPHONE %p could not open: %s\n",
2171 DBGC (
iphone,
"IPHONE %p could not describe: %s\n",
2179 DBGC (
iphone,
"IPHONE %p could not fetch MAC address: %s\n",
2225 USB_ROM ( 0x05ac, 0xffff,
"iphone",
"iPhone", 0 ),
#define NULL
NULL pointer (VOID *)
union @162305117151260234136356364136041353210355154177 key
Sense key.
struct golan_inbox_hdr hdr
Message header.
#define SHA256_DIGEST_SIZE
struct arbelprm_rc_send_wqe rc
struct arbelprm_completion_with_error error
int asn1_prepend(struct asn1_builder *builder, unsigned int type, const void *data, size_t len)
Prepend data to ASN.1 builder.
int asn1_prepend_raw(struct asn1_builder *builder, const void *data, size_t len)
Prepend raw data to ASN.1 builder.
int asn1_wrap(struct asn1_builder *builder, unsigned int type)
Wrap ASN.1 builder.
#define ASN1_INTEGER
ASN.1 integer.
#define ASN1_UTF8_STRING
ASN.1 UTF-8 string.
#define ASN1_BIT_STRING
ASN.1 bit string.
static struct asn1_cursor * asn1_built(struct asn1_builder *builder)
Get cursor for built object.
#define ASN1_EXPLICIT_TAG(number)
ASN.1 explicit tag.
#define ASN1_NULL
ASN.1 null.
#define ASN1_OID
ASN.1 object identifier.
#define ASN1_OID_COMMON_NAME
ASN.1 OID for commonName (2.5.4.3)
#define ASN1_BOOLEAN
ASN.1 boolean.
#define ASN1_CURSOR(value)
Define an ASN.1 cursor for a static value.
#define ASN1_OID_BASICCONSTRAINTS
ASN.1 OID for id-ce-basicConstraints (2.5.29.19)
#define ASN1_SEQUENCE
ASN.1 sequence.
#define ASN1_SHORT(tag,...)
Construct a short ASN.1 value.
#define ASN1_OID_KEYUSAGE
ASN.1 OID for id-ce-keyUsage (2.5.29.15)
#define ASN1_SET
ASN.1 set.
#define ASN1_OID_SHA256WITHRSAENCRYPTION
ASN.1 OID for sha256WithRSAEncryption (1.2.840.113549.1.1.11)
#define ASN1_GENERALIZED_TIME
ASN.1 generalized time.
#define ASN1_OID_RSAENCRYPTION
ASN.1 OID for rsaEncryption (1.2.840.113549.1.1.1)
#define ASN1_OCTET_STRING
ASN.1 octet string.
#define assert(condition)
Assert a condition at run-time.
size_t base64_encode(const void *raw, size_t raw_len, char *data, size_t len)
Base64-encode data.
int base64_decode(const char *encoded, void *data, size_t len)
Base64-decode string.
static size_t base64_decoded_max_len(const char *encoded)
Calculate maximum length of base64-decoded string.
static size_t base64_encoded_len(size_t raw_len)
Calculate length of base64-encoded data.
uint32_t next
Next descriptor address.
uint64_t tag
Identity tag.
uint32_t type
Operating system type.
uint8_t data[48]
Additional event data.
uint8_t meta
Metadata flags.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
static struct net_device * netdev
#define __unused
Declare a variable or data structure as unused.
uint32_t start
Starting offset.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define REQUIRE_OBJECT(object)
Require an object.
#define ENOENT
No such file or directory.
#define EINVAL
Invalid argument.
#define EPROTO
Protocol error.
#define EPIPE
Broken pipe.
#define ENOMEM
Not enough space.
#define ECANCELED
Operation canceled.
#define EPERM
Operation not permitted.
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
#define REQUIRING_SYMBOL(symbol)
Specify the file's requiring symbol.
static void digest_init(struct digest_algorithm *digest, void *ctx)
static void digest_final(struct digest_algorithm *digest, void *ctx, void *out)
static void digest_update(struct digest_algorithm *digest, void *ctx, const void *data, size_t len)
static int pubkey_sign(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, struct asn1_builder *signature)
#define __profiler
Declare a profiler.
static void profile_stop(struct profiler *profiler)
Stop profiling.
static void profile_start(struct profiler *profiler)
Start profiling.
Universal Serial Bus (USB)
#define __usb_driver
Declare a USB driver.
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
#define USB_ROM(_vendor, _product, _name, _description, _data)
#define USB_ID(_vendor, _product, _name, _description, _data)
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
@ USB_SCORE_NORMAL
Normal driver.
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
void * memset(void *dest, int character, size_t len) __nonnull
void * memmove(void *dest, const void *src, size_t len) __nonnull
void intf_close(struct interface *intf, int rc)
Close an object interface.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
#define iob_push(iobuf, len)
#define iob_put(iobuf, len)
#define iob_disown(iobuf)
Disown an I/O buffer.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define iob_reserve(iobuf, len)
#define iob_pull(iobuf, len)
static struct usb_device_id iphone_ids[]
iPhone device IDs
static struct interface_operation ipair_xfer_operations[]
Pairing client interface operations.
static void imux_shutdown(struct imux *imux)
Shut down USB multiplexer.
static int imux_start_pair(struct imux *imux)
Open pairing client.
static struct io_buffer * imux_alloc_iob(struct imux *imux __unused, size_t len)
Allocate I/O buffer for pseudo-TCP socket.
static int ipair_tx_pair(struct ipair *ipair)
Transmit Pair message.
static int ipair_create(struct interface *xfer, unsigned int flags)
Create a pairing client.
static int ipair_tag(struct ipair *ipair, const char *msg, const char *tag, char **start, char **end)
Locate XML tag.
static const char ipair_suffix[]
Common suffix for all pairing messages.
static int ipair_rx_session_error(struct ipair *ipair, char *error)
Receive StartSession message error.
static int ipair_rx_pair_error(struct ipair *ipair, char *error)
Receive Pair message error.
static int ipair_tx_pubkey(struct ipair *ipair)
Transmit DevicePublicKey message.
static int ipair_key(struct ipair *ipair, const char *msg, const char *key, const char *type, char **start, char **end)
Locate XML property list dictionary value.
static const uint8_t icert_name_iphone_data[]
"iPhone" subject name
static const uint8_t icert_name_root_data[]
"Root" subject name
static int icert_cert(struct icert *icert, struct asn1_cursor *subject, struct asn1_cursor *issuer, struct asn1_cursor *private, struct asn1_cursor *public, struct asn1_cursor *exts, struct x509_certificate **cert)
Construct certificate.
static struct asn1_cursor icert_leaf_exts
Extensions used in constructed leaf certificates.
static void iphone_poll(struct net_device *netdev)
Poll for completed and received packets.
static void imux_rx_version(struct imux *imux)
Receive version message.
static int ipair_rx_pair(struct ipair *ipair, char *msg)
Receive Pair message.
static int icert_encode(struct icert *icert, struct x509_certificate *cert, char **encenc)
Construct doubly base64-encoded certificate.
static int iphone_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
static const uint8_t icert_sha256_rsa[]
"SHA-256 with RSA algorithm" identifier used in constructed certificates
static void ipair_close(struct ipair *ipair, int rc)
Shut down pairing client.
static struct usb_endpoint_driver_operations imux_out_operations
Bulk OUT endpoint operations.
static const uint8_t icert_name_ipxe_data[]
"iPXE" subject name
static uint8_t icert_root_fingerprint[SHA256_DIGEST_SIZE]
iPhone root certificate fingerprint
static void imux_remove(struct usb_function *func)
Remove device.
static const char icert_end[]
PEM certificate suffix.
static void imux_out_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk OUT transfer.
static const uint8_t icert_validity[]
Validity period in constructed certificates.
static void imux_rx_log(struct imux *imux, struct imux_header *hdr, size_t len)
Receive log message.
static int imux_tx_version(struct imux *imux)
Transmit version message.
static struct interface_operation imux_tcp_operations[]
Pseudo-TCP socket interface operations.
static int iphone_open(struct net_device *netdev)
Open network device.
static int ipair_tx(struct ipair *ipair, const char *fmt,...)
Transmit XML message.
static struct asn1_cursor icert_name_iphone
"iPhone" subject name
static struct usb_endpoint_driver_operations imux_in_operations
Bulk IN endpoint operations.
static int iphone_out_transmit(struct iphone *iphone, struct io_buffer *iobuf)
Transmit packet.
static const char ipair_host_id[]
Arbitrary host ID used for pairing.
static const uint8_t icert_tbs_prefix[]
"TBSCertificate" prefix in constructed certificates
static void ipair_free(struct refcnt *refcnt)
Free pairing client.
static int ipair_tx_session(struct ipair *ipair)
Transmit StartSession message.
static struct usb_endpoint_driver_operations iphone_out_operations
Bulk OUT endpoint operations.
static void iphone_remove(struct usb_function *func)
Remove device.
static const uint8_t icert_leaf_exts_data[]
Extensions used in constructed leaf certificates.
static const char icert_begin[]
PEM certificate prefix.
static void iphone_expired(struct retry_timer *timer, int over __unused)
Periodically update link status.
static struct asn1_cursor icert_name_root
"Root" subject name
static const char ipair_prefix[]
Common prefix for all pairing messages.
static void imux_in_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk IN transfer.
#define EINPROGRESS_PAIRING
static int ipair_rx(struct ipair *ipair, char *msg, size_t len)
Receive XML message payload.
static int ipair_rx_session(struct ipair *ipair, char *msg)
Receive StartSession message.
static void icert_free(struct icert *icert)
Free pairing certificates.
static const char ipair_system_buid[]
Arbitrary system BUID used for pairing.
static void iphone_in_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk IN transfer.
static struct interface_descriptor ipair_xfer_desc
Pairing client interface descriptor.
static int imux_tx_syn(struct imux *imux)
Transmit pseudo-TCP SYN.
static int ipair_rx_pubkey(struct ipair *ipair, char *msg)
Receive DevicePublicKey message.
static void iphone_out_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk OUT transfer.
static int icert_certs(struct icert *icert, struct asn1_cursor *key)
Construct certificates.
static struct interface_descriptor imux_tcp_desc
Pseudo-TCP socket interface descriptor.
static int ipair_deliver(struct ipair *ipair, struct io_buffer *iobuf, struct xfer_metadata *meta __unused)
Handle received data.
static const uint8_t icert_rsa[]
"RSA algorithm" identifier used in constructed certificates
static struct x509_root icert_root
Root of trust for iPhone certificates.
static const uint8_t icert_nul[]
Single zero byte used in constructed certificates.
static int iphone_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
static void imux_step(struct imux *imux)
Multiplexer process.
static void iphone_close(struct net_device *netdev)
Close network device.
static int imux_deliver(struct imux *imux, struct io_buffer *iobuf, struct xfer_metadata *meta __unused)
Transmit packet via pseudo-TCP socket.
static int imux_tx(struct imux *imux, struct io_buffer *iobuf)
Transmit message.
static void ipair_window_changed(struct ipair *ipair)
Handle window change notification.
static void imux_close(struct imux *imux, int rc)
Close USB multiplexer.
static struct asn1_cursor icert_root_exts
Extensions used in constructed root certificate.
static void imux_rx_syn(struct imux *imux)
Receive pseudo-TCP SYN+ACK.
static int imux_tx_tcp(struct imux *imux, struct io_buffer *iobuf)
Transmit pseudo-TCP message.
static struct net_device_operations iphone_operations
iPhone network device operations
#define ENOTCONN_STATUS(status)
static struct usb_endpoint_driver_operations iphone_in_operations
Bulk IN endpoint operations.
static int imux_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
static struct usb_device_id imux_ids[]
USB multiplexer device IDs.
static struct process_descriptor imux_process_desc
Multiplexer process descriptor.
static void iphone_check_link(struct net_device *netdev)
Check link status.
static int iphone_check_pair(struct iphone *iphone)
Check pairing status.
static const uint8_t icert_root_exts_data[]
Extensions used in constructed root certificate.
static void ipair_expired(struct retry_timer *timer, int over __unused)
Pairing transmission timer.
static struct asn1_cursor icert_name_ipxe
"iPXE" subject name
static void imux_rx_tcp(struct imux *imux, struct io_buffer *iobuf)
Receive pseudo-TCP message.
iPhone USB Ethernet driver
#define IMUX_IN_MAX_FILL
Multiplexer bulk IN maximum fill level.
#define IMUX_PORT_LOCAL
Local port number.
#define IMUX_IN_MTU
Multiplexer bulk IN buffer size.
#define IPHONE_IN_MTU
Bulk IN buffer size.
#define IPHONE_IN_PAD
Bulk IN padding.
#define IPHONE_LINK_CHECK_INTERVAL
Link check interval.
#define IMUX_WINDOW
Advertised TCP window.
@ IPAIR_TLS
TLS session has been started.
@ IPAIR_RX_LEN
Standalone length has been received.
@ IPAIR_REQUEST
Request a new pairing.
#define IMUX_PORT_LOCKDOWND
Lockdown daemon port number.
#define IPHONE_GET_MAC
Get MAC address.
#define IPHONE_GET_LINK
Get link status.
#define IPAIR_RETRY_DELAY
Pairing retry delay.
#define IPHONE_IN_MAX_FILL
Bulk IN maximum fill level.
@ IMUX_VERSION
Version number.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
#define list_del(list)
Delete an entry from a list.
#define LIST_HEAD(list)
Declare a static list head.
#define list_add(new, head)
Add a new entry to the head of a list.
void * zalloc(size_t size)
Allocate cleared memory.
void * malloc(size_t size)
Allocate memory.
void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
void netdev_link_err(struct net_device *netdev, int rc)
Mark network device as having a specific link state.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
int register_netdev(struct net_device *netdev)
Register network device.
Network device management.
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
uint32_t end
Ending offset.
int pem_asn1(const void *data, size_t len, size_t offset, struct asn1_cursor **cursor)
Extract ASN.1 object from PEM data.
static void privkey_init(struct private_key *key)
Initialise empty private key.
static void privkey_put(struct private_key *key)
Drop reference to private key.
void process_del(struct process *process)
Remove process from process list.
void process_add(struct process *process)
Add process to process list.
static void process_init(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process and add to process list.
static int process_running(struct process *process)
Check if process is running.
#define PROC_DESC(object_type, process, _step)
Define a process descriptor.
void ref_no_free(struct refcnt *refcnt __unused)
Do not free reference-counted object.
static void(* free)(struct refcnt *refcnt))
#define REF_INIT(free_fn)
Initialise a static reference counter.
#define ref_put(refcnt)
Drop reference to object.
#define ref_init(refcnt, free)
Initialise a reference counter.
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
void stop_timer(struct retry_timer *timer)
Stop timer.
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
struct pubkey_algorithm rsa_algorithm
RSA public-key algorithm.
RSA public-key cryptography.
struct digest_algorithm sha256_algorithm
SHA-256 algorithm.
#define SHA256_CTX_SIZE
SHA-256 context size.
#define va_start(ap, last)
__builtin_va_list va_list
#define container_of(ptr, type, field)
Get containing structure.
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
struct stp_switch root
Root switch.
char * strerror(int errno)
Retrieve string representation of error number.
int strcmp(const char *first, const char *second)
Compare strings.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
char * strstr(const char *haystack, const char *needle)
Find substring.
char * strcpy(char *dest, const char *src)
Copy string.
size_t strlen(const char *src)
Get length of string.
size_t len
Length of data.
const void * data
Start of data.
size_t len
Length of data.
A message digest algorithm.
size_t digestsize
Digest size.
An iPhone pairing certificate set.
struct x509_certificate * device
Device certificate.
struct private_key * key
"Private" key
struct x509_certificate * host
Host certificate.
struct x509_certificate * root
Root certificate.
An iPhone USB multiplexer.
struct process process
Polling process.
uint16_t in_seq
Input sequence.
uint16_t out_seq
Output sequence.
struct usbnet_device usbnet
USB network device.
uint16_t port
Pseudo-TCP local port number.
int(* action)(struct imux *imux)
Pending action.
struct refcnt refcnt
Reference counter.
struct usb_bus * bus
USB bus.
struct usb_device * usb
USB device.
struct list_head list
List of USB multiplexers.
uint32_t tcp_ack
Pseudo-TCP acknowledgement number.
struct interface tcp
Pseudo-TCP lockdown socket interface.
uint32_t tcp_seq
Pseudo-TCP sequence number.
unsigned int flags
Pairing flags.
An object interface descriptor.
An object interface operation.
void * data
Start of data.
An iPhone pairing client.
struct interface xfer
Data transfer interface.
struct retry_timer timer
Pairing timer.
unsigned int flags
State flags.
int(* tx)(struct ipair *ipair)
Transmit message.
struct refcnt refcnt
Reference counter.
int(* rx)(struct ipair *ipair, char *msg)
Receive message.
struct icert icert
Pairing certificates.
An iPhone network device.
struct usb_device * usb
USB device.
struct net_device * netdev
Network device.
struct list_head list
List of iPhone network devices.
struct retry_timer timer
Link status check timer.
struct usb_bus * bus
USB bus.
struct usbnet_device usbnet
USB network device.
Network device operations.
struct asn1_builder builder
ASN.1 object builder.
A data structure for storing profiling information.
A USB configuration descriptor.
struct usb_port * port
USB port.
USB endpoint driver operations.
int open
Endpoint is open.
struct usb_device * usb
USB device.
struct device dev
Generic device.
struct usb_bus * bus
USB bus.
struct usb_hub * hub
USB hub.
struct usb_endpoint out
Bulk OUT endpoint.
struct usb_endpoint in
Bulk IN endpoint.
struct asn1_cursor raw
Raw certificate.
An X.509 root certificate list.
int add_tls(struct interface *xfer, const char *name, struct x509_root *root, struct private_key *key)
Add TLS on an interface.
Transport Layer Security Protocol.
int usb_control(struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len)
Issue USB control transaction.
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
int usbnet_refill(struct usbnet_device *usbnet)
Refill USB network device bulk IN and interrupt endpoints.
int usbnet_open(struct usbnet_device *usbnet)
Open USB network device.
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
int usbnet_describe(struct usbnet_device *usbnet, struct usb_configuration_descriptor *config)
Describe USB network device interfaces.
static void usbnet_init(struct usbnet_device *usbnet, struct usb_function *func, struct usb_endpoint_driver_operations *intr, struct usb_endpoint_driver_operations *in, struct usb_endpoint_driver_operations *out)
Initialise USB network device.
int printf(const char *fmt,...)
Write a formatted string to the console.
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
Write a formatted string to a buffer.
int ssize_t const char * fmt
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
int x509_is_valid(struct x509_certificate *cert, struct x509_root *root)
Check if X.509 certificate is valid.
const char * x509_name(struct x509_certificate *cert)
Get X.509 certificate display name.
void x509_fingerprint(struct x509_certificate *cert, struct digest_algorithm *digest, void *fingerprint)
Calculate X.509 certificate fingerprint.
static void x509_put(struct x509_certificate *cert)
Drop reference to X.509 certificate.
size_t xfer_window(struct interface *intf)
Check flow control window.
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
struct io_buffer * xfer_alloc_iob(struct interface *intf, size_t len)
Allocate I/O buffer.
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
int xfer_deliver_iob(struct interface *intf, struct io_buffer *iobuf)
Deliver datagram as I/O buffer without metadata.
Data transfer interfaces.