Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
belle-sip
Commits
60e0bf1e
Commit
60e0bf1e
authored
Mar 21, 2012
by
Simon Morlat
Browse files
implement non-invite server transaction
parent
141ce1a0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
211 additions
and
14 deletions
+211
-14
src/Makefile.am
src/Makefile.am
+1
-0
src/belle_sip_internal.h
src/belle_sip_internal.h
+6
-2
src/ict.c
src/ict.c
+3
-0
src/ist.c
src/ist.c
+55
-0
src/nict.c
src/nict.c
+4
-0
src/nist.c
src/nist.c
+120
-0
src/transaction.c
src/transaction.c
+22
-12
No files found.
src/Makefile.am
View file @
60e0bf1e
...
...
@@ -48,6 +48,7 @@ libbellesip_la_SOURCES= \
siplistener.c
\
ict.c
\
nict.c
\
nist.c
\
transports/udp_listeningpoint.c
\
transports/udp_channel.c
\
transports/stream_channel.c
\
...
...
src/belle_sip_internal.h
View file @
60e0bf1e
...
...
@@ -502,8 +502,7 @@ struct belle_sip_transaction{
belle_sip_object_t
base
;
belle_sip_provider_t
*
provider
;
/*the provider that created this transaction */
belle_sip_request_t
*
request
;
belle_sip_response_t
*
prov_response
;
belle_sip_response_t
*
final_response
;
belle_sip_response_t
*
last_response
;
belle_sip_channel_t
*
channel
;
char
*
branch_id
;
belle_sip_transaction_state_t
state
;
...
...
@@ -594,8 +593,12 @@ struct belle_sip_server_transaction{
};
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN
(
belle_sip_server_transaction_t
,
belle_sip_transaction_t
)
int
(
*
send_new_response
)(
belle_sip_server_transaction_t
*
,
belle_sip_response_t
*
resp
);
void
(
*
on_request_retransmission
)(
belle_sip_server_transaction_t
*
obj
);
BELLE_SIP_DECLARE_CUSTOM_VPTR_END
void
belle_sip_server_transaction_init
(
belle_sip_server_transaction_t
*
t
,
belle_sip_provider_t
*
prov
,
belle_sip_request_t
*
req
);
struct
belle_sip_ist
{
belle_sip_server_transaction_t
base
;
};
...
...
@@ -609,6 +612,7 @@ belle_sip_ist_t * belle_sip_ist_new(belle_sip_provider_t *prov, belle_sip_reques
struct
belle_sip_nist
{
belle_sip_server_transaction_t
base
;
belle_sip_source_t
*
timer_J
;
};
typedef
struct
belle_sip_nist
belle_sip_nist_t
;
...
...
src/ict.c
View file @
60e0bf1e
...
...
@@ -16,6 +16,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* INVITE client transaction implementation.
**/
#include "belle_sip_internal.h"
...
...
src/ist.c
0 → 100644
View file @
60e0bf1e
/*
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/>.
*/
/**
*
INVITE
server
transaction
implementation
.
**
#include "belle_sip_internal.h"
static
void
ist_destroy
(
belle_sip_ist_t
*
obj
){
}
static
void
ist_on_terminate
(
belle_sip_ist_t
*
obj
){
// belle_sip_transaction_t *base=(belle_sip_transaction_t*)obj;
}
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES
(
belle_sip_ist_t
);
BELLE_SIP_INSTANCIATE_CUSTOM_VPTR
(
belle_sip_ist_t
)
=
{
{
{
{
BELLE_SIP_VPTR_INIT
(
belle_sip_ist_t
,
belle_sip_server_transaction_t
,
FALSE
),
(
belle_sip_object_destroy_t
)
ist_destroy
,
NULL
,
NULL
},
(
void
(
*
)(
belle_sip_transaction_t
*
))
ist_on_terminate
},
}
};
belle_sip_ist_t
*
belle_sip_ist_new
(
belle_sip_provider_t
*
prov
,
belle_sip_request_t
*
req
){
belle_sip_ist_t
*
obj
=
belle_sip_object_new
(
belle_sip_ist_t
);
belle_sip_server_transaction_init
((
belle_sip_server_transaction_t
*
)
obj
,
prov
,
req
);
return
obj
;
}
src/nict.c
View file @
60e0bf1e
...
...
@@ -17,6 +17,10 @@
*/
/**
* non-INVITE client transaction implementation.
**/
#include "belle_sip_internal.h"
static
void
nict_destroy
(
belle_sip_nict_t
*
obj
){
...
...
src/nist.c
0 → 100644
View file @
60e0bf1e
/*
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/>.
*/
/**
* non-INVITE server transaction implementation.
**/
#include "belle_sip_internal.h"
static
void
nist_destroy
(
belle_sip_nist_t
*
obj
){
}
static
void
nist_on_terminate
(
belle_sip_nist_t
*
obj
){
belle_sip_transaction_t
*
base
=
(
belle_sip_transaction_t
*
)
obj
;
if
(
obj
->
timer_J
){
belle_sip_transaction_stop_timer
(
base
,
obj
->
timer_J
);
belle_sip_object_unref
(
obj
->
timer_J
);
obj
->
timer_J
=
NULL
;
}
}
static
int
nist_on_timer_J
(
belle_sip_nist_t
*
obj
){
belle_sip_transaction_terminate
((
belle_sip_transaction_t
*
)
obj
);
return
BELLE_SIP_STOP
;
}
static
void
nist_set_completed
(
belle_sip_nist_t
*
obj
){
belle_sip_transaction_t
*
base
=
(
belle_sip_transaction_t
*
)
obj
;
const
belle_sip_timer_config_t
*
cfg
=
belle_sip_transaction_get_timer_config
(
base
);
int
tval
;
if
(
!
belle_sip_channel_is_reliable
(
base
->
channel
))
tval
=
cfg
->
T1
*
64
;
else
tval
=
0
;
obj
->
timer_J
=
belle_sip_timeout_source_new
((
belle_sip_source_func_t
)
nist_on_timer_J
,
obj
,
tval
);
belle_sip_transaction_start_timer
(
base
,
obj
->
timer_J
);
}
static
int
nist_send_new_response
(
belle_sip_nist_t
*
obj
,
belle_sip_response_t
*
resp
){
belle_sip_transaction_t
*
base
=
(
belle_sip_transaction_t
*
)
obj
;
int
code
=
belle_sip_response_get_status_code
(
resp
);
int
ret
=
0
;
switch
(
base
->
state
){
case
BELLE_SIP_TRANSACTION_TRYING
:
if
(
code
<
200
){
base
->
state
=
BELLE_SIP_TRANSACTION_PROCEEDING
;
belle_sip_channel_queue_message
(
base
->
channel
,(
belle_sip_message_t
*
)
base
->
last_response
);
}
break
;
case
BELLE_SIP_TRANSACTION_PROCEEDING
:
if
(
code
>=
200
){
nist_set_completed
(
obj
);
}
belle_sip_channel_queue_message
(
base
->
channel
,(
belle_sip_message_t
*
)
base
->
last_response
);
break
;
case
BELLE_SIP_TRANSACTION_COMPLETED
:
belle_sip_warning
(
"nist_send_new_response(): not allowed to send a response while transaction is completed."
);
ret
=-
1
;
/*not allowed to send a response at this time*/
break
;
default:
//ignore
break
;
}
return
ret
;
}
static
void
nist_on_request_retransmission
(
belle_sip_nist_t
*
obj
){
belle_sip_transaction_t
*
base
=
(
belle_sip_transaction_t
*
)
obj
;
switch
(
base
->
state
){
case
BELLE_SIP_TRANSACTION_PROCEEDING
:
case
BELLE_SIP_TRANSACTION_COMPLETED
:
belle_sip_channel_queue_message
(
base
->
channel
,(
belle_sip_message_t
*
)
base
->
last_response
);
break
;
default:
//ignore
break
;
}
}
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES
(
belle_sip_nist_t
);
BELLE_SIP_INSTANCIATE_CUSTOM_VPTR
(
belle_sip_nist_t
)
=
{
{
{
{
BELLE_SIP_VPTR_INIT
(
belle_sip_nist_t
,
belle_sip_server_transaction_t
,
FALSE
),
(
belle_sip_object_destroy_t
)
nist_destroy
,
NULL
,
NULL
},
(
void
(
*
)(
belle_sip_transaction_t
*
))
nist_on_terminate
},
(
int
(
*
)(
belle_sip_server_transaction_t
*
,
belle_sip_response_t
*
))
nist_send_new_response
,
(
void
(
*
)(
belle_sip_server_transaction_t
*
))
nist_on_request_retransmission
,
}
};
belle_sip_nist_t
*
belle_sip_nist_new
(
belle_sip_provider_t
*
prov
,
belle_sip_request_t
*
req
){
belle_sip_nist_t
*
obj
=
belle_sip_object_new
(
belle_sip_nist_t
);
belle_sip_transaction_t
*
base
=
(
belle_sip_transaction_t
*
)
obj
;
belle_sip_server_transaction_init
((
belle_sip_server_transaction_t
*
)
obj
,
prov
,
req
);
base
->
state
=
BELLE_SIP_TRANSACTION_TRYING
;
return
obj
;
}
src/transaction.c
View file @
60e0bf1e
...
...
@@ -46,8 +46,7 @@ static void belle_sip_transaction_init(belle_sip_transaction_t *t, belle_sip_pro
static
void
transaction_destroy
(
belle_sip_transaction_t
*
t
){
if
(
t
->
request
)
belle_sip_object_unref
(
t
->
request
);
if
(
t
->
prov_response
)
belle_sip_object_unref
(
t
->
prov_response
);
if
(
t
->
final_response
)
belle_sip_object_unref
(
t
->
final_response
);
if
(
t
->
last_response
)
belle_sip_object_unref
(
t
->
last_response
);
if
(
t
->
channel
)
belle_sip_object_unref
(
t
->
channel
);
}
...
...
@@ -125,14 +124,28 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR(belle_sip_server_transaction_t)={
}
};
belle_sip_server_transaction_t
*
belle_sip_server_transaction_new
(
belle_sip_provider_t
*
prov
,
belle_sip_request_t
*
req
){
belle_sip_server_transaction_t
*
t
=
belle_sip_object_new
(
belle_sip_server_transaction_t
);
void
belle_sip_server_transaction_init
(
belle_sip_server_transaction_t
*
t
,
belle_sip_provider_t
*
prov
,
belle_sip_request_t
*
req
){
belle_sip_transaction_init
((
belle_sip_transaction_t
*
)
t
,
prov
,
req
);
return
t
;
}
void
belle_sip_server_transaction_send_response
(
belle_sip_server_transaction_t
*
t
,
belle_sip_response_t
*
resp
){
//BELLE_SIP_OBJECT_VPTR(t,belle_sip_transaction_t)->on_response((belle_sip_transaction_t*)t,resp);
belle_sip_transaction_t
*
base
=
(
belle_sip_transaction_t
*
)
t
;
belle_sip_object_ref
(
resp
);
if
(
!
base
->
last_response
){
belle_sip_hop_t
hop
;
belle_sip_response_get_return_hop
(
resp
,
&
hop
);
base
->
channel
=
belle_sip_provider_get_channel
(
base
->
provider
,
hop
.
host
,
hop
.
port
,
hop
.
transport
);
belle_sip_object_ref
(
base
->
channel
);
}
if
(
BELLE_SIP_OBJECT_VPTR
(
t
,
belle_sip_server_transaction_t
)
->
send_new_response
(
t
,
resp
)
==
0
){
if
(
base
->
last_response
)
belle_sip_object_unref
(
base
->
last_response
);
base
->
last_response
=
resp
;
}
}
void
belle_sip_server_transaction_on_retransmission
(
belle_sip_server_transaction_t
*
t
){
BELLE_SIP_OBJECT_VPTR
(
t
,
belle_sip_server_transaction_t
)
->
on_request_retransmission
(
t
);
}
/*
...
...
@@ -196,9 +209,9 @@ void belle_sip_client_transaction_notify_response(belle_sip_client_transaction_t
belle_sip_transaction_t
*
base
=
(
belle_sip_transaction_t
*
)
t
;
belle_sip_response_event_t
event
;
if
(
base
->
prov
_response
)
belle_sip_object_unref
(
base
->
prov
_response
);
base
->
prov
_response
=
(
belle_sip_response_t
*
)
belle_sip_object_ref
(
resp
);
if
(
base
->
last
_response
)
belle_sip_object_unref
(
base
->
last
_response
);
base
->
last
_response
=
(
belle_sip_response_t
*
)
belle_sip_object_ref
(
resp
);
event
.
source
=
base
->
provider
;
event
.
client_transaction
=
t
;
...
...
@@ -271,7 +284,4 @@ belle_sip_ist_t *belle_sip_ist_new(belle_sip_provider_t *prov, belle_sip_request
return
NULL
;
}
belle_sip_nist_t
*
belle_sip_nist_new
(
belle_sip_provider_t
*
prov
,
belle_sip_request_t
*
req
){
return
NULL
;
}
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