getting closer
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@111 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
31f79bf237
commit
04d4509a32
|
@ -1153,7 +1153,7 @@ uint32_t zap_separate_string(char *buf, char delim, char **array, int arraylen)
|
||||||
|
|
||||||
void print_bits(uint8_t *b, int bl, char *buf, int blen, int e)
|
void print_bits(uint8_t *b, int bl, char *buf, int blen, int e)
|
||||||
{
|
{
|
||||||
int i,j = 0,k;
|
int i,j = 0, k, l = 0;
|
||||||
|
|
||||||
if (blen < (bl * 10) + 2) {
|
if (blen < (bl * 10) + 2) {
|
||||||
return;
|
return;
|
||||||
|
@ -1171,7 +1171,11 @@ void print_bits(uint8_t *b, int bl, char *buf, int blen, int e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf[j++] = ']';
|
buf[j++] = ']';
|
||||||
|
buf[j++] = ' ';
|
||||||
|
if (++l == 6) {
|
||||||
buf[j++] = '\n';
|
buf[j++] = '\n';
|
||||||
|
l = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[j++] = '\0';
|
buf[j++] = '\0';
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
#include "zap_isdn.h"
|
#include "zap_isdn.h"
|
||||||
#include "Q931.h"
|
#include "Q931.h"
|
||||||
#include "Q921.h"
|
#include "Q921.h"
|
||||||
|
#define LINE "--------------------------------------------------------------------------------"
|
||||||
|
#define IODEBUG
|
||||||
|
|
||||||
static L3INT zap_isdn_931_err(void *pvt, L3INT id, L3INT p1, L3INT p2)
|
static L3INT zap_isdn_931_err(void *pvt, L3INT id, L3INT p1, L3INT p2)
|
||||||
{
|
{
|
||||||
|
@ -46,11 +47,26 @@ static L3INT zap_isdn_931_err(void *pvt, L3INT id, L3INT p1, L3INT p2)
|
||||||
static L3INT zap_isdn_931_34(void *pvt, L2UCHAR *msg, L2INT mlen)
|
static L3INT zap_isdn_931_34(void *pvt, L2UCHAR *msg, L2INT mlen)
|
||||||
{
|
{
|
||||||
zap_span_t *span = (zap_span_t *) pvt;
|
zap_span_t *span = (zap_span_t *) pvt;
|
||||||
|
zap_isdn_data_t *data = span->isdn_data;
|
||||||
Q931mes_Generic *gen = (Q931mes_Generic *) msg;
|
Q931mes_Generic *gen = (Q931mes_Generic *) msg;
|
||||||
|
|
||||||
assert(span != NULL);
|
|
||||||
|
|
||||||
zap_log(ZAP_LOG_DEBUG, "Yay I got an event! %d\n", gen->MesType);
|
Q931mes_Restart * restart = (Q931mes_Restart*)msg;
|
||||||
|
|
||||||
|
L3INT ieoff = Q931GetIEOffset(restart->RestartInd);
|
||||||
|
Q931ie_RestartInd * restartind = (void *)(&restart->buf + (ieoff * sizeof(restart->buf[1])));
|
||||||
|
|
||||||
|
|
||||||
|
assert(span != NULL);
|
||||||
|
assert(data != NULL);
|
||||||
|
printf("WTF: %d", ((Q931mes_Restart*)gen)->Size);
|
||||||
|
zap_log(ZAP_LOG_DEBUG, "Yay I got an event! %d %d\n", gen->MesType, ((Q931mes_Restart*)gen)->Size);
|
||||||
|
zap_log(ZAP_LOG_DEBUG, "send ack %d\n", restartind->Class);
|
||||||
|
zap_log(ZAP_LOG_DEBUG, "send ack %d\n", ((Q931mes_Restart*)gen)->Size);
|
||||||
|
|
||||||
|
printf("XXXXXXXXXXXXx");
|
||||||
|
gen->MesType = Q931mes_RESTART_ACKNOWLEDGE;
|
||||||
|
Q931Rx43(&data->q931, msg, 12);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -59,11 +75,17 @@ static int zap_isdn_921_21(void *pvt, L2UCHAR *msg, L2INT mlen)
|
||||||
{
|
{
|
||||||
zap_span_t *span = (zap_span_t *) pvt;
|
zap_span_t *span = (zap_span_t *) pvt;
|
||||||
zap_size_t len = (zap_size_t) mlen;
|
zap_size_t len = (zap_size_t) mlen;
|
||||||
|
#ifdef IODEBUG
|
||||||
|
char bb[512] = "";
|
||||||
|
print_bits(msg, (int)len, bb, sizeof(bb), 1);
|
||||||
|
zap_log(ZAP_LOG_DEBUG, "WRITE %d\n%s\n%s\n\n", (int)len, LINE, bb);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
assert(span != NULL);
|
assert(span != NULL);
|
||||||
return zap_channel_write(span->isdn_data->dchan, msg, &len) == ZAP_SUCCESS ? 0 : -1;
|
return zap_channel_write(span->isdn_data->dchan, msg, &len) == ZAP_SUCCESS ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *zap_isdn_run(zap_thread_t *me, void *obj)
|
static void *zap_isdn_run(zap_thread_t *me, void *obj)
|
||||||
{
|
{
|
||||||
zap_span_t *span = (zap_span_t *) obj;
|
zap_span_t *span = (zap_span_t *) obj;
|
||||||
|
@ -98,11 +120,11 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
|
||||||
if (flags & ZAP_READ) {
|
if (flags & ZAP_READ) {
|
||||||
len = sizeof(buf);
|
len = sizeof(buf);
|
||||||
if (zap_channel_read(data->dchan, buf, &len) == ZAP_SUCCESS) {
|
if (zap_channel_read(data->dchan, buf, &len) == ZAP_SUCCESS) {
|
||||||
/*char bb[512] = "";
|
#ifdef IODEBUG
|
||||||
|
char bb[512] = "";
|
||||||
print_bits(buf, (int)len, bb, sizeof(bb), 1);
|
print_bits(buf, (int)len, bb, sizeof(bb), 1);
|
||||||
zap_log(ZAP_LOG_DEBUG, "Read %d bytes\n%s\n", (int)len, bb);
|
zap_log(ZAP_LOG_DEBUG, "READ %d\n%s\n%s\n\n", (int)len, LINE, bb);
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
Q921QueueHDLCFrame(&data->q921, buf, (int)len);
|
Q921QueueHDLCFrame(&data->q921, buf, (int)len);
|
||||||
Q921Rx12(&data->q921);
|
Q921Rx12(&data->q921);
|
||||||
|
|
Loading…
Reference in New Issue