radius_client.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * hostapd / RADIUS client
  3. * Copyright (c) 2002-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 RADIUS_CLIENT_H
  15. #define RADIUS_CLIENT_H
  16. #include "ip_addr.h"
  17. struct radius_msg;
  18. struct hostapd_radius_server {
  19. /* MIB prefix for shared variables:
  20. * @ = radiusAuth or radiusAcc depending on the type of the server */
  21. struct hostapd_ip_addr addr; /* @ServerAddress */
  22. int port; /* @ClientServerPortNumber */
  23. u8 *shared_secret;
  24. size_t shared_secret_len;
  25. /* Dynamic (not from configuration file) MIB data */
  26. int index; /* @ServerIndex */
  27. int round_trip_time; /* @ClientRoundTripTime; in hundredths of a
  28. * second */
  29. u32 requests; /* @Client{Access,}Requests */
  30. u32 retransmissions; /* @Client{Access,}Retransmissions */
  31. u32 access_accepts; /* radiusAuthClientAccessAccepts */
  32. u32 access_rejects; /* radiusAuthClientAccessRejects */
  33. u32 access_challenges; /* radiusAuthClientAccessChallenges */
  34. u32 responses; /* radiusAccClientResponses */
  35. u32 malformed_responses; /* @ClientMalformed{Access,}Responses */
  36. u32 bad_authenticators; /* @ClientBadAuthenticators */
  37. u32 timeouts; /* @ClientTimeouts */
  38. u32 unknown_types; /* @ClientUnknownTypes */
  39. u32 packets_dropped; /* @ClientPacketsDropped */
  40. /* @ClientPendingRequests: length of hapd->radius->msgs for matching
  41. * msg_type */
  42. };
  43. struct hostapd_radius_servers {
  44. /* RADIUS Authentication and Accounting servers in priority order */
  45. struct hostapd_radius_server *auth_servers, *auth_server;
  46. int num_auth_servers;
  47. struct hostapd_radius_server *acct_servers, *acct_server;
  48. int num_acct_servers;
  49. int retry_primary_interval;
  50. int acct_interim_interval;
  51. int msg_dumps;
  52. struct hostapd_ip_addr client_addr;
  53. int force_client_addr;
  54. };
  55. typedef enum {
  56. RADIUS_AUTH,
  57. RADIUS_ACCT,
  58. RADIUS_ACCT_INTERIM /* used only with radius_client_send(); just like
  59. * RADIUS_ACCT, but removes any pending interim
  60. * RADIUS Accounting packages for the same STA
  61. * before sending the new interim update */
  62. } RadiusType;
  63. typedef enum {
  64. RADIUS_RX_PROCESSED,
  65. RADIUS_RX_QUEUED,
  66. RADIUS_RX_UNKNOWN,
  67. RADIUS_RX_INVALID_AUTHENTICATOR
  68. } RadiusRxResult;
  69. struct radius_client_data;
  70. int radius_client_register(struct radius_client_data *radius,
  71. RadiusType msg_type,
  72. RadiusRxResult (*handler)
  73. (struct radius_msg *msg, struct radius_msg *req,
  74. const u8 *shared_secret, size_t shared_secret_len,
  75. void *data),
  76. void *data);
  77. int radius_client_send(struct radius_client_data *radius,
  78. struct radius_msg *msg,
  79. RadiusType msg_type, const u8 *addr);
  80. u8 radius_client_get_id(struct radius_client_data *radius);
  81. #ifdef CONFIG_NO_RADIUS
  82. static inline void radius_client_flush(struct radius_client_data *radius,
  83. int only_auth)
  84. {
  85. }
  86. static inline struct radius_client_data *
  87. radius_client_init(void *ctx, struct hostapd_radius_servers *conf)
  88. {
  89. return (void *) -1;
  90. }
  91. static inline void radius_client_deinit(struct radius_client_data *radius)
  92. {
  93. }
  94. static inline void radius_client_flush_auth(struct radius_client_data *radius,
  95. u8 *addr)
  96. {
  97. }
  98. static inline int radius_client_get_mib(struct radius_client_data *radius,
  99. char *buf, size_t buflen)
  100. {
  101. return 0;
  102. }
  103. #else /* CONFIG_NO_RADIUS */
  104. void radius_client_flush(struct radius_client_data *radius, int only_auth);
  105. struct radius_client_data *
  106. radius_client_init(void *ctx, struct hostapd_radius_servers *conf);
  107. void radius_client_deinit(struct radius_client_data *radius);
  108. void radius_client_flush_auth(struct radius_client_data *radius, u8 *addr);
  109. int radius_client_get_mib(struct radius_client_data *radius, char *buf,
  110. size_t buflen);
  111. #endif /* CONFIG_NO_RADIUS */
  112. struct radius_client_data *
  113. radius_client_reconfig(struct radius_client_data *old, void *ctx,
  114. struct hostapd_radius_servers *oldconf,
  115. struct hostapd_radius_servers *newconf);
  116. #endif /* RADIUS_CLIENT_H */