-
Notifications
You must be signed in to change notification settings - Fork 909
/
sl.h
115 lines (100 loc) · 3.51 KB
/
sl.h
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
/*
* Copyright (C) 2001-2006 FhG FOKUS
*
* This file is part of Kamailio, a free SIP server.
*
* Kamailio 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
*
* Kamailio 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* @brief SL - API definitions
* @ingroup sl
* Module: @ref sl
*/
#ifndef _SL_H_
#define _SL_H_
#include "../../core/sr_module.h"
#include "../../core/parser/msg_parser.h"
/* callback for SL events */
#define SLCB_REPLY_READY (1<<0) /* stateless reply ready to be sent */
#define SLCB_ACK_FILTERED (1<<1) /* stateless ACK filtered */
/**
* @brief SL callback parameter structure
*/
typedef struct sl_cbp {
unsigned int type; /* type of callback */
sip_msg_t *req; /* SIP request to reply to, or filtered ACK */
int code; /* reply status code */
str *reason; /* reply reason phrase */
str *reply; /* raw content of the reply to be sent */
struct dest_info *dst; /* info about destination address */
void *cbp; /* parameter from callback registration */
} sl_cbp_t;
/**
* @brief SL callback function prototype
*/
typedef void (*sl_cbf_f)(sl_cbp_t *slcbp);
/**
* @brief SL callback structure definition
*/
typedef struct sl_cbelem {
unsigned int type; /* type of callback - can be a mask of types */
sl_cbf_f cbf; /* pointer to callback function */
void *cbp; /* param to callback function */
struct sl_cbelem* next; /* next sl_cbelem value */
} sl_cbelem_t;
void sl_destroy_callbacks_list(void);
typedef int (*sl_register_cb_f)(sl_cbelem_t *cbe);
int sl_register_callback(sl_cbelem_t *cbe);
void sl_run_callbacks(unsigned int type, struct sip_msg *req,
int code, char *reason, str *reply, struct dest_info *dst);
/* prototypes for SL API functions */
typedef int (*get_reply_totag_f)(struct sip_msg *msg, str *tag);
typedef int (*send_reply_f)(struct sip_msg *msg, int code, str *reason);
typedef int (*sl_send_reply_f)(struct sip_msg *msg, int code, char *reason);
typedef int (*sl_send_sreply_f)(struct sip_msg *msg, int code, str *reason);
typedef int (*sl_send_dreply_f)(struct sip_msg *msg, int code, str *reason,
str *tag);
/**
* @brief Stateless (sl) API structure
*/
typedef struct sl_api {
sl_send_reply_f zreply; /* send sl reply, reason is charz */
sl_send_sreply_f sreply; /* send sl reply, reason is str */
sl_send_dreply_f dreply; /* send sl reply with tag, reason is str */
send_reply_f freply; /* send sl reply with tag, reason is str */
get_reply_totag_f get_reply_totag;
sl_register_cb_f register_cb;
} sl_api_t;
typedef int (*bind_sl_f)(sl_api_t* api);
/**
* @brief Load the SL API
*/
static inline int sl_load_api(sl_api_t *slb)
{
bind_sl_f bindsl;
bindsl = (bind_sl_f)find_export("bind_sl", 0, 0);
if ( bindsl == 0) {
LM_ERR("cannot find bind_sl\n");
return -1;
}
if (bindsl(slb)==-1)
{
LM_ERR("cannot bind sl api\n");
return -1;
}
return 0;
}
#endif /* _SL_H_ */