rad_dict.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Include file for RADIUS
  3. *
  4. * Copyright (C) 2001-2003 FhG FOKUS
  5. *
  6. * This file is part of ser, a free SIP server.
  7. *
  8. * ser is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * For a license to use the ser software under conditions
  14. * other than those described here, or to purchase support for this
  15. * software, please contact iptel.org by e-mail at the following addresses:
  16. * [email protected]
  17. *
  18. * ser is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26. */
  27. /*
  28. * WARNING: Don't forget to update sip_router/etc/dictionary.ser if you
  29. * update this file !
  30. */
  31. #ifndef _RAD_DICT_H
  32. #define _RAD_DICT_H
  33. struct attr {
  34. const char *n;
  35. int v;
  36. };
  37. struct val {
  38. const char *n;
  39. int v;
  40. };
  41. typedef enum rad_attr {
  42. /* Standard attributes according to RFC2865 and RFC2866 */
  43. A_USER_NAME = 0,
  44. A_NAS_IP_ADDRESS,
  45. A_NAS_PORT,
  46. A_SERVICE_TYPE,
  47. A_CALLED_STATION_ID,
  48. A_CALLING_STATION_ID,
  49. A_ACCT_STATUS_TYPE,
  50. A_ACCT_SESSION_ID,
  51. A_ACCT_SESSION_TIME,
  52. /* Attributes according to draft-schulzrinne-sipping-radius-accounting-00 */
  53. A_SIP_METHOD,
  54. A_SIP_RESPONSE_CODE,
  55. A_SIP_CSEQ,
  56. A_SIP_TO_TAG,
  57. A_SIP_FROM_TAG,
  58. A_SIP_BRANCH_ID,
  59. A_SIP_TRANSLATED_REQUEST_ID,
  60. A_SIP_SOURCE_IP_ADDRESS,
  61. A_SIP_SOURCE_PORT,
  62. /* Attributes according to draft-sterman-aaa-sip-00 */
  63. A_DIGEST_RESPONSE,
  64. A_DIGEST_REALM,
  65. A_DIGEST_NONCE,
  66. A_DIGEST_METHOD,
  67. A_DIGEST_URI,
  68. A_DIGEST_QOP,
  69. A_DIGEST_ALGORITHM,
  70. A_DIGEST_BODY_DIGEST,
  71. A_DIGEST_CNONCE,
  72. A_DIGEST_NONCE_COUNT,
  73. A_DIGEST_USER_NAME,
  74. /* To be deprecated in the future */
  75. /* SER-specific attributes */
  76. A_SER_FROM,
  77. A_SER_FLAGS,
  78. A_SER_ORIGINAL_REQUEST_ID,
  79. A_SER_TO,
  80. A_SER_DIGEST_USERNAME,
  81. A_SER_DIGEST_REALM,
  82. A_SER_REQUEST_TIMESTAMP,
  83. A_SER_TO_DID,
  84. A_SER_FROM_UID,
  85. A_SER_FROM_DID,
  86. A_SER_TO_UID,
  87. A_SER_RESPONSE_TIMESTAMP,
  88. A_SER_ATTR,
  89. A_SER_SERVICE_TYPE,
  90. A_SER_DID,
  91. A_SER_UID,
  92. A_SER_DOMAIN,
  93. A_SER_URI_USER,
  94. A_SER_URI_SCHEME,
  95. A_SER_SERVER_ID,
  96. /* CISCO Vendor Specific Attributes */
  97. A_CISCO_AVPAIR,
  98. A_MAX
  99. } rad_attr_t;
  100. typedef enum rad_val {
  101. /* Acct-Status-Type */
  102. V_START = 0,
  103. V_STOP,
  104. V_INTERIM_UPDATE,
  105. V_FAILED,
  106. /* Service-Type */
  107. V_SIP_SESSION,
  108. V_CALL_CHECK,
  109. /* SER-Service-Type */
  110. V_GET_URI_ATTRS,
  111. V_GET_USER_ATTRS,
  112. V_DIGEST_AUTHENTICATION,
  113. V_GET_DOMAIN_ATTRS,
  114. V_GET_GLOBAL_ATTRS,
  115. V_LOOKUP_DOMAIN,
  116. V_MAX
  117. } rad_val_t;
  118. /*
  119. * Search the RADIUS dictionary for codes of all attributes
  120. * and values defined above
  121. */
  122. #define INIT_AV(rh, at, vl, fn, e1, e2) \
  123. { \
  124. int i; \
  125. DICT_ATTR *da; \
  126. DICT_VALUE *dv; \
  127. \
  128. for (i = 0; i < A_MAX; i++) { \
  129. if (at[i].n == NULL) \
  130. continue; \
  131. da = rc_dict_findattr(rh, at[i].n); \
  132. if (da == NULL) { \
  133. LOG(L_ERR, "ERROR: %s: can't get code for the " \
  134. "%s attribute\n", fn, at[i].n); \
  135. return e1; \
  136. } \
  137. at[i].v = da->value; \
  138. } \
  139. for (i = 0; i < V_MAX; i++) { \
  140. if (vl[i].n == NULL) \
  141. continue; \
  142. dv = rc_dict_findval(rh, vl[i].n); \
  143. if (dv == NULL) { \
  144. LOG(L_ERR, "ERROR: %s: can't get code for the " \
  145. "%s attribute value\n", fn, vl[i].n);\
  146. return e2; \
  147. } \
  148. vl[i].v = dv->value; \
  149. } \
  150. }
  151. #endif /* _RAD_DICT_H */