Create two versions of call ptr verify. One gripes and one does not.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2027 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
parent
fb61cedfd7
commit
31b4b63b40
@ -883,7 +883,7 @@ struct d_ctrl_dummy {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Check if the given call ptr is valid.
|
* \brief Check if the given call ptr is valid and gripe if not.
|
||||||
*
|
*
|
||||||
* \param ctrl D channel controller.
|
* \param ctrl D channel controller.
|
||||||
* \param call Q.931 call leg.
|
* \param call Q.931 call leg.
|
||||||
@ -892,9 +892,10 @@ struct d_ctrl_dummy {
|
|||||||
* \retval FALSE if call ptr is invalid.
|
* \retval FALSE if call ptr is invalid.
|
||||||
*/
|
*/
|
||||||
#define pri_is_call_valid(ctrl, call) \
|
#define pri_is_call_valid(ctrl, call) \
|
||||||
q931_is_call_valid(ctrl, call, __PRETTY_FUNCTION__, __LINE__)
|
q931_is_call_valid_gripe(ctrl, call, __PRETTY_FUNCTION__, __LINE__)
|
||||||
|
|
||||||
int q931_is_call_valid(struct pri *ctrl, struct q931_call *call, const char *func_name, unsigned long func_line);
|
int q931_is_call_valid(struct pri *ctrl, struct q931_call *call);
|
||||||
|
int q931_is_call_valid_gripe(struct pri *ctrl, struct q931_call *call, const char *func_name, unsigned long func_line);
|
||||||
|
|
||||||
extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data);
|
extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data);
|
||||||
|
|
||||||
|
40
q931.c
40
q931.c
@ -327,16 +327,13 @@ static int q931_encode_channel(const q931_call *call)
|
|||||||
*
|
*
|
||||||
* \param ctrl D channel controller.
|
* \param ctrl D channel controller.
|
||||||
* \param call Q.931 call leg.
|
* \param call Q.931 call leg.
|
||||||
* \param func_name Calling function name for debug tracing. (__PRETTY_FUNCTION__)
|
|
||||||
* \param func_line Calling function line number for debug tracing. (__LINE__)
|
|
||||||
*
|
*
|
||||||
* \retval TRUE if call ptr is valid.
|
* \retval TRUE if call ptr is valid.
|
||||||
* \retval FALSE if call ptr is invalid.
|
* \retval FALSE if call ptr is invalid.
|
||||||
*/
|
*/
|
||||||
int q931_is_call_valid(struct pri *ctrl, struct q931_call *call, const char *func_name, unsigned long func_line)
|
int q931_is_call_valid(struct pri *ctrl, struct q931_call *call)
|
||||||
{
|
{
|
||||||
struct q931_call *cur;
|
struct q931_call *cur;
|
||||||
struct pri *gripe;
|
|
||||||
struct pri *link;
|
struct pri *link;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
@ -347,18 +344,14 @@ int q931_is_call_valid(struct pri *ctrl, struct q931_call *call, const char *fun
|
|||||||
if (!ctrl) {
|
if (!ctrl) {
|
||||||
/* Must use suspect ctrl from call ptr. */
|
/* Must use suspect ctrl from call ptr. */
|
||||||
if (!call->pri) {
|
if (!call->pri) {
|
||||||
pri_message(NULL,
|
/* Definitely a bad call pointer. */
|
||||||
"!! %s() line:%lu Called with invalid call ptr (%p) (No ctrl)\n",
|
|
||||||
func_name, func_line, call);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Find the master - He has the call pool */
|
/* Find the master - He has the call pool */
|
||||||
ctrl = PRI_MASTER(call->pri);
|
ctrl = PRI_MASTER(call->pri);
|
||||||
gripe = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
/* Find the master - He has the call pool */
|
/* Find the master - He has the call pool */
|
||||||
ctrl = PRI_MASTER(ctrl);
|
ctrl = PRI_MASTER(ctrl);
|
||||||
gripe = ctrl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check real call records. */
|
/* Check real call records. */
|
||||||
@ -387,11 +380,36 @@ int q931_is_call_valid(struct pri *ctrl, struct q931_call *call, const char *fun
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Well it looks like this is a stale call ptr. */
|
/* Well it looks like this is a stale call ptr. */
|
||||||
pri_message(gripe, "!! %s() line:%lu Called with invalid call ptr (%p)\n",
|
|
||||||
func_name, func_line, call);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Check if the given call ptr is valid and gripe if not.
|
||||||
|
*
|
||||||
|
* \param ctrl D channel controller.
|
||||||
|
* \param call Q.931 call leg.
|
||||||
|
* \param func_name Calling function name for debug tracing. (__PRETTY_FUNCTION__)
|
||||||
|
* \param func_line Calling function line number for debug tracing. (__LINE__)
|
||||||
|
*
|
||||||
|
* \retval TRUE if call ptr is valid.
|
||||||
|
* \retval FALSE if call ptr is invalid.
|
||||||
|
*/
|
||||||
|
int q931_is_call_valid_gripe(struct pri *ctrl, struct q931_call *call, const char *func_name, unsigned long func_line)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
if (!call) {
|
||||||
|
/* Let's not gripe about this invalid call pointer. */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
res = q931_is_call_valid(ctrl, call);
|
||||||
|
if (!res) {
|
||||||
|
pri_message(ctrl, "!! %s() line:%lu Called with invalid call ptr (%p)\n",
|
||||||
|
func_name, func_line, call);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Initialize the given struct q931_party_name
|
* \brief Initialize the given struct q931_party_name
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user