summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsip/sip_event.h
blob: ac7bc6915c55c59abd0c4609f389f39e615980cd (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
126
127
128
129
130
131
132
133
/* $Id$
 *
 */
#ifndef __PJSIP_SIP_EVENT_H__
#define __PJSIP_SIP_EVENT_H__

/**
 * @file sip_event.h
 * @brief SIP Event
 */

PJ_BEGIN_DECL

/**
 * @defgroup PJSIP_EVENT SIP Event
 * @ingroup PJSIP
 * @{
 */
#include <pj/types.h>


/** 
 * Event IDs.
 */
typedef enum pjsip_event_id_e
{
    /** Unidentified event. */
    PJSIP_EVENT_UNIDENTIFIED,

    /** Timer event, normally only used internally in transaction. */
    PJSIP_EVENT_TIMER,

    /** Message transmission event. */
    PJSIP_EVENT_TX_MSG,

    /** Message received event. */
    PJSIP_EVENT_RX_MSG,

    /** Transport error event. */
    PJSIP_EVENT_TRANSPORT_ERROR,

    /** Transaction state changed event. */
    PJSIP_EVENT_TSX_STATE_CHANGED,

    /** 2xx response received event. */
    PJSIP_EVENT_RX_200_RESPONSE,

    /** ACK request received event. */
    PJSIP_EVENT_RX_ACK_MSG,

    /** Message discarded event. */
    PJSIP_EVENT_DISCARD_MSG,

    /** Indicates that the event was triggered by user action. */
    PJSIP_EVENT_USER,

    /** On before transmitting message. */
    PJSIP_EVENT_BEFORE_TX,

} pjsip_event_id_e;


/**
 * \struct
 * \brief Event descriptor to fully identify a SIP event.
 *
 * Events are the only way for a lower layer object to inform something
 * to higher layer objects. Normally this is achieved by means of callback,
 * i.e. the higher layer objects register a callback to handle the event on
 * the lower layer objects.
 *
 * This event descriptor is used for example by transactions, to inform
 * endpoint about events, and by transports, to inform endpoint about
 * unexpected transport error.
 */
struct pjsip_event
{
    /** This is necessary so that we can put events as a list. */
    PJ_DECL_LIST_MEMBER(struct pjsip_event)

    /** The event type, can be any value of \b pjsip_event_id_e.
     *  @see pjsip_event_id_e
     */
    pjsip_event_id_e type;

    /** This field determines what is the content of \b src (source data). 
     */
    pjsip_event_id_e src_type;

    /** Source data, which content is dependent on \b src_type.
     *  - if src_type==PJSIP_EVENT_RX_MSG, src.rdata is valid.
     *  - if src_type==PJSIP_EVENT_TX_MSG, src.tdata is valid.
     *  - if src_type==PJSIP_EVENT_TIMER, src.timer is valid.
     */
    union
    {
	pjsip_rx_data	*rdata;
	pjsip_tx_data	*tdata;
	pj_timer_entry	*timer;
	void		*data;
	unsigned long	 udata;
    } src;

    /** The object that generates this event. */
    union
    {
	pjsip_transaction  *tsx;
	void		   *ptr;
	unsigned long	    udata;
    } obj;

    /** Other data. */
    union
    {
	long		    long_data;
	void *		    ptr_data;
    } data;
};

/**
 * Get the event string from the event ID.
 * @param e the event ID.
 * @notes defined in sip_misc.c
 */
PJ_DEF(const char *) pjsip_event_str(pjsip_event_id_e e);

/**
 * @}
 */

PJ_END_DECL

#endif	/* __PJSIP_SIP_EVENT_H__ */