Core Update of doxygen, removal of history, changing "ser" to "kamailio"
[sip-router] / rad_dict.h
1 /*
2  * Include file for RADIUS
3  *
4  * Copyright (C) 2001-2003 FhG FOKUS
5  *
6  * This file is part of Kamailio, a free SIP server.
7  *
8  * Kamailio 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  * Kamailio is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License 
19  * along with this program; if not, write to the Free Software 
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22 /*!
23  * \file
24  * \brief Kamailio core :: Radius include file
25  * \ingroup core
26  * Module: \ref core
27  *
28  * \note WARNING: Don't forget to update sip_router/etc/dictionary.sip-router if you 
29  * update this file !
30  */
31
32 #ifndef _RAD_DICT_H
33 #define _RAD_DICT_H
34
35 struct attr {
36         const char *n;
37         int v;
38 };
39
40 struct val {
41         const char *n;
42         int v;
43 };
44
45 typedef enum rad_attr {
46              /* Standard attributes according to RFC2865 and RFC2866 */
47         A_USER_NAME = 0,
48         A_NAS_IP_ADDRESS,
49         A_NAS_PORT,
50         A_SERVICE_TYPE,
51         A_CALLED_STATION_ID,
52         A_CALLING_STATION_ID,
53         A_ACCT_STATUS_TYPE,
54         A_ACCT_SESSION_ID,
55         A_ACCT_SESSION_TIME,
56
57              /* Attributes according to draft-schulzrinne-sipping-radius-accounting-00 */
58         A_SIP_METHOD,
59         A_SIP_RESPONSE_CODE,
60         A_SIP_CSEQ,
61         A_SIP_TO_TAG,
62         A_SIP_FROM_TAG,
63         A_SIP_BRANCH_ID,
64         A_SIP_TRANSLATED_REQUEST_ID,
65         A_SIP_SOURCE_IP_ADDRESS,
66         A_SIP_SOURCE_PORT,
67         
68              /* Attributes according to draft-sterman-aaa-sip-00 */
69         A_DIGEST_RESPONSE,
70         A_DIGEST_REALM,
71         A_DIGEST_NONCE,
72         A_DIGEST_METHOD,
73         A_DIGEST_URI,
74         A_DIGEST_QOP,
75         A_DIGEST_ALGORITHM,
76         A_DIGEST_BODY_DIGEST,
77         A_DIGEST_CNONCE,
78         A_DIGEST_NONCE_COUNT,
79         A_DIGEST_USER_NAME,
80
81              /* To be deprecated in the future */
82
83              /* SER-specific attributes */
84         A_SER_FROM,
85         A_SER_FLAGS,
86         A_SER_ORIGINAL_REQUEST_ID,
87         A_SER_TO,
88         A_SER_DIGEST_USERNAME,
89         A_SER_DIGEST_REALM,
90         A_SER_REQUEST_TIMESTAMP,
91         A_SER_TO_DID,
92         A_SER_FROM_UID,
93         A_SER_FROM_DID,
94         A_SER_TO_UID,
95         A_SER_RESPONSE_TIMESTAMP,
96         A_SER_ATTR,
97         A_SER_SERVICE_TYPE,
98         A_SER_DID,
99         A_SER_UID,
100         A_SER_DOMAIN,
101         A_SER_URI_USER,
102         A_SER_URI_SCHEME,
103         A_SER_SERVER_ID,
104
105              /* CISCO Vendor Specific Attributes */
106         A_CISCO_AVPAIR,
107         A_MAX
108 } rad_attr_t;
109
110
111 typedef enum rad_val {
112          /* Acct-Status-Type */
113         V_START = 0,
114         V_STOP,
115         V_INTERIM_UPDATE,
116         V_FAILED,
117
118              /* Service-Type */
119         V_SIP_SESSION,
120         V_CALL_CHECK,
121
122              /* SER-Service-Type */
123         V_GET_URI_ATTRS,
124         V_GET_USER_ATTRS,
125         V_DIGEST_AUTHENTICATION,
126         V_GET_DOMAIN_ATTRS,
127         V_GET_GLOBAL_ATTRS,
128         V_LOOKUP_DOMAIN,
129
130         V_MAX
131 } rad_val_t;
132
133
134 /*
135  * Search the RADIUS dictionary for codes of all attributes
136  * and values defined above
137  */
138 #define INIT_AV(rh, at, vl, fn, e1, e2)                                 \
139 {                                                                       \
140         int i;                                                          \
141         DICT_ATTR *da;                                                  \
142         DICT_VALUE *dv;                                                 \
143                                                                         \
144         for (i = 0; i < A_MAX; i++) {                                   \
145                 if (at[i].n == NULL)                                    \
146                         continue;                                       \
147                 da = rc_dict_findattr(rh, at[i].n);                     \
148                 if (da == NULL) {                                       \
149                         LM_ERR("%s: can't get code for %s attr\n",      \
150                                         fn, at[i].n);                   \
151                         return e1;                                      \
152                 }                                                       \
153                 at[i].v = da->value;                                    \
154         }                                                               \
155         for (i = 0; i < V_MAX; i++) {                                   \
156                 if (vl[i].n == NULL)                                    \
157                         continue;                                       \
158                 dv = rc_dict_findval(rh, vl[i].n);                      \
159                 if (dv == NULL) {                                       \
160                         LM_ERR("%s: can't get code for %s attr value\n",\
161                                         fn, vl[i].n);                   \
162                         return e2;                                      \
163                 }                                                       \
164                 vl[i].v = dv->value;                                    \
165         }                                                               \
166 }
167
168 #endif /* _RAD_DICT_H */