• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/uqmi/common/mbim.c

  1 /*
  2  * Copyright (C) 2016  Bjørn Mork <bjorn@mork.no>
  3  *
  4  * This library is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2 of the License, or (at your option) any later version.
  8  *
  9  * This library 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 GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with this library; if not, write to the
 16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17  * Boston, MA 02110-1301 USA.
 18  */
 19 
 20 #include <stdbool.h>
 21 #include <stdint.h>
 22 #include <string.h>
 23 
 24 #include <stdio.h>
 25 
 26 #include "mbim.h"
 27 
 28 static const uint8_t qmiuuid[16] = { 0xd1, 0xa3, 0x0b, 0xc2, 0xf9, 0x7a, 0x6e, 0x43,
 29                                      0xbf, 0x65, 0xc7, 0xe2, 0x4f, 0xb0, 0xf0, 0xd3 };
 30 
 31 bool is_mbim_qmi(struct mbim_command_message *msg)
 32 {
 33         return msg->header.type == cpu_to_le32(MBIM_MESSAGE_TYPE_COMMAND_DONE) &&
 34                 msg->command_id == cpu_to_le32(MBIM_CID_QMI_MSG) &&
 35                 !msg->command_type &&   /* actually 'status' here */
 36                 !memcmp(msg->service_id, qmiuuid, 16);
 37                                                                             }
 38 
 39 void mbim_qmi_cmd(struct mbim_command_message *msg, int len, uint16_t tid)
 40 {
 41         msg->header.type = cpu_to_le32(MBIM_MESSAGE_TYPE_COMMAND);
 42         msg->header.length = cpu_to_le32(sizeof(*msg) + len);
 43         msg->header.transaction_id = cpu_to_le32(tid);
 44         msg->fragment_header.total = cpu_to_le32(1);
 45         msg->fragment_header.current = 0;
 46         memcpy(msg->service_id, qmiuuid, 16);
 47         msg->command_id = cpu_to_le32(MBIM_CID_QMI_MSG);
 48         msg->command_type = cpu_to_le32(MBIM_MESSAGE_COMMAND_TYPE_SET);
 49         msg->buffer_length = cpu_to_le32(len);
 50 }
 51 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt