Update HTTP/HTTPS stack.

This commit is contained in:
bossiel 2010-03-10 18:05:59 +00:00
parent 7452e9c929
commit cf8fcffc29
35 changed files with 11604 additions and 5067 deletions

View File

@ -36,6 +36,8 @@
THTTP_BEGIN_DECLS
#define THTTP_MAX_CONTENT_SIZE 0xFFFF
typedef enum thttp_stack_param_type_e
{
/* Identity */
@ -70,8 +72,8 @@ TINYHTTP_API int thttp_stack_set(thttp_stack_handle_t *self, ...);
TINYHTTP_API int thttp_stack_stop(thttp_stack_handle_t *self);
int thttp_stack_send(thttp_stack_handle_t *self, thttp_operation_handle_t* op, const struct thttp_message_s* message);
int thttp_stack_add_op(thttp_stack_handle_t *self, thttp_operation_handle_t* op);
int thttp_stack_remove_op(thttp_stack_handle_t *self, thttp_operation_handle_t* op);
int thttp_stack_push_op(thttp_stack_handle_t *self, thttp_operation_handle_t* op);
int thttp_stack_pop_op(thttp_stack_handle_t *self, thttp_operation_handle_t* op);
TINYHTTP_GEXTERN const void *thttp_stack_def_t;

View File

@ -43,7 +43,7 @@
THTTP_BEGIN_DECLS
#define THTTP_CHALLENGE_CREATE(username, password, isproxy, scheme, realm, nonce, opaque, algorithm, qop) tsk_object_new(thttp_challenge_def_t, username, password, (unsigned)isproxy,(const char*)scheme, (const char*)realm, (const char*)nonce, (const char*)opaque, (const char*)algorithm, (const char*)qop)
#define THTTP_CHALLENGE_CREATE(isproxy, scheme, realm, nonce, opaque, algorithm, qop) tsk_object_new(thttp_challenge_def_t, (unsigned)isproxy,(const char*)scheme, (const char*)realm, (const char*)nonce, (const char*)opaque, (const char*)algorithm, (const char*)qop)
typedef struct thttp_challenge_s
{
@ -58,9 +58,6 @@ typedef struct thttp_challenge_s
char* algorithm;
const char* qop;
char* username;
char* password;
tsk_md5string_t cnonce;
unsigned nc;
}
@ -69,7 +66,7 @@ thttp_challenge_t;
typedef tsk_list_t thttp_challenges_L_t;
int thttp_challenge_update(thttp_challenge_t *self, const char* scheme, const char* realm, const char* nonce, const char* opaque, const char* algorithm, const char* qop);
thttp_header_t *thttp_challenge_create_header_authorization(thttp_challenge_t *self, const thttp_request_t *request);
thttp_header_t *thttp_challenge_create_header_authorization(thttp_challenge_t *self, const char* username, const char* password, const thttp_request_t *request);
TINYHTTP_GEXTERN const void *thttp_challenge_def_t;

View File

@ -32,20 +32,31 @@
#include "tinyhttp_config.h"
#include "tinyHTTP/thttp_operation.h"
#include "tsk_object.h"
THTTP_BEGIN_DECLS
#define THTTP_EVENT_CREATE(code, phrase, message) tsk_object_new(thttp_event_def_t, code, phrase, (const thttp_message_t*)message)
#define THTTP_EVENT_CREATE(type, opid, description, message) tsk_object_new(thttp_event_def_t, (thttp_event_type_t)type, (thttp_operation_id_t)opid, (const char*)description, (const thttp_message_t*)message)
#define THTTP_EVENT(self) ((thttp_event_t*)(self))
typedef enum thttp_event_type_e
{
thttp_event_message,
thttp_event_closed,
}
thttp_event_type_t;
typedef struct thttp_event_s
{
TSK_DECLARE_OBJECT;
short code;
char* phrase;
thttp_event_type_t type;
thttp_operation_id_t opid;
char* description;
struct thttp_message_s *message;
}
thttp_event_t;

View File

@ -74,14 +74,14 @@ THTTP_BEGIN_DECLS
#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_CODE(self) (THTTP_MESSAGE_IS_RESPONSE((self)) ? (self)->status_code : 0)
#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_CONTENT(message) (THTTP_MESSAGE_HAS_CONTENT(message) ? (message)->Content->data : 0)
#define THTTP_MESSAGE_HAS_CONTENT(message) ((message) && (message)->Content)
#define THTTP_RESPONSE_IS(self, code) (THTTP_RESPONSE_CODE((self)) == code)
@ -158,8 +158,9 @@ 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_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);
TINYHTTP_API int thttp_message_add_content(thttp_message_t *self, const char* content_type, const void* content, size_t size);
#if !defined(_MSC_VER) || defined(__GNUC__)
static void THTTP_MESSAGE_ADD_HEADER(thttp_message_t *self, ...)

View File

@ -37,6 +37,7 @@
#include "tsk_object.h"
#include "tsk_list.h"
#include "tsk_params.h"
#include "tsk_fsm.h"
THTTP_BEGIN_DECLS
@ -71,8 +72,10 @@ const tsk_param_t* thttp_operation_get_header(const thttp_operation_handle_t *se
const tsk_params_L_t* thttp_operation_get_headers(const thttp_operation_handle_t *self);
const tsk_params_L_t* thttp_operation_get_params(const thttp_operation_handle_t *self);
tnet_fd_t thttp_operation_get_fd(const thttp_operation_handle_t *self);
tsk_buffer_t* thttp_operation_get_buf(const thttp_operation_handle_t *self);
int thttp_operation_set_fd(thttp_operation_handle_t *self, tnet_fd_t fd);
TINYHTTP_API int thttp_operation_perform(thttp_operation_handle_t* self);
TINYHTTP_API int thttp_operation_cancel(thttp_operation_handle_t* self); // TODO
typedef tsk_list_t thttp_operations_L_t; /**< List of @ref thttp_operation_handle_t elements. */
TINYHTTP_GEXTERN const void *thttp_operation_def_t;

View File

@ -59,6 +59,7 @@
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_Authenticate = "Proxy-Authenticate"i SP* HCOLON SP*<: any* :>CRLF @parse_header_Proxy_Authenticate;
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;
@ -69,13 +70,15 @@
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;
WWW_Authenticate = "WWW-Authenticate"i SP* HCOLON SP*<: any* :>CRLF @parse_header_WWW_Authenticate;
######
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;
auth_header = Authorization | WWW_Authenticate | Proxy_Authorization | Proxy_Authenticate;
request_header = Accept | Accept_Charset | Accept_Encoding | Accept_Language | Expect | From | Host | If_Match | If_Modified_Since | If_None_Match | If_Range | If_Unmodified_Since | Max_Forwards | 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;
HEADER = (general_header | auth_header | request_header | entity_header)@1 | extension_header@0;
}%%

View File

@ -46,6 +46,5 @@
Request = Request_Line (message_header* :>CRLF);
# HTTP MESSAGE
HTTP_message = Request | Response;
HTTP_message = (Response | Request)>1 @eoh message_body?>0;
}%%

View File

