1 /* 2 * Header file for address.c implementing allow_address function 3 * 4 * Copyright (C) 2006 Juha Heinanen 5 * 6 * This file is part of Kamailio, a free SIP server. 7 * 8 * Kamailio 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 12 * 13 * Kamailio is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 #ifndef ADDRESS_H 24 #define ADDRESS_H 25 26 #include "../../core/parser/msg_parser.h" 27 28 29 /* Pointer to current address hash table pointer */ 30 extern struct addr_list ***perm_addr_table; 31 32 33 /* Pointer to current subnet table */ 34 extern struct subnet **perm_subnet_table; 35 36 37 /* Pointer to current domain name table */ 38 extern struct domain_name_list ***perm_domain_table; 39 40 /* 41 * Initialize data structures 42 */ 43 int init_addresses(void); 44 45 46 /* 47 * Reload address table to new hash table and when done, make new hash table 48 * current one. 49 */ 50 int reload_address_table(void); 51 52 /* 53 * Wrapper to reload addr table from mi or rpc 54 * we need to open the db_handle 55 */ 56 int reload_address_table_cmd(void); 57 58 /* 59 * Close connections and release memory 60 */ 61 void clean_addresses(void); 62 63 64 int allow_address(sip_msg_t *_msg, int addr_group, str *ips, int port); 65 66 /* 67 * Checks if an entry exists in cached address table that belongs to a 68 * given address group and has given ip address and port. Port value 69 * 0 in cached address table matches any port. 70 */ 71 int w_allow_address(struct sip_msg* _msg, char* _addr_group, char* _addr_sp, 72 char* _port_sp); 73 74 75 int allow_source_address(sip_msg_t *_msg, int addr_group); 76 77 /* 78 * w_allow_source_address("group") equals to allow_address("group", "$si", "$sp") 79 * but is faster. 80 */ 81 int w_allow_source_address(struct sip_msg* _msg, char* _addr_group, char* _str2); 82 83 84 /* 85 * Checks if source address/port is found in cached address or 86 * subnet table in any group. If yes, returns that group. If not returns -1. 87 * Port value 0 in cached address and group table matches any port. 88 */ 89 int allow_source_address_group(struct sip_msg* _msg, char* _str1, char* _str2); 90 91 int ki_allow_source_address_group(sip_msg_t* _msg); 92 93 /* 94 * Checks if address/port is found in cached address or 95 * subnet table in any group. If yes, returns that group. If not returns -1. 96 * Port value 0 in cached address and group table matches any port. 97 */ 98 int allow_address_group(struct sip_msg* _msg, char* _addr, char* _port); 99 100 int ki_allow_address_group(sip_msg_t* _msg, str* _addr, int _port); 101 102 #endif /* ADDRESS_H */ 103