4 * Copyright (C) 2001-2003 FhG Fokus
6 * This file is part of ser, a free SIP server.
8 * ser is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version
13 * For a license to use the ser software under conditions
14 * other than those described here, or to purchase support for this
15 * software, please contact iptel.org by e-mail at the following addresses:
18 * ser is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 * 2005-02-13 script callbacks devided into request and reply types (bogdan)
30 * 2009-06-01 Added pre- and post-script callback support for all types
31 * of route blocks. (Miklos)
37 #include "parser/msg_parser.h"
39 typedef int (cb_function)(struct sip_msg *msg, unsigned int flags, void *param);
42 #define PRE_SCRIPT_CB (1<<30)
43 #define POST_SCRIPT_CB (1<<31)
45 /* Pre- and post-script callback flags. Use these flags to register
46 * for the callbacks, and to check the type of the callback from the
48 * (Power of 2 so more callbacks can be registered at once.)
50 enum script_cb_flag { REQUEST_CB=1, FAILURE_CB=2, ONREPLY_CB=4,
51 BRANCH_CB=8, ONSEND_CB=16, ERROR_CB=32,
52 LOCAL_CB=64, EVENT_CB=128 };
54 /* Callback types used for executing the callbacks.
55 * Keep in sync with script_cb_flag!!!
57 enum script_cb_type { REQUEST_CB_TYPE=1, FAILURE_CB_TYPE, ONREPLY_CB_TYPE,
58 BRANCH_CB_TYPE, ONSEND_CB_TYPE, ERROR_CB_TYPE,
59 LOCAL_CB_TYPE, EVENT_CB_TYPE };
63 struct script_cb *next;
67 /* Register pre- or post-script callbacks.
68 * Returns -1 on error, 0 on success
70 int register_script_cb( cb_function f, unsigned int flags, void *param );
73 void destroy_script_cb();
75 /* Execute pre-script callbacks of a given type.
76 * Returns 0 on error, 1 on success
78 int exec_pre_script_cb( struct sip_msg *msg, enum script_cb_type type);
80 /* Execute post-script callbacks of a given type.
81 * Always returns 1, success.
83 int exec_post_script_cb( struct sip_msg *msg, enum script_cb_type type);