|
@@ -22,6 +22,14 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * \file
|
|
|
|
+ * \ingroup call_obj
|
|
|
|
+ * \brief call_obj :: Module functionality.
|
|
|
|
+ *
|
|
|
|
+ * - Module: \ref call_obj
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+/*
|
|
* Functionality of call_obj module.
|
|
* Functionality of call_obj module.
|
|
*/
|
|
*/
|
|
|
|
|
|
@@ -36,37 +44,42 @@
|
|
#include "cobj.h"
|
|
#include "cobj.h"
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Element of the array.
|
|
|
|
|
|
+ * \brief Element of the array.
|
|
|
|
+ *
|
|
* When assigned equals false other contents are undefined.
|
|
* When assigned equals false other contents are undefined.
|
|
*/
|
|
*/
|
|
typedef struct {
|
|
typedef struct {
|
|
- bool assigned;
|
|
|
|
- uint64_t timestamp;
|
|
|
|
- str callid;
|
|
|
|
|
|
+ bool assigned; /**< Element of the array is assigned. */
|
|
|
|
+ uint64_t timestamp; /**< Timestamp when element was assigned. */
|
|
|
|
+ str callid; /**< Call-ID of associated call. */
|
|
} co_object_t;
|
|
} co_object_t;
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * \brief Data type for shared called_obj data between processes.
|
|
|
|
+ */
|
|
typedef struct {
|
|
typedef struct {
|
|
- int start; /* Number of first object. */
|
|
|
|
- int end; /* Number of last object (included). */
|
|
|
|
|
|
+ int start; /**< Number of first object. */
|
|
|
|
+ int end; /**< Number of last object (included). */
|
|
/**
|
|
/**
|
|
- * Current position of last assigned object.
|
|
|
|
|
|
+ * \brief Current position of last assigned object.
|
|
|
|
+ *
|
|
* 0 - no object has been assigned yet.
|
|
* 0 - no object has been assigned yet.
|
|
*/
|
|
*/
|
|
int cur;
|
|
int cur;
|
|
- int assigned; /* Number of assigned objects at this moment. */
|
|
|
|
- gen_lock_t *lock; /* Lock to protect ring array. */
|
|
|
|
- co_object_t *ring; /* Array of call objects. */
|
|
|
|
|
|
+ int assigned; /**< Number of assigned objects at this moment. */
|
|
|
|
+ gen_lock_t *lock; /**< Lock to protect ring array. */
|
|
|
|
+ co_object_t *ring; /**< Array of call objects. */
|
|
} co_data_t;
|
|
} co_data_t;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Struct containing all call object related data.
|
|
|
|
|
|
+ * \brief Struct containing all call object related data.
|
|
*/
|
|
*/
|
|
static co_data_t *co_data = NULL;
|
|
static co_data_t *co_data = NULL;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Initialize call object module.
|
|
|
|
|
|
+ * \brief Initialize call object module.
|
|
*
|
|
*
|
|
- * /return 0 on success.
|
|
|
|
|
|
+ * \return 0 on success.
|
|
*/
|
|
*/
|
|
int cobj_init(int start, int end)
|
|
int cobj_init(int start, int end)
|
|
{
|
|
{
|
|
@@ -109,7 +122,7 @@ int cobj_init(int start, int end)
|
|
}
|
|
}
|
|
LM_DBG("Allocated %lu bytes for the ring\n", array_size);
|
|
LM_DBG("Allocated %lu bytes for the ring\n", array_size);
|
|
|
|
|
|
- /**
|
|
|
|
|
|
+ /*
|
|
* Initialize lock.
|
|
* Initialize lock.
|
|
*/
|
|
*/
|
|
co_data->lock = lock_alloc();
|
|
co_data->lock = lock_alloc();
|
|
@@ -144,7 +157,7 @@ int cobj_init(int start, int end)
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Close call object module.
|
|
|
|
|
|
+ * \brief Close call object module.
|
|
*/
|
|
*/
|
|
void cobj_destroy(void)
|
|
void cobj_destroy(void)
|
|
{
|
|
{
|
|
@@ -174,10 +187,10 @@ void cobj_destroy(void)
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get current timestamp in milliseconds.
|
|
|
|
|
|
+ * \brief Get current timestamp in milliseconds.
|
|
*
|
|
*
|
|
- * /param ts pointer to timestamp integer.
|
|
|
|
- * /return 0 on success.
|
|
|
|
|
|
+ * \param ts pointer to timestamp integer.
|
|
|
|
+ * \return 0 on success.
|
|
*/
|
|
*/
|
|
int get_timestamp(uint64_t *ts)
|
|
int get_timestamp(uint64_t *ts)
|
|
{
|
|
{
|
|
@@ -196,9 +209,9 @@ int get_timestamp(uint64_t *ts)
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Fill an object with data.
|
|
|
|
|
|
+ * \brief Fill an object with data.
|
|
*
|
|
*
|
|
- * /return 0 on success.
|
|
|
|
|
|
+ * \return 0 on success.
|
|
*/
|
|
*/
|
|
static int cobj_fill(co_object_t *obj, uint64_t timestamp, str *callid)
|
|
static int cobj_fill(co_object_t *obj, uint64_t timestamp, str *callid)
|
|
{
|
|
{
|
|
@@ -226,12 +239,12 @@ clean:
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get a free object.
|
|
|
|
|
|
+ * \brief Get a free object.
|
|
*
|
|
*
|
|
- * /param timestamp assign this timestamp to the object we get.
|
|
|
|
- * /param callid pointer to callid str.
|
|
|
|
- * /return -1 if an error happens.
|
|
|
|
- * /return number of a free object on success.
|
|
|
|
|
|
+ * \param timestamp assign this timestamp to the object we get.
|
|
|
|
+ * \param callid pointer to callid str.
|
|
|
|
+ * \return -1 if an error happens.
|
|
|
|
+ * \return number of a free object on success.
|
|
*/
|
|
*/
|
|
int cobj_get(uint64_t timestamp, str *callid)
|
|
int cobj_get(uint64_t timestamp, str *callid)
|
|
{
|
|
{
|
|
@@ -307,10 +320,10 @@ clean:
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Free an Object
|
|
|
|
|
|
+ * \brief Free an Object
|
|
*
|
|
*
|
|
- * /param num number of object to free
|
|
|
|
- * /return 0 on success
|
|
|
|
|
|
+ * \param num number of object to free
|
|
|
|
+ * \return 0 on success
|
|
*/
|
|
*/
|
|
int cobj_free(int num)
|
|
int cobj_free(int num)
|
|
{
|
|
{
|
|
@@ -348,10 +361,10 @@ clean:
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Fill data in cobj_stats_t structure passed as pointer.
|
|
|
|
|
|
+ * \brief Fill data in cobj_stats_t structure passed as pointer.
|
|
*
|
|
*
|
|
- * /param stats pointer to cobj_stats_t structure.
|
|
|
|
- * /return 0 on success
|
|
|
|
|
|
+ * \param stats pointer to cobj_stats_t structure.
|
|
|
|
+ * \return 0 on success
|
|
*/
|
|
*/
|
|
int cobj_stats_get(cobj_stats_t *stats)
|
|
int cobj_stats_get(cobj_stats_t *stats)
|
|
{
|
|
{
|
|
@@ -379,7 +392,7 @@ clean:
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Free all objects at once.
|
|
|
|
|
|
+ * \brief Free all objects at once.
|
|
*/
|
|
*/
|
|
void cobj_free_all(void)
|
|
void cobj_free_all(void)
|
|
{
|
|
{
|
|
@@ -402,7 +415,7 @@ void cobj_free_all(void)
|
|
obj->assigned = false;
|
|
obj->assigned = false;
|
|
}
|
|
}
|
|
|
|
|
|
- } // for i
|
|
|
|
|
|
+ } /* for i */
|
|
|
|
|
|
co_data->cur = 0; /* No object assigned yet. */
|
|
co_data->cur = 0; /* No object assigned yet. */
|
|
co_data->assigned = 0; /* No assigned objects at this moment. */
|
|
co_data->assigned = 0; /* No assigned objects at this moment. */
|
|
@@ -413,16 +426,16 @@ void cobj_free_all(void)
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get all objects which timestamp is less than or equals some value.
|
|
|
|
|
|
+ * \brief Get all objects which timestamp is less than or equals some value.
|
|
*
|
|
*
|
|
* User shall free returned list when not used any more.
|
|
* User shall free returned list when not used any more.
|
|
*
|
|
*
|
|
- * /param ts timestamp to compare.
|
|
|
|
- * /param elem returned list. NULL on error of if zero elements.
|
|
|
|
- * /param limit maximum number of objects to return. 0 means unlimited.
|
|
|
|
|
|
+ * \param ts timestamp to compare.
|
|
|
|
+ * \param elem returned list. NULL on error of if zero elements.
|
|
|
|
+ * \param limit maximum number of objects to return. 0 means unlimited.
|
|
*
|
|
*
|
|
- * /return number of returned objects on success.
|
|
|
|
- * /return -1 on error
|
|
|
|
|
|
+ * \return number of returned objects on success.
|
|
|
|
+ * \return -1 on error
|
|
*/
|
|
*/
|
|
int cobj_get_timestamp(uint64_t ts, cobj_elem_t **elem, int limit)
|
|
int cobj_get_timestamp(uint64_t ts, cobj_elem_t **elem, int limit)
|
|
{
|
|
{
|
|
@@ -518,9 +531,9 @@ clean:
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Free an object list.
|
|
|
|
|
|
+ * \brief Free an object list.
|
|
*
|
|
*
|
|
- * /param elem pointer to first element in the list.
|
|
|
|
|
|
+ * \param elem pointer to first element in the list.
|
|
*/
|
|
*/
|
|
void cobj_free_list(cobj_elem_t *elem)
|
|
void cobj_free_list(cobj_elem_t *elem)
|
|
{
|
|
{
|