Fixed some free() bugs in the APDU code.
git-svn-id: https://origsvn.digium.com/svn/libpri/trunk@200 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
parent
545e628f65
commit
84adda970c
@ -801,16 +801,16 @@ extern int rose_invoke_decode(struct pri *pri, q931_call *call, unsigned char *d
|
||||
case SS_CNID_CALLINGNAME:
|
||||
if (pri->debug & PRI_DEBUG_APDU)
|
||||
pri_message(" Handle Name display operation\n");
|
||||
switch (comp->type & PRI_DEBUG_APDU) {
|
||||
case ROSE_NAME_PRESENTATION_ALLOWED_SIMPLE:
|
||||
memcpy(call->callername, comp->data, comp->len);
|
||||
call->callername[comp->len] = 0;
|
||||
if (pri->debug & PRI_DEBUG_APDU)
|
||||
pri_message(" Received caller name '%s'\n", call->callername);
|
||||
return 0;
|
||||
default:
|
||||
pri_message("Do not handle argument of type 0x%X\n", comp->type);
|
||||
return -1;
|
||||
switch (comp->type) {
|
||||
case ROSE_NAME_PRESENTATION_ALLOWED_SIMPLE:
|
||||
memcpy(call->callername, comp->data, comp->len);
|
||||
call->callername[comp->len] = 0;
|
||||
if (pri->debug & PRI_DEBUG_APDU)
|
||||
pri_message(" Received caller name '%s'\n", call->callername);
|
||||
return 0;
|
||||
default:
|
||||
pri_message("Do not handle argument of type 0x%X\n", comp->type);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case ROSE_DIVERTING_LEG_INFORMATION2:
|
||||
@ -839,9 +839,9 @@ extern int pri_call_apdu_queue(q931_call *call, int messagetype, void *apdu, int
|
||||
return -1;
|
||||
|
||||
new_event = malloc(sizeof(struct apdu_event));
|
||||
memset(new_event, 0, sizeof(struct apdu_event));
|
||||
|
||||
if (new_event) {
|
||||
memset(new_event, 0, sizeof(struct apdu_event));
|
||||
new_event->message = messagetype;
|
||||
new_event->callback = function;
|
||||
new_event->data = data;
|
||||
@ -873,8 +873,8 @@ extern int pri_call_apdu_queue_cleanup(q931_call *call)
|
||||
while (cur_event) {
|
||||
/* TODO: callbacks, some way of giving return res on status of apdu */
|
||||
free_event = cur_event;
|
||||
free(free_event);
|
||||
cur_event = cur_event->next;
|
||||
free(free_event);
|
||||
}
|
||||
call->apdus = NULL;
|
||||
}
|
||||
|
36
testprilib.c
36
testprilib.c
@ -76,7 +76,6 @@ static void event1(struct pri *pri, pri_event *e)
|
||||
int x;
|
||||
static q931_call *calls[TEST_CALLS];
|
||||
char name[256], num[256], dest[256];
|
||||
struct pri_sr *sr;
|
||||
switch(e->gen.e) {
|
||||
case PRI_EVENT_DCHAN_UP:
|
||||
printf("Network is up. Sending blast of calls!\n");
|
||||
@ -89,15 +88,18 @@ static void event1(struct pri *pri, pri_event *e)
|
||||
continue;
|
||||
}
|
||||
#if 0
|
||||
sr = pri_sr_new();
|
||||
pri_sr_set_channel(sr, x+1, 0, 0);
|
||||
pri_sr_set_bearer(sr, 0, PRI_LAYER_1_ULAW);
|
||||
pri_sr_set_called(sr, dest, PRI_NATIONAL_ISDN, 1);
|
||||
pri_sr_set_caller(sr, num, name, PRI_NATIONAL_ISDN, PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN);
|
||||
pri_sr_set_redirecting(sr, num, PRI_NATIONAL_ISDN, PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, PRI_REDIR_UNCONDITIONAL);
|
||||
if (pri_setup(pri, calls[x], sr))
|
||||
perror("pri_setup");
|
||||
pri_sr_free(sr);
|
||||
{
|
||||
struct pri_sr *sr;
|
||||
sr = pri_sr_new();
|
||||
pri_sr_set_channel(sr, x+1, 0, 0);
|
||||
pri_sr_set_bearer(sr, 0, PRI_LAYER_1_ULAW);
|
||||
pri_sr_set_called(sr, dest, PRI_NATIONAL_ISDN, 1);
|
||||
pri_sr_set_caller(sr, num, name, PRI_NATIONAL_ISDN, PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN);
|
||||
pri_sr_set_redirecting(sr, num, PRI_NATIONAL_ISDN, PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, PRI_REDIR_UNCONDITIONAL);
|
||||
if (pri_setup(pri, calls[x], sr))
|
||||
perror("pri_setup");
|
||||
pri_sr_free(sr);
|
||||
}
|
||||
#else
|
||||
if (pri_call(pri, calls[x], PRI_TRANS_CAP_DIGITAL, x + 1, 1, 1, num,
|
||||
PRI_NATIONAL_ISDN, name, PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN,
|
||||
@ -113,6 +115,10 @@ static void event1(struct pri *pri, pri_event *e)
|
||||
q931_facility(pri, e->ringing.call);
|
||||
pri_answer(pri, e->ringing.call, e->ringing.channel, 0);
|
||||
break;
|
||||
case PRI_EVENT_HANGUP_REQ:
|
||||
printf("PRI 1: %s (%d)\n", pri_event2str(e->gen.e), e->gen.e);
|
||||
pri_hangup(pri, e->hangup.call, e->hangup.cause);
|
||||
break;
|
||||
default:
|
||||
printf("PRI 1: %s (%d)\n", pri_event2str(e->gen.e), e->gen.e);
|
||||
}
|
||||
@ -127,6 +133,14 @@ static void event2(struct pri *pri, pri_event *e)
|
||||
pri_proceeding(pri, e->ring.call, e->ring.channel, 0);
|
||||
pri_acknowledge(pri, e->ring.call, e->ring.channel, 0);
|
||||
break;
|
||||
case PRI_EVENT_ANSWER:
|
||||
printf("PRI 2: %s (%d)\n", pri_event2str(e->gen.e), e->gen.e);
|
||||
pri_hangup(pri, e->answer.call, PRI_CAUSE_NORMAL_UNSPECIFIED);
|
||||
break;
|
||||
case PRI_EVENT_HANGUP:
|
||||
printf("PRI 2: %s (%d)\n", pri_event2str(e->gen.e), e->gen.e);
|
||||
pri_hangup(pri, e->hangup.call, e->hangup.cause);
|
||||
break;
|
||||
case PRI_EVENT_DCHAN_UP:
|
||||
default:
|
||||
printf("PRI 2: %s (%d)\n", pri_event2str(e->gen.e), e->gen.e);
|
||||
@ -195,7 +209,7 @@ static void *dchan(void *data)
|
||||
fd_set fds;
|
||||
int res;
|
||||
for(;;) {
|
||||
if (next == pri_schedule_next(pri)) {
|
||||
if ((next = pri_schedule_next(pri))) {
|
||||
gettimeofday(&tv, NULL);
|
||||
tv.tv_sec = next->tv_sec - tv.tv_sec;
|
||||
tv.tv_usec = next->tv_usec - tv.tv_usec;
|
||||
|
Loading…
Reference in New Issue
Block a user