diff --git a/q931.c b/q931.c index 6e6eaf6..719e970 100644 --- a/q931.c +++ b/q931.c @@ -623,6 +623,20 @@ int q931_party_id_presentation(const struct q931_party_id *id) return number_value | number_screening; } +static void q931_clr_subcommands(struct pri *ctrl) +{ + ctrl->subcmds.counter_subcmd = 0; +} + +struct pri_subcommand *q931_alloc_subcommand(struct pri *ctrl) +{ + if (ctrl->subcmds.counter_subcmd < PRI_MAX_SUBCOMMANDS) { + return &ctrl->subcmds.subcmd[ctrl->subcmds.counter_subcmd++]; + } + + return NULL; +} + static char *code2str(int code, struct msgtype *codes, int max) { int x; @@ -3736,6 +3750,7 @@ static void pri_release_finaltimeout(void *data) c->t308_timedout++; c->ourcallstate = Q931_CALL_STATE_NULL; c->peercallstate = Q931_CALL_STATE_NULL; + q931_clr_subcommands(ctrl); ctrl->schedev = 1; ctrl->ev.e = PRI_EVENT_HANGUP_ACK; ctrl->ev.hangup.subcmds = &ctrl->subcmds; @@ -4136,20 +4151,6 @@ int q931_hangup(struct pri *ctrl, q931_call *c, int cause) return 0; } -static void q931_clr_subcommands(struct pri *ctrl) -{ - ctrl->subcmds.counter_subcmd = 0; -} - -struct pri_subcommand *q931_alloc_subcommand(struct pri *ctrl) -{ - if (ctrl->subcmds.counter_subcmd < PRI_MAX_SUBCOMMANDS) { - return &ctrl->subcmds.subcmd[ctrl->subcmds.counter_subcmd++]; - } - - return NULL; -} - static int prepare_to_handle_maintenance_message(struct pri *ctrl, q931_mh *mh, q931_call *c) { if ((!ctrl) || (!mh) || (!c)) {