blob: 9bb760b8907f075857d0830fedf53592ead9bd62 [file] [log] [blame]
Alexandre Lision8af73cb2013-12-10 14:11:20 -05001/* $Id$ */
2/*
3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __PJSIP_TRANSPORT_LOOP_H__
21#define __PJSIP_TRANSPORT_LOOP_H__
22
23
24/**
25 * @file sip_transport_loop.h
26 * @brief
27 * Loopback transport (for debugging)
28 */
29
30
31#include <pjsip/sip_transport.h>
32
33/**
34 * @defgroup PJSIP_TRANSPORT_LOOP Loop Transport
35 * @ingroup PJSIP_TRANSPORT
36 * @brief Loopback transport (for testing purposes).
37 * @{
38 * The loopback transport simply bounce back outgoing messages as
39 * incoming messages. This feature is used mostly during automated
40 * testing, to provide controlled behavior.
41 */
42
43PJ_BEGIN_DECL
44
45/**
46 * Create and start datagram loop transport.
47 *
48 * @param endpt The endpoint instance.
49 * @param transport Pointer to receive the transport instance.
50 *
51 * @return PJ_SUCCESS on success.
52 */
53PJ_DECL(pj_status_t) pjsip_loop_start( pjsip_endpoint *endpt,
54 pjsip_transport **transport);
55
56
57/**
58 * Enable/disable flag to discard any packets sent using the specified
59 * loop transport.
60 *
61 * @param tp The loop transport.
62 * @param discard If non-zero, any outgoing packets will be discarded.
63 * @param prev_value Optional argument to receive previous value of
64 * the discard flag.
65 *
66 * @return PJ_SUCCESS on success.
67 */
68PJ_DECL(pj_status_t) pjsip_loop_set_discard( pjsip_transport *tp,
69 pj_bool_t discard,
70 pj_bool_t *prev_value );
71
72
73/**
74 * Enable/disable flag to simulate network error. When this flag is set,
75 * outgoing transmission will return either immediate error or error via
76 * callback. If error is to be notified via callback, then the notification
77 * will occur after some delay, which is controlled by #pjsip_loop_set_delay().
78 *
79 * @param tp The loop transport.
80 * @param fail_flag If set to 1, the transport will return fail to deliver
81 * the message. If delay is zero, failure will occur
82 * immediately; otherwise it will be reported in callback.
83 * If set to zero, the transport will successfully deliver
84 * the packet.
85 * @param prev_value Optional argument to receive previous value of
86 * the failure flag.
87 *
88 * @return PJ_SUCCESS on success.
89 */
90PJ_DECL(pj_status_t) pjsip_loop_set_failure( pjsip_transport *tp,
91 int fail_flag,
92 int *prev_value );
93
94
95/**
96 * Set delay (in miliseconds) before packet is received by the other end
97 * of the loop transport. This will also
98 * control the delay for error notification callback.
99 *
100 * @param tp The loop transport.
101 * @param delay Delay, in miliseconds.
102 * @param prev_value Optional argument to receive previous value of the
103 * delay.
104 *
105 * @return PJ_SUCCESS on success.
106 */
107PJ_DECL(pj_status_t) pjsip_loop_set_recv_delay( pjsip_transport *tp,
108 unsigned delay,
109 unsigned *prev_value);
110
111
112/**
113 * Set delay (in miliseconds) before send notification is delivered to sender.
114 * This will also control the delay for error notification callback.
115 *
116 * @param tp The loop transport.
117 * @param delay Delay, in miliseconds.
118 * @param prev_value Optional argument to receive previous value of the
119 * delay.
120 *
121 * @return PJ_SUCCESS on success.
122 */
123PJ_DECL(pj_status_t) pjsip_loop_set_send_callback_delay( pjsip_transport *tp,
124 unsigned delay,
125 unsigned *prev_value);
126
127
128/**
129 * Set both receive and send notification delay.
130 *
131 * @param tp The loop transport.
132 * @param delay Delay, in miliseconds.
133 *
134 * @return PJ_SUCCESS on success.
135 */
136PJ_DECL(pj_status_t) pjsip_loop_set_delay( pjsip_transport *tp,
137 unsigned delay );
138
139
140PJ_END_DECL
141
142/**
143 * @}
144 */
145
146#endif /* __PJSIP_TRANSPORT_LOOP_H__ */
147