commands.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * uqmi -- tiny QMI support implementation
  3. *
  4. * Copyright (C) 2014-2015 Felix Fietkau <nbd@openwrt.org>
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19. * Boston, MA 02110-1301 USA.
  20. */
  21. #ifndef __UQMI_COMMANDS_H
  22. #define __UQMI_COMMANDS_H
  23. #include <stdbool.h>
  24. #include "commands-wds.h"
  25. #include "commands-dms.h"
  26. #include "commands-nas.h"
  27. #include "commands-wms.h"
  28. #include "commands-wda.h"
  29. #include "commands-uim.h"
  30. enum qmi_cmd_result {
  31. QMI_CMD_DONE,
  32. QMI_CMD_REQUEST,
  33. QMI_CMD_EXIT,
  34. };
  35. enum {
  36. CMD_TYPE_OPTION = -1,
  37. };
  38. struct uqmi_cmd_handler {
  39. const char *name;
  40. int type;
  41. enum qmi_cmd_result (*prepare)(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg);
  42. void (*cb)(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg);
  43. };
  44. struct uqmi_cmd {
  45. const struct uqmi_cmd_handler *handler;
  46. char *arg;
  47. };
  48. #define __uqmi_commands \
  49. __uqmi_command(version, get-versions, no, QMI_SERVICE_CTL), \
  50. __uqmi_command(sync, sync, no, QMI_SERVICE_CTL), \
  51. __uqmi_command(set_client_id, set-client-id, required, CMD_TYPE_OPTION), \
  52. __uqmi_command(get_client_id, get-client-id, required, QMI_SERVICE_CTL), \
  53. __uqmi_command(ctl_set_data_format, set-data-format, required, QMI_SERVICE_CTL), \
  54. __uqmi_wds_commands, \
  55. __uqmi_dms_commands, \
  56. __uqmi_nas_commands, \
  57. __uqmi_wms_commands, \
  58. __uqmi_wda_commands, \
  59. __uqmi_uim_commands
  60. #define __uqmi_command(_name, _optname, _arg, _option) __UQMI_COMMAND_##_name
  61. enum uqmi_command {
  62. __uqmi_commands,
  63. __UQMI_COMMAND_LAST
  64. };
  65. #undef __uqmi_command
  66. extern bool single_line;
  67. extern const struct uqmi_cmd_handler uqmi_cmd_handler[];
  68. void uqmi_add_command(char *arg, int longidx);
  69. bool uqmi_run_commands(struct qmi_dev *qmi);
  70. int uqmi_add_error(const char *msg);
  71. #endif