dtm.h

00001 /*
00002  * Copyright (C) 2009 1&1 Internet AG
00003  *
00004  * This file is part of sip-router, a free SIP server.
00005  *
00006  * sip-router is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version
00010  *
00011  * sip-router is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License 
00017  * along with this program; if not, write to the Free Software 
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 #ifndef _DTM_H_
00022 #define _DTM_H_
00023 
00024 
00025 
00026 
00027 #include "common.h"
00028 
00029 
00030 
00031 
00032 typedef int32_t dtm_node_index_t;
00033 
00034 
00035 
00036 
00037 struct dtm_node_t {
00038         dtm_node_index_t child[10];
00039         carrier_t carrier;
00040 } __attribute__ ((packed));
00041 
00042 
00043 
00044 
00045 /*
00046  The PDB data in the given file is loaded into memory via mmap.
00047 */
00048 struct dtm_node_t *dtm_load(char *filename);
00049 
00050 /*
00051  Find the longest prefix match of number in mroot.
00052  Set *carrier according to value in dtree.
00053  Return the number of matched digits.
00054  In case no match is found, return -1.
00055 */
00056 int dtm_longest_match(struct dtm_node_t *mroot, const char *number, int numberlen, carrier_t *carrier);
00057 
00058 
00059 
00060 
00061 #endif