Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ctrl_iface.h 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * WPA Supplicant / UNIX domain socket -based control interface
  3. * Copyright (c) 2004-2005, Jouni Malinen <j@w1.fi>
  4. *
  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 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #ifndef CTRL_IFACE_H
  15. #define CTRL_IFACE_H
  16. #ifdef CONFIG_CTRL_IFACE
  17. /* Shared functions from ctrl_iface.c; to be called by ctrl_iface backends */
  18. /**
  19. * wpa_supplicant_ctrl_iface_process - Process ctrl_iface command
  20. * @wpa_s: Pointer to wpa_supplicant data
  21. * @buf: Received command buffer (nul terminated string)
  22. * @resp_len: Variable to be set to the response length
  23. * Returns: Response (*resp_len bytes) or %NULL on failure
  24. *
  25. * Control interface backends call this function when receiving a message that
  26. * they do not process internally, i.e., anything else than ATTACH, DETACH,
  27. * and LEVEL. The return response value is then sent to the external program
  28. * that sent the command. Caller is responsible for freeing the buffer after
  29. * this. If %NULL is returned, *resp_len can be set to two special values:
  30. * 1 = send "FAIL\n" response, 2 = send "OK\n" response. If *resp_len has any
  31. * other value, no response is sent.
  32. */
  33. char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
  34. char *buf, size_t *resp_len);
  35. /**
  36. * wpa_supplicant_ctrl_iface_process - Process global ctrl_iface command
  37. * @global: Pointer to global data from wpa_supplicant_init()
  38. * @buf: Received command buffer (nul terminated string)
  39. * @resp_len: Variable to be set to the response length
  40. * Returns: Response (*resp_len bytes) or %NULL on failure
  41. *
  42. * Control interface backends call this function when receiving a message from
  43. * the global ctrl_iface connection. The return response value is then sent to
  44. * the external program that sent the command. Caller is responsible for
  45. * freeing the buffer after this. If %NULL is returned, *resp_len can be set to
  46. * two special values: 1 = send "FAIL\n" response, 2 = send "OK\n" response. If
  47. * *resp_len has any other value, no response is sent.
  48. */
  49. char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global,
  50. char *buf, size_t *resp_len);
  51. /* Functions that each ctrl_iface backend must implement */
  52. /**
  53. * wpa_supplicant_ctrl_iface_init - Initialize control interface
  54. * @wpa_s: Pointer to wpa_supplicant data
  55. * Returns: Pointer to private data on success, %NULL on failure
  56. *
  57. * Initialize the control interface and start receiving commands from external
  58. * programs.
  59. *
  60. * Required to be implemented in each control interface backend.
  61. */
  62. struct ctrl_iface_priv *
  63. wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s);
  64. /**
  65. * wpa_supplicant_ctrl_iface_deinit - Deinitialize control interface
  66. * @priv: Pointer to private data from wpa_supplicant_ctrl_iface_init()
  67. *
  68. * Deinitialize the control interface that was initialized with
  69. * wpa_supplicant_ctrl_iface_init().
  70. *
  71. * Required to be implemented in each control interface backend.
  72. */
  73. void wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv);
  74. /**
  75. * wpa_supplicant_ctrl_iface_wait - Wait for ctrl_iface monitor
  76. * @priv: Pointer to private data from wpa_supplicant_ctrl_iface_init()
  77. *
  78. * Wait until the first message from an external program using the control
  79. * interface is received. This function can be used to delay normal startup
  80. * processing to allow control interface programs to attach with
  81. * %wpa_supplicant before normal operations are started.
  82. *
  83. * Required to be implemented in each control interface backend.
  84. */
  85. void wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv);
  86. /**
  87. * wpa_supplicant_global_ctrl_iface_init - Initialize global control interface
  88. * @global: Pointer to global data from wpa_supplicant_init()
  89. * Returns: Pointer to private data on success, %NULL on failure
  90. *
  91. * Initialize the global control interface and start receiving commands from
  92. * external programs.
  93. *
  94. * Required to be implemented in each control interface backend.
  95. */
  96. struct ctrl_iface_global_priv *
  97. wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global);
  98. /**
  99. * wpa_supplicant_global_ctrl_iface_deinit - Deinitialize global ctrl interface
  100. * @priv: Pointer to private data from wpa_supplicant_global_ctrl_iface_init()
  101. *
  102. * Deinitialize the global control interface that was initialized with
  103. * wpa_supplicant_global_ctrl_iface_init().
  104. *
  105. * Required to be implemented in each control interface backend.
  106. */
  107. void wpa_supplicant_global_ctrl_iface_deinit(
  108. struct ctrl_iface_global_priv *priv);
  109. #else /* CONFIG_CTRL_IFACE */
  110. static inline struct ctrl_iface_priv *
  111. wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s)
  112. {
  113. return (void *) -1;
  114. }
  115. static inline void
  116. wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv)
  117. {
  118. }
  119. static inline void
  120. wpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv, int level,
  121. char *buf, size_t len)
  122. {
  123. }
  124. static inline void
  125. wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv)
  126. {
  127. }
  128. static inline struct ctrl_iface_global_priv *
  129. wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global)
  130. {
  131. return (void *) 1;
  132. }
  133. static inline void
  134. wpa_supplicant_global_ctrl_iface_deinit(struct ctrl_iface_global_priv *priv)
  135. {
  136. }
  137. #endif /* CONFIG_CTRL_IFACE */
  138. #endif /* CTRL_IFACE_H */