3 * Copyright (C) 2014 John Crispin <blogic@openwrt.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
20 struct mbim_message_header
{
23 uint32_t transaction_id
;
24 } __attribute__((packed
));
26 struct mbim_open_message
{
27 struct mbim_message_header header
;
28 uint32_t max_control_transfer
;
29 } __attribute__((packed
));
31 struct mbim_open_done_message
{
32 struct mbim_message_header header
;
34 } __attribute__((packed
));
36 struct mbim_close_done_message
{
38 } __attribute__((packed
));
40 struct mbim_error_message
{
41 uint32_t error_status_code
;
42 } __attribute__((packed
));
44 struct mbim_fragment_header
{
47 } __attribute__((packed
));
49 struct fragment_message
{
50 struct mbim_fragment_header fragment_header
;
52 } __attribute__((packed
));
54 struct command_message
{
55 struct mbim_message_header header
;
56 struct mbim_fragment_header fragment_header
;
57 uint8_t service_id
[16];
59 uint32_t command_type
;
60 uint32_t buffer_length
;
62 } __attribute__((packed
));
64 struct command_done_message
{
65 struct mbim_fragment_header fragment_header
;
66 uint8_t service_id
[16];
69 uint32_t buffer_length
;
71 } __attribute__((packed
));
73 struct indicate_status_message
{
74 struct mbim_fragment_header fragment_header
;
75 uint8_t service_id
[16];
77 uint32_t buffer_length
;
79 } __attribute__((packed
));
81 typedef int (*_mbim_cmd_request
)(void);
82 typedef int (*_mbim_cmd_response
)(void *buffer
, int len
);
84 extern uint8_t basic_connect
[16];
85 extern int transaction_id
;
87 const char* mbim_enum_string(struct mbim_enum
*e
, uint32_t key
);
88 char* mbim_get_string(struct mbim_string
*str
, char *in
);
89 void mbim_setup_header(struct mbim_message_header
*hdr
, MbimMessageType type
, int length
);
90 uint8_t* mbim_setup_command_msg(uint8_t *uuid
, uint32_t type
, uint32_t command_id
, int len
);
91 int mbim_send_open_msg(void);
92 int mbim_send_close_msg(void);
93 int mbim_send_command_msg(void);
94 int mbim_add_payload(uint8_t len
);
95 int mbim_encode_string(struct mbim_string
*str
, char *in
);
96 void mbim_get_ipv4(void *buffer
, char *out
, uint32_t offset
);