k/registrar/api.h

00001 /*
00002  * $Id$
00003  *
00004  * Functions that process REGISTER message 
00005  * and store data in usrloc
00006  *
00007  * Copyright (C) 2010 Daniel-Constantin Mierla (asipto.com)
00008  *
00009  * This file is part of Kamailio, a free SIP server.
00010  *
00011  * Kamailio is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version
00015  *
00016  * Kamailio is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License 
00022  * along with this program; if not, write to the Free Software 
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *
00025  */
00026 
00027 
00028 #ifndef _REGISTRAR_API_H_
00029 #define _REGISTRAR_API_H_
00030 
00031 #include "../../sr_module.h"
00032 #include "../../parser/msg_parser.h"
00033 
00034 typedef int (*regapi_save_f)(struct sip_msg *msg, char *table, int flags);
00035 int regapi_save(struct sip_msg *msg, char *table, int flags);
00036 
00037 typedef int (*regapi_lookup_f)(struct sip_msg *msg, char *table);
00038 int regapi_lookup(struct sip_msg *msg, char *table);
00039 
00043 typedef struct registrar_api {
00044         regapi_save_f    save;
00045         regapi_lookup_f  lookup;
00046         regapi_lookup_f  registered;
00047 } registrar_api_t;
00048 
00049 typedef int (*bind_registrar_f)(registrar_api_t* api);
00050 int bind_registrar(registrar_api_t* api);
00051 
00055 static inline int registrar_load_api(registrar_api_t *api)
00056 {
00057         bind_registrar_f bindregistrar;
00058 
00059         bindregistrar = (bind_registrar_f)find_export("bind_registrar", 0, 0);
00060         if(bindregistrar == 0) {
00061                 LM_ERR("cannot find bind_registrar\n");
00062                 return -1;
00063         }
00064         if (bindregistrar(api) < 0)
00065         {
00066                 LM_ERR("cannot bind registrar api\n");
00067                 return -1;
00068         }
00069         return 0;
00070 }
00071 
00072 
00073 #endif