[ozmod_libpri] Fix array out of bounds error and clean up some enums in lpwrap_pri.h

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@737 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Stefan Knoblich 2009-06-04 17:20:53 +00:00
parent 34a4427fba
commit 1bfb99db66
2 changed files with 38 additions and 33 deletions

View File

@ -40,26 +40,29 @@
#define LPWRAP_MAX_CHAN_PER_SPAN 32
typedef enum {
LPWRAP_PRI_EVENT_ANY = 0,
LPWRAP_PRI_EVENT_DCHAN_UP = PRI_EVENT_DCHAN_UP,
LPWRAP_PRI_EVENT_DCHAN_DOWN = PRI_EVENT_DCHAN_DOWN,
LPWRAP_PRI_EVENT_RESTART = PRI_EVENT_RESTART,
LPWRAP_PRI_EVENT_CONFIG_ERR = PRI_EVENT_CONFIG_ERR,
LPWRAP_PRI_EVENT_RING = PRI_EVENT_RING,
LPWRAP_PRI_EVENT_HANGUP = PRI_EVENT_HANGUP,
LPWRAP_PRI_EVENT_RINGING = PRI_EVENT_RINGING,
LPWRAP_PRI_EVENT_ANSWER = PRI_EVENT_ANSWER,
LPWRAP_PRI_EVENT_HANGUP_ACK = PRI_EVENT_HANGUP_ACK,
LPWRAP_PRI_EVENT_RESTART_ACK = PRI_EVENT_RESTART_ACK,
LPWRAP_PRI_EVENT_FACNAME = PRI_EVENT_FACNAME,
LPWRAP_PRI_EVENT_ANY = 0,
LPWRAP_PRI_EVENT_DCHAN_UP = PRI_EVENT_DCHAN_UP,
LPWRAP_PRI_EVENT_DCHAN_DOWN = PRI_EVENT_DCHAN_DOWN,
LPWRAP_PRI_EVENT_RESTART = PRI_EVENT_RESTART,
LPWRAP_PRI_EVENT_CONFIG_ERR = PRI_EVENT_CONFIG_ERR,
LPWRAP_PRI_EVENT_RING = PRI_EVENT_RING,
LPWRAP_PRI_EVENT_HANGUP = PRI_EVENT_HANGUP,
LPWRAP_PRI_EVENT_RINGING = PRI_EVENT_RINGING,
LPWRAP_PRI_EVENT_ANSWER = PRI_EVENT_ANSWER,
LPWRAP_PRI_EVENT_HANGUP_ACK = PRI_EVENT_HANGUP_ACK,
LPWRAP_PRI_EVENT_RESTART_ACK = PRI_EVENT_RESTART_ACK,
LPWRAP_PRI_EVENT_FACNAME = PRI_EVENT_FACNAME,
LPWRAP_PRI_EVENT_INFO_RECEIVED = PRI_EVENT_INFO_RECEIVED,
LPWRAP_PRI_EVENT_PROCEEDING = PRI_EVENT_PROCEEDING,
LPWRAP_PRI_EVENT_SETUP_ACK = PRI_EVENT_SETUP_ACK,
LPWRAP_PRI_EVENT_HANGUP_REQ = PRI_EVENT_HANGUP_REQ,
LPWRAP_PRI_EVENT_NOTIFY = PRI_EVENT_NOTIFY,
LPWRAP_PRI_EVENT_PROGRESS = PRI_EVENT_PROGRESS,
LPWRAP_PRI_EVENT_KEYPAD_DIGIT = PRI_EVENT_KEYPAD_DIGIT,
LPWRAP_PRI_EVENT_IO_FAIL = 19
LPWRAP_PRI_EVENT_PROCEEDING = PRI_EVENT_PROCEEDING,
LPWRAP_PRI_EVENT_SETUP_ACK = PRI_EVENT_SETUP_ACK,
LPWRAP_PRI_EVENT_HANGUP_REQ = PRI_EVENT_HANGUP_REQ,
LPWRAP_PRI_EVENT_NOTIFY = PRI_EVENT_NOTIFY,
LPWRAP_PRI_EVENT_PROGRESS = PRI_EVENT_PROGRESS,
LPWRAP_PRI_EVENT_KEYPAD_DIGIT = PRI_EVENT_KEYPAD_DIGIT,
LPWRAP_PRI_EVENT_IO_FAIL = 19,
/* don't touch */
LPWRAP_PRI_EVENT_MAX
} lpwrap_pri_event_t;
typedef enum {
@ -68,17 +71,20 @@ typedef enum {
} lpwrap_pri_node_t;
typedef enum {
LPWRAP_PRI_SWITCH_UNKNOWN = PRI_SWITCH_UNKNOWN,
LPWRAP_PRI_SWITCH_NI2 = PRI_SWITCH_NI2,
LPWRAP_PRI_SWITCH_DMS100 = PRI_SWITCH_DMS100,
LPWRAP_PRI_SWITCH_LUCENT5E = PRI_SWITCH_LUCENT5E,
LPWRAP_PRI_SWITCH_ATT4ESS = PRI_SWITCH_ATT4ESS,
LPWRAP_PRI_SWITCH_UNKNOWN = PRI_SWITCH_UNKNOWN,
LPWRAP_PRI_SWITCH_NI2 = PRI_SWITCH_NI2,
LPWRAP_PRI_SWITCH_DMS100 = PRI_SWITCH_DMS100,
LPWRAP_PRI_SWITCH_LUCENT5E = PRI_SWITCH_LUCENT5E,
LPWRAP_PRI_SWITCH_ATT4ESS = PRI_SWITCH_ATT4ESS,
LPWRAP_PRI_SWITCH_EUROISDN_E1 = PRI_SWITCH_EUROISDN_E1,
LPWRAP_PRI_SWITCH_EUROISDN_T1 = PRI_SWITCH_EUROISDN_T1,
LPWRAP_PRI_SWITCH_NI1 = PRI_SWITCH_NI1,
LPWRAP_PRI_SWITCH_GR303_EOC = PRI_SWITCH_GR303_EOC,
LPWRAP_PRI_SWITCH_GR303_TMC = PRI_SWITCH_GR303_TMC,
LPWRAP_PRI_SWITCH_QSIG = PRI_SWITCH_QSIG
LPWRAP_PRI_SWITCH_NI1 = PRI_SWITCH_NI1,
LPWRAP_PRI_SWITCH_GR303_EOC = PRI_SWITCH_GR303_EOC,
LPWRAP_PRI_SWITCH_GR303_TMC = PRI_SWITCH_GR303_TMC,
LPWRAP_PRI_SWITCH_QSIG = PRI_SWITCH_QSIG,
/* don't touch */
LPWRAP_PRI_SWITCH_MAX
} lpwrap_pri_switch_t;
typedef enum {
@ -88,7 +94,6 @@ typedef enum {
struct lpwrap_pri;
typedef int (*event_handler)(struct lpwrap_pri *, lpwrap_pri_event_t, pri_event *);
typedef int (*loop_handler)(struct lpwrap_pri *);
#define MAX_EVENT 18
struct lpwrap_pri {
struct pri *pri;
@ -96,7 +101,7 @@ struct lpwrap_pri {
zap_channel_t *dchan;
unsigned int flags;
void *private_info;
event_handler eventmap[MAX_EVENT+1];
event_handler eventmap[LPWRAP_PRI_EVENT_MAX];
loop_handler on_loop;
};

View File

@ -900,7 +900,7 @@ static void *zap_libpri_run(zap_thread_t *me, void *obj)
LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_INFO_RECEIVED, on_info);
LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RESTART, on_restart);
LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_IO_FAIL, on_io_fail);
if (down) {
zap_log(ZAP_LOG_INFO, "PRI back up on span %d\n", isdn_data->spri.span->span_id);
zap_set_state_all(span, ZAP_CHANNEL_STATE_RESTART);
@ -910,9 +910,9 @@ static void *zap_libpri_run(zap_thread_t *me, void *obj)
isdn_data->spri.on_loop = check_flags;
isdn_data->spri.private_info = span;
lpwrap_run_pri(&isdn_data->spri);
}
if (!zap_running() || zap_test_flag(span, ZAP_SPAN_STOP_THREAD)) {
break;
}