radius.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (C) 2001-2003 FhG Fokus
  3. *
  4. * This file is part of Kamailio, a free SIP server.
  5. *
  6. * Kamailio is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version
  10. *
  11. * Kamailio is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. * WARNING: Don't forget to update the dictionary if you update this file !!!
  21. *
  22. * History:
  23. * --------
  24. * 2005-06-28 multi leg call support added (bogdan)
  25. * 2008-09-03 added type field to attribute structure, which is set
  26. * during INIT_AV.
  27. *
  28. */
  29. /*!
  30. * \file
  31. * \brief Radius support
  32. */
  33. #ifndef _RADIUS_CORE_H
  34. #define _RADIUS_CORE_H
  35. #ifndef USE_FREERADIUS
  36. #include <radiusclient-ng.h>
  37. #define DEFAULT_RADIUSCLIENT_CONF \
  38. "/usr/local/etc/radiusclient-ng/radiusclient.conf"
  39. #else
  40. #include <freeradius-client.h>
  41. #define DEFAULT_RADIUSCLIENT_CONF ""
  42. #endif
  43. struct attr {
  44. const char *n;
  45. int v;
  46. unsigned int t; /* type of attribute */
  47. };
  48. struct val {
  49. const char *n;
  50. int v;
  51. };
  52. #define A_USER_NAME 0
  53. #define A_SERVICE_TYPE 1
  54. #define A_CALLED_STATION_ID 2
  55. #define A_CALLING_STATION_ID 3
  56. #define A_ACCT_STATUS_TYPE 4
  57. #define A_ACCT_SESSION_ID 5
  58. #define A_SIP_METHOD 6
  59. #define A_SIP_RESPONSE_CODE 7
  60. #define A_SIP_CSEQ 8
  61. #define A_SIP_TO_TAG 9
  62. #define A_SIP_FROM_TAG 10
  63. #define A_DIGEST_RESPONSE 11
  64. #define A_DIGEST_ATTRIBUTES 12
  65. #define A_SIP_URI_USER 13
  66. #define A_SIP_URI_HOST 14
  67. #define A_DIGEST_REALM 15
  68. #define A_DIGEST_NONCE 16
  69. #define A_DIGEST_METHOD 17
  70. #define A_DIGEST_URI 18
  71. #define A_DIGEST_QOP 19
  72. #define A_DIGEST_ALGORITHM 20
  73. #define A_DIGEST_BODY_DIGEST 21
  74. #define A_DIGEST_CNONCE 22
  75. #define A_DIGEST_NONCE_COUNT 23
  76. #define A_DIGEST_USER_NAME 24
  77. #define A_SIP_GROUP 25
  78. #define A_CISCO_AVPAIR 26
  79. #define A_SIP_AVP 27
  80. #define A_TIME_STAMP 28
  81. #define A_SIP_CALL_ID 29
  82. #define A_SIP_REQUEST_HASH 30
  83. #define A_MAX 31
  84. #define V_STATUS_START 0
  85. #define V_STATUS_STOP 1
  86. #define V_STATUS_FAILED 2
  87. #define V_CALL_CHECK 3
  88. #define V_SIP_SESSION 4
  89. #define V_GROUP_CHECK 5
  90. #define V_SIP_CALLER_AVPS 6
  91. #define V_SIP_CALLEE_AVPS 7
  92. #define V_SIP_VERIFY_DESTINATION 8
  93. #define V_SIP_VERIFY_SOURCE 9
  94. #define V_MAX 10
  95. #define INIT_AV(rh, at, nr_at, vl, nr_vl, fn, e1, e2) \
  96. { \
  97. int i; \
  98. DICT_ATTR *da; \
  99. DICT_VALUE *dv; \
  100. \
  101. for (i = 0; i < nr_at; i++) { \
  102. if (at[i].n == NULL) \
  103. continue; \
  104. da = rc_dict_findattr(rh, at[i].n); \
  105. if (da == NULL) { \
  106. LM_ERR("%s: can't get code for the " \
  107. "%s attribute\n", fn, at[i].n); \
  108. return e1; \
  109. } \
  110. at[i].v = da->value; \
  111. at[i].t = da->type; \
  112. } \
  113. for (i = 0; i < nr_vl; i++) { \
  114. if (vl[i].n == NULL) \
  115. continue; \
  116. dv = rc_dict_findval(rh, vl[i].n); \
  117. if (dv == NULL) { \
  118. LM_ERR("%s: can't get code for the " \
  119. "%s attribute value\n", fn, vl[i].n);\
  120. return e2; \
  121. } \
  122. vl[i].v = dv->value; \
  123. } \
  124. }
  125. #endif