summaryrefslogtreecommitdiff
path: root/mbim-msg.h
diff options
context:
space:
mode:
Diffstat (limited to 'mbim-msg.h')
-rw-r--r--mbim-msg.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/mbim-msg.h b/mbim-msg.h
new file mode 100644
index 0000000..1f84031
--- /dev/null
+++ b/mbim-msg.h
@@ -0,0 +1,84 @@
+#ifndef _MBIM_MSG_H__
+#define _MBIM_MSG_H__
+
+#include <string.h>
+
+struct mbim_message_header {
+ uint32_t type;
+ uint32_t length;
+ uint32_t transaction_id;
+} __attribute__((packed));
+
+struct mbim_open_message {
+ struct mbim_message_header header;
+ uint32_t max_control_transfer;
+} __attribute__((packed));
+
+struct mbim_open_done_message {
+ struct mbim_message_header header;
+ uint32_t status_code;
+} __attribute__((packed));
+
+struct mbim_close_done_message {
+ uint32_t status_code;
+} __attribute__((packed));
+
+struct mbim_error_message {
+ uint32_t error_status_code;
+} __attribute__((packed));
+
+struct mbim_fragment_header {
+ uint32_t total;
+ uint32_t current;
+} __attribute__((packed));
+
+struct fragment_message {
+ struct mbim_fragment_header fragment_header;
+ uint8_t buffer[];
+} __attribute__((packed));
+
+struct command_message {
+ struct mbim_message_header header;
+ struct mbim_fragment_header fragment_header;
+ uint8_t service_id[16];
+ uint32_t command_id;
+ uint32_t command_type;
+ uint32_t buffer_length;
+ uint8_t buffer[];
+} __attribute__((packed));
+
+struct command_done_message {
+ struct mbim_fragment_header fragment_header;
+ uint8_t service_id[16];
+ uint32_t command_id;
+ uint32_t status_code;
+ uint32_t buffer_length;
+ uint8_t buffer[];
+} __attribute__((packed));
+
+struct indicate_status_message {
+ struct mbim_fragment_header fragment_header;
+ uint8_t service_id[16];
+ uint32_t command_id;
+ uint32_t buffer_length;
+ uint8_t buffer[];
+} __attribute__((packed));
+
+typedef int (*_mbim_cmd_request)(void);
+typedef int (*_mbim_cmd_response)(void *buffer, int len);
+
+extern uint8_t basic_connect[16];
+extern int transaction_id;
+
+const char* mbim_enum_string(struct mbim_enum *e, uint32_t key);
+char* mbim_get_string(struct mbim_string *str, char *in);
+void mbim_setup_header(struct mbim_message_header *hdr, MbimMessageType type, int length);
+uint8_t* mbim_setup_command_msg(uint8_t *uuid, uint32_t type, uint32_t command_id, int len);
+int mbim_send_open_msg(void);
+int mbim_send_close_msg(void);
+int mbim_send_command_msg(void);
+int mbim_add_payload(uint8_t len);
+int mbim_encode_string(struct mbim_string *str, char *in);
+void mbim_get_ipv4(void *buffer, char *out, uint32_t offset);
+
+#endif