Commit 0e2312ad authored by Simon Morlat's avatar Simon Morlat

http support started

parent 62ee9e23
......@@ -113,14 +113,18 @@ BELLE_SIP_DECLARE_TYPES_BEGIN(belle_sip,1)
BELLE_SIP_TYPE_ID(belle_sip_signing_key_t),
BELLE_SIP_TYPE_ID(belle_sip_dns_srv_t),
BELLE_SIP_TYPE_ID(belle_sip_simple_resolver_context_t),
BELLE_SIP_TYPE_ID(belle_sip_combined_resolver_context_t)
BELLE_SIP_TYPE_ID(belle_sip_combined_resolver_context_t),
BELLE_SIP_TYPE_ID(belle_http_provider_t),
BELLE_SIP_TYPE_ID(belle_http_request_t),
BELLE_SIP_TYPE_ID(belle_http_response_t)
BELLE_SIP_DECLARE_TYPES_END
enum belle_sip_interface_ids{
belle_sip_interface_id_first=1,
BELLE_SIP_INTERFACE_ID(belle_sip_channel_listener_t),
BELLE_SIP_INTERFACE_ID(belle_sip_listener_t)
BELLE_SIP_INTERFACE_ID(belle_sip_listener_t),
BELLE_SIP_INTERFACE_ID(belle_http_request_listener_t)
};
BELLE_SIP_BEGIN_DECLS
......@@ -139,6 +143,7 @@ typedef struct belle_sip_listening_point belle_sip_listening_point_t;
typedef struct belle_sip_tls_listening_point belle_sip_tls_listening_point_t;
typedef struct belle_sip_stack belle_sip_stack_t;
typedef struct belle_sip_provider belle_sip_provider_t;
typedef struct belle_http_provider belle_http_provider_t;
typedef struct belle_sip_dialog belle_sip_dialog_t;
typedef struct belle_sip_transaction belle_sip_transaction_t;
typedef struct belle_sip_server_transaction belle_sip_server_transaction_t;
......@@ -146,6 +151,8 @@ typedef struct belle_sip_client_transaction belle_sip_client_transaction_t;
typedef struct _belle_sip_message belle_sip_message_t;
typedef struct _belle_sip_request belle_sip_request_t;
typedef struct _belle_sip_response belle_sip_response_t;
typedef struct _belle_http_request belle_http_request_t;
typedef struct _belle_http_response belle_http_response_t;
typedef struct belle_sip_hop belle_sip_hop_t;
#include "belle-sip/utils.h"
......@@ -164,7 +171,8 @@ typedef struct belle_sip_hop belle_sip_hop_t;
#include "belle-sip/listeningpoint.h"
#include "belle-sip/provider.h"
#include "belle-sip/auth-helper.h"
#include "belle-sip/http-listener.h"
#include "belle-sip/http-provider.h"
#undef TRUE
......
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
This program 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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef belle_http_listener_h
#define belle_http_listener_h
struct belle_http_response_event{
belle_http_provider_t *provider;
belle_http_request_t *request;
belle_http_response_t *response;
};
typedef struct belle_http_response_event belle_http_response_event_t;
struct belle_http_io_error_event{
belle_http_provider_t *provider;
belle_http_request_t *request;
};
typedef struct belle_http_io_error_event belle_http_io_error_event_t;
typedef struct belle_http_io_error_event belle_http_timeout_event;
#define BELLE_HTTP_INTERFACE_FUNCS(argT) \
void (*process_response_event)(argT *user_ctx, const belle_http_response_event_t *event); \
void (*process_io_error)(argT *user_ctx, const belle_sip_io_error_event_t *event); \
void (*process_timeout)(argT *user_ctx, const belle_sip_timeout_event_t *event); \
void (*process_auth_requested)(argT *user_ctx, belle_sip_auth_event_t *event);
BELLE_SIP_DECLARE_INTERFACE_BEGIN(belle_http_request_listener_t)
BELLE_HTTP_INTERFACE_FUNCS(belle_http_request_listener_t)
BELLE_SIP_DECLARE_INTERFACE_END
struct belle_http_request_listener_callbacks{
BELLE_HTTP_INTERFACE_FUNCS(void*)
};
typedef struct belle_http_request_listener_callbacks belle_http_request_listener_callbacks_t;
BELLE_SIP_BEGIN_DECLS
/**
* Creates an object implementing the belle_http_request_listener_t interface.
* This object passes the events to the callbacks, providing also the user context.
**/
BELLESIP_EXPORT belle_http_request_listener_t *belle_http_request_listener_create_from_callbacks(const belle_http_request_listener_callbacks_t *callbacks, void *user_ctx);
BELLE_SIP_END_DECLS
#endif
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
This program 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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef belle_sip_http_provider_h
#define belle_sip_http_provider_h
BELLE_SIP_BEGIN_DECLS
BELLESIP_EXPORT void belle_http_provider_send_request(belle_http_provider_t *obj, belle_http_request_t *req, belle_http_request_listener_t *listener);
BELLE_SIP_END_DECLS
#endif
......@@ -40,6 +40,8 @@ BELLESIP_EXPORT void belle_sip_stack_delete_listening_point(belle_sip_stack_t *s
BELLESIP_EXPORT belle_sip_provider_t *belle_sip_stack_create_provider(belle_sip_stack_t *s, belle_sip_listening_point_t *lp);
BELLESIP_EXPORT belle_http_provider_t * belle_sip_stack_create_http_provider(belle_sip_stack_t *s);
BELLESIP_EXPORT belle_sip_main_loop_t* belle_sip_stack_get_main_loop(belle_sip_stack_t *stack);
BELLESIP_EXPORT void belle_sip_stack_main(belle_sip_stack_t *stack);
......
......@@ -553,6 +553,10 @@ typedef struct listener_ctx{
#define BELLE_SIP_PROVIDER_INVOKE_LISTENERS(listeners,callback,event) \
BELLE_SIP_INVOKE_LISTENERS_ARG((listeners),belle_sip_listener_t,callback,(event))
/*
* http provider
*/
belle_http_provider_t *belle_http_provider_new(belle_sip_stack_t *s);
struct _belle_sip_message {
belle_sip_object_t base;
......
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
This program 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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "belle_sip_internal.h"
struct belle_http_provider{
belle_sip_stack_t *stack;
belle_sip_list_t *tcp_channels;
belle_sip_list_t *tls_channels;
};
static int channel_on_event(belle_sip_channel_listener_t *obj, belle_sip_channel_t *chan, unsigned int revents){
if (revents & BELLE_SIP_EVENT_READ){
belle_sip_message_t *msg;
while ((msg=belle_sip_channel_pick_message(chan)))
belle_sip_provider_dispatch_message(BELLE_SIP_PROVIDER(obj),msg);
}
return 0;
}
static int channel_on_auth_requested(belle_sip_channel_listener_t *obj, belle_sip_channel_t *chan, const char* distinguished_name){
if (BELLE_SIP_IS_INSTANCE_OF(chan,belle_sip_tls_channel_t)) {
belle_http_provider_t *prov=BELLE_SIP_PROVIDER(obj);
belle_sip_auth_event_t* auth_event = belle_sip_auth_event_create(NULL,NULL);
belle_sip_tls_channel_t *tls_chan=BELLE_SIP_TLS_CHANNEL(chan);
auth_event->mode=BELLE_SIP_AUTH_MODE_TLS;
belle_sip_auth_event_set_distinguished_name(auth_event,distinguished_name);
/*
BELLE_SIP_PROVIDER_INVOKE_LISTENERS(prov->listeners,process_auth_requested,auth_event);
belle_sip_tls_channel_set_client_certificates_chain(tls_chan,auth_event->cert);
belle_sip_tls_channel_set_client_certificate_key(tls_chan,auth_event->key);
belle_sip_auth_event_destroy(auth_event);
*/
}
return 0;
}
static void channel_on_sending(belle_sip_channel_listener_t *obj, belle_sip_channel_t *chan, belle_sip_message_t *msg){
}
BELLE_SIP_IMPLEMENT_INTERFACE_BEGIN(belle_http_provider_t,belle_sip_channel_listener_t)
channel_state_changed,
channel_on_event,
channel_on_sending,
channel_on_auth_requested
BELLE_SIP_IMPLEMENT_INTERFACE_END
BELLE_SIP_DECLARE_IMPLEMENTED_INTERFACES_1(belle_http_provider_t,belle_sip_channel_listener_t);
static void http_provider_uninit(belle_http_provider_t *obj){
}
BELLE_SIP_INSTANCIATE_VPTR(belle_http_provider_t,belle_sip_object_t,http_provider_uninit,NULL,NULL,FALSE);
belle_sip_provider_t *belle_http_provider_new(belle_sip_stack_t *s){
belle_sip_provider_t *p=belle_sip_object_new(belle_http_provider_t);
p->stack=s;
return p;
}
......@@ -134,6 +134,11 @@ belle_sip_provider_t *belle_sip_stack_create_provider(belle_sip_stack_t *s, bell
return p;
}
belle_http_provider_t *belle_sip_stack_create_http_provider(belle_sip_stack_t *s){
belle_http_provider_t *p=belle_http_provider_new(s);
return p;
}
void belle_sip_stack_delete_provider(belle_sip_stack_t *s, belle_sip_provider_t *p){
belle_sip_object_unref(p);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment