From 0506a04219e424d3c823950eee0cf13669f023f7 Mon Sep 17 00:00:00 2001 From: bossiel Date: Fri, 5 Mar 2010 00:36:12 +0000 Subject: [PATCH] Update HTTP stack. --- trunk/tinyHTTP/include/thttp.h | 36 ++++ trunk/tinyHTTP/include/tinyHTTP/thttp_event.h | 59 ++++++ .../include/tinyHTTP/thttp_operation.h | 40 ++++ .../include/tinyHTTP/thttp_transport.h | 40 ++++ trunk/tinyHTTP/src/thttp.c | 181 +++++++++++++++++- trunk/tinyHTTP/src/thttp_event.c | 87 +++++++++ trunk/tinyHTTP/src/thttp_operation.c | 30 +++ trunk/tinyHTTP/src/thttp_transport.c | 30 +++ trunk/tinyHTTP/test/test.c | 17 +- trunk/tinyHTTP/test/test.vcproj | 4 + trunk/tinyHTTP/test/test_stack.h | 32 ++++ trunk/tinyHTTP/tinyHTTP.vcproj | 24 +++ trunk/tinyIPSec/src/tipsec_vista.c | 2 +- trunk/tinyNET/tinyNET.vcproj | 2 +- .../tinysip/transports/tsip_transport.h | 30 +-- .../src/transports/tsip_transport_ipsec.c | 4 +- .../src/transports/tsip_transport_layer.c | 2 +- trunk/tinySIP/src/tsip.c | 11 +- trunk/tinySIP/test/test/test_stack.h | 41 ++-- trunk/tinySIP/tinySIP.vcproj | 8 + 20 files changed, 630 insertions(+), 50 deletions(-) create mode 100644 trunk/tinyHTTP/include/tinyHTTP/thttp_event.h create mode 100644 trunk/tinyHTTP/include/tinyHTTP/thttp_operation.h create mode 100644 trunk/tinyHTTP/include/tinyHTTP/thttp_transport.h create mode 100644 trunk/tinyHTTP/src/thttp_event.c create mode 100644 trunk/tinyHTTP/src/thttp_operation.c create mode 100644 trunk/tinyHTTP/src/thttp_transport.c create mode 100644 trunk/tinyHTTP/test/test_stack.h diff --git a/trunk/tinyHTTP/include/thttp.h b/trunk/tinyHTTP/include/thttp.h index 489a2b91..be054fdb 100644 --- a/trunk/tinyHTTP/include/thttp.h +++ b/trunk/tinyHTTP/include/thttp.h @@ -31,7 +31,43 @@ #include "tinyhttp_config.h" +#include "tinyHTTP/thttp_event.h" + THTTP_BEGIN_DECLS + +typedef enum thttp_stack_param_type_e +{ + /* Identity */ + pname_usr, + pname_proxy, + pname_useragent, +#define THTTP_STACK_SET_USER(USRNAME_STR, PASSWORD_STR) pname_usr, (const char*)USRNAME_STR, (const char*)PASSWORD_STR +#define THTTP_STACK_SET_PROXY(HOST_STR, PORT_INT, USRNAME_STR, PASSWORD_STR) pname_proxy, (const char*)HOST_STR, (int)PORT_INT, (const char*)USRNAME_STR, (const char*)PASSWORD_STR +#define THTTP_STACK_SET_USER_AGENT(UA_STR) pname_useragent, (const char*)UA_STR + + /* Network */ + pname_local_ip, + pname_local_port, +#define THTTP_STACK_SET_LOCAL_IP(STR) pname_local_ip, (const char*)STR +#define THTTP_STACK_SET_LOCAL_PORT(INT) pname_local_port, (int)INT + + + pname_null, +#define THTTP_STACK_SET_NULL() pname_null +} +thttp_stack_param_type_t; + +typedef void thttp_stack_handle_t; + +TINYHTTP_API int thttp_global_init(); +TINYHTTP_API int thttp_global_deinit(); + + +TINYHTTP_API thttp_stack_handle_t *thttp_stack_create(thttp_stack_callback callback, ...); +TINYHTTP_API int thttp_stack_start(thttp_stack_handle_t *self); +TINYHTTP_API int thttp_stack_set(thttp_stack_handle_t *self, ...); +TINYHTTP_API int thttp_stack_stop(thttp_stack_handle_t *self); + THTTP_END_DECLS #endif /* TINYHTTP_THTTP_H */ \ No newline at end of file diff --git a/trunk/tinyHTTP/include/tinyHTTP/thttp_event.h b/trunk/tinyHTTP/include/tinyHTTP/thttp_event.h new file mode 100644 index 00000000..90dee95c --- /dev/null +++ b/trunk/tinyHTTP/include/tinyHTTP/thttp_event.h @@ -0,0 +1,59 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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_event.h + * @brief HTTP/HTTPS event. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYHTTP_EVENT_H +#define TINYHTTP_EVENT_H + +#include "tinyhttp_config.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(self) ((thttp_event_t*)(self)) + +typedef struct thttp_event_s +{ + TSK_DECLARE_OBJECT; + + short code; + char* phrase; + + struct thttp_message_s *message; +} +thttp_event_t; + +typedef int (*thttp_stack_callback)(const thttp_event_t *httpevent); + +TINYHTTP_GEXTERN const void *thttp_event_def_t; + +THTTP_END_DECLS + +#endif /* TINYHTTP_EVENT_H */ diff --git a/trunk/tinyHTTP/include/tinyHTTP/thttp_operation.h b/trunk/tinyHTTP/include/tinyHTTP/thttp_operation.h new file mode 100644 index 00000000..ba8081e6 --- /dev/null +++ b/trunk/tinyHTTP/include/tinyHTTP/thttp_operation.h @@ -0,0 +1,40 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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_operation.h + * @brief HTTP/HTTPS operation. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef THTTP_OPERATION_H +#define THTTP_OPERATION_H + +#include "tinyhttp_config.h" + +THTTP_BEGIN_DECLS + + +THTTP_END_DECLS + +#endif /* THTTP_OPERATION_H */ diff --git a/trunk/tinyHTTP/include/tinyHTTP/thttp_transport.h b/trunk/tinyHTTP/include/tinyHTTP/thttp_transport.h new file mode 100644 index 00000000..c3ec971d --- /dev/null +++ b/trunk/tinyHTTP/include/tinyHTTP/thttp_transport.h @@ -0,0 +1,40 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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_transport.h + * @brief HTTP/HTTPS transport. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef THTTP_TRANSPORT_H +#define THTTP_TRANSPORT_H + +#include "tinyhttp_config.h" + +THTTP_BEGIN_DECLS + + +THTTP_END_DECLS + +#endif /* THTTP_TRANSPORT_H */ diff --git a/trunk/tinyHTTP/src/thttp.c b/trunk/tinyHTTP/src/thttp.c index 7a9af268..b48c24b0 100644 --- a/trunk/tinyHTTP/src/thttp.c +++ b/trunk/tinyHTTP/src/thttp.c @@ -27,10 +27,187 @@ * @date Created: Sat Nov 8 16:54:58 2009 mdiop */ #include "thttp.h" +#include "tinyHTTP/thttp_event.h" + +#include "tnet.h" +#include "tnet_transport.h" + +#include "tsk_runnable.h" +#include "tsk_time.h" +#include "tsk_debug.h" + +//#include +//#include +#include /* srand */ + /** @mainpage TinyHTTP API Overview * * This file is an overview of tinyHTTP API. * -* tinySAK is a HTTP (RFC 2616) stack. -*/ \ No newline at end of file +* tinyHTTP is a HTTP (RFC 2616) stack. +*/ + +// KeepAlive : http://www.io.com/~maus/HttpKeepAlive.html + +static unsigned __thttp_initialized = 0; +static void *run(void* self); + +typedef struct thttp_stack_s +{ + TSK_DECLARE_OBJECT; + + /* Identity */ + char* username; + char* password; + char* proxy_host; + int proxy_port; + char* proxy_username; + char* proxy_password; + char* user_agent; + + /* Network */ + char* local_ip; + int local_port; + tnet_transport_t *transport; + + + + unsigned running; +} +thttp_stack_t; + +int __thttp_stack_set(thttp_stack_t *self, va_list values) +{ + thttp_stack_param_type_t curr; + + while((curr=va_arg(values, thttp_stack_param_type_t)) != pname_null) + { + switch(curr) + { + // + // Identity + // + case pname_usr: + { /* USRNAME_STR, PASSWORD_STR */ + tsk_strupdate(&self->username, va_arg(values, const char*)); + tsk_strupdate(&self->password, va_arg(values, const char*)); + break; + } + case pname_proxy: + { /* HOST_STR, PORT_INT, USRNAME_STR, PASSWORD_STR */ + tsk_strupdate(&self->proxy_host, va_arg(values, const char*)); + self->proxy_port = va_arg(values, int); + tsk_strupdate(&self->proxy_username, va_arg(values, const char*)); + tsk_strupdate(&self->proxy_password, va_arg(values, const char*)); + break; + } + case pname_useragent: + { /* UA_STR */ + tsk_strupdate(&self->user_agent, va_arg(values, const char*)); + break; + } + + // + // Network + // + case pname_local_ip: + { /* STR */ + tsk_strupdate(&self->local_ip, va_arg(values, const char*)); + break; + } + case pname_local_port: + { /* INT */ + self->local_port = va_arg(values, int); + break; + } + + }/* switch */ + }/* while */ +} + +int thttp_global_init() +{ + if(!__thttp_initialized) + { + srand((unsigned int) tsk_time_epoch()); + if(!tnet_startup()){ + __thttp_initialized = 1; + return 0; + } + } + return -1; +} + +int thttp_global_deinit() +{ + if(__thttp_initialized) + { + if(!tnet_cleanup()){ + __thttp_initialized = 0; + return 0; + } + } + return -1; +} + +thttp_stack_handle_t *thttp_stack_create(thttp_stack_callback callback, ...) +{ + +} + +int thttp_stack_start(thttp_stack_handle_t *self) +{ + +} + +int thttp_stack_set(thttp_stack_handle_t *self, ...) +{ + +} + +int thttp_stack_stop(thttp_stack_handle_t *self) +{ + +} + + +int thttp_stack_start(thttp_stack_handle_t *self) +{ + if(self) + { + int ret; + thttp_stack_t *stack = self; + + TSK_RUNNABLE(stack)->run = run; + if(ret = tsk_runnable_start(TSK_RUNNABLE(stack), thttp_event_def_t)){ + return ret; + } + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/tinyHTTP/src/thttp_event.c b/trunk/tinyHTTP/src/thttp_event.c new file mode 100644 index 00000000..381725d1 --- /dev/null +++ b/trunk/tinyHTTP/src/thttp_event.c @@ -0,0 +1,87 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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_event.c + * @brief HTTP/HTTPS event. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#include "tinyHTTP/thttp_event.h" +#include "tinyHTTP/thttp_message.h" + +#include "tsk_string.h" + + + + + + + + + + + +//======================================================== +// HTTP event object definition +// +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->message = tsk_object_ref((void*)va_arg(*app, thttp_message_t *)); + } + return self; +} + +static void* thttp_event_destroy(void * self) +{ + thttp_event_t *httpevent = self; + if(httpevent) + { + TSK_FREE(httpevent->phrase); + TSK_OBJECT_SAFE_FREE(httpevent->message); + } + return self; +} + +static int thttp_event_cmp(const void *obj1, const void *obj2) +{ + return -1; +} + +static const tsk_object_def_t thttp_event_def_s = +{ + sizeof(thttp_event_t), + thttp_event_create, + thttp_event_destroy, + thttp_event_cmp, +}; +const void *thttp_event_def_t = &thttp_event_def_s; \ No newline at end of file diff --git a/trunk/tinyHTTP/src/thttp_operation.c b/trunk/tinyHTTP/src/thttp_operation.c new file mode 100644 index 00000000..3095fad8 --- /dev/null +++ b/trunk/tinyHTTP/src/thttp_operation.c @@ -0,0 +1,30 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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_operation.c + * @brief HTTP/HTTPS operation. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#include "tinyHTTP/thttp_operation.h" \ No newline at end of file diff --git a/trunk/tinyHTTP/src/thttp_transport.c b/trunk/tinyHTTP/src/thttp_transport.c new file mode 100644 index 00000000..8cbaf43b --- /dev/null +++ b/trunk/tinyHTTP/src/thttp_transport.c @@ -0,0 +1,30 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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_transport.c + * @brief HTTP/HTTPS transport. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#include "tinyHTTP/thttp_transport.h" \ No newline at end of file diff --git a/trunk/tinyHTTP/test/test.c b/trunk/tinyHTTP/test/test.c index 5515daef..e07b3cd2 100644 --- a/trunk/tinyHTTP/test/test.c +++ b/trunk/tinyHTTP/test/test.c @@ -26,14 +26,17 @@ #include "tsk.h" +#include "thttp.h" #include "tinyHTTP/auth/thttp_auth.h" #define LOOP 1 #define RUN_TEST_ALL 0 -#define RUN_TEST_AUTH 1 +#define RUN_TEST_AUTH 0 +#define RUN_TEST_STACK 1 #include "test_auth.h" +#include "test_stack.h" #ifdef _WIN32_WCE @@ -42,21 +45,27 @@ int _tmain(int argc, _TCHAR* argv[]) int main() #endif { + thttp_global_init(); + #if LOOP - while(1) + for(;;) #endif { /* Print copyright information */ - printf("Doubango Project\nCopyright (C) 2009 Mamadou Diop \n\n"); + printf("Doubango Project\nCopyright (C) 2009-2010 Mamadou Diop \n\n"); #if RUN_TEST_AUTH || RUN_TEST_ALL test_basic_auth(); test_digest_auth(); #endif +#if RUN_TEST_STACK || RUN_TEST_ALL + test_stack(); +#endif + } - getchar(); + thttp_global_deinit(); return 0; } diff --git a/trunk/tinyHTTP/test/test.vcproj b/trunk/tinyHTTP/test/test.vcproj index 5bf19893..a3dcdbd8 100644 --- a/trunk/tinyHTTP/test/test.vcproj +++ b/trunk/tinyHTTP/test/test.vcproj @@ -206,6 +206,10 @@ RelativePath=".\test_auth.h" > + + +* +* 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_STACK_H_ +#define _TEST_STACK_H_ + +void test_stack() +{ + +} + +#endif /* _TEST_STACK_H_ */ + + diff --git a/trunk/tinyHTTP/tinyHTTP.vcproj b/trunk/tinyHTTP/tinyHTTP.vcproj index c75dc9e5..02fec50a 100644 --- a/trunk/tinyHTTP/tinyHTTP.vcproj +++ b/trunk/tinyHTTP/tinyHTTP.vcproj @@ -342,10 +342,22 @@ RelativePath=".\src\thttp.c" > + + + + + + @@ -402,10 +414,22 @@ RelativePath=".\include\thttp.h" > + + + + + + diff --git a/trunk/tinyIPSec/src/tipsec_vista.c b/trunk/tinyIPSec/src/tipsec_vista.c index e2ec51ad..a64669e9 100644 --- a/trunk/tinyIPSec/src/tipsec_vista.c +++ b/trunk/tinyIPSec/src/tipsec_vista.c @@ -550,7 +550,7 @@ int tipsec_boundSA(__in const tipsec_context_vista_t* context, __in UINT64 local bundle.numSAs = 1; bundle.saList = &sa; bundle.ipVersion = TINYIPSEC_VISTA_GET_IPVER(TIPSEC_CONTEXT(context)->use_ipv6); - bundle.lifetime.lifetimeSeconds = (TIPSEC_CONTEXT(context)->lifetime > TINYIPSEC_SA_MAX_LIFETIME) ? TINYIPSEC_SA_MAX_LIFETIME : TIPSEC_CONTEXT(context)->lifetime; + bundle.lifetime.lifetimeSeconds = (UINT32)((TIPSEC_CONTEXT(context)->lifetime > TINYIPSEC_SA_MAX_LIFETIME) ? TINYIPSEC_SA_MAX_LIFETIME : TIPSEC_CONTEXT(context)->lifetime); /* From remote to local (inbound) ? */ if(toInbound){ diff --git a/trunk/tinyNET/tinyNET.vcproj b/trunk/tinyNET/tinyNET.vcproj index 4ddff1c8..adc5ae8e 100644 --- a/trunk/tinyNET/tinyNET.vcproj +++ b/trunk/tinyNET/tinyNET.vcproj @@ -65,7 +65,7 @@ /> net_transport) : -1) -#define tsip_transport_isready(transport) (transport ? tnet_transport_isready(transport->net_transport) : -1) -#define tsip_transport_issecure(transport) (transport ? tnet_transport_issecure(transport->net_transport) : 0) -#define tsip_transport_isconnected(transport) (transport ? tnet_transport_isconnected(transport->net_transport, transport->connectedFD) : 0) -#define tsip_transport_get_description(transport) (transport ? tnet_transport_get_description(transport->net_transport) : 0) -#define tsip_transport_get_ip_n_port(transport, ip, port) (transport ? tnet_transport_get_ip_n_port(transport->net_transport, transport->connectedFD, ip, port) : -1) +#define tsip_transport_start(transport) (transport ? tnet_transport_start(transport->net_transport) : -1) +#define tsip_transport_isready(transport) (transport ? tnet_transport_isready(transport->net_transport) : -1) +#define tsip_transport_issecure(transport) (transport ? tnet_transport_issecure(transport->net_transport) : 0) +#define tsip_transport_isconnected(transport) (transport ? tnet_transport_isconnected(transport->net_transport, transport->connectedFD) : 0) +#define tsip_transport_get_description(transport) (transport ? tnet_transport_get_description(transport->net_transport) : 0) +#define tsip_transport_get_ip_n_port(transport, ip, port) (transport ? tnet_transport_get_ip_n_port(transport->net_transport, transport->connectedFD, ip, port) : -1) -#define tsip_transport_connectto(transport, host, port) (transport ? (transport->connectedFD=tnet_transport_connectto(transport->net_transport, host, port)) : TNET_INVALID_FD) -//#define tsip_transport_send(transport, buf, size) (transport ? tnet_transport_send(transport->net_transport, transport->connectedFD, buf, size) : 0) -#define tsip_transport_sendto(transport, to, buf, size) (transport ? tnet_transport_sendto(transport->net_transport, transport->connectedFD, to, buf, size) : 0) +#define tsip_transport_connectto(transport, host, port, type) (transport ? (transport->connectedFD=tnet_transport_connectto(transport->net_transport, host, port, type)) : TNET_INVALID_FD) +#define tsip_transport_connectto2(transport, host, port) (transport ? (transport->connectedFD=tnet_transport_connectto2(transport->net_transport, host, port)) : TNET_INVALID_FD) +#define tsip_transport_sendto(transport, to, buf, size) (transport ? tnet_transport_sendto(transport->net_transport, transport->connectedFD, to, buf, size) : 0) -#define tsip_transport_set_callback(transport, callback, callback_data) (transport ? tnet_transport_set_callback(transport->net_transport, callback, callback_data) : -1) +#define tsip_transport_set_callback(transport, callback, callback_data) (transport ? tnet_transport_set_callback(transport->net_transport, callback, callback_data) : -1) -#define tsip_transport_have_socket(transport, fd) (transport ? tnet_transport_have_socket(transport->net_transport, fd) : 0) -#define tsip_transport_add_socket(transport, fd, take_ownership) (transport ? tnet_transport_add_socket(transport->net_transport, fd, take_ownership) : -1) -#define tsip_transport_remove_socket(transport, fd) (transport ? tnet_transport_remove_socket(transport->net_transport, fd) : -1) +#define tsip_transport_have_socket(transport, fd) (transport ? tnet_transport_have_socket(transport->net_transport, fd) : 0) +#define tsip_transport_add_socket(transport, fd, type, take_ownership, isClient) (transport ? tnet_transport_add_socket(transport->net_transport, fd, type, take_ownership, isClient) : -1) +#define tsip_transport_remove_socket(transport, fd) (transport ? tnet_transport_remove_socket(transport->net_transport, fd) : -1) -//#define tsip_transport_get_socket_type(transport) (transport ? tnet_transport_get_socket_type(transport->net_transport) : tnet_socket_type_invalid) +//#define tsip_transport_get_socket_type(transport) (transport ? tnet_transport_get_socket_type(transport->net_transport) : tnet_socket_type_invalid) -#define tsip_transport_shutdown(transport) (transport ? tnet_transport_shutdown(transport->net_transport) : -1) +#define tsip_transport_shutdown(transport) (transport ? tnet_transport_shutdown(transport->net_transport) : -1) TINYSIP_GEXTERN const void *tsip_transport_def_t; diff --git a/trunk/tinySIP/src/transports/tsip_transport_ipsec.c b/trunk/tinySIP/src/transports/tsip_transport_ipsec.c index 1f9895ba..bc13f024 100644 --- a/trunk/tinySIP/src/transports/tsip_transport_ipsec.c +++ b/trunk/tinySIP/src/transports/tsip_transport_ipsec.c @@ -462,8 +462,8 @@ static void* tsip_ipsec_association_create(void * self, va_list * app) association->socket_uc = TNET_SOCKET_CREATE(ip_local, TNET_SOCKET_PORT_ANY, transport->type); /* Add Both sockets to the network transport */ - tsip_transport_add_socket(transport, association->socket_us->fd, 0); - tsip_transport_add_socket(transport, association->socket_uc->fd, 0); + tsip_transport_add_socket(transport, association->socket_us->fd, transport->type, 0, 0); + tsip_transport_add_socket(transport, association->socket_uc->fd, transport->type, 0, 1); /* Set local */ if(!tnet_get_peerip(transport->connectedFD, &ip_remote)){ /* Get remote IP string */ diff --git a/trunk/tinySIP/src/transports/tsip_transport_layer.c b/trunk/tinySIP/src/transports/tsip_transport_layer.c index 6e95eabd..266b9e01 100644 --- a/trunk/tinySIP/src/transports/tsip_transport_layer.c +++ b/trunk/tinySIP/src/transports/tsip_transport_layer.c @@ -474,7 +474,7 @@ int tsip_transport_layer_start(const tsip_transport_layer_t* self) } tsip_transport_set_callback(transport, TNET_SOCKET_TYPE_IS_DGRAM(transport->type) ? TNET_TRANSPORT_DATA_READ(tsip_transport_layer_dgram_data_read) : TNET_TRANSPORT_DATA_READ(tsip_transport_layer_stream_data_read), transport); - tsip_transport_connectto(transport, TSIP_STACK(self->stack)->proxy_cscf, TSIP_STACK(self->stack)->proxy_cscf_port); + tsip_transport_connectto2(transport, TSIP_STACK(self->stack)->proxy_cscf, TSIP_STACK(self->stack)->proxy_cscf_port); } /* FIXME: CONNECTED ?*/ diff --git a/trunk/tinySIP/src/tsip.c b/trunk/tinySIP/src/tsip.c index fc86f846..779efe30 100644 --- a/trunk/tinySIP/src/tsip.c +++ b/trunk/tinySIP/src/tsip.c @@ -276,8 +276,8 @@ int __tsip_stack_set(tsip_stack_t *self, va_list values) { return -1; } - } - } + }/* switch */ + }/* while */ return 0; } @@ -368,8 +368,7 @@ int tsip_stack_start(tsip_stack_handle_t *self) tsip_stack_t *stack = self; TSK_RUNNABLE(stack)->run = run; - if(ret = tsk_runnable_start(TSK_RUNNABLE(stack), tsip_event_def_t)) - { + if(ret = tsk_runnable_start(TSK_RUNNABLE(stack), tsip_event_def_t)){ return ret; } @@ -686,7 +685,7 @@ void *run(void* self) TSK_RUNNABLE_RUN_BEGIN(stack); - TSK_DEBUG_INFO("STACK::run -- START"); + TSK_DEBUG_INFO("SIP STACK::run -- START"); if((curr = TSK_RUNNABLE_POP_FIRST(stack))) { @@ -699,6 +698,6 @@ void *run(void* self) TSK_RUNNABLE_RUN_END(self); - TSK_DEBUG_INFO("STACK::run -- STOP"); + TSK_DEBUG_INFO("SIP STACK::run -- STOP"); return 0; } diff --git a/trunk/tinySIP/test/test/test_stack.h b/trunk/tinySIP/test/test/test_stack.h index 63000add..fa625c54 100644 --- a/trunk/tinySIP/test/test/test_stack.h +++ b/trunk/tinySIP/test/test/test_stack.h @@ -34,7 +34,7 @@ #define TEST_STACK_PIDF \ ""\ - ""\ + ""\ " "\ " "\ " open"\ @@ -223,13 +223,17 @@ int test_stack_callback(const tsip_event_t *sipevent) void test_stack() { +#define DOMAIN "ericsson.com" +//#define DOMAIN "ims.inexbee.com" +//#define DOMAIN "sip2sip.info" + /* tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, TSIP_STACK_SET_DISPLAY_NAME("2233392625"), - TSIP_STACK_SET_PUBLIC_IDENTITY("sip:2233392625@sip2sip.info"), + TSIP_STACK_SET_PUBLIC_IDENTITY("sip:2233392625@DOMAIN"), TSIP_STACK_SET_PRIVATE_IDENTITY("2233392625"), TSIP_STACK_SET_PASSWORD("d3sb7j4fb8"), - TSIP_STACK_SET_REALM("sip:sip2sip.info"), // FIXME: without sip: + TSIP_STACK_SET_REALM("sip:DOMAIN"), // FIXME: without sip: TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), //TSIP_STACK_SET_DISCOVERY_NAPTR(1), TSIP_STACK_SET_PROXY_CSCF("proxy.sipthor.net", "udp", 0), @@ -240,16 +244,16 @@ void test_stack() TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), TSIP_STACK_SET_PRIVACY("header;id"), */ -/* + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), - TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@ericsson.com"), - TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@ericsson.com"), + TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@"DOMAIN), + TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@"DOMAIN), TSIP_STACK_SET_PASSWORD("mamadou"), - TSIP_STACK_SET_REALM("sip:ericsson.com"), // FIXME: without sip: + TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip: TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), //TSIP_STACK_SET_DISCOVERY_NAPTR(1), - TSIP_STACK_SET_PROXY_CSCF("192.168.0.11", "udp", 0), + TSIP_STACK_SET_PROXY_CSCF("192.168.0.11", "tcp", 0), //TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0), TSIP_STACK_SET_PROXY_CSCF_PORT(5081), //TSIP_STACK_SET_SECAGREE_IPSEC("hmac-md5-96", "null", "trans", "esp"), @@ -257,14 +261,14 @@ void test_stack() TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"), TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), TSIP_STACK_SET_PRIVACY("header;id"), -*/ + /* tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), - TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@ims.inexbee.com"), - TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@ims.inexbee.com"), + TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@"DOMAIN), + TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@"DOMAIN), TSIP_STACK_SET_PASSWORD("mamadou"), - TSIP_STACK_SET_REALM("sip:ims.inexbee.com"), // FIXME: without sip: + TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip: TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), //TSIP_STACK_SET_DISCOVERY_NAPTR(1), TSIP_STACK_SET_PROXY_CSCF("pcscf.ims.inexbee.com", "udp", 1), @@ -276,12 +280,13 @@ void test_stack() TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), TSIP_STACK_SET_PRIVACY("header;id"), */ + /* tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), - TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@micromethod.com"), - TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@micromethod.com"), + TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@"DOMAIN), + TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@"DOMAIN), TSIP_STACK_SET_PASSWORD("mamadou"), - TSIP_STACK_SET_REALM("sip:micromethod.com"), // FIXME: without sip: + TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip: TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), //TSIP_STACK_SET_DISCOVERY_NAPTR(1), TSIP_STACK_SET_PROXY_CSCF("192.168.16.104", "udp", 0), @@ -292,7 +297,7 @@ void test_stack() TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"), TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), TSIP_STACK_SET_PRIVACY("header;id"), - +*/ TSIP_STACK_SET_NULL()); tsip_operation_handle_t *op = TSIP_OPERATION_CREATE(stack, @@ -329,7 +334,7 @@ void test_stack() /* MESSAGE */ //{ // tsip_operation_handle_t *op3 = TSIP_OPERATION_CREATE(stack, - // TSIP_OPERATION_SET_HEADER("to", "sip:laurent@micromethod.com"), + // TSIP_OPERATION_SET_HEADER("to", "sip:alice@"DOMAIN), // TSIP_OPERATION_SET_HEADER("Accept-Contact", "*;+g.oma.sip-im"), // TSIP_OPERATION_SET_HEADER("Content-Type", "text/plain"), @@ -343,7 +348,7 @@ void test_stack() { tsip_operation_handle_t *op4 = TSIP_OPERATION_CREATE(stack, TSIP_OPERATION_SET_HEADER("expires", "30"), - TSIP_OPERATION_SET_HEADER("to", "sip:mamadou@micromethod.com"), + TSIP_OPERATION_SET_HEADER("to", "sip:mamadou@"DOMAIN), TSIP_OPERATION_SET_HEADER("Content-Type", "application/pidf+xml"), TSIP_OPERATION_SET_HEADER("Accept-Contact", "*;+g.oma.sip-im"), TSIP_OPERATION_SET_HEADER("Event", "presence"), diff --git a/trunk/tinySIP/tinySIP.vcproj b/trunk/tinySIP/tinySIP.vcproj index ce61b9bb..1aef4e52 100644 --- a/trunk/tinySIP/tinySIP.vcproj +++ b/trunk/tinySIP/tinySIP.vcproj @@ -809,6 +809,10 @@ RelativePath=".\src\transports\tsip_transport_layer.c" > + + + +