Browse code

- radius dictionary management (originaly in modules/acc/dict.h) - aligned to the updated dictionary.ser file

Jan Janak authored on 15/11/2005 12:25:07
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,156 @@
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.ser 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
+	A_SER_URI_USER,
84
+	A_SER_GROUP,
85
+	A_SER_RPID,
86
+
87
+	     /* SER-specific attributes */
88
+	A_SER_ATTRS,
89
+	A_SER_FROM,
90
+	A_SER_FLAGS,
91
+	A_SER_ORIGINAL_REQUEST_ID,
92
+	A_SER_TO,
93
+	A_SER_DIGEST_USERNAME,
94
+	A_SER_DIGEST_REALM,
95
+	A_SER_REQUEST_TIMESTAMP,
96
+	A_SER_TO_DID,
97
+	A_SER_FROM_UID,
98
+	A_SER_FROM_DID,
99
+	A_SER_TO_UID,
100
+	A_SER_RESPONSE_TIMESTAMP,
101
+
102
+	     /* CISCO Vendor Specific Attributes */
103
+	A_CISCO_AVPAIR,
104
+	A_MAX
105
+} rad_attr_t;
106
+
107
+
108
+typedef enum rad_val {
109
+	V_START = 0,
110
+	V_STOP,
111
+	V_INTERIM_UPDATE,
112
+	V_FAILED,
113
+	V_CALL_CHECK,
114
+	V_SIP_SESSION,
115
+	V_SER_CALLER_AVPS,
116
+	V_SER_CALLEE_AVPS,
117
+	V_SER_GROUP_CHECK,
118
+	V_MAX
119
+} rad_val_t;
120
+
121
+
122
+/*
123
+ * Search the RADIUS dictionary for codes of all attributes
124
+ * and values defined above
125
+ */
126
+#define	INIT_AV(rh, at, vl, fn, e1, e2)					\
127
+{									\
128
+	int i;								\
129
+	DICT_ATTR *da;							\
130
+	DICT_VALUE *dv;							\
131
+									\
132
+	for (i = 0; i < A_MAX; i++) {					\
133
+		if (at[i].n == NULL)					\
134
+			continue;					\
135
+		da = rc_dict_findattr(rh, at[i].n);			\
136
+		if (da == NULL) {					\
137
+			LOG(L_ERR, "ERROR: %s: can't get code for the "	\
138
+				   "%s attribute\n", fn, at[i].n);	\
139
+			return e1;					\
140
+		}							\
141
+		at[i].v = da->value;					\
142
+	}								\
143
+	for (i = 0; i < V_MAX; i++) {					\
144
+		if (vl[i].n == NULL)					\
145
+			continue;					\
146
+		dv = rc_dict_findval(rh, vl[i].n);			\
147
+		if (dv == NULL) {					\
148
+			LOG(L_ERR, "ERROR: %s: can't get code for the "	\
149
+				   "%s attribute value\n", fn, vl[i].n);\
150
+			return e2;					\
151
+		}							\
152
+		vl[i].v = dv->value;					\
153
+	}								\
154
+}
155
+
156
+#endif /* _RAD_DICT_H */