452-ctrl_iface_reload.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. --- a/hostapd/ctrl_iface.c
  2. +++ b/hostapd/ctrl_iface.c
  3. @@ -33,6 +33,7 @@
  4. #include "wps/wps.h"
  5. #include "config_file.h"
  6. #include "ctrl_iface.h"
  7. +#include "config_file.h"
  8. struct wpa_ctrl_dst {
  9. @@ -43,6 +44,7 @@ struct wpa_ctrl_dst {
  10. int errors;
  11. };
  12. +static char *reload_opts = NULL;
  13. static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
  14. const char *buf, size_t len);
  15. @@ -152,6 +154,66 @@ static int hostapd_ctrl_iface_new_sta(st
  16. return 0;
  17. }
  18. +static int hostapd_ctrl_iface_set_down(struct hostapd_data *hapd)
  19. +{
  20. + if (hapd->driver->stop_ap)
  21. + hapd->driver->stop_ap(hapd->drv_priv);
  22. + return 0;
  23. +}
  24. +
  25. +static char *get_option(char *opt, char *str)
  26. +{
  27. + int len = strlen(str);
  28. +
  29. + if (!strncmp(opt, str, len))
  30. + return opt + len;
  31. + else
  32. + return NULL;
  33. +}
  34. +
  35. +static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname)
  36. +{
  37. + struct hostapd_config *conf;
  38. + char *opt, *val;
  39. +
  40. + conf = hostapd_config_read(fname);
  41. + if (!conf)
  42. + return NULL;
  43. +
  44. + for (opt = strtok(reload_opts, " ");
  45. + opt;
  46. + opt = strtok(NULL, " ")) {
  47. +
  48. + if ((val = get_option(opt, "channel=")))
  49. + conf->channel = atoi(val);
  50. + else if ((val = get_option(opt, "ht_capab=")))
  51. + conf->ht_capab = atoi(val);
  52. + else if ((val = get_option(opt, "ht_capab_mask=")))
  53. + conf->ht_capab &= atoi(val);
  54. + else if ((val = get_option(opt, "sec_chan=")))
  55. + conf->secondary_channel = atoi(val);
  56. + else if ((val = get_option(opt, "hwmode=")))
  57. + conf->hw_mode = atoi(val);
  58. + else if ((val = get_option(opt, "ieee80211n=")))
  59. + conf->ieee80211n = atoi(val);
  60. + else
  61. + break;
  62. + }
  63. +
  64. + return conf;
  65. +}
  66. +
  67. +static int hostapd_ctrl_iface_reload(struct hostapd_data *hapd, char *txt)
  68. +{
  69. + struct hostapd_iface *iface = hapd->iface;
  70. +
  71. + iface->config_read_cb = hostapd_ctrl_iface_config_read;
  72. + reload_opts = txt;
  73. +
  74. + hostapd_reload_config(iface);
  75. +
  76. + iface->config_read_cb = hostapd_config_read;
  77. +}
  78. #ifdef CONFIG_IEEE80211W
  79. #ifdef NEED_AP_MLME
  80. @@ -710,6 +772,10 @@ static void hostapd_ctrl_iface_receive(i
  81. reply_len += res;
  82. }
  83. #endif /* CONFIG_NO_RADIUS */
  84. + } else if (os_strcmp(buf, "DOWN") == 0) {
  85. + hostapd_ctrl_iface_set_down(hapd);
  86. + } else if (os_strncmp(buf, "RELOAD ", 7) == 0) {
  87. + hostapd_ctrl_iface_reload(hapd, buf + 7);
  88. } else if (os_strcmp(buf, "STA-FIRST") == 0) {
  89. reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
  90. reply_size);