00001 /* 00002 * $Id$ 00003 * 00004 * Copyright (C) 2001-2003 FhG Fokus 00005 * 00006 * This file is part of ser, a free SIP server. 00007 * 00008 * ser is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version 00012 * 00013 * For a license to use the ser software under conditions 00014 * other than those described here, or to purchase support for this 00015 * software, please contact iptel.org by e-mail at the following addresses: 00016 * info@iptel.org 00017 * 00018 * ser is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 * GNU General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License 00024 * along with this program; if not, write to the Free Software 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00026 * 00027 * History: 00028 * -------- 00029 * 2005-02-13 script callbacks devided into request and reply types (bogdan) 00030 * 2009-06-01 Added pre- and post-script callback support for all types 00031 * of route blocks. (Miklos) 00032 */ 00033 00034 #ifndef _SCRIPT_CB_H_ 00035 #define _SCRIPT_CB_H_ 00036 00037 #include "parser/msg_parser.h" 00038 00039 typedef int (cb_function)(struct sip_msg *msg, unsigned int flags, void *param); 00040 00041 00042 #define PRE_SCRIPT_CB (1<<30) 00043 #define POST_SCRIPT_CB (1<<31) 00044 00045 /* Pre- and post-script callback flags. Use these flags to register 00046 * for the callbacks, and to check the type of the callback from the 00047 * functions. 00048 * (Power of 2 so more callbacks can be registered at once.) 00049 */ 00050 enum script_cb_flag { REQUEST_CB=1, FAILURE_CB=2, ONREPLY_CB=4, 00051 BRANCH_CB=8, ONSEND_CB=16, ERROR_CB=32, 00052 LOCAL_CB=64, EVENT_CB=128 }; 00053 00054 /* Callback types used for executing the callbacks. 00055 * Keep in sync with script_cb_flag!!! 00056 */ 00057 enum script_cb_type { REQUEST_CB_TYPE=1, FAILURE_CB_TYPE, ONREPLY_CB_TYPE, 00058 BRANCH_CB_TYPE, ONSEND_CB_TYPE, ERROR_CB_TYPE, 00059 LOCAL_CB_TYPE, EVENT_CB_TYPE }; 00060 00061 struct script_cb{ 00062 cb_function *cbf; 00063 struct script_cb *next; 00064 void *param; 00065 }; 00066 00067 /* Register pre- or post-script callbacks. 00068 * Returns -1 on error, 0 on success 00069 */ 00070 int register_script_cb( cb_function f, unsigned int flags, void *param ); 00071 00072 int init_script_cb(void); 00073 void destroy_script_cb(void); 00074 00075 /* Execute pre-script callbacks of a given type. 00076 * Returns 0 on error, 1 on success 00077 */ 00078 int exec_pre_script_cb( struct sip_msg *msg, enum script_cb_type type); 00079 00080 /* Execute post-script callbacks of a given type. 00081 * Always returns 1, success. 00082 */ 00083 int exec_post_script_cb( struct sip_msg *msg, enum script_cb_type type); 00084 00085 #endif 00086
1.7.1