int Q921Rx12(L2TRUNK trunk);
int Q921Rx32(L2TRUNK trunk, L2UCHAR * Mes, L2INT Size);
int Q921Start(L2TRUNK trunk);
-void Q921SetGetTimeCB(L2ULONG (*callback)());\r
-void Q921TimerTick(L2TRUNK trunk);\r
+void Q921SetGetTimeCB(L2ULONG (*callback)());
+void Q921TimerTick(L2TRUNK trunk);
#endif
#include "zap_isdn.h"
#include "Q931.h"
#include "Q921.h"
+#ifdef WIN32
+#include <windows.h>
+#else
+#include <sys/time.h>
+#endif
+
#define LINE "--------------------------------------------------------------------------------"
#define IODEBUG
+static L2ULONG zap_time_now()
+{
+#ifdef WIN32
+ return timeGetTime();
+#else
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return ((tv.tv_sec * 1000) + (tv.tv_usec / 1000));
+#endif
+}
+
static L3INT zap_isdn_931_err(void *pvt, L3INT id, L3INT p1, L3INT p2)
{
zap_log(ZAP_LOG_ERROR, "ERROR: %d %d %d", id, p1, p2);
unsigned char buf[1024];
zap_size_t len = sizeof(buf);
+#ifdef WIN32
+ timeBeginPeriod(1);
+#endif
+
zap_log(ZAP_LOG_DEBUG, "ISDN thread starting.\n");
Q921Start(&data->q921);
while(zap_test_flag(data, ZAP_ISDN_RUNNING)) {
zap_wait_flag_t flags = ZAP_READ;
zap_status_t status = zap_channel_wait(data->dchan, &flags, 100);
-
+
+ Q921TimerTick(&data->q921);
+
switch(status) {
case ZAP_FAIL:
{
zap_channel_close(&data->dchans[1]);
zap_clear_flag(span->isdn_data, ZAP_ISDN_RUNNING);
+#ifdef WIN32
+ timeEndPeriod(1);
+#endif
+
zap_log(ZAP_LOG_DEBUG, "ISDN thread ended.\n");
return NULL;
}
zap_status_t zap_isdn_init(void)
{
Q931Initialize();
+
+ Q921SetGetTimeCB(zap_time_now);
return ZAP_SUCCESS;
}