ap.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * WPA Supplicant - Basic AP mode support routines
  3. * Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
  4. * Copyright (c) 2009, Atheros Communications
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Alternatively, this software may be distributed under the terms of BSD
  11. * license.
  12. *
  13. * See README and COPYING for more details.
  14. */
  15. #include "includes.h"
  16. #include "common.h"
  17. #include "../hostapd/hostapd.h"
  18. #include "eap_common/eap_defs.h"
  19. #include "eap_server/eap_methods.h"
  20. #include "eap_common/eap_wsc_common.h"
  21. int hostapd_reload_config(struct hostapd_iface *iface)
  22. {
  23. /* TODO */
  24. return -1;
  25. }
  26. int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
  27. const u8 *addr, int *vlan_id)
  28. {
  29. int start, end, middle, res;
  30. start = 0;
  31. end = num_entries - 1;
  32. while (start <= end) {
  33. middle = (start + end) / 2;
  34. res = os_memcmp(list[middle].addr, addr, ETH_ALEN);
  35. if (res == 0) {
  36. if (vlan_id)
  37. *vlan_id = list[middle].vlan_id;
  38. return 1;
  39. }
  40. if (res < 0)
  41. start = middle + 1;
  42. else
  43. end = middle - 1;
  44. }
  45. return 0;
  46. }
  47. int hostapd_rate_found(int *list, int rate)
  48. {
  49. int i;
  50. if (list == NULL)
  51. return 0;
  52. for (i = 0; list[i] >= 0; i++)
  53. if (list[i] == rate)
  54. return 1;
  55. return 0;
  56. }
  57. const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id)
  58. {
  59. return NULL;
  60. }
  61. int hostapd_for_each_interface(int (*cb)(struct hostapd_iface *iface,
  62. void *ctx), void *ctx)
  63. {
  64. /* TODO */
  65. return 0;
  66. }
  67. const struct hostapd_eap_user *
  68. hostapd_get_eap_user(const struct hostapd_bss_config *conf, const u8 *identity,
  69. size_t identity_len, int phase2)
  70. {
  71. struct hostapd_eap_user *user = conf->eap_user;
  72. #ifdef CONFIG_WPS
  73. if (conf->wps_state && identity_len == WSC_ID_ENROLLEE_LEN &&
  74. os_memcmp(identity, WSC_ID_ENROLLEE, WSC_ID_ENROLLEE_LEN) == 0) {
  75. static struct hostapd_eap_user wsc_enrollee;
  76. os_memset(&wsc_enrollee, 0, sizeof(wsc_enrollee));
  77. wsc_enrollee.methods[0].method = eap_server_get_type(
  78. "WSC", &wsc_enrollee.methods[0].vendor);
  79. return &wsc_enrollee;
  80. }
  81. if (conf->wps_state && conf->ap_pin &&
  82. identity_len == WSC_ID_REGISTRAR_LEN &&
  83. os_memcmp(identity, WSC_ID_REGISTRAR, WSC_ID_REGISTRAR_LEN) == 0) {
  84. static struct hostapd_eap_user wsc_registrar;
  85. os_memset(&wsc_registrar, 0, sizeof(wsc_registrar));
  86. wsc_registrar.methods[0].method = eap_server_get_type(
  87. "WSC", &wsc_registrar.methods[0].vendor);
  88. wsc_registrar.password = (u8 *) conf->ap_pin;
  89. wsc_registrar.password_len = os_strlen(conf->ap_pin);
  90. return &wsc_registrar;
  91. }
  92. #endif /* CONFIG_WPS */
  93. while (user) {
  94. if (!phase2 && user->identity == NULL) {
  95. /* Wildcard match */
  96. break;
  97. }
  98. if (user->phase2 == !!phase2 && user->wildcard_prefix &&
  99. identity_len >= user->identity_len &&
  100. os_memcmp(user->identity, identity, user->identity_len) ==
  101. 0) {
  102. /* Wildcard prefix match */
  103. break;
  104. }
  105. if (user->phase2 == !!phase2 &&
  106. user->identity_len == identity_len &&
  107. os_memcmp(user->identity, identity, identity_len) == 0)
  108. break;
  109. user = user->next;
  110. }
  111. return user;
  112. }