radius.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2001-2003 FhG Fokus
00003  *
00004  * This file is part of Kamailio, a free SIP server.
00005  *
00006  * Kamailio is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version
00010  *
00011  * Kamailio is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License 
00017  * along with this program; if not, write to the Free Software 
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  * WARNING: Don't forget to update the dictionary if you update this file !!!
00021  *
00022  * History:
00023  * --------
00024  * 2005-06-28  multi leg call support added (bogdan)
00025  * 2008-09-03  added type field to attribute structure, which is set
00026  *             during INIT_AV.
00027  *
00028  */
00029 
00036 #ifndef _RADIUS_CORE_H
00037 #define _RADIUS_CORE_H
00038 
00039 #ifndef USE_FREERADIUS
00040         #include <radiusclient-ng.h>
00041         #define DEFAULT_RADIUSCLIENT_CONF \
00042                 "/usr/local/etc/radiusclient-ng/radiusclient.conf"
00043 #else
00044         #include <freeradius-client.h>
00045         #define DEFAULT_RADIUSCLIENT_CONF ""
00046 #endif
00047 
00048 
00049 struct attr {
00050         const char *n;
00051         int v;
00052         unsigned int t; /* type of attribute */
00053 };
00054 
00055 struct val {
00056         const char *n;
00057         int v;
00058 };
00059 
00060 #define A_USER_NAME                                     0
00061 #define A_SERVICE_TYPE                                  1
00062 #define A_CALLED_STATION_ID                             2
00063 #define A_CALLING_STATION_ID                            3
00064 #define A_ACCT_STATUS_TYPE                              4
00065 #define A_ACCT_SESSION_ID                               5
00066 #define A_SIP_METHOD                                    6
00067 #define A_SIP_RESPONSE_CODE                             7
00068 #define A_SIP_CSEQ                                      8
00069 #define A_SIP_TO_TAG                                    9
00070 #define A_SIP_FROM_TAG                                  10
00071 #define A_DIGEST_RESPONSE                               11
00072 #define A_DIGEST_ATTRIBUTES                             12
00073 #define A_SIP_URI_USER                                  13
00074 #define A_SIP_URI_HOST                                  14
00075 #define A_DIGEST_REALM                                  15
00076 #define A_DIGEST_NONCE                                  16
00077 #define A_DIGEST_METHOD                                 17
00078 #define A_DIGEST_URI                                    18
00079 #define A_DIGEST_QOP                                    19
00080 #define A_DIGEST_ALGORITHM                              20
00081 #define A_DIGEST_BODY_DIGEST                            21
00082 #define A_DIGEST_CNONCE                                 22
00083 #define A_DIGEST_NONCE_COUNT                            23
00084 #define A_DIGEST_USER_NAME                              24
00085 #define A_SIP_GROUP                                     25
00086 #define A_CISCO_AVPAIR                                  26
00087 #define A_SIP_AVP                                       27
00088 #define A_TIME_STAMP                                    28
00089 #define A_SIP_CALL_ID                                   29
00090 #define A_SIP_REQUEST_HASH                              30
00091 #define A_MAX                                           31
00092 
00093 #define V_STATUS_START                  0
00094 #define V_STATUS_STOP                   1
00095 #define V_STATUS_FAILED                 2
00096 #define V_CALL_CHECK                    3
00097 #define V_SIP_SESSION                   4
00098 #define V_GROUP_CHECK                   5
00099 #define V_SIP_CALLER_AVPS               6
00100 #define V_SIP_CALLEE_AVPS               7
00101 #define V_SIP_VERIFY_DESTINATION        8
00102 #define V_SIP_VERIFY_SOURCE             9
00103 #define V_MAX                          10
00104 
00105 #define INIT_AV(rh, at, nr_at, vl, nr_vl, fn, e1, e2) \
00106 {                                                                       \
00107         int i;                                                          \
00108         DICT_ATTR *da;                                                  \
00109         DICT_VALUE *dv;                                                 \
00110                                                                         \
00111         for (i = 0; i < nr_at; i++) {                                   \
00112                 if (at[i].n == NULL)                                    \
00113                         continue;                                       \
00114                 da = rc_dict_findattr(rh, at[i].n);                     \
00115                 if (da == NULL) {                                       \
00116                         LM_ERR("%s: can't get code for the "    \
00117                                    "%s attribute\n", fn, at[i].n);      \
00118                         return e1;                                      \
00119                 }                                                       \
00120                 at[i].v = da->value;                                    \
00121                 at[i].t = da->type;                                     \
00122         }                                                               \
00123         for (i = 0; i < nr_vl; i++) {                                   \
00124                 if (vl[i].n == NULL)                                    \
00125                         continue;                                       \
00126                 dv = rc_dict_findval(rh, vl[i].n);                      \
00127                 if (dv == NULL) {                                       \
00128                         LM_ERR("%s: can't get code for the "    \
00129                                    "%s attribute value\n", fn, vl[i].n);\
00130                         return e2;                                      \
00131                 }                                                       \
00132                 vl[i].v = dv->value;                                    \
00133         }                                                               \
00134 }
00135 
00136 #endif