00001 /* 00002 * mangler module 00003 * 00004 * $Id$ 00005 * 00006 * Copyright (C) 2001-2003 FhG Fokus 00007 * 00008 * This file is part of ser, a free SIP server. 00009 * 00010 * ser is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version 00014 * 00015 * For a license to use the ser software under conditions 00016 * other than those described here, or to purchase support for this 00017 * software, please contact iptel.org by e-mail at the following addresses: 00018 * info@iptel.org 00019 * 00020 * ser is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * You should have received a copy of the GNU General Public License 00026 * along with this program; if not, write to the Free Software 00027 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00028 */ 00029 /* History: 00030 * -------- 00031 * 2003-04-07 first version. 00032 */ 00033 00034 /* TO DO: precompiled expresions */ 00035 00036 #ifndef SDP_MANGLER_H 00037 #define SDP_MANGLER_H 00038 00039 00040 #include "../../parser/msg_parser.h" /* struct sip_msg */ 00041 #include "common.h" 00042 #include <regex.h> 00043 00044 00045 /* With STRICT_CHECK off: 00046 If you define a port like 41231311 and BEST_EFFORT is defined it will 00047 consider a port the first 5 digits 00048 Similarly an ip like 12.31.12.313131132131 will be mangled with only 3 digits 00049 from the last group 00050 */ 00051 00052 #ifdef STRICT_CHECK 00053 #define PORT_REGEX "(m=[a-z]+ [0-9]{1,5} )" 00054 #define IP_REGEX "(c=IN IP4 [0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}( |\n|\r))" 00055 #endif 00056 00057 00058 #ifndef STRICT_CHECK 00059 #define PORT_REGEX "m=[a-z]+ [0-9]{1,5}" 00060 #define IP_REGEX "(c=IN IP4 [0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})" 00061 #endif 00062 00063 00064 #define MIN_ORIGINAL_PORT 1 00065 #define MAX_ORIGINAL_PORT 65535 00066 #define MIN_MANGLED_PORT 1 00067 #define MAX_MANGLED_PORT 65535 00068 #define MIN_OFFSET_VALUE -65535 00069 #define MAX_OFFSET_VALUE 65535 00070 00071 00072 00073 extern regex_t *portExpression; 00074 extern regex_t *ipExpression; 00075 00076 00077 00078 /* replaces all appearances of a port in lines like m=audio port with 00079 a new value for port which is oldvalue+offset 00080 @param msg a pointer to a sip message 00081 @param offset value of an offset.Must be a numeric format like "-12345" 00082 @param unused unused parameter 00083 @return negative in case of error or number of replacements - 1 00084 */ 00085 int sdp_mangle_port (struct sip_msg *msg, char *offset, char *unused); 00086 00087 /* may replace all appearances of an ip in lines like c=IN IP4 ip with 00088 a new value for ip if the found ip matches the filter 00089 @param msg a pointer to a sip message 00090 @param oldip an filter for ip's in form ip/mask.Example 00091 of oldip "10.0.0.0/255.0.0.0" or "10.0.0.0/8" 00092 @param newip the ip replacing old ip 00093 @return negative in case of error or number of replacements - 1 00094 */ 00095 00096 int sdp_mangle_ip (struct sip_msg *msg, char *oldip, char *newip); 00097 00098 int compile_expresions(char *port,char *ip); 00099 int free_compiled_expresions(); 00100 00101 #endif
1.7.1