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 @@
0
+/*
1
+ * Include file for RADIUS
2
+ *
3
+ * Copyright (C) 2001-2003 FhG FOKUS
4
+ *
5
+ * This file is part of ser, a free SIP server.
6
+ *
7
+ * ser is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 2 of the License, or
10
+ * (at your option) any later version
11
+ *
12
+ * For a license to use the ser software under conditions
13
+ * other than those described here, or to purchase support for this
14
+ * software, please contact iptel.org by e-mail at the following addresses:
15
+ *    info@iptel.org
16
+ *
17
+ * ser is distributed in the hope that it will be useful,
18
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+ * GNU General Public License for more details.
21
+ *
22
+ * You should have received a copy of the GNU General Public License 
23
+ * along with this program; if not, write to the Free Software 
24
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
+ */
26
+
27
+/*
28
+ * WARNING: Don't forget to update sip_router/etc/dictionary.ser 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
+	A_SER_URI_USER,
83
+	A_SER_GROUP,
84
+	A_SER_RPID,
85
+
86
+	     /* SER-specific attributes */
87
+	A_SER_ATTRS,
88
+	A_SER_FROM,
89
+	A_SER_FLAGS,
90
+	A_SER_ORIGINAL_REQUEST_ID,
91
+	A_SER_TO,
92
+	A_SER_DIGEST_USERNAME,
93
+	A_SER_DIGEST_REALM,
94
+	A_SER_REQUEST_TIMESTAMP,
95
+	A_SER_TO_DID,
96
+	A_SER_FROM_UID,
97
+	A_SER_FROM_DID,
98
+	A_SER_TO_UID,
99
+	A_SER_RESPONSE_TIMESTAMP,
100
+
101
+	     /* CISCO Vendor Specific Attributes */
102
+	A_CISCO_AVPAIR,
103
+	A_MAX
104
+} rad_attr_t;
105
+
106
+
107
+typedef enum rad_val {
108
+	V_START = 0,
109
+	V_STOP,
110
+	V_INTERIM_UPDATE,
111
+	V_FAILED,
112
+	V_CALL_CHECK,
113
+	V_SIP_SESSION,
114
+	V_SER_CALLER_AVPS,
115
+	V_SER_CALLEE_AVPS,
116
+	V_SER_GROUP_CHECK,
117
+	V_MAX
118
+} rad_val_t;
119
+
120
+
121
+/*
122
+ * Search the RADIUS dictionary for codes of all attributes
123
+ * and values defined above
124
+ */
125
+#define	INIT_AV(rh, at, vl, fn, e1, e2)					\
126
+{									\
127
+	int i;								\
128
+	DICT_ATTR *da;							\
129
+	DICT_VALUE *dv;							\
130
+									\
131
+	for (i = 0; i < A_MAX; i++) {					\
132
+		if (at[i].n == NULL)					\
133
+			continue;					\
134
+		da = rc_dict_findattr(rh, at[i].n);			\
135
+		if (da == NULL) {					\
136
+			LOG(L_ERR, "ERROR: %s: can't get code for the "	\
137
+				   "%s attribute\n", fn, at[i].n);	\
138
+			return e1;					\
139
+		}							\
140
+		at[i].v = da->value;					\
141
+	}								\
142
+	for (i = 0; i < V_MAX; i++) {					\
143
+		if (vl[i].n == NULL)					\
144
+			continue;					\
145
+		dv = rc_dict_findval(rh, vl[i].n);			\
146
+		if (dv == NULL) {					\
147
+			LOG(L_ERR, "ERROR: %s: can't get code for the "	\
148
+				   "%s attribute value\n", fn, vl[i].n);\
149
+			return e2;					\
150
+		}							\
151
+		vl[i].v = dv->value;					\
152
+	}								\
153
+}
154
+
155
+#endif /* _RAD_DICT_H */