Module: sip-router Branch: mariuszbihlei/p_usrloc Commit: 75d2b1e18a265501729c0186a918b865b44af79b URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=75d2b1e1...
Author: Marius Zbihlei marius.zbihlei@1and1.ro Committer: Marius Zbihlei marius.zbihlei@1and1.ro Date: Thu Jan 20 12:06:04 2011 +0200
modules_k/usrloc Further refactoring of code
---
modules_k/usrloc/ucontact.h | 1 - modules_k/usrloc/ul_callback.h | 5 +- modules_k/usrloc/usrloc.c | 4 + modules_k/usrloc/usrloc.h | 135 ---------------------------------------- 4 files changed, 7 insertions(+), 138 deletions(-)
diff --git a/modules_k/usrloc/ucontact.h b/modules_k/usrloc/ucontact.h index 8ef3491..9686a07 100644 --- a/modules_k/usrloc/ucontact.h +++ b/modules_k/usrloc/ucontact.h @@ -39,7 +39,6 @@ #include <stdio.h> #include "usrloc.h"
- /*! \brief ancient time used for marking the contacts forced to expired */ #define UL_EXPIRED_TIME 10
diff --git a/modules_k/usrloc/ul_callback.h b/modules_k/usrloc/ul_callback.h index bb322cb..dadce6d 100644 --- a/modules_k/usrloc/ul_callback.h +++ b/modules_k/usrloc/ul_callback.h @@ -32,6 +32,7 @@ #ifndef _UL_CALLBACKS_H #define _UL_CALLBACKS_H
+#include "../../dprint.h"
/* forward declaration for ucontact_t */ struct ucontact; @@ -84,8 +85,8 @@ static inline void run_ul_callbacks( int type , struct ucontact *c)
for (cbp=ulcb_list->first; cbp; cbp=cbp->next) { if(cbp->types&type) { - /*LM_DBG("contact=%p, callback type %d/%d, id %d entered\n", - c, type, cbp->types, cbp->id );*/ + LM_DBG("contact=%p, callback type %d/%d, id %d entered\n", + c, type, cbp->types, cbp->id ); cbp->callback( c, type, cbp->param ); } } diff --git a/modules_k/usrloc/usrloc.c b/modules_k/usrloc/usrloc.c index f5e1dde..b7a4283 100644 --- a/modules_k/usrloc/usrloc.c +++ b/modules_k/usrloc/usrloc.c @@ -34,6 +34,10 @@ */
#include "usrloc.h" +#include "dlist.h" +#include "urecord.h" +#include "ucontact.h" +#include "udomain.h" #include "../../sr_module.h" #include "ul_mod.h"
diff --git a/modules_k/usrloc/usrloc.h b/modules_k/usrloc/usrloc.h index f57387e..827e568 100644 --- a/modules_k/usrloc/usrloc.h +++ b/modules_k/usrloc/usrloc.h @@ -124,168 +124,33 @@ typedef struct urecord { struct urecord* next; /*!< Previous item in the hash entry */ } urecord_t;
-/*! - * \brief Create and insert a new record - * \param _d domain to insert the new record - * \param _aor address of the record - * \param _r new created record - * \return return 0 on success, -1 on failure - */ typedef int (*insert_urecord_t)(struct udomain* _d, str* _aor, struct urecord** _r); -int insert_urecord(struct udomain* _d, str* _aor, struct urecord** _r); -
-/*! - * \brief Obtain a urecord pointer if the urecord exists in domain - * \param _d domain to search the record - * \param _aor address of record - * \param _r new created record - * \return 0 if a record was found, 1 if nothing could be found - */ typedef int (*get_urecord_t)(struct udomain* _d, str* _aor, struct urecord** _r); -int get_urecord(struct udomain* _d, str* _aor, struct urecord** _r);
- -/*! - * \brief Delete a urecord from domain - * \param _d domain where the record should be deleted - * \param _aor address of record - * \param _r deleted record - * \return 0 on success, -1 if the record could not be deleted - */ typedef int (*delete_urecord_t)(struct udomain* _d, str* _aor, struct urecord* _r); -int delete_urecord(struct udomain* _d, str* _aor, struct urecord* _r);
- -/*! - * \brief Update ucontact with new values - * \param _r record the contact belongs to - * \param _c updated contact - * \param _ci new contact informations - * \return 0 on success, -1 on failure - */ typedef int (*update_ucontact_t)(struct urecord* _r, struct ucontact* _c, struct ucontact_info* _ci); -int update_ucontact(struct urecord* _r, struct ucontact* _c, struct ucontact_info* _ci); - -/*! - * \brief Release urecord previously obtained through get_urecord - * \warning Failing to calls this function after get_urecord will - * result in a memory leak when the DB_ONLY mode is used. When - * the records is later deleted, e.g. with delete_urecord, then - * its not necessary, as this function already releases the record. - * \param _r released record - */ typedef void (*release_urecord_t)(struct urecord* _r); -void release_urecord(struct urecord* _r); -
-/*! - * \brief Create and insert new contact into urecord - * \param _r record into the new contact should be inserted - * \param _contact contact string - * \param _ci contact information - * \param _c new created contact - * \return 0 on success, -1 on failure - */ typedef int (*insert_ucontact_t)(struct urecord* _r, str* _contact, struct ucontact_info* _ci, struct ucontact** _c); -int insert_ucontact(struct urecord* _r, str* _contact, - struct ucontact_info* _ci, struct ucontact** _c);
- -/*! - * \brief Delete ucontact from urecord - * \param _r record where the contact belongs to - * \param _c deleted contact - * \return 0 on success, -1 on failure - */ typedef int (*delete_ucontact_t)(struct urecord* _r, struct ucontact* _c); -int delete_ucontact(struct urecord* _r, struct ucontact* _c); -
-/*! - * \brief Get pointer to ucontact with given contact - * \param _r record where to search the contacts - * \param _c contact string - * \param _callid callid - * \param _path path - * \param _cseq CSEQ number - * \param _co found contact - * \return 0 - found, 1 - not found, -1 - invalid found, - * -2 - found, but to be skipped (same cseq) - */ typedef int (*get_ucontact_t)(struct urecord* _r, str* _c, str* _callid, str* _path, int _cseq, struct ucontact** _co); -int get_ucontact(struct urecord* _r, str* _c, str* _callid, str* _path, - int _cseq, - struct ucontact** _co);
-/*! \brief - * Timer handler for given domain - */ typedef void (*lock_udomain_t)(struct udomain* _d, str *_aor); -void lock_udomain(struct udomain* _d, str *_aor); -
-/*! - * \brief Release lock for a domain - * \param _d domain - * \param _aor address of record, uses as hash source for the lock slot - */ typedef void (*unlock_udomain_t)(struct udomain* _d, str *_aor); -void unlock_udomain(struct udomain* _d, str *_aor);
-/*! - * \brief Registers a new domain with usrloc - * - * Registers a new domain with usrloc. If the domain exists, - * a pointer to existing structure will be returned, otherwise - * a new domain will be created - * \param _n domain name - * \param _d new created domain - * \return 0 on success, -1 on failure - */ typedef int (*register_udomain_t)(const char* _n, struct udomain** _d); -int register_udomain(const char* _n, struct udomain** _d);
-/*! - * \brief Get all contacts from the usrloc, in partitions if wanted - * - * Return list of all contacts for all currently registered - * users in all domains. The caller must provide buffer of - * sufficient length for fitting all those contacts. In the - * case when buffer was exhausted, the function returns - * estimated amount of additional space needed, in this - * case the caller is expected to repeat the call using - * this value as the hint. - * - * Information is packed into the buffer as follows: - * - * +------------+----------+-----+------+-----+ - * |contact1.len|contact1.s|sock1|flags1|path1| - * +------------+----------+-----+------+-----+ - * |contact2.len|contact2.s|sock2|flags2|path1| - * +------------+----------+-----+------+-----+ - * |..........................................| - * +------------+----------+-----+------+-----+ - * |contactN.len|contactN.s|sockN|flagsN|pathN| - * +------------+----------+-----+------+-----+ - * |000000000000| - * +------------+ - * - * \param buf target buffer - * \param len length of buffer - * \param flags contact flags - * \param part_idx part index - * \param part_max maximal part - * \return 0 on success, positive if buffer size was not sufficient, negative on failure - */ typedef int (*get_all_ucontacts_t) (void* buf, int len, unsigned int flags, unsigned int part_idx, unsigned int part_max); -int get_all_ucontacts(void *, int, unsigned int, - unsigned int part_idx, unsigned int part_max);
/*! usrloc API export structure */ typedef struct usrloc_api {