summaryrefslogtreecommitdiffstats
path: root/tinySIP/ragel/tsip_parser_header_Proxy_Authorization.rl
blob: 1e8437bd1276180f45e70f45a9924593c32c4948 (plain)
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
///*
//* Copyright (C) 2010-2011 Mamadou Diop.
//*
//* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
//*	
//* This file is part of Open Source Doubango Framework.
//*
//* DOUBANGO 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 3 of the License, or
//* (at your option) any later version.
//*	
//* DOUBANGO 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 DOUBANGO.
//*
//*/
//
///**@file tsip_header_Proxy_Authorization.c
// * @brief SIP Proxy-Authenticate header.
// *
// * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
// *
//
// */
//#include "tinysip/headers/tsip_header_Proxy_Authorization.h"
//
//#include "tinysip/parsers/tsip_parser_uri.h"
//
//#include "tsk_debug.h"
//#include "tsk_memory.h"
//#include "tsk_time.h"
//
//#include <string.h>
//

//
///***********************************
//*	Ragel state machine.
//*/
//%%{
//	machine tsip_machine_parser_header_Proxy_Authorization;
//
//	# Includes
//	include tsip_machine_utils "./ragel/tsip_machine_utils.rl";
//	
//	action tag
//	{
//		tag_start = p;
//	}
//	
//	action is_digest
//	{
//		#//FIXME: Only Digest is supported
//		hdr_Proxy_Authorization->scheme = tsk_strdup("Digest");
//	}
//
//	action parse_username
//	{
//		TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->username);
//		tsk_strunquote(&hdr_Proxy_Authorization->username);
//	}
//
//	action parse_realm
//	{
//		TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->realm);
//		tsk_strunquote(&hdr_Proxy_Authorization->realm);
//	}
//
//	action parse_nonce
//	{
//		TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->nonce);
//		tsk_strunquote(&hdr_Proxy_Authorization->nonce);
//	}
//
//	action parse_uri
//	{
//		TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->line.request.uri);
//	}
//
//	action parse_response
//	{
//		TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->response);
//		tsk_strunquote(&hdr_Proxy_Authorization->response);
//	}
//
//	action parse_algorithm
//	{
//		TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->algorithm);
//	}
//
//	action parse_cnonce
//	{
//		TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->cnonce);
//		tsk_strunquote(&hdr_Proxy_Authorization->cnonce);
//	}
//
//	action parse_opaque
//	{
//		TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->opaque);
//		tsk_strunquote(&hdr_Proxy_Authorization->opaque);
//	}
//
//	action parse_qop
//	{
//		TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->qop);
//		//tsk_strunquote(&hdr_Proxy_Authorization->qop);
//	}
//
//	action parse_nc
//	{
//		TSK_PARSER_SET_STRING(hdr_Proxy_Authorization->nc);
//		TSK_DEBUG_INFO("PROXY_AUTHORIZATION:PARSE_NC");
//	}
//
//	action parse_param
//	{
//		TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_Proxy_Authorization));
//	}
//
//	action eob
//	{
//	}
//
//	#FIXME: Only Digest (MD5, AKAv1-MD5 and AKAv2-MD5) is supported
//	qop_value  = "auth" | "auth-int" | token;
//	other_response = (any+);
//	auth_param = generic_param>tag %parse_param;
//	
//	username = "username"i EQUAL quoted_string>tag %parse_username;
//	realm = "realm"i EQUAL quoted_string>tag %parse_realm;
//	nonce = "nonce"i EQUAL quoted_string>tag %parse_nonce;
//	digest_uri = "uri"i EQUAL LDQUOT <: (any*)>tag %parse_uri :> RDQUOT;
//	#dresponse = "response"i EQUAL LDQUOT <: (LHEX{32})>tag %parse_response :> RDQUOT;
//	dresponse = "response"i EQUAL quoted_string>tag %parse_response;
//	algorithm = "algorithm"i EQUAL <:token>tag %parse_algorithm;
//	cnonce = "cnonce"i EQUAL quoted_string>tag %parse_cnonce;
//	opaque = "opaque"i EQUAL quoted_string>tag %parse_opaque;
//	message_qop = "qop"i EQUAL qop_value>tag %parse_qop;
//	nonce_count = "nc"i EQUAL (LHEX{8})>tag %parse_nc;
//	
//	dig_resp = (username | realm | nonce | digest_uri | dresponse | algorithm | cnonce | opaque | message_qop | nonce_count)@1 | auth_param@0;
//	digest_response = dig_resp ( COMMA dig_resp )*;
//	credentials = ( "Digest"i LWS digest_response )>is_digest | other_response;
//	Proxy_Authorization = "Proxy-Authorization"i HCOLON credentials;
//
//	# Entry point
//	main := Proxy_Authorization :>CRLF @eob;
//
//}%%
//
//int tsip_header_Proxy_Authorization_serialize(const tsip_header_t* header, tsk_buffer_t* output)
//{
//	if(header)
//	{
//		const tsip_header_Proxy_Authorization_t *Proxy_Authorization = header;
//		if(Proxy_Authorization && Proxy_Authorization->scheme)
//		{
//			return tsk_buffer_append_2(output, "%s %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", 
//				Proxy_Authorization->scheme,
//
//				Proxy_Authorization->username ? "username=\"" : "",
//				Proxy_Authorization->username ? Proxy_Authorization->username : "",
//				Proxy_Authorization->username ? "\"" : "",
//
//				Proxy_Authorization->realm ? ",realm=\"" : "",
//				Proxy_Authorization->realm ? Proxy_Authorization->realm : "",
//				Proxy_Authorization->realm ? "\"" : "",
//
//				Proxy_Authorization->nonce ? ",nonce=\"" : "",
//				Proxy_Authorization->nonce ? Proxy_Authorization->nonce : "",
//				Proxy_Authorization->nonce ? "\"" : "",
//
//				Proxy_Authorization->line.request.uri ? ",uri=\"" : "",
//				Proxy_Authorization->line.request.uri ? Proxy_Authorization->line.request.uri : "",
//				Proxy_Authorization->line.request.uri ? "\"" : "",
//				
//				Proxy_Authorization->response ? ",response=\"" : "",
//				Proxy_Authorization->response ? Proxy_Authorization->response : "",
//				Proxy_Authorization->response ? "\"" : "",
//				
//				Proxy_Authorization->algorithm ? ",algorithm=" : "",
//				Proxy_Authorization->algorithm ? Proxy_Authorization->algorithm : "",
//
//				Proxy_Authorization->cnonce ? ",cnonce=\"" : "",
//				Proxy_Authorization->cnonce ? Proxy_Authorization->cnonce : "",
//				Proxy_Authorization->cnonce ? "\"" : "",
//
//				Proxy_Authorization->opaque ? ",opaque=\"" : "",
//				Proxy_Authorization->opaque ? Proxy_Authorization->opaque : "",
//				Proxy_Authorization->opaque ? "\"" : "",
//
//				Proxy_Authorization->qop ? ",qop=" : "",
//				Proxy_Authorization->qop ? Proxy_Authorization->qop : "",
//
//				Proxy_Authorization->nc ? ",nc=" : "",
//				Proxy_Authorization->nc ? Proxy_Authorization->nc : ""
//				);
//		}
//	}
//	return -1;
//}
//
//tsip_header_Proxy_Authorization_t *tsip_header_Proxy_Authorization_parse(const char *data, tsk_size_t size)
//{
//	int cs = 0;
//	const char *p = data;
//	const char *pe = p + size;
//	const char *eof = pe;
//	tsip_header_Proxy_Authorization_t *hdr_Proxy_Authorization = TSIP_HEADER_PROXY_AUTHORIZATION_CREATE();
//	
//	const char *tag_start = tsk_null;
//
//	%%write data;
//	%%write init;
//	%%write exec;
//	
//	if( cs < %%{ write first_final; }%% )
//	{
//		TSK_OBJECT_SAFE_FREE(hdr_Proxy_Authorization);
//	}
//	
//	return hdr_Proxy_Authorization;
//}
//
//
//
//
//
//
//
////========================================================
////	Proxy_Authorization header object definition
////
//
//static tsk_object_t* tsip_header_Proxy_Authorization_ctor(tsk_object_t *self, va_list * app)
//{
//	tsip_header_Proxy_Authorization_t *Proxy_Authorization = self;
//	if(Proxy_Authorization)
//	{
//		TSIP_HEADER(Proxy_Authorization)->type = tsip_htype_Proxy_Authorization;
//		TSIP_HEADER(Proxy_Authorization)->serialize = tsip_header_Proxy_Authorization_serialize;
//	}
//	else
//	{
//		TSK_DEBUG_ERROR("Failed to create new Proxy_Authorization header.");
//	}
//	return self;
//}
//
//static tsk_object_t* tsip_header_Proxy_Authorization_dtor(tsk_object_t *self)
//{
//	tsip_header_Proxy_Authorization_t *Proxy_Authorization = self;
//	if(Proxy_Authorization)
//	{
//		TSK_FREE(Proxy_Authorization->scheme);
//		TSK_FREE(Proxy_Authorization->username);
//		TSK_FREE(Proxy_Authorization->realm);
//		TSK_FREE(Proxy_Authorization->nonce);
//		TSK_FREE(Proxy_Authorization->line.request.uri);
//		TSK_FREE(Proxy_Authorization->response);
//		TSK_FREE(Proxy_Authorization->algorithm);
//		TSK_FREE(Proxy_Authorization->cnonce);
//		TSK_FREE(Proxy_Authorization->opaque);
//		TSK_FREE(Proxy_Authorization->qop);
//		TSK_FREE(Proxy_Authorization->nc);
//		
//		TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Proxy_Authorization));
//	}
//	else TSK_DEBUG_ERROR("Null Proxy_Authorization header.");
//
//	return self;
//}
//
//static const tsk_object_def_t tsip_header_Proxy_Authorization_def_s = 
//{
//	sizeof(tsip_header_Proxy_Authorization_t),
//	tsip_header_Proxy_Authorization_ctor,
//	tsip_header_Proxy_Authorization_dtor,
//	0
//};
//const void *tsip_header_Proxy_Authorization_def_t = &tsip_header_Proxy_Authorization_def_s;
OpenPOWER on IntegriCloud