763-radius-wispr.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. --- a/src/ap/ieee802_1x.c
  2. +++ b/src/ap/ieee802_1x.c
  3. @@ -2000,6 +2000,25 @@ static int ieee802_1x_update_vlan(struct
  4. }
  5. #endif /* CONFIG_NO_VLAN */
  6. +static int ieee802_1x_update_wispr(struct hostapd_data *hapd,
  7. + struct sta_info *sta,
  8. + struct radius_msg *msg)
  9. +{
  10. + memset(sta->bandwidth, 0, sizeof(sta->bandwidth));
  11. +
  12. + if (radius_msg_get_wispr(msg, sta->bandwidth))
  13. + return 0;
  14. +
  15. + if (!sta->bandwidth[0] && !sta->bandwidth[1])
  16. + return 0;
  17. +
  18. + hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
  19. + HOSTAPD_LEVEL_INFO,
  20. + "received wispr bandwidth from RADIUS server %d/%d",
  21. + sta->bandwidth[0], sta->bandwidth[1]);
  22. +
  23. + return 0;
  24. +}
  25. /**
  26. * ieee802_1x_receive_auth - Process RADIUS frames from Authentication Server
  27. @@ -2116,6 +2135,7 @@ ieee802_1x_receive_auth(struct radius_ms
  28. ieee802_1x_check_hs20(hapd, sta, msg,
  29. session_timeout_set ?
  30. (int) session_timeout : -1);
  31. + ieee802_1x_update_wispr(hapd, sta, msg);
  32. break;
  33. case RADIUS_CODE_ACCESS_REJECT:
  34. sm->eap_if->aaaFail = true;
  35. --- a/src/ap/sta_info.h
  36. +++ b/src/ap/sta_info.h
  37. @@ -95,6 +95,7 @@ struct sta_info {
  38. u8 supported_rates[WLAN_SUPP_RATES_MAX];
  39. int supported_rates_len;
  40. u8 qosinfo; /* Valid when WLAN_STA_WMM is set */
  41. + u32 bandwidth[2];
  42. #ifdef CONFIG_MESH
  43. enum mesh_plink_state plink_state;
  44. --- a/src/radius/radius.c
  45. +++ b/src/radius/radius.c
  46. @@ -1377,6 +1377,35 @@ radius_msg_get_cisco_keys(struct radius_
  47. return keys;
  48. }
  49. +#define RADIUS_VENDOR_ID_WISPR 14122
  50. +#define RADIUS_WISPR_AV_BW_UP 7
  51. +#define RADIUS_WISPR_AV_BW_DOWN 8
  52. +
  53. +int
  54. +radius_msg_get_wispr(struct radius_msg *msg, u32 *bandwidth)
  55. +{
  56. + int i;
  57. +
  58. + if (msg == NULL || bandwidth == NULL)
  59. + return 1;
  60. +
  61. + for (i = 0; i < 2; i++) {
  62. + size_t keylen;
  63. + u8 *key;
  64. +
  65. + key = radius_msg_get_vendor_attr(msg, RADIUS_VENDOR_ID_WISPR,
  66. + RADIUS_WISPR_AV_BW_UP + i, &keylen);
  67. + if (!key)
  68. + continue;
  69. +
  70. + if (keylen == 4)
  71. + bandwidth[i] = ntohl(*((u32 *)key));
  72. + os_free(key);
  73. + }
  74. +
  75. + return 0;
  76. +}
  77. +
  78. int radius_msg_add_mppe_keys(struct radius_msg *msg,
  79. const u8 *req_authenticator,
  80. --- a/src/radius/radius.h
  81. +++ b/src/radius/radius.h
  82. @@ -232,6 +232,10 @@ enum {
  83. RADIUS_VENDOR_ATTR_WFA_HS20_T_C_URL = 10,
  84. };
  85. +#define RADIUS_VENDOR_ID_WISPR 14122
  86. +#define RADIUS_WISPR_AV_BW_UP 7
  87. +#define RADIUS_WISPR_AV_BW_DOWN 8
  88. +
  89. #ifdef _MSC_VER
  90. #pragma pack(pop)
  91. #endif /* _MSC_VER */
  92. @@ -304,6 +308,7 @@ radius_msg_get_ms_keys(struct radius_msg
  93. struct radius_ms_mppe_keys *
  94. radius_msg_get_cisco_keys(struct radius_msg *msg, struct radius_msg *sent_msg,
  95. const u8 *secret, size_t secret_len);
  96. +int radius_msg_get_wispr(struct radius_msg *msg, u32 *bandwidth);
  97. int radius_msg_add_mppe_keys(struct radius_msg *msg,
  98. const u8 *req_authenticator,
  99. const u8 *secret, size_t secret_len,