@ -31,10 +31,11 @@
//#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_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_Dummy.h"
//#include "tinyhttp/headers/thttp_header_Expires.h"
//#include "tinyhttp/headers/thttp_header_From.h"
//#include "tinyhttp/headers/thttp_header_Max_Forwards.h"
@ -53,10 +54,31 @@
//#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 "tinyhttp/headers/thttp_header_WWW_Authenticate.h"
#include "tsk_debug.h"
#undef ADD_HEADERS
#undef ADD_HEADER
#define ADD_HEADERS(headers)\
if(headers)\
{\
tsk_list_item_t *item;\
tsk_list_foreach(item, headers)\
{\
thttp_header_t *hdr = tsk_object_ref(item->data);\
tsk_list_push_back_data(message->headers, ((void**) &hdr));\
}\
\
TSK_OBJECT_SAFE_FREE(headers);\
}
#define ADD_HEADER(header)\
if(header)\
{\
tsk_list_push_back_data(message->headers, ((void**) &header));\
}
/***********************************
* Ragel state machine.
*/
@ -67,235 +89,370 @@
# /*== Accept: ==*/
action parse_header_Accept
{
TSK_DEBUG_ERROR("parse_header_Accept NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Accept NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Accept_Charset: ==*/
action parse_header_Accept_Charset
{
TSK_DEBUG_ERROR("parse_header_Accept_Charset NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Accept_Charset NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Accept_Encoding: ==*/
action parse_header_Accept_Encoding
{
TSK_DEBUG_ERROR("parse_header_Accept_Encoding NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Accept_Encoding NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Accept_Language: ==*/
action parse_header_Accept_Language
{
TSK_DEBUG_ERROR("parse_header_Accept_Language NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Accept_Language NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Allow: ==*/
action parse_header_Allow
{
TSK_DEBUG_ERROR("parse_header_Allow NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Allow NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Authorization: ==*/
action parse_header_Authorization
{
TSK_DEBUG_ERROR("parse_header_Authorization NOT IMPLEMENTED");
thttp_header_Authorization_t *header = thttp_header_Authorization_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
}
# /*== Cache_Control: ==*/
action parse_header_Cache_Control
{
TSK_DEBUG_ERROR("parse_header_Cache_Control NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Cache_Control NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Connection: ==*/
action parse_header_Connection
{
TSK_DEBUG_ERROR("parse_header_Connection NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Connection NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Content_Encoding: ==*/
action parse_header_Content_Encoding
{
TSK_DEBUG_ERROR("parse_header_Content_Encoding NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Content_Encoding NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Content_Language: ==*/
action parse_header_Content_Language
{
TSK_DEBUG_ERROR("parse_header_Content_Language NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Content_Language NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Content_Length: ==*/
action parse_header_Content_Length
{
TSK_DEBUG_ERROR("parse_header_Content_Length NOT IMPLEMENTED");
if(!message->Content_Length){
message->Content_Length = thttp_header_Content_Length_parse(state->tag_start, (state->tag_end-state->tag_start));
}
else{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("The message already have 'Content-Length' header.");
}
}
# /*== Content_Location: ==*/
action parse_header_Content_Location
{
TSK_DEBUG_ERROR("parse_header_Content_Location NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Content_Location NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Content_MD5: ==*/
action parse_header_Content_MD5
{
TSK_DEBUG_ERROR("parse_header_Content_MD5 NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Content_MD5 NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Content_Range: ==*/
action parse_header_Content_Range
{
TSK_DEBUG_ERROR("parse_header_Content_Range NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Content_Range NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Content_Type: ==*/
action parse_header_Content_Type
{
TSK_DEBUG_ERROR("parse_header_Content_Type NOT IMPLEMENTED");
if(!message->Content_Type){
message->Content_Type = thttp_header_Content_Type_parse(state->tag_start, (state->tag_end-state->tag_start));
}
else{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("The message already have 'Content-Type' header.");
}
}
# /*== Date: ==*/
action parse_header_Date
{
TSK_DEBUG_ERROR("parse_header_Date NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Date NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Expect: ==*/
action parse_header_Expect
{
TSK_DEBUG_ERROR("parse_header_Expect NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Expect NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Expires: ==*/
action parse_header_Expires
{
TSK_DEBUG_ERROR("parse_header_Expires NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Expires NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== From: ==*/
action parse_header_From
{
TSK_DEBUG_ERROR("parse_header_From NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_From NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Host: ==*/
action parse_header_Host
{
TSK_DEBUG_ERROR("parse_header_Host NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Host NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== If_Match: ==*/
action parse_header_If_Match
{
TSK_DEBUG_ERROR("parse_header_If_Match NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_If_Match NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== If_Modified_Since: ==*/
action parse_header_If_Modified_Since
{
TSK_DEBUG_ERROR("parse_header_If_Modified_Since NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_If_Modified_Since NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== If_None_Match: ==*/
action parse_header_If_None_Match
{
TSK_DEBUG_ERROR("parse_header_If_None_Match NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_If_None_Match NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== If_Range: ==*/
action parse_header_If_Range
{
TSK_DEBUG_ERROR("parse_header_If_Range NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_If_Range NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== If_Unmodified_Since: ==*/
action parse_header_If_Unmodified_Since
{
TSK_DEBUG_ERROR("parse_header_If_Unmodified_Since NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_If_Unmodified_Since NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Last_Modified: ==*/
action parse_header_Last_Modified
{
TSK_DEBUG_ERROR("parse_header_Last_Modified NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Last_Modified NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Max_Forwards: ==*/
action parse_header_Max_Forwards
{
TSK_DEBUG_ERROR("parse_header_Max_Forwards NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Max_Forwards NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Pragma: ==*/
action parse_header_Pragma
{
TSK_DEBUG_ERROR("parse_header_Pragma NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Pragma NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Proxy_Authenticate: ==*/
action parse_header_Proxy_Authenticate
{
thttp_header_Proxy_Authenticate_t *header = thttp_header_Proxy_Authenticate_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
}
# /*== Proxy_Authorization: ==*/
action parse_header_Proxy_Authorization
{
TSK_DEBUG_ERROR("parse_header_Proxy_Authorizations NOT IMPLEMENTED");
thttp_header_Proxy_Authorization_t *header = thttp_header_Proxy_Authorization_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
}
# /*== Range: ==*/
action parse_header_Range
{
TSK_DEBUG_ERROR("parse_header_Range NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Range NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Referer: ==*/
action parse_header_Referer
{
TSK_DEBUG_ERROR("parse_header_Referer NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Referer NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Transfer_Encoding: ==*/
action parse_header_Transfer_Encoding
{
TSK_DEBUG_ERROR("parse_header_Transfer_Encoding NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Transfer_Encoding NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== TE: ==*/
action parse_header_TE
{
TSK_DEBUG_ERROR("parse_header_TE NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_TE NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Trailer: ==*/
action parse_header_Trailer
{
TSK_DEBUG_ERROR("parse_header_Trailer NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Trailer NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Upgrade: ==*/
action parse_header_Upgrade
{
TSK_DEBUG_ERROR("parse_header_Upgrade NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Upgrade NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== User_Agent: ==*/
action parse_header_User_Agent
{
TSK_DEBUG_ERROR("parse_header_User_Agent NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_User_Agent NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Via: ==*/
action parse_header_Via
{
TSK_DEBUG_ERROR("parse_header_Via NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Via NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Warning: ==*/
action parse_header_Warning
{
TSK_DEBUG_ERROR("parse_header_Warning NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Warning NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== WWW-Authenticate: ==*/
action parse_header_WWW_Authenticate
{
thttp_header_WWW_Authenticate_t *header = thttp_header_WWW_Authenticate_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
}
# /*== extension_header: ==*/
action parse_header_extension_header
{
TSK_DEBUG_ERROR("parse_header_extension_header NOT IMPLEMENTED");
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_extension_header NOT IMPLEMENTED. Will be added as Dummy header.");
}

View File

@ -80,8 +80,7 @@ static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *
state->tag_end = p;
len = (int)(state->tag_end - state->tag_start);
if(!message->url)
{
if(!message->url){
message->url = thttp_url_parse(state->tag_start, (size_t)len);
}
}
@ -93,8 +92,7 @@ static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *
state->tag_end = p;
len = (int)(state->tag_end - state->tag_start);
if(!message->http_version)
{
if(!message->http_version){
message->http_version = tsk_calloc(1, len+1);
memcpy(message->http_version, state->tag_start, len);
}
@ -107,13 +105,11 @@ static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *
state->tag_end = p;
len = (int)(state->tag_end - state->tag_start);
if(message->type == thttp_unknown)
{
if(message->type == thttp_unknown){
message->type = thttp_response;
message->status_code = atoi(state->tag_start);
}
else
{
else{
state->cs = thttp_machine_parser_message_error;
}
}
@ -125,8 +121,7 @@ static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *
state->tag_end = p;
len = (int)(state->tag_end - state->tag_start);
if(!message->reason_phrase)
{
if(!message->reason_phrase){
message->reason_phrase = tsk_calloc(1, len+1);
memcpy(message->reason_phrase, state->tag_start, len);
}
@ -139,14 +134,12 @@ static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *
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
{
if(thttp_header_parse(state, message)){
TSK_DEBUG_ERROR("Failed to parse header - %s", state->tag_start);
}
else{
//TSK_DEBUG_INFO("THTTP_MESSAGE_PARSER::PARSE_HEADER len=%d state=%d", len, state->cs);
}
}
#/* Parse http content/body. */

View File

@ -65,7 +65,7 @@ int thttp_challenge_reset_cnonce(thttp_challenge_t *self)
return -1;
}
int thttp_challenge_get_response(thttp_challenge_t *self, const char* method, const char* uristring, const tsk_buffer_t* entity_body, tsk_md5string_t* response)
int thttp_challenge_get_response(thttp_challenge_t *self, const char* username, const char* password, const char* method, const char* uristring, const tsk_buffer_t* entity_body, tsk_md5string_t* response)
{
if(THTTP_CHALLENGE_IS_DIGEST(self))
{
@ -75,7 +75,7 @@ int thttp_challenge_get_response(thttp_challenge_t *self, const char* method, co
/* ===
Calculate HA1 = MD5(A1) = M5(username:realm:secret)
*/
thttp_auth_digest_HA1(self->username, self->realm, self->password, &ha1);
thttp_auth_digest_HA1(username, self->realm, password, &ha1);
/* ===
HA2
@ -131,7 +131,7 @@ int thttp_challenge_update(thttp_challenge_t *self, const char* scheme, const ch
return -1;
}
thttp_header_t *thttp_challenge_create_header_authorization(thttp_challenge_t *self, const thttp_request_t *request)
thttp_header_t *thttp_challenge_create_header_authorization(thttp_challenge_t *self, const char* username, const char* password, const thttp_request_t *request)
{
tsk_md5string_t response;
nonce_count_t nc;
@ -154,14 +154,14 @@ thttp_header_t *thttp_challenge_create_header_authorization(thttp_challenge_t *s
}
// FIXME: entity_body ==> request-content
if(thttp_challenge_get_response(self, request->method, uristring, 0/*FIXME*/, &response))
if(thttp_challenge_get_response(self, username, password, request->method, uristring, request->Content, &response))
{
goto bail;
}
#define THTTP_AUTH_COPY_VALUES(hdr) \
hdr->username = tsk_strdup(self->username); \
hdr->username = tsk_strdup(username); \
hdr->scheme = tsk_strdup(self->scheme); \
hdr->realm = tsk_strdup(self->realm); \
hdr->nonce = tsk_strdup(self->nonce); \
@ -230,8 +230,6 @@ static void* thttp_challenge_create(void *self, va_list * app)
{
const char* qop;
challenge->username = tsk_strdup(va_arg(*app, const char*));
challenge->password = tsk_strdup(va_arg(*app, const char*));
challenge->isproxy = va_arg(*app, unsigned);
challenge->scheme = tsk_strdup(va_arg(*app, const char*));
challenge->realm = tsk_strdup(va_arg(*app, const char*));
@ -260,8 +258,6 @@ static void* thttp_challenge_destroy(void *self)
thttp_challenge_t *challenge = self;
if(challenge)
{
TSK_FREE(challenge->username);
TSK_FREE(challenge->password);
TSK_FREE(challenge->scheme);
TSK_FREE(challenge->realm);
TSK_FREE(challenge->nonce);

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,7 @@ static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *
* Ragel state machine.
*/
/* #line 183 "thttp_parser_message.rl" */
/* #line 176 "thttp_parser_message.rl" */
@ -54,8 +54,8 @@ static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *
/* #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
3, 1, 4, 1, 5, 1, 6, 1,
7, 2, 0, 5, 2, 6, 0
};
static const unsigned char _thttp_machine_parser_message_key_offsets[] = {
@ -152,7 +152,7 @@ static const char _thttp_machine_parser_message_indicies[] = {
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
57, 1, 49, 49, 49, 1, 58, 0
};
static const char _thttp_machine_parser_message_trans_targs[] = {
@ -163,18 +163,18 @@ static const char _thttp_machine_parser_message_trans_targs[] = {
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
42, 43, 44
};
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, 20, 13, 15, 0, 0, 0,
0, 0, 0, 0, 7, 1, 0, 0,
9, 1, 1, 1, 1, 1, 1, 15,
9, 1, 1, 1, 1, 1, 1, 17,
1, 0, 0, 0, 0, 0, 0, 11,
0, 0
0, 0, 0
};
static const int thttp_machine_parser_message_start = 1;
@ -184,7 +184,7 @@ 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" */
/* #line 181 "thttp_parser_message.rl" */
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @fn int thttp_message_parse(tsk_ragel_state_t *state, thttp_message_t *result)
@ -224,7 +224,7 @@ int thttp_message_parse(tsk_ragel_state_t *state, thttp_message_t **result, int
if( state->cs <
/* #line 226 "../src/parsers/thttp_parser_message.c" */
44
/* #line 224 "thttp_parser_message.rl" */
/* #line 217 "thttp_parser_message.rl" */
)
{
TSK_OBJECT_SAFE_FREE(*result);
@ -245,7 +245,7 @@ static void thttp_message_parser_init(tsk_ragel_state_t *state)
cs = thttp_machine_parser_message_start;
}
/* #line 239 "thttp_parser_message.rl" */
/* #line 232 "thttp_parser_message.rl" */
state->cs = cs;
}
@ -367,76 +367,85 @@ _match:
state->tag_end = p;
len = (int)(state->tag_end - state->tag_start);
if(!message->url)
{
if(!message->url){
message->url = thttp_url_parse(state->tag_start, (size_t)len);
}
}
break;
case 3:
/* #line 91 "thttp_parser_message.rl" */
/* #line 90 "thttp_parser_message.rl" */
{
int len;
state->tag_end = p;
len = (int)(state->tag_end - state->tag_start);
if(!message->http_version)
{
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" */
/* #line 103 "thttp_parser_message.rl" */
{
int len;
state->tag_end = p;
len = (int)(state->tag_end - state->tag_start);
if(message->type == thttp_unknown)
{
if(message->type == thttp_unknown){
message->type = thttp_response;
message->status_code = atoi(state->tag_start);
}
else
{
else{
state->cs = thttp_machine_parser_message_error;
}
}
break;
case 5:
/* #line 123 "thttp_parser_message.rl" */
/* #line 119 "thttp_parser_message.rl" */
{
int len;
state->tag_end = p;
len = (int)(state->tag_end - state->tag_start);
if(!message->reason_phrase)
{
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" */
/* #line 132 "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
{
if(thttp_header_parse(state, message)){
TSK_DEBUG_ERROR("Failed to parse header - %s", state->tag_start);
}
else{
//TSK_DEBUG_INFO("THTTP_MESSAGE_PARSER::PARSE_HEADER len=%d state=%d", len, state->cs);
}
}
break;
/* #line 440 "../src/parsers/thttp_parser_message.c" */
case 7:
/* #line 156 "thttp_parser_message.rl" */
{
state->cs = cs;
state->p = p;
state->pe = pe;
state->eof = eof;
thttp_message_parser_eoh(state, message, extract_content);
cs = state->cs;
p = state->p;
pe = state->pe;
eof = state->eof;
}
break;
/* #line 449 "../src/parsers/thttp_parser_message.c" */
}
}
@ -449,7 +458,7 @@ _again:
_out: {}
}
/* #line 251 "thttp_parser_message.rl" */
/* #line 244 "thttp_parser_message.rl" */
state->cs = cs;
state->p = p;

View File

@ -29,6 +29,7 @@
#include "thttp.h"
#include "tinyHTTP/thttp_event.h"
#include "tinyHTTP/thttp_message.h"
#include "tinyHTTP/parsers/thttp_parser_message.h"
#include "tnet.h"
#include "tnet_transport.h"
@ -38,7 +39,6 @@
#include "tsk_debug.h"
#include "tsk_memory.h"
#include "tsk_string.h"
#include "tsk_fsm.h"
//#include <stdarg.h>
//#include <string.h>
@ -61,7 +61,6 @@ typedef struct thttp_stack_s
TSK_DECLARE_OBJECT;
thttp_stack_callback callback;
tsk_fsm_t *fsm;
/* Identity */
char* username;
@ -82,77 +81,97 @@ typedef struct thttp_stack_s
}
thttp_stack_t;
thttp_operation_handle_t* thttp_stack_get_op(thttp_stack_handle_t *self, tnet_fd_t fd);
/* ======================== internal functions ======================== */
const thttp_operation_handle_t* thttp_stack_get_op(const thttp_stack_handle_t *self, tnet_fd_t fd);
int thttp_stack_alert(const thttp_stack_handle_t *self, const thttp_event_t* e);
/* ======================== external functions ======================== */
extern int thttp_operation_SignalMessage(const thttp_operation_handle_t *self, const thttp_message_t* message);
static int thttp_transport_layer_stream_cb(const tnet_transport_event_t* e)
{
int ret = -1;
// tsk_ragel_state_t state;
// thttp_message_t *message = THTTP_NULL;
// int endOfheaders = -1;
// const thttp_t *stack = e->callback_data;
//
// switch(e->type){
// case event_data: {
// break;
// }
// case event_closed:
// case event_connected:
// default:{
// return 0;
// }
// }
//
//
// /* Check if buffer is too big to be valid (have we missed some chuncks?) */
// if(TSK_BUFFER_SIZE(transport->buff_stream) >= 0xFFFF){
// tsk_buffer_cleanup(transport->buff_stream);
// }
//
// /* Append new content. */
// tsk_buffer_append(transport->buff_stream, e->data, e->size);
//
// /* Check if we have all HTTP headers. */
// if((endOfheaders = tsk_strindexOf(TSK_BUFFER_DATA(transport->buff_stream),TSK_BUFFER_SIZE(transport->buff_stream), "\r\n\r\n"/*2CRLF*/)) < 0){
// TSK_DEBUG_INFO("No all HTTP headers in the TCP buffer.");
// goto bail;
// }
//
// /* If we are there this mean that we have all HTTP headers.
// * ==> Parse the HTTP message without the content.
// */
// tsk_ragel_state_init(&state, TSK_BUFFER_DATA(transport->buff_stream), endOfheaders + 4/*2CRLF*/);
// if(thttp_message_parse(&state, &message, THTTP_FALSE/* do not extract the content */) == THTTP_TRUE
// && message->firstVia && message->Call_ID && message->CSeq && message->From && message->To)
// {
// size_t clen = THTTP_MESSAGE_CONTENT_LENGTH(message); /* MUST have content-length header (see RFC 3261 - 7.5). If no CL header then the macro return zero. */
// if(clen == 0){ /* No content */
// tsk_buffer_remove(transport->buff_stream, 0, (endOfheaders + 4/*2CRLF*/)); /* Remove HTTP headers and CRLF */
// }
// else{ /* There is a content */
// if((endOfheaders + 4/*2CRLF*/ + clen) > TSK_BUFFER_SIZE(transport->buff_stream)){ /* There is content but not all the content. */
// TSK_DEBUG_INFO("No all HTTP content in the TCP buffer.");
// goto bail;
// }
// else{
// /* Add the content to the message. */
// thttp_message_add_content(message, THTTP_NULL, TSK_BUFFER_TO_U8(transport->buff_stream) + endOfheaders + 4/*2CRLF*/, clen);
// /* Remove HTTP headers, CRLF and the content. */
// tsk_buffer_remove(transport->buff_stream, 0, (endOfheaders + 4/*2CRLF*/ + clen));
// }
// }
// }
//
// if(message){
// /* Handle the incoming message. */
// ret = thttp_transport_layer_handle_incoming_msg(transport, message);
// /* Set fd */
// message->sockfd = e->fd;
// }
// else ret = -15;
//
//bail:
// TSK_OBJECT_SAFE_FREE(message);
tsk_ragel_state_t state;
thttp_message_t *message = THTTP_NULL;
int endOfheaders = -1;
const thttp_stack_t *stack = e->callback_data;
const thttp_operation_handle_t* operation = 0;
tsk_buffer_t* buf = 0;
switch(e->type){
case event_data: {
break;
}
case event_closed:
case event_connected:
default:{
return 0;
}
}
/* Gets the associated operation */
if(!(operation = thttp_stack_get_op(stack, e->fd))){
TSK_DEBUG_ERROR("Failed to found associated operation.");
ret = -1;
goto bail;
}
else{
if((buf = thttp_operation_get_buf(operation))){
buf = tsk_object_ref(buf); // thread-safeness
}
else{
TSK_DEBUG_ERROR("The current opeartion do not hold a valid buffer.");
ret = -3;
goto bail;
}
}
/* Check if buffer is too big to be valid (have we missed some chuncks?) */
if(TSK_BUFFER_SIZE(buf) >= THTTP_MAX_CONTENT_SIZE){
tsk_buffer_cleanup(buf);
}
/* Append new content. */
tsk_buffer_append(buf, e->data, e->size);
/* Check if we have all HTTP headers. */
if((endOfheaders = tsk_strindexOf(TSK_BUFFER_DATA(buf),TSK_BUFFER_SIZE(buf), "\r\n\r\n"/*2CRLF*/)) < 0){
TSK_DEBUG_INFO("No all HTTP headers in the TCP buffer.");
goto bail;
}
/* If we are here this mean that we have all HTTP headers.
* ==> Parse the HTTP message without the content.
*/
tsk_ragel_state_init(&state, TSK_BUFFER_DATA(buf), endOfheaders + 4/*2CRLF*/);
if(!(ret = thttp_message_parse(&state, &message, 0/* do not extract the content */)))
{
size_t clen = THTTP_MESSAGE_CONTENT_LENGTH(message); /* MUST have content-length header (see RFC 3261 - 7.5). If no CL header then the macro return zero. */
if(clen == 0){ /* No content */
tsk_buffer_remove(buf, 0, (endOfheaders + 4/*2CRLF*/)); /* Remove HTTP headers and CRLF */
}
else{ /* There is a content */
if((endOfheaders + 4/*2CRLF*/ + clen) > TSK_BUFFER_SIZE(buf)){ /* There is content but not all the content. */
TSK_DEBUG_INFO("No all HTTP content in the TCP buffer.");
goto bail;
}
else{
/* Add the content to the message. */
thttp_message_add_content(message, THTTP_NULL, TSK_BUFFER_TO_U8(buf) + endOfheaders + 4/*2CRLF*/, clen);
/* Remove HTTP headers, CRLF and the content. */
tsk_buffer_remove(buf, 0, (endOfheaders + 4/*2CRLF*/ + clen));
}
}
}
/* Alert the operation (FSM) */
if(message){
thttp_operation_SignalMessage(operation, message);
}
bail:
TSK_OBJECT_SAFE_FREE(buf);
TSK_OBJECT_SAFE_FREE(message);
return ret;
}
@ -361,11 +380,11 @@ bail:
return ret;
}
thttp_operation_handle_t* thttp_stack_get_op(thttp_stack_handle_t *self, tnet_fd_t fd)
const thttp_operation_handle_t* thttp_stack_get_op(const thttp_stack_handle_t *self, tnet_fd_t fd)
{
thttp_operation_handle_t* ret = 0;
thttp_stack_t *stack = self;
tsk_list_item_t *item;
const thttp_operation_handle_t* ret = 0;
const thttp_stack_t *stack = self;
const tsk_list_item_t *item;
if(!stack || !stack->ops){
return 0;
@ -383,10 +402,10 @@ thttp_operation_handle_t* thttp_stack_get_op(thttp_stack_handle_t *self, tnet_fd
tsk_safeobj_unlock(stack);
return 0;
return ret;
}
int thttp_stack_add_op(thttp_stack_handle_t *self, thttp_operation_handle_t* op)
int thttp_stack_push_op(thttp_stack_handle_t *self, thttp_operation_handle_t* op)
{
thttp_stack_t *stack = self;
@ -395,18 +414,16 @@ int thttp_stack_add_op(thttp_stack_handle_t *self, thttp_operation_handle_t* op)
}
tsk_safeobj_lock(stack);
/* ref() called by the operation's ctor,
unref will be called when removed from the list. */
tsk_list_push_back_data(stack->ops, &op);
tsk_safeobj_unlock(stack);
return 0;
}
int thttp_stack_remove_op(thttp_stack_handle_t *self, thttp_operation_handle_t* op)
int thttp_stack_pop_op(thttp_stack_handle_t *self, thttp_operation_handle_t* op)
{
thttp_stack_t *stack = self;
if(!stack || !stack->ops || !op){
return -1;
}
@ -414,11 +431,27 @@ int thttp_stack_remove_op(thttp_stack_handle_t *self, thttp_operation_handle_t*
tsk_safeobj_lock(stack);
tsk_list_remove_item_by_data(stack->ops, op);
tsk_safeobj_unlock(stack);
return 0;
}
int thttp_stack_alert(const thttp_stack_handle_t *self, const thttp_event_t* e)
{
const thttp_stack_t *stack = self;
if(!stack || !e){
return -1;
}
if(stack->callback){
return stack->callback(e);
}
else{
return 0;
}
}
@ -452,7 +485,7 @@ static void* _thttp_stack_create(void * self, va_list * app)
if(stack){
tsk_safeobj_init(stack);
stack->ops = TSK_LIST_CREATE_AS_NOT_OWNER();
stack->ops = TSK_LIST_CREATE();
}
return self;
}
@ -461,8 +494,6 @@ static void* thttp_stack_destroy(void * self)
{
thttp_stack_t *stack = self;
if(stack){
TSK_OBJECT_SAFE_FREE(stack->fsm);
/* Identity */
TSK_FREE(stack->username);
TSK_FREE(stack->password);

View File

@ -1,29 +0,0 @@
/*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
/**@file thttp.c
* @brief HTTP (RFC 2616) and HTTP basic/digest authetication (RFC 2617) implementations.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "thttp.h"

View File

@ -49,13 +49,10 @@ static void* thttp_event_create(void * self, va_list * app)
{
thttp_event_t *httpevent = self;
if(httpevent)
{
#if defined(__GNUC__)
httpevent->code = (short)va_arg(*app, int);
#else
httpevent->code = va_arg(*app, short);
#endif
httpevent->phrase = tsk_strdup( va_arg(*app, const char *) );
{
httpevent->type = va_arg(*app, thttp_event_type_t);
httpevent->opid = va_arg(*app, thttp_operation_id_t);
httpevent->description = tsk_strdup( va_arg(*app, const char *) );
httpevent->message = tsk_object_ref((void*)va_arg(*app, thttp_message_t *));
}
return self;
@ -66,7 +63,7 @@ static void* thttp_event_destroy(void * self)
thttp_event_t *httpevent = self;
if(httpevent)
{
TSK_FREE(httpevent->phrase);
TSK_FREE(httpevent->description);
TSK_OBJECT_SAFE_FREE(httpevent->message);
}
return self;

View File

@ -34,26 +34,76 @@
#include "tinyHTTP/parsers/thttp_parser_url.h"
#include "tinyHTTP/headers/thttp_header_Dummy.h"
#include "tinyHTTP/headers/thttp_header_WWW_Authenticate.h"
#include "tinyHTTP/auth/thttp_challenge.h"
#include "tnet_utils.h"
#include "tsk_debug.h"
#define DEBUG_STATE_MACHINE 1
#define THTTP_MESSAGE_DESCRIPTION(message) \
THTTP_MESSAGE_IS_RESPONSE(message) ? THTTP_RESPONSE_PHRASE(message) : THTTP_REQUEST_METHOD(message)
typedef struct thttp_operation_s
{
TSK_DECLARE_OBJECT;
thttp_operation_id_t id;
thttp_stack_handle_t* stack;
tsk_fsm_t *fsm;
const thttp_stack_handle_t* stack;
tsk_params_L_t *params;
tsk_params_L_t *headers;
tnet_fd_t fd;
tsk_buffer_t* buf;
thttp_challenges_L_t *challenges;
}
thttp_operation_t;
/* ======================== internal functions ======================== */
int thttp_operation_OnTerminated(thttp_operation_t *self);
int thttp_operation_SignalMessage(const thttp_operation_handle_t *self, const thttp_message_t* message);
int thttp_operation_update_challenges(thttp_operation_t *self, const thttp_response_t* response);
/* ======================== external functions ======================== */
extern int thttp_stack_alert(const thttp_stack_handle_t *self, const thttp_event_t* e);
/* ======================== transitions ======================== */
int thttp_operation_Started_2_Transfering_X_perform(va_list *app);
int thttp_operation_Transfering_2_Transfering_X_401_407(va_list *app);
int thttp_operation_Transfering_2_Transfering_X_message(va_list *app); /* Any other HTTP message except 401/407 */
int thttp_operation_Any_2_Terminated_X_closed(va_list *app);
int thttp_operation_Any_2_Terminated_X_Error(va_list *app);
/* ======================== conds ======================== */
/* ======================== actions ======================== */
typedef enum _fsm_action_e
{
_fsm_action_perform,
_fsm_action_401_407,
_fsm_action_message,
_fsm_action_closed,
_fsm_action_transporterror,
_fsm_action_error,
}
_fsm_action_t;
/* ======================== states ======================== */
typedef enum _fsm_state_e
{
_fsm_state_Started,
_fsm_state_Transfering,
_fsm_state_Terminated
}
_fsm_state_t;
int __thttp_operation_set(thttp_operation_t *self, va_list values)
{
@ -165,6 +215,14 @@ tnet_fd_t thttp_operation_get_fd(const thttp_operation_handle_t *self)
return TNET_INVALID_FD;
}
tsk_buffer_t* thttp_operation_get_buf(const thttp_operation_handle_t *self)
{
if(self){
return ((const thttp_operation_t *)self)->buf;
}
return 0;
}
int thttp_operation_set_fd(thttp_operation_handle_t *self, tnet_fd_t fd)
{
thttp_operation_t* op;
@ -221,9 +279,25 @@ int thttp_operation_perform(thttp_operation_handle_t* self)
}
}
/* Sends the message. */
ret = thttp_stack_send((thttp_stack_handle_t*)op->stack, op, message);
/* Add creadentials */
if(THTTP_MESSAGE_IS_REQUEST(message) && !TSK_LIST_IS_EMPTY(op->challenges))
{
thttp_challenge_t *challenge;
thttp_header_t* auth_hdr;
tsk_list_foreach(item, op->challenges)
{
challenge = item->data;
auth_hdr = thttp_challenge_create_header_authorization(challenge, "username", "password", message);
if(auth_hdr){
thttp_message_add_header(message, auth_hdr);
tsk_object_unref(auth_hdr), auth_hdr = 0;
}
}
}
/* Sends the message. */
ret = tsk_fsm_act(op->fsm, _fsm_action_perform, op, message, op, message);
bail:
TSK_OBJECT_SAFE_FREE(message);
return ret;
@ -233,6 +307,231 @@ bail:
//--------------------------------------------------------
// == STATE MACHINE BEGIN ==
//--------------------------------------------------------
int thttp_operation_Started_2_Transfering_X_perform(va_list *app)
{
thttp_operation_t *self = va_arg(*app, thttp_operation_t*);
const thttp_message_t *message = va_arg(*app, const thttp_message_t *);
return thttp_stack_send((thttp_stack_handle_t*)self->stack, self, message);
}
int thttp_operation_Transfering_2_Transfering_X_401_407(va_list *app)
{
int ret;
thttp_operation_t *self = va_arg(*app, thttp_operation_t*);
const thttp_response_t *response = va_arg(*app, const thttp_response_t *);
if((ret = thttp_operation_update_challenges(self, response))){
// Alert the user.
return ret;
}
/* Retry with creadentials. */
return thttp_operation_perform(self);
}
int thttp_operation_Transfering_2_Transfering_X_message(va_list *app)
{
thttp_operation_t *self = va_arg(*app, thttp_operation_t*);
const thttp_message_t *message = va_arg(*app, const thttp_message_t *);
thttp_event_t* e = 0;
/* Alert the user. */
e = THTTP_EVENT_CREATE(thttp_event_message, self->id, THTTP_MESSAGE_DESCRIPTION(message), message);
thttp_stack_alert(self->stack, e);
TSK_OBJECT_SAFE_FREE(e);
return 0;
}
int thttp_operation_Any_2_Terminated_X_closed(va_list *app)
{
return 0;
}
int thttp_operation_Any_2_Terminated_X_Error(va_list *app)
{
return 0;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// == STATE MACHINE END ==
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int thttp_operation_OnTerminated(thttp_operation_t *self)
{
TSK_DEBUG_INFO("=== OPERATION terminated ===");
return 0;
}
int thttp_operation_SignalMessage(const thttp_operation_handle_t *self, const thttp_message_t* message)
{
const thttp_operation_t* operation = self;
int ret = -1;
if(!operation || !message){
goto bail;
}
if(THTTP_RESPONSE_IS(message, 401) || THTTP_RESPONSE_IS(message, 407)){
ret = tsk_fsm_act(operation->fsm, _fsm_action_401_407, operation, message, operation, message);
}
else{
ret = tsk_fsm_act(operation->fsm, _fsm_action_message, operation, message, operation, message);
}
bail:
return ret;
}
int thttp_operation_update_challenges(thttp_operation_t *self, const thttp_response_t* response)
{
int ret = -1;
size_t i;
tsk_list_item_t *item;
thttp_challenge_t *challenge;
const thttp_header_WWW_Authenticate_t *WWW_Authenticate;
const thttp_header_Proxy_Authenticate_t *Proxy_Authenticate;
/* RFC 2617 - Digest Operation
* (A) The client response to a WWW-Authenticate challenge for a protection
space starts an authentication session with that protection space.
The authentication session lasts until the client receives another
WWW-Authenticate challenge from any server in the protection space.
(B) The server may return a 401 response with a new nonce value, causing the client
to retry the request; by specifying stale=TRUE with this response,
the server tells the client to retry with the new nonce, but without
prompting for a new username and password.
*/
/* FIXME: As we perform the same task ==> Use only one loop.
*/
for(i =0; (WWW_Authenticate = (const thttp_header_WWW_Authenticate_t*)thttp_message_get_headerAt(response, thttp_htype_WWW_Authenticate, i)); i++)
{
int isnew = 1;
tsk_list_foreach(item, self->challenges)
{
challenge = item->data;
if(challenge->isproxy) continue;
if(tsk_strequals(challenge->realm, WWW_Authenticate->realm) && (WWW_Authenticate->stale /*|| acceptNewVector*/))
{
/*== (B) ==*/
if((ret = thttp_challenge_update(challenge,
WWW_Authenticate->scheme,
WWW_Authenticate->realm,
WWW_Authenticate->nonce,
WWW_Authenticate->opaque,
WWW_Authenticate->algorithm,
WWW_Authenticate->qop)))
{
return ret;
}
else
{
isnew = 0;
continue;
}
}
else return -1;
}
if(isnew)
{
if((challenge = THTTP_CHALLENGE_CREATE(0, /* Not proxy */
WWW_Authenticate->scheme,
WWW_Authenticate->realm,
WWW_Authenticate->nonce,
WWW_Authenticate->opaque,
WWW_Authenticate->algorithm,
WWW_Authenticate->qop)))
{
tsk_list_push_back_data(self->challenges, (void**)&challenge);
}
else return -1;
}
}
for(i=0; (Proxy_Authenticate = (const thttp_header_Proxy_Authenticate_t*)thttp_message_get_headerAt(response, thttp_htype_Proxy_Authenticate, i)); i++)
{
int isnew = 1;
tsk_list_foreach(item, self->challenges)
{
challenge = item->data;
if(!challenge->isproxy) continue;
if(tsk_strequals(challenge->realm, Proxy_Authenticate->realm) && (Proxy_Authenticate->stale /*|| acceptNewVector*/))
{
/*== (B) ==*/
if((ret = thttp_challenge_update(challenge,
Proxy_Authenticate->scheme,
Proxy_Authenticate->realm,
Proxy_Authenticate->nonce,
Proxy_Authenticate->opaque,
Proxy_Authenticate->algorithm,
Proxy_Authenticate->qop)))
{
return ret;
}
else
{
isnew = 0;
continue;
}
}
else return -1;
}
if(isnew)
{
if((challenge = THTTP_CHALLENGE_CREATE(1, /* Proxy */
Proxy_Authenticate->scheme,
Proxy_Authenticate->realm,
Proxy_Authenticate->nonce,
Proxy_Authenticate->opaque,
Proxy_Authenticate->algorithm,
Proxy_Authenticate->qop)))
{
tsk_list_push_back_data(self->challenges, (void**)&challenge);
}
else return -1;
}
}
return 0;
}
//========================================================
// HTTP Operation object definition
//
@ -242,11 +541,13 @@ static void* thttp_operation_create(void * self, va_list * app)
static thttp_operation_id_t unique_id = 0;
if(operation)
{
operation->stack = tsk_object_ref( va_arg(*app, thttp_stack_handle_t*) );
operation->stack = va_arg(*app, const thttp_stack_handle_t*);
operation->params = TSK_LIST_CREATE();
operation->headers = TSK_LIST_CREATE();
operation->fd = TNET_INVALID_FD;
operation->buf = TSK_BUFFER_CREATE_NULL();
operation->challenges = TSK_LIST_CREATE();
operation->fsm = TSK_FSM_CREATE(_fsm_state_Started, _fsm_state_Terminated);
if(__thttp_operation_set(self, *app)){
operation->id = THTTP_OPERATION_INVALID_ID;
@ -255,8 +556,51 @@ static void* thttp_operation_create(void * self, va_list * app)
operation->id = ++unique_id;
}
/* Add the operation to the stack. The stack will not own the op. */
thttp_stack_add_op(operation->stack, operation);
/* init FSM */
operation->fsm->debug = DEBUG_STATE_MACHINE;
tsk_fsm_set_callback_terminated(operation->fsm, TSK_FSM_ONTERMINATED(thttp_operation_OnTerminated), operation);
tsk_fsm_set(operation->fsm,
/*=======================
* === Started ===
*/
// Started -> (Send) -> Trying
TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_perform, _fsm_state_Transfering, thttp_operation_Started_2_Transfering_X_perform, "thttp_operation_Started_2_Transfering_X_perform"),
// Started -> (Any) -> Started
TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Started, "thttp_operation_Started_2_Started_X_any"),
/*=======================
* === Transfering ===
*/
// Transfering -> (401/407) -> Transfering
TSK_FSM_ADD_ALWAYS(_fsm_state_Transfering, _fsm_action_401_407, _fsm_state_Transfering, thttp_operation_Transfering_2_Transfering_X_401_407, "thttp_operation_Transfering_2_Transfering_X_401_407"),
// Transfering -> (message) -> Transfering
TSK_FSM_ADD_ALWAYS(_fsm_state_Transfering, _fsm_action_message, _fsm_state_Transfering, thttp_operation_Transfering_2_Transfering_X_message, "thttp_operation_Transfering_2_Transfering_X_message"),
//// Trying -> (401/407) -> Trying
//TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_401_407, _fsm_state_Trying, thttp_operation_Trying_2_Trying_X_401_407, "thttp_operation_Trying_2_Trying_X_401_407"),
//// Trying -> (300_to_699) -> Terminated
//TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_300_to_699, _fsm_state_Terminated, thttp_operation_Trying_2_Terminated_X_300_to_699, "thttp_operation_Trying_2_Terminated_X_300_to_699"),
//// Trying -> (cancel) -> Terminated
//TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_cancel, _fsm_state_Terminated, thttp_operation_Trying_2_Terminated_X_cancel, "thttp_operation_Trying_2_Terminated_X_cancel"),
//// Trying -> (closed) -> Terminated
//TSK_FSM_ADD_ALWAYS(_fsm_state_Trying, _fsm_action_closed, _fsm_state_Terminated, thttp_operation_Trying_2_Terminated_X_closed, "thttp_operation_Trying_2_Terminated_X_closed"),
// Trying -> (Any) -> Trying
TSK_FSM_ADD_ALWAYS_NOTHING(_fsm_state_Transfering, "thttp_operation_Trying_2_Trying_X_any"),
/*=======================
* === Any ===
*/
// Any -> (closed) -> Terminated
TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_closed, _fsm_state_Terminated, thttp_operation_Any_2_Terminated_X_closed, "thttp_operation_Any_2_Terminated_X_closed"),
// Any -> (error) -> Terminated
TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_error, _fsm_state_Terminated, thttp_operation_Any_2_Terminated_X_Error, "thttp_operation_Any_2_Terminated_X_Error"),
TSK_FSM_ADD_NULL());
/* add to the stack */
thttp_stack_push_op((thttp_stack_handle_t*)operation->stack, operation);
}
return self;
@ -266,14 +610,15 @@ static void* thttp_operation_destroy(void * self)
{
thttp_operation_t *operation = self;
if(operation){
/* Remove the operation from the stack. The stack do not own the op. */
thttp_stack_remove_op(operation->stack, operation);
TSK_OBJECT_SAFE_FREE(operation->stack);
/* Remove from the stack */
thttp_stack_pop_op((thttp_stack_handle_t*)operation->stack, operation);
TSK_OBJECT_SAFE_FREE(operation->params);
TSK_OBJECT_SAFE_FREE(operation->headers);
TSK_OBJECT_SAFE_FREE(operation->buf);
TSK_OBJECT_SAFE_FREE(operation->challenges);
TSK_OBJECT_SAFE_FREE(operation->fsm);
tnet_sockfd_close(&operation->fd);
}

View File

@ -28,6 +28,7 @@
#include "thttp.h"
#include "tinyHTTP/thttp_operation.h"
#include "tinyHTTP/thttp_message.h"
#include "tinyHTTP/auth/thttp_auth.h"
#define LOOP 1
@ -36,10 +37,12 @@
#define RUN_TEST_AUTH 0
#define RUN_TEST_STACK 1
#define RUN_TEST_URL 0
#define RUN_TEST_MSGS 0
#include "test_auth.h"
#include "test_stack.h"
#include "test_url.h"
#include "test_messages.h"
#ifdef _WIN32_WCE
@ -69,6 +72,11 @@ int main()
#if RUN_TEST_URL || RUN_TEST_ALL
test_url();
#endif
#if RUN_TEST_MSGS || RUN_TEST_ALL
test_messages();
#endif
}
thttp_global_deinit();

View File

@ -0,0 +1,78 @@
/*
* 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.
*
*/
#ifndef _TEST_MESSAGES_H_
#define _TEST_MESSAGES_H_
#include "tinyHTTP/parsers/thttp_parser_message.h"
#define TEST_MSG_200 \
"HTTP/1.1 200 OK\r\n" \
"Date: Wed, 10 Mar 2010 13:37:13 GMT\r\n" \
"Server: Apache\r\n" \
"Content-length: 3\r\n" \
"Expires: Sat, 07 Aug 2010 13:37:13 +0000\r\n" \
"Cache-Control: public\r\n" \
"X-Deezer-Cache: HIT\r\n" \
"Pragma: \r\n" \
"Keep-Alive: timeout=2, max=100\r\n" \
"Connection: Keep-Alive\r\n" \
"Content-Type: video/flv\r\n" \
"\r\n" \
"123"
#define TEST_MSG_401 \
"HTTP/1.1 401 Unauthorized\r\n" \
"Server: Apache-Coyote/1.1\r\n" \
"WWW-Authenticate: Digest realm=\"example.com\", qop=\"auth\", nonce=\"f39d20a4dbfbd32d943de9b285d59a30\", opaque=\"c5ad02feb52eb050e464cec3740c0f2e\"\r\n" \
"Content-Length: 0\r\n" \
"Date: Wed, 10 Mar 2010 14:20:47 GMT\r\n" \
"\r\n"
#define TEST_MSG TEST_MSG_401
void test_messages()
{
thttp_message_t *message = 0;
tsk_ragel_state_t state;
int ret;
/* deserialize the message */
tsk_ragel_state_init(&state, TEST_MSG, strlen(TEST_MSG));
if(!(ret = thttp_message_parse(&state, &message, 1))){
tsk_buffer_t *buffer = TSK_BUFFER_CREATE_NULL();
/* serialize the message */
thttp_message_tostring(message, buffer);
TSK_DEBUG_INFO("Response=\n%s", TSK_BUFFER_TO_STRING(buffer));
TSK_OBJECT_SAFE_FREE(buffer);
}
else{
TSK_DEBUG_ERROR("Failed to parse HTTP message.");
}
TSK_OBJECT_SAFE_FREE(message);
}
#endif /* _TEST_MESSAGES_H_ */

View File

@ -24,6 +24,30 @@
int test_stack_callback(const thttp_event_t *httpevent)
{
switch(httpevent->type){
case thttp_event_message: /* New HTTP message */
{
TSK_DEBUG_INFO("opid=%llu", httpevent->opid);
if(THTTP_RESPONSE_IS_2XX(httpevent->message)){
TSK_DEBUG_INFO("=== 2xx ==> %s", THTTP_MESSAGE_CONTENT(httpevent->message));
// You can use
}
else{
if(THTTP_MESSAGE_IS_RESPONSE(httpevent->message)){
TSK_DEBUG_INFO("=== code ==> %u", THTTP_RESPONSE_CODE(httpevent->message));
}
}
break;
}
case thttp_event_closed: /* HTTP connection closed */
{
TSK_DEBUG_INFO("opid=%llu", httpevent->opid);
// Delete the associated operation if you want
// perform(op) on a closed operation will open a new TCP/TLS connection.
}
}
return 0;
}
@ -33,10 +57,10 @@ void test_stack()
thttp_stack_handle_t* stack = thttp_stack_create(test_stack_callback,
THTTP_STACK_SET_NULL());
//if(thttp_stack_start(stack)){
// goto bail;
//}
/*
if(thttp_stack_start(stack)){
goto bail;
}
op = THTTP_OPERATION_CREATE(stack,
THTTP_OPERATION_SET_PARAM("method", "GET"),
THTTP_OPERATION_SET_PARAM("URL", "http://siptest.colibria.com:8080/services/resource-lists/users/sip:mercuro1@colibria.com/index"),
@ -49,7 +73,8 @@ void test_stack()
THTTP_OPERATION_SET_NULL());
thttp_operation_perform(op);
*/
/*
op = THTTP_OPERATION_CREATE(stack,
THTTP_OPERATION_SET_PARAM("method", "GET"),
//THTTP_OPERATION_SET_PARAM("URL", "https://msp.f-secure.com/web-test/common/test.html"),
@ -60,8 +85,8 @@ void test_stack()
THTTP_OPERATION_SET_HEADER("User-Agent", "XDM-client/OMA1.1"),
THTTP_OPERATION_SET_NULL());
//thttp_operation_perform(op);
thttp_operation_perform(op);
*/
/*thttp_operation_set(op,
THTTP_OPERATION_SET_PARAM("method", "HEAD"),

View File

@ -567,13 +567,12 @@ void *tnet_transport_mainthread(void *param)
if(ret == WSAEWOULDBLOCK){
TSK_DEBUG_WARN("WSAEWOULDBLOCK error for READ operation");
}
else if(ret == WSAECONNRESET && TNET_SOCKET_TYPE_IS_DGRAM(transport->master->type))
{ /* For DGRAM ==> The sent packet gernerated "ICMP Destination/Port unreachable" result. */
else if(ret == WSAECONNRESET && TNET_SOCKET_TYPE_IS_DGRAM(transport->master->type)){
/* For DGRAM ==> The sent packet gernerated "ICMP Destination/Port unreachable" result. */
TSK_FREE(wsaBuffer.buf);
continue; // ignore and retry.
}
else
{
else{
TSK_FREE(wsaBuffer.buf);
removeSocket(index, context);

View File

@ -58,51 +58,45 @@ void tsk_list_remove_item(tsk_list_t* list, tsk_list_item_t* item)
}
/**@ingroup tsk_list_group
* Remove an object from the @a list.
* @param list The list from which to remove the object.
* Pops an object from the @a list.
* @param list The list from which to pop the object.
* @param tskobj Any valid object(declared using @ref TSK_DECLARE_OBJECT) to remove.
* @retval The item.
*/
void tsk_list_remove_item_by_data(tsk_list_t* list, const void * tskobj)
tsk_list_item_t* tsk_list_pop_item_by_data(tsk_list_t* list, const void * tskobj)
{
if(list)
{
tsk_list_item_t *prev = 0;
tsk_list_item_t *curr = prev = list->head;
//assert((list && list->tail) ? !list->tail->next : 1);
while(curr)
{
if(!tsk_object_cmp(curr->data, tskobj))
{
if(prev == curr)
{ /* Found at first position. */
if(list->head == list->tail)
{ /* There was only one item */
if(prev == curr){
/* Found at first position. */
if(list->head == list->tail){
/* There was only one item */
list->head = list->tail = 0;
}
else
{
else{
list->head = curr->next;
}
}
else
{
if(curr == list->tail)
{ /* Found at last position */
if(curr == list->tail){
/* Found at last position */
list->tail = prev;
list->tail->next = 0;
}
else
{
else{
prev->next = curr->next;
}
}
/*curr =*/ tsk_object_unref(curr);
break;
return curr;
}
prev = curr;
@ -110,16 +104,30 @@ void tsk_list_remove_item_by_data(tsk_list_t* list, const void * tskobj)
}
}
//assert((list && list->tail) ? !list->tail->next : 1);
return 0;
}
/**@ingroup tsk_list_group
* Remove an item from the @a list using a predicate function.
* @param list The list from which to remove the item.
* Removes an object from the @a list.
* @param list The list from which to remove the object.
* @param tskobj Any valid object(declared using @ref TSK_DECLARE_OBJECT) to remove.
*/
void tsk_list_remove_item_by_data(tsk_list_t* list, const void * tskobj)
{
tsk_list_item_t* item;
if((item = tsk_list_pop_item_by_data(list, tskobj))){
tsk_object_unref(item);
}
}
/**@ingroup tsk_list_group
* Pops an item from the @a list using a predicate function.
* @param list The list from which to pop the item.
* @param predicate The predicate function used to match the item.
* @param data Arbitrary data to pass to the predicate function.
* @retval The item
*/
void tsk_list_remove_item_by_pred(tsk_list_t* list, tsk_list_func_predicate predicate, const void * data)
tsk_list_item_t* tsk_list_pop_item_by_pred(tsk_list_t* list, tsk_list_func_predicate predicate, const void * data)
{
if(list)
{
@ -130,40 +138,51 @@ void tsk_list_remove_item_by_pred(tsk_list_t* list, tsk_list_func_predicate pred
{
if(!predicate(curr, data))
{
if(prev == curr)
{ /* Found at first position. */
if(list->head == list->tail)
{ /* There was only one item */
if(prev == curr){
/* Found at first position. */
if(list->head == list->tail){
/* There was only one item */
list->head = list->tail = 0;
}
else
{
else{
list->head = curr->next;
}
}
else
{
if(curr == list->tail)
{ /* Found at last position */
if(curr == list->tail){
/* Found at last position */
list->tail = prev;
list->tail->next = 0;
}
else
{
else{
prev->next = curr->next;
}
}
/*curr =*/ tsk_object_unref(curr);
break;
return curr;
}
prev = curr;
curr = curr->next;
}
}
//assert((list && list->tail) ? !list->tail->next : 1);
return 0;
}
/**@ingroup tsk_list_group
* Removes an item from the @a list using a predicate function.
* @param list The list from which to remove the item.
* @param predicate The predicate function used to match the item.
* @param data Arbitrary data to pass to the predicate function.
*/
void tsk_list_remove_item_by_pred(tsk_list_t* list, tsk_list_func_predicate predicate, const void * data)
{
tsk_list_item_t* item;
if((item = tsk_list_pop_item_by_pred(list, predicate, data))){
tsk_object_unref(item);
}
}
/**@ingroup tsk_list_group
@ -177,8 +196,7 @@ void tsk_list_clear_items(tsk_list_t* list)
tsk_list_item_t* next = 0;
tsk_list_item_t* curr = list->head;
while(curr)
{
while(curr){
next = curr->next;
tsk_object_unref(curr);
curr = next;
@ -200,17 +218,13 @@ tsk_list_item_t* tsk_list_pop_first_item(tsk_list_t* list)
item = list->head;
if(list->head)
{
if(list->head->next)
{
if(list->head->next){
list->head = list->head->next;
}
else
{
else{
list->head = list->tail = 0;
}
}
//assert((list && list->tail) ? !list->tail->next : 1);
}
return item;
@ -237,8 +251,6 @@ void tsk_list_push_item(tsk_list_t* list, tsk_list_item_t** item, int back)
list->tail = list->head = *item;
}
(*item) = 0;
//assert((list && list->tail) ? !list->tail->next : 1);
}
/**@ingroup tsk_list_group
@ -259,12 +271,10 @@ void tsk_list_push_filtered_item(tsk_list_t* list, tsk_list_item_t** item, int a
int diff = tsk_object_cmp((*item), curr);
if((diff <= 0 && ascending) || (diff >=0 && !ascending))
{
if(curr == list->head)
{
if(curr == list->head){
tsk_list_push_front_item(list, item);
}
else
{
else{
(*item)->next = curr;
prev->next = (*item);
}
@ -293,8 +303,7 @@ void tsk_list_push_list(tsk_list_t* dest, tsk_list_t** src, int back)
tsk_list_item_t* next = 0;
tsk_list_item_t* curr = (*src)->head;
while(curr)
{
while(curr){
next = curr->next;
tsk_list_push_item(dest, &curr, back);
curr = next->next;
@ -318,11 +327,9 @@ void tsk_list_push_data(tsk_list_t* list, void** data, int back)
tsk_list_push_item(list, &item, back);
(*data) = 0;
}
else
{
else{
TSK_DEBUG_WARN("Cannot add an uninitialized data to the list");
}
//assert((list && list->tail) ? !list->tail->next : 1);
}
/**@ingroup tsk_list_group
@ -340,8 +347,6 @@ void tsk_list_push_filtered_data(tsk_list_t* list, void** data, int ascending)
tsk_list_push_filtered_item(list, &item, ascending);
(*data) = 0;
//assert((list && list->tail) ? !list->tail->next : 1);
}
else
{
@ -362,8 +367,7 @@ const tsk_list_item_t* tsk_list_find_item_by_data(const tsk_list_t* list, const
tsk_list_item_t *item;
tsk_list_foreach(item, list)
{
if(!tsk_object_cmp(item->data, tskobj))
{
if(!tsk_object_cmp(item->data, tskobj)){
return item;
}
}
@ -391,8 +395,7 @@ const tsk_list_item_t* tsk_list_find_item_by_pred(const tsk_list_t* list, tsk_li
}
}
}
else
{
else{
TSK_DEBUG_WARN("Cannot use an uninitialized predicate function");
}
return 0;
@ -420,12 +423,10 @@ static void* tsk_list_item_create(void * self, va_list * app)
static void* tsk_list_item_destroy(void *self)
{
tsk_list_item_t *item = self;
if(item)
{
if(item){
item->data = tsk_object_unref(item->data);
}
else
{
else{
TSK_DEBUG_WARN("Cannot free an uninitialized item");
}
return item;
@ -467,8 +468,7 @@ static void* tsk_list_destroy(void *self)
tsk_list_item_t* next = 0;
tsk_list_item_t* curr = list->head;
while(curr)
{
while(curr){
next = curr->next;
/*curr =*/ tsk_object_unref(curr);
curr = next;

View File

@ -93,8 +93,10 @@ typedef int (*tsk_list_func_predicate)(const tsk_list_item_t* item, const void*
#define tsk_list_foreach(item, list) for(item = list?list->head:0; item; item= item->next)
TINYSAK_API void tsk_list_remove_item(tsk_list_t* list, tsk_list_item_t* item);
TINYSAK_API tsk_list_item_t* tsk_list_pop_item_by_data(tsk_list_t* list, const void * tskobj);
TINYSAK_API void tsk_list_remove_item_by_data(tsk_list_t* list, const void * tskobj);
TINYSAK_API void tsk_list_remove_item_by_pred(tsk_list_t* list, tsk_list_func_predicate predicate, const void * data);
TINYSAK_API tsk_list_item_t* tsk_list_pop_item_by_pred(tsk_list_t* list, tsk_list_func_predicate predicate, const void * data);
TINYSAK_API void tsk_list_clear_items(tsk_list_t* list);
TINYSAK_API tsk_list_item_t* tsk_list_pop_first_item(tsk_list_t* list);

View File

@ -36,7 +36,7 @@
*/
#if defined (_DEBUG) || defined (DEBUG)
# define TSK_DEBUG_OBJECTS 1
# define TSK_DEBUG_OBJECTS 0
static int tsk_objects_count = 0;
#else
# define TSK_DEBUG_OBJECTS 0
@ -46,7 +46,7 @@ static int tsk_objects_count = 0;
*/
typedef struct tsk_object_header_s{
const void* base; /**< Opaque data holding a pointer to the actual meta-data(size, constructor, destructor and comparator) */
size_t refCount; /**< Reference counter. */
int refCount; /**< Reference counter. */
}
tsk_object_header_t;
#define TSK_OBJECT_HEADER_GET(object) ((tsk_object_header_t*)object)
@ -101,8 +101,7 @@ void* tsk_object_new2(const tsk_object_def_t *objdef, va_list* ap)
{
(*(const tsk_object_def_t **) newobj) = objdef;
TSK_OBJECT_HEADER_GET(newobj)->refCount = 1;
if(objdef->constructor)
{
if(objdef->constructor){
newobj = objdef->constructor(newobj, ap);
}
else{
@ -182,7 +181,7 @@ void* tsk_object_unref(void *self)
{
if(self)
{
if(!--(TSK_OBJECT_HEADER_GET(self)->refCount)){
if(0 == --(TSK_OBJECT_HEADER_GET(self)->refCount)){ // If refCount is < 0 then, nothing should happen.
tsk_object_delete(self);
return 0;
}

View File

@ -73,7 +73,7 @@ TSIP_BEGIN_DECLS
#define TSIP_RESPONSE_CREATE(request, status_code, reason_phrase) tsk_object_new(tsip_message_def_t, (tsip_message_type_t)tsip_response, (const tsip_request_t*)request, (short)status_code, (const char*)reason_phrase)
#define TSIP_RESPONSE_CODE(self) ((self)->status_code)
#define TSIP_RESPONSE_CODE(self) (TSIP_MESSAGE_IS_RESPONSE((self)) ? (self)->status_code : 0)
#define TSIP_RESPONSE_PHRASE(self) ((self)->reason_phrase)
#define TSIP_REQUEST_METHOD(self) ((self)->method)

View File

@ -124,10 +124,10 @@
P_User_Database = "P-User-Database"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_User_Database;
P_Visited_Network_ID = "P-Visited-Network-ID"i SP* HCOLON SP*<: any* :>CRLF @parse_header_P_Visited_Network_ID;
# Ignore not supported headers
#extension_header = (token) SP* HCOLON SP*<: any* :>CRLF @parse_header_extension_header;
######
extension_header = (token) SP* HCOLON SP*<: any* :>CRLF @parse_header_extension_header;
HEADER = ( Accept | Accept_Contact | Accept_Encoding | Accept_Language | Accept_Resource_Priority | Alert_Info | Allow | Allow_Events | Authentication_Info | Authorization | Call_ID | Call_Info | Contact | Content_Disposition | Content_Encoding | Content_Language | Content_Length | Content_Type | CSeq | Date | Error_Info | Event | Expires | From | History_Info | Identity | Identity_Info | In_Reply_To | Join | Max_Forwards | MIME_Version | Min_Expires | Min_SE | Organization | Path | Priority | Privacy | Proxy_Authenticate | Proxy_Authorization | Proxy_Require | RAck | Reason | Record_Route | Refer_Sub | Refer_To | Referred_By | Reject_Contact | Replaces | Reply_To | Request_Disposition | Require | Resource_Priority | Retry_After | Route | RSeq | Security_Client | Security_Server | Security_Verify | Server | Service_Route | Session_Expires | SIP_ETag | SIP_If_Match | Subject | Subscription_State | Supported | Target_Dialog | Timestamp | To | Unsupported | User_Agent | Via | Warning | WWW_Authenticate | P_Access_Network_Info | P_Answer_State | P_Asserted_Identity | P_Associated_URI | P_Called_Party_ID | P_Charging_Function_Addresses | P_Charging_Vector | P_DCS_Billing_Info | P_DCS_LAES | P_DCS_OSPS | P_DCS_Redirect | P_DCS_Trace_Party_ID | P_Early_Media | P_Media_Authorization | P_Preferred_Identity | P_Profile_Key | P_User_Database | P_Visited_Network_ID);
HEADER = ( Accept | Accept_Contact | Accept_Encoding | Accept_Language | Accept_Resource_Priority | Alert_Info | Allow | Allow_Events | Authentication_Info | Authorization | Call_ID | Call_Info | Contact | Content_Disposition | Content_Encoding | Content_Language | Content_Length | Content_Type | CSeq | Date | Error_Info | Event | Expires | From | History_Info | Identity | Identity_Info | In_Reply_To | Join | Max_Forwards | MIME_Version | Min_Expires | Min_SE | Organization | Path | Priority | Privacy | Proxy_Authenticate | Proxy_Authorization | Proxy_Require | RAck | Reason | Record_Route | Refer_Sub | Refer_To | Referred_By | Reject_Contact | Replaces | Reply_To | Request_Disposition | Require | Resource_Priority | Retry_After | Route | RSeq | Security_Client | Security_Server | Security_Verify | Server | Service_Route | Session_Expires | SIP_ETag | SIP_If_Match | Subject | Subscription_State | Supported | Target_Dialog | Timestamp | To | Unsupported | User_Agent | Via | Warning | WWW_Authenticate | P_Access_Network_Info | P_Answer_State | P_Asserted_Identity | P_Associated_URI | P_Called_Party_ID | P_Charging_Function_Addresses | P_Charging_Vector | P_DCS_Billing_Info | P_DCS_LAES | P_DCS_OSPS | P_DCS_Redirect | P_DCS_Trace_Party_ID | P_Early_Media | P_Media_Authorization | P_Preferred_Identity | P_Profile_Key | P_User_Database | P_Visited_Network_ID)@1 | (extension_header)@0;
}%%

View File

@ -35,6 +35,7 @@
#include "tinysip/headers/tsip_header_Call_ID.h"
#include "tinysip/headers/tsip_header_Contact.h"
#include "tinysip/headers/tsip_header_CSeq.h"
#include "tinysip/headers/tsip_header_Dummy.h"
#include "tinysip/headers/tsip_header_Event.h"
#include "tinysip/headers/tsip_header_Expires.h"
#include "tinysip/headers/tsip_header_From.h"
@ -102,37 +103,49 @@
# /*== Accept: ==*/
action parse_header_Accept
{
TSK_DEBUG_ERROR("parse_header_Accept NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Accept NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Accept-Contact: ==*/
action parse_header_Accept_Contact
{
TSK_DEBUG_ERROR("parse_header_Accept_Contact NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Accept_Contact NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Accept-Encoding: ==*/
action parse_header_Accept_Encoding
{
TSK_DEBUG_ERROR("parse_header_Accept_Encoding NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Accept_Encoding NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Accept-Language: ==*/
action parse_header_Accept_Language
{
TSK_DEBUG_ERROR("parse_header_Accept_Language NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Accept_Language NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Accept-Resource-Priority : ==*/
action parse_header_Accept_Resource_Priority
{
TSK_DEBUG_ERROR("parse_header_Accept_Resource_Priority NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Accept_Resource_Priority NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Alert-Info: ==*/
action parse_header_Alert_Info
{
TSK_DEBUG_ERROR("parse_header_Alert_Info NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Alert_Info NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Allow: ==*/
@ -152,7 +165,9 @@
# /*== Authentication-Info: ==*/
action parse_header_Authentication_Info
{
TSK_DEBUG_ERROR("parse_header_Authentication_Info NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Authentication_Info NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Authorization: ==*/
@ -165,16 +180,22 @@
# /*== Call-ID: ==*/
action parse_header_Call_ID
{
if(!message->Call_ID)
{
if(!message->Call_ID){
message->Call_ID = tsip_header_Call_ID_parse(state->tag_start, (state->tag_end-state->tag_start));
}
else{
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("The message already have 'Call-ID' header.");
}
}
# /*== Call-Info: ==*/
action parse_header_Call_Info
{
TSK_DEBUG_ERROR("parse_header_Call_Info NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Call_Info NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Contact: ==*/
@ -202,58 +223,80 @@
# /*== Content-Disposition: ==*/
action parse_header_Content_Disposition
{
TSK_DEBUG_ERROR("parse_header_Content_Disposition NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Content_Disposition NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Content-Encoding: ==*/
action parse_header_Content_Encoding
{
TSK_DEBUG_ERROR("PARSE_HEADER_ACCEPT NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("PARSE_HEADER_ACCEPT NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Content-Language: ==*/
action parse_header_Content_Language
{
TSK_DEBUG_ERROR("parse_header_Content_Language NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Content_Language NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Content-Length: ==*/
action parse_header_Content_Length
{
if(!message->Content_Length)
{
if(!message->Content_Length){
message->Content_Length = tsip_header_Content_Length_parse(state->tag_start, (state->tag_end-state->tag_start));
}
else{
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("The message already have 'Content-Length' header.");
}
}
# /*== Content-Type: ==*/
action parse_header_Content_Type
{
if(!message->Content_Type)
{
if(!message->Content_Type){
message->Content_Type = tsip_header_Content_Type_parse(state->tag_start, (state->tag_end-state->tag_start));
}
else{
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("The message already have 'Content-Type' header.");
}
}
# /*== CSeq: ==*/
action parse_header_CSeq
{
if(!message->CSeq)
{
if(!message->CSeq){
message->CSeq = tsip_header_CSeq_parse(state->tag_start, (state->tag_end-state->tag_start));
}
else{
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("The message already have 'CSeq' header.");
}
}
# /*== Date: ==*/
action parse_header_Date
{
TSK_DEBUG_ERROR("parse_header_Date NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Date NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Error-Info: ==*/
action parse_header_Error_Info
{
TSK_DEBUG_ERROR("parse_header_Error_Info NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Error_Info NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Event: ==*/
@ -266,49 +309,67 @@
# /*== Expires: ==*/
action parse_header_Expires
{
if(!message->Expires)
{
if(!message->Expires){
message->Expires = tsip_header_Expires_parse(state->tag_start, (state->tag_end-state->tag_start));
}
else{
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("The message already have 'Expires' header.");
}
}
# /*== From: ==*/
action parse_header_From
{
if(!message->From)
{
if(!message->From){
message->From = tsip_header_From_parse(state->tag_start, (state->tag_end-state->tag_start));
}
else{
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("The message already have 'From' header.");
}
}
# /*== History-Info: ==*/
action parse_header_History_Info
{
TSK_DEBUG_ERROR("parse_header_History_Info NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_History_Info NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Identity: ==*/
action parse_header_Identity
{
TSK_DEBUG_ERROR("parse_header_Identity NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Identity NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Identity-Info: ==*/
action parse_header_Identity_Info
{
TSK_DEBUG_ERROR("parse_header_Identity_Info NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Identity_Info NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== In_Reply-To: ==*/
action parse_header_In_Reply_To
{
TSK_DEBUG_ERROR("parse_header_In_Reply_To NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_In_Reply_To NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Join: ==*/
action parse_header_Join
{
TSK_DEBUG_ERROR("parse_header_Join NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Join NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Max-Forwards: ==*/
@ -321,7 +382,9 @@
# /*== MIME-Version: ==*/
action parse_header_MIME_Version
{
TSK_DEBUG_ERROR("parse_header_MIME_Version NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_MIME_Version NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Min-Expires: ==*/
@ -334,13 +397,17 @@
# /*== Min-SE: ==*/
action parse_header_Min_SE
{
TSK_DEBUG_ERROR("parse_header_Min_SE NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Min_SE NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Organization: ==*/
action parse_header_Organization
{
TSK_DEBUG_ERROR("parse_header_Organization NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Organization NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-Access-Network-Info: ==*/
@ -353,7 +420,9 @@
# /*== P-Answer-State: ==*/
action parse_header_P_Answer_State
{
TSK_DEBUG_ERROR("parse_header_P_Answer_State NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_Answer_State NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-Asserted-Identity: ==*/
@ -373,7 +442,9 @@
# /*== P-Called-Party-ID: ==*/
action parse_header_P_Called_Party_ID
{
TSK_DEBUG_ERROR("parse_header_P_Called_Party_ID NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_Called_Party_ID NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-Charging-Function-Addresses : ==*/
@ -386,49 +457,65 @@
# /*== P_Charging_Vector: ==*/
action parse_header_P_Charging_Vector
{
TSK_DEBUG_ERROR("parse_header_P_Charging_Vector NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_Charging_Vector NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-DCS-Billing-Info: ==*/
action parse_header_P_DCS_Billing_Info
{
TSK_DEBUG_ERROR("parse_header_P_DCS_Billing_Info NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_DCS_Billing_Info NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-DCS-LAES: ==*/
action parse_header_P_DCS_LAES
{
TSK_DEBUG_ERROR("parse_header_P_DCS_LAES NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_DCS_LAES NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-DCS-OSPS: ==*/
action parse_header_P_DCS_OSPS
{
TSK_DEBUG_ERROR("parse_header_P_DCS_OSPS NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_DCS_OSPS NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-DCS-Redirect: ==*/
action parse_header_P_DCS_Redirect
{
TSK_DEBUG_ERROR("parse_header_P_DCS_Redirect NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_DCS_Redirect NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-DCS-Trace-Party-ID: ==*/
action parse_header_P_DCS_Trace_Party_ID
{
TSK_DEBUG_ERROR("parse_header_P_DCS_Trace_Party_ID NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_DCS_Trace_Party_ID NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-Early-Media: ==*/
action parse_header_P_Early_Media
{
TSK_DEBUG_ERROR("parse_header_P_Early_Media NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_Early_Media NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-Media-Authorization: ==*/
action parse_header_P_Media_Authorization
{
TSK_DEBUG_ERROR("parse_header_P_Media_Authorization NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_Media_Authorization NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-Preferred-Identity: ==*/
@ -441,19 +528,25 @@
# /*== P-Profile-Key: ==*/
action parse_header_P_Profile_Key
{
TSK_DEBUG_ERROR("parse_header_P_Profile_Key NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_Profile_Key NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-User-Database: ==*/
action parse_header_P_User_Database
{
TSK_DEBUG_ERROR("parse_header_P_User_Database NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_User_Database NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== P-Visited-Network-ID: ==*/
action parse_header_P_Visited_Network_ID
{
TSK_DEBUG_ERROR("parse_header_P_Visited_Network_ID NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_P_Visited_Network_ID NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Path: ==*/
@ -466,7 +559,9 @@
# /* == Priority: ==*/
action parse_header_Priority
{
TSK_DEBUG_ERROR("parse_header_Priority NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Priority NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Privacy: ==*/
@ -500,13 +595,17 @@
# /*== RAck: ==*/
action parse_header_RAck
{
TSK_DEBUG_ERROR("parse_header_RAck NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_RAck NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Reason: ==*/
action parse_header_Reason
{
TSK_DEBUG_ERROR("parse_header_Reason NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Reason NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Record-Route: ==*/
@ -519,65 +618,80 @@
# /*== Refer-Sub: ==*/
action parse_header_Refer_Sub
{
TSK_DEBUG_ERROR("parse_header_Refer_Sub NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Refer_Sub NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Refer-To: ==*/
action parse_header_Refer_To
{
TSK_DEBUG_ERROR("parse_header_Refer_To NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Refer_To NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Referred-By: ==*/
action parse_header_Referred_By
{
TSK_DEBUG_ERROR("parse_header_Referred_By NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Referred_By NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Reject-Contact: ==*/
action parse_header_Reject_Contact
{
TSK_DEBUG_ERROR("parse_header_Reject_Contact NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Reject_Contact NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Replaces: ==*/
action parse_header_Replaces
{
TSK_DEBUG_ERROR("parse_header_Replaces NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Replaces NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Reply-To: ==*/
action parse_header_Reply_To
{
TSK_DEBUG_ERROR("parse_header_Reply_To NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Reply_To NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Request-Disposition: ==*/
action parse_header_Request_Disposition
{
TSK_DEBUG_ERROR("parse_header_Request_Disposition NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Request_Disposition NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Require: ==*/
action parse_header_Require
{
tsip_header_Require_t *header = tsip_header_Require_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_push_back_data(message->headers, ((void**) &header));
}
ADD_HEADER(header);
}
# /*== Resource-Priority: ==*/
action parse_header_Resource_Priority
{
TSK_DEBUG_ERROR("parse_header_Resource_Priority NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Resource_Priority NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Retry-After: ==*/
action parse_header_Retry_After
{
TSK_DEBUG_ERROR("parse_header_Retry_After NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Retry_After NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Route: ==*/
@ -590,7 +704,9 @@
# /*== RSeq: ==*/
action parse_header_RSeq
{
TSK_DEBUG_ERROR("parse_header_RSeq NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_RSeq NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Security_Client: ==*/
@ -631,7 +747,9 @@
# /*== Session-Expires: ==*/
action parse_header_Session_Expires
{
TSK_DEBUG_ERROR("parse_header_Session_Expires NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Session_Expires NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== SIP-ETag: ==*/
@ -651,7 +769,9 @@
# /*== Subject: ==*/
action parse_header_Subject
{
TSK_DEBUG_ERROR("parse_header_Subject NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Subject NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Subscription-State: ==*/
@ -671,28 +791,38 @@
# /*== Target-Dialog: ==*/
action parse_header_Target_Dialog
{
TSK_DEBUG_ERROR("parse_header_Target_Dialog NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Target_Dialog NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Timestamp: ==*/
action parse_header_Timestamp
{
TSK_DEBUG_ERROR("parse_header_Timestamp NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Timestamp NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== To: ==*/
action parse_header_To
{
if(!message->To)
{
if(!message->To){
message->To = tsip_header_To_parse(state->tag_start, (state->tag_end-state->tag_start));
}
else{
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("The message already have 'To' header.");
}
}
# /*== Unsupported: ==*/
action parse_header_Unsupported
{
TSK_DEBUG_ERROR("parse_header_Unsupported NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
TSK_DEBUG_WARN("parse_header_Unsupported NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== User-Agent: ==*/
@ -705,17 +835,12 @@
# /*== Via: ==*/
action parse_header_Via
{
if(!message->firstVia)
{
if(!message->firstVia){
message->firstVia = tsip_header_Via_parse(state->tag_start, (state->tag_end-state->tag_start));
}
else
{
else{
tsip_header_Via_t *header = tsip_header_Via_parse(state->tag_start, (state->tag_end-state->tag_start));
if(header)
{
tsk_list_push_back_data(message->headers, ((void**) &header));
}
ADD_HEADER(header);
}
}
@ -736,7 +861,8 @@
# /*== extension_header: ==*/
action parse_header_extension_header
{
TSK_DEBUG_ERROR("parse_header_extension_header NOT IMPLEMENTED");
tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
}

View File

@ -140,12 +140,10 @@ static void tsip_message_parser_eoh(tsk_ragel_state_t *state, tsip_message_t *me
state->tag_end = p;
len = (int)(state->tag_end - state->tag_start);
if(tsip_header_parse(state, message))
{
if(tsip_header_parse(state, message)){
//TSK_DEBUG_INFO("TSIP_MESSAGE_PARSER::PARSE_HEADER len=%d state=%d", len, state->cs);
}
else
{
else{
TSK_DEBUG_ERROR("Failed to parse header - %s", state->tag_start);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,7 @@ static void tsip_message_parser_eoh(tsk_ragel_state_t *state, tsip_message_t *me
* Ragel state machine.
*/
/* #line 184 "tsip_parser_message.rl" */
/* #line 182 "tsip_parser_message.rl" */
@ -179,18 +179,16 @@ static const int tsip_machine_parser_message_error = 0;
static const int tsip_machine_parser_message_en_main = 1;
/* #line 189 "tsip_parser_message.rl" */
/* #line 187 "tsip_parser_message.rl" */
TSIP_BOOLEAN tsip_message_parse(tsk_ragel_state_t *state, tsip_message_t **result, TSIP_BOOLEAN extract_content)
{
if(!state || state->pe <= state->p)
{
if(!state || state->pe <= state->p){
return TSIP_FALSE;
}
if(!*result)
{
if(!*result){
*result = TSIP_MESSAGE_CREATE();
}
@ -205,9 +203,9 @@ TSIP_BOOLEAN tsip_message_parse(tsk_ragel_state_t *state, tsip_message_t **resul
/* Check result */
if( state->cs <
/* #line 209 "../src/parsers/tsip_parser_message.c" */
/* #line 207 "../src/parsers/tsip_parser_message.c" */
42
/* #line 213 "tsip_parser_message.rl" */
/* #line 209 "tsip_parser_message.rl" */
)
{
TSK_OBJECT_SAFE_FREE(*result);
@ -223,12 +221,12 @@ static void tsip_message_parser_init(tsk_ragel_state_t *state)
/* Regel machine initialization. */
/* #line 227 "../src/parsers/tsip_parser_message.c" */
/* #line 225 "../src/parsers/tsip_parser_message.c" */
{
cs = tsip_machine_parser_message_start;
}
/* #line 228 "tsip_parser_message.rl" */
/* #line 224 "tsip_parser_message.rl" */
state->cs = cs;
}
@ -241,7 +239,7 @@ static void tsip_message_parser_execute(tsk_ragel_state_t *state, tsip_message_t
const char *eof = state->eof;
/* #line 245 "../src/parsers/tsip_parser_message.c" */
/* #line 243 "../src/parsers/tsip_parser_message.c" */
{
int _klen;
unsigned int _trans;
@ -410,18 +408,16 @@ _match:
state->tag_end = p;
len = (int)(state->tag_end - state->tag_start);
if(tsip_header_parse(state, message))
{
if(tsip_header_parse(state, message)){
//TSK_DEBUG_INFO("TSIP_MESSAGE_PARSER::PARSE_HEADER len=%d state=%d", len, state->cs);
}
else
{
else{
TSK_DEBUG_ERROR("Failed to parse header - %s", state->tag_start);
}
}
break;
case 7:
/* #line 164 "tsip_parser_message.rl" */
/* #line 162 "tsip_parser_message.rl" */
{
state->cs = cs;
state->p = p;
@ -436,7 +432,7 @@ _match:
eof = state->eof;
}
break;
/* #line 440 "../src/parsers/tsip_parser_message.c" */
/* #line 436 "../src/parsers/tsip_parser_message.c" */
}
}
@ -449,7 +445,7 @@ _again:
_out: {}
}
/* #line 240 "tsip_parser_message.rl" */
/* #line 236 "tsip_parser_message.rl" */
state->cs = cs;
state->p = p;
@ -466,14 +462,12 @@ static void tsip_message_parser_eoh(tsk_ragel_state_t *state, tsip_message_t *me
if(extract_content && message)
{
uint32_t clen = tsip_message_getContent_length(message);
if((p+clen) <pe && !message->Content)
{
uint32_t clen = TSIP_MESSAGE_CONTENT_LENGTH(message);
if((p+clen) <pe && !message->Content){
message->Content = TSK_BUFFER_CREATE((p+1), clen);
p = (p+clen);
}
else
{
else{
p = (pe-1);
}
}

View File

@ -42,10 +42,10 @@
#define RUN_TEST_LOOP 1
#define RUN_TEST_ALL 0
#define RUN_TEST_MESSAGES 0
#define RUN_TEST_MESSAGES 1
#define RUN_TEST_URI 0
#define RUN_TEST_TRANSAC 0
#define RUN_TEST_STACK 1
#define RUN_TEST_STACK 0
#ifdef _WIN32_WCE
int _tmain(int argc, _TCHAR* argv[])

View File

@ -212,6 +212,10 @@
RelativePath="..\..\tinyHTTP\test\test_auth.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\test\test_messages.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\test\test_stack.h"
>

View File

@ -399,10 +399,6 @@
RelativePath="..\..\tinyHTTP\src\headers\thttp_header_Dummy.c"
>
</File>
<File
RelativePath="..\..\tinyHTTP\src\headers\thttp_header_Proxy_Authenticate.c"
>
</File>
<File
RelativePath="..\..\tinyHTTP\src\headers\thttp_header_WWW_Authenticate.c"
>
@ -491,10 +487,6 @@
RelativePath="..\..\tinyHTTP\include\tinyHTTP\headers\thttp_header_Dummy.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\include\tinyHTTP\headers\thttp_header_Proxy_Authenticate.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\include\tinyHTTP\headers\thttp_header_WWW_Authenticate.h"
>

View File

@ -121,7 +121,7 @@
<p class="body_text" align="left">
<strong>doubango</strong> is an experimental cross-platform, open source 3GPP NGN/IMS
framework for embedded systems (it also works on Windows XP/Vista/7, Mac OS X and
unix-like systems).
unix-like systems). <b>It is fully written in C</b>.
<br />
The framework has been carefully designed to efficiently work on embedded systems
with limited memory and low computing power and to be extremely portable.<br />