summaryrefslogtreecommitdiff
path: root/pjsip/include/pjsip/sip_transport_loop.h
blob: 3cc2af86723dc88d7a552e092b2a30dfd2ea49a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* $Id$ */
/* 
 * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
 *
 * 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 2 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 */
#ifndef __PJSIP_TRANSPORT_LOOP_H__
#define __PJSIP_TRANSPORT_LOOP_H__

#include <pjsip/sip_transport.h>

PJ_BEGIN_DECL

/**
 * Create and start datagram loop transport.
 *
 * @param endpt		The endpoint instance.
 * @param transport	Pointer to receive the transport instance.
 *
 * @return		PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t) pjsip_loop_start( pjsip_endpoint *endpt,
				       pjsip_transport **transport);


/**
 * Enable/disable flag to discard any packets sent using the specified
 * loop transport.
 *
 * @param tp		The loop transport.
 * @param discard	If non-zero, any outgoing packets will be discarded.
 * @param prev_value	Optional argument to receive previous value of
 *			the discard flag.
 *
 * @return		PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t) pjsip_loop_set_discard( pjsip_transport *tp,
					     pj_bool_t discard,
					     pj_bool_t *prev_value );


/**
 * Enable/disable flag to simulate network error. When this flag is set,
 * outgoing transmission will return either immediate error or error via
 * callback. If error is to be notified via callback, then the notification
 * will occur after some delay, which is controlled by #pjsip_loop_set_delay().
 *
 * @param tp		The loop transport.
 * @param fail_flag	If set to 1, the transport will return fail to deliver
 *			the message. If delay is zero, failure will occur
 *			immediately; otherwise it will be reported in callback.
 *			If set to zero, the transport will successfully deliver
 *			the packet.
 * @param prev_value	Optional argument to receive previous value of
 *			the failure flag.
 *
 * @return		PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t) pjsip_loop_set_failure( pjsip_transport *tp,
					     int fail_flag,
					     int *prev_value );


/**
 * Set delay (in miliseconds) before packet is received by the other end
 * of the loop transport. This will also 
 * control the delay for error notification callback.
 *
 * @param tp		The loop transport.
 * @param delay		Delay, in miliseconds.
 * @param prev_value	Optional argument to receive previous value of the
 *			delay.
 *
 * @return		PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t) pjsip_loop_set_recv_delay( pjsip_transport *tp,
						unsigned delay,
						unsigned *prev_value);


/**
 * Set delay (in miliseconds) before send notification is delivered to sender.
 * This will also control the delay for error notification callback.
 *
 * @param tp		The loop transport.
 * @param delay		Delay, in miliseconds.
 * @param prev_value	Optional argument to receive previous value of the
 *			delay.
 *
 * @return		PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t) pjsip_loop_set_send_callback_delay( pjsip_transport *tp,
							 unsigned delay,
							 unsigned *prev_value);


/**
 * Set both receive and send notification delay.
 *
 * @param tp		The loop transport.
 * @param delay		Delay, in miliseconds.
 *
 * @return		PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t) pjsip_loop_set_delay( pjsip_transport *tp,
					   unsigned delay );


PJ_END_DECL


#endif	/* __PJSIP_TRANSPORT_LOOP_H__ */