File: rad_dict.h

package info (click to toggle)
kamailio 4.2.0-2+deb8u3
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 56,276 kB
  • sloc: ansic: 552,836; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (169 lines) | stat: -rw-r--r-- 3,797 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
 * Include file for RADIUS
 *
 * Copyright (C) 2001-2003 FhG FOKUS
 *
 * This file is part of ser, a free SIP server.
 *
 * ser is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version
 *
 * For a license to use the ser software under conditions
 * other than those described here, or to purchase support for this
 * software, please contact iptel.org by e-mail at the following addresses:
 *    info@iptel.org
 *
 * ser is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

/*
 * WARNING: Don't forget to update sip_router/etc/dictionary.sip-router if you 
 * update this file !
 */

#ifndef _RAD_DICT_H
#define _RAD_DICT_H

struct attr {
	const char *n;
	int v;
};

struct val {
	const char *n;
	int v;
};

typedef enum rad_attr {
	     /* Standard attributes according to RFC2865 and RFC2866 */
	A_USER_NAME = 0,
	A_NAS_IP_ADDRESS,
	A_NAS_PORT,
	A_SERVICE_TYPE,
	A_CALLED_STATION_ID,
	A_CALLING_STATION_ID,
	A_ACCT_STATUS_TYPE,
	A_ACCT_SESSION_ID,
	A_ACCT_SESSION_TIME,

	     /* Attributes according to draft-schulzrinne-sipping-radius-accounting-00 */
	A_SIP_METHOD,
	A_SIP_RESPONSE_CODE,
	A_SIP_CSEQ,
	A_SIP_TO_TAG,
	A_SIP_FROM_TAG,
	A_SIP_BRANCH_ID,
	A_SIP_TRANSLATED_REQUEST_ID,
	A_SIP_SOURCE_IP_ADDRESS,
	A_SIP_SOURCE_PORT,
	
	     /* Attributes according to draft-sterman-aaa-sip-00 */
	A_DIGEST_RESPONSE,
	A_DIGEST_REALM,
	A_DIGEST_NONCE,
	A_DIGEST_METHOD,
	A_DIGEST_URI,
	A_DIGEST_QOP,
	A_DIGEST_ALGORITHM,
	A_DIGEST_BODY_DIGEST,
	A_DIGEST_CNONCE,
	A_DIGEST_NONCE_COUNT,
	A_DIGEST_USER_NAME,

	     /* To be deprecated in the future */

	     /* SER-specific attributes */
	A_SER_FROM,
	A_SER_FLAGS,
	A_SER_ORIGINAL_REQUEST_ID,
	A_SER_TO,
	A_SER_DIGEST_USERNAME,
	A_SER_DIGEST_REALM,
	A_SER_REQUEST_TIMESTAMP,
	A_SER_TO_DID,
	A_SER_FROM_UID,
	A_SER_FROM_DID,
	A_SER_TO_UID,
	A_SER_RESPONSE_TIMESTAMP,
	A_SER_ATTR,
	A_SER_SERVICE_TYPE,
	A_SER_DID,
	A_SER_UID,
	A_SER_DOMAIN,
	A_SER_URI_USER,
	A_SER_URI_SCHEME,
	A_SER_SERVER_ID,

	     /* CISCO Vendor Specific Attributes */
	A_CISCO_AVPAIR,
	A_MAX
} rad_attr_t;


typedef enum rad_val {
	 /* Acct-Status-Type */
	V_START = 0,
	V_STOP,
	V_INTERIM_UPDATE,
	V_FAILED,

	     /* Service-Type */
	V_SIP_SESSION,
	V_CALL_CHECK,

	     /* SER-Service-Type */
	V_GET_URI_ATTRS,
	V_GET_USER_ATTRS,
	V_DIGEST_AUTHENTICATION,
	V_GET_DOMAIN_ATTRS,
	V_GET_GLOBAL_ATTRS,
	V_LOOKUP_DOMAIN,

	V_MAX
} rad_val_t;


/*
 * Search the RADIUS dictionary for codes of all attributes
 * and values defined above
 */
#define	INIT_AV(rh, at, vl, fn, e1, e2)					\
{									\
	int i;								\
	DICT_ATTR *da;							\
	DICT_VALUE *dv;							\
									\
	for (i = 0; i < A_MAX; i++) {					\
		if (at[i].n == NULL)					\
			continue;					\
		da = rc_dict_findattr(rh, at[i].n);			\
		if (da == NULL) {					\
			LM_ERR("%s: can't get code for %s attr\n",	\
					fn, at[i].n);			\
			return e1;					\
		}							\
		at[i].v = da->value;					\
	}								\
	for (i = 0; i < V_MAX; i++) {					\
		if (vl[i].n == NULL)					\
			continue;					\
		dv = rc_dict_findval(rh, vl[i].n);			\
		if (dv == NULL) {					\
			LM_ERR("%s: can't get code for %s attr value\n",\
					fn, vl[i].n);			\
			return e2;					\
		}							\
		vl[i].v = dv->value;					\
	}								\
}

#endif /* _RAD_DICT_H */