pkg/kamailio/fedora/16: Updated rel in .spec to dev2
[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 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  *    info@iptel.org
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 /*
29  * WARNING: Don't forget to update sip_router/etc/dictionary.sip-router if you 
30  * update this file !
31  */
32
33 #ifndef _RAD_DICT_H
34 #define _RAD_DICT_H
35
36 struct attr {
37         const char *n;
38         int v;
39 };
40
41 struct val {
42         const char *n;
43         int v;
44 };
45
46 typedef enum rad_attr {
47              /* Standard attributes according to RFC2865 and RFC2866 */
48         A_USER_NAME = 0,
49         A_NAS_IP_ADDRESS,
50         A_NAS_PORT,
51         A_SERVICE_TYPE,
52         A_CALLED_STATION_ID,
53         A_CALLING_STATION_ID,
54         A_ACCT_STATUS_TYPE,
55         A_ACCT_SESSION_ID,
56         A_ACCT_SESSION_TIME,
57
58              /* Attributes according to draft-schulzrinne-sipping-radius-accounting-00 */
59         A_SIP_METHOD,
60         A_SIP_RESPONSE_CODE,
61         A_SIP_CSEQ,
62         A_SIP_TO_TAG,
63         A_SIP_FROM_TAG,
64         A_SIP_BRANCH_ID,
65         A_SIP_TRANSLATED_REQUEST_ID,
66         A_SIP_SOURCE_IP_ADDRESS,
67         A_SIP_SOURCE_PORT,
68         
69              /* Attributes according to draft-sterman-aaa-sip-00 */
70         A_DIGEST_RESPONSE,
71         A_DIGEST_REALM,
72         A_DIGEST_NONCE,
73         A_DIGEST_METHOD,
74         A_DIGEST_URI,
75         A_DIGEST_QOP,
76         A_DIGEST_ALGORITHM,
77         A_DIGEST_BODY_DIGEST,
78         A_DIGEST_CNONCE,
79         A_DIGEST_NONCE_COUNT,
80         A_DIGEST_USER_NAME,
81
82              /* To be deprecated in the future */
83
84              /* SER-specific attributes */
85         A_SER_FROM,
86         A_SER_FLAGS,
87         A_SER_ORIGINAL_REQUEST_ID,
88         A_SER_TO,
89         A_SER_DIGEST_USERNAME,
90         A_SER_DIGEST_REALM,
91         A_SER_REQUEST_TIMESTAMP,
92         A_SER_TO_DID,
93         A_SER_FROM_UID,
94         A_SER_FROM_DID,
95         A_SER_TO_UID,
96         A_SER_RESPONSE_TIMESTAMP,
97         A_SER_ATTR,
98         A_SER_SERVICE_TYPE,
99         A_SER_DID,
100         A_SER_UID,
101         A_SER_DOMAIN,
102         A_SER_URI_USER,
103         A_SER_URI_SCHEME,
104         A_SER_SERVER_ID,
105
106              /* CISCO Vendor Specific Attributes */
107         A_CISCO_AVPAIR,
108         A_MAX
109 } rad_attr_t;
110
111
112 typedef enum rad_val {
113          /* Acct-Status-Type */
114         V_START = 0,
115         V_STOP,
116         V_INTERIM_UPDATE,
117         V_FAILED,
118
119              /* Service-Type */
120         V_SIP_SESSION,
121         V_CALL_CHECK,
122
123              /* SER-Service-Type */
124         V_GET_URI_ATTRS,
125         V_GET_USER_ATTRS,
126         V_DIGEST_AUTHENTICATION,
127         V_GET_DOMAIN_ATTRS,
128         V_GET_GLOBAL_ATTRS,
129         V_LOOKUP_DOMAIN,
130
131         V_MAX
132 } rad_val_t;
133
134
135 /*
136  * Search the RADIUS dictionary for codes of all attributes
137  * and values defined above
138  */
139 #define INIT_AV(rh, at, vl, fn, e1, e2)                                 \
140 {                                                                       \
141         int i;                                                          \
142         DICT_ATTR *da;                                                  \
143         DICT_VALUE *dv;                                                 \
144                                                                         \
145         for (i = 0; i < A_MAX; i++) {                                   \
146                 if (at[i].n == NULL)                                    \
147                         continue;                                       \
148                 da = rc_dict_findattr(rh, at[i].n);                     \
149                 if (da == NULL) {                                       \
150                         LOG(L_ERR, "ERROR: %s: can't get code for the " \
151                                    "%s attribute\n", fn, at[i].n);      \
152                         return e1;                                      \
153                 }                                                       \
154                 at[i].v = da->value;                                    \
155         }                                                               \
156         for (i = 0; i < V_MAX; i++) {                                   \
157                 if (vl[i].n == NULL)                                    \
158                         continue;                                       \
159                 dv = rc_dict_findval(rh, vl[i].n);                      \
160                 if (dv == NULL) {                                       \
161                         LOG(L_ERR, "ERROR: %s: can't get code for the " \
162                                    "%s attribute value\n", fn, vl[i].n);\
163                         return e2;                                      \
164                 }                                                       \
165                 vl[i].v = dv->value;                                    \
166         }                                                               \
167 }
168
169 #endif /* _RAD_DICT_H */