Make pridump and testprilib compile again.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2292 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
parent
053a38202e
commit
4af121db62
12
pridump.c
12
pridump.c
@ -42,7 +42,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/types.h>
|
||||
#include <zaptel/zaptel.h>
|
||||
#include <dahdi/user.h>
|
||||
#include "libpri.h"
|
||||
#include "pri_q921.h"
|
||||
#include "pri_q931.h"
|
||||
@ -50,18 +50,18 @@
|
||||
static int pri_open(char *dev)
|
||||
{
|
||||
int dfd;
|
||||
struct zt_params p;
|
||||
struct dahdi_params p;
|
||||
|
||||
dfd = open(dev, O_RDWR);
|
||||
if (dfd < 0) {
|
||||
fprintf(stderr, "Failed to open dchannel '%s': %s\n", dev, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(dfd, ZT_GET_PARAMS, &p)) {
|
||||
if (ioctl(dfd, DAHDI_GET_PARAMS, &p)) {
|
||||
fprintf(stderr, "Unable to get parameters on '%s': %s\n", dev, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if ((p.sigtype != ZT_SIG_HDLCRAW) && (p.sigtype != ZT_SIG_HDLCFCS)) {
|
||||
if ((p.sigtype != DAHDI_SIG_HDLCRAW) && (p.sigtype != DAHDI_SIG_HDLCFCS)) {
|
||||
fprintf(stderr, "%s is in %d signalling, not FCS HDLC or RAW HDLC mode\n", dev, p.sigtype);
|
||||
return -1;
|
||||
}
|
||||
@ -94,8 +94,8 @@ static int pri_bridge(int d1, int d2)
|
||||
max = d1;
|
||||
if (max < d2)
|
||||
max = d2;
|
||||
ioctl(d1, ZT_GETEVENT, &e);
|
||||
ioctl(d2, ZT_GETEVENT, &e);
|
||||
ioctl(d1, DAHDI_GETEVENT, &e);
|
||||
ioctl(d2, DAHDI_GETEVENT, &e);
|
||||
res = select(max + 1, &fds, NULL, NULL, NULL);
|
||||
if (res < 0) {
|
||||
fprintf(stderr, "Select returned %d: %s\n", res, strerror(errno));
|
||||
|
22
testprilib.c
22
testprilib.c
@ -48,13 +48,10 @@
|
||||
#include <sys/time.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <zaptel/zaptel.h>
|
||||
#ifndef SOLARIS
|
||||
#include <zap.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <sys/select.h>
|
||||
#include "libpri.h"
|
||||
#include "pri_q921.h"
|
||||
#include "pri_q931.h"
|
||||
|
||||
#ifndef AF_LOCAL
|
||||
@ -66,7 +63,7 @@
|
||||
#define PRI_DEF_NODETYPE PRI_CPE
|
||||
#define PRI_DEF_SWITCHTYPE PRI_SWITCH_NI2
|
||||
|
||||
static struct pri *first, *cur;
|
||||
static struct pri *first;
|
||||
|
||||
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
@ -159,9 +156,9 @@ static void testmsg(struct pri *pri, char *s)
|
||||
*c = '\0';
|
||||
c++;
|
||||
}
|
||||
if (keeplast)
|
||||
if (keeplast || !pri)
|
||||
printf("%s", s);
|
||||
else if (cur == first)
|
||||
else if (pri == first)
|
||||
printf("-1 %s", s);
|
||||
else
|
||||
printf("-2 %s", s);
|
||||
@ -185,9 +182,9 @@ static void testerr(struct pri *pri, char *s)
|
||||
*c = '\0';
|
||||
c++;
|
||||
}
|
||||
if (keeplast)
|
||||
if (keeplast || !pri)
|
||||
printf("%s", s);
|
||||
else if (cur == first)
|
||||
else if (pri == first)
|
||||
printf("=1 %s", s);
|
||||
else
|
||||
printf("=2 %s", s);
|
||||
@ -207,7 +204,7 @@ static void *dchan(void *data)
|
||||
/* Joint D-channel */
|
||||
struct pri *pri = data;
|
||||
struct timeval *next, tv;
|
||||
pri_event *e;
|
||||
pri_event *e = NULL;
|
||||
fd_set fds;
|
||||
int res;
|
||||
for(;;) {
|
||||
@ -228,7 +225,6 @@ static void *dchan(void *data)
|
||||
FD_SET(pri_fd(pri), &fds);
|
||||
res = select(pri_fd(pri) + 1, &fds, NULL, NULL, next ? &tv : NULL);
|
||||
pthread_mutex_lock(&lock);
|
||||
cur = pri;
|
||||
if (res < 0) {
|
||||
perror("select");
|
||||
} else if (!res) {
|
||||
@ -238,9 +234,9 @@ static void *dchan(void *data)
|
||||
}
|
||||
if (e) {
|
||||
if (first == pri) {
|
||||
event1(e->gen.pri, e);
|
||||
event1(pri, e);
|
||||
} else {
|
||||
event2(e->gen.pri, e);
|
||||
event2(pri, e);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&lock);
|
||||
|
Loading…
Reference in New Issue
Block a user