- Resolve bug in IPSec vista SPIs outbound SAs.
- Update HTTP project. - Move ragel state manager to TINYSAK project.
This commit is contained in:
parent
40773d05f0
commit
71f9ed09f7
|
@ -246,6 +246,7 @@
|
|||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
|
|
|
@ -50,7 +50,7 @@ upalpha = "A" / "B" / "C" / "D" / "E" / "F" / "G" / "H" / "I" / "J" / "K" / "L"
|
|||
alphanum = alpha / digit
|
||||
|
||||
;;;; 2. URI Characters and Escape Sequences
|
||||
uric = reserved / unreserved / escaped
|
||||
urlc = reserved / unreserved / escaped
|
||||
|
||||
;;;; 2.2. Reserved Characters
|
||||
reserved = ";" / "/" / "?" / ":" / "@" / "&" / "=" / "+" / "$" / ","
|
||||
|
@ -76,8 +76,8 @@ absoluteURI = scheme ":" ( hier-part / opaque-part )
|
|||
hier-part = ( net-path / abs-path ) [ "?" query ]
|
||||
net-path = "//" authority [ abs-path ]
|
||||
abs-path = "/" path-segments
|
||||
opaque-part = uric-no-slash *uric
|
||||
uric-no-slash = unreserved / escaped / ";" / "?" / ":" / "@" / "&" / "=" / "+" / "$" / ","
|
||||
opaque-part = urlc-no-slash *urlc
|
||||
urlc-no-slash = unreserved / escaped / ";" / "?" / ":" / "@" / "&" / "=" / "+" / "$" / ","
|
||||
|
||||
;;;; 3.1. Scheme Component
|
||||
scheme = alpha *( alpha / digit / "+" / "-" / "." )
|
||||
|
@ -107,14 +107,14 @@ param = *pchar
|
|||
pchar = unreserved / escaped / ":" / "@" / "&" / "=" / "+" / "$" / ","
|
||||
|
||||
;;;; 3.4. Query Component
|
||||
query = *uric
|
||||
query = *urlc
|
||||
|
||||
;;;; 4. URI References
|
||||
URI-reference = [ absoluteURI / relativeURI ] [ "#" fragment ]
|
||||
|
||||
|
||||
;;;; 4.1. Fragment Identifier
|
||||
fragment = *uric
|
||||
fragment = *urlc
|
||||
|
||||
;;;; 5. Relative URI References
|
||||
relativeURI = ( net-path / abs-path / rel-path ) [ "?" query ]
|
||||
|
@ -179,12 +179,12 @@ qop-value = "auth" / "auth-int" / token
|
|||
;;;; 3.2.2 The Authorization Request Header
|
||||
credentials = "Digest" digest-response
|
||||
digest-response = digest-response-value *(COMMA digest-response-value)
|
||||
digest-response-value = ( username / realm / nonce / digest-uri / auth-response / [ algorithm ] / [cnonce] / [opaque] / [message-qop] / [nonce-count] / [auth-param] )
|
||||
digest-response-value = ( username / realm / nonce / digest-url / auth-response / [ algorithm ] / [cnonce] / [opaque] / [message-qop] / [nonce-count] / [auth-param] )
|
||||
|
||||
username = "username" "=" username-value
|
||||
username-value = quoted-string
|
||||
digest-uri = "uri" "=" digest-uri-value
|
||||
digest-uri-value = request-uri ; As specified by HTTP/1.1
|
||||
digest-url = "url" "=" digest-url-value
|
||||
digest-url-value = request-url ; As specified by HTTP/1.1
|
||||
message-qop = "qop" "=" qop-value
|
||||
cnonce = "cnonce" "=" cnonce-value
|
||||
cnonce-value = nonce-value
|
||||
|
@ -227,7 +227,7 @@ SWS = [LWS] ; sep whitespace
|
|||
TEXT = 1*(token / LWS) ; <any OCTET except CTLs, but including LWS>
|
||||
COMMA = SWS "," SWS ; comma
|
||||
|
||||
;;;; text (from sip ==> is it right?)
|
||||
;;;; text (from http ==> is it right?)
|
||||
TEXT-UTF8-TRIM = 1*TEXT-UTF8char *(*LWS TEXT-UTF8char)
|
||||
TEXT-UTF8char = %x21-7E / UTF8-NONASCII
|
||||
UTF8-NONASCII = %xC0-DF 1UTF8-CONT / %xE0-EF 2UTF8-CONT / %xF0-F7 3UTF8-CONT / %xF8-FB 4UTF8-CONT / %xFC-FD 5UTF8-CONT
|
||||
|
|
|
@ -41,12 +41,12 @@ qop-value = "auth" | "auth-int" | token
|
|||
|
||||
;;;; 3.2.2 The Authorization Request Header
|
||||
credentials = "Digest" digest-response
|
||||
digest-response = 1#( username | realm | nonce | digest-uri | response | [ algorithm ] | [cnonce] | [opaque] | [message-qop] | [nonce-count] | [auth-param] )
|
||||
digest-response = 1#( username | realm | nonce | digest-url | response | [ algorithm ] | [cnonce] | [opaque] | [message-qop] | [nonce-count] | [auth-param] )
|
||||
|
||||
username = "username" "=" username-value
|
||||
username-value = quoted-string
|
||||
digest-uri = "uri" "=" digest-uri-value
|
||||
digest-uri-value = request-uri ; As specified by HTTP/1.1
|
||||
digest-url = "url" "=" digest-url-value
|
||||
digest-url-value = request-url ; As specified by HTTP/1.1
|
||||
message-qop = "qop" "=" qop-value
|
||||
cnonce = "cnonce" "=" cnonce-value
|
||||
cnonce-value = nonce-value
|
||||
|
|
|
@ -16,7 +16,7 @@ digit = "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"
|
|||
alphanum = alpha / digit
|
||||
|
||||
;;;; 2. URI Characters and Escape Sequences
|
||||
uric = reserved / unreserved / escaped
|
||||
urlc = reserved / unreserved / escaped
|
||||
|
||||
;;;; 2.2. Reserved Characters
|
||||
reserved = ";" / "/" / "?" / ":" / "@" / "&" / "=" / "+" / "$" / ","
|
||||
|
@ -42,8 +42,8 @@ absoluteURI = scheme ":" ( hier-part / opaque-part )
|
|||
hier-part = ( net-path / abs-path ) [ "?" query ]
|
||||
net-path = "//" authority [ abs-path ]
|
||||
abs-path = "/" path-segments
|
||||
opaque-part = uric-no-slash *uric
|
||||
uric-no-slash = unreserved / escaped / ";" / "?" / ":" / "@" / "&" / "=" / "+" / "$" / ","
|
||||
opaque-part = urlc-no-slash *urlc
|
||||
urlc-no-slash = unreserved / escaped / ";" / "?" / ":" / "@" / "&" / "=" / "+" / "$" / ","
|
||||
|
||||
;;;; 3.1. Scheme Component
|
||||
scheme = alpha *( alpha / digit / "+" / "-" / "." )
|
||||
|
@ -73,14 +73,14 @@ param = *pchar
|
|||
pchar = unreserved / escaped / ":" / "@" / "&" / "=" / "+" / "$" / ","
|
||||
|
||||
;;;; 3.4. Query Component
|
||||
query = *uric
|
||||
query = *urlc
|
||||
|
||||
;;;; 4. URI References
|
||||
URI-reference = [ absoluteURI / relativeURI ] [ "#" fragment ]
|
||||
|
||||
|
||||
;;;; 4.1. Fragment Identifier
|
||||
fragment = *uric
|
||||
fragment = *urlc
|
||||
|
||||
;;;; 5. Relative URI References
|
||||
relativeURI = ( net-path / abs-path / rel-path ) [ "?" query ]
|
||||
|
|
|
@ -52,7 +52,7 @@ TINYHTTP_API size_t thttp_auth_basic_response(const char* userid, const char* pa
|
|||
TINYHTTP_API int thttp_auth_digest_HA1(const char* username, const char* realm, const char* password, tsk_md5string_t* ha1);
|
||||
TINYHTTP_API int thttp_auth_digest_HA1sess(const char* username, const char* realm, const char* password, const char* nonce, const char* cnonce, tsk_md5string_t* ha1sess);
|
||||
|
||||
TINYHTTP_API int thttp_auth_digest_HA2(const char* method, const char* uri, const char* entity_body, const char* qop, tsk_md5string_t* ha2);
|
||||
TINYHTTP_API int thttp_auth_digest_HA2(const char* method, const char* url, const char* entity_body, const char* qop, tsk_md5string_t* ha2);
|
||||
|
||||
TINYHTTP_API int thttp_auth_digest_response(const tsk_md5string_t *ha1, const char* nonce, const nonce_count_t noncecount, const char* cnonce,
|
||||
const char* qop, const tsk_md5string_t* ha2, tsk_md5string_t* response);
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_header.h
|
||||
* @brief Defines a HTTP header (field-name: field-value).
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef TINYHTTP_HEADER_H
|
||||
#define TINYHTTP_HEADER_H
|
||||
|
||||
#include "tinyhttp_config.h"
|
||||
|
||||
#include "tsk_ragel_state.h"
|
||||
|
||||
#include "tsk_params.h"
|
||||
#include "tsk_object.h"
|
||||
#include "tsk_safeobj.h"
|
||||
#include "tsk_memory.h"
|
||||
#include "tsk_string.h"
|
||||
#include "tsk_list.h"
|
||||
#include "tsk_buffer.h"
|
||||
|
||||
THTTP_BEGIN_DECLS
|
||||
|
||||
#define THTTP_HEADER(self) ((thttp_header_t*)(self))
|
||||
#define THTTP_HEADER_PARAMS(self) (THTTP_HEADER(self)->params)
|
||||
|
||||
typedef int (*thttp_header_value_tostring)(const struct thttp_header_s* header, tsk_buffer_t* output);
|
||||
|
||||
/**
|
||||
* @enum thttp_header_type_e
|
||||
*
|
||||
* @brief List of all supported headers.
|
||||
**/
|
||||
typedef enum thttp_header_type_e
|
||||
{
|
||||
thttp_htype_Authorization,
|
||||
thttp_htype_Proxy_Authenticate,
|
||||
thttp_htype_Proxy_Authorization,
|
||||
thttp_htype_WWW_Authenticate,
|
||||
}
|
||||
thttp_header_type_t;
|
||||
|
||||
/*================================
|
||||
*/
|
||||
typedef struct thttp_header_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
thttp_header_type_t type;
|
||||
thttp_header_value_tostring tostring;
|
||||
tsk_params_L_t *params;
|
||||
}
|
||||
thttp_header_t;
|
||||
|
||||
#define THTTP_DECLARE_HEADER thttp_header_t header
|
||||
typedef tsk_list_t thttp_headers_L_t; /**< List of @ref thttp_header_t elements. */
|
||||
/*
|
||||
================================*/
|
||||
|
||||
TINYHTTP_API const char *thttp_header_get_name(thttp_header_type_t type);
|
||||
TINYHTTP_API int thttp_header_tostring(const thttp_header_t *self, tsk_buffer_t *output);
|
||||
|
||||
THTTP_END_DECLS
|
||||
|
||||
#endif /* TINYHTTP_HEADERS_H */
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_header_Authorization.h
|
||||
* @brief HTTP header 'Authorization'.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef _THTTP_HEADER_AUTHORIZATION_H_
|
||||
#define _THTTP_HEADER_AUTHORIZATION_H_
|
||||
|
||||
#include "tinyhttp_config.h"
|
||||
#include "tinyhttp/headers/thttp_header.h"
|
||||
|
||||
THTTP_BEGIN_DECLS
|
||||
|
||||
/**@def THTTP_HEADER_AUTHORIZATION_CREATE
|
||||
* Creates new http 'AUTHORIZATION' header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
|
||||
* @sa TSK_OBJECT_SAFE_FREE.
|
||||
*/
|
||||
#define THTTP_HEADER_AUTHORIZATION_CREATE() tsk_object_new(thttp_header_Authorization_def_t)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @struct
|
||||
///
|
||||
/// @brief HTTP header 'Authorization' as per RFC 3261 subclause .
|
||||
/// @author Mamadou
|
||||
/// @date 12/3/2009
|
||||
///
|
||||
/// @par ABNF = Authorization = "Authorization" ":" credentials
|
||||
/// credentials = "Digest" digest-response
|
||||
/// digest-response = digest-response-value *(COMMA digest-response-value)
|
||||
/// digest-response-value = ( username / realm / nonce / digest-url / auth-response / [ algorithm ] / [cnonce] / [opaque] / [message-qop] / [nonce-count] / [auth-param] )
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct thttp_header_Authorization_s
|
||||
{
|
||||
THTTP_DECLARE_HEADER;
|
||||
|
||||
char* scheme;
|
||||
char* username;
|
||||
char* realm;
|
||||
char* nonce;
|
||||
char* uri;
|
||||
char* response;
|
||||
char* algorithm;
|
||||
char* cnonce;
|
||||
char* opaque;
|
||||
char* qop;
|
||||
char* nc;
|
||||
}
|
||||
thttp_header_Authorization_t;
|
||||
typedef thttp_header_Authorization_t thttp_header_Proxy_Authorization_t;
|
||||
|
||||
TINYHTTP_API thttp_header_Authorization_t *thttp_header_Authorization_parse(const char *data, size_t size);
|
||||
TINYHTTP_API thttp_header_Proxy_Authorization_t *thttp_header_Proxy_Authorization_parse(const char *data, size_t size);
|
||||
|
||||
TINYHTTP_GEXTERN const void *thttp_header_Authorization_def_t;
|
||||
|
||||
THTTP_END_DECLS
|
||||
|
||||
#endif /* _THTTP_HEADER_AUTHORIZATION_H_ */
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_header_Content_Length.h
|
||||
* @brief HTTP header 'Content-Length'.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef _THTTP_HEADER_CONTENT_LENGTH_H_
|
||||
#define _THTTP_HEADER_CONTENT_LENGTH_H_
|
||||
|
||||
#include "tinyhttp_config.h"
|
||||
#include "tinyhttp/headers/thttp_header.h"
|
||||
|
||||
THTTP_BEGIN_DECLS
|
||||
|
||||
/**@def THTTP_HEADER_CONTENT_LENGTH_CREATE
|
||||
* Creates new http 'Content-Length' header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
|
||||
* @sa TSK_OBJECT_SAFE_FREE.
|
||||
*/
|
||||
|
||||
#define THTTP_HEADER_CONTENT_LENGTH_VA_ARGS(length) thttp_header_Content_Length_def_t, (uint32_t)length
|
||||
#define THTTP_HEADER_CONTENT_LENGTH_CREATE(length) tsk_object_new(THTTP_HEADER_CONTENT_LENGTH_VA_ARGS(length))
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @struct
|
||||
///
|
||||
/// @brief HTTP header 'Content-Length'.
|
||||
/// @author Mamadou
|
||||
/// @date 12/3/2009
|
||||
///
|
||||
/// @par ABNF: Content-Length / l
|
||||
/// Content-Length = "Content-Length" HCOLON 1*DIGIT
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct thttp_header_Content_Length_s
|
||||
{
|
||||
THTTP_DECLARE_HEADER;
|
||||
|
||||
uint32_t length;
|
||||
}
|
||||
thttp_header_Content_Length_t;
|
||||
|
||||
thttp_header_Content_Length_t *thttp_header_Content_Length_parse(const char *data, size_t size);
|
||||
|
||||
TINYHTTP_GEXTERN const void *thttp_header_Content_Length_def_t;
|
||||
|
||||
THTTP_END_DECLS
|
||||
|
||||
#endif /* _THTTP_HEADER_CONTENT_LENGTH_H_ */
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_header_Content_Type.h
|
||||
* @brief HTTP header 'Content-Type'.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef _THTTP_HEADER_CONTENT_TYPE_H_
|
||||
#define _THTTP_HEADER_CONTENT_TYPE_H_
|
||||
|
||||
#include "tinyhttp_config.h"
|
||||
#include "tinyhttp/headers/thttp_header.h"
|
||||
|
||||
THTTP_BEGIN_DECLS
|
||||
|
||||
/**@def THTTP_HEADER_CONTENT_TYPE_CREATE
|
||||
* Creates new http 'Content-Type' header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
|
||||
* @sa TSK_OBJECT_SAFE_FREE.
|
||||
*/
|
||||
#define THTTP_HEADER_CONTENT_TYPE_CREATE() tsk_object_new(thttp_header_Content_Type_def_t)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @struct
|
||||
///
|
||||
/// @brief HTTP header 'Content-Type'.
|
||||
/// @author Mamadou
|
||||
/// @date 12/3/2009
|
||||
///
|
||||
/// @par ABNF= Content-Type
|
||||
/// Content-Type = ( "Content-Type" / "c" ) HCOLON media-type
|
||||
/// media-type = m-type SLASH m-subtype *( SEMI m-parameter)
|
||||
/// m-type = discrete-type / composite-type
|
||||
/// discrete-type = "text" / "image" / "audio" / "video" / "application" / extension-token
|
||||
/// composite-type = "message" / "multipart" / extension-token
|
||||
/// extension-token = ietf-token / x-token
|
||||
/// ietf-token = token
|
||||
/// x-token = "x-" token
|
||||
/// m-subtype = extension-token / iana-token
|
||||
/// iana-token = token
|
||||
/// m-parameter = m-attribute EQUAL m-value
|
||||
/// m-attribute = token
|
||||
/// m-value = token / quoted-string
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct thttp_header_Content_Type_s
|
||||
{
|
||||
THTTP_DECLARE_HEADER;
|
||||
|
||||
char* type;
|
||||
}
|
||||
thttp_header_Content_Type_t;
|
||||
|
||||
|
||||
thttp_header_Content_Type_t *thttp_header_Content_Type_parse(const char *data, size_t size);
|
||||
|
||||
TINYHTTP_GEXTERN const void *thttp_header_Content_Type_def_t;
|
||||
|
||||
|
||||
THTTP_END_DECLS
|
||||
|
||||
#endif /* _THTTP_HEADER_CONTENT_TYPE_H_ */
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_header_WWW_Authenticate.h
|
||||
* @brief HTTP header 'WWW-Authenticate'.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef _THTTP_HEADER_WWW_Authenticate_H_
|
||||
#define _THTTP_HEADER_WWW_Authenticate_H_
|
||||
|
||||
#include "tinyhttp_config.h"
|
||||
#include "tinyhttp/headers/thttp_header.h"
|
||||
|
||||
THTTP_BEGIN_DECLS
|
||||
|
||||
/**@def THTTP_HEADER_WWW_AUTHENTICATE_CREATE
|
||||
* Creates new http 'WWW-AUTHENTICATE' header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
|
||||
* @sa TSK_OBJECT_SAFE_FREE.
|
||||
*/
|
||||
#define THTTP_HEADER_WWW_AUTHENTICATE_CREATE() tsk_object_new(thttp_header_WWW_Authenticate_def_t)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @struct
|
||||
///
|
||||
/// @brief HTTP header 'WWW-Authenticate'.
|
||||
/// @author Mamadou
|
||||
/// @date 12/3/2009
|
||||
///
|
||||
/// @par ABNF = WWW-Authenticate = "WWW-Authenticate" HCOLON challenge
|
||||
/// challenge = ("Digest" LWS digest-cln *(COMMA digest-cln)) / other-challenge
|
||||
/// other-challenge = auth-scheme / auth-param *(COMMA auth-param)
|
||||
/// digest-cln = realm / domain / nonce / opaque / stale / algorithm / qop-options / auth-param
|
||||
/// realm = "realm" EQUAL realm-value
|
||||
/// realm-value = quoted-string
|
||||
/// domain = "domain" EQUAL LDQUOT URI *( 1*SP URI ) RDQUOT
|
||||
/// URI = absoluteURI / abs-path
|
||||
/// opaque = "opaque" EQUAL quoted-string
|
||||
/// stale = "stale" EQUAL ( "true" / "false" )
|
||||
/// qop-options = "qop" EQUAL LDQUOT qop-value *("," qop-value) RDQUOT
|
||||
/// qop-value = "auth" / "auth-int" / token
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct thttp_header_WWW_Authenticate_s
|
||||
{
|
||||
THTTP_DECLARE_HEADER;
|
||||
|
||||
char* scheme;
|
||||
char* realm;
|
||||
char* domain;
|
||||
char* nonce;
|
||||
char* opaque;
|
||||
unsigned stale:1;
|
||||
char* algorithm;
|
||||
char* qop;
|
||||
}
|
||||
thttp_header_WWW_Authenticate_t;
|
||||
|
||||
typedef thttp_header_WWW_Authenticate_t thttp_header_Proxy_Authenticate_t;
|
||||
|
||||
TINYHTTP_API thttp_header_WWW_Authenticate_t *thttp_header_WWW_Authenticate_parse(const char *data, size_t size);
|
||||
TINYHTTP_API thttp_header_Proxy_Authenticate_t *thttp_header_Proxy_Authenticate_parse(const char *data, size_t size);
|
||||
|
||||
TINYHTTP_GEXTERN const void *thttp_header_WWW_Authenticate_def_t;
|
||||
|
||||
THTTP_END_DECLS
|
||||
|
||||
#endif /* _THTTP_HEADER_WWW_Authenticate_H_ */
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_parser_header.h
|
||||
* @brief HTTP headers parser.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef TINYHTTP_PARSER_HEADERS_H
|
||||
#define TINYHTTP_PARSER_HEADERS_H
|
||||
|
||||
#include "tinyhttp_config.h"
|
||||
#include "tinyhttp/thttp_message.h"
|
||||
#include "tsk_ragel_state.h"
|
||||
|
||||
THTTP_BEGIN_DECLS
|
||||
|
||||
int thttp_header_parse(tsk_ragel_state_t *state, thttp_message_t *message);
|
||||
|
||||
THTTP_END_DECLS
|
||||
|
||||
#endif /* TINYHTTP_PARSER_HEADERS_H */
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_parser_message.h
|
||||
* @brief HTTP message parser.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef TINYHTTP_PARSER_MESSAGE_H
|
||||
#define TINYHTTP_PARSER_MESSAGE_H
|
||||
|
||||
#include "tinyhttp_config.h"
|
||||
#include "tinyhttp/thttp_message.h"
|
||||
#include "tsk_ragel_state.h"
|
||||
|
||||
THTTP_BEGIN_DECLS
|
||||
|
||||
TINYHTTP_API int thttp_message_parse(tsk_ragel_state_t *state, thttp_message_t **result);
|
||||
|
||||
THTTP_END_DECLS
|
||||
|
||||
#endif /* TINYHTTP_PARSER_MESSAGE_H */
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_parser_url.h
|
||||
* @brief HTTP/HTTPS URL parser.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef TINYHTTP_PARSER_URL_H
|
||||
#define TINYHTTP_PARSER_URL_H
|
||||
|
||||
#include "tinyhttp_config.h"
|
||||
#include "tinyhttp/thttp_url.h"
|
||||
|
||||
#include "tsk_ragel_state.h"
|
||||
|
||||
THTTP_BEGIN_DECLS
|
||||
|
||||
TINYHTTP_API thttp_url_t *thttp_url_parse(const char *data, size_t size);
|
||||
|
||||
THTTP_END_DECLS
|
||||
|
||||
#endif /* TINYHTTP_PARSER_URL_H */
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_message.h
|
||||
* @brief Represents a HTTP message. A HTTP message is either a request from a client to a server, or a
|
||||
* response from a server to a client.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef THTTP_MESSAGE_H
|
||||
#define THTTP_MESSAGE_H
|
||||
|
||||
#include "tinyhttp_config.h"
|
||||
|
||||
#include "tinyhttp/thttp_url.h"
|
||||
|
||||
//#include "tinyhttp/headers/thttp_header_Call_ID.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Contact.h"
|
||||
#include "tinyhttp/headers/thttp_header_Content_Length.h"
|
||||
#include "tinyhttp/headers/thttp_header_Content_Type.h"
|
||||
//#include "tinyhttp/headers/thttp_header_CSeq.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Expires.h"
|
||||
//#include "tinyhttp/headers/thttp_header_From.h"
|
||||
//#include "tinyhttp/headers/thttp_header_P_Access_Network_Info.h"
|
||||
//#include "tinyhttp/headers/thttp_header_To.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Via.h"
|
||||
|
||||
#include "tsk_object.h"
|
||||
#include "tsk_buffer.h"
|
||||
|
||||
THTTP_BEGIN_DECLS
|
||||
|
||||
#define THTTP_MESSAGE_VERSION_10 "HTTP/1.0"
|
||||
#define THTTP_MESSAGE_VERSION_20 "HTTP/2.0"
|
||||
#define THTTP_MESSAGE_VERSION_DEFAULT THTTP_MESSAGE_VERSION_20
|
||||
|
||||
#define THTTP_MESSAGE_IS_REQUEST(self) ((self) ? (self)->type == thttp_request : 0)
|
||||
#define THTTP_MESSAGE_IS_RESPONSE(self) ((self) ? (self)->type == thttp_response : 0)
|
||||
|
||||
#define THTTP_MESSAGE(self) ((thttp_message_t*)(self))
|
||||
#define THTTP_MESSAGE_AS_RESPONSE(self) ((thttp_response_t*)(self))
|
||||
#define THTTP_MESSAGE_AS_REQUEST(self) ((thttp_request_t*)(self))
|
||||
|
||||
|
||||
/**@def THTTP_MESSAGE_CREATE
|
||||
* Creates new http messgae. Could be either a request or a response.
|
||||
* You must call @ref TSK_OBJECT_SAFE_FREE to free the message.
|
||||
* @sa TSK_OBJECT_SAFE_FREE.
|
||||
*/
|
||||
#define THTTP_MESSAGE_CREATE() tsk_object_new(thttp_message_def_t, (thttp_message_type_t)thttp_unknown)
|
||||
#define THTTP_REQUEST_CREATE(method, url) tsk_object_new(thttp_message_def_t, (thttp_message_type_t)thttp_request, (const char*)method, (const thttp_url_t*)url)
|
||||
#define THTTP_RESPONSE_CREATE(request, status_code, reason_phrase) tsk_object_new(thttp_message_def_t, (thttp_message_type_t)thttp_response, (const thttp_request_t*)request, (short)status_code, (const char*)reason_phrase)
|
||||
|
||||
|
||||
#define THTTP_RESPONSE_CODE(self) ((self)->status_code)
|
||||
#define THTTP_RESPONSE_PHRASE(self) ((self)->reason_phrase)
|
||||
|
||||
#define THTTP_REQUEST_METHOD(self) ((self)->method)
|
||||
#define THTTP_REQUEST_URI(self) ((self)->url)
|
||||
|
||||
#define THTTP_MESSAGE_CONTENT_LENGTH(message) (uint32_t)(((message) && (message)->Content_Length) ? (message)->Content_Length->length : 0)
|
||||
#define THTTP_MESSAGE_CONTENT(message) (THTTP_MESSAGE_HAS_CONTENT(message) ? (message)->Content : 0)
|
||||
#define THTTP_MESSAGE_HAS_CONTENT(message) ((message) && (message)->Content)
|
||||
|
||||
#define THTTP_RESPONSE_IS(self, code) (THTTP_RESPONSE_CODE((self)) == code)
|
||||
#define THTTP_RESPONSE_IS_NXX(self, N) (N##00<= THTTP_RESPONSE_CODE((self)) && THTTP_RESPONSE_CODE((self)) <= N##99)
|
||||
#define THTTP_RESPONSE_IS_1XX(self) THTTP_RESPONSE_IS_NXX(self, 1)
|
||||
#define THTTP_RESPONSE_IS_2XX(self) THTTP_RESPONSE_IS_NXX(self, 2)
|
||||
#define THTTP_RESPONSE_IS_3XX(self) THTTP_RESPONSE_IS_NXX(self, 3)
|
||||
#define THTTP_RESPONSE_IS_4XX(self) THTTP_RESPONSE_IS_NXX(self, 4)
|
||||
#define THTTP_RESPONSE_IS_5XX(self) THTTP_RESPONSE_IS_NXX(self, 5)
|
||||
#define THTTP_RESPONSE_IS_6XX(self) THTTP_RESPONSE_IS_NXX(self, 6)
|
||||
#define THTTP_RESPONSE_IS_23456(self) (200<= THTTP_RESPONSE_CODE((self)) && THTTP_RESPONSE_CODE((self)) <= 699)
|
||||
|
||||
/**
|
||||
* @enum thttp_message_type_t
|
||||
*
|
||||
* @brief Defines the message type (Request or Response).
|
||||
**/
|
||||
typedef enum thttp_message_type_e
|
||||
{
|
||||
thttp_unknown,
|
||||
thttp_request,
|
||||
thttp_response
|
||||
}
|
||||
thttp_message_type_t;
|
||||
|
||||
/**
|
||||
* @struct thttp_message_t
|
||||
*
|
||||
* @brief Represents a HTTP message. A HTTP message is either a request from a client to a server,
|
||||
* or a response from a server to a client. See RFC 3261 suc-bclause 7.
|
||||
* You must call @ref THTTP_MESSAGE_CREATE to create a http message and TSK_OBJECT_SAFE_FREE to free the message.
|
||||
*
|
||||
* @author Mamadou
|
||||
* @date 12/2/2009
|
||||
**/
|
||||
typedef struct thttp_message_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
char *http_version; /**< The HTTP version. Only 'HTTP/2.0' is supported. */
|
||||
thttp_message_type_t type; /**< The type of this HTTP message. */
|
||||
|
||||
#if !defined(__C99__) /* C99 does not allow unnamed structs/unions */
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
#endif
|
||||
char *method;
|
||||
thttp_url_t *url;
|
||||
#if !defined(__C99__)
|
||||
};
|
||||
struct
|
||||
{
|
||||
#endif
|
||||
short status_code;
|
||||
char *reason_phrase;
|
||||
#if !defined(__C99__)
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
/*== MOST COMMON HEADERS. */
|
||||
//thttp_header_Via_t *firstVia; /**< First Via header. */
|
||||
//thttp_header_From_t *From;
|
||||
//thttp_header_To_t *To;
|
||||
//thttp_header_Contact_t *Contact;
|
||||
//thttp_header_Call_ID_t *Call_ID;
|
||||
//thttp_header_CSeq_t *CSeq;
|
||||
//thttp_header_Expires_t *Expires;
|
||||
|
||||
thttp_header_Content_Type_t *Content_Type;
|
||||
thttp_header_Content_Length_t *Content_Length;
|
||||
tsk_buffer_t *Content;
|
||||
|
||||
/*== OTHER HEADERS*/
|
||||
thttp_headers_L_t *headers;
|
||||
}
|
||||
thttp_message_t;
|
||||
|
||||
typedef thttp_message_t thttp_request_t; /**< HTTP request message. */
|
||||
typedef thttp_message_t thttp_response_t; /**< HTTP response message. */
|
||||
|
||||
|
||||
TINYHTTP_API int thttp_message_add_header(thttp_message_t *self, const thttp_header_t *hdr);
|
||||
TINYHTTP_API int thttp_message_add_headers(thttp_message_t *self, const thttp_headers_L_t *headers);
|
||||
|
||||
#if !defined(_MSC_VER) || defined(__GNUC__)
|
||||
static void THTTP_MESSAGE_ADD_HEADER(thttp_message_t *self, ...)
|
||||
{
|
||||
va_list ap;
|
||||
thttp_header_t *header;
|
||||
const tsk_object_def_t *objdef;
|
||||
|
||||
va_start(ap, self);
|
||||
objdef = va_arg(ap, const tsk_object_def_t*);
|
||||
header = tsk_object_new2(objdef, &ap);
|
||||
va_end(ap);
|
||||
|
||||
thttp_message_add_header(self, header);
|
||||
tsk_object_unref(header);
|
||||
}
|
||||
#else
|
||||
#define THTTP_MESSAGE_ADD_HEADER(self, objdef, ...) \
|
||||
{ \
|
||||
thttp_header_t *header = tsk_object_new(objdef, __VA_ARGS__); \
|
||||
thttp_message_add_header(self, header); \
|
||||
tsk_object_unref(header); \
|
||||
}
|
||||
#endif
|
||||
|
||||
TINYHTTP_API const thttp_header_t *thttp_message_get_headerAt(const thttp_message_t *self, thttp_header_type_t type, size_t index);
|
||||
TINYHTTP_API const thttp_header_t *thttp_message_get_header(const thttp_message_t *self, thttp_header_type_t type);
|
||||
|
||||
TINYHTTP_API uint32_t thttp_message_getContent_length(const thttp_message_t *message);
|
||||
|
||||
TINYHTTP_API int thttp_message_tostring(const thttp_message_t *self, tsk_buffer_t *output);
|
||||
|
||||
TINYHTTP_API thttp_request_t *thttp_request_new(const char* method, const thttp_url_t *request_url, const thttp_url_t *from, const thttp_url_t *to, const char *call_id, int32_t cseq);
|
||||
TINYHTTP_API thttp_response_t *thttp_response_new(short status_code, const char* reason_phrase, const thttp_request_t *request);
|
||||
|
||||
TINYHTTP_GEXTERN const void *thttp_message_def_t;
|
||||
|
||||
THTTP_END_DECLS
|
||||
|
||||
#endif /* THTTP_MESSAGE_H */
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_url.h
|
||||
* @brief HTTP/HTTPS URL.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef TINYHTTP_URL_H
|
||||
#define TINYHTTP_URL_H
|
||||
|
||||
#include "tinyhttp_config.h"
|
||||
|
||||
#include "tsk_object.h"
|
||||
#include "tsk_params.h"
|
||||
#include "tsk_buffer.h"
|
||||
|
||||
THTTP_BEGIN_DECLS
|
||||
|
||||
/**@def THTTP_URL_CREATE
|
||||
* Creates new http/https/tel url. You must call @ref TSK_OBJECT_SAFE_FREE to free the url.
|
||||
* @sa TSK_OBJECT_SAFE_FREE.
|
||||
*/
|
||||
#define THTTP_URL_CREATE(type) tsk_object_new(thttp_url_def_t, (thttp_url_type_t) type)
|
||||
|
||||
#define THTTP_URL_IS_SECURE(url) ((url && url->type==url_https) ? 1 : 0)
|
||||
|
||||
typedef enum thttp_url_type_e
|
||||
{
|
||||
url_unknown,
|
||||
url_http,
|
||||
url_https,
|
||||
}
|
||||
thttp_url_type_t;
|
||||
|
||||
typedef enum thttp_host_type_e
|
||||
{
|
||||
host_unknown,
|
||||
host_hostname,
|
||||
host_ipv4,
|
||||
host_ipv6
|
||||
}
|
||||
thttp_host_type_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @struct thttp_url_t
|
||||
///
|
||||
/// @brief HTTP/HTTPS URL.
|
||||
///
|
||||
/// @author Mamadou
|
||||
/// @date 12/6/2009
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct thttp_url_s
|
||||
{
|
||||
TSK_DECLARE_OBJECT;
|
||||
|
||||
thttp_url_type_t type;
|
||||
char *scheme;
|
||||
char *host; /**< Host name. Hostname or IPv4address or IPv6address. */
|
||||
thttp_host_type_t host_type; /**< IPv4 or IPv6 or domain name. */
|
||||
uint16_t port;
|
||||
char *password;
|
||||
}
|
||||
thttp_url_t;
|
||||
|
||||
TINYHTTP_API int thttp_url_serialize(const thttp_url_t *url, tsk_buffer_t *output);
|
||||
TINYHTTP_API char* thttp_url_tostring(const thttp_url_t *url);
|
||||
TINYHTTP_API thttp_url_t *thttp_url_clone(const thttp_url_t *url);
|
||||
|
||||
TINYHTTP_GEXTERN const void *thttp_url_def_t;
|
||||
|
||||
THTTP_END_DECLS
|
||||
|
||||
#endif /* TINYHTTP_URL_H */
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# Ragel generator
|
||||
# For more information about Ragel: http://www.complang.org/ragel/
|
||||
|
||||
export OPTIONS="-C -L -T0"
|
||||
#export OPTIONS="-C -L -G2"
|
||||
|
||||
# HTTP/HTTPS URL parser
|
||||
ragel.exe $OPTIONS -o ../src/parsers/thttp_parser_url.c thttp_parser_url.rl
|
||||
|
||||
# HTTP message (both requests an responses) parser.
|
||||
ragel.exe $OPTIONS -o ../src/parsers/thttp_parser_message.c thttp_parser_message.rl
|
||||
|
||||
# HTTP headers parser
|
||||
ragel.exe $OPTIONS -o ../src/parsers/thttp_parser_header.c thttp_parser_header.rl
|
||||
|
||||
|
||||
|
||||
|
||||
# ==Authorization
|
||||
ragel.exe $OPTIONS -o ../src/headers/thttp_header_Authorization.c thttp_parser_header_Authorization.rl
|
||||
|
||||
# ==Content-Length
|
||||
ragel.exe $OPTIONS -o ../src/headers/thttp_header_Content_Length.c thttp_parser_header_Content_Length.rl
|
||||
|
||||
# ==Content-Type
|
||||
ragel.exe $OPTIONS -o ../src/headers/thttp_header_Content_Type.c thttp_parser_header_Content_Type.rl
|
||||
|
||||
# ==WWW-Authenticate
|
||||
ragel.exe $OPTIONS -o ../src/headers/thttp_header_WWW_Authenticate.c thttp_parser_header_WWW_Authenticate.rl
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
/**@file thttp_machine_headers.rl.
|
||||
* @brief Ragel file.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
|
||||
/*== Header pasrsing machine. Supports both full-length and compact mode. */
|
||||
%%{
|
||||
machine thttp_machine_header;
|
||||
|
||||
Accept = "Accept"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept;
|
||||
Accept_Charset = "Accept-Charset"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept_Charset;
|
||||
Accept_Encoding = "Accept-Encoding"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept_Encoding;
|
||||
Accept_Language = "Accept-Language"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Accept_Language;
|
||||
Allow = "Allow"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Allow;
|
||||
Authorization = "Authorization"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Authorization;
|
||||
Cache_Control = "Cache-Control"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Cache_Control;
|
||||
Connection = "Connection"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Connection;
|
||||
Content_Encoding = ("Content-Encoding"i | "e") SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Encoding;
|
||||
Content_Language = "Content-Language"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Language;
|
||||
Content_Length = "Content-Length"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Length;
|
||||
Content_Location = "Content-Location"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Location;
|
||||
Content_MD5 = "Content-MD5"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_MD5;
|
||||
Content_Range = "Content-Range"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Range;
|
||||
Content_Type = ("Content-Type"i | "c") SP* HCOLON SP*<: any* :>CRLF @parse_header_Content_Type;
|
||||
Date = "Date"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Date;
|
||||
Expect = "Expect"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Expect;
|
||||
Expires = "Expires"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Expires;
|
||||
From = "From"i SP* HCOLON SP*<: any* :>CRLF @parse_header_From;
|
||||
Host = "Host"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Host;
|
||||
If_Match = "If-Match"i SP* HCOLON SP*<: any* :>CRLF @parse_header_If_Match;
|
||||
If_Modified_Since = "If-Modified-Since"i SP* HCOLON SP*<: any* :>CRLF @parse_header_If_Modified_Since;
|
||||
If_None_Match = "If-None-Match"i SP* HCOLON SP*<: any* :>CRLF @parse_header_If_None_Match;
|
||||
If_Range = "If-Range"i SP* HCOLON SP*<: any* :>CRLF @parse_header_If_Range;
|
||||
If_Unmodified_Since = "If-Unmodified-Since"i SP* HCOLON SP*<: any* :>CRLF @parse_header_If_Unmodified_Since;
|
||||
Last_Modified = "Last-Modified"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Last_Modified;
|
||||
Max_Forwards = "Max-Forwards"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Max_Forwards;
|
||||
Pragma = "Pragma"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Pragma;
|
||||
Proxy_Authorization = "Proxy-Authorization"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Proxy_Authorization;
|
||||
Range = "Range"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Range;
|
||||
Referer = "Referer"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Referer;
|
||||
Transfer_Encoding = "Transfer-Encoding"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Transfer_Encoding;
|
||||
TE = "TE"i SP* HCOLON SP*<: any* :>CRLF @parse_header_TE;
|
||||
Trailer = "Trailer"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Trailer;
|
||||
Upgrade = "Upgrade"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Upgrade;
|
||||
User_Agent = "User-Agent"i SP* HCOLON SP*<: any* :>CRLF @parse_header_User_Agent;
|
||||
Via = "Via"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Via;
|
||||
Warning = "Warning"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Warning;
|
||||
|
||||
######
|
||||
extension_header = (token) SP* HCOLON SP*<: any* :>CRLF @parse_header_extension_header;
|
||||
|
||||
general_header = Cache_Control | Connection | Date | Pragma | Trailer | Transfer_Encoding | Upgrade | Via | Warning;
|
||||
request_header = Accept | Accept_Charset | Accept_Encoding | Accept_Language | Authorization | Expect | From | Host | If_Match | If_Modified_Since | If_None_Match | If_Range | If_Unmodified_Since | Max_Forwards | Proxy_Authorization | Range | Referer | TE | User_Agent;
|
||||
entity_header = Allow | Content_Encoding | Content_Language | Content_Length | Content_Location | Content_MD5 | Content_Range | Content_Type | Expires | Last_Modified;
|
||||
|
||||
HEADER = (general_header | request_header | entity_header)@1 | extension_header@0;
|
||||
}%%
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
/**@file thttp_machine_message.rl
|
||||
* @brief Ragel file.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
%%{
|
||||
machine thttp_machine_message;
|
||||
|
||||
message_body = any*;
|
||||
HTTP_Version = ("HTTP"i "/" DIGIT+ "." DIGIT+)>tag %parse_httpversion;
|
||||
|
||||
message_header = any+ >tag :>CRLF %parse_header;
|
||||
|
||||
# HTTP RESPONSE
|
||||
Reason_Phrase = (( reserved | unreserved | escaped | UTF8_NONASCII | UTF8_CONT | SP | HTAB )*)>tag %parse_reason_phrase;
|
||||
Status_Line = HTTP_Version :>SP Status_Code>tag %parse_status_code :>SP Reason_Phrase :>CRLF;
|
||||
Response = Status_Line (message_header* :>CRLF);
|
||||
|
||||
# HTTP REQUEST
|
||||
URI = (scheme HCOLON any+)>tag %parse_requesturl;
|
||||
Request_URI = URI;
|
||||
Request_Line = Method>tag %parse_method :>SP Request_URI :>SP HTTP_Version :>CRLF;
|
||||
Request = Request_Line (message_header* :>CRLF);
|
||||
|
||||
# HTTP MESSAGE
|
||||
HTTP_message = Request | Response;
|
||||
|
||||
}%%
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
/**@file thttp_machine_utils.rl
|
||||
* @brief Ragel file.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
%%{
|
||||
machine thttp_machine_utils;
|
||||
|
||||
OCTET = "0x"[0-9A-Fa-f]+;
|
||||
CHAR = 0x01..0x7f;
|
||||
VCHAR = 0x21..0x7e;
|
||||
ALPHA = 0x41..0x5a | 0x61..0x7a;
|
||||
DIGIT = 0x30..0x39;
|
||||
CTL = 0x00..0x1f | 0x7f;
|
||||
HTAB = "\t";
|
||||
LF = "\n";
|
||||
CR = "\r";
|
||||
SP = " ";
|
||||
DQUOTE = "\"";
|
||||
BIT = "0" | "1";
|
||||
HEXDIG = DIGIT | "A"i | "B"i | "C"i | "D"i | "E"i | "F"i;
|
||||
CRLF = CR LF;
|
||||
WSP = SP | HTAB;
|
||||
LWSP = ( WSP | ( CRLF WSP ) )*;
|
||||
LWS = ( WSP* CRLF )? WSP+;
|
||||
SWS = LWS?;
|
||||
EQUAL = SWS "=" SWS;
|
||||
LHEX = DIGIT | 0x61..0x66;
|
||||
HCOLON = ( SP | HTAB )* ":" SWS;
|
||||
separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\\" | DQUOTE | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HTAB;
|
||||
STAR = SWS "*" SWS;
|
||||
SLASH = SWS "/" SWS;
|
||||
LPAREN = SWS "(" SWS;
|
||||
RPAREN = SWS ")" SWS;
|
||||
COMMA = SWS "," SWS;
|
||||
SEMI = SWS ";" SWS;
|
||||
COLON = SWS ":" SWS;
|
||||
LAQUOT = SWS "<";
|
||||
LDQUOT = SWS DQUOTE;
|
||||
RAQUOT = ">" SWS;
|
||||
RDQUOT = DQUOTE SWS;
|
||||
UTF8_CONT = 0x80..0xbf;
|
||||
UTF8_NONASCII = ( 0xc0..0xdf UTF8_CONT ) | ( 0xe0..0xef UTF8_CONT{2} ) | ( 0xf0..0xf7 UTF8_CONT{3} ) | ( 0xf8..0xfb UTF8_CONT{4} ) | ( 0xfc..0xfd UTF8_CONT{5} );
|
||||
ctext = 0x21..0x27 | 0x2a..0x5b | 0x5d..0x7e | UTF8_NONASCII | LWS;
|
||||
qvalue = ( "0" ( "." DIGIT{,3} )? ) | ( "1" ( "." "0"{,3} )? );
|
||||
alphanum = ALPHA | DIGIT;
|
||||
scheme = ALPHA ( ALPHA | DIGIT | "+" | "-" | "." )*;
|
||||
token = ( alphanum | "-" | "." | "!" | "%" | "*" | "_" | "+" | "`" | "'" | "~" )+;
|
||||
ietf_token = token;
|
||||
x_token = "x-"i token;
|
||||
iana_token = token;
|
||||
token_nodot = ( alphanum | "-" | "!" | "%" | "*" | "_" | "+" | "`" | "'" | "~" )+;
|
||||
word = ( alphanum | "-" | "." | "!" | "%" | "*" | "_" | "+" | "`" | "'" | "~" | "(" | ")" | "<" | ">" | ":" | "\\" | DQUOTE | "/" | "[" | "]" | "?" | "{" | "}" )+;
|
||||
domainlabel = alphanum | ( alphanum ( alphanum | "-" )* alphanum );
|
||||
toplabel = ALPHA | ( ALPHA ( alphanum | "-" )* alphanum );
|
||||
hostname = ( domainlabel "." )* toplabel "."?;
|
||||
IPv4address = DIGIT{1,3} "." DIGIT{1,3} "." DIGIT{1,3} "." DIGIT{1,3};
|
||||
hex4 = HEXDIG{1,4};
|
||||
hexseq = hex4 ( ":" hex4 )*;
|
||||
hexpart = hexseq | ( hexseq "::" hexseq? ) | ( "::" hexseq? );
|
||||
IPv6address = hexpart ( ":" IPv4address )?;
|
||||
IPv6reference = "[" IPv6address "]";
|
||||
host = hostname | IPv4address | IPv6reference;
|
||||
qdtext = LWS | "!" | 0x23..0x5b | 0x5d..0x7e | UTF8_NONASCII;
|
||||
quoted_pair = "\\" ( 0x00..0x09 | 0x0b..0x0c | 0x0e..0x7f );
|
||||
quoted_string = SWS DQUOTE ( qdtext | quoted_pair )* DQUOTE;
|
||||
gen_value = token | host | quoted_string;
|
||||
generic_param = token ( EQUAL gen_value )?;
|
||||
accept_param = ( "q"i EQUAL qvalue ) | generic_param;
|
||||
mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")";
|
||||
unreserved = alphanum | mark;
|
||||
escaped = "%" HEXDIG HEXDIG;
|
||||
user_unreserved = "&" | "=" | "+" | "$" | "," | ";" | "?" | "/";
|
||||
user = ( unreserved | escaped | user_unreserved )+;
|
||||
param_unreserved = "[" | "]" | "/" | ":" | "&" | "+" | "$";
|
||||
pct_encoded = "%" HEXDIG HEXDIG;
|
||||
paramchar = param_unreserved | unreserved | pct_encoded;
|
||||
pname = paramchar+;
|
||||
pvalue = paramchar+;
|
||||
parameter = ";" pname ( "=" pvalue )?;
|
||||
reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ",";
|
||||
urlc = reserved | unreserved | escaped;
|
||||
|
||||
extension_code = DIGIT{3};
|
||||
Status_Code = "100" | "101" | "200" | "201" | "202" | "203" | "204" | "205" | "206" | "300" | "301" | "302" | "303" | "304" | "305" | "307" | "400" | "401" | "402" | "403" | "404" | "405" | "406" | "407" | "408" | "409" | "410" | "411" | "412" | "413" | "414" | "415" | "416" | "417" | "500" | "501" | "502" | "503" | "504" | "505" | extension_code;
|
||||
|
||||
extension_method = token;
|
||||
Method = "OPTIONS"i | "GET"i | "HEAD"i | "POST"i | "PUT"i | "DELETE"i | "TRACE"i | "CONNECT"i | extension_method;
|
||||
}%%
|
|
@ -0,0 +1,322 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_parser_headers.c
|
||||
* @brief HTTP headers parser.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinyhttp/parsers/thttp_parser_header.h"
|
||||
|
||||
//#include "tinyhttp/headers/thttp_header_Allow.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Allow_Events.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Authorization.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Call_ID.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Contact.h"
|
||||
//#include "tinyhttp/headers/thttp_header_CSeq.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Expires.h"
|
||||
//#include "tinyhttp/headers/thttp_header_From.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Max_Forwards.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Min_Expires.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Path.h"
|
||||
//#include "tinyhttp/headers/thttp_header_P_Access_Network_Info.h"
|
||||
//#include "tinyhttp/headers/thttp_header_P_Preferred_Identity.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Privacy.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Proxy_Authenticate.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Proxy_Authorization.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Record_Route.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Require.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Route.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Service_Route.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Supported.h"
|
||||
//#include "tinyhttp/headers/thttp_header_To.h"
|
||||
//#include "tinyhttp/headers/thttp_header_User_Agent.h"
|
||||
//#include "tinyhttp/headers/thttp_header_Via.h"
|
||||
//#include "tinyhttp/headers/thttp_header_WWW_Authenticate.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
%%{
|
||||
machine thttp_machine_parser_headers;
|
||||
|
||||
|
||||
# /*== Accept: ==*/
|
||||
action parse_header_Accept
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Accept NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Accept_Charset: ==*/
|
||||
action parse_header_Accept_Charset
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Accept_Charset NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Accept_Encoding: ==*/
|
||||
action parse_header_Accept_Encoding
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Accept_Encoding NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Accept_Language: ==*/
|
||||
action parse_header_Accept_Language
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Accept_Language NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Allow: ==*/
|
||||
action parse_header_Allow
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Allow NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Authorization: ==*/
|
||||
action parse_header_Authorization
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Authorization NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Cache_Control: ==*/
|
||||
action parse_header_Cache_Control
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Cache_Control NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Connection: ==*/
|
||||
action parse_header_Connection
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Connection NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Content_Encoding: ==*/
|
||||
action parse_header_Content_Encoding
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Content_Encoding NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Content_Language: ==*/
|
||||
action parse_header_Content_Language
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Content_Language NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Content_Length: ==*/
|
||||
action parse_header_Content_Length
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Content_Length NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Content_Location: ==*/
|
||||
action parse_header_Content_Location
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Content_Location NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Content_MD5: ==*/
|
||||
action parse_header_Content_MD5
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Content_MD5 NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Content_Range: ==*/
|
||||
action parse_header_Content_Range
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Content_Range NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Content_Type: ==*/
|
||||
action parse_header_Content_Type
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Content_Type NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Date: ==*/
|
||||
action parse_header_Date
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Date NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Expect: ==*/
|
||||
action parse_header_Expect
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Expect NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Expires: ==*/
|
||||
action parse_header_Expires
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Expires NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== From: ==*/
|
||||
action parse_header_From
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_From NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Host: ==*/
|
||||
action parse_header_Host
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Host NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== If_Match: ==*/
|
||||
action parse_header_If_Match
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_If_Match NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== If_Modified_Since: ==*/
|
||||
action parse_header_If_Modified_Since
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_If_Modified_Since NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== If_None_Match: ==*/
|
||||
action parse_header_If_None_Match
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_If_None_Match NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== If_Range: ==*/
|
||||
action parse_header_If_Range
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_If_Range NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== If_Unmodified_Since: ==*/
|
||||
action parse_header_If_Unmodified_Since
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_If_Unmodified_Since NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Last_Modified: ==*/
|
||||
action parse_header_Last_Modified
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Last_Modified NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Max_Forwards: ==*/
|
||||
action parse_header_Max_Forwards
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Max_Forwards NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Pragma: ==*/
|
||||
action parse_header_Pragma
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Pragma NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Proxy_Authorization: ==*/
|
||||
action parse_header_Proxy_Authorization
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Proxy_Authorizations NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Range: ==*/
|
||||
action parse_header_Range
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Range NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Referer: ==*/
|
||||
action parse_header_Referer
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Referer NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Transfer_Encoding: ==*/
|
||||
action parse_header_Transfer_Encoding
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Transfer_Encoding NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== TE: ==*/
|
||||
action parse_header_TE
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_TE NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Trailer: ==*/
|
||||
action parse_header_Trailer
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Trailer NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Upgrade: ==*/
|
||||
action parse_header_Upgrade
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Upgrade NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== User_Agent: ==*/
|
||||
action parse_header_User_Agent
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_User_Agent NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Via: ==*/
|
||||
action parse_header_Via
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Via NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== Warning: ==*/
|
||||
action parse_header_Warning
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_Warning NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
# /*== extension_header: ==*/
|
||||
action parse_header_extension_header
|
||||
{
|
||||
TSK_DEBUG_ERROR("parse_header_extension_header NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
|
||||
# Includes
|
||||
include thttp_machine_utils "./thttp_machine_utils.rl";
|
||||
include thttp_machine_header "./thttp_machine_header.rl";
|
||||
|
||||
# Entry point
|
||||
main := HEADER;
|
||||
}%%
|
||||
|
||||
int thttp_header_parse(tsk_ragel_state_t *state, thttp_message_t *message)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = state->tag_start;
|
||||
const char *pe = state->tag_end;
|
||||
const char *eof = pe;
|
||||
|
||||
%%write data;
|
||||
%%write init;
|
||||
%%write exec;
|
||||
|
||||
return ( cs >= %%{ write first_final; }%% ) ? 0 : -1;
|
||||
}
|
|
@ -0,0 +1,301 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_header_Authorization.c
|
||||
* @brief HTTP Authorization header.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinyhttp/headers/thttp_header_Authorization.h"
|
||||
|
||||
#include "tinyhttp/parsers/thttp_parser_url.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
#include "tsk_time.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**@defgroup thttp_header_Authorization_group HTTP Proxy-Authenticate header.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
%%{
|
||||
machine thttp_machine_parser_header_Authorization;
|
||||
|
||||
# Includes
|
||||
include thttp_machine_utils "./thttp_machine_utils.rl";
|
||||
|
||||
action tag
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
|
||||
action is_digest
|
||||
{
|
||||
#//FIXME: Only Digest is supported
|
||||
hdr_Authorization->scheme = tsk_strdup("Digest");
|
||||
}
|
||||
|
||||
action is_auth
|
||||
{
|
||||
THTTP_HEADER(hdr_Authorization)->type = thttp_htype_Authorization;
|
||||
}
|
||||
|
||||
action is_proxy
|
||||
{
|
||||
THTTP_HEADER(hdr_Authorization)->type = thttp_htype_Proxy_Authorization;
|
||||
}
|
||||
|
||||
action parse_username
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Authorization->username);
|
||||
tsk_strunquote(&hdr_Authorization->username);
|
||||
}
|
||||
|
||||
action parse_realm
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Authorization->realm);
|
||||
tsk_strunquote(&hdr_Authorization->realm);
|
||||
}
|
||||
|
||||
action parse_nonce
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Authorization->nonce);
|
||||
tsk_strunquote(&hdr_Authorization->nonce);
|
||||
}
|
||||
|
||||
action parse_uri
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Authorization->uri);
|
||||
}
|
||||
|
||||
action parse_response
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Authorization->response);
|
||||
tsk_strunquote(&hdr_Authorization->response);
|
||||
}
|
||||
|
||||
action parse_algorithm
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Authorization->algorithm);
|
||||
}
|
||||
|
||||
action parse_cnonce
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Authorization->cnonce);
|
||||
tsk_strunquote(&hdr_Authorization->cnonce);
|
||||
}
|
||||
|
||||
action parse_opaque
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Authorization->opaque);
|
||||
tsk_strunquote(&hdr_Authorization->opaque);
|
||||
}
|
||||
|
||||
action parse_qop
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Authorization->qop);
|
||||
//tsk_strunquote(&hdr_Authorization->qop);
|
||||
}
|
||||
|
||||
action parse_nc
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_Authorization->nc);
|
||||
}
|
||||
|
||||
action parse_param
|
||||
{
|
||||
TSK_PARSER_ADD_PARAM(THTTP_HEADER_PARAMS(hdr_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;
|
||||
Authorization = ("Authorization"i>is_auth | "Proxy-Authorization"i>is_proxy) HCOLON credentials;
|
||||
|
||||
# Entry point
|
||||
main := Authorization :>CRLF @eob;
|
||||
|
||||
}%%
|
||||
|
||||
int thttp_header_Authorization_tostring(const void* header, tsk_buffer_t* output)
|
||||
{
|
||||
if(header)
|
||||
{
|
||||
const thttp_header_Authorization_t *Authorization = header;
|
||||
if(Authorization && Authorization->scheme)
|
||||
{
|
||||
return tsk_buffer_appendEx(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",
|
||||
Authorization->scheme,
|
||||
|
||||
Authorization->username ? "username=\"" : "",
|
||||
Authorization->username ? Authorization->username : "",
|
||||
Authorization->username ? "\"" : "",
|
||||
|
||||
Authorization->realm ? ",realm=\"" : "",
|
||||
Authorization->realm ? Authorization->realm : "",
|
||||
Authorization->realm ? "\"" : "",
|
||||
|
||||
Authorization->nonce ? ",nonce=\"" : "",
|
||||
Authorization->nonce ? Authorization->nonce : "",
|
||||
Authorization->nonce ? "\"" : "",
|
||||
|
||||
Authorization->uri ? ",uri=\"" : "",
|
||||
Authorization->uri ? Authorization->uri : "",
|
||||
Authorization->uri ? "\"" : "",
|
||||
|
||||
Authorization->response ? ",response=\"" : "",
|
||||
Authorization->response ? Authorization->response : "",
|
||||
Authorization->response ? "\"" : "",
|
||||
|
||||
Authorization->algorithm ? ",algorithm=" : "",
|
||||
Authorization->algorithm ? Authorization->algorithm : "",
|
||||
|
||||
Authorization->cnonce ? ",cnonce=\"" : "",
|
||||
Authorization->cnonce ? Authorization->cnonce : "",
|
||||
Authorization->cnonce ? "\"" : "",
|
||||
|
||||
Authorization->opaque ? ",opaque=\"" : "",
|
||||
Authorization->opaque ? Authorization->opaque : "",
|
||||
Authorization->opaque ? "\"" : "",
|
||||
|
||||
Authorization->qop ? ",qop=" : "",
|
||||
Authorization->qop ? Authorization->qop : "",
|
||||
|
||||
Authorization->nc ? ",nc=" : "",
|
||||
Authorization->nc ? Authorization->nc : ""
|
||||
);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
thttp_header_Authorization_t *thttp_header_Authorization_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
thttp_header_Authorization_t *hdr_Authorization = THTTP_HEADER_AUTHORIZATION_CREATE();
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
%%write data;
|
||||
%%write init;
|
||||
%%write exec;
|
||||
|
||||
if( cs < %%{ write first_final; }%% )
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(hdr_Authorization);
|
||||
}
|
||||
|
||||
return hdr_Authorization;
|
||||
}
|
||||
|
||||
thttp_header_Proxy_Authorization_t *thttp_header_Proxy_Authorization_parse(const char *data, size_t size)
|
||||
{
|
||||
return thttp_header_Authorization_parse(data, size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// Authorization header object definition
|
||||
//
|
||||
|
||||
/**@ingroup thttp_header_Authorization_group
|
||||
*/
|
||||
static void* thttp_header_Authorization_create(void *self, va_list * app)
|
||||
{
|
||||
thttp_header_Authorization_t *Authorization = self;
|
||||
if(Authorization)
|
||||
{
|
||||
THTTP_HEADER(Authorization)->type = thttp_htype_Authorization;
|
||||
THTTP_HEADER(Authorization)->tostring = thttp_header_Authorization_tostring;
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new Authorization header.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup thttp_header_Authorization_group
|
||||
*/
|
||||
static void* thttp_header_Authorization_destroy(void *self)
|
||||
{
|
||||
thttp_header_Authorization_t *Authorization = self;
|
||||
if(Authorization)
|
||||
{
|
||||
TSK_FREE(Authorization->scheme);
|
||||
TSK_FREE(Authorization->username);
|
||||
TSK_FREE(Authorization->realm);
|
||||
TSK_FREE(Authorization->nonce);
|
||||
TSK_FREE(Authorization->uri);
|
||||
TSK_FREE(Authorization->response);
|
||||
TSK_FREE(Authorization->algorithm);
|
||||
TSK_FREE(Authorization->cnonce);
|
||||
TSK_FREE(Authorization->opaque);
|
||||
TSK_FREE(Authorization->qop);
|
||||
TSK_FREE(Authorization->nc);
|
||||
|
||||
TSK_OBJECT_SAFE_FREE(THTTP_HEADER_PARAMS(Authorization));
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null Authorization header.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t thttp_header_Authorization_def_s =
|
||||
{
|
||||
sizeof(thttp_header_Authorization_t),
|
||||
thttp_header_Authorization_create,
|
||||
thttp_header_Authorization_destroy,
|
||||
0
|
||||
};
|
||||
const void *thttp_header_Authorization_def_t = &thttp_header_Authorization_def_s;
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_header_Content_Length.c
|
||||
* @brief HTTP Content-Length header.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinyhttp/headers/thttp_header_Content_Length.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
|
||||
/**@defgroup thttp_header_Content_Length_group HTTP Content_Length header.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
%%{
|
||||
machine thttp_machine_parser_header_Content_Length;
|
||||
|
||||
# Includes
|
||||
include thttp_machine_utils "./thttp_machine_utils.rl";
|
||||
|
||||
action tag
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
|
||||
action parse_content_length
|
||||
{
|
||||
TSK_PARSER_SET_INTEGER(hdr_clength->length);
|
||||
}
|
||||
|
||||
action eob
|
||||
{
|
||||
}
|
||||
|
||||
Content_Length = "Content-Length"i HCOLON (DIGIT+)>tag %parse_content_length;
|
||||
|
||||
# Entry point
|
||||
main := Content_Length :>CRLF @eob;
|
||||
|
||||
}%%
|
||||
|
||||
int thttp_header_Content_Length_tostring(const void* header, tsk_buffer_t* output)
|
||||
{
|
||||
if(header)
|
||||
{
|
||||
const thttp_header_Content_Length_t *Content_Length = header;
|
||||
return tsk_buffer_appendEx(output, "%d", Content_Length->length);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
thttp_header_Content_Length_t *thttp_header_Content_Length_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
thttp_header_Content_Length_t *hdr_clength = THTTP_HEADER_CONTENT_LENGTH_CREATE(0);
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
%%write data;
|
||||
%%write init;
|
||||
%%write exec;
|
||||
|
||||
if( cs < %%{ write first_final; }%% )
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(hdr_clength);
|
||||
}
|
||||
|
||||
return hdr_clength;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// Content_Length header object definition
|
||||
//
|
||||
|
||||
/**@ingroup thttp_header_Content_Length_group
|
||||
*/
|
||||
static void* thttp_header_Content_Length_create(void *self, va_list * app)
|
||||
{
|
||||
thttp_header_Content_Length_t *Content_Length = self;
|
||||
if(Content_Length)
|
||||
{
|
||||
Content_Length->length = va_arg(*app, uint32_t);
|
||||
|
||||
THTTP_HEADER(Content_Length)->type = thttp_htype_Content_Length;
|
||||
THTTP_HEADER(Content_Length)->tostring = thttp_header_Content_Length_tostring;
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new Content_Length header.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup thttp_header_Content_Length_group
|
||||
*/
|
||||
static void* thttp_header_Content_Length_destroy(void *self)
|
||||
{
|
||||
thttp_header_Content_Length_t *Content_Length = self;
|
||||
if(Content_Length)
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(THTTP_HEADER_PARAMS(Content_Length));
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null Content_Length header.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t thttp_header_Content_Length_def_s =
|
||||
{
|
||||
sizeof(thttp_header_Content_Length_t),
|
||||
thttp_header_Content_Length_create,
|
||||
thttp_header_Content_Length_destroy,
|
||||
0
|
||||
};
|
||||
const void *thttp_header_Content_Length_def_t = &thttp_header_Content_Length_def_s;
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_header_Content_Type.c
|
||||
* @brief HTTP Content-Type header.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinyhttp/headers/thttp_header_Content_Type.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**@defgroup thttp_header_Content_Type_group HTTP Content_Type header.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
%%{
|
||||
machine thttp_machine_parser_header_Content_Type;
|
||||
|
||||
# Includes
|
||||
include thttp_machine_utils "./thttp_machine_utils.rl";
|
||||
|
||||
action tag
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
|
||||
action parse_content_type
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_ctype->type);
|
||||
}
|
||||
|
||||
action parse_param
|
||||
{
|
||||
TSK_PARSER_ADD_PARAM(THTTP_HEADER_PARAMS(hdr_ctype));
|
||||
}
|
||||
|
||||
action eob
|
||||
{
|
||||
}
|
||||
|
||||
extension_token = ietf_token | x_token;
|
||||
|
||||
m_attribute = token;
|
||||
m_value = token | quoted_string;
|
||||
m_parameter = (m_attribute EQUAL m_value)>tag %parse_param;
|
||||
|
||||
discrete_type = "text"i | "image"i | "audio"i | "video"i | "application"i | extension_token;
|
||||
composite_type = "message"i | "multipart"i | extension_token;
|
||||
m_type = discrete_type | composite_type;
|
||||
m_subtype = extension_token | iana_token;
|
||||
|
||||
media_type = (m_type SLASH m_subtype)@1 >tag %parse_content_type ((SEMI m_parameter)*)@0;
|
||||
|
||||
Content_Type = ( "Content-Type"i | "c"i ) HCOLON media_type;
|
||||
|
||||
# Entry point
|
||||
main := Content_Type :>CRLF @eob;
|
||||
|
||||
}%%
|
||||
|
||||
int thttp_header_Content_Type_tostring(const void* header, tsk_buffer_t* output)
|
||||
{
|
||||
if(header)
|
||||
{
|
||||
const thttp_header_Content_Type_t *Content_Type = header;
|
||||
return tsk_buffer_append(output, Content_Type->type, strlen(Content_Type->type));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
thttp_header_Content_Type_t *thttp_header_Content_Type_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
thttp_header_Content_Type_t *hdr_ctype = THTTP_HEADER_CONTENT_TYPE_CREATE();
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
%%write data;
|
||||
%%write init;
|
||||
%%write exec;
|
||||
|
||||
if( cs < %%{ write first_final; }%% )
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(hdr_ctype);
|
||||
}
|
||||
|
||||
return hdr_ctype;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// Content_Type header object definition
|
||||
//
|
||||
|
||||
/**@ingroup thttp_header_Content_Type_group
|
||||
*/
|
||||
static void* thttp_header_Content_Type_create(void *self, va_list * app)
|
||||
{
|
||||
thttp_header_Content_Type_t *Content_Type = self;
|
||||
if(Content_Type)
|
||||
{
|
||||
THTTP_HEADER(Content_Type)->type = thttp_htype_Content_Type;
|
||||
THTTP_HEADER(Content_Type)->tostring = thttp_header_Content_Type_tostring;
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new Content_Type header.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup thttp_header_Content_Type_group
|
||||
*/
|
||||
static void* thttp_header_Content_Type_destroy(void *self)
|
||||
{
|
||||
thttp_header_Content_Type_t *Content_Type = self;
|
||||
if(Content_Type)
|
||||
{
|
||||
TSK_FREE(Content_Type->type);
|
||||
TSK_OBJECT_SAFE_FREE(THTTP_HEADER_PARAMS(Content_Type));
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null Content_Type header.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t thttp_header_Content_Type_def_s =
|
||||
{
|
||||
sizeof(thttp_header_Content_Type_t),
|
||||
thttp_header_Content_Type_create,
|
||||
thttp_header_Content_Type_destroy,
|
||||
0
|
||||
};
|
||||
const void *thttp_header_Content_Type_def_t = &thttp_header_Content_Type_def_s;
|
|
@ -0,0 +1,263 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_header_WWW_Authenticate.c
|
||||
* @brief HTTP WWW-Authenticate header.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinyhttp/headers/thttp_header_WWW_Authenticate.h"
|
||||
|
||||
#include "tinyhttp/parsers/thttp_parser_url.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
#include "tsk_time.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**@defgroup thttp_header_WWW_Authenticate_group HTTP WWW-Authenticate header.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
%%{
|
||||
machine thttp_machine_parser_header_WWW_Authenticate;
|
||||
|
||||
# Includes
|
||||
include thttp_machine_utils "./thttp_machine_utils.rl";
|
||||
|
||||
action tag
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
|
||||
action is_digest
|
||||
{
|
||||
#//FIXME: Only Digest is supported
|
||||
hdr_WWW_Authenticate->scheme = tsk_strdup("Digest");
|
||||
}
|
||||
|
||||
action is_auth
|
||||
{
|
||||
THTTP_HEADER(hdr_WWW_Authenticate)->type = thttp_htype_WWW_Authenticate;
|
||||
}
|
||||
|
||||
action is_proxy
|
||||
{
|
||||
THTTP_HEADER(hdr_WWW_Authenticate)->type = thttp_htype_Proxy_Authenticate;
|
||||
}
|
||||
|
||||
action parse_realm
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->realm);
|
||||
tsk_strunquote(&hdr_WWW_Authenticate->realm);
|
||||
}
|
||||
|
||||
action parse_domain
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->domain);
|
||||
//tsk_strunquote(&hdr_WWW_Authenticate->domain);
|
||||
}
|
||||
|
||||
action parse_nonce
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->nonce);
|
||||
tsk_strunquote(&hdr_WWW_Authenticate->nonce);
|
||||
}
|
||||
|
||||
action parse_opaque
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->opaque);
|
||||
tsk_strunquote(&hdr_WWW_Authenticate->opaque);
|
||||
}
|
||||
|
||||
action parse_stale
|
||||
{
|
||||
hdr_WWW_Authenticate->stale = tsk_strniequals(tag_start, "true", 4);
|
||||
}
|
||||
|
||||
action parse_algorithm
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->algorithm);
|
||||
}
|
||||
|
||||
action parse_qop
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->qop);
|
||||
//tsk_strunquote(&hdr_WWW_Authenticate->qop);
|
||||
}
|
||||
|
||||
action parse_param
|
||||
{
|
||||
TSK_PARSER_ADD_PARAM(THTTP_HEADER_PARAMS(hdr_WWW_Authenticate));
|
||||
}
|
||||
|
||||
action eob
|
||||
{
|
||||
}
|
||||
|
||||
#FIXME: Only Digest (MD5, AKAv1-MD5 and AKAv2-MD5) is supported
|
||||
other_challenge = (any+);
|
||||
auth_param = generic_param>tag %parse_param;
|
||||
|
||||
realm = "realm"i EQUAL quoted_string>tag %parse_realm;
|
||||
domain = "domain"i EQUAL LDQUOT <: (any*)>tag %parse_domain :> RDQUOT;
|
||||
nonce = "nonce"i EQUAL quoted_string>tag %parse_nonce;
|
||||
opaque = "opaque"i EQUAL quoted_string>tag %parse_opaque;
|
||||
stale = "stale"i EQUAL ( "true"i | "false"i )>tag %parse_stale;
|
||||
algorithm = "algorithm"i EQUAL <:token>tag %parse_algorithm;
|
||||
qop_options = "qop"i EQUAL LDQUOT <: (any*)>tag %parse_qop :> RDQUOT;
|
||||
|
||||
digest_cln = (realm | domain | nonce | opaque | stale | algorithm | qop_options)@1 | auth_param@0;
|
||||
challenge = ( "Digest"i LWS digest_cln ( COMMA <:digest_cln )* )>is_digest | other_challenge;
|
||||
WWW_Authenticate = ("WWW-Authenticate"i>is_auth | "Proxy-Authenticate"i>is_proxy) HCOLON challenge;
|
||||
|
||||
# Entry point
|
||||
main := WWW_Authenticate :>CRLF @eob;
|
||||
|
||||
}%%
|
||||
|
||||
int thttp_header_WWW_Authenticate_tostring(const void* header, tsk_buffer_t* output)
|
||||
{
|
||||
if(header)
|
||||
{
|
||||
const thttp_header_WWW_Authenticate_t *WWW_Authenticate = header;
|
||||
if(WWW_Authenticate && WWW_Authenticate->scheme)
|
||||
{
|
||||
return tsk_buffer_appendEx(output, "%s realm=\"%s\"%s%s%s%s%s%s%s%s%s%s%s%s,stale=%s%s%s",
|
||||
WWW_Authenticate->scheme,
|
||||
WWW_Authenticate->realm ? WWW_Authenticate->realm : "",
|
||||
|
||||
WWW_Authenticate->domain ? ",domain=\"" : "",
|
||||
WWW_Authenticate->domain ? WWW_Authenticate->domain : "",
|
||||
WWW_Authenticate->domain ? "\"" : "",
|
||||
|
||||
|
||||
WWW_Authenticate->qop ? ",qop=\"" : "",
|
||||
WWW_Authenticate->qop ? WWW_Authenticate->qop : "",
|
||||
WWW_Authenticate->qop ? "\"" : "",
|
||||
|
||||
|
||||
WWW_Authenticate->nonce ? ",nonce=\"" : "",
|
||||
WWW_Authenticate->nonce ? WWW_Authenticate->nonce : "",
|
||||
WWW_Authenticate->nonce ? "\"" : "",
|
||||
|
||||
WWW_Authenticate->opaque ? ",opaque=\"" : "",
|
||||
WWW_Authenticate->opaque ? WWW_Authenticate->opaque : "",
|
||||
WWW_Authenticate->opaque ? "\"" : "",
|
||||
|
||||
WWW_Authenticate->stale ? "TRUE" : "FALSE",
|
||||
|
||||
WWW_Authenticate->algorithm ? ",algorithm=" : "",
|
||||
WWW_Authenticate->algorithm ? WWW_Authenticate->algorithm : ""
|
||||
);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
thttp_header_WWW_Authenticate_t *thttp_header_WWW_Authenticate_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
thttp_header_WWW_Authenticate_t *hdr_WWW_Authenticate = THTTP_HEADER_WWW_AUTHENTICATE_CREATE();
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
%%write data;
|
||||
%%write init;
|
||||
%%write exec;
|
||||
|
||||
if( cs < %%{ write first_final; }%% )
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(hdr_WWW_Authenticate);
|
||||
}
|
||||
|
||||
return hdr_WWW_Authenticate;
|
||||
}
|
||||
|
||||
thttp_header_Proxy_Authenticate_t *thttp_header_Proxy_Authenticate_parse(const char *data, size_t size)
|
||||
{
|
||||
return thttp_header_WWW_Authenticate_parse(data, size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// WWW_Authenticate header object definition
|
||||
//
|
||||
|
||||
/**@ingroup thttp_header_WWW_Authenticate_group
|
||||
*/
|
||||
static void* thttp_header_WWW_Authenticate_create(void *self, va_list * app)
|
||||
{
|
||||
thttp_header_WWW_Authenticate_t *WWW_Authenticate = self;
|
||||
if(WWW_Authenticate)
|
||||
{
|
||||
THTTP_HEADER(WWW_Authenticate)->type = thttp_htype_WWW_Authenticate;
|
||||
THTTP_HEADER(WWW_Authenticate)->tostring = thttp_header_WWW_Authenticate_tostring;
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new WWW_Authenticate header.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup thttp_header_WWW_Authenticate_group
|
||||
*/
|
||||
static void* thttp_header_WWW_Authenticate_destroy(void *self)
|
||||
{
|
||||
thttp_header_WWW_Authenticate_t *WWW_Authenticate = self;
|
||||
if(WWW_Authenticate)
|
||||
{
|
||||
TSK_FREE(WWW_Authenticate->scheme);
|
||||
TSK_FREE(WWW_Authenticate->realm);
|
||||
TSK_FREE(WWW_Authenticate->domain);
|
||||
TSK_FREE(WWW_Authenticate->nonce);
|
||||
TSK_FREE(WWW_Authenticate->opaque);
|
||||
TSK_FREE(WWW_Authenticate->algorithm);
|
||||
TSK_FREE(WWW_Authenticate->qop);
|
||||
|
||||
TSK_OBJECT_SAFE_FREE(THTTP_HEADER_PARAMS(WWW_Authenticate));
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null WWW_Authenticate header.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t thttp_header_WWW_Authenticate_def_s =
|
||||
{
|
||||
sizeof(thttp_header_WWW_Authenticate_t),
|
||||
thttp_header_WWW_Authenticate_create,
|
||||
thttp_header_WWW_Authenticate_destroy,
|
||||
0
|
||||
};
|
||||
const void *thttp_header_WWW_Authenticate_def_t = &thttp_header_WWW_Authenticate_def_s;
|
|
@ -0,0 +1,286 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_parser_message.c
|
||||
* @brief HTTP parser.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinyhttp/parsers/thttp_parser_message.h"
|
||||
#include "tinyhttp/parsers/thttp_parser_header.h"
|
||||
|
||||
#include "tinyhttp/parsers/thttp_parser_url.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
|
||||
static void thttp_message_parser_execute(tsk_ragel_state_t *state, thttp_message_t *message);
|
||||
static void thttp_message_parser_init(tsk_ragel_state_t *state);
|
||||
static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *message);
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
%%{
|
||||
machine thttp_machine_parser_message;
|
||||
|
||||
#/* Tag the buffer (start point). */
|
||||
action tag
|
||||
{
|
||||
state->tag_start = p;
|
||||
}
|
||||
|
||||
#/* HTTP method */
|
||||
action parse_method
|
||||
{
|
||||
int len;
|
||||
state->tag_end = p;
|
||||
len = (int)(state->tag_end - state->tag_start);
|
||||
|
||||
if(message->type == thttp_unknown)
|
||||
{
|
||||
message->type = thttp_request;
|
||||
if(!message->method)
|
||||
{
|
||||
message->method = tsk_calloc(1, len+1);
|
||||
memcpy(message->method, state->tag_start, len);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
state->cs = thttp_machine_parser_message_error;
|
||||
}
|
||||
}
|
||||
|
||||
#/* Request URI parsing */
|
||||
action parse_requesturl
|
||||
{
|
||||
int len;
|
||||
state->tag_end = p;
|
||||
len = (int)(state->tag_end - state->tag_start);
|
||||
|
||||
if(!message->url)
|
||||
{
|
||||
message->url = thttp_url_parse(state->tag_start, (size_t)len);
|
||||
}
|
||||
}
|
||||
|
||||
#/* Sip Version */
|
||||
action parse_httpversion
|
||||
{
|
||||
int len;
|
||||
state->tag_end = p;
|
||||
len = (int)(state->tag_end - state->tag_start);
|
||||
|
||||
if(!message->http_version)
|
||||
{
|
||||
message->http_version = tsk_calloc(1, len+1);
|
||||
memcpy(message->http_version, state->tag_start, len);
|
||||
}
|
||||
}
|
||||
|
||||
#/* Status Code */
|
||||
action parse_status_code
|
||||
{
|
||||
int len;
|
||||
state->tag_end = p;
|
||||
len = (int)(state->tag_end - state->tag_start);
|
||||
|
||||
if(message->type == thttp_unknown)
|
||||
{
|
||||
message->type = thttp_response;
|
||||
message->status_code = atoi(state->tag_start);
|
||||
}
|
||||
else
|
||||
{
|
||||
state->cs = thttp_machine_parser_message_error;
|
||||
}
|
||||
}
|
||||
|
||||
#/* Reason Phrase */
|
||||
action parse_reason_phrase
|
||||
{
|
||||
int len;
|
||||
state->tag_end = p;
|
||||
len = (int)(state->tag_end - state->tag_start);
|
||||
|
||||
if(!message->reason_phrase)
|
||||
{
|
||||
message->reason_phrase = tsk_calloc(1, len+1);
|
||||
memcpy(message->reason_phrase, state->tag_start, len);
|
||||
}
|
||||
}
|
||||
|
||||
#/* Parse http header */
|
||||
action parse_header
|
||||
{
|
||||
int len;
|
||||
state->tag_end = p;
|
||||
len = (int)(state->tag_end - state->tag_start);
|
||||
|
||||
if(thttp_header_parse(state, message))
|
||||
{
|
||||
//TSK_DEBUG_INFO("THTTP_MESSAGE_PARSER::PARSE_HEADER len=%d state=%d", len, state->cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to parse header - %s", state->tag_start);
|
||||
}
|
||||
}
|
||||
|
||||
#/* Parse http content/body. */
|
||||
#action parse_body
|
||||
#{
|
||||
# int len;
|
||||
# state->tag_end = p;
|
||||
# len = (int)(state->tag_end - state->tag_start);
|
||||
# TSK_DEBUG_ERROR("==THTTP_MESSAGE_PARSER::PARSE_BODY==");
|
||||
#}
|
||||
|
||||
#/* End-Of-Headers */
|
||||
action eoh
|
||||
{
|
||||
state->cs = cs;
|
||||
state->p = p;
|
||||
state->pe = pe;
|
||||
state->eof = eof;
|
||||
|
||||
thttp_message_parser_eoh(state, message);
|
||||
|
||||
cs = state->cs;
|
||||
p = state->p;
|
||||
pe = state->pe;
|
||||
eof = state->eof;
|
||||
}
|
||||
|
||||
# Includes
|
||||
include thttp_machine_utils "./thttp_machine_utils.rl";
|
||||
include thttp_machine_message "./thttp_machine_message.rl";
|
||||
|
||||
# Entry point
|
||||
main := HTTP_message;
|
||||
}%%
|
||||
|
||||
|
||||
/* Regel data */
|
||||
%%write data;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn int thttp_message_parse(tsk_ragel_state_t *state, thttp_message_t *result)
|
||||
///
|
||||
/// @brief Parse a HTTP message. Both requests and reponses messages.
|
||||
///
|
||||
/// @author Mamadou
|
||||
/// @date 12/4/2009
|
||||
///
|
||||
/// @param [in,out] state The ragel state to use.
|
||||
/// @param [out] result Non-null http message created using @ref THTTP_MESSAGE_CREATE. You must use @ref TSK_OBJECT_SAFE_FREE to
|
||||
/// free the result.
|
||||
///
|
||||
/// @return @ref zero if succeed and non-zero error code otherwise.
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int thttp_message_parse(tsk_ragel_state_t *state, thttp_message_t **result)
|
||||
{
|
||||
if(!state || state->pe <= state->p)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!*result)
|
||||
{
|
||||
*result = THTTP_MESSAGE_CREATE();
|
||||
}
|
||||
|
||||
/* Ragel init */
|
||||
thttp_message_parser_init(state);
|
||||
|
||||
/*
|
||||
* State mechine execution.
|
||||
*/
|
||||
thttp_message_parser_execute(state, *result);
|
||||
|
||||
/* Check result */
|
||||
|
||||
if( state->cs < %%{ write first_final; }%% )
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(*result);
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void thttp_message_parser_init(tsk_ragel_state_t *state)
|
||||
{
|
||||
int cs = 0;
|
||||
|
||||
/* Regel machine initialization. */
|
||||
%% write init;
|
||||
|
||||
state->cs = cs;
|
||||
}
|
||||
|
||||
static void thttp_message_parser_execute(tsk_ragel_state_t *state, thttp_message_t *message)
|
||||
{
|
||||
int cs = state->cs;
|
||||
const char *p = state->p;
|
||||
const char *pe = state->pe;
|
||||
const char *eof = state->eof;
|
||||
|
||||
%% write exec;
|
||||
|
||||
state->cs = cs;
|
||||
state->p = p;
|
||||
state->pe = pe;
|
||||
state->eof = eof;
|
||||
}
|
||||
|
||||
static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *message)
|
||||
{
|
||||
int cs = state->cs;
|
||||
const char *p = state->p;
|
||||
const char *pe = state->pe;
|
||||
const char *eof = state->eof;
|
||||
|
||||
if(message)
|
||||
{
|
||||
uint32_t clen = thttp_message_getContent_length(message);
|
||||
if((p+clen) <pe && !message->Content)
|
||||
{
|
||||
message->Content = TSK_BUFFER_CREATE((p+1), clen);
|
||||
p = (p+clen);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = (pe-1);
|
||||
}
|
||||
}
|
||||
//%%write eof;
|
||||
|
||||
state->cs = cs;
|
||||
state->p = p;
|
||||
state->pe = pe;
|
||||
state->eof = eof;
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_parser_url.c
|
||||
* @brief HTTP/HTTPS URL parser.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinyhttp/parsers/thttp_parser_url.h"
|
||||
|
||||
#include "tsk_string.h"
|
||||
#include "tsk_memory.h"
|
||||
#include "tsk_debug.h"
|
||||
|
||||
/**@defgroup thttp_parser_url_group HTTP/HTTPS URL parser.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
%%{
|
||||
machine thttp_machine_parser_url;
|
||||
|
||||
# Includes
|
||||
include thttp_machine_utils "./thttp_machine_utils.rl";
|
||||
|
||||
action tag
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
|
||||
#/* Sets URL type */
|
||||
action is_http { url->scheme = tsk_strdup("http"), url->type = url_http; }
|
||||
action is_https { url->scheme = tsk_strdup("https"), url->type = url_https; }
|
||||
|
||||
action eob
|
||||
{
|
||||
}
|
||||
|
||||
main := (("http:"i>tag %is_http | "https:"i>tag %is_https) any*) @eob;
|
||||
|
||||
}%%
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn thttp_url_t *thttp_url_parse(const char *data, size_t size)
|
||||
///
|
||||
/// @brief Parses HTTP/HTTPS URL.
|
||||
///
|
||||
/// @author Mamadou
|
||||
/// @date 12/6/2009
|
||||
///
|
||||
/// @param [in,out] data Data from which to parse the url.
|
||||
/// @param size The data size.
|
||||
///
|
||||
/// @return null if it fails, else the http/https/tel url.
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
thttp_url_t *thttp_url_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
|
||||
const char *ts = 0, *te = 0;
|
||||
int act =0;
|
||||
|
||||
thttp_url_t *url = THTTP_URL_CREATE(url_unknown);
|
||||
|
||||
const char *tag_start = 0;
|
||||
|
||||
%%write data;
|
||||
%%write init;
|
||||
%%write exec;
|
||||
|
||||
if( cs < %%{ write first_final; }%% )
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to parse HTTP/HTTPS URL.");
|
||||
TSK_OBJECT_SAFE_FREE(url);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
|
@ -137,7 +137,7 @@ int thttp_auth_digest_HA1sess(const char* username, const char* realm, const cha
|
|||
}
|
||||
|
||||
/**
|
||||
* @fn int thttp_auth_digest_HA2(const char* method, const char* uri, const char* entity_body,
|
||||
* @fn int thttp_auth_digest_HA2(const char* method, const char* url, const char* entity_body,
|
||||
* const char* qop, tsk_md5string_t* ha2)
|
||||
*
|
||||
* @brief Generates digest HA2 value as per RFC 2617 subclause 3.2.2.3.
|
||||
|
@ -146,31 +146,31 @@ int thttp_auth_digest_HA1sess(const char* username, const char* realm, const cha
|
|||
* @date 12/30/2009
|
||||
*
|
||||
* @param [in,out] method The HTTP/SIP method name.
|
||||
* @param [in,out] uri The HTTP URL or SIP URI of the request.
|
||||
* @param [in,out] url The HTTP URL or SIP URI of the request.
|
||||
* @param [in,out] entity_body The entity body.
|
||||
* @param [in,out] qop The Quality Of Protection.
|
||||
* @param [in,out] ha2 A pointer to the response.
|
||||
*
|
||||
* @return Zero if succeed and non-zero error code otherwise.
|
||||
**/
|
||||
int thttp_auth_digest_HA2(const char* method, const char* uri, const char* entity_body, const char* qop, tsk_md5string_t* ha2)
|
||||
int thttp_auth_digest_HA2(const char* method, const char* url, const char* entity_body, const char* qop, tsk_md5string_t* ha2)
|
||||
{
|
||||
int ret;
|
||||
/* RFC 2617 - 3.2.2.3 A2
|
||||
|
||||
If the "qop" directive's value is "auth" or is unspecified, then A2
|
||||
is:
|
||||
A2 = Method ":" digest-uri-value
|
||||
A2 = Method ":" digest-url-value
|
||||
|
||||
If the "qop" value is "auth-int", then A2 is:
|
||||
A2 = Method ":" digest-uri-value ":" H(entity-body)
|
||||
A2 = Method ":" digest-url-value ":" H(entity-body)
|
||||
*/
|
||||
|
||||
char *a2 = 0;
|
||||
|
||||
if(!qop || tsk_strempty(qop) || tsk_striequals(qop, "auth"))
|
||||
{
|
||||
tsk_sprintf(&a2, "%s:%s", method, uri);
|
||||
tsk_sprintf(&a2, "%s:%s", method, url);
|
||||
}
|
||||
else if(tsk_striequals(qop, "auth-int"))
|
||||
{
|
||||
|
@ -181,11 +181,11 @@ int thttp_auth_digest_HA2(const char* method, const char* uri, const char* entit
|
|||
{
|
||||
goto bail;
|
||||
}
|
||||
tsk_sprintf(&a2, "%s:%s:%s", method, uri, hEntity);
|
||||
tsk_sprintf(&a2, "%s:%s:%s", method, url, hEntity);
|
||||
}
|
||||
else
|
||||
{
|
||||
tsk_sprintf(&a2, "%s:%s:%s", method, uri, TSK_MD5_EMPTY);
|
||||
tsk_sprintf(&a2, "%s:%s:%s", method, url, TSK_MD5_EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,315 @@
|
|||
|
||||
/* #line 1 "thttp_parser_header_Content_Length.rl" */
|
||||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_header_Content_Length.c
|
||||
* @brief HTTP Content-Length header.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinyhttp/headers/thttp_header_Content_Length.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
|
||||
/**@defgroup thttp_header_Content_Length_group HTTP Content_Length header.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
|
||||
/* #line 66 "thttp_parser_header_Content_Length.rl" */
|
||||
|
||||
|
||||
int thttp_header_Content_Length_tostring(const void* header, tsk_buffer_t* output)
|
||||
{
|
||||
if(header)
|
||||
{
|
||||
const thttp_header_Content_Length_t *Content_Length = header;
|
||||
return tsk_buffer_appendEx(output, "%d", Content_Length->length);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
thttp_header_Content_Length_t *thttp_header_Content_Length_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
thttp_header_Content_Length_t *hdr_clength = THTTP_HEADER_CONTENT_LENGTH_CREATE(0);
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
|
||||
/* #line 70 "../src/headers/thttp_header_Content_Length.c" */
|
||||
static const char _thttp_machine_parser_header_Content_Length_actions[] = {
|
||||
0, 1, 0, 1, 1, 1, 2
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Length_key_offsets[] = {
|
||||
0, 0, 2, 4, 6, 8, 10, 12,
|
||||
14, 15, 17, 19, 21, 23, 25, 27,
|
||||
30, 35, 36, 38, 42, 45, 46
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Length_trans_keys[] = {
|
||||
67, 99, 79, 111, 78, 110, 84, 116,
|
||||
69, 101, 78, 110, 84, 116, 45, 76,
|
||||
108, 69, 101, 78, 110, 71, 103, 84,
|
||||
116, 72, 104, 9, 32, 58, 9, 13,
|
||||
32, 48, 57, 10, 9, 32, 9, 32,
|
||||
48, 57, 13, 48, 57, 10, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Length_single_lengths[] = {
|
||||
0, 2, 2, 2, 2, 2, 2, 2,
|
||||
1, 2, 2, 2, 2, 2, 2, 3,
|
||||
3, 1, 2, 2, 1, 1, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Length_range_lengths[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 1, 1, 0, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Length_index_offsets[] = {
|
||||
0, 0, 3, 6, 9, 12, 15, 18,
|
||||
21, 23, 26, 29, 32, 35, 38, 41,
|
||||
45, 50, 52, 55, 59, 62, 64
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Length_indicies[] = {
|
||||
0, 0, 1, 2, 2, 1, 3, 3,
|
||||
1, 4, 4, 1, 5, 5, 1, 6,
|
||||
6, 1, 7, 7, 1, 8, 1, 9,
|
||||
9, 1, 10, 10, 1, 11, 11, 1,
|
||||
12, 12, 1, 13, 13, 1, 14, 14,
|
||||
1, 14, 14, 15, 1, 15, 16, 15,
|
||||
17, 1, 18, 1, 19, 19, 1, 19,
|
||||
19, 17, 1, 20, 21, 1, 22, 1,
|
||||
1, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Length_trans_targs[] = {
|
||||
2, 0, 3, 4, 5, 6, 7, 8,
|
||||
9, 10, 11, 12, 13, 14, 15, 16,
|
||||
17, 20, 18, 19, 21, 20, 22
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Length_trans_actions[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 0, 0, 3, 0, 5
|
||||
};
|
||||
|
||||
static const int thttp_machine_parser_header_Content_Length_start = 1;
|
||||
static const int thttp_machine_parser_header_Content_Length_first_final = 22;
|
||||
static const int thttp_machine_parser_header_Content_Length_error = 0;
|
||||
|
||||
static const int thttp_machine_parser_header_Content_Length_en_main = 1;
|
||||
|
||||
|
||||
/* #line 90 "thttp_parser_header_Content_Length.rl" */
|
||||
|
||||
/* #line 141 "../src/headers/thttp_header_Content_Length.c" */
|
||||
{
|
||||
cs = thttp_machine_parser_header_Content_Length_start;
|
||||
}
|
||||
|
||||
/* #line 91 "thttp_parser_header_Content_Length.rl" */
|
||||
|
||||
/* #line 148 "../src/headers/thttp_header_Content_Length.c" */
|
||||
{
|
||||
int _klen;
|
||||
unsigned int _trans;
|
||||
const char *_acts;
|
||||
unsigned int _nacts;
|
||||
const char *_keys;
|
||||
|
||||
if ( p == pe )
|
||||
goto _test_eof;
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
_resume:
|
||||
_keys = _thttp_machine_parser_header_Content_Length_trans_keys + _thttp_machine_parser_header_Content_Length_key_offsets[cs];
|
||||
_trans = _thttp_machine_parser_header_Content_Length_index_offsets[cs];
|
||||
|
||||
_klen = _thttp_machine_parser_header_Content_Length_single_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + _klen - 1;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + ((_upper-_lower) >> 1);
|
||||
if ( (*p) < *_mid )
|
||||
_upper = _mid - 1;
|
||||
else if ( (*p) > *_mid )
|
||||
_lower = _mid + 1;
|
||||
else {
|
||||
_trans += (_mid - _keys);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_keys += _klen;
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_klen = _thttp_machine_parser_header_Content_Length_range_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + (_klen<<1) - 2;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
|
||||
if ( (*p) < _mid[0] )
|
||||
_upper = _mid - 2;
|
||||
else if ( (*p) > _mid[1] )
|
||||
_lower = _mid + 2;
|
||||
else {
|
||||
_trans += ((_mid - _keys)>>1);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_match:
|
||||
_trans = _thttp_machine_parser_header_Content_Length_indicies[_trans];
|
||||
cs = _thttp_machine_parser_header_Content_Length_trans_targs[_trans];
|
||||
|
||||
if ( _thttp_machine_parser_header_Content_Length_trans_actions[_trans] == 0 )
|
||||
goto _again;
|
||||
|
||||
_acts = _thttp_machine_parser_header_Content_Length_actions + _thttp_machine_parser_header_Content_Length_trans_actions[_trans];
|
||||
_nacts = (unsigned int) *_acts++;
|
||||
while ( _nacts-- > 0 )
|
||||
{
|
||||
switch ( *_acts++ )
|
||||
{
|
||||
case 0:
|
||||
/* #line 48 "thttp_parser_header_Content_Length.rl" */
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* #line 53 "thttp_parser_header_Content_Length.rl" */
|
||||
{
|
||||
TSK_PARSER_SET_INTEGER(hdr_clength->length);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
/* #line 58 "thttp_parser_header_Content_Length.rl" */
|
||||
{
|
||||
}
|
||||
break;
|
||||
/* #line 239 "../src/headers/thttp_header_Content_Length.c" */
|
||||
}
|
||||
}
|
||||
|
||||
_again:
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
if ( ++p != pe )
|
||||
goto _resume;
|
||||
_test_eof: {}
|
||||
_out: {}
|
||||
}
|
||||
|
||||
/* #line 92 "thttp_parser_header_Content_Length.rl" */
|
||||
|
||||
if( cs <
|
||||
/* #line 255 "../src/headers/thttp_header_Content_Length.c" */
|
||||
22
|
||||
/* #line 93 "thttp_parser_header_Content_Length.rl" */
|
||||
)
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(hdr_clength);
|
||||
}
|
||||
|
||||
return hdr_clength;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// Content_Length header object definition
|
||||
//
|
||||
|
||||
/**@ingroup thttp_header_Content_Length_group
|
||||
*/
|
||||
static void* thttp_header_Content_Length_create(void *self, va_list * app)
|
||||
{
|
||||
thttp_header_Content_Length_t *Content_Length = self;
|
||||
if(Content_Length)
|
||||
{
|
||||
Content_Length->length = va_arg(*app, uint32_t);
|
||||
|
||||
THTTP_HEADER(Content_Length)->type = thttp_htype_Content_Length;
|
||||
THTTP_HEADER(Content_Length)->tostring = thttp_header_Content_Length_tostring;
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new Content_Length header.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup thttp_header_Content_Length_group
|
||||
*/
|
||||
static void* thttp_header_Content_Length_destroy(void *self)
|
||||
{
|
||||
thttp_header_Content_Length_t *Content_Length = self;
|
||||
if(Content_Length)
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(THTTP_HEADER_PARAMS(Content_Length));
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null Content_Length header.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t thttp_header_Content_Length_def_s =
|
||||
{
|
||||
sizeof(thttp_header_Content_Length_t),
|
||||
thttp_header_Content_Length_create,
|
||||
thttp_header_Content_Length_destroy,
|
||||
0
|
||||
};
|
||||
const void *thttp_header_Content_Length_def_t = &thttp_header_Content_Length_def_s;
|
|
@ -0,0 +1,420 @@
|
|||
|
||||
/* #line 1 "thttp_parser_header_Content_Type.rl" */
|
||||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_header_Content_Type.c
|
||||
* @brief HTTP Content-Type header.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinyhttp/headers/thttp_header_Content_Type.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**@defgroup thttp_header_Content_Type_group HTTP Content_Type header.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
|
||||
/* #line 86 "thttp_parser_header_Content_Type.rl" */
|
||||
|
||||
|
||||
int thttp_header_Content_Type_tostring(const void* header, tsk_buffer_t* output)
|
||||
{
|
||||
if(header)
|
||||
{
|
||||
const thttp_header_Content_Type_t *Content_Type = header;
|
||||
return tsk_buffer_append(output, Content_Type->type, strlen(Content_Type->type));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
thttp_header_Content_Type_t *thttp_header_Content_Type_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
thttp_header_Content_Type_t *hdr_ctype = THTTP_HEADER_CONTENT_TYPE_CREATE();
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
|
||||
/* #line 72 "../src/headers/thttp_header_Content_Type.c" */
|
||||
static const char _thttp_machine_parser_header_Content_Type_actions[] = {
|
||||
0, 1, 0, 1, 1, 1, 2, 1,
|
||||
3
|
||||
};
|
||||
|
||||
static const short _thttp_machine_parser_header_Content_Type_key_offsets[] = {
|
||||
0, 0, 2, 7, 10, 27, 28, 30,
|
||||
46, 62, 66, 67, 69, 72, 89, 90,
|
||||
92, 108, 126, 130, 131, 133, 136, 153,
|
||||
154, 156, 172, 190, 194, 195, 197, 200,
|
||||
218, 219, 221, 239, 240, 242, 245, 261,
|
||||
263, 265, 267, 269, 271, 272, 274, 278,
|
||||
279, 285, 303, 305, 307, 309, 311, 313,
|
||||
314, 316, 318, 320, 322
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Type_trans_keys[] = {
|
||||
67, 99, 9, 32, 58, 79, 111, 9,
|
||||
32, 58, 9, 13, 32, 33, 37, 39,
|
||||
126, 42, 43, 45, 46, 48, 57, 65,
|
||||
90, 95, 122, 10, 9, 32, 9, 32,
|
||||
33, 37, 39, 126, 42, 43, 45, 46,
|
||||
48, 57, 65, 90, 95, 122, 9, 13,
|
||||
32, 33, 37, 39, 47, 126, 42, 43,
|
||||
45, 57, 65, 90, 95, 122, 9, 13,
|
||||
32, 47, 10, 9, 32, 9, 32, 47,
|
||||
9, 13, 32, 33, 37, 39, 126, 42,
|
||||
43, 45, 46, 48, 57, 65, 90, 95,
|
||||
122, 10, 9, 32, 9, 32, 33, 37,
|
||||
39, 126, 42, 43, 45, 46, 48, 57,
|
||||
65, 90, 95, 122, 9, 13, 32, 33,
|
||||
37, 39, 59, 126, 42, 43, 45, 46,
|
||||
48, 57, 65, 90, 95, 122, 9, 13,
|
||||
32, 59, 10, 9, 32, 9, 32, 59,
|
||||
9, 13, 32, 33, 37, 39, 126, 42,
|
||||
43, 45, 46, 48, 57, 65, 90, 95,
|
||||
122, 10, 9, 32, 9, 32, 33, 37,
|
||||
39, 126, 42, 43, 45, 46, 48, 57,
|
||||
65, 90, 95, 122, 9, 13, 32, 33,
|
||||
37, 39, 61, 126, 42, 43, 45, 46,
|
||||
48, 57, 65, 90, 95, 122, 9, 13,
|
||||
32, 61, 10, 9, 32, 9, 32, 61,
|
||||
9, 13, 32, 33, 34, 37, 39, 126,
|
||||
42, 43, 45, 46, 48, 57, 65, 90,
|
||||
95, 122, 10, 9, 32, 9, 13, 32,
|
||||
33, 34, 37, 39, 126, 42, 43, 45,
|
||||
46, 48, 57, 65, 90, 95, 122, 10,
|
||||
9, 32, 9, 32, 34, 9, 13, 34,
|
||||
92, -64, -33, -32, -17, -16, -9, -8,
|
||||
-5, -4, -3, 32, 126, -128, -65, -128,
|
||||
-65, -128, -65, -128, -65, -128, -65, 10,
|
||||
9, 32, 9, 13, 32, 59, 10, 0,
|
||||
9, 11, 12, 14, 127, 9, 13, 32,
|
||||
33, 37, 39, 59, 126, 42, 43, 45,
|
||||
46, 48, 57, 65, 90, 95, 122, 78,
|
||||
110, 84, 116, 69, 101, 78, 110, 84,
|
||||
116, 45, 84, 116, 89, 121, 80, 112,
|
||||
69, 101, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Type_single_lengths[] = {
|
||||
0, 2, 5, 3, 7, 1, 2, 6,
|
||||
8, 4, 1, 2, 3, 7, 1, 2,
|
||||
6, 8, 4, 1, 2, 3, 7, 1,
|
||||
2, 6, 8, 4, 1, 2, 3, 8,
|
||||
1, 2, 8, 1, 2, 3, 4, 0,
|
||||
0, 0, 0, 0, 1, 2, 4, 1,
|
||||
0, 8, 2, 2, 2, 2, 2, 1,
|
||||
2, 2, 2, 2, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Type_range_lengths[] = {
|
||||
0, 0, 0, 0, 5, 0, 0, 5,
|
||||
4, 0, 0, 0, 0, 5, 0, 0,
|
||||
5, 5, 0, 0, 0, 0, 5, 0,
|
||||
0, 5, 5, 0, 0, 0, 0, 5,
|
||||
0, 0, 5, 0, 0, 0, 6, 1,
|
||||
1, 1, 1, 1, 0, 0, 0, 0,
|
||||
3, 5, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const short _thttp_machine_parser_header_Content_Type_index_offsets[] = {
|
||||
0, 0, 3, 9, 13, 26, 28, 31,
|
||||
43, 56, 61, 63, 66, 70, 83, 85,
|
||||
88, 100, 114, 119, 121, 124, 128, 141,
|
||||
143, 146, 158, 172, 177, 179, 182, 186,
|
||||
200, 202, 205, 219, 221, 224, 228, 239,
|
||||
241, 243, 245, 247, 249, 251, 254, 259,
|
||||
261, 265, 279, 282, 285, 288, 291, 294,
|
||||
296, 299, 302, 305, 308
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Type_indicies[] = {
|
||||
0, 0, 1, 2, 2, 3, 4, 4,
|
||||
1, 2, 2, 3, 1, 3, 5, 3,
|
||||
6, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 1, 7, 1, 8, 8, 1, 8,
|
||||
8, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 1, 9, 10, 9, 11, 11,
|
||||
11, 12, 11, 11, 11, 11, 11, 1,
|
||||
9, 10, 9, 12, 1, 13, 1, 14,
|
||||
14, 1, 14, 14, 12, 1, 12, 15,
|
||||
12, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 1, 17, 1, 18, 18, 1,
|
||||
18, 18, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 1, 19, 20, 19, 16,
|
||||
16, 16, 21, 16, 16, 16, 16, 16,
|
||||
16, 1, 22, 23, 22, 24, 1, 25,
|
||||
1, 26, 26, 1, 26, 26, 24, 1,
|
||||
24, 27, 24, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 1, 29, 1, 30,
|
||||
30, 1, 30, 30, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 1, 31, 32,
|
||||
31, 33, 33, 33, 34, 33, 33, 33,
|
||||
33, 33, 33, 1, 31, 32, 31, 34,
|
||||
1, 35, 1, 36, 36, 1, 36, 36,
|
||||
34, 1, 34, 37, 34, 38, 39, 38,
|
||||
38, 38, 38, 38, 38, 38, 38, 1,
|
||||
40, 1, 41, 41, 1, 41, 42, 41,
|
||||
38, 39, 38, 38, 38, 38, 38, 38,
|
||||
38, 38, 1, 43, 1, 44, 44, 1,
|
||||
44, 44, 39, 1, 39, 50, 51, 52,
|
||||
45, 46, 47, 48, 49, 39, 1, 39,
|
||||
1, 45, 1, 46, 1, 47, 1, 48,
|
||||
1, 53, 1, 39, 39, 1, 54, 55,
|
||||
54, 56, 1, 57, 1, 39, 39, 39,
|
||||
1, 54, 55, 54, 38, 38, 38, 56,
|
||||
38, 38, 38, 38, 38, 38, 1, 58,
|
||||
58, 1, 59, 59, 1, 60, 60, 1,
|
||||
61, 61, 1, 62, 62, 1, 63, 1,
|
||||
64, 64, 1, 65, 65, 1, 66, 66,
|
||||
1, 2, 2, 1, 1, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Type_trans_targs[] = {
|
||||
2, 0, 3, 4, 50, 5, 8, 6,
|
||||
7, 9, 10, 8, 13, 11, 12, 14,
|
||||
17, 15, 16, 18, 47, 22, 18, 19,
|
||||
22, 20, 21, 23, 26, 24, 25, 27,
|
||||
28, 26, 31, 29, 30, 32, 49, 38,
|
||||
33, 34, 35, 36, 37, 39, 40, 41,
|
||||
42, 43, 44, 46, 48, 45, 18, 47,
|
||||
22, 60, 51, 52, 53, 54, 55, 56,
|
||||
57, 58, 59
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_header_Content_Type_trans_actions[] = {
|
||||
0, 0, 0, 0, 0, 0, 1, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 3, 3, 3, 0, 0,
|
||||
0, 0, 0, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 5, 5,
|
||||
5, 7, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0
|
||||
};
|
||||
|
||||
static const int thttp_machine_parser_header_Content_Type_start = 1;
|
||||
static const int thttp_machine_parser_header_Content_Type_first_final = 60;
|
||||
static const int thttp_machine_parser_header_Content_Type_error = 0;
|
||||
|
||||
static const int thttp_machine_parser_header_Content_Type_en_main = 1;
|
||||
|
||||
|
||||
/* #line 110 "thttp_parser_header_Content_Type.rl" */
|
||||
|
||||
/* #line 241 "../src/headers/thttp_header_Content_Type.c" */
|
||||
{
|
||||
cs = thttp_machine_parser_header_Content_Type_start;
|
||||
}
|
||||
|
||||
/* #line 111 "thttp_parser_header_Content_Type.rl" */
|
||||
|
||||
/* #line 248 "../src/headers/thttp_header_Content_Type.c" */
|
||||
{
|
||||
int _klen;
|
||||
unsigned int _trans;
|
||||
const char *_acts;
|
||||
unsigned int _nacts;
|
||||
const char *_keys;
|
||||
|
||||
if ( p == pe )
|
||||
goto _test_eof;
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
_resume:
|
||||
_keys = _thttp_machine_parser_header_Content_Type_trans_keys + _thttp_machine_parser_header_Content_Type_key_offsets[cs];
|
||||
_trans = _thttp_machine_parser_header_Content_Type_index_offsets[cs];
|
||||
|
||||
_klen = _thttp_machine_parser_header_Content_Type_single_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + _klen - 1;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + ((_upper-_lower) >> 1);
|
||||
if ( (*p) < *_mid )
|
||||
_upper = _mid - 1;
|
||||
else if ( (*p) > *_mid )
|
||||
_lower = _mid + 1;
|
||||
else {
|
||||
_trans += (_mid - _keys);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_keys += _klen;
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_klen = _thttp_machine_parser_header_Content_Type_range_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + (_klen<<1) - 2;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
|
||||
if ( (*p) < _mid[0] )
|
||||
_upper = _mid - 2;
|
||||
else if ( (*p) > _mid[1] )
|
||||
_lower = _mid + 2;
|
||||
else {
|
||||
_trans += ((_mid - _keys)>>1);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_match:
|
||||
_trans = _thttp_machine_parser_header_Content_Type_indicies[_trans];
|
||||
cs = _thttp_machine_parser_header_Content_Type_trans_targs[_trans];
|
||||
|
||||
if ( _thttp_machine_parser_header_Content_Type_trans_actions[_trans] == 0 )
|
||||
goto _again;
|
||||
|
||||
_acts = _thttp_machine_parser_header_Content_Type_actions + _thttp_machine_parser_header_Content_Type_trans_actions[_trans];
|
||||
_nacts = (unsigned int) *_acts++;
|
||||
while ( _nacts-- > 0 )
|
||||
{
|
||||
switch ( *_acts++ )
|
||||
{
|
||||
case 0:
|
||||
/* #line 50 "thttp_parser_header_Content_Type.rl" */
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* #line 55 "thttp_parser_header_Content_Type.rl" */
|
||||
{
|
||||
TSK_PARSER_SET_STRING(hdr_ctype->type);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
/* #line 60 "thttp_parser_header_Content_Type.rl" */
|
||||
{
|
||||
TSK_PARSER_ADD_PARAM(THTTP_HEADER_PARAMS(hdr_ctype));
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
/* #line 65 "thttp_parser_header_Content_Type.rl" */
|
||||
{
|
||||
}
|
||||
break;
|
||||
/* #line 345 "../src/headers/thttp_header_Content_Type.c" */
|
||||
}
|
||||
}
|
||||
|
||||
_again:
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
if ( ++p != pe )
|
||||
goto _resume;
|
||||
_test_eof: {}
|
||||
_out: {}
|
||||
}
|
||||
|
||||
/* #line 112 "thttp_parser_header_Content_Type.rl" */
|
||||
|
||||
if( cs <
|
||||
/* #line 361 "../src/headers/thttp_header_Content_Type.c" */
|
||||
60
|
||||
/* #line 113 "thttp_parser_header_Content_Type.rl" */
|
||||
)
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(hdr_ctype);
|
||||
}
|
||||
|
||||
return hdr_ctype;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// Content_Type header object definition
|
||||
//
|
||||
|
||||
/**@ingroup thttp_header_Content_Type_group
|
||||
*/
|
||||
static void* thttp_header_Content_Type_create(void *self, va_list * app)
|
||||
{
|
||||
thttp_header_Content_Type_t *Content_Type = self;
|
||||
if(Content_Type)
|
||||
{
|
||||
THTTP_HEADER(Content_Type)->type = thttp_htype_Content_Type;
|
||||
THTTP_HEADER(Content_Type)->tostring = thttp_header_Content_Type_tostring;
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new Content_Type header.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup thttp_header_Content_Type_group
|
||||
*/
|
||||
static void* thttp_header_Content_Type_destroy(void *self)
|
||||
{
|
||||
thttp_header_Content_Type_t *Content_Type = self;
|
||||
if(Content_Type)
|
||||
{
|
||||
TSK_FREE(Content_Type->type);
|
||||
TSK_OBJECT_SAFE_FREE(THTTP_HEADER_PARAMS(Content_Type));
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null Content_Type header.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t thttp_header_Content_Type_def_s =
|
||||
{
|
||||
sizeof(thttp_header_Content_Type_t),
|
||||
thttp_header_Content_Type_create,
|
||||
thttp_header_Content_Type_destroy,
|
||||
0
|
||||
};
|
||||
const void *thttp_header_Content_Type_def_t = &thttp_header_Content_Type_def_s;
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,488 @@
|
|||
|
||||
/* #line 1 "thttp_parser_message.rl" */
|
||||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_parser_message.c
|
||||
* @brief HTTP parser.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinyhttp/parsers/thttp_parser_message.h"
|
||||
#include "tinyhttp/parsers/thttp_parser_header.h"
|
||||
|
||||
#include "tinyhttp/parsers/thttp_parser_url.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
|
||||
static void thttp_message_parser_execute(tsk_ragel_state_t *state, thttp_message_t *message);
|
||||
static void thttp_message_parser_init(tsk_ragel_state_t *state);
|
||||
static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *message);
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
|
||||
/* #line 183 "thttp_parser_message.rl" */
|
||||
|
||||
|
||||
|
||||
/* Regel data */
|
||||
|
||||
/* #line 55 "../src/parsers/thttp_parser_message.c" */
|
||||
static const char _thttp_machine_parser_message_actions[] = {
|
||||
0, 1, 0, 1, 1, 1, 2, 1,
|
||||
3, 1, 4, 1, 5, 1, 6, 2,
|
||||
0, 5, 2, 6, 0
|
||||
};
|
||||
|
||||
static const unsigned char _thttp_machine_parser_message_key_offsets[] = {
|
||||
0, 0, 16, 31, 35, 47, 50, 50,
|
||||
51, 53, 55, 57, 59, 60, 62, 65,
|
||||
67, 70, 71, 72, 73, 74, 75, 76,
|
||||
93, 110, 127, 141, 143, 146, 148, 151,
|
||||
153, 155, 157, 158, 184, 210, 212, 214,
|
||||
216, 218, 220, 226, 232
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_message_trans_keys[] = {
|
||||
33, 37, 39, 72, 104, 126, 42, 43,
|
||||
45, 46, 48, 57, 65, 90, 95, 122,
|
||||
32, 33, 37, 39, 126, 42, 43, 45,
|
||||
46, 48, 57, 65, 90, 95, 122, 65,
|
||||
90, 97, 122, 9, 32, 43, 58, 45,
|
||||
46, 48, 57, 65, 90, 97, 122, 9,
|
||||
32, 58, 32, 72, 104, 84, 116, 84,
|
||||
116, 80, 112, 47, 48, 57, 46, 48,
|
||||
57, 48, 57, 13, 48, 57, 10, 13,
|
||||
13, 10, 13, 10, 32, 33, 37, 39,
|
||||
84, 116, 126, 42, 43, 45, 46, 48,
|
||||
57, 65, 90, 95, 122, 32, 33, 37,
|
||||
39, 84, 116, 126, 42, 43, 45, 46,
|
||||
48, 57, 65, 90, 95, 122, 32, 33,
|
||||
37, 39, 80, 112, 126, 42, 43, 45,
|
||||
46, 48, 57, 65, 90, 95, 122, 32,
|
||||
33, 37, 39, 47, 126, 42, 43, 45,
|
||||
57, 65, 90, 95, 122, 48, 57, 46,
|
||||
48, 57, 48, 57, 32, 48, 57, 48,
|
||||
57, 48, 57, 48, 57, 32, 13, 37,
|
||||
60, 62, 96, 127, -64, -33, -32, -17,
|
||||
-16, -9, -8, -5, -4, -3, -2, 8,
|
||||
10, 31, 34, 35, 91, 94, 123, 125,
|
||||
13, 37, 60, 62, 96, 127, -64, -33,
|
||||
-32, -17, -16, -9, -8, -5, -4, -3,
|
||||
-2, 8, 10, 31, 34, 35, 91, 94,
|
||||
123, 125, -128, -65, -128, -65, -128, -65,
|
||||
-128, -65, -128, -65, 48, 57, 65, 70,
|
||||
97, 102, 48, 57, 65, 70, 97, 102,
|
||||
0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_message_single_lengths[] = {
|
||||
0, 6, 5, 0, 4, 3, 0, 1,
|
||||
2, 2, 2, 2, 1, 0, 1, 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 7,
|
||||
7, 7, 6, 0, 1, 0, 1, 0,
|
||||
0, 0, 1, 6, 6, 0, 0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_message_range_lengths[] = {
|
||||
0, 5, 5, 2, 4, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 1, 1, 1,
|
||||
1, 0, 0, 0, 0, 0, 0, 5,
|
||||
5, 5, 4, 1, 1, 1, 1, 1,
|
||||
1, 1, 0, 10, 10, 1, 1, 1,
|
||||
1, 1, 3, 3, 0
|
||||
};
|
||||
|
||||
static const unsigned char _thttp_machine_parser_message_index_offsets[] = {
|
||||
0, 0, 12, 23, 26, 35, 39, 40,
|
||||
42, 45, 48, 51, 54, 56, 58, 61,
|
||||
63, 66, 68, 70, 72, 74, 76, 78,
|
||||
91, 104, 117, 128, 130, 133, 135, 138,
|
||||
140, 142, 144, 146, 163, 180, 182, 184,
|
||||
186, 188, 190, 194, 198
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_message_indicies[] = {
|
||||
0, 0, 0, 2, 2, 0, 0, 0,
|
||||
0, 0, 0, 1, 3, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 1, 5,
|
||||
5, 1, 6, 6, 7, 8, 7, 7,
|
||||
7, 7, 1, 6, 6, 8, 1, 9,
|
||||
10, 9, 11, 11, 1, 12, 12, 1,
|
||||
13, 13, 1, 14, 14, 1, 15, 1,
|
||||
16, 1, 17, 16, 1, 18, 1, 19,
|
||||
18, 1, 20, 1, 22, 21, 24, 23,
|
||||
25, 1, 27, 26, 28, 1, 3, 4,
|
||||
4, 4, 29, 29, 4, 4, 4, 4,
|
||||
4, 4, 1, 3, 4, 4, 4, 30,
|
||||
30, 4, 4, 4, 4, 4, 4, 1,
|
||||
3, 4, 4, 4, 31, 31, 4, 4,
|
||||
4, 4, 4, 4, 1, 3, 4, 4,
|
||||
4, 32, 4, 4, 4, 4, 4, 1,
|
||||
33, 1, 34, 33, 1, 35, 1, 36,
|
||||
35, 1, 37, 1, 38, 1, 39, 1,
|
||||
40, 1, 47, 48, 1, 1, 1, 1,
|
||||
42, 43, 44, 45, 46, 1, 1, 1,
|
||||
1, 1, 41, 55, 56, 1, 1, 1,
|
||||
1, 50, 51, 52, 53, 54, 1, 1,
|
||||
1, 1, 1, 49, 49, 1, 50, 1,
|
||||
51, 1, 52, 1, 53, 1, 57, 57,
|
||||
57, 1, 49, 49, 49, 1, 1, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_message_trans_targs[] = {
|
||||
2, 0, 23, 3, 2, 4, 5, 4,
|
||||
6, 7, 8, 9, 10, 11, 12, 13,
|
||||
14, 15, 16, 17, 18, 19, 22, 19,
|
||||
20, 21, 19, 22, 44, 24, 25, 26,
|
||||
27, 28, 29, 30, 31, 32, 33, 34,
|
||||
35, 36, 37, 38, 39, 40, 41, 17,
|
||||
42, 36, 37, 38, 39, 40, 41, 17,
|
||||
42, 43
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_message_trans_actions[] = {
|
||||
1, 0, 1, 3, 0, 1, 0, 0,
|
||||
0, 0, 5, 1, 0, 0, 0, 0,
|
||||
0, 0, 0, 7, 0, 1, 0, 0,
|
||||
0, 0, 18, 13, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 7, 1, 0, 0,
|
||||
9, 1, 1, 1, 1, 1, 1, 15,
|
||||
1, 0, 0, 0, 0, 0, 0, 11,
|
||||
0, 0
|
||||
};
|
||||
|
||||
static const int thttp_machine_parser_message_start = 1;
|
||||
static const int thttp_machine_parser_message_first_final = 44;
|
||||
static const int thttp_machine_parser_message_error = 0;
|
||||
|
||||
static const int thttp_machine_parser_message_en_main = 1;
|
||||
|
||||
|
||||
/* #line 188 "thttp_parser_message.rl" */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn int thttp_message_parse(tsk_ragel_state_t *state, thttp_message_t *result)
|
||||
///
|
||||
/// @brief Parse a HTTP message. Both requests and reponses messages.
|
||||
///
|
||||
/// @author Mamadou
|
||||
/// @date 12/4/2009
|
||||
///
|
||||
/// @param [in,out] state The ragel state to use.
|
||||
/// @param [out] result Non-null http message created using @ref THTTP_MESSAGE_CREATE. You must use @ref TSK_OBJECT_SAFE_FREE to
|
||||
/// free the result.
|
||||
///
|
||||
/// @return @ref zero if succeed and non-zero error code otherwise.
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int thttp_message_parse(tsk_ragel_state_t *state, thttp_message_t **result)
|
||||
{
|
||||
if(!state || state->pe <= state->p)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!*result)
|
||||
{
|
||||
*result = THTTP_MESSAGE_CREATE();
|
||||
}
|
||||
|
||||
/* Ragel init */
|
||||
thttp_message_parser_init(state);
|
||||
|
||||
/*
|
||||
* State mechine execution.
|
||||
*/
|
||||
thttp_message_parser_execute(state, *result);
|
||||
|
||||
/* Check result */
|
||||
|
||||
if( state->cs <
|
||||
/* #line 228 "../src/parsers/thttp_parser_message.c" */
|
||||
44
|
||||
/* #line 226 "thttp_parser_message.rl" */
|
||||
)
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(*result);
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void thttp_message_parser_init(tsk_ragel_state_t *state)
|
||||
{
|
||||
int cs = 0;
|
||||
|
||||
/* Regel machine initialization. */
|
||||
|
||||
/* #line 246 "../src/parsers/thttp_parser_message.c" */
|
||||
{
|
||||
cs = thttp_machine_parser_message_start;
|
||||
}
|
||||
|
||||
/* #line 241 "thttp_parser_message.rl" */
|
||||
|
||||
state->cs = cs;
|
||||
}
|
||||
|
||||
static void thttp_message_parser_execute(tsk_ragel_state_t *state, thttp_message_t *message)
|
||||
{
|
||||
int cs = state->cs;
|
||||
const char *p = state->p;
|
||||
const char *pe = state->pe;
|
||||
const char *eof = state->eof;
|
||||
|
||||
|
||||
/* #line 264 "../src/parsers/thttp_parser_message.c" */
|
||||
{
|
||||
int _klen;
|
||||
unsigned int _trans;
|
||||
const char *_acts;
|
||||
unsigned int _nacts;
|
||||
const char *_keys;
|
||||
|
||||
if ( p == pe )
|
||||
goto _test_eof;
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
_resume:
|
||||
_keys = _thttp_machine_parser_message_trans_keys + _thttp_machine_parser_message_key_offsets[cs];
|
||||
_trans = _thttp_machine_parser_message_index_offsets[cs];
|
||||
|
||||
_klen = _thttp_machine_parser_message_single_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + _klen - 1;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + ((_upper-_lower) >> 1);
|
||||
if ( (*p) < *_mid )
|
||||
_upper = _mid - 1;
|
||||
else if ( (*p) > *_mid )
|
||||
_lower = _mid + 1;
|
||||
else {
|
||||
_trans += (_mid - _keys);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_keys += _klen;
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_klen = _thttp_machine_parser_message_range_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + (_klen<<1) - 2;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
|
||||
if ( (*p) < _mid[0] )
|
||||
_upper = _mid - 2;
|
||||
else if ( (*p) > _mid[1] )
|
||||
_lower = _mid + 2;
|
||||
else {
|
||||
_trans += ((_mid - _keys)>>1);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_match:
|
||||
_trans = _thttp_machine_parser_message_indicies[_trans];
|
||||
cs = _thttp_machine_parser_message_trans_targs[_trans];
|
||||
|
||||
if ( _thttp_machine_parser_message_trans_actions[_trans] == 0 )
|
||||
goto _again;
|
||||
|
||||
_acts = _thttp_machine_parser_message_actions + _thttp_machine_parser_message_trans_actions[_trans];
|
||||
_nacts = (unsigned int) *_acts++;
|
||||
while ( _nacts-- > 0 )
|
||||
{
|
||||
switch ( *_acts++ )
|
||||
{
|
||||
case 0:
|
||||
/* #line 50 "thttp_parser_message.rl" */
|
||||
{
|
||||
state->tag_start = p;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* #line 56 "thttp_parser_message.rl" */
|
||||
{
|
||||
int len;
|
||||
state->tag_end = p;
|
||||
len = (int)(state->tag_end - state->tag_start);
|
||||
|
||||
if(message->type == thttp_unknown)
|
||||
{
|
||||
message->type = thttp_request;
|
||||
if(!message->method)
|
||||
{
|
||||
message->method = tsk_calloc(1, len+1);
|
||||
memcpy(message->method, state->tag_start, len);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
state->cs = thttp_machine_parser_message_error;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
/* #line 78 "thttp_parser_message.rl" */
|
||||
{
|
||||
int len;
|
||||
state->tag_end = p;
|
||||
len = (int)(state->tag_end - state->tag_start);
|
||||
|
||||
if(!message->url)
|
||||
{
|
||||
message->url = thttp_url_parse(state->tag_start, (size_t)len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
/* #line 91 "thttp_parser_message.rl" */
|
||||
{
|
||||
int len;
|
||||
state->tag_end = p;
|
||||
len = (int)(state->tag_end - state->tag_start);
|
||||
|
||||
if(!message->http_version)
|
||||
{
|
||||
message->http_version = tsk_calloc(1, len+1);
|
||||
memcpy(message->http_version, state->tag_start, len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
/* #line 105 "thttp_parser_message.rl" */
|
||||
{
|
||||
int len;
|
||||
state->tag_end = p;
|
||||
len = (int)(state->tag_end - state->tag_start);
|
||||
|
||||
if(message->type == thttp_unknown)
|
||||
{
|
||||
message->type = thttp_response;
|
||||
message->status_code = atoi(state->tag_start);
|
||||
}
|
||||
else
|
||||
{
|
||||
state->cs = thttp_machine_parser_message_error;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
/* #line 123 "thttp_parser_message.rl" */
|
||||
{
|
||||
int len;
|
||||
state->tag_end = p;
|
||||
len = (int)(state->tag_end - state->tag_start);
|
||||
|
||||
if(!message->reason_phrase)
|
||||
{
|
||||
message->reason_phrase = tsk_calloc(1, len+1);
|
||||
memcpy(message->reason_phrase, state->tag_start, len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
/* #line 137 "thttp_parser_message.rl" */
|
||||
{
|
||||
int len;
|
||||
state->tag_end = p;
|
||||
len = (int)(state->tag_end - state->tag_start);
|
||||
|
||||
if(thttp_header_parse(state, message))
|
||||
{
|
||||
//TSK_DEBUG_INFO("THTTP_MESSAGE_PARSER::PARSE_HEADER len=%d state=%d", len, state->cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to parse header - %s", state->tag_start);
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* #line 442 "../src/parsers/thttp_parser_message.c" */
|
||||
}
|
||||
}
|
||||
|
||||
_again:
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
if ( ++p != pe )
|
||||
goto _resume;
|
||||
_test_eof: {}
|
||||
_out: {}
|
||||
}
|
||||
|
||||
/* #line 253 "thttp_parser_message.rl" */
|
||||
|
||||
state->cs = cs;
|
||||
state->p = p;
|
||||
state->pe = pe;
|
||||
state->eof = eof;
|
||||
}
|
||||
|
||||
static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *message)
|
||||
{
|
||||
int cs = state->cs;
|
||||
const char *p = state->p;
|
||||
const char *pe = state->pe;
|
||||
const char *eof = state->eof;
|
||||
|
||||
if(message)
|
||||
{
|
||||
uint32_t clen = thttp_message_getContent_length(message);
|
||||
if((p+clen) <pe && !message->Content)
|
||||
{
|
||||
message->Content = TSK_BUFFER_CREATE((p+1), clen);
|
||||
p = (p+clen);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = (pe-1);
|
||||
}
|
||||
}
|
||||
//%%write eof;
|
||||
|
||||
state->cs = cs;
|
||||
state->p = p;
|
||||
state->pe = pe;
|
||||
state->eof = eof;
|
||||
}
|
|
@ -0,0 +1,277 @@
|
|||
|
||||
/* #line 1 "thttp_parser_url.rl" */
|
||||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_parser_url.c
|
||||
* @brief HTTP/HTTPS URL parser.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinyhttp/parsers/thttp_parser_url.h"
|
||||
|
||||
#include "tsk_string.h"
|
||||
#include "tsk_memory.h"
|
||||
#include "tsk_debug.h"
|
||||
|
||||
/**@defgroup thttp_parser_url_group HTTP/HTTPS URL parser.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
|
||||
/* #line 63 "thttp_parser_url.rl" */
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn thttp_url_t *thttp_url_parse(const char *data, size_t size)
|
||||
///
|
||||
/// @brief Parses HTTP/HTTPS URL.
|
||||
///
|
||||
/// @author Mamadou
|
||||
/// @date 12/6/2009
|
||||
///
|
||||
/// @param [in,out] data Data from which to parse the url.
|
||||
/// @param size The data size.
|
||||
///
|
||||
/// @return null if it fails, else the http/https/tel url.
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
thttp_url_t *thttp_url_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
|
||||
const char *ts = 0, *te = 0;
|
||||
int act =0;
|
||||
|
||||
thttp_url_t *url = THTTP_URL_CREATE(url_unknown);
|
||||
|
||||
const char *tag_start = 0;
|
||||
|
||||
|
||||
/* #line 77 "../src/parsers/thttp_parser_url.c" */
|
||||
static const char _thttp_machine_parser_url_actions[] = {
|
||||
0, 1, 0, 1, 1, 1, 2, 1,
|
||||
3, 2, 1, 3, 2, 2, 3
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_url_key_offsets[] = {
|
||||
0, 0, 2, 4, 6, 8, 11, 12,
|
||||
12, 12
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_url_trans_keys[] = {
|
||||
72, 104, 84, 116, 84, 116, 80, 112,
|
||||
58, 83, 115, 58, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_url_single_lengths[] = {
|
||||
0, 2, 2, 2, 2, 3, 1, 0,
|
||||
0, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_url_range_lengths[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_url_index_offsets[] = {
|
||||
0, 0, 3, 6, 9, 12, 16, 18,
|
||||
19, 20
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_url_trans_targs[] = {
|
||||
2, 2, 0, 3, 3, 0, 4, 4,
|
||||
0, 5, 5, 0, 7, 6, 6, 0,
|
||||
9, 0, 8, 8, 8, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_url_trans_actions[] = {
|
||||
1, 1, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 7, 0, 0, 0,
|
||||
7, 0, 9, 7, 12, 0
|
||||
};
|
||||
|
||||
static const char _thttp_machine_parser_url_eof_actions[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 3,
|
||||
0, 5
|
||||
};
|
||||
|
||||
static const int thttp_machine_parser_url_start = 1;
|
||||
static const int thttp_machine_parser_url_first_final = 7;
|
||||
static const int thttp_machine_parser_url_error = 0;
|
||||
|
||||
static const int thttp_machine_parser_url_en_main = 1;
|
||||
|
||||
|
||||
/* #line 93 "thttp_parser_url.rl" */
|
||||
|
||||
/* #line 134 "../src/parsers/thttp_parser_url.c" */
|
||||
{
|
||||
cs = thttp_machine_parser_url_start;
|
||||
}
|
||||
|
||||
/* #line 94 "thttp_parser_url.rl" */
|
||||
|
||||
/* #line 141 "../src/parsers/thttp_parser_url.c" */
|
||||
{
|
||||
int _klen;
|
||||
unsigned int _trans;
|
||||
const char *_acts;
|
||||
unsigned int _nacts;
|
||||
const char *_keys;
|
||||
|
||||
if ( p == pe )
|
||||
goto _test_eof;
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
_resume:
|
||||
_keys = _thttp_machine_parser_url_trans_keys + _thttp_machine_parser_url_key_offsets[cs];
|
||||
_trans = _thttp_machine_parser_url_index_offsets[cs];
|
||||
|
||||
_klen = _thttp_machine_parser_url_single_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + _klen - 1;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + ((_upper-_lower) >> 1);
|
||||
if ( (*p) < *_mid )
|
||||
_upper = _mid - 1;
|
||||
else if ( (*p) > *_mid )
|
||||
_lower = _mid + 1;
|
||||
else {
|
||||
_trans += (_mid - _keys);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_keys += _klen;
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_klen = _thttp_machine_parser_url_range_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + (_klen<<1) - 2;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
|
||||
if ( (*p) < _mid[0] )
|
||||
_upper = _mid - 2;
|
||||
else if ( (*p) > _mid[1] )
|
||||
_lower = _mid + 2;
|
||||
else {
|
||||
_trans += ((_mid - _keys)>>1);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_match:
|
||||
cs = _thttp_machine_parser_url_trans_targs[_trans];
|
||||
|
||||
if ( _thttp_machine_parser_url_trans_actions[_trans] == 0 )
|
||||
goto _again;
|
||||
|
||||
_acts = _thttp_machine_parser_url_actions + _thttp_machine_parser_url_trans_actions[_trans];
|
||||
_nacts = (unsigned int) *_acts++;
|
||||
while ( _nacts-- > 0 )
|
||||
{
|
||||
switch ( *_acts++ )
|
||||
{
|
||||
case 0:
|
||||
/* #line 49 "thttp_parser_url.rl" */
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* #line 54 "thttp_parser_url.rl" */
|
||||
{ url->scheme = tsk_strdup("http"), url->type = url_http; }
|
||||
break;
|
||||
case 2:
|
||||
/* #line 55 "thttp_parser_url.rl" */
|
||||
{ url->scheme = tsk_strdup("https"), url->type = url_https; }
|
||||
break;
|
||||
case 3:
|
||||
/* #line 58 "thttp_parser_url.rl" */
|
||||
{
|
||||
}
|
||||
break;
|
||||
/* #line 233 "../src/parsers/thttp_parser_url.c" */
|
||||
}
|
||||
}
|
||||
|
||||
_again:
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
if ( ++p != pe )
|
||||
goto _resume;
|
||||
_test_eof: {}
|
||||
if ( p == eof )
|
||||
{
|
||||
const char *__acts = _thttp_machine_parser_url_actions + _thttp_machine_parser_url_eof_actions[cs];
|
||||
unsigned int __nacts = (unsigned int) *__acts++;
|
||||
while ( __nacts-- > 0 ) {
|
||||
switch ( *__acts++ ) {
|
||||
case 1:
|
||||
/* #line 54 "thttp_parser_url.rl" */
|
||||
{ url->scheme = tsk_strdup("http"), url->type = url_http; }
|
||||
break;
|
||||
case 2:
|
||||
/* #line 55 "thttp_parser_url.rl" */
|
||||
{ url->scheme = tsk_strdup("https"), url->type = url_https; }
|
||||
break;
|
||||
/* #line 257 "../src/parsers/thttp_parser_url.c" */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_out: {}
|
||||
}
|
||||
|
||||
/* #line 95 "thttp_parser_url.rl" */
|
||||
|
||||
if( cs <
|
||||
/* #line 268 "../src/parsers/thttp_parser_url.c" */
|
||||
7
|
||||
/* #line 96 "thttp_parser_url.rl" */
|
||||
)
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to parse HTTP/HTTPS URL.");
|
||||
TSK_OBJECT_SAFE_FREE(url);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file thttp_url.c
|
||||
* @brief SIP/SIPS/TEL URL.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinyhttp/thttp_url.h"
|
||||
|
||||
#include "tinyhttp/parsers/thttp_parser_url.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
#include "tsk_string.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**@defgroup thttp_url_group
|
||||
*/
|
||||
|
||||
int __thttp_url_serialize(const thttp_url_t *url, tsk_buffer_t *output)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int thttp_url_serialize(const thttp_url_t *url, tsk_buffer_t *output)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
char* thttp_url_tostring(const thttp_url_t *url)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
thttp_url_t *thttp_url_clone(const thttp_url_t *url)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// HTTP/HTTPS URL object definition
|
||||
//
|
||||
|
||||
/**@ingroup thttp_url_group
|
||||
*/
|
||||
static void* thttp_url_create(void *self, va_list * app)
|
||||
{
|
||||
thttp_url_t *url = self;
|
||||
if(url)
|
||||
{
|
||||
url->type = va_arg(*app, thttp_url_type_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new SIP/SIPS/TEL.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup thttp_url_group
|
||||
*/
|
||||
static void* thttp_url_destroy(void *self)
|
||||
{
|
||||
thttp_url_t *url = self;
|
||||
if(url)
|
||||
{
|
||||
TSK_FREE(url->scheme);
|
||||
TSK_FREE(url->host);
|
||||
TSK_FREE(url->password);
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null HTTP/HTTPS URL.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t thttp_url_def_s =
|
||||
{
|
||||
sizeof(thttp_url_t),
|
||||
thttp_url_create,
|
||||
thttp_url_destroy,
|
||||
0
|
||||
};
|
||||
const void *thttp_url_def_t = &thttp_url_def_s;
|
|
@ -346,7 +346,7 @@
|
|||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\thttp_utl.c"
|
||||
RelativePath=".\src\thttp_url.c"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
|
@ -360,10 +360,38 @@
|
|||
<Filter
|
||||
Name="headers"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\headers\thttp_header.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\headers\thttp_header_Authorization.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\headers\thttp_header_Proxy_Authenticate.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\headers\thttp_header_WWW_Authenticate.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="parsers"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\parsers\thttp_parser_header.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\parsers\thttp_parser_message.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\parsers\thttp_parser_url.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@ -396,10 +424,46 @@
|
|||
<Filter
|
||||
Name="headers"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\include\tinyHTTP\headers\thttp_header.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\tinyHTTP\headers\thttp_header_Authorization.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\tinyHTTP\headers\thttp_header_Content_Length.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\tinyHTTP\headers\thttp_header_Content_Type.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\tinyHTTP\headers\thttp_header_Proxy_Authenticate.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\tinyHTTP\headers\thttp_header_WWW_Authenticate.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="parsers"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\include\tinyHTTP\parsers\thttp_parser_header.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\tinyHTTP\parsers\thttp_parser_message.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\tinyHTTP\parsers\thttp_parser_url.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@ -421,6 +485,46 @@
|
|||
<Filter
|
||||
Name="ragel"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\ragel\thttp_machine_header.rl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ragel\thttp_machine_message.rl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ragel\thttp_machine_utils.rl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ragel\thttp_parser_header.rl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ragel\thttp_parser_header_Authorization.rl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ragel\thttp_parser_header_Content_Length.rl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ragel\thttp_parser_header_Content_Type.rl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ragel\thttp_parser_header_WWW_Authenticate.rl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ragel\thttp_parser_message.rl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ragel\thttp_parser_url.rl"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
|
|
@ -1,29 +1,24 @@
|
|||
/****************************************************************************
|
||||
_ _
|
||||
| | | |
|
||||
_ | | ___ _ _| | _ ____ ____ ____ ___
|
||||
/ || |/ _ \| | | | || \ / _ | _ \ / _ |/ _ \
|
||||
( (_| | |_| | |_| | |_) | ( | | | | ( ( | | |_| |
|
||||
\____|\___/ \____|____/ \_||_|_| |_|\_|| |\___/
|
||||
(_____|
|
||||
|
||||
Copyright (C) 2009 xxxyyyzzz <imsframework(at)gmail.com>
|
||||
|
||||
This file is part of Open Source Doubango IMS Client Framework project.
|
||||
|
||||
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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DOUBANGO.
|
||||
****************************************************************************/
|
||||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
|
|
|
@ -1,29 +1,24 @@
|
|||
/****************************************************************************
|
||||
_ _
|
||||
| | | |
|
||||
_ | | ___ _ _| | _ ____ ____ ____ ___
|
||||
/ || |/ _ \| | | | || \ / _ | _ \ / _ |/ _ \
|
||||
( (_| | |_| | |_| | |_) | ( | | | | ( ( | | |_| |
|
||||
\____|\___/ \____|____/ \_||_|_| |_|\_|| |\___/
|
||||
(_____|
|
||||
|
||||
Copyright (C) 2009 xxxyyyzzz <imsframework(at)gmail.com>
|
||||
|
||||
This file is part of Open Source Doubango IMS Client Framework project.
|
||||
|
||||
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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DOUBANGO.
|
||||
****************************************************************************/
|
||||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1,34 +1,29 @@
|
|||
/****************************************************************************
|
||||
_ _
|
||||
| | | |
|
||||
_ | | ___ _ _| | _ ____ ____ ____ ___
|
||||
/ || |/ _ \| | | | || \ / _ | _ \ / _ |/ _ \
|
||||
( (_| | |_| | |_| | |_) | ( | | | | ( ( | | |_| |
|
||||
\____|\___/ \____|____/ \_||_|_| |_|\_|| |\___/
|
||||
(_____|
|
||||
|
||||
Copyright (C) 2009 xxxyyyzzz <imsframework(at)gmail.com>
|
||||
|
||||
This file is part of Open Source Doubango IMS Client Framework project.
|
||||
|
||||
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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DOUBANGO.
|
||||
****************************************************************************/
|
||||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
#include "stdafx.h"
|
||||
#include "ipsec_api.h"
|
||||
|
||||
#define REMOTE_IP "192.168.0.9" //"2a01:e35:8b32:7050:6122:2706:2124:32ca"//"192.168.0.15"
|
||||
#define LOCAL_IP "192.168.0.14" //"2a01:e35:8b32:7050:6122:2706:2124:32cb"//"192.168.0.14"
|
||||
#define LOCAL_IP "192.168.0.12" //"2a01:e35:8b32:7050:6122:2706:2124:32cb"//"192.168.0.14"
|
||||
|
||||
#define IK "1234567890123456"
|
||||
#define CK "1234567890121234"
|
||||
|
@ -46,6 +41,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||
ipsec_context_t* context = 0;
|
||||
uint32_t spi_local_s = 0, spi_local_c = 0, spi_remote_s = 0, spi_remote_c = 0;
|
||||
|
||||
//http://www.arib.or.jp/IMT-2000/V740Dec09/2_T63/ARIB-STD-T63/Rel7/33/A33203-790.pdf
|
||||
/* create context */
|
||||
IPSEC_CONTEXT_CREATE(context);
|
||||
|
||||
|
@ -53,8 +49,8 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||
|
||||
/* set algorithms, proto and mode */
|
||||
context->auth = iaa_hmac_md5_96;
|
||||
context->encrypt = iea_3des;
|
||||
context->proto = ipp_both;
|
||||
context->encrypt = iea_null;
|
||||
context->proto = ipp_esp;
|
||||
context->mode = ipm_transport;
|
||||
|
||||
/* set ik and ck */
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Version="9.00"
|
||||
Name="test"
|
||||
ProjectGUID="{E40FEB1F-BE85-488D-BCBE-89668F6EBBF7}"
|
||||
RootNamespace="test"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
|
@ -66,6 +67,8 @@
|
|||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
|
@ -86,9 +89,6 @@
|
|||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
|
@ -141,6 +141,8 @@
|
|||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
|
@ -161,9 +163,6 @@
|
|||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyIPSec", "tinyIPSec\tinyIPSec.vcproj", "{002FF064-588F-402E-A096-C8D033F49F40}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcproj", "{E40FEB1F-BE85-488D-BCBE-89668F6EBBF7}"
|
||||
|
|
|
@ -295,11 +295,14 @@ int ipsec_sa_bound(ipsec_context_t* context, ipsec_direction_t direction)
|
|||
bundle.lifetime.lifetimeSeconds = (context->SAs[direction].lifetime > WIN32_SA_MAX_LIFETIME) ? WIN32_SA_MAX_LIFETIME : context->SAs[direction].lifetime;
|
||||
|
||||
/* inbound ? */
|
||||
if(direction == ipd_incoming_rep || direction == ipd_incoming_req)
|
||||
if(direction == ipd_incoming_rep || direction == ipd_incoming_req){
|
||||
result = IPsecSaContextAddInbound0(engine, GET_SA_OPAQUE(context->SAs[direction])->saId, &bundle);
|
||||
else
|
||||
result = IPsecSaContextAddOutbound0(engine, GET_SA_OPAQUE(context->SAs[direction])->saId, &bundle);
|
||||
|
||||
}
|
||||
else{
|
||||
result = IPsecSaContextAddOutbound0(engine, GET_SA_OPAQUE(context->SAs[direction == ipd_outgoing_rep ? ipd_incoming_req : ipd_incoming_rep])->saId, &bundle);
|
||||
DEBUG_PRINT("saId=%d\n", GET_SA_OPAQUE(context->SAs[direction])->saId);
|
||||
}
|
||||
|
||||
CLEANUP_ON_ERROR(result);
|
||||
|
||||
CLEANUP:
|
||||
|
@ -434,6 +437,7 @@ DWORD getInboundSPI(ipsec_context_t* context, ipsec_direction_t direction)
|
|||
GET_SA_OPAQUE(context->SAs[direction])->inFilterId = tmpInFilterId;
|
||||
GET_SA_OPAQUE(context->SAs[direction])->outFilterId = tmpOutFilterId;
|
||||
GET_SA_OPAQUE(context->SAs[direction])->saId = tmpSaId;
|
||||
DEBUG_PRINT("tmpSaId=%d\n", tmpSaId);
|
||||
CLEANUP:
|
||||
if (result != NO_ERROR)
|
||||
{
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Version="9.00"
|
||||
Name="tinyIPSec"
|
||||
ProjectGUID="{002FF064-588F-402E-A096-C8D033F49F40}"
|
||||
RootNamespace="tinyIPSec"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
|
@ -65,6 +66,8 @@
|
|||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
|
@ -85,9 +88,6 @@
|
|||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
|
@ -141,6 +141,8 @@
|
|||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
|
@ -161,9 +163,6 @@
|
|||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
|
|
|
@ -325,4 +325,4 @@ static const tsk_object_def_t tnet_dhcp_option_dns_def_s =
|
|||
tnet_dhcp_option_dns_destroy,
|
||||
0,
|
||||
};
|
||||
const void *tnet_dhcp_option_dns_def_t = &tnet_dhcp_option_dns_def_s;
|
||||
const void *tnet_dhcp_option_dns_def_t = &tnet_dhcp_option_dns_def_s;
|
||||
|
|
|
@ -258,4 +258,4 @@ static const tsk_object_def_t tnet_dhcp6_ctx_def_s =
|
|||
tnet_dhcp6_ctx_destroy,
|
||||
0,
|
||||
};
|
||||
const void *tnet_dhcp6_ctx_def_t = &tnet_dhcp6_ctx_def_s;
|
||||
const void *tnet_dhcp6_ctx_def_t = &tnet_dhcp6_ctx_def_s;
|
||||
|
|
|
@ -281,4 +281,4 @@ static const tsk_object_def_t tnet_dhcp6_duid_ll_def_s =
|
|||
tnet_dhcp6_duid_ll_destroy,
|
||||
0,
|
||||
};
|
||||
const void *tnet_dhcp6_duid_ll_def_t = &tnet_dhcp6_duid_ll_def_s;
|
||||
const void *tnet_dhcp6_duid_ll_def_t = &tnet_dhcp6_duid_ll_def_s;
|
||||
|
|
|
@ -122,4 +122,5 @@ static const tsk_object_def_t tnet_dhcp6_message_def_s =
|
|||
tnet_dhcp6_message_destroy,
|
||||
0,
|
||||
};
|
||||
const void *tnet_dhcp6_message_def_t = &tnet_dhcp6_message_def_s;
|
||||
const void *tnet_dhcp6_message_def_t = &tnet_dhcp6_message_def_s;
|
||||
|
||||
|
|
|
@ -336,4 +336,4 @@ static const tsk_object_def_t tnet_dhcp6_option_vendorclass_def_s =
|
|||
tnet_dhcp6_option_vendorclass_destroy,
|
||||
0,
|
||||
};
|
||||
const void *tnet_dhcp6_option_vendorclass_def_t = &tnet_dhcp6_option_vendorclass_def_s;
|
||||
const void *tnet_dhcp6_option_vendorclass_def_t = &tnet_dhcp6_option_vendorclass_def_s;
|
||||
|
|
|
@ -21,7 +21,15 @@ OBJS = \
|
|||
###################
|
||||
OBJS += dhcp/tnet_dhcp.o\
|
||||
dhcp/tnet_dhcp_message.o\
|
||||
dhcp/tnet_dhcp_option.o
|
||||
dhcp/tnet_dhcp_option.o\
|
||||
dhcp/tnet_dhcp_option_sip.o
|
||||
###################
|
||||
## DHCPv6
|
||||
###################
|
||||
OBJS += dhcp6/tnet_dhcp6.o\
|
||||
dhcp6/tnet_dhcp6_duid.o\
|
||||
dhcp6/tnet_dhcp6_message.o\
|
||||
dhcp6/tnet_dhcp6_option.o
|
||||
###################
|
||||
## DDNS
|
||||
###################
|
||||
|
|
|
@ -171,7 +171,7 @@ tnet_interfaces_L_t* tnet_get_interfaces()
|
|||
continue;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
tnet_fd_t fd = TNET_INVALID_FD;
|
||||
|
@ -217,7 +217,7 @@ tnet_interfaces_L_t* tnet_get_interfaces()
|
|||
struct sockaddr_in *sin;
|
||||
struct ifreq *ifr;
|
||||
|
||||
if((fd = socket(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP)) < 0)
|
||||
if((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new DGRAM socket and errno= [%d]", tnet_geterrno());
|
||||
goto done;
|
||||
|
@ -244,7 +244,7 @@ tnet_interfaces_L_t* tnet_get_interfaces()
|
|||
{
|
||||
tnet_interface_t *iface = TNET_INTERFACE_CREATE(ifr->ifr_name, ifr->ifr_hwaddr.sa_data, 6);
|
||||
tsk_list_push_back_data(ifaces, (void**)&(iface));
|
||||
index
|
||||
//iface->index = if_nametoindex(ifr->ifr_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ int tnet_sockaddrinfo_init(const char *host, tnet_port_t port, enum tnet_socket_
|
|||
hints.ai_family = TNET_SOCKET_TYPE_IS_IPV6(type) ? AF_INET6 : AF_INET;
|
||||
hints.ai_socktype = TNET_SOCKET_TYPE_IS_STREAM(type) ? SOCK_STREAM : SOCK_DGRAM;
|
||||
hints.ai_protocol = TNET_SOCKET_TYPE_IS_STREAM(type) ? IPPROTO_TCP : IPPROTO_UDP;
|
||||
//--hints.ai_flags = AI_PASSIVE;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
|
||||
/* Performs getaddrinfo */
|
||||
if((status = tnet_getaddrinfo(host, p, &hints, &result)))
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef TNET_TEST_TRANSPORT_H
|
||||
#define TNET_TEST_TRANSPORT_H
|
||||
|
||||
#define REMOTE_IP4 "ekiga.net"//"192.168.0.15"
|
||||
#define REMOTE_IP4 "proxy.sipthor.net"//"192.168.0.15"
|
||||
#define REMOTE_IP6 "2a01:e35:8632:7050:6122:2706:2124:32cb"
|
||||
#define REMOTE_IP REMOTE_IP4
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ OBJS = tsk.o\
|
|||
tsk_time.o\
|
||||
tsk_timer.o\
|
||||
tsk_url.o\
|
||||
tsk_uuid.o\
|
||||
tsk_xml.o
|
||||
|
||||
$(APP): $(OBJS)
|
||||
|
|
|
@ -63,6 +63,7 @@ TSK_BEGIN_DECLS
|
|||
#include "tsk_hmac.h"
|
||||
#include "tsk_base64.h"
|
||||
#include "tsk_uuid.h"
|
||||
#include "tsk_ragel_state.h"
|
||||
|
||||
TSK_END_DECLS
|
||||
|
||||
|
|
|
@ -20,17 +20,17 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/**@file tsip_ragel_state.c.
|
||||
* @brief Ragel state for sip parsing.
|
||||
/**@file tsk_ragel_state.c.
|
||||
* @brief Ragel state for SIP, HTTP and MSRP parsing.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinysip/parsers/tsip_ragel_state.h"
|
||||
#include "tsk_ragel_state.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn void tsip_ragel_state_init(tsip_ragel_state_t *state, const char *data, size_t size)
|
||||
/// @fn void tsk_ragel_state_init(tsk_ragel_state_t *state, const char *data, size_t size)
|
||||
///
|
||||
/// @brief Initialize/Reset the ragel state with default values.
|
||||
///
|
||||
|
@ -42,7 +42,7 @@
|
|||
/// @param size The size of the data.
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void tsip_ragel_state_init(tsip_ragel_state_t *state, const char *data, size_t size)
|
||||
void tsk_ragel_state_init(tsk_ragel_state_t *state, const char *data, size_t size)
|
||||
{
|
||||
state->cs = 0;
|
||||
state->p = data;
|
|
@ -20,24 +20,24 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/**@file tsip_ragel_state.h.
|
||||
* @brief Ragel state for sip parsing.
|
||||
/**@file tsk_ragel_state.h.
|
||||
* @brief Ragel state for sak parsing.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef TINYSIP_RAGEL_STATE_H
|
||||
#define TINYSIP_RAGEL_STATE_H
|
||||
#ifndef TINYSAK_RAGEL_STATE_H
|
||||
#define TINYSAK_RAGEL_STATE_H
|
||||
|
||||
#include "tinysip_config.h"
|
||||
#include "tinysak_config.h"
|
||||
#include "tsk_params.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
TSIP_BEGIN_DECLS
|
||||
TSK_BEGIN_DECLS
|
||||
|
||||
#define SCANNER_SET_STRING(string) \
|
||||
#define TSK_SCANNER_SET_STRING(string) \
|
||||
if(!string) \
|
||||
{ \
|
||||
int len = (int)(te - ts); \
|
||||
|
@ -47,14 +47,14 @@ TSIP_BEGIN_DECLS
|
|||
} \
|
||||
}
|
||||
|
||||
#define PARSER_SET_STRING(string) \
|
||||
#define TSK_PARSER_SET_STRING(string) \
|
||||
if(!string) \
|
||||
{ \
|
||||
int len = (int)(p - tag_start); \
|
||||
string = tsk_calloc(len+1, sizeof(char)), memcpy(string, tag_start, len); \
|
||||
}
|
||||
|
||||
#define SCANNER_SET_INTEGER(integer) \
|
||||
#define TSK_SCANNER_SET_INTEGER(integer) \
|
||||
{ \
|
||||
int len = (int)(te - ts); \
|
||||
if(len>=0) \
|
||||
|
@ -66,7 +66,7 @@ TSIP_BEGIN_DECLS
|
|||
} \
|
||||
}
|
||||
|
||||
#define PARSER_SET_INTEGER(integer) \
|
||||
#define TSK_PARSER_SET_INTEGER(integer) \
|
||||
{ \
|
||||
int len = (int)(p - tag_start); \
|
||||
if(len>=0) \
|
||||
|
@ -78,7 +78,7 @@ TSIP_BEGIN_DECLS
|
|||
} \
|
||||
}
|
||||
|
||||
#define PARSER_ADD_PARAM(dest) \
|
||||
#define TSK_PARSER_ADD_PARAM(dest) \
|
||||
{ \
|
||||
size_t len = (size_t)(p - tag_start); \
|
||||
tsk_param_t *param = tsk_params_parse_param(tag_start, len); \
|
||||
|
@ -89,7 +89,7 @@ TSIP_BEGIN_DECLS
|
|||
} \
|
||||
}
|
||||
|
||||
#define SACANNER_ADD_PARAM(dest) \
|
||||
#define TSK_SACANNER_ADD_PARAM(dest) \
|
||||
{ \
|
||||
int len = (int)(te - ts); \
|
||||
if(len >0) \
|
||||
|
@ -103,7 +103,7 @@ TSIP_BEGIN_DECLS
|
|||
} \
|
||||
}
|
||||
|
||||
#define PARSER_ADD_STRING(dest) \
|
||||
#define TSK_PARSER_ADD_STRING(dest) \
|
||||
{ \
|
||||
size_t len = (size_t)(p - tag_start); \
|
||||
tsk_string_t *string = TSK_STRING_CREATE(0); \
|
||||
|
@ -116,14 +116,14 @@ TSIP_BEGIN_DECLS
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @struct tsip_parser_s
|
||||
/// @struct tsk_parser_s
|
||||
///
|
||||
/// @brief Ragel state.
|
||||
///
|
||||
/// @author Mamadou
|
||||
/// @date 12/4/2009
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct tsip_ragel_state_s
|
||||
typedef struct tsk_ragel_state_s
|
||||
{
|
||||
int cs; /**< Ragel current state. */
|
||||
const char *p; /**< Data pointing to the buffer to parse. */
|
||||
|
@ -133,12 +133,12 @@ typedef struct tsip_ragel_state_s
|
|||
const char* tag_start; /**< Last tag start position set by ragel machine. */
|
||||
const char* tag_end; /**< The end of the ragel tag. */
|
||||
}
|
||||
tsip_ragel_state_t;
|
||||
tsk_ragel_state_t;
|
||||
|
||||
|
||||
TINYSIP_API void tsip_ragel_state_init(tsip_ragel_state_t *state, const char *data, size_t size);
|
||||
TINYSAK_API void tsk_ragel_state_init(tsk_ragel_state_t *state, const char *data, size_t size);
|
||||
|
||||
TSIP_END_DECLS
|
||||
TSK_END_DECLS
|
||||
|
||||
#endif /* TINYSIP_RAGEL_STATE_H */
|
||||
#endif /* TINYSAK_RAGEL_STATE_H */
|
||||
|
|
@ -422,6 +422,10 @@
|
|||
RelativePath=".\src\tsk_ppfcs32.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tsk_ragel_state.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tsk_runnable.h"
|
||||
>
|
||||
|
@ -536,6 +540,10 @@
|
|||
RelativePath=".\src\tsk_ppfcs32.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tsk_ragel_state.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tsk_runnable.c"
|
||||
>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include "tinysip_config.h"
|
||||
|
||||
#include "tinysip/parsers/tsip_ragel_state.h"
|
||||
#include "tsk_ragel_state.h"
|
||||
|
||||
#include "tsk_params.h"
|
||||
#include "tsk_object.h"
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
|
||||
#include "tinysip_config.h"
|
||||
#include "tinysip/tsip_message.h"
|
||||
#include "tinysip/parsers/tsip_ragel_state.h"
|
||||
#include "tsk_ragel_state.h"
|
||||
|
||||
TSIP_BEGIN_DECLS
|
||||
|
||||
TSIP_BOOLEAN tsip_header_parse(tsip_ragel_state_t *state, tsip_message_t *message);
|
||||
TSIP_BOOLEAN tsip_header_parse(tsk_ragel_state_t *state, tsip_message_t *message);
|
||||
|
||||
TSIP_END_DECLS
|
||||
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
|
||||
#include "tinysip_config.h"
|
||||
#include "tinysip/tsip_message.h"
|
||||
#include "tinysip/parsers/tsip_ragel_state.h"
|
||||
#include "tsk_ragel_state.h"
|
||||
|
||||
TSIP_BEGIN_DECLS
|
||||
|
||||
TINYSIP_API TSIP_BOOLEAN tsip_message_parse(tsip_ragel_state_t *state, tsip_message_t **result);
|
||||
TINYSIP_API TSIP_BOOLEAN tsip_message_parse(tsk_ragel_state_t *state, tsip_message_t **result);
|
||||
|
||||
TSIP_END_DECLS
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "tinysip_config.h"
|
||||
#include "tinysip/tsip_uri.h"
|
||||
|
||||
#include "tinysip/parsers/tsip_ragel_state.h"
|
||||
#include "tsk_ragel_state.h"
|
||||
|
||||
TSIP_BEGIN_DECLS
|
||||
|
||||
|
|
|
@ -1,96 +1,96 @@
|
|||
# Ragel generator
|
||||
# For more information about Ragel: http://www.complang.org/ragel/
|
||||
|
||||
#export OPTIONS="-C -L -T0 -F1 -G2"
|
||||
export OPTIONS="-C -L -G2"
|
||||
export OPTIONS="-C -L -T0"
|
||||
#export OPTIONS="-C -L -G2"
|
||||
|
||||
# SIP/SIPS/TEL URI parser
|
||||
ragel.exe $OPTIONS -o ../src/parsers/tsip_parser_uri.c tsip_parser_uri.rl
|
||||
|
||||
# SIP message (both requests an responses) parser.
|
||||
#ragel.exe $OPTIONS -o ../src/parsers/tsip_parser_message.c tsip_parser_message.rl
|
||||
ragel.exe $OPTIONS -o ../src/parsers/tsip_parser_message.c tsip_parser_message.rl
|
||||
|
||||
# SIP headers parser
|
||||
#ragel.exe $OPTIONS -o ../src/parsers/tsip_parser_header.c tsip_parser_header.rl
|
||||
ragel.exe $OPTIONS -o ../src/parsers/tsip_parser_header.c tsip_parser_header.rl
|
||||
|
||||
|
||||
# ==Allow
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Allow.c tsip_parser_header_Allow.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Allow.c tsip_parser_header_Allow.rl
|
||||
|
||||
# ==Allow-Events
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Allow_Events.c tsip_parser_header_Allow_Events.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Allow_Events.c tsip_parser_header_Allow_Events.rl
|
||||
|
||||
# ==Authorization
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Authorization.c tsip_parser_header_Authorization.rl
|
||||
######ragel.exe $OPTIONS -o ../src/headers/tsip_header_Authorization.c tsip_parser_header_Authorization.rl
|
||||
|
||||
# ==Call-ID
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Call_ID.c tsip_parser_header_Call_ID.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Call_ID.c tsip_parser_header_Call_ID.rl
|
||||
|
||||
# ==Content-Length
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Content_Length.c tsip_parser_header_Content_Length.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Content_Length.c tsip_parser_header_Content_Length.rl
|
||||
|
||||
# ==Content-Type
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Content_Type.c tsip_parser_header_Content_Type.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Content_Type.c tsip_parser_header_Content_Type.rl
|
||||
|
||||
# ==Contact
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Contact.c tsip_parser_header_Contact.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Contact.c tsip_parser_header_Contact.rl
|
||||
|
||||
# ==CSeq
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_CSeq.c tsip_parser_header_CSeq.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_CSeq.c tsip_parser_header_CSeq.rl
|
||||
|
||||
# ==Expires
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Expires.c tsip_parser_header_Expires.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Expires.c tsip_parser_header_Expires.rl
|
||||
|
||||
# ==From
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_From.c tsip_parser_header_From.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_From.c tsip_parser_header_From.rl
|
||||
|
||||
# ==Max-Forwards
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Max_Forwards.c tsip_parser_header_Max_Forwards.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Max_Forwards.c tsip_parser_header_Max_Forwards.rl
|
||||
|
||||
# ==Min-Expires
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Min_Expires.c tsip_parser_header_Min_Expires.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Min_Expires.c tsip_parser_header_Min_Expires.rl
|
||||
|
||||
# ==Path
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Path.c tsip_parser_header_Path.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Path.c tsip_parser_header_Path.rl
|
||||
|
||||
# ==P-Access-Network-Info
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_P_Access_Network_Info.c tsip_parser_header_P_Access_Network_Info.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_P_Access_Network_Info.c tsip_parser_header_P_Access_Network_Info.rl
|
||||
|
||||
# ==P-Preferred-Identity
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_P_Preferred_Identity.c tsip_parser_header_P_Preferred_Identity.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_P_Preferred_Identity.c tsip_parser_header_P_Preferred_Identity.rl
|
||||
|
||||
# ==Privacy
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Privacy.c tsip_parser_header_Privacy.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Privacy.c tsip_parser_header_Privacy.rl
|
||||
|
||||
# ==Proxy-Authenticate
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Proxy_Authenticate.c tsip_parser_header_Proxy_Authenticate.rl
|
||||
########ragel.exe $OPTIONS -o ../src/headers/tsip_header_Proxy_Authenticate.c tsip_parser_header_Proxy_Authenticate.rl
|
||||
|
||||
# ==Proxy-Authorization
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Proxy_Authorization.c tsip_parser_header_Proxy_Authorization.rl
|
||||
#########ragel.exe $OPTIONS -o ../src/headers/tsip_header_Proxy_Authorization.c tsip_parser_header_Proxy_Authorization.rl
|
||||
|
||||
# ==Record-Route
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Record_Route.c tsip_parser_header_Record_Route.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Record_Route.c tsip_parser_header_Record_Route.rl
|
||||
|
||||
# ==Require
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Require.c tsip_parser_header_Require.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Require.c tsip_parser_header_Require.rl
|
||||
|
||||
# == Service-Route
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Route.c tsip_parser_header_Route.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Route.c tsip_parser_header_Route.rl
|
||||
|
||||
# == Service-Route
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Service_Route.c tsip_parser_header_Service_Route.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Service_Route.c tsip_parser_header_Service_Route.rl
|
||||
|
||||
# ==Supported
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Supported.c tsip_parser_header_Supported.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Supported.c tsip_parser_header_Supported.rl
|
||||
|
||||
# ==To
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_To.c tsip_parser_header_To.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_To.c tsip_parser_header_To.rl
|
||||
|
||||
# ==User-Agent
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_User_Agent.c tsip_parser_header_User_Agent.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_User_Agent.c tsip_parser_header_User_Agent.rl
|
||||
|
||||
# ==Via
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_Via.c tsip_parser_header_Via.rl
|
||||
ragel.exe $OPTIONS -o ../src/headers/tsip_header_Via.c tsip_parser_header_Via.rl
|
||||
|
||||
# ==WWW-Authenticate
|
||||
#ragel.exe $OPTIONS -o ../src/headers/tsip_header_WWW_Authenticate.c tsip_parser_header_WWW_Authenticate.rl
|
||||
#########ragel.exe $OPTIONS -o ../src/headers/tsip_header_WWW_Authenticate.c tsip_parser_header_WWW_Authenticate.rl
|
||||
|
|
|
@ -774,7 +774,7 @@
|
|||
main := HEADER;
|
||||
}%%
|
||||
|
||||
TSIP_BOOLEAN tsip_header_parse(tsip_ragel_state_t *state, tsip_message_t *message)
|
||||
TSIP_BOOLEAN tsip_header_parse(tsk_ragel_state_t *state, tsip_message_t *message)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = state->tag_start;
|
||||
|
@ -785,5 +785,6 @@ TSIP_BOOLEAN tsip_header_parse(tsip_ragel_state_t *state, tsip_message_t *messag
|
|||
%%write init;
|
||||
%%write exec;
|
||||
|
||||
return (cs == tsip_machine_parser_headers_first_final);
|
||||
return ( cs >= %%{ write first_final; }%% );
|
||||
//return (cs == tsip_machine_parser_headers_first_final);
|
||||
}
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
action parse_method
|
||||
{
|
||||
PARSER_ADD_STRING(hdr_allow->methods);
|
||||
TSK_PARSER_ADD_STRING(hdr_allow->methods);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
action parse_event
|
||||
{
|
||||
PARSER_ADD_STRING(hdr_allow_events->events);
|
||||
TSK_PARSER_ADD_STRING(hdr_allow_events->events);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
|
|
@ -1,290 +1,290 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file tsip_header_Authorization.c
|
||||
* @brief SIP Proxy-Authenticate header.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinysip/headers/tsip_header_Authorization.h"
|
||||
|
||||
#include "tinysip/parsers/tsip_parser_uri.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
#include "tsk_time.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**@defgroup tsip_header_Authorization_group SIP Proxy-Authenticate header.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
%%{
|
||||
machine tsip_machine_parser_header_Authorization;
|
||||
|
||||
# Includes
|
||||
include tsip_machine_utils "./tsip_machine_utils.rl";
|
||||
|
||||
action tag
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
|
||||
action is_digest
|
||||
{
|
||||
#//FIXME: Only Digest is supported
|
||||
hdr_Authorization->scheme = tsk_strdup("Digest");
|
||||
}
|
||||
|
||||
action parse_username
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Authorization->username);
|
||||
tsk_strunquote(&hdr_Authorization->username);
|
||||
}
|
||||
|
||||
action parse_realm
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Authorization->realm);
|
||||
tsk_strunquote(&hdr_Authorization->realm);
|
||||
}
|
||||
|
||||
action parse_nonce
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Authorization->nonce);
|
||||
tsk_strunquote(&hdr_Authorization->nonce);
|
||||
}
|
||||
|
||||
action parse_uri
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Authorization->uri);
|
||||
}
|
||||
|
||||
action parse_response
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Authorization->response);
|
||||
tsk_strunquote(&hdr_Authorization->response);
|
||||
}
|
||||
|
||||
action parse_algorithm
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Authorization->algorithm);
|
||||
}
|
||||
|
||||
action parse_cnonce
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Authorization->cnonce);
|
||||
tsk_strunquote(&hdr_Authorization->cnonce);
|
||||
}
|
||||
|
||||
action parse_opaque
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Authorization->opaque);
|
||||
tsk_strunquote(&hdr_Authorization->opaque);
|
||||
}
|
||||
|
||||
action parse_qop
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Authorization->qop);
|
||||
//tsk_strunquote(&hdr_Authorization->qop);
|
||||
}
|
||||
|
||||
action parse_nc
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Authorization->nc);
|
||||
}
|
||||
|
||||
action parse_param
|
||||
{
|
||||
PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_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;
|
||||
Authorization = "Authorization"i HCOLON credentials;
|
||||
|
||||
# Entry point
|
||||
main := Authorization :>CRLF @eob;
|
||||
|
||||
}%%
|
||||
|
||||
int tsip_header_Authorization_tostring(const void* header, tsk_buffer_t* output)
|
||||
{
|
||||
if(header)
|
||||
{
|
||||
const tsip_header_Authorization_t *Authorization = header;
|
||||
if(Authorization && Authorization->scheme)
|
||||
{
|
||||
return tsk_buffer_appendEx(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",
|
||||
Authorization->scheme,
|
||||
|
||||
Authorization->username ? "username=\"" : "",
|
||||
Authorization->username ? Authorization->username : "",
|
||||
Authorization->username ? "\"" : "",
|
||||
|
||||
Authorization->realm ? ",realm=\"" : "",
|
||||
Authorization->realm ? Authorization->realm : "",
|
||||
Authorization->realm ? "\"" : "",
|
||||
|
||||
Authorization->nonce ? ",nonce=\"" : "",
|
||||
Authorization->nonce ? Authorization->nonce : "",
|
||||
Authorization->nonce ? "\"" : "",
|
||||
|
||||
Authorization->uri ? ",uri=\"" : "",
|
||||
Authorization->uri ? Authorization->uri : "",
|
||||
Authorization->uri ? "\"" : "",
|
||||
|
||||
Authorization->response ? ",response=\"" : "",
|
||||
Authorization->response ? Authorization->response : "",
|
||||
Authorization->response ? "\"" : "",
|
||||
|
||||
Authorization->algorithm ? ",algorithm=" : "",
|
||||
Authorization->algorithm ? Authorization->algorithm : "",
|
||||
|
||||
Authorization->cnonce ? ",cnonce=\"" : "",
|
||||
Authorization->cnonce ? Authorization->cnonce : "",
|
||||
Authorization->cnonce ? "\"" : "",
|
||||
|
||||
Authorization->opaque ? ",opaque=\"" : "",
|
||||
Authorization->opaque ? Authorization->opaque : "",
|
||||
Authorization->opaque ? "\"" : "",
|
||||
|
||||
Authorization->qop ? ",qop=" : "",
|
||||
Authorization->qop ? Authorization->qop : "",
|
||||
|
||||
Authorization->nc ? ",nc=" : "",
|
||||
Authorization->nc ? Authorization->nc : ""
|
||||
);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
tsip_header_Authorization_t *tsip_header_Authorization_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
tsip_header_Authorization_t *hdr_Authorization = TSIP_HEADER_AUTHORIZATION_CREATE();
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
%%write data;
|
||||
%%write init;
|
||||
%%write exec;
|
||||
|
||||
if( cs < %%{ write first_final; }%% )
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(hdr_Authorization);
|
||||
}
|
||||
|
||||
return hdr_Authorization;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// Authorization header object definition
|
||||
///*
|
||||
//* Copyright (C) 2009 Mamadou Diop.
|
||||
//*
|
||||
//* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
//*
|
||||
//* 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 Lesser General Public License for more details.
|
||||
//*
|
||||
//* You should have received a copy of the GNU General Public License
|
||||
//* along with DOUBANGO.
|
||||
//*
|
||||
//*/
|
||||
//
|
||||
|
||||
/**@ingroup tsip_header_Authorization_group
|
||||
*/
|
||||
static void* tsip_header_Authorization_create(void *self, va_list * app)
|
||||
{
|
||||
tsip_header_Authorization_t *Authorization = self;
|
||||
if(Authorization)
|
||||
{
|
||||
TSIP_HEADER(Authorization)->type = tsip_htype_Authorization;
|
||||
TSIP_HEADER(Authorization)->tostring = tsip_header_Authorization_tostring;
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new Authorization header.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup tsip_header_Authorization_group
|
||||
*/
|
||||
static void* tsip_header_Authorization_destroy(void *self)
|
||||
{
|
||||
tsip_header_Authorization_t *Authorization = self;
|
||||
if(Authorization)
|
||||
{
|
||||
TSK_FREE(Authorization->scheme);
|
||||
TSK_FREE(Authorization->username);
|
||||
TSK_FREE(Authorization->realm);
|
||||
TSK_FREE(Authorization->nonce);
|
||||
TSK_FREE(Authorization->uri);
|
||||
TSK_FREE(Authorization->response);
|
||||
TSK_FREE(Authorization->algorithm);
|
||||
TSK_FREE(Authorization->cnonce);
|
||||
TSK_FREE(Authorization->opaque);
|
||||
TSK_FREE(Authorization->qop);
|
||||
TSK_FREE(Authorization->nc);
|
||||
|
||||
TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Authorization));
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null Authorization header.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tsip_header_Authorization_def_s =
|
||||
{
|
||||
sizeof(tsip_header_Authorization_t),
|
||||
tsip_header_Authorization_create,
|
||||
tsip_header_Authorization_destroy,
|
||||
0
|
||||
};
|
||||
const void *tsip_header_Authorization_def_t = &tsip_header_Authorization_def_s;
|
||||
///**@file tsip_header_Authorization.c
|
||||
// * @brief SIP Authorization header.
|
||||
// *
|
||||
// * @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
// *
|
||||
// * @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
// */
|
||||
//#include "tinysip/headers/tsip_header_Authorization.h"
|
||||
//
|
||||
//#include "tinysip/parsers/tsip_parser_uri.h"
|
||||
//
|
||||
//#include "tsk_debug.h"
|
||||
//#include "tsk_memory.h"
|
||||
//#include "tsk_time.h"
|
||||
//
|
||||
//#include <string.h>
|
||||
//
|
||||
///**@defgroup tsip_header_Authorization_group SIP Proxy-Authenticate header.
|
||||
//*/
|
||||
//
|
||||
///***********************************
|
||||
//* Ragel state machine.
|
||||
//*/
|
||||
//%%{
|
||||
// machine tsip_machine_parser_header_Authorization;
|
||||
//
|
||||
// # Includes
|
||||
// include tsip_machine_utils "./tsip_machine_utils.rl";
|
||||
//
|
||||
// action tag
|
||||
// {
|
||||
// tag_start = p;
|
||||
// }
|
||||
//
|
||||
// action is_digest
|
||||
// {
|
||||
// #//FIXME: Only Digest is supported
|
||||
// hdr_Authorization->scheme = tsk_strdup("Digest");
|
||||
// }
|
||||
//
|
||||
// action parse_username
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Authorization->username);
|
||||
// tsk_strunquote(&hdr_Authorization->username);
|
||||
// }
|
||||
//
|
||||
// action parse_realm
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Authorization->realm);
|
||||
// tsk_strunquote(&hdr_Authorization->realm);
|
||||
// }
|
||||
//
|
||||
// action parse_nonce
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Authorization->nonce);
|
||||
// tsk_strunquote(&hdr_Authorization->nonce);
|
||||
// }
|
||||
//
|
||||
// action parse_uri
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Authorization->uri);
|
||||
// }
|
||||
//
|
||||
// action parse_response
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Authorization->response);
|
||||
// tsk_strunquote(&hdr_Authorization->response);
|
||||
// }
|
||||
//
|
||||
// action parse_algorithm
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Authorization->algorithm);
|
||||
// }
|
||||
//
|
||||
// action parse_cnonce
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Authorization->cnonce);
|
||||
// tsk_strunquote(&hdr_Authorization->cnonce);
|
||||
// }
|
||||
//
|
||||
// action parse_opaque
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Authorization->opaque);
|
||||
// tsk_strunquote(&hdr_Authorization->opaque);
|
||||
// }
|
||||
//
|
||||
// action parse_qop
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Authorization->qop);
|
||||
// //tsk_strunquote(&hdr_Authorization->qop);
|
||||
// }
|
||||
//
|
||||
// action parse_nc
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Authorization->nc);
|
||||
// }
|
||||
//
|
||||
// action parse_param
|
||||
// {
|
||||
// TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_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;
|
||||
// Authorization = "Authorization"i HCOLON credentials;
|
||||
//
|
||||
// # Entry point
|
||||
// main := Authorization :>CRLF @eob;
|
||||
//
|
||||
//}%%
|
||||
//
|
||||
//int tsip_header_Authorization_tostring(const void* header, tsk_buffer_t* output)
|
||||
//{
|
||||
// if(header)
|
||||
// {
|
||||
// const tsip_header_Authorization_t *Authorization = header;
|
||||
// if(Authorization && Authorization->scheme)
|
||||
// {
|
||||
// return tsk_buffer_appendEx(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",
|
||||
// Authorization->scheme,
|
||||
//
|
||||
// Authorization->username ? "username=\"" : "",
|
||||
// Authorization->username ? Authorization->username : "",
|
||||
// Authorization->username ? "\"" : "",
|
||||
//
|
||||
// Authorization->realm ? ",realm=\"" : "",
|
||||
// Authorization->realm ? Authorization->realm : "",
|
||||
// Authorization->realm ? "\"" : "",
|
||||
//
|
||||
// Authorization->nonce ? ",nonce=\"" : "",
|
||||
// Authorization->nonce ? Authorization->nonce : "",
|
||||
// Authorization->nonce ? "\"" : "",
|
||||
//
|
||||
// Authorization->uri ? ",uri=\"" : "",
|
||||
// Authorization->uri ? Authorization->uri : "",
|
||||
// Authorization->uri ? "\"" : "",
|
||||
//
|
||||
// Authorization->response ? ",response=\"" : "",
|
||||
// Authorization->response ? Authorization->response : "",
|
||||
// Authorization->response ? "\"" : "",
|
||||
//
|
||||
// Authorization->algorithm ? ",algorithm=" : "",
|
||||
// Authorization->algorithm ? Authorization->algorithm : "",
|
||||
//
|
||||
// Authorization->cnonce ? ",cnonce=\"" : "",
|
||||
// Authorization->cnonce ? Authorization->cnonce : "",
|
||||
// Authorization->cnonce ? "\"" : "",
|
||||
//
|
||||
// Authorization->opaque ? ",opaque=\"" : "",
|
||||
// Authorization->opaque ? Authorization->opaque : "",
|
||||
// Authorization->opaque ? "\"" : "",
|
||||
//
|
||||
// Authorization->qop ? ",qop=" : "",
|
||||
// Authorization->qop ? Authorization->qop : "",
|
||||
//
|
||||
// Authorization->nc ? ",nc=" : "",
|
||||
// Authorization->nc ? Authorization->nc : ""
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// return -1;
|
||||
//}
|
||||
//
|
||||
//tsip_header_Authorization_t *tsip_header_Authorization_parse(const char *data, size_t size)
|
||||
//{
|
||||
// int cs = 0;
|
||||
// const char *p = data;
|
||||
// const char *pe = p + size;
|
||||
// const char *eof = pe;
|
||||
// tsip_header_Authorization_t *hdr_Authorization = TSIP_HEADER_AUTHORIZATION_CREATE();
|
||||
//
|
||||
// const char *tag_start;
|
||||
//
|
||||
// %%write data;
|
||||
// %%write init;
|
||||
// %%write exec;
|
||||
//
|
||||
// if( cs < %%{ write first_final; }%% )
|
||||
// {
|
||||
// TSK_OBJECT_SAFE_FREE(hdr_Authorization);
|
||||
// }
|
||||
//
|
||||
// return hdr_Authorization;
|
||||
//}
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
////========================================================
|
||||
//// Authorization header object definition
|
||||
////
|
||||
//
|
||||
///**@ingroup tsip_header_Authorization_group
|
||||
//*/
|
||||
//static void* tsip_header_Authorization_create(void *self, va_list * app)
|
||||
//{
|
||||
// tsip_header_Authorization_t *Authorization = self;
|
||||
// if(Authorization)
|
||||
// {
|
||||
// TSIP_HEADER(Authorization)->type = tsip_htype_Authorization;
|
||||
// TSIP_HEADER(Authorization)->tostring = tsip_header_Authorization_tostring;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// TSK_DEBUG_ERROR("Failed to create new Authorization header.");
|
||||
// }
|
||||
// return self;
|
||||
//}
|
||||
//
|
||||
///**@ingroup tsip_header_Authorization_group
|
||||
//*/
|
||||
//static void* tsip_header_Authorization_destroy(void *self)
|
||||
//{
|
||||
// tsip_header_Authorization_t *Authorization = self;
|
||||
// if(Authorization)
|
||||
// {
|
||||
// TSK_FREE(Authorization->scheme);
|
||||
// TSK_FREE(Authorization->username);
|
||||
// TSK_FREE(Authorization->realm);
|
||||
// TSK_FREE(Authorization->nonce);
|
||||
// TSK_FREE(Authorization->uri);
|
||||
// TSK_FREE(Authorization->response);
|
||||
// TSK_FREE(Authorization->algorithm);
|
||||
// TSK_FREE(Authorization->cnonce);
|
||||
// TSK_FREE(Authorization->opaque);
|
||||
// TSK_FREE(Authorization->qop);
|
||||
// TSK_FREE(Authorization->nc);
|
||||
//
|
||||
// TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Authorization));
|
||||
// }
|
||||
// else TSK_DEBUG_ERROR("Null Authorization header.");
|
||||
//
|
||||
// return self;
|
||||
//}
|
||||
//
|
||||
//static const tsk_object_def_t tsip_header_Authorization_def_s =
|
||||
//{
|
||||
// sizeof(tsip_header_Authorization_t),
|
||||
// tsip_header_Authorization_create,
|
||||
// tsip_header_Authorization_destroy,
|
||||
// 0
|
||||
//};
|
||||
//const void *tsip_header_Authorization_def_t = &tsip_header_Authorization_def_s;
|
|
@ -53,12 +53,12 @@
|
|||
|
||||
action parse_method
|
||||
{
|
||||
PARSER_SET_STRING(hdr_cseq->method);
|
||||
TSK_PARSER_SET_STRING(hdr_cseq->method);
|
||||
}
|
||||
|
||||
action parse_seq
|
||||
{
|
||||
PARSER_SET_INTEGER(hdr_cseq->seq);
|
||||
TSK_PARSER_SET_INTEGER(hdr_cseq->seq);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
action parse_value
|
||||
{
|
||||
PARSER_SET_STRING(hdr_call_id->value);
|
||||
TSK_PARSER_SET_STRING(hdr_call_id->value);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
{
|
||||
if(curr_contact)
|
||||
{
|
||||
PARSER_SET_STRING(curr_contact->display_name);
|
||||
TSK_PARSER_SET_STRING(curr_contact->display_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@
|
|||
{
|
||||
if(curr_contact)
|
||||
{
|
||||
PARSER_SET_INTEGER(curr_contact->expires);
|
||||
TSK_PARSER_SET_INTEGER(curr_contact->expires);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@
|
|||
{
|
||||
if(curr_contact)
|
||||
{
|
||||
PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_contact));
|
||||
TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_contact));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@
|
|||
|
||||
c_p_expires = "expires"i EQUAL delta_seconds>tag %parse_expires;
|
||||
contact_extension = (generic_param)>tag %parse_param;
|
||||
contact_params = c_p_expires>1 | contact_extension>0;
|
||||
contact_params = c_p_expires@1 | contact_extension@0;
|
||||
contact_param = (( my_name_addr | URI ) <: ( SEMI contact_params )*) >create_contact %add_contact;
|
||||
Contact = ( "Contact"i | "m"i ) HCOLON ( STAR | ( contact_param ( COMMA contact_param )* ) );
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
action parse_content_length
|
||||
{
|
||||
PARSER_SET_INTEGER(hdr_clength->length);
|
||||
TSK_PARSER_SET_INTEGER(hdr_clength->length);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
|
|
@ -53,12 +53,12 @@
|
|||
|
||||
action parse_content_type
|
||||
{
|
||||
PARSER_SET_STRING(hdr_ctype->type);
|
||||
TSK_PARSER_SET_STRING(hdr_ctype->type);
|
||||
}
|
||||
|
||||
action parse_param
|
||||
{
|
||||
PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_ctype));
|
||||
TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_ctype));
|
||||
}
|
||||
|
||||
action eob
|
||||
|
@ -76,7 +76,7 @@
|
|||
m_type = discrete_type | composite_type;
|
||||
m_subtype = extension_token | iana_token;
|
||||
|
||||
media_type = (m_type SLASH m_subtype)>1 >tag %parse_content_type ((SEMI m_parameter)*)>0;
|
||||
media_type = (m_type SLASH m_subtype)@1 >tag %parse_content_type ((SEMI m_parameter)*)@0;
|
||||
|
||||
Content_Type = ( "Content-Type"i | "c"i ) HCOLON media_type;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
action parse_delta_seconds
|
||||
{
|
||||
PARSER_SET_INTEGER(hdr_expires->delta_seconds);
|
||||
TSK_PARSER_SET_INTEGER(hdr_expires->delta_seconds);
|
||||
TSK_DEBUG_INFO("EXPIRES:PARSE_DELTA_SECONDS");
|
||||
}
|
||||
|
||||
|
|
|
@ -59,17 +59,17 @@
|
|||
|
||||
action parse_display_name
|
||||
{
|
||||
PARSER_SET_STRING(hdr_from->display_name);
|
||||
TSK_PARSER_SET_STRING(hdr_from->display_name);
|
||||
}
|
||||
|
||||
action parse_tag
|
||||
{
|
||||
PARSER_SET_STRING(hdr_from->tag);
|
||||
TSK_PARSER_SET_STRING(hdr_from->tag);
|
||||
}
|
||||
|
||||
action parse_param
|
||||
{
|
||||
PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_from));
|
||||
TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_from));
|
||||
}
|
||||
|
||||
action eob
|
||||
|
@ -80,7 +80,7 @@
|
|||
display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name;
|
||||
my_name_addr = display_name? :>LAQUOT<: URI :>RAQUOT;
|
||||
my_tag_param = "tag"i EQUAL token>tag %parse_tag;
|
||||
from_param = (my_tag_param)>1 | (generic_param)>0 >tag %parse_param;
|
||||
from_param = (my_tag_param)@1 | (generic_param)@0 >tag %parse_param;
|
||||
from_spec = ( my_name_addr | URI ) :> ( SEMI from_param )*;
|
||||
|
||||
From = ( "From"i | "f"i ) HCOLON from_spec;
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
|
||||
action parse_value
|
||||
{
|
||||
PARSER_SET_INTEGER(hdr_maxf->value);
|
||||
TSK_PARSER_SET_INTEGER(hdr_maxf->value);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
|
||||
action parse_value
|
||||
{
|
||||
PARSER_SET_INTEGER(hdr_minE->value);
|
||||
TSK_PARSER_SET_INTEGER(hdr_minE->value);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
|
||||
action parse_value
|
||||
{
|
||||
PARSER_SET_STRING(hdr_ani->value);
|
||||
TSK_PARSER_SET_STRING(hdr_ani->value);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
{
|
||||
if(!hdr_pi->display_name)
|
||||
{
|
||||
PARSER_SET_STRING(hdr_pi->display_name);
|
||||
TSK_PARSER_SET_STRING(hdr_pi->display_name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
{
|
||||
if(curr_path)
|
||||
{
|
||||
PARSER_SET_STRING(curr_path->display_name);
|
||||
TSK_PARSER_SET_STRING(curr_path->display_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@
|
|||
{
|
||||
if(curr_path)
|
||||
{
|
||||
PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_path));
|
||||
TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_path));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,14 +63,14 @@
|
|||
|
||||
action parse_priv_value
|
||||
{
|
||||
PARSER_ADD_STRING(hdr_privacy->values);
|
||||
TSK_PARSER_ADD_STRING(hdr_privacy->values);
|
||||
}
|
||||
|
||||
action eob
|
||||
{
|
||||
}
|
||||
|
||||
priv_value = ("header"i | "session"i | "user"i | "none"i | "critical"i | "id"i | "history"i)>1 | token>0;
|
||||
priv_value = ("header"i | "session"i | "user"i | "none"i | "critical"i | "id"i | "history"i)@1 | token@0;
|
||||
Privacy_hdr = "Privacy"i HCOLON priv_value>tag %parse_priv_value ( ";" priv_value>tag %parse_priv_value )*;
|
||||
|
||||
# Entry point
|
||||
|
|
|
@ -1,250 +1,250 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser 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_Authenticate.c
|
||||
* @brief SIP Proxy-Authenticate header.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinysip/headers/tsip_header_Proxy_Authenticate.h"
|
||||
|
||||
#include "tinysip/parsers/tsip_parser_uri.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
#include "tsk_time.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**@defgroup tsip_header_Proxy_Authenticate_group SIP Proxy-Authenticate header.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
%%{
|
||||
machine tsip_machine_parser_header_Proxy_Authenticate;
|
||||
|
||||
# Includes
|
||||
include tsip_machine_utils "./tsip_machine_utils.rl";
|
||||
|
||||
action tag
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
|
||||
action is_digest
|
||||
{
|
||||
#//FIXME: Only Digest is supported
|
||||
hdr_Proxy_Authenticate->scheme = tsk_strdup("Digest");
|
||||
}
|
||||
|
||||
action parse_realm
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authenticate->realm);
|
||||
tsk_strunquote(&hdr_Proxy_Authenticate->realm);
|
||||
}
|
||||
|
||||
action parse_domain
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authenticate->domain);
|
||||
//tsk_strunquote(&hdr_Proxy_Authenticate->domain);
|
||||
}
|
||||
|
||||
action parse_nonce
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authenticate->nonce);
|
||||
tsk_strunquote(&hdr_Proxy_Authenticate->nonce);
|
||||
}
|
||||
|
||||
action parse_opaque
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authenticate->opaque);
|
||||
tsk_strunquote(&hdr_Proxy_Authenticate->opaque);
|
||||
}
|
||||
|
||||
action parse_stale
|
||||
{
|
||||
hdr_Proxy_Authenticate->stale = tsk_strniequals(tag_start, "true", 4);
|
||||
}
|
||||
|
||||
action parse_algorithm
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authenticate->algorithm);
|
||||
}
|
||||
|
||||
action parse_qop
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authenticate->qop);
|
||||
//tsk_strunquote(&hdr_Proxy_Authenticate->qop);
|
||||
}
|
||||
|
||||
action parse_param
|
||||
{
|
||||
PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_Proxy_Authenticate));
|
||||
}
|
||||
|
||||
action eob
|
||||
{
|
||||
}
|
||||
|
||||
#FIXME: Only Digest (MD5, AKAv1-MD5 and AKAv2-MD5) is supported
|
||||
other_challenge = (any+);
|
||||
auth_param = generic_param>tag %parse_param;
|
||||
|
||||
realm = "realm"i EQUAL quoted_string>tag %parse_realm;
|
||||
domain = "domain"i EQUAL LDQUOT <: (any*)>tag %parse_domain :> RDQUOT;
|
||||
nonce = "nonce"i EQUAL quoted_string>tag %parse_nonce;
|
||||
opaque = "opaque"i EQUAL quoted_string>tag %parse_opaque;
|
||||
stale = "stale"i EQUAL ( "true"i | "false"i )>tag %parse_stale;
|
||||
algorithm = "algorithm"i EQUAL <:token>tag %parse_algorithm;
|
||||
qop_options = "qop"i EQUAL LDQUOT <: (any*)>tag %parse_qop :> RDQUOT;
|
||||
|
||||
digest_cln = (realm | domain | nonce | opaque | stale | algorithm | qop_options)>1 | auth_param>0;
|
||||
challenge = ( "Digest"i LWS digest_cln ( COMMA digest_cln )* )>is_digest | other_challenge;
|
||||
Proxy_Authenticate = "Proxy-Authenticate"i HCOLON challenge;
|
||||
|
||||
# Entry point
|
||||
main := Proxy_Authenticate :>CRLF @eob;
|
||||
|
||||
}%%
|
||||
|
||||
int tsip_header_Proxy_Authenticate_tostring(const void* header, tsk_buffer_t* output)
|
||||
{
|
||||
if(header)
|
||||
{
|
||||
const tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = header;
|
||||
if(Proxy_Authenticate && Proxy_Authenticate->scheme)
|
||||
{
|
||||
return tsk_buffer_appendEx(output, "%s realm=\"%s\"%s%s%s%s%s%s%s%s%s%s%s%s,stale=%s%s%s",
|
||||
Proxy_Authenticate->scheme,
|
||||
Proxy_Authenticate->realm ? Proxy_Authenticate->realm : "",
|
||||
|
||||
Proxy_Authenticate->domain ? ",domain=\"" : "",
|
||||
Proxy_Authenticate->domain ? Proxy_Authenticate->domain : "",
|
||||
Proxy_Authenticate->domain ? "\"" : "",
|
||||
|
||||
|
||||
Proxy_Authenticate->qop ? ",qop=\"" : "",
|
||||
Proxy_Authenticate->qop ? Proxy_Authenticate->qop : "",
|
||||
Proxy_Authenticate->qop ? "\"" : "",
|
||||
|
||||
|
||||
Proxy_Authenticate->nonce ? ",nonce=\"" : "",
|
||||
Proxy_Authenticate->nonce ? Proxy_Authenticate->nonce : "",
|
||||
Proxy_Authenticate->nonce ? "\"" : "",
|
||||
|
||||
Proxy_Authenticate->opaque ? ",opaque=\"" : "",
|
||||
Proxy_Authenticate->opaque ? Proxy_Authenticate->opaque : "",
|
||||
Proxy_Authenticate->opaque ? "\"" : "",
|
||||
|
||||
Proxy_Authenticate->stale ? "TRUE" : "FALSE",
|
||||
|
||||
Proxy_Authenticate->algorithm ? ",algorithm=" : "",
|
||||
Proxy_Authenticate->algorithm ? Proxy_Authenticate->algorithm : ""
|
||||
);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
tsip_header_Proxy_Authenticate_t *tsip_header_Proxy_Authenticate_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
tsip_header_Proxy_Authenticate_t *hdr_Proxy_Authenticate = TSIP_HEADER_PROXY_AUTHENTICATE_CREATE();
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
%%write data;
|
||||
%%write init;
|
||||
%%write exec;
|
||||
|
||||
if( cs < %%{ write first_final; }%% )
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(hdr_Proxy_Authenticate);
|
||||
}
|
||||
|
||||
return hdr_Proxy_Authenticate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// Proxy_Authenticate header object definition
|
||||
///*
|
||||
//* Copyright (C) 2009 Mamadou Diop.
|
||||
//*
|
||||
//* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
//*
|
||||
//* 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 Lesser General Public License for more details.
|
||||
//*
|
||||
//* You should have received a copy of the GNU General Public License
|
||||
//* along with DOUBANGO.
|
||||
//*
|
||||
//*/
|
||||
//
|
||||
|
||||
/**@ingroup tsip_header_Proxy_Authenticate_group
|
||||
*/
|
||||
static void* tsip_header_Proxy_Authenticate_create(void *self, va_list * app)
|
||||
{
|
||||
tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = self;
|
||||
if(Proxy_Authenticate)
|
||||
{
|
||||
TSIP_HEADER(Proxy_Authenticate)->type = tsip_htype_Proxy_Authenticate;
|
||||
TSIP_HEADER(Proxy_Authenticate)->tostring = tsip_header_Proxy_Authenticate_tostring;
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new Proxy_Authenticate header.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup tsip_header_Proxy_Authenticate_group
|
||||
*/
|
||||
static void* tsip_header_Proxy_Authenticate_destroy(void *self)
|
||||
{
|
||||
tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = self;
|
||||
if(Proxy_Authenticate)
|
||||
{
|
||||
TSK_FREE(Proxy_Authenticate->scheme);
|
||||
TSK_FREE(Proxy_Authenticate->realm);
|
||||
TSK_FREE(Proxy_Authenticate->domain);
|
||||
TSK_FREE(Proxy_Authenticate->nonce);
|
||||
TSK_FREE(Proxy_Authenticate->opaque);
|
||||
TSK_FREE(Proxy_Authenticate->algorithm);
|
||||
TSK_FREE(Proxy_Authenticate->qop);
|
||||
|
||||
TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Proxy_Authenticate));
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null Proxy_Authenticate header.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tsip_header_Proxy_Authenticate_def_s =
|
||||
{
|
||||
sizeof(tsip_header_Proxy_Authenticate_t),
|
||||
tsip_header_Proxy_Authenticate_create,
|
||||
tsip_header_Proxy_Authenticate_destroy,
|
||||
0
|
||||
};
|
||||
const void *tsip_header_Proxy_Authenticate_def_t = &tsip_header_Proxy_Authenticate_def_s;
|
||||
///**@file tsip_header_Proxy_Authenticate.c
|
||||
// * @brief SIP Proxy-Authenticate header.
|
||||
// *
|
||||
// * @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
// *
|
||||
// * @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
// */
|
||||
//#include "tinysip/headers/tsip_header_Proxy_Authenticate.h"
|
||||
//
|
||||
//#include "tinysip/parsers/tsip_parser_uri.h"
|
||||
//
|
||||
//#include "tsk_debug.h"
|
||||
//#include "tsk_memory.h"
|
||||
//#include "tsk_time.h"
|
||||
//
|
||||
//#include <string.h>
|
||||
//
|
||||
///**@defgroup tsip_header_Proxy_Authenticate_group SIP Proxy-Authenticate header.
|
||||
//*/
|
||||
//
|
||||
///***********************************
|
||||
//* Ragel state machine.
|
||||
//*/
|
||||
//%%{
|
||||
// machine tsip_machine_parser_header_Proxy_Authenticate;
|
||||
//
|
||||
// # Includes
|
||||
// include tsip_machine_utils "./tsip_machine_utils.rl";
|
||||
//
|
||||
// action tag
|
||||
// {
|
||||
// tag_start = p;
|
||||
// }
|
||||
//
|
||||
// action is_digest
|
||||
// {
|
||||
// #//FIXME: Only Digest is supported
|
||||
// hdr_Proxy_Authenticate->scheme = tsk_strdup("Digest");
|
||||
// }
|
||||
//
|
||||
// action parse_realm
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Proxy_Authenticate->realm);
|
||||
// tsk_strunquote(&hdr_Proxy_Authenticate->realm);
|
||||
// }
|
||||
//
|
||||
// action parse_domain
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Proxy_Authenticate->domain);
|
||||
// //tsk_strunquote(&hdr_Proxy_Authenticate->domain);
|
||||
// }
|
||||
//
|
||||
// action parse_nonce
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Proxy_Authenticate->nonce);
|
||||
// tsk_strunquote(&hdr_Proxy_Authenticate->nonce);
|
||||
// }
|
||||
//
|
||||
// action parse_opaque
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Proxy_Authenticate->opaque);
|
||||
// tsk_strunquote(&hdr_Proxy_Authenticate->opaque);
|
||||
// }
|
||||
//
|
||||
// action parse_stale
|
||||
// {
|
||||
// hdr_Proxy_Authenticate->stale = tsk_strniequals(tag_start, "true", 4);
|
||||
// }
|
||||
//
|
||||
// action parse_algorithm
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Proxy_Authenticate->algorithm);
|
||||
// }
|
||||
//
|
||||
// action parse_qop
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_Proxy_Authenticate->qop);
|
||||
// //tsk_strunquote(&hdr_Proxy_Authenticate->qop);
|
||||
// }
|
||||
//
|
||||
// action parse_param
|
||||
// {
|
||||
// TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_Proxy_Authenticate));
|
||||
// }
|
||||
//
|
||||
// action eob
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// #FIXME: Only Digest (MD5, AKAv1-MD5 and AKAv2-MD5) is supported
|
||||
// other_challenge = (any+);
|
||||
// auth_param = generic_param>tag %parse_param;
|
||||
//
|
||||
// realm = "realm"i EQUAL quoted_string>tag %parse_realm;
|
||||
// domain = "domain"i EQUAL LDQUOT <: (any*)>tag %parse_domain :> RDQUOT;
|
||||
// nonce = "nonce"i EQUAL quoted_string>tag %parse_nonce;
|
||||
// opaque = "opaque"i EQUAL quoted_string>tag %parse_opaque;
|
||||
// stale = "stale"i EQUAL ( "true"i | "false"i )>tag %parse_stale;
|
||||
// algorithm = "algorithm"i EQUAL <:token>tag %parse_algorithm;
|
||||
// qop_options = "qop"i EQUAL LDQUOT <: (any*)>tag %parse_qop :> RDQUOT;
|
||||
//
|
||||
// digest_cln = (realm | domain | nonce | opaque | stale | algorithm | qop_options)@1 | auth_param@0;
|
||||
// challenge = ( "Digest"i LWS digest_cln ( COMMA digest_cln )* )>is_digest | other_challenge;
|
||||
// Proxy_Authenticate = "Proxy-Authenticate"i HCOLON challenge;
|
||||
//
|
||||
// # Entry point
|
||||
// main := Proxy_Authenticate :>CRLF @eob;
|
||||
//
|
||||
//}%%
|
||||
//
|
||||
//int tsip_header_Proxy_Authenticate_tostring(const void* header, tsk_buffer_t* output)
|
||||
//{
|
||||
// if(header)
|
||||
// {
|
||||
// const tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = header;
|
||||
// if(Proxy_Authenticate && Proxy_Authenticate->scheme)
|
||||
// {
|
||||
// return tsk_buffer_appendEx(output, "%s realm=\"%s\"%s%s%s%s%s%s%s%s%s%s%s%s,stale=%s%s%s",
|
||||
// Proxy_Authenticate->scheme,
|
||||
// Proxy_Authenticate->realm ? Proxy_Authenticate->realm : "",
|
||||
//
|
||||
// Proxy_Authenticate->domain ? ",domain=\"" : "",
|
||||
// Proxy_Authenticate->domain ? Proxy_Authenticate->domain : "",
|
||||
// Proxy_Authenticate->domain ? "\"" : "",
|
||||
//
|
||||
//
|
||||
// Proxy_Authenticate->qop ? ",qop=\"" : "",
|
||||
// Proxy_Authenticate->qop ? Proxy_Authenticate->qop : "",
|
||||
// Proxy_Authenticate->qop ? "\"" : "",
|
||||
//
|
||||
//
|
||||
// Proxy_Authenticate->nonce ? ",nonce=\"" : "",
|
||||
// Proxy_Authenticate->nonce ? Proxy_Authenticate->nonce : "",
|
||||
// Proxy_Authenticate->nonce ? "\"" : "",
|
||||
//
|
||||
// Proxy_Authenticate->opaque ? ",opaque=\"" : "",
|
||||
// Proxy_Authenticate->opaque ? Proxy_Authenticate->opaque : "",
|
||||
// Proxy_Authenticate->opaque ? "\"" : "",
|
||||
//
|
||||
// Proxy_Authenticate->stale ? "TRUE" : "FALSE",
|
||||
//
|
||||
// Proxy_Authenticate->algorithm ? ",algorithm=" : "",
|
||||
// Proxy_Authenticate->algorithm ? Proxy_Authenticate->algorithm : ""
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// return -1;
|
||||
//}
|
||||
//
|
||||
//tsip_header_Proxy_Authenticate_t *tsip_header_Proxy_Authenticate_parse(const char *data, size_t size)
|
||||
//{
|
||||
// int cs = 0;
|
||||
// const char *p = data;
|
||||
// const char *pe = p + size;
|
||||
// const char *eof = pe;
|
||||
// tsip_header_Proxy_Authenticate_t *hdr_Proxy_Authenticate = TSIP_HEADER_PROXY_AUTHENTICATE_CREATE();
|
||||
//
|
||||
// const char *tag_start;
|
||||
//
|
||||
// %%write data;
|
||||
// %%write init;
|
||||
// %%write exec;
|
||||
//
|
||||
// if( cs < %%{ write first_final; }%% )
|
||||
// {
|
||||
// TSK_OBJECT_SAFE_FREE(hdr_Proxy_Authenticate);
|
||||
// }
|
||||
//
|
||||
// return hdr_Proxy_Authenticate;
|
||||
//}
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
////========================================================
|
||||
//// Proxy_Authenticate header object definition
|
||||
////
|
||||
//
|
||||
///**@ingroup tsip_header_Proxy_Authenticate_group
|
||||
//*/
|
||||
//static void* tsip_header_Proxy_Authenticate_create(void *self, va_list * app)
|
||||
//{
|
||||
// tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = self;
|
||||
// if(Proxy_Authenticate)
|
||||
// {
|
||||
// TSIP_HEADER(Proxy_Authenticate)->type = tsip_htype_Proxy_Authenticate;
|
||||
// TSIP_HEADER(Proxy_Authenticate)->tostring = tsip_header_Proxy_Authenticate_tostring;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// TSK_DEBUG_ERROR("Failed to create new Proxy_Authenticate header.");
|
||||
// }
|
||||
// return self;
|
||||
//}
|
||||
//
|
||||
///**@ingroup tsip_header_Proxy_Authenticate_group
|
||||
//*/
|
||||
//static void* tsip_header_Proxy_Authenticate_destroy(void *self)
|
||||
//{
|
||||
// tsip_header_Proxy_Authenticate_t *Proxy_Authenticate = self;
|
||||
// if(Proxy_Authenticate)
|
||||
// {
|
||||
// TSK_FREE(Proxy_Authenticate->scheme);
|
||||
// TSK_FREE(Proxy_Authenticate->realm);
|
||||
// TSK_FREE(Proxy_Authenticate->domain);
|
||||
// TSK_FREE(Proxy_Authenticate->nonce);
|
||||
// TSK_FREE(Proxy_Authenticate->opaque);
|
||||
// TSK_FREE(Proxy_Authenticate->algorithm);
|
||||
// TSK_FREE(Proxy_Authenticate->qop);
|
||||
//
|
||||
// TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Proxy_Authenticate));
|
||||
// }
|
||||
// else TSK_DEBUG_ERROR("Null Proxy_Authenticate header.");
|
||||
//
|
||||
// return self;
|
||||
//}
|
||||
//
|
||||
//static const tsk_object_def_t tsip_header_Proxy_Authenticate_def_s =
|
||||
//{
|
||||
// sizeof(tsip_header_Proxy_Authenticate_t),
|
||||
// tsip_header_Proxy_Authenticate_create,
|
||||
// tsip_header_Proxy_Authenticate_destroy,
|
||||
// 0
|
||||
//};
|
||||
//const void *tsip_header_Proxy_Authenticate_def_t = &tsip_header_Proxy_Authenticate_def_s;
|
|
@ -1,291 +1,291 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser 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)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#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>
|
||||
|
||||
/**@defgroup tsip_header_Proxy_Authorization_group SIP Proxy-Authenticate header.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
%%{
|
||||
machine tsip_machine_parser_header_Proxy_Authorization;
|
||||
|
||||
# Includes
|
||||
include tsip_machine_utils "./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
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authorization->username);
|
||||
tsk_strunquote(&hdr_Proxy_Authorization->username);
|
||||
}
|
||||
|
||||
action parse_realm
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authorization->realm);
|
||||
tsk_strunquote(&hdr_Proxy_Authorization->realm);
|
||||
}
|
||||
|
||||
action parse_nonce
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authorization->nonce);
|
||||
tsk_strunquote(&hdr_Proxy_Authorization->nonce);
|
||||
}
|
||||
|
||||
action parse_uri
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authorization->uri);
|
||||
}
|
||||
|
||||
action parse_response
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authorization->response);
|
||||
tsk_strunquote(&hdr_Proxy_Authorization->response);
|
||||
}
|
||||
|
||||
action parse_algorithm
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authorization->algorithm);
|
||||
}
|
||||
|
||||
action parse_cnonce
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authorization->cnonce);
|
||||
tsk_strunquote(&hdr_Proxy_Authorization->cnonce);
|
||||
}
|
||||
|
||||
action parse_opaque
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authorization->opaque);
|
||||
tsk_strunquote(&hdr_Proxy_Authorization->opaque);
|
||||
}
|
||||
|
||||
action parse_qop
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authorization->qop);
|
||||
//tsk_strunquote(&hdr_Proxy_Authorization->qop);
|
||||
}
|
||||
|
||||
action parse_nc
|
||||
{
|
||||
PARSER_SET_STRING(hdr_Proxy_Authorization->nc);
|
||||
TSK_DEBUG_INFO("PROXY_AUTHORIZATION:PARSE_NC");
|
||||
}
|
||||
|
||||
action parse_param
|
||||
{
|
||||
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_tostring(const void* 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_appendEx(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->uri ? ",uri=\"" : "",
|
||||
Proxy_Authorization->uri ? Proxy_Authorization->uri : "",
|
||||
Proxy_Authorization->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, 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;
|
||||
|
||||
%%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
|
||||
///*
|
||||
//* Copyright (C) 2009 Mamadou Diop.
|
||||
//*
|
||||
//* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
//*
|
||||
//* 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 Lesser General Public License for more details.
|
||||
//*
|
||||
//* You should have received a copy of the GNU General Public License
|
||||
//* along with DOUBANGO.
|
||||
//*
|
||||
//*/
|
||||
//
|
||||
|
||||
/**@ingroup tsip_header_Proxy_Authorization_group
|
||||
*/
|
||||
static void* tsip_header_Proxy_Authorization_create(void *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)->tostring = tsip_header_Proxy_Authorization_tostring;
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new Proxy_Authorization header.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup tsip_header_Proxy_Authorization_group
|
||||
*/
|
||||
static void* tsip_header_Proxy_Authorization_destroy(void *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->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_create,
|
||||
tsip_header_Proxy_Authorization_destroy,
|
||||
0
|
||||
};
|
||||
const void *tsip_header_Proxy_Authorization_def_t = &tsip_header_Proxy_Authorization_def_s;
|
||||
///**@file tsip_header_Proxy_Authorization.c
|
||||
// * @brief SIP Proxy-Authenticate header.
|
||||
// *
|
||||
// * @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
// *
|
||||
// * @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
// */
|
||||
//#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>
|
||||
//
|
||||
///**@defgroup tsip_header_Proxy_Authorization_group SIP Proxy-Authenticate header.
|
||||
//*/
|
||||
//
|
||||
///***********************************
|
||||
//* Ragel state machine.
|
||||
//*/
|
||||
//%%{
|
||||
// machine tsip_machine_parser_header_Proxy_Authorization;
|
||||
//
|
||||
// # Includes
|
||||
// include tsip_machine_utils "./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->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_tostring(const void* 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_appendEx(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->uri ? ",uri=\"" : "",
|
||||
// Proxy_Authorization->uri ? Proxy_Authorization->uri : "",
|
||||
// Proxy_Authorization->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, 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;
|
||||
//
|
||||
// %%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
|
||||
////
|
||||
//
|
||||
///**@ingroup tsip_header_Proxy_Authorization_group
|
||||
//*/
|
||||
//static void* tsip_header_Proxy_Authorization_create(void *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)->tostring = tsip_header_Proxy_Authorization_tostring;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// TSK_DEBUG_ERROR("Failed to create new Proxy_Authorization header.");
|
||||
// }
|
||||
// return self;
|
||||
//}
|
||||
//
|
||||
///**@ingroup tsip_header_Proxy_Authorization_group
|
||||
//*/
|
||||
//static void* tsip_header_Proxy_Authorization_destroy(void *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->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_create,
|
||||
// tsip_header_Proxy_Authorization_destroy,
|
||||
// 0
|
||||
//};
|
||||
//const void *tsip_header_Proxy_Authorization_def_t = &tsip_header_Proxy_Authorization_def_s;
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
action parse_route
|
||||
{
|
||||
PARSER_SET_STRING(hdr_record_route->value);
|
||||
TSK_PARSER_SET_STRING(hdr_record_route->value);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
action parse_option
|
||||
{
|
||||
PARSER_ADD_STRING(hdr_require->options);
|
||||
TSK_PARSER_ADD_STRING(hdr_require->options);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
{
|
||||
if(curr_route)
|
||||
{
|
||||
PARSER_SET_STRING(curr_route->display_name);
|
||||
TSK_PARSER_SET_STRING(curr_route->display_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@
|
|||
{
|
||||
if(curr_route)
|
||||
{
|
||||
PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_route));
|
||||
TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_route));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
{
|
||||
if(curr_service)
|
||||
{
|
||||
PARSER_SET_STRING(curr_service->display_name);
|
||||
TSK_PARSER_SET_STRING(curr_service->display_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@
|
|||
{
|
||||
if(curr_service)
|
||||
{
|
||||
PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_service));
|
||||
TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(curr_service));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
action parse_option
|
||||
{
|
||||
PARSER_ADD_STRING(hdr_supported->options);
|
||||
TSK_PARSER_ADD_STRING(hdr_supported->options);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
|
|
@ -59,17 +59,17 @@
|
|||
|
||||
action parse_display_name
|
||||
{
|
||||
PARSER_SET_STRING(hdr_to->display_name);
|
||||
TSK_PARSER_SET_STRING(hdr_to->display_name);
|
||||
}
|
||||
|
||||
action parse_tag
|
||||
{
|
||||
PARSER_SET_STRING(hdr_to->tag);
|
||||
TSK_PARSER_SET_STRING(hdr_to->tag);
|
||||
}
|
||||
|
||||
action parse_param
|
||||
{
|
||||
PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_to));
|
||||
TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_to));
|
||||
}
|
||||
|
||||
action eob
|
||||
|
@ -77,7 +77,7 @@
|
|||
}
|
||||
|
||||
my_tag_param = "tag"i EQUAL token>tag %parse_tag;
|
||||
to_param = my_tag_param>1 | (generic_param)>0 >tag %parse_param;
|
||||
to_param = my_tag_param@1 | (generic_param)@0 >tag %parse_param;
|
||||
|
||||
URI = (scheme HCOLON any+)>tag %parse_uri;
|
||||
display_name = (( token LWS )+ | quoted_string)>tag %parse_display_name;
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
action parse_user_agent
|
||||
{
|
||||
PARSER_SET_STRING(hdr_user_agent->value);
|
||||
TSK_PARSER_SET_STRING(hdr_user_agent->value);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
|
|
@ -52,57 +52,57 @@
|
|||
|
||||
action parse_protocol_name
|
||||
{
|
||||
PARSER_SET_STRING(hdr_via->proto_name);
|
||||
TSK_PARSER_SET_STRING(hdr_via->proto_name);
|
||||
}
|
||||
|
||||
action parse_protocol_version
|
||||
{
|
||||
PARSER_SET_STRING(hdr_via->proto_version);
|
||||
TSK_PARSER_SET_STRING(hdr_via->proto_version);
|
||||
}
|
||||
|
||||
action parse_host
|
||||
{
|
||||
PARSER_SET_STRING(hdr_via->host);
|
||||
TSK_PARSER_SET_STRING(hdr_via->host);
|
||||
}
|
||||
|
||||
action parse_port
|
||||
{
|
||||
PARSER_SET_INTEGER(hdr_via->port);
|
||||
TSK_PARSER_SET_INTEGER(hdr_via->port);
|
||||
}
|
||||
|
||||
action parse_transport
|
||||
{
|
||||
PARSER_SET_STRING(hdr_via->transport);
|
||||
TSK_PARSER_SET_STRING(hdr_via->transport);
|
||||
}
|
||||
|
||||
action parse_ttl
|
||||
{
|
||||
PARSER_SET_INTEGER(hdr_via->ttl);
|
||||
TSK_PARSER_SET_INTEGER(hdr_via->ttl);
|
||||
}
|
||||
|
||||
action parse_maddr
|
||||
{
|
||||
PARSER_SET_STRING(hdr_via->maddr);
|
||||
TSK_PARSER_SET_STRING(hdr_via->maddr);
|
||||
}
|
||||
|
||||
action parse_received
|
||||
{
|
||||
PARSER_SET_STRING(hdr_via->received);
|
||||
TSK_PARSER_SET_STRING(hdr_via->received);
|
||||
}
|
||||
|
||||
action parse_branch
|
||||
{
|
||||
PARSER_SET_STRING(hdr_via->branch);
|
||||
TSK_PARSER_SET_STRING(hdr_via->branch);
|
||||
}
|
||||
|
||||
action parse_comp
|
||||
{
|
||||
PARSER_SET_STRING(hdr_via->comp);
|
||||
TSK_PARSER_SET_STRING(hdr_via->comp);
|
||||
}
|
||||
|
||||
action parse_rport
|
||||
{
|
||||
PARSER_SET_INTEGER(hdr_via->rport);
|
||||
TSK_PARSER_SET_INTEGER(hdr_via->rport);
|
||||
}
|
||||
|
||||
action has_rport
|
||||
|
@ -115,7 +115,7 @@
|
|||
|
||||
action parse_param
|
||||
{
|
||||
PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_via));
|
||||
TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_via));
|
||||
}
|
||||
|
||||
action eob
|
||||
|
@ -125,7 +125,7 @@
|
|||
|
||||
protocol_name = "SIP"i | token >tag %parse_protocol_name;
|
||||
protocol_version = token >tag %parse_protocol_version;
|
||||
transport = "UDP"i | "TCP"i | "TLS"i | "SCTP"i | "TLS-SCTP"i | other_transport >tag %parse_transport;
|
||||
transport = ("UDP"i | "TCP"i | "TLS"i | "SCTP"i | "TLS-SCTP"i | other_transport) >tag %parse_transport;
|
||||
sent_protocol = protocol_name SLASH protocol_version SLASH transport;
|
||||
sent_by = host>tag %parse_host ( COLON port >tag %parse_port )?;
|
||||
via_ttl = "ttl"i EQUAL ttl >tag %parse_ttl;
|
||||
|
@ -135,7 +135,7 @@
|
|||
via_compression = "comp"i EQUAL ( "sigcomp"i | other_compression )>tag %parse_comp;
|
||||
response_port = "rport"i ( EQUAL DIGIT+ >tag %parse_rport )? %has_rport;
|
||||
via_extension = (generic_param) >tag %parse_param;
|
||||
via_params = (via_ttl | via_maddr | via_received | via_branch | via_compression | response_port)>1 | (via_extension)>0;
|
||||
via_params = (via_ttl | via_maddr | via_received | via_branch | via_compression | response_port)@1 | (via_extension)@0;
|
||||
via_parm = sent_protocol LWS sent_by ( SEMI via_params )*;
|
||||
Via = ( "Via"i | "v"i ) HCOLON via_parm ( COMMA via_parm )*;
|
||||
|
||||
|
@ -209,6 +209,7 @@ tsip_header_Via_t *tsip_header_Via_parse(const char *data, size_t size)
|
|||
|
||||
if( cs < %%{ write first_final; }%% )
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to parse Via header.");
|
||||
TSK_OBJECT_SAFE_FREE(hdr_via);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,250 +1,250 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file tsip_header_WWW_Authenticate.c
|
||||
* @brief SIP WWW-Authenticate header.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinysip/headers/tsip_header_WWW_Authenticate.h"
|
||||
|
||||
#include "tinysip/parsers/tsip_parser_uri.h"
|
||||
|
||||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
#include "tsk_time.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**@defgroup tsip_header_WWW_Authenticate_group SIP WWW-Authenticate header.
|
||||
*/
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
*/
|
||||
%%{
|
||||
machine tsip_machine_parser_header_WWW_Authenticate;
|
||||
|
||||
# Includes
|
||||
include tsip_machine_utils "./tsip_machine_utils.rl";
|
||||
|
||||
action tag
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
|
||||
action is_digest
|
||||
{
|
||||
#//FIXME: Only Digest is supported
|
||||
hdr_WWW_Authenticate->scheme = tsk_strdup("Digest");
|
||||
}
|
||||
|
||||
action parse_realm
|
||||
{
|
||||
PARSER_SET_STRING(hdr_WWW_Authenticate->realm);
|
||||
tsk_strunquote(&hdr_WWW_Authenticate->realm);
|
||||
}
|
||||
|
||||
action parse_domain
|
||||
{
|
||||
PARSER_SET_STRING(hdr_WWW_Authenticate->domain);
|
||||
//tsk_strunquote(&hdr_WWW_Authenticate->domain);
|
||||
}
|
||||
|
||||
action parse_nonce
|
||||
{
|
||||
PARSER_SET_STRING(hdr_WWW_Authenticate->nonce);
|
||||
tsk_strunquote(&hdr_WWW_Authenticate->nonce);
|
||||
}
|
||||
|
||||
action parse_opaque
|
||||
{
|
||||
PARSER_SET_STRING(hdr_WWW_Authenticate->opaque);
|
||||
tsk_strunquote(&hdr_WWW_Authenticate->opaque);
|
||||
}
|
||||
|
||||
action parse_stale
|
||||
{
|
||||
hdr_WWW_Authenticate->stale = tsk_strniequals(tag_start, "true", 4);
|
||||
}
|
||||
|
||||
action parse_algorithm
|
||||
{
|
||||
PARSER_SET_STRING(hdr_WWW_Authenticate->algorithm);
|
||||
}
|
||||
|
||||
action parse_qop
|
||||
{
|
||||
PARSER_SET_STRING(hdr_WWW_Authenticate->qop);
|
||||
//tsk_strunquote(&hdr_WWW_Authenticate->qop);
|
||||
}
|
||||
|
||||
action parse_param
|
||||
{
|
||||
PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_WWW_Authenticate));
|
||||
}
|
||||
|
||||
action eob
|
||||
{
|
||||
}
|
||||
|
||||
#FIXME: Only Digest (MD5, AKAv1-MD5 and AKAv2-MD5) is supported
|
||||
other_challenge = (any+);
|
||||
auth_param = generic_param>tag %parse_param;
|
||||
|
||||
realm = "realm"i EQUAL quoted_string>tag %parse_realm;
|
||||
domain = "domain"i EQUAL LDQUOT <: (any*)>tag %parse_domain :> RDQUOT;
|
||||
nonce = "nonce"i EQUAL quoted_string>tag %parse_nonce;
|
||||
opaque = "opaque"i EQUAL quoted_string>tag %parse_opaque;
|
||||
stale = "stale"i EQUAL ( "true"i | "false"i )>tag %parse_stale;
|
||||
algorithm = "algorithm"i EQUAL <:token>tag %parse_algorithm;
|
||||
qop_options = "qop"i EQUAL LDQUOT <: (any*)>tag %parse_qop :> RDQUOT;
|
||||
|
||||
digest_cln = (realm | domain | nonce | opaque | stale | algorithm | qop_options)>1 | auth_param>0;
|
||||
challenge = ( "Digest"i LWS digest_cln ( COMMA <:digest_cln )* )>is_digest | other_challenge;
|
||||
WWW_Authenticate = "WWW-Authenticate"i HCOLON challenge;
|
||||
|
||||
# Entry point
|
||||
main := WWW_Authenticate :>CRLF @eob;
|
||||
|
||||
}%%
|
||||
|
||||
int tsip_header_WWW_Authenticate_tostring(const void* header, tsk_buffer_t* output)
|
||||
{
|
||||
if(header)
|
||||
{
|
||||
const tsip_header_WWW_Authenticate_t *WWW_Authenticate = header;
|
||||
if(WWW_Authenticate && WWW_Authenticate->scheme)
|
||||
{
|
||||
return tsk_buffer_appendEx(output, "%s realm=\"%s\"%s%s%s%s%s%s%s%s%s%s%s%s,stale=%s%s%s",
|
||||
WWW_Authenticate->scheme,
|
||||
WWW_Authenticate->realm ? WWW_Authenticate->realm : "",
|
||||
|
||||
WWW_Authenticate->domain ? ",domain=\"" : "",
|
||||
WWW_Authenticate->domain ? WWW_Authenticate->domain : "",
|
||||
WWW_Authenticate->domain ? "\"" : "",
|
||||
|
||||
|
||||
WWW_Authenticate->qop ? ",qop=\"" : "",
|
||||
WWW_Authenticate->qop ? WWW_Authenticate->qop : "",
|
||||
WWW_Authenticate->qop ? "\"" : "",
|
||||
|
||||
|
||||
WWW_Authenticate->nonce ? ",nonce=\"" : "",
|
||||
WWW_Authenticate->nonce ? WWW_Authenticate->nonce : "",
|
||||
WWW_Authenticate->nonce ? "\"" : "",
|
||||
|
||||
WWW_Authenticate->opaque ? ",opaque=\"" : "",
|
||||
WWW_Authenticate->opaque ? WWW_Authenticate->opaque : "",
|
||||
WWW_Authenticate->opaque ? "\"" : "",
|
||||
|
||||
WWW_Authenticate->stale ? "TRUE" : "FALSE",
|
||||
|
||||
WWW_Authenticate->algorithm ? ",algorithm=" : "",
|
||||
WWW_Authenticate->algorithm ? WWW_Authenticate->algorithm : ""
|
||||
);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
tsip_header_WWW_Authenticate_t *tsip_header_WWW_Authenticate_parse(const char *data, size_t size)
|
||||
{
|
||||
int cs = 0;
|
||||
const char *p = data;
|
||||
const char *pe = p + size;
|
||||
const char *eof = pe;
|
||||
tsip_header_WWW_Authenticate_t *hdr_WWW_Authenticate = TSIP_HEADER_WWW_AUTHENTICATE_CREATE();
|
||||
|
||||
const char *tag_start;
|
||||
|
||||
%%write data;
|
||||
%%write init;
|
||||
%%write exec;
|
||||
|
||||
if( cs < %%{ write first_final; }%% )
|
||||
{
|
||||
TSK_OBJECT_SAFE_FREE(hdr_WWW_Authenticate);
|
||||
}
|
||||
|
||||
return hdr_WWW_Authenticate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================
|
||||
// WWW_Authenticate header object definition
|
||||
///*
|
||||
//* Copyright (C) 2009 Mamadou Diop.
|
||||
//*
|
||||
//* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
|
||||
//*
|
||||
//* 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 Lesser General Public License for more details.
|
||||
//*
|
||||
//* You should have received a copy of the GNU General Public License
|
||||
//* along with DOUBANGO.
|
||||
//*
|
||||
//*/
|
||||
//
|
||||
|
||||
/**@ingroup tsip_header_WWW_Authenticate_group
|
||||
*/
|
||||
static void* tsip_header_WWW_Authenticate_create(void *self, va_list * app)
|
||||
{
|
||||
tsip_header_WWW_Authenticate_t *WWW_Authenticate = self;
|
||||
if(WWW_Authenticate)
|
||||
{
|
||||
TSIP_HEADER(WWW_Authenticate)->type = tsip_htype_WWW_Authenticate;
|
||||
TSIP_HEADER(WWW_Authenticate)->tostring = tsip_header_WWW_Authenticate_tostring;
|
||||
}
|
||||
else
|
||||
{
|
||||
TSK_DEBUG_ERROR("Failed to create new WWW_Authenticate header.");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**@ingroup tsip_header_WWW_Authenticate_group
|
||||
*/
|
||||
static void* tsip_header_WWW_Authenticate_destroy(void *self)
|
||||
{
|
||||
tsip_header_WWW_Authenticate_t *WWW_Authenticate = self;
|
||||
if(WWW_Authenticate)
|
||||
{
|
||||
TSK_FREE(WWW_Authenticate->scheme);
|
||||
TSK_FREE(WWW_Authenticate->realm);
|
||||
TSK_FREE(WWW_Authenticate->domain);
|
||||
TSK_FREE(WWW_Authenticate->nonce);
|
||||
TSK_FREE(WWW_Authenticate->opaque);
|
||||
TSK_FREE(WWW_Authenticate->algorithm);
|
||||
TSK_FREE(WWW_Authenticate->qop);
|
||||
|
||||
TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(WWW_Authenticate));
|
||||
}
|
||||
else TSK_DEBUG_ERROR("Null WWW_Authenticate header.");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tsip_header_WWW_Authenticate_def_s =
|
||||
{
|
||||
sizeof(tsip_header_WWW_Authenticate_t),
|
||||
tsip_header_WWW_Authenticate_create,
|
||||
tsip_header_WWW_Authenticate_destroy,
|
||||
0
|
||||
};
|
||||
const void *tsip_header_WWW_Authenticate_def_t = &tsip_header_WWW_Authenticate_def_s;
|
||||
///**@file tsip_header_WWW_Authenticate.c
|
||||
// * @brief SIP WWW-Authenticate header.
|
||||
// *
|
||||
// * @author Mamadou Diop <diopmamadou(at)yahoo.fr>
|
||||
// *
|
||||
// * @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
// */
|
||||
//#include "tinysip/headers/tsip_header_WWW_Authenticate.h"
|
||||
//
|
||||
//#include "tinysip/parsers/tsip_parser_uri.h"
|
||||
//
|
||||
//#include "tsk_debug.h"
|
||||
//#include "tsk_memory.h"
|
||||
//#include "tsk_time.h"
|
||||
//
|
||||
//#include <string.h>
|
||||
//
|
||||
///**@defgroup tsip_header_WWW_Authenticate_group SIP WWW-Authenticate header.
|
||||
//*/
|
||||
//
|
||||
///***********************************
|
||||
//* Ragel state machine.
|
||||
//*/
|
||||
//%%{
|
||||
// machine tsip_machine_parser_header_WWW_Authenticate;
|
||||
//
|
||||
// # Includes
|
||||
// include tsip_machine_utils "./tsip_machine_utils.rl";
|
||||
//
|
||||
// action tag
|
||||
// {
|
||||
// tag_start = p;
|
||||
// }
|
||||
//
|
||||
// action is_digest
|
||||
// {
|
||||
// #//FIXME: Only Digest is supported
|
||||
// hdr_WWW_Authenticate->scheme = tsk_strdup("Digest");
|
||||
// }
|
||||
//
|
||||
// action parse_realm
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->realm);
|
||||
// tsk_strunquote(&hdr_WWW_Authenticate->realm);
|
||||
// }
|
||||
//
|
||||
// action parse_domain
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->domain);
|
||||
// //tsk_strunquote(&hdr_WWW_Authenticate->domain);
|
||||
// }
|
||||
//
|
||||
// action parse_nonce
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->nonce);
|
||||
// tsk_strunquote(&hdr_WWW_Authenticate->nonce);
|
||||
// }
|
||||
//
|
||||
// action parse_opaque
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->opaque);
|
||||
// tsk_strunquote(&hdr_WWW_Authenticate->opaque);
|
||||
// }
|
||||
//
|
||||
// action parse_stale
|
||||
// {
|
||||
// hdr_WWW_Authenticate->stale = tsk_strniequals(tag_start, "true", 4);
|
||||
// }
|
||||
//
|
||||
// action parse_algorithm
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->algorithm);
|
||||
// }
|
||||
//
|
||||
// action parse_qop
|
||||
// {
|
||||
// TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->qop);
|
||||
// //tsk_strunquote(&hdr_WWW_Authenticate->qop);
|
||||
// }
|
||||
//
|
||||
// action parse_param
|
||||
// {
|
||||
// TSK_PARSER_ADD_PARAM(TSIP_HEADER_PARAMS(hdr_WWW_Authenticate));
|
||||
// }
|
||||
//
|
||||
// action eob
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// #FIXME: Only Digest (MD5, AKAv1-MD5 and AKAv2-MD5) is supported
|
||||
// other_challenge = (any+);
|
||||
// auth_param = generic_param>tag %parse_param;
|
||||
//
|
||||
// realm = "realm"i EQUAL quoted_string>tag %parse_realm;
|
||||
// domain = "domain"i EQUAL LDQUOT <: (any*)>tag %parse_domain :> RDQUOT;
|
||||
// nonce = "nonce"i EQUAL quoted_string>tag %parse_nonce;
|
||||
// opaque = "opaque"i EQUAL quoted_string>tag %parse_opaque;
|
||||
// stale = "stale"i EQUAL ( "true"i | "false"i )>tag %parse_stale;
|
||||
// algorithm = "algorithm"i EQUAL <:token>tag %parse_algorithm;
|
||||
// qop_options = "qop"i EQUAL LDQUOT <: (any*)>tag %parse_qop :> RDQUOT;
|
||||
//
|
||||
// digest_cln = (realm | domain | nonce | opaque | stale | algorithm | qop_options)@1 | auth_param@0;
|
||||
// challenge = ( "Digest"i LWS digest_cln ( COMMA <:digest_cln )* )>is_digest | other_challenge;
|
||||
// WWW_Authenticate = "WWW-Authenticate"i HCOLON challenge;
|
||||
//
|
||||
// # Entry point
|
||||
// main := WWW_Authenticate :>CRLF @eob;
|
||||
//
|
||||
//}%%
|
||||
//
|
||||
//int tsip_header_WWW_Authenticate_tostring(const void* header, tsk_buffer_t* output)
|
||||
//{
|
||||
// if(header)
|
||||
// {
|
||||
// const tsip_header_WWW_Authenticate_t *WWW_Authenticate = header;
|
||||
// if(WWW_Authenticate && WWW_Authenticate->scheme)
|
||||
// {
|
||||
// return tsk_buffer_appendEx(output, "%s realm=\"%s\"%s%s%s%s%s%s%s%s%s%s%s%s,stale=%s%s%s",
|
||||
// WWW_Authenticate->scheme,
|
||||
// WWW_Authenticate->realm ? WWW_Authenticate->realm : "",
|
||||
//
|
||||
// WWW_Authenticate->domain ? ",domain=\"" : "",
|
||||
// WWW_Authenticate->domain ? WWW_Authenticate->domain : "",
|
||||
// WWW_Authenticate->domain ? "\"" : "",
|
||||
//
|
||||
//
|
||||
// WWW_Authenticate->qop ? ",qop=\"" : "",
|
||||
// WWW_Authenticate->qop ? WWW_Authenticate->qop : "",
|
||||
// WWW_Authenticate->qop ? "\"" : "",
|
||||
//
|
||||
//
|
||||
// WWW_Authenticate->nonce ? ",nonce=\"" : "",
|
||||
// WWW_Authenticate->nonce ? WWW_Authenticate->nonce : "",
|
||||
// WWW_Authenticate->nonce ? "\"" : "",
|
||||
//
|
||||
// WWW_Authenticate->opaque ? ",opaque=\"" : "",
|
||||
// WWW_Authenticate->opaque ? WWW_Authenticate->opaque : "",
|
||||
// WWW_Authenticate->opaque ? "\"" : "",
|
||||
//
|
||||
// WWW_Authenticate->stale ? "TRUE" : "FALSE",
|
||||
//
|
||||
// WWW_Authenticate->algorithm ? ",algorithm=" : "",
|
||||
// WWW_Authenticate->algorithm ? WWW_Authenticate->algorithm : ""
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// return -1;
|
||||
//}
|
||||
//
|
||||
//tsip_header_WWW_Authenticate_t *tsip_header_WWW_Authenticate_parse(const char *data, size_t size)
|
||||
//{
|
||||
// int cs = 0;
|
||||
// const char *p = data;
|
||||
// const char *pe = p + size;
|
||||
// const char *eof = pe;
|
||||
// tsip_header_WWW_Authenticate_t *hdr_WWW_Authenticate = TSIP_HEADER_WWW_AUTHENTICATE_CREATE();
|
||||
//
|
||||
// const char *tag_start;
|
||||
//
|
||||
// %%write data;
|
||||
// %%write init;
|
||||
// %%write exec;
|
||||
//
|
||||
// if( cs < %%{ write first_final; }%% )
|
||||
// {
|
||||
// TSK_OBJECT_SAFE_FREE(hdr_WWW_Authenticate);
|
||||
// }
|
||||
//
|
||||
// return hdr_WWW_Authenticate;
|
||||
//}
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
////========================================================
|
||||
//// WWW_Authenticate header object definition
|
||||
////
|
||||
//
|
||||
///**@ingroup tsip_header_WWW_Authenticate_group
|
||||
//*/
|
||||
//static void* tsip_header_WWW_Authenticate_create(void *self, va_list * app)
|
||||
//{
|
||||
// tsip_header_WWW_Authenticate_t *WWW_Authenticate = self;
|
||||
// if(WWW_Authenticate)
|
||||
// {
|
||||
// TSIP_HEADER(WWW_Authenticate)->type = tsip_htype_WWW_Authenticate;
|
||||
// TSIP_HEADER(WWW_Authenticate)->tostring = tsip_header_WWW_Authenticate_tostring;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// TSK_DEBUG_ERROR("Failed to create new WWW_Authenticate header.");
|
||||
// }
|
||||
// return self;
|
||||
//}
|
||||
//
|
||||
///**@ingroup tsip_header_WWW_Authenticate_group
|
||||
//*/
|
||||
//static void* tsip_header_WWW_Authenticate_destroy(void *self)
|
||||
//{
|
||||
// tsip_header_WWW_Authenticate_t *WWW_Authenticate = self;
|
||||
// if(WWW_Authenticate)
|
||||
// {
|
||||
// TSK_FREE(WWW_Authenticate->scheme);
|
||||
// TSK_FREE(WWW_Authenticate->realm);
|
||||
// TSK_FREE(WWW_Authenticate->domain);
|
||||
// TSK_FREE(WWW_Authenticate->nonce);
|
||||
// TSK_FREE(WWW_Authenticate->opaque);
|
||||
// TSK_FREE(WWW_Authenticate->algorithm);
|
||||
// TSK_FREE(WWW_Authenticate->qop);
|
||||
//
|
||||
// TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(WWW_Authenticate));
|
||||
// }
|
||||
// else TSK_DEBUG_ERROR("Null WWW_Authenticate header.");
|
||||
//
|
||||
// return self;
|
||||
//}
|
||||
//
|
||||
//static const tsk_object_def_t tsip_header_WWW_Authenticate_def_s =
|
||||
//{
|
||||
// sizeof(tsip_header_WWW_Authenticate_t),
|
||||
// tsip_header_WWW_Authenticate_create,
|
||||
// tsip_header_WWW_Authenticate_destroy,
|
||||
// 0
|
||||
//};
|
||||
//const void *tsip_header_WWW_Authenticate_def_t = &tsip_header_WWW_Authenticate_def_s;
|
|
@ -35,9 +35,9 @@
|
|||
#include "tsk_debug.h"
|
||||
#include "tsk_memory.h"
|
||||
|
||||
static void tsip_message_parser_execute(tsip_ragel_state_t *state, tsip_message_t *message);
|
||||
static void tsip_message_parser_init(tsip_ragel_state_t *state);
|
||||
static void tsip_message_parser_eoh(tsip_ragel_state_t *state, tsip_message_t *message);
|
||||
static void tsip_message_parser_execute(tsk_ragel_state_t *state, tsip_message_t *message);
|
||||
static void tsip_message_parser_init(tsk_ragel_state_t *state);
|
||||
static void tsip_message_parser_eoh(tsk_ragel_state_t *state, tsip_message_t *message);
|
||||
|
||||
/***********************************
|
||||
* Ragel state machine.
|
||||
|
@ -187,7 +187,7 @@ static void tsip_message_parser_eoh(tsip_ragel_state_t *state, tsip_message_t *m
|
|||
%%write data;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn TSIP_BOOLEAN tsip_message_parse(tsip_ragel_state_t *state, tsip_message_t *result)
|
||||
/// @fn TSIP_BOOLEAN tsip_message_parse(tsk_ragel_state_t *state, tsip_message_t *result)
|
||||
///
|
||||
/// @brief Parse a SIP message. Both requests and reponses messages.
|
||||
///
|
||||
|
@ -201,7 +201,7 @@ static void tsip_message_parser_eoh(tsip_ragel_state_t *state, tsip_message_t *m
|
|||
/// @return @ref TSIP_TRUE if succeed and @ref TSIP_FALSE otherwise.
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
TSIP_BOOLEAN tsip_message_parse(tsip_ragel_state_t *state, tsip_message_t **result)
|
||||
TSIP_BOOLEAN tsip_message_parse(tsk_ragel_state_t *state, tsip_message_t **result)
|
||||
{
|
||||
if(!state || state->pe <= state->p)
|
||||
{
|
||||
|
@ -232,7 +232,7 @@ TSIP_BOOLEAN tsip_message_parse(tsip_ragel_state_t *state, tsip_message_t **resu
|
|||
}
|
||||
|
||||
|
||||
static void tsip_message_parser_init(tsip_ragel_state_t *state)
|
||||
static void tsip_message_parser_init(tsk_ragel_state_t *state)
|
||||
{
|
||||
int cs = 0;
|
||||
|
||||
|
@ -242,7 +242,7 @@ static void tsip_message_parser_init(tsip_ragel_state_t *state)
|
|||
state->cs = cs;
|
||||
}
|
||||
|
||||
static void tsip_message_parser_execute(tsip_ragel_state_t *state, tsip_message_t *message)
|
||||
static void tsip_message_parser_execute(tsk_ragel_state_t *state, tsip_message_t *message)
|
||||
{
|
||||
int cs = state->cs;
|
||||
const char *p = state->p;
|
||||
|
@ -257,7 +257,7 @@ static void tsip_message_parser_execute(tsip_ragel_state_t *state, tsip_message_
|
|||
state->eof = eof;
|
||||
}
|
||||
|
||||
static void tsip_message_parser_eoh(tsip_ragel_state_t *state, tsip_message_t *message)
|
||||
static void tsip_message_parser_eoh(tsk_ragel_state_t *state, tsip_message_t *message)
|
||||
{
|
||||
int cs = state->cs;
|
||||
const char *p = state->p;
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
# Includes
|
||||
include tsip_machine_utils "./tsip_machine_utils.rl";
|
||||
include tsip_machine_userinfo;
|
||||
#include tsip_machine_userinfo;
|
||||
|
||||
action tag
|
||||
{
|
||||
|
@ -63,32 +63,32 @@
|
|||
|
||||
action parse_scheme
|
||||
{
|
||||
PARSER_SET_STRING(uri->scheme);
|
||||
TSK_PARSER_SET_STRING(uri->scheme);
|
||||
}
|
||||
|
||||
action parse_user_name
|
||||
{
|
||||
PARSER_SET_STRING(uri->user_name);
|
||||
TSK_PARSER_SET_STRING(uri->user_name);
|
||||
}
|
||||
|
||||
action parse_password
|
||||
{
|
||||
PARSER_SET_STRING(uri->password);
|
||||
TSK_PARSER_SET_STRING(uri->password);
|
||||
}
|
||||
|
||||
action parse_host
|
||||
{
|
||||
PARSER_SET_STRING(uri->host);
|
||||
TSK_PARSER_SET_STRING(uri->host);
|
||||
}
|
||||
|
||||
action parse_port
|
||||
{
|
||||
PARSER_SET_INTEGER(uri->port);
|
||||
TSK_PARSER_SET_INTEGER(uri->port);
|
||||
}
|
||||
|
||||
action parse_param
|
||||
{
|
||||
PARSER_ADD_PARAM(uri->params);
|
||||
TSK_PARSER_ADD_PARAM(uri->params);
|
||||
}
|
||||
|
||||
action eob
|
||||
|
@ -113,7 +113,7 @@
|
|||
|
||||
( (IPv6reference >is_ipv6)>89 | (IPv4address >is_ipv4)>88 | (hostname >is_hostname)>87 ) @90
|
||||
{
|
||||
SCANNER_SET_STRING(uri->host);
|
||||
TSK_SCANNER_SET_STRING(uri->host);
|
||||
if(uri->host_type == host_ipv6)
|
||||
{
|
||||
tsk_strunquoteex(&uri->host, '[', ']');
|
||||
|
@ -123,7 +123,7 @@
|
|||
(":" port)@80
|
||||
{
|
||||
ts++;
|
||||
SCANNER_SET_INTEGER(uri->port);
|
||||
TSK_SCANNER_SET_INTEGER(uri->port);
|
||||
};
|
||||
|
||||
( uri_parameters ) @70 { };
|
||||
|
|
|
@ -288,8 +288,10 @@ int tsip_challenge_update(tsip_challenge_t *self, const char* scheme, const char
|
|||
tsk_strupdate(&self->nonce, nonce);
|
||||
tsk_strupdate(&self->opaque, opaque);
|
||||
tsk_strupdate(&self->algorithm, algorithm);
|
||||
self->qop = tsk_strcontains(qop, strlen(qop), "auth-int") ? "auth-int" :
|
||||
(tsk_strcontains(qop, strlen(qop), "auth") ? "auth" : 0);
|
||||
if(qop){
|
||||
self->qop = tsk_strcontains(qop, strlen(qop), "auth-int") ? "auth-int" :
|
||||
(tsk_strcontains(qop, strlen(qop), "auth") ? "auth" : 0);
|
||||
}
|
||||
|
||||
if(noncechanged && self->qop){
|
||||
tsip_challenge_reset_cnonce(self);
|
||||
|
@ -443,8 +445,10 @@ static void* tsip_challenge_create(void *self, va_list * app)
|
|||
challenge->opaque = tsk_strdup(va_arg(*app, const char*));
|
||||
challenge->algorithm = tsk_strdup(va_arg(*app, const char*));
|
||||
qop = va_arg(*app, const char*);
|
||||
challenge->qop = tsk_strcontains(qop, strlen(qop), "auth-int") ? "auth-int" :
|
||||
(tsk_strcontains(qop, strlen(qop), "auth") ? "auth" : 0);
|
||||
if(qop){
|
||||
challenge->qop = tsk_strcontains(qop, strlen(qop), "auth-int") ? "auth-int" :
|
||||
(tsk_strcontains(qop, strlen(qop), "auth") ? "auth" : 0);
|
||||
}
|
||||
|
||||
if(challenge->qop){
|
||||
tsip_challenge_reset_cnonce(challenge);
|
||||
|
|
|
@ -114,7 +114,7 @@ void tsip_dialog_message_init(tsip_dialog_message_t *self)
|
|||
*/
|
||||
tsip_dialog_messageContext_Init(&self->_fsm, self);
|
||||
|
||||
TSIP_DIALOG(self)->callback = tsip_dialog_message_event_callback;
|
||||
TSIP_DIALOG(self)->callback = TSIP_DIALOG_EVENT_CALLBACK(tsip_dialog_message_event_callback);
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUG)
|
||||
setDebugFlag(&(self->_fsm), DEBUG_STATE_MACHINE);
|
||||
|
|
|
@ -86,7 +86,77 @@ tsip_header_Allow_t *tsip_header_Allow_parse(const char *data, size_t size)
|
|||
const char *tag_start;
|
||||
|
||||
|
||||
/* #line 90 "../source/headers/tsip_header_Allow.c" */
|
||||
/* #line 90 "../src/headers/tsip_header_Allow.c" */
|
||||
static const char _tsip_machine_parser_header_Allow_actions[] = {
|
||||
0, 1, 0, 1, 1, 1, 2
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_key_offsets[] = {
|
||||
0, 0, 2, 4, 6, 8, 10, 13,
|
||||
30, 31, 47, 51, 52, 54, 57, 74,
|
||||
75, 77, 93
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_trans_keys[] = {
|
||||
65, 97, 76, 108, 76, 108, 79, 111,
|
||||
87, 119, 9, 32, 58, 9, 13, 32,
|
||||
33, 37, 39, 126, 42, 43, 45, 46,
|
||||
48, 57, 65, 90, 95, 122, 10, 9,
|
||||
13, 32, 33, 37, 39, 44, 126, 42,
|
||||
46, 48, 57, 65, 90, 95, 122, 9,
|
||||
13, 32, 44, 10, 9, 32, 9, 32,
|
||||
44, 9, 13, 32, 33, 37, 39, 126,
|
||||
42, 43, 45, 46, 48, 57, 65, 90,
|
||||
95, 122, 10, 9, 32, 9, 32, 33,
|
||||
37, 39, 126, 42, 43, 45, 46, 48,
|
||||
57, 65, 90, 95, 122, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_single_lengths[] = {
|
||||
0, 2, 2, 2, 2, 2, 3, 7,
|
||||
1, 8, 4, 1, 2, 3, 7, 1,
|
||||
2, 6, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_range_lengths[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 5,
|
||||
0, 4, 0, 0, 0, 0, 5, 0,
|
||||
0, 5, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_index_offsets[] = {
|
||||
0, 0, 3, 6, 9, 12, 15, 19,
|
||||
32, 34, 47, 52, 54, 57, 61, 74,
|
||||
76, 79, 91
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_indicies[] = {
|
||||
0, 0, 1, 2, 2, 1, 3, 3,
|
||||
1, 4, 4, 1, 5, 5, 1, 5,
|
||||
5, 6, 1, 6, 7, 6, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 1,
|
||||
9, 1, 10, 11, 10, 12, 12, 12,
|
||||
13, 12, 12, 12, 12, 12, 1, 14,
|
||||
15, 14, 16, 1, 17, 1, 18, 18,
|
||||
1, 18, 18, 16, 1, 16, 19, 16,
|
||||
8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 1, 20, 1, 21, 21, 1, 21,
|
||||
21, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 1, 1, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_trans_targs[] = {
|
||||
2, 0, 3, 4, 5, 6, 7, 8,
|
||||
9, 18, 10, 8, 9, 14, 10, 11,
|
||||
14, 12, 13, 15, 16, 17
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_trans_actions[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 5, 3, 3, 0, 3, 0, 0,
|
||||
0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const int tsip_machine_parser_header_Allow_start = 1;
|
||||
static const int tsip_machine_parser_header_Allow_first_final = 18;
|
||||
static const int tsip_machine_parser_header_Allow_error = 0;
|
||||
|
@ -96,301 +166,113 @@ static const int tsip_machine_parser_header_Allow_en_main = 1;
|
|||
|
||||
/* #line 110 "tsip_parser_header_Allow.rl" */
|
||||
|
||||
/* #line 100 "../source/headers/tsip_header_Allow.c" */
|
||||
/* #line 170 "../src/headers/tsip_header_Allow.c" */
|
||||
{
|
||||
cs = tsip_machine_parser_header_Allow_start;
|
||||
}
|
||||
|
||||
/* #line 111 "tsip_parser_header_Allow.rl" */
|
||||
|
||||
/* #line 107 "../source/headers/tsip_header_Allow.c" */
|
||||
/* #line 177 "../src/headers/tsip_header_Allow.c" */
|
||||
{
|
||||
int _klen;
|
||||
unsigned int _trans;
|
||||
const char *_acts;
|
||||
unsigned int _nacts;
|
||||
const char *_keys;
|
||||
|
||||
if ( p == pe )
|
||||
goto _test_eof;
|
||||
switch ( cs )
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
_resume:
|
||||
_keys = _tsip_machine_parser_header_Allow_trans_keys + _tsip_machine_parser_header_Allow_key_offsets[cs];
|
||||
_trans = _tsip_machine_parser_header_Allow_index_offsets[cs];
|
||||
|
||||
_klen = _tsip_machine_parser_header_Allow_single_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + _klen - 1;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + ((_upper-_lower) >> 1);
|
||||
if ( (*p) < *_mid )
|
||||
_upper = _mid - 1;
|
||||
else if ( (*p) > *_mid )
|
||||
_lower = _mid + 1;
|
||||
else {
|
||||
_trans += (_mid - _keys);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_keys += _klen;
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_klen = _tsip_machine_parser_header_Allow_range_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + (_klen<<1) - 2;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
|
||||
if ( (*p) < _mid[0] )
|
||||
_upper = _mid - 2;
|
||||
else if ( (*p) > _mid[1] )
|
||||
_lower = _mid + 2;
|
||||
else {
|
||||
_trans += ((_mid - _keys)>>1);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_match:
|
||||
_trans = _tsip_machine_parser_header_Allow_indicies[_trans];
|
||||
cs = _tsip_machine_parser_header_Allow_trans_targs[_trans];
|
||||
|
||||
if ( _tsip_machine_parser_header_Allow_trans_actions[_trans] == 0 )
|
||||
goto _again;
|
||||
|
||||
_acts = _tsip_machine_parser_header_Allow_actions + _tsip_machine_parser_header_Allow_trans_actions[_trans];
|
||||
_nacts = (unsigned int) *_acts++;
|
||||
while ( _nacts-- > 0 )
|
||||
{
|
||||
case 1:
|
||||
switch( (*p) ) {
|
||||
case 65: goto st2;
|
||||
case 97: goto st2;
|
||||
}
|
||||
goto st0;
|
||||
st0:
|
||||
cs = 0;
|
||||
goto _out;
|
||||
st2:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof2;
|
||||
case 2:
|
||||
switch( (*p) ) {
|
||||
case 76: goto st3;
|
||||
case 108: goto st3;
|
||||
}
|
||||
goto st0;
|
||||
st3:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof3;
|
||||
case 3:
|
||||
switch( (*p) ) {
|
||||
case 76: goto st4;
|
||||
case 108: goto st4;
|
||||
}
|
||||
goto st0;
|
||||
st4:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof4;
|
||||
case 4:
|
||||
switch( (*p) ) {
|
||||
case 79: goto st5;
|
||||
case 111: goto st5;
|
||||
}
|
||||
goto st0;
|
||||
st5:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof5;
|
||||
case 5:
|
||||
switch( (*p) ) {
|
||||
case 87: goto st6;
|
||||
case 119: goto st6;
|
||||
}
|
||||
goto st0;
|
||||
st6:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof6;
|
||||
case 6:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st6;
|
||||
case 32: goto st6;
|
||||
case 58: goto st7;
|
||||
}
|
||||
goto st0;
|
||||
st7:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof7;
|
||||
case 7:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st7;
|
||||
case 13: goto st8;
|
||||
case 32: goto st7;
|
||||
case 33: goto tr8;
|
||||
case 37: goto tr8;
|
||||
case 39: goto tr8;
|
||||
case 126: goto tr8;
|
||||
}
|
||||
if ( (*p) < 48 ) {
|
||||
if ( (*p) > 43 ) {
|
||||
if ( 45 <= (*p) && (*p) <= 46 )
|
||||
goto tr8;
|
||||
} else if ( (*p) >= 42 )
|
||||
goto tr8;
|
||||
} else if ( (*p) > 57 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 95 <= (*p) && (*p) <= 122 )
|
||||
goto tr8;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto tr8;
|
||||
} else
|
||||
goto tr8;
|
||||
goto st0;
|
||||
tr11:
|
||||
/* #line 56 "tsip_parser_header_Allow.rl" */
|
||||
{
|
||||
PARSER_ADD_STRING(hdr_allow->methods);
|
||||
}
|
||||
goto st8;
|
||||
st8:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof8;
|
||||
case 8:
|
||||
/* #line 206 "../source/headers/tsip_header_Allow.c" */
|
||||
if ( (*p) == 10 )
|
||||
goto tr9;
|
||||
goto st0;
|
||||
tr9:
|
||||
/* #line 61 "tsip_parser_header_Allow.rl" */
|
||||
{
|
||||
}
|
||||
goto st18;
|
||||
st18:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof18;
|
||||
case 18:
|
||||
/* #line 219 "../source/headers/tsip_header_Allow.c" */
|
||||
goto st0;
|
||||
tr8:
|
||||
switch ( *_acts++ )
|
||||
{
|
||||
case 0:
|
||||
/* #line 51 "tsip_parser_header_Allow.rl" */
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
goto st9;
|
||||
st9:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof9;
|
||||
case 9:
|
||||
/* #line 231 "../source/headers/tsip_header_Allow.c" */
|
||||
switch( (*p) ) {
|
||||
case 9: goto tr10;
|
||||
case 13: goto tr11;
|
||||
case 32: goto tr10;
|
||||
case 33: goto st9;
|
||||
case 37: goto st9;
|
||||
case 39: goto st9;
|
||||
case 44: goto tr13;
|
||||
case 126: goto st9;
|
||||
}
|
||||
if ( (*p) < 48 ) {
|
||||
if ( 42 <= (*p) && (*p) <= 46 )
|
||||
goto st9;
|
||||
} else if ( (*p) > 57 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 95 <= (*p) && (*p) <= 122 )
|
||||
goto st9;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto st9;
|
||||
} else
|
||||
goto st9;
|
||||
goto st0;
|
||||
tr10:
|
||||
break;
|
||||
case 1:
|
||||
/* #line 56 "tsip_parser_header_Allow.rl" */
|
||||
{
|
||||
PARSER_ADD_STRING(hdr_allow->methods);
|
||||
TSK_PARSER_ADD_STRING(hdr_allow->methods);
|
||||
}
|
||||
goto st10;
|
||||
st10:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof10;
|
||||
case 10:
|
||||
/* #line 264 "../source/headers/tsip_header_Allow.c" */
|
||||
switch( (*p) ) {
|
||||
case 9: goto st10;
|
||||
case 13: goto st11;
|
||||
case 32: goto st10;
|
||||
case 44: goto st14;
|
||||
}
|
||||
goto st0;
|
||||
st11:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof11;
|
||||
case 11:
|
||||
if ( (*p) == 10 )
|
||||
goto st12;
|
||||
goto st0;
|
||||
st12:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof12;
|
||||
case 12:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st13;
|
||||
case 32: goto st13;
|
||||
}
|
||||
goto st0;
|
||||
st13:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof13;
|
||||
case 13:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st13;
|
||||
case 32: goto st13;
|
||||
case 44: goto st14;
|
||||
}
|
||||
goto st0;
|
||||
tr13:
|
||||
/* #line 56 "tsip_parser_header_Allow.rl" */
|
||||
break;
|
||||
case 2:
|
||||
/* #line 61 "tsip_parser_header_Allow.rl" */
|
||||
{
|
||||
PARSER_ADD_STRING(hdr_allow->methods);
|
||||
}
|
||||
goto st14;
|
||||
st14:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof14;
|
||||
case 14:
|
||||
/* #line 308 "../source/headers/tsip_header_Allow.c" */
|
||||
switch( (*p) ) {
|
||||
case 9: goto st14;
|
||||
case 13: goto st15;
|
||||
case 32: goto st14;
|
||||
case 33: goto tr8;
|
||||
case 37: goto tr8;
|
||||
case 39: goto tr8;
|
||||
case 126: goto tr8;
|
||||
break;
|
||||
/* #line 268 "../src/headers/tsip_header_Allow.c" */
|
||||
}
|
||||
}
|
||||
if ( (*p) < 48 ) {
|
||||
if ( (*p) > 43 ) {
|
||||
if ( 45 <= (*p) && (*p) <= 46 )
|
||||
goto tr8;
|
||||
} else if ( (*p) >= 42 )
|
||||
goto tr8;
|
||||
} else if ( (*p) > 57 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 95 <= (*p) && (*p) <= 122 )
|
||||
goto tr8;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto tr8;
|
||||
} else
|
||||
goto tr8;
|
||||
goto st0;
|
||||
st15:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof15;
|
||||
case 15:
|
||||
if ( (*p) == 10 )
|
||||
goto st16;
|
||||
goto st0;
|
||||
st16:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof16;
|
||||
case 16:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st17;
|
||||
case 32: goto st17;
|
||||
}
|
||||
goto st0;
|
||||
st17:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof17;
|
||||
case 17:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st17;
|
||||
case 32: goto st17;
|
||||
case 33: goto tr8;
|
||||
case 37: goto tr8;
|
||||
case 39: goto tr8;
|
||||
case 126: goto tr8;
|
||||
}
|
||||
if ( (*p) < 48 ) {
|
||||
if ( (*p) > 43 ) {
|
||||
if ( 45 <= (*p) && (*p) <= 46 )
|
||||
goto tr8;
|
||||
} else if ( (*p) >= 42 )
|
||||
goto tr8;
|
||||
} else if ( (*p) > 57 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 95 <= (*p) && (*p) <= 122 )
|
||||
goto tr8;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto tr8;
|
||||
} else
|
||||
goto tr8;
|
||||
goto st0;
|
||||
}
|
||||
_test_eof2: cs = 2; goto _test_eof;
|
||||
_test_eof3: cs = 3; goto _test_eof;
|
||||
_test_eof4: cs = 4; goto _test_eof;
|
||||
_test_eof5: cs = 5; goto _test_eof;
|
||||
_test_eof6: cs = 6; goto _test_eof;
|
||||
_test_eof7: cs = 7; goto _test_eof;
|
||||
_test_eof8: cs = 8; goto _test_eof;
|
||||
_test_eof18: cs = 18; goto _test_eof;
|
||||
_test_eof9: cs = 9; goto _test_eof;
|
||||
_test_eof10: cs = 10; goto _test_eof;
|
||||
_test_eof11: cs = 11; goto _test_eof;
|
||||
_test_eof12: cs = 12; goto _test_eof;
|
||||
_test_eof13: cs = 13; goto _test_eof;
|
||||
_test_eof14: cs = 14; goto _test_eof;
|
||||
_test_eof15: cs = 15; goto _test_eof;
|
||||
_test_eof16: cs = 16; goto _test_eof;
|
||||
_test_eof17: cs = 17; goto _test_eof;
|
||||
|
||||
_again:
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
if ( ++p != pe )
|
||||
goto _resume;
|
||||
_test_eof: {}
|
||||
_out: {}
|
||||
}
|
||||
|
@ -398,7 +280,7 @@ case 17:
|
|||
/* #line 112 "tsip_parser_header_Allow.rl" */
|
||||
|
||||
if( cs <
|
||||
/* #line 402 "../source/headers/tsip_header_Allow.c" */
|
||||
/* #line 284 "../src/headers/tsip_header_Allow.c" */
|
||||
18
|
||||
/* #line 113 "tsip_parser_header_Allow.rl" */
|
||||
)
|
||||
|
|
|
@ -88,7 +88,87 @@ tsip_header_Allow_Events_t *tsip_header_Allow_Events_parse(const char *data, siz
|
|||
const char *tag_start;
|
||||
|
||||
|
||||
/* #line 92 "../source/headers/tsip_header_Allow_Events.c" */
|
||||
/* #line 92 "../src/headers/tsip_header_Allow_Events.c" */
|
||||
static const char _tsip_machine_parser_header_Allow_events_actions[] = {
|
||||
0, 1, 0, 1, 1, 1, 2
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_events_key_offsets[] = {
|
||||
0, 0, 4, 6, 8, 10, 12, 13,
|
||||
15, 17, 19, 21, 23, 25, 28, 44,
|
||||
45, 47, 62, 79, 83, 84, 86, 89,
|
||||
90, 103
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_events_trans_keys[] = {
|
||||
65, 85, 97, 117, 76, 108, 76, 108,
|
||||
79, 111, 87, 119, 45, 69, 101, 86,
|
||||
118, 69, 101, 78, 110, 84, 116, 83,
|
||||
115, 9, 32, 58, 9, 13, 32, 33,
|
||||
37, 39, 45, 126, 42, 43, 48, 57,
|
||||
65, 90, 95, 122, 10, 9, 32, 9,
|
||||
32, 33, 37, 39, 45, 126, 42, 43,
|
||||
48, 57, 65, 90, 95, 122, 9, 13,
|
||||
32, 33, 37, 39, 44, 46, 126, 42,
|
||||
45, 48, 57, 65, 90, 95, 122, 9,
|
||||
13, 32, 44, 10, 9, 32, 9, 32,
|
||||
44, 10, 33, 37, 39, 45, 126, 42,
|
||||
43, 48, 57, 65, 90, 95, 122, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_events_single_lengths[] = {
|
||||
0, 4, 2, 2, 2, 2, 1, 2,
|
||||
2, 2, 2, 2, 2, 3, 8, 1,
|
||||
2, 7, 9, 4, 1, 2, 3, 1,
|
||||
5, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_events_range_lengths[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 4, 0,
|
||||
0, 4, 4, 0, 0, 0, 0, 0,
|
||||
4, 0
|
||||
};
|
||||
|
||||
static const unsigned char _tsip_machine_parser_header_Allow_events_index_offsets[] = {
|
||||
0, 0, 5, 8, 11, 14, 17, 19,
|
||||
22, 25, 28, 31, 34, 37, 41, 54,
|
||||
56, 59, 71, 85, 90, 92, 95, 99,
|
||||
101, 111
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_events_indicies[] = {
|
||||
0, 2, 0, 2, 1, 3, 3, 1,
|
||||
4, 4, 1, 5, 5, 1, 6, 6,
|
||||
1, 7, 1, 8, 8, 1, 9, 9,
|
||||
1, 10, 10, 1, 11, 11, 1, 12,
|
||||
12, 1, 2, 2, 1, 2, 2, 13,
|
||||
1, 13, 14, 13, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 1, 16, 1,
|
||||
17, 17, 1, 17, 17, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 1, 18,
|
||||
19, 18, 20, 20, 20, 21, 22, 20,
|
||||
20, 20, 20, 20, 1, 23, 24, 23,
|
||||
13, 1, 25, 1, 26, 26, 1, 26,
|
||||
26, 13, 1, 27, 1, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 1, 1,
|
||||
0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_events_trans_targs[] = {
|
||||
2, 0, 13, 3, 4, 5, 6, 7,
|
||||
8, 9, 10, 11, 12, 14, 15, 18,
|
||||
16, 17, 19, 23, 18, 14, 24, 19,
|
||||
20, 21, 22, 25
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_Allow_events_trans_actions[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1,
|
||||
0, 0, 3, 3, 0, 3, 0, 0,
|
||||
0, 0, 0, 5
|
||||
};
|
||||
|
||||
static const int tsip_machine_parser_header_Allow_events_start = 1;
|
||||
static const int tsip_machine_parser_header_Allow_events_first_final = 25;
|
||||
static const int tsip_machine_parser_header_Allow_events_error = 0;
|
||||
|
@ -98,363 +178,113 @@ static const int tsip_machine_parser_header_Allow_events_en_main = 1;
|
|||
|
||||
/* #line 116 "tsip_parser_header_Allow_Events.rl" */
|
||||
|
||||
/* #line 102 "../source/headers/tsip_header_Allow_Events.c" */
|
||||
/* #line 182 "../src/headers/tsip_header_Allow_Events.c" */
|
||||
{
|
||||
cs = tsip_machine_parser_header_Allow_events_start;
|
||||
}
|
||||
|
||||
/* #line 117 "tsip_parser_header_Allow_Events.rl" */
|
||||
|
||||
/* #line 109 "../source/headers/tsip_header_Allow_Events.c" */
|
||||
/* #line 189 "../src/headers/tsip_header_Allow_Events.c" */
|
||||
{
|
||||
int _klen;
|
||||
unsigned int _trans;
|
||||
const char *_acts;
|
||||
unsigned int _nacts;
|
||||
const char *_keys;
|
||||
|
||||
if ( p == pe )
|
||||
goto _test_eof;
|
||||
switch ( cs )
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
_resume:
|
||||
_keys = _tsip_machine_parser_header_Allow_events_trans_keys + _tsip_machine_parser_header_Allow_events_key_offsets[cs];
|
||||
_trans = _tsip_machine_parser_header_Allow_events_index_offsets[cs];
|
||||
|
||||
_klen = _tsip_machine_parser_header_Allow_events_single_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + _klen - 1;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + ((_upper-_lower) >> 1);
|
||||
if ( (*p) < *_mid )
|
||||
_upper = _mid - 1;
|
||||
else if ( (*p) > *_mid )
|
||||
_lower = _mid + 1;
|
||||
else {
|
||||
_trans += (_mid - _keys);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_keys += _klen;
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_klen = _tsip_machine_parser_header_Allow_events_range_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + (_klen<<1) - 2;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
|
||||
if ( (*p) < _mid[0] )
|
||||
_upper = _mid - 2;
|
||||
else if ( (*p) > _mid[1] )
|
||||
_lower = _mid + 2;
|
||||
else {
|
||||
_trans += ((_mid - _keys)>>1);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_match:
|
||||
_trans = _tsip_machine_parser_header_Allow_events_indicies[_trans];
|
||||
cs = _tsip_machine_parser_header_Allow_events_trans_targs[_trans];
|
||||
|
||||
if ( _tsip_machine_parser_header_Allow_events_trans_actions[_trans] == 0 )
|
||||
goto _again;
|
||||
|
||||
_acts = _tsip_machine_parser_header_Allow_events_actions + _tsip_machine_parser_header_Allow_events_trans_actions[_trans];
|
||||
_nacts = (unsigned int) *_acts++;
|
||||
while ( _nacts-- > 0 )
|
||||
{
|
||||
case 1:
|
||||
switch( (*p) ) {
|
||||
case 65: goto st2;
|
||||
case 85: goto st13;
|
||||
case 97: goto st2;
|
||||
case 117: goto st13;
|
||||
}
|
||||
goto st0;
|
||||
st0:
|
||||
cs = 0;
|
||||
goto _out;
|
||||
st2:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof2;
|
||||
case 2:
|
||||
switch( (*p) ) {
|
||||
case 76: goto st3;
|
||||
case 108: goto st3;
|
||||
}
|
||||
goto st0;
|
||||
st3:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof3;
|
||||
case 3:
|
||||
switch( (*p) ) {
|
||||
case 76: goto st4;
|
||||
case 108: goto st4;
|
||||
}
|
||||
goto st0;
|
||||
st4:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof4;
|
||||
case 4:
|
||||
switch( (*p) ) {
|
||||
case 79: goto st5;
|
||||
case 111: goto st5;
|
||||
}
|
||||
goto st0;
|
||||
st5:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof5;
|
||||
case 5:
|
||||
switch( (*p) ) {
|
||||
case 87: goto st6;
|
||||
case 119: goto st6;
|
||||
}
|
||||
goto st0;
|
||||
st6:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof6;
|
||||
case 6:
|
||||
if ( (*p) == 45 )
|
||||
goto st7;
|
||||
goto st0;
|
||||
st7:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof7;
|
||||
case 7:
|
||||
switch( (*p) ) {
|
||||
case 69: goto st8;
|
||||
case 101: goto st8;
|
||||
}
|
||||
goto st0;
|
||||
st8:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof8;
|
||||
case 8:
|
||||
switch( (*p) ) {
|
||||
case 86: goto st9;
|
||||
case 118: goto st9;
|
||||
}
|
||||
goto st0;
|
||||
st9:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof9;
|
||||
case 9:
|
||||
switch( (*p) ) {
|
||||
case 69: goto st10;
|
||||
case 101: goto st10;
|
||||
}
|
||||
goto st0;
|
||||
st10:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof10;
|
||||
case 10:
|
||||
switch( (*p) ) {
|
||||
case 78: goto st11;
|
||||
case 110: goto st11;
|
||||
}
|
||||
goto st0;
|
||||
st11:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof11;
|
||||
case 11:
|
||||
switch( (*p) ) {
|
||||
case 84: goto st12;
|
||||
case 116: goto st12;
|
||||
}
|
||||
goto st0;
|
||||
st12:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof12;
|
||||
case 12:
|
||||
switch( (*p) ) {
|
||||
case 83: goto st13;
|
||||
case 115: goto st13;
|
||||
}
|
||||
goto st0;
|
||||
st13:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof13;
|
||||
case 13:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st13;
|
||||
case 32: goto st13;
|
||||
case 58: goto st14;
|
||||
}
|
||||
goto st0;
|
||||
tr21:
|
||||
/* #line 58 "tsip_parser_header_Allow_Events.rl" */
|
||||
{
|
||||
PARSER_ADD_STRING(hdr_allow_events->events);
|
||||
}
|
||||
goto st14;
|
||||
st14:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof14;
|
||||
case 14:
|
||||
/* #line 243 "../source/headers/tsip_header_Allow_Events.c" */
|
||||
switch( (*p) ) {
|
||||
case 9: goto st14;
|
||||
case 13: goto st15;
|
||||
case 32: goto st14;
|
||||
case 33: goto tr15;
|
||||
case 37: goto tr15;
|
||||
case 39: goto tr15;
|
||||
case 45: goto tr15;
|
||||
case 126: goto tr15;
|
||||
}
|
||||
if ( (*p) < 48 ) {
|
||||
if ( 42 <= (*p) && (*p) <= 43 )
|
||||
goto tr15;
|
||||
} else if ( (*p) > 57 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 95 <= (*p) && (*p) <= 122 )
|
||||
goto tr15;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto tr15;
|
||||
} else
|
||||
goto tr15;
|
||||
goto st0;
|
||||
st15:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof15;
|
||||
case 15:
|
||||
if ( (*p) == 10 )
|
||||
goto st16;
|
||||
goto st0;
|
||||
st16:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof16;
|
||||
case 16:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st17;
|
||||
case 32: goto st17;
|
||||
}
|
||||
goto st0;
|
||||
st17:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof17;
|
||||
case 17:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st17;
|
||||
case 32: goto st17;
|
||||
case 33: goto tr15;
|
||||
case 37: goto tr15;
|
||||
case 39: goto tr15;
|
||||
case 45: goto tr15;
|
||||
case 126: goto tr15;
|
||||
}
|
||||
if ( (*p) < 48 ) {
|
||||
if ( 42 <= (*p) && (*p) <= 43 )
|
||||
goto tr15;
|
||||
} else if ( (*p) > 57 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 95 <= (*p) && (*p) <= 122 )
|
||||
goto tr15;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto tr15;
|
||||
} else
|
||||
goto tr15;
|
||||
goto st0;
|
||||
tr15:
|
||||
switch ( *_acts++ )
|
||||
{
|
||||
case 0:
|
||||
/* #line 53 "tsip_parser_header_Allow_Events.rl" */
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
goto st18;
|
||||
st18:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof18;
|
||||
case 18:
|
||||
/* #line 317 "../source/headers/tsip_header_Allow_Events.c" */
|
||||
switch( (*p) ) {
|
||||
case 9: goto tr18;
|
||||
case 13: goto tr19;
|
||||
case 32: goto tr18;
|
||||
case 33: goto st18;
|
||||
case 37: goto st18;
|
||||
case 39: goto st18;
|
||||
case 44: goto tr21;
|
||||
case 46: goto st24;
|
||||
case 126: goto st18;
|
||||
}
|
||||
if ( (*p) < 48 ) {
|
||||
if ( 42 <= (*p) && (*p) <= 45 )
|
||||
goto st18;
|
||||
} else if ( (*p) > 57 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 95 <= (*p) && (*p) <= 122 )
|
||||
goto st18;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto st18;
|
||||
} else
|
||||
goto st18;
|
||||
goto st0;
|
||||
tr18:
|
||||
break;
|
||||
case 1:
|
||||
/* #line 58 "tsip_parser_header_Allow_Events.rl" */
|
||||
{
|
||||
PARSER_ADD_STRING(hdr_allow_events->events);
|
||||
TSK_PARSER_ADD_STRING(hdr_allow_events->events);
|
||||
}
|
||||
goto st19;
|
||||
st19:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof19;
|
||||
case 19:
|
||||
/* #line 351 "../source/headers/tsip_header_Allow_Events.c" */
|
||||
switch( (*p) ) {
|
||||
case 9: goto st19;
|
||||
case 13: goto st20;
|
||||
case 32: goto st19;
|
||||
case 44: goto st14;
|
||||
}
|
||||
goto st0;
|
||||
st20:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof20;
|
||||
case 20:
|
||||
if ( (*p) == 10 )
|
||||
goto st21;
|
||||
goto st0;
|
||||
st21:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof21;
|
||||
case 21:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st22;
|
||||
case 32: goto st22;
|
||||
}
|
||||
goto st0;
|
||||
st22:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof22;
|
||||
case 22:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st22;
|
||||
case 32: goto st22;
|
||||
case 44: goto st14;
|
||||
}
|
||||
goto st0;
|
||||
tr19:
|
||||
/* #line 58 "tsip_parser_header_Allow_Events.rl" */
|
||||
{
|
||||
PARSER_ADD_STRING(hdr_allow_events->events);
|
||||
}
|
||||
goto st23;
|
||||
st23:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof23;
|
||||
case 23:
|
||||
/* #line 395 "../source/headers/tsip_header_Allow_Events.c" */
|
||||
if ( (*p) == 10 )
|
||||
goto tr27;
|
||||
goto st0;
|
||||
tr27:
|
||||
break;
|
||||
case 2:
|
||||
/* #line 63 "tsip_parser_header_Allow_Events.rl" */
|
||||
{
|
||||
}
|
||||
goto st25;
|
||||
st25:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof25;
|
||||
case 25:
|
||||
/* #line 408 "../source/headers/tsip_header_Allow_Events.c" */
|
||||
goto st0;
|
||||
st24:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof24;
|
||||
case 24:
|
||||
switch( (*p) ) {
|
||||
case 33: goto st18;
|
||||
case 37: goto st18;
|
||||
case 39: goto st18;
|
||||
case 45: goto st18;
|
||||
case 126: goto st18;
|
||||
break;
|
||||
/* #line 280 "../src/headers/tsip_header_Allow_Events.c" */
|
||||
}
|
||||
}
|
||||
if ( (*p) < 48 ) {
|
||||
if ( 42 <= (*p) && (*p) <= 43 )
|
||||
goto st18;
|
||||
} else if ( (*p) > 57 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 95 <= (*p) && (*p) <= 122 )
|
||||
goto st18;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto st18;
|
||||
} else
|
||||
goto st18;
|
||||
goto st0;
|
||||
}
|
||||
_test_eof2: cs = 2; goto _test_eof;
|
||||
_test_eof3: cs = 3; goto _test_eof;
|
||||
_test_eof4: cs = 4; goto _test_eof;
|
||||
_test_eof5: cs = 5; goto _test_eof;
|
||||
_test_eof6: cs = 6; goto _test_eof;
|
||||
_test_eof7: cs = 7; goto _test_eof;
|
||||
_test_eof8: cs = 8; goto _test_eof;
|
||||
_test_eof9: cs = 9; goto _test_eof;
|
||||
_test_eof10: cs = 10; goto _test_eof;
|
||||
_test_eof11: cs = 11; goto _test_eof;
|
||||
_test_eof12: cs = 12; goto _test_eof;
|
||||
_test_eof13: cs = 13; goto _test_eof;
|
||||
_test_eof14: cs = 14; goto _test_eof;
|
||||
_test_eof15: cs = 15; goto _test_eof;
|
||||
_test_eof16: cs = 16; goto _test_eof;
|
||||
_test_eof17: cs = 17; goto _test_eof;
|
||||
_test_eof18: cs = 18; goto _test_eof;
|
||||
_test_eof19: cs = 19; goto _test_eof;
|
||||
_test_eof20: cs = 20; goto _test_eof;
|
||||
_test_eof21: cs = 21; goto _test_eof;
|
||||
_test_eof22: cs = 22; goto _test_eof;
|
||||
_test_eof23: cs = 23; goto _test_eof;
|
||||
_test_eof25: cs = 25; goto _test_eof;
|
||||
_test_eof24: cs = 24; goto _test_eof;
|
||||
|
||||
_again:
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
if ( ++p != pe )
|
||||
goto _resume;
|
||||
_test_eof: {}
|
||||
_out: {}
|
||||
}
|
||||
|
@ -462,7 +292,7 @@ case 24:
|
|||
/* #line 118 "tsip_parser_header_Allow_Events.rl" */
|
||||
|
||||
if( cs <
|
||||
/* #line 466 "../source/headers/tsip_header_Allow_Events.c" */
|
||||
/* #line 296 "../src/headers/tsip_header_Allow_Events.c" */
|
||||
25
|
||||
/* #line 119 "tsip_parser_header_Allow_Events.rl" */
|
||||
)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -67,7 +67,75 @@ tsip_header_CSeq_t *tsip_header_CSeq_parse(const char *data, size_t size)
|
|||
const char *tag_start;
|
||||
|
||||
|
||||
/* #line 71 "../source/headers/tsip_header_CSeq.c" */
|
||||
/* #line 71 "../src/headers/tsip_header_CSeq.c" */
|
||||
static const char _tsip_machine_parser_header_CSeq_actions[] = {
|
||||
0, 1, 0, 1, 1, 1, 2, 1,
|
||||
3
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_CSeq_key_offsets[] = {
|
||||
0, 0, 2, 4, 6, 8, 11, 16,
|
||||
17, 19, 23, 28, 45, 46, 48, 64,
|
||||
79, 80
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_CSeq_trans_keys[] = {
|
||||
67, 99, 83, 115, 69, 101, 81, 113,
|
||||
9, 32, 58, 9, 13, 32, 48, 57,
|
||||
10, 9, 32, 9, 32, 48, 57, 9,
|
||||
13, 32, 48, 57, 9, 13, 32, 33,
|
||||
37, 39, 126, 42, 43, 45, 46, 48,
|
||||
57, 65, 90, 95, 122, 10, 9, 32,
|
||||
9, 32, 33, 37, 39, 126, 42, 43,
|
||||
45, 46, 48, 57, 65, 90, 95, 122,
|
||||
13, 33, 37, 39, 126, 42, 43, 45,
|
||||
46, 48, 57, 65, 90, 95, 122, 10,
|
||||
0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_CSeq_single_lengths[] = {
|
||||
0, 2, 2, 2, 2, 3, 3, 1,
|
||||
2, 2, 3, 7, 1, 2, 6, 5,
|
||||
1, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_CSeq_range_lengths[] = {
|
||||
0, 0, 0, 0, 0, 0, 1, 0,
|
||||
0, 1, 1, 5, 0, 0, 5, 5,
|
||||
0, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_CSeq_index_offsets[] = {
|
||||
0, 0, 3, 6, 9, 12, 16, 21,
|
||||
23, 26, 30, 35, 48, 50, 53, 65,
|
||||
76, 78
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_CSeq_indicies[] = {
|
||||
0, 0, 1, 2, 2, 1, 3, 3,
|
||||
1, 4, 4, 1, 4, 4, 5, 1,
|
||||
5, 6, 5, 7, 1, 8, 1, 9,
|
||||
9, 1, 9, 9, 7, 1, 10, 11,
|
||||
10, 12, 1, 13, 14, 13, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 1,
|
||||
16, 1, 17, 17, 1, 17, 17, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15,
|
||||
1, 18, 19, 19, 19, 19, 19, 19,
|
||||
19, 19, 19, 1, 20, 1, 1, 0
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_CSeq_trans_targs[] = {
|
||||
2, 0, 3, 4, 5, 6, 7, 10,
|
||||
8, 9, 11, 12, 10, 11, 12, 15,
|
||||
13, 14, 16, 15, 17
|
||||
};
|
||||
|
||||
static const char _tsip_machine_parser_header_CSeq_trans_actions[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 1,
|
||||
0, 0, 5, 5, 0, 0, 0, 1,
|
||||
0, 0, 3, 0, 7
|
||||
};
|
||||
|
||||
static const int tsip_machine_parser_header_CSeq_start = 1;
|
||||
static const int tsip_machine_parser_header_CSeq_first_final = 17;
|
||||
static const int tsip_machine_parser_header_CSeq_error = 0;
|
||||
|
@ -77,284 +145,119 @@ static const int tsip_machine_parser_header_CSeq_en_main = 1;
|
|||
|
||||
/* #line 96 "tsip_parser_header_CSeq.rl" */
|
||||
|
||||
/* #line 81 "../source/headers/tsip_header_CSeq.c" */
|
||||
/* #line 149 "../src/headers/tsip_header_CSeq.c" */
|
||||
{
|
||||
cs = tsip_machine_parser_header_CSeq_start;
|
||||
}
|
||||
|
||||
/* #line 97 "tsip_parser_header_CSeq.rl" */
|
||||
|
||||
/* #line 88 "../source/headers/tsip_header_CSeq.c" */
|
||||
/* #line 156 "../src/headers/tsip_header_CSeq.c" */
|
||||
{
|
||||
int _klen;
|
||||
unsigned int _trans;
|
||||
const char *_acts;
|
||||
unsigned int _nacts;
|
||||
const char *_keys;
|
||||
|
||||
if ( p == pe )
|
||||
goto _test_eof;
|
||||
switch ( cs )
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
_resume:
|
||||
_keys = _tsip_machine_parser_header_CSeq_trans_keys + _tsip_machine_parser_header_CSeq_key_offsets[cs];
|
||||
_trans = _tsip_machine_parser_header_CSeq_index_offsets[cs];
|
||||
|
||||
_klen = _tsip_machine_parser_header_CSeq_single_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + _klen - 1;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + ((_upper-_lower) >> 1);
|
||||
if ( (*p) < *_mid )
|
||||
_upper = _mid - 1;
|
||||
else if ( (*p) > *_mid )
|
||||
_lower = _mid + 1;
|
||||
else {
|
||||
_trans += (_mid - _keys);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_keys += _klen;
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_klen = _tsip_machine_parser_header_CSeq_range_lengths[cs];
|
||||
if ( _klen > 0 ) {
|
||||
const char *_lower = _keys;
|
||||
const char *_mid;
|
||||
const char *_upper = _keys + (_klen<<1) - 2;
|
||||
while (1) {
|
||||
if ( _upper < _lower )
|
||||
break;
|
||||
|
||||
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
|
||||
if ( (*p) < _mid[0] )
|
||||
_upper = _mid - 2;
|
||||
else if ( (*p) > _mid[1] )
|
||||
_lower = _mid + 2;
|
||||
else {
|
||||
_trans += ((_mid - _keys)>>1);
|
||||
goto _match;
|
||||
}
|
||||
}
|
||||
_trans += _klen;
|
||||
}
|
||||
|
||||
_match:
|
||||
_trans = _tsip_machine_parser_header_CSeq_indicies[_trans];
|
||||
cs = _tsip_machine_parser_header_CSeq_trans_targs[_trans];
|
||||
|
||||
if ( _tsip_machine_parser_header_CSeq_trans_actions[_trans] == 0 )
|
||||
goto _again;
|
||||
|
||||
_acts = _tsip_machine_parser_header_CSeq_actions + _tsip_machine_parser_header_CSeq_trans_actions[_trans];
|
||||
_nacts = (unsigned int) *_acts++;
|
||||
while ( _nacts-- > 0 )
|
||||
{
|
||||
case 1:
|
||||
switch( (*p) ) {
|
||||
case 67: goto st2;
|
||||
case 99: goto st2;
|
||||
}
|
||||
goto st0;
|
||||
st0:
|
||||
cs = 0;
|
||||
goto _out;
|
||||
st2:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof2;
|
||||
case 2:
|
||||
switch( (*p) ) {
|
||||
case 83: goto st3;
|
||||
case 115: goto st3;
|
||||
}
|
||||
goto st0;
|
||||
st3:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof3;
|
||||
case 3:
|
||||
switch( (*p) ) {
|
||||
case 69: goto st4;
|
||||
case 101: goto st4;
|
||||
}
|
||||
goto st0;
|
||||
st4:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof4;
|
||||
case 4:
|
||||
switch( (*p) ) {
|
||||
case 81: goto st5;
|
||||
case 113: goto st5;
|
||||
}
|
||||
goto st0;
|
||||
st5:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof5;
|
||||
case 5:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st5;
|
||||
case 32: goto st5;
|
||||
case 58: goto st6;
|
||||
}
|
||||
goto st0;
|
||||
st6:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof6;
|
||||
case 6:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st6;
|
||||
case 13: goto st7;
|
||||
case 32: goto st6;
|
||||
}
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr7;
|
||||
goto st0;
|
||||
st7:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof7;
|
||||
case 7:
|
||||
if ( (*p) == 10 )
|
||||
goto st8;
|
||||
goto st0;
|
||||
st8:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof8;
|
||||
case 8:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st9;
|
||||
case 32: goto st9;
|
||||
}
|
||||
goto st0;
|
||||
st9:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof9;
|
||||
case 9:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st9;
|
||||
case 32: goto st9;
|
||||
}
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto tr7;
|
||||
goto st0;
|
||||
tr7:
|
||||
switch ( *_acts++ )
|
||||
{
|
||||
case 0:
|
||||
/* #line 50 "tsip_parser_header_CSeq.rl" */
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
goto st10;
|
||||
st10:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof10;
|
||||
case 10:
|
||||
/* #line 189 "../source/headers/tsip_header_CSeq.c" */
|
||||
switch( (*p) ) {
|
||||
case 9: goto tr10;
|
||||
case 13: goto tr11;
|
||||
case 32: goto tr10;
|
||||
}
|
||||
if ( 48 <= (*p) && (*p) <= 57 )
|
||||
goto st10;
|
||||
goto st0;
|
||||
tr10:
|
||||
/* #line 60 "tsip_parser_header_CSeq.rl" */
|
||||
{
|
||||
PARSER_SET_INTEGER(hdr_cseq->seq);
|
||||
}
|
||||
goto st11;
|
||||
st11:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof11;
|
||||
case 11:
|
||||
/* #line 208 "../source/headers/tsip_header_CSeq.c" */
|
||||
switch( (*p) ) {
|
||||
case 9: goto st11;
|
||||
case 13: goto st12;
|
||||
case 32: goto st11;
|
||||
case 33: goto tr15;
|
||||
case 37: goto tr15;
|
||||
case 39: goto tr15;
|
||||
case 126: goto tr15;
|
||||
}
|
||||
if ( (*p) < 48 ) {
|
||||
if ( (*p) > 43 ) {
|
||||
if ( 45 <= (*p) && (*p) <= 46 )
|
||||
goto tr15;
|
||||
} else if ( (*p) >= 42 )
|
||||
goto tr15;
|
||||
} else if ( (*p) > 57 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 95 <= (*p) && (*p) <= 122 )
|
||||
goto tr15;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto tr15;
|
||||
} else
|
||||
goto tr15;
|
||||
goto st0;
|
||||
tr11:
|
||||
/* #line 60 "tsip_parser_header_CSeq.rl" */
|
||||
{
|
||||
PARSER_SET_INTEGER(hdr_cseq->seq);
|
||||
}
|
||||
goto st12;
|
||||
st12:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof12;
|
||||
case 12:
|
||||
/* #line 243 "../source/headers/tsip_header_CSeq.c" */
|
||||
if ( (*p) == 10 )
|
||||
goto st13;
|
||||
goto st0;
|
||||
st13:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof13;
|
||||
case 13:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st14;
|
||||
case 32: goto st14;
|
||||
}
|
||||
goto st0;
|
||||
st14:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof14;
|
||||
case 14:
|
||||
switch( (*p) ) {
|
||||
case 9: goto st14;
|
||||
case 32: goto st14;
|
||||
case 33: goto tr15;
|
||||
case 37: goto tr15;
|
||||
case 39: goto tr15;
|
||||
case 126: goto tr15;
|
||||
}
|
||||
if ( (*p) < 48 ) {
|
||||
if ( (*p) > 43 ) {
|
||||
if ( 45 <= (*p) && (*p) <= 46 )
|
||||
goto tr15;
|
||||
} else if ( (*p) >= 42 )
|
||||
goto tr15;
|
||||
} else if ( (*p) > 57 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 95 <= (*p) && (*p) <= 122 )
|
||||
goto tr15;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto tr15;
|
||||
} else
|
||||
goto tr15;
|
||||
goto st0;
|
||||
tr15:
|
||||
/* #line 50 "tsip_parser_header_CSeq.rl" */
|
||||
{
|
||||
tag_start = p;
|
||||
}
|
||||
goto st15;
|
||||
st15:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof15;
|
||||
case 15:
|
||||
/* #line 293 "../source/headers/tsip_header_CSeq.c" */
|
||||
switch( (*p) ) {
|
||||
case 13: goto tr18;
|
||||
case 33: goto st15;
|
||||
case 37: goto st15;
|
||||
case 39: goto st15;
|
||||
case 126: goto st15;
|
||||
}
|
||||
if ( (*p) < 48 ) {
|
||||
if ( (*p) > 43 ) {
|
||||
if ( 45 <= (*p) && (*p) <= 46 )
|
||||
goto st15;
|
||||
} else if ( (*p) >= 42 )
|
||||
goto st15;
|
||||
} else if ( (*p) > 57 ) {
|
||||
if ( (*p) > 90 ) {
|
||||
if ( 95 <= (*p) && (*p) <= 122 )
|
||||
goto st15;
|
||||
} else if ( (*p) >= 65 )
|
||||
goto st15;
|
||||
} else
|
||||
goto st15;
|
||||
goto st0;
|
||||
tr18:
|
||||
break;
|
||||
case 1:
|
||||
/* #line 55 "tsip_parser_header_CSeq.rl" */
|
||||
{
|
||||
PARSER_SET_STRING(hdr_cseq->method);
|
||||
TSK_PARSER_SET_STRING(hdr_cseq->method);
|
||||
}
|
||||
goto st16;
|
||||
st16:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof16;
|
||||
case 16:
|
||||
/* #line 326 "../source/headers/tsip_header_CSeq.c" */
|
||||
if ( (*p) == 10 )
|
||||
goto tr20;
|
||||
goto st0;
|
||||
tr20:
|
||||
break;
|
||||
case 2:
|
||||
/* #line 60 "tsip_parser_header_CSeq.rl" */
|
||||
{
|
||||
TSK_PARSER_SET_INTEGER(hdr_cseq->seq);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
/* #line 65 "tsip_parser_header_CSeq.rl" */
|
||||
{
|
||||
}
|
||||
goto st17;
|
||||
st17:
|
||||
if ( ++p == pe )
|
||||
goto _test_eof17;
|
||||
case 17:
|
||||
/* #line 339 "../source/headers/tsip_header_CSeq.c" */
|
||||
goto st0;
|
||||
break;
|
||||
/* #line 253 "../src/headers/tsip_header_CSeq.c" */
|
||||
}
|
||||
}
|
||||
_test_eof2: cs = 2; goto _test_eof;
|
||||
_test_eof3: cs = 3; goto _test_eof;
|
||||
_test_eof4: cs = 4; goto _test_eof;
|
||||
_test_eof5: cs = 5; goto _test_eof;
|
||||
_test_eof6: cs = 6; goto _test_eof;
|
||||
_test_eof7: cs = 7; goto _test_eof;
|
||||
_test_eof8: cs = 8; goto _test_eof;
|
||||
_test_eof9: cs = 9; goto _test_eof;
|
||||
_test_eof10: cs = 10; goto _test_eof;
|
||||
_test_eof11: cs = 11; goto _test_eof;
|
||||
_test_eof12: cs = 12; goto _test_eof;
|
||||
_test_eof13: cs = 13; goto _test_eof;
|
||||
_test_eof14: cs = 14; goto _test_eof;
|
||||
_test_eof15: cs = 15; goto _test_eof;
|
||||
_test_eof16: cs = 16; goto _test_eof;
|
||||
_test_eof17: cs = 17; goto _test_eof;
|
||||
|
||||
_again:
|
||||
if ( cs == 0 )
|
||||
goto _out;
|
||||
if ( ++p != pe )
|
||||
goto _resume;
|
||||
_test_eof: {}
|
||||
_out: {}
|
||||
}
|
||||
|
@ -362,7 +265,7 @@ case 17:
|
|||
/* #line 98 "tsip_parser_header_CSeq.rl" */
|
||||
|
||||
if( cs <
|
||||
/* #line 366 "../source/headers/tsip_header_CSeq.c" */
|
||||
/* #line 269 "../src/headers/tsip_header_CSeq.c" */
|
||||
17
|
||||
/* #line 99 "tsip_parser_header_CSeq.rl" */
|
||||
)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue