Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
belle-sip
Commits
957298c1
Commit
957298c1
authored
Dec 05, 2013
by
Simon Morlat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http in progress
parent
934dd1d9
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
69 additions
and
29 deletions
+69
-29
include/belle-sip/belle-sip.h
include/belle-sip/belle-sip.h
+1
-0
include/belle-sip/http-message.h
include/belle-sip/http-message.h
+1
-0
include/belle-sip/http-provider.h
include/belle-sip/http-provider.h
+1
-1
include/belle-sip/sipstack.h
include/belle-sip/sipstack.h
+1
-1
src/belle_sip_internal.h
src/belle_sip_internal.h
+1
-1
src/channel.c
src/channel.c
+28
-0
src/channel.h
src/channel.h
+3
-0
src/http-message.c
src/http-message.c
+4
-0
src/http-provider.c
src/http-provider.c
+25
-3
src/listeningpoint.c
src/listeningpoint.c
+2
-21
src/sipstack.c
src/sipstack.c
+2
-2
No files found.
include/belle-sip/belle-sip.h
View file @
957298c1
...
...
@@ -175,6 +175,7 @@ typedef struct belle_http_url belle_http_url_t;
#include "belle-sip/auth-helper.h"
#include "belle-sip/http-listener.h"
#include "belle-sip/http-provider.h"
#include "belle-sip/http-message.h"
#undef TRUE
...
...
include/belle-sip/http-message.h
View file @
957298c1
...
...
@@ -24,6 +24,7 @@
BELLE_SIP_BEGIN_DECLS
belle_http_url_t
*
belle_http_request_get_url
(
belle_http_request_t
*
req
);
BELLE_SIP_END_DECLS
...
...
include/belle-sip/http-provider.h
View file @
957298c1
...
...
@@ -25,7 +25,7 @@ BELLE_SIP_BEGIN_DECLS
#define BELLE_SIP_HTTP_PROVIDER(obj) BELLE_SIP_CAST(obj,belle_http_provider_t)
BELLESIP_EXPORT
void
belle_http_provider_send_request
(
belle_http_provider_t
*
obj
,
belle_http_request_t
*
req
,
belle_http_request_listener_t
*
listener
);
BELLESIP_EXPORT
int
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
...
...
include/belle-sip/sipstack.h
View file @
957298c1
...
...
@@ -40,7 +40,7 @@ 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_http_provider_t
*
belle_sip_stack_create_http_provider
(
belle_sip_stack_t
*
s
,
const
char
*
bind_ip
);
BELLESIP_EXPORT
belle_sip_main_loop_t
*
belle_sip_stack_get_main_loop
(
belle_sip_stack_t
*
stack
);
...
...
src/belle_sip_internal.h
View file @
957298c1
...
...
@@ -560,7 +560,7 @@ typedef struct listener_ctx{
/*
* http provider
*/
belle_http_provider_t
*
belle_http_provider_new
(
belle_sip_stack_t
*
s
);
belle_http_provider_t
*
belle_http_provider_new
(
belle_sip_stack_t
*
s
,
const
char
*
bind_ip
);
/*
...
...
src/channel.c
View file @
957298c1
...
...
@@ -783,4 +783,32 @@ void belle_sip_channel_force_close(belle_sip_channel_t *obj){
channel_set_state
(
obj
,
BELLE_SIP_CHANNEL_DISCONNECTED
);
}
belle_sip_channel_t
*
belle_sip_channel_find_from_list_with_addrinfo
(
belle_sip_list_t
*
l
,
const
belle_sip_hop_t
*
hop
,
const
struct
addrinfo
*
addr
){
belle_sip_list_t
*
elem
;
belle_sip_channel_t
*
chan
;
for
(
elem
=
l
;
elem
!=
NULL
;
elem
=
elem
->
next
){
chan
=
(
belle_sip_channel_t
*
)
elem
->
data
;
if
(
belle_sip_channel_matches
(
chan
,
hop
,
addr
)){
return
chan
;
}
}
return
NULL
;
}
belle_sip_channel_t
*
belle_sip_channel_find_from_list
(
belle_sip_list_t
*
l
,
const
belle_sip_hop_t
*
hop
){
struct
addrinfo
*
res
=
NULL
;
struct
addrinfo
hints
=
{
0
};
char
portstr
[
20
];
belle_sip_channel_t
*
chan
;
hints
.
ai_flags
=
AI_NUMERICHOST
|
AI_NUMERICSERV
;
snprintf
(
portstr
,
sizeof
(
portstr
),
"%i"
,
hop
->
port
);
getaddrinfo
(
hop
->
host
,
portstr
,
&
hints
,
&
res
);
chan
=
belle_sip_channel_find_from_list_with_addrinfo
(
l
,
hop
,
res
);
if
(
res
)
freeaddrinfo
(
res
);
return
chan
;
}
src/channel.h
View file @
957298c1
...
...
@@ -182,6 +182,9 @@ BELLE_SIP_DECLARE_CUSTOM_VPTR_END
void
belle_sip_tls_channel_set_client_certificates_chain
(
belle_sip_tls_channel_t
*
obj
,
belle_sip_certificates_chain_t
*
cert_chain
);
void
belle_sip_tls_channel_set_client_certificate_key
(
belle_sip_tls_channel_t
*
obj
,
belle_sip_signing_key_t
*
key
);
belle_sip_channel_t
*
belle_sip_channel_find_from_list_with_addrinfo
(
belle_sip_list_t
*
l
,
const
belle_sip_hop_t
*
hop
,
const
struct
addrinfo
*
addr
);
belle_sip_channel_t
*
belle_sip_channel_find_from_list
(
belle_sip_list_t
*
l
,
const
belle_sip_hop_t
*
hop
);
#define BELLE_SIP_TLS_CHANNEL(obj) BELLE_SIP_CAST(obj,belle_sip_tls_channel_t)
#endif
src/http-message.c
View file @
957298c1
...
...
@@ -61,3 +61,7 @@ void belle_http_request_set_listener(belle_http_request_t *req, belle_http_reque
if
(
l
)
belle_sip_object_weak_ref
(
l
,(
belle_sip_object_destroy_notify_t
)
belle_http_request_listener_destroyed
,
req
);
}
belle_http_url_t
*
belle_http_request_get_url
(
belle_http_request_t
*
req
){
return
req
->
req_url
;
}
src/http-provider.c
View file @
957298c1
...
...
@@ -30,6 +30,7 @@ struct belle_http_channel_context{
struct
belle_http_provider
{
belle_sip_stack_t
*
stack
;
char
*
bind_ip
;
belle_sip_list_t
*
tcp_channels
;
belle_sip_list_t
*
tls_channels
;
};
...
...
@@ -103,15 +104,36 @@ static void http_provider_uninit(belle_http_provider_t *obj){
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES
(
belle_http_provider_t
);
BELLE_SIP_INSTANCIATE_VPTR
(
belle_http_provider_t
,
belle_sip_object_t
,
http_provider_uninit
,
NULL
,
NULL
,
FALSE
);
belle_http_provider_t
*
belle_http_provider_new
(
belle_sip_stack_t
*
s
){
belle_http_provider_t
*
belle_http_provider_new
(
belle_sip_stack_t
*
s
,
const
char
*
bind_ip
){
belle_http_provider_t
*
p
=
belle_sip_object_new
(
belle_http_provider_t
);
p
->
stack
=
s
;
p
->
bind_ip
=
belle_sip_strdup
(
bind_ip
);
return
p
;
}
void
belle_http_provider_send_request
(
belle_http_provider_t
*
obj
,
belle_http_request_t
*
req
,
belle_http_request_listener_t
*
listener
){
/*belle_sip_channel_t *chan;*/
int
belle_http_provider_send_request
(
belle_http_provider_t
*
obj
,
belle_http_request_t
*
req
,
belle_http_request_listener_t
*
listener
){
belle_sip_channel_t
*
chan
;
belle_sip_hop_t
*
hop
=
NULL
;
//belle_sip_hop_new_from_uri(belle_http_request_get_url(req));
belle_sip_list_t
**
channels
=
NULL
;
if
(
strcasecmp
(
hop
->
transport
,
"tcp"
)
==
0
)
channels
=&
obj
->
tcp_channels
;
else
if
(
strcasecmp
(
hop
->
transport
,
"tls"
)
==
0
)
channels
=&
obj
->
tls_channels
;
else
{
belle_sip_error
(
"belle_http_provider_send_request(): unsupported transport %s"
,
hop
->
transport
);
return
-
1
;
}
belle_http_request_set_listener
(
req
,
listener
);
chan
=
belle_sip_channel_find_from_list
(
*
channels
,
hop
);
if
(
!
chan
){
chan
=
belle_sip_stream_channel_new_client
(
obj
->
stack
,
obj
->
bind_ip
,
0
,
hop
->
cname
,
hop
->
host
,
hop
->
port
);
belle_http_channel_context_new
(
chan
);
*
channels
=
belle_sip_list_prepend
(
*
channels
,
chan
);
}
belle_sip_object_unref
(
hop
);
belle_sip_channel_queue_message
(
chan
,
BELLE_SIP_MESSAGE
(
req
));
return
0
;
}
src/listeningpoint.c
View file @
957298c1
...
...
@@ -129,30 +129,11 @@ int belle_sip_listening_point_get_well_known_port(const char *transport){
}
belle_sip_channel_t
*
_belle_sip_listening_point_get_channel
(
belle_sip_listening_point_t
*
lp
,
const
belle_sip_hop_t
*
hop
,
const
struct
addrinfo
*
addr
){
belle_sip_list_t
*
elem
;
belle_sip_channel_t
*
chan
;
for
(
elem
=
lp
->
channels
;
elem
!=
NULL
;
elem
=
elem
->
next
){
chan
=
(
belle_sip_channel_t
*
)
elem
->
data
;
if
(
belle_sip_channel_matches
(
chan
,
hop
,
addr
)){
return
chan
;
}
}
return
NULL
;
return
belle_sip_channel_find_from_list_with_addrinfo
(
lp
->
channels
,
hop
,
addr
);
}
belle_sip_channel_t
*
belle_sip_listening_point_get_channel
(
belle_sip_listening_point_t
*
lp
,
const
belle_sip_hop_t
*
hop
){
struct
addrinfo
*
res
=
NULL
;
struct
addrinfo
hints
=
{
0
};
char
portstr
[
20
];
belle_sip_channel_t
*
chan
;
hints
.
ai_flags
=
AI_NUMERICHOST
|
AI_NUMERICSERV
;
snprintf
(
portstr
,
sizeof
(
portstr
),
"%i"
,
hop
->
port
);
getaddrinfo
(
hop
->
host
,
portstr
,
&
hints
,
&
res
);
chan
=
_belle_sip_listening_point_get_channel
(
lp
,
hop
,
res
);
if
(
res
)
freeaddrinfo
(
res
);
return
chan
;
return
belle_sip_channel_find_from_list
(
lp
->
channels
,
hop
);
}
static
int
send_keep_alive
(
belle_sip_channel_t
*
obj
)
{
...
...
src/sipstack.c
View file @
957298c1
...
...
@@ -134,8 +134,8 @@ 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
);
belle_http_provider_t
*
belle_sip_stack_create_http_provider
(
belle_sip_stack_t
*
s
,
const
char
*
bind_ip
){
belle_http_provider_t
*
p
=
belle_http_provider_new
(
s
,
bind_ip
);
return
p
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment