update
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@23 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
0c1eacbf25
commit
2dcf9de997
|
@ -175,6 +175,7 @@ struct zap_channel {
|
||||||
zap_chan_type_t type;
|
zap_chan_type_t type;
|
||||||
zap_socket_t sockfd;
|
zap_socket_t sockfd;
|
||||||
zap_channel_flag_t flags;
|
zap_channel_flag_t flags;
|
||||||
|
void *mod_data;
|
||||||
struct zap_software_interface *zint;
|
struct zap_software_interface *zint;
|
||||||
};
|
};
|
||||||
typedef struct zap_channel zap_channel_t;
|
typedef struct zap_channel zap_channel_t;
|
||||||
|
@ -189,8 +190,8 @@ struct zap_span {
|
||||||
typedef struct zap_span zap_span_t;
|
typedef struct zap_span zap_span_t;
|
||||||
|
|
||||||
#define ZINT_CONFIGURE_ARGS (struct zap_software_interface *zint)
|
#define ZINT_CONFIGURE_ARGS (struct zap_software_interface *zint)
|
||||||
#define ZINT_OPEN_ARGS (unsigned span_id, unsigned chan_id, zap_channel_t **zchan)
|
#define ZINT_OPEN_ARGS (zap_channel_t *zchan)
|
||||||
#define ZINT_CLOSE_ARGS (zap_channel_t **zchan)
|
#define ZINT_CLOSE_ARGS (zap_channel_t *zchan)
|
||||||
#define ZINT_SET_CODEC_ARGS (zap_channel_t *zchan, zap_codec_t codec)
|
#define ZINT_SET_CODEC_ARGS (zap_channel_t *zchan, zap_codec_t codec)
|
||||||
#define ZINT_SET_INTERVAL_ARGS (zap_channel_t *zchan, unsigned ms)
|
#define ZINT_SET_INTERVAL_ARGS (zap_channel_t *zchan, unsigned ms)
|
||||||
#define ZINT_WAIT_ARGS (zap_channel_t *zchan, zap_wait_flag_t flags, unsigned to)
|
#define ZINT_WAIT_ARGS (zap_channel_t *zchan, zap_wait_flag_t flags, unsigned to)
|
||||||
|
@ -216,7 +217,7 @@ typedef zap_status_t (*zint_write_t) ZINT_WRITE_ARGS ;
|
||||||
#define ZINT_WRITE_FUNCTION(name) zap_status_t name ZINT_WRITE_ARGS
|
#define ZINT_WRITE_FUNCTION(name) zap_status_t name ZINT_WRITE_ARGS
|
||||||
|
|
||||||
#define ZINT_CONFIGURE_MUZZLE assert(zint != NULL)
|
#define ZINT_CONFIGURE_MUZZLE assert(zint != NULL)
|
||||||
#define ZINT_OPEN_MUZZLE assert(span_id != 0); assert(chan_id != 0); assert(zchan != NULL)
|
#define ZINT_OPEN_MUZZLEE assert(zchan != NULL)
|
||||||
#define ZINT_CLOSE_MUZZLE assert(zchan != NULL)
|
#define ZINT_CLOSE_MUZZLE assert(zchan != NULL)
|
||||||
#define ZINT_SET_CODEC_MUZZLE assert(zchan != NULL); assert(codec != 0)
|
#define ZINT_SET_CODEC_MUZZLE assert(zchan != NULL); assert(codec != 0)
|
||||||
#define ZINT_SET_INTERVAL_MUZZLE assert(zchan != NULL); assert(ms != 0)
|
#define ZINT_SET_INTERVAL_MUZZLE assert(zchan != NULL); assert(ms != 0)
|
||||||
|
|
|
@ -189,35 +189,43 @@ zap_status_t zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_cha
|
||||||
zap_status_t zap_channel_open(const char *name, unsigned span_id, unsigned chan_id, zap_channel_t **zchan)
|
zap_status_t zap_channel_open(const char *name, unsigned span_id, unsigned chan_id, zap_channel_t **zchan)
|
||||||
{
|
{
|
||||||
zap_software_interface_t *zint = (zap_software_interface_t *) hashtable_search(globals.interface_hash, (char *)name);
|
zap_software_interface_t *zint = (zap_software_interface_t *) hashtable_search(globals.interface_hash, (char *)name);
|
||||||
|
zap_status_t status = ZAP_FAIL;
|
||||||
|
|
||||||
if (span_id < ZAP_MAX_SPANS_INTERFACE && chan_id < ZAP_MAX_CHANNELS_SPAN && zint) {
|
if (span_id < ZAP_MAX_SPANS_INTERFACE && chan_id < ZAP_MAX_CHANNELS_SPAN && zint) {
|
||||||
zap_channel_t *check;
|
zap_channel_t *check;
|
||||||
check = &zint->spans[span_id].channels[chan_id];
|
check = &zint->spans[span_id].channels[chan_id];
|
||||||
if (zap_test_flag(check, ZAP_CHANNEL_READY) && ! zap_test_flag(check, ZAP_CHANNEL_OPEN)) {
|
if (zap_test_flag(check, ZAP_CHANNEL_READY) && ! zap_test_flag(check, ZAP_CHANNEL_OPEN)) {
|
||||||
zap_set_flag(check, ZAP_CHANNEL_OPEN);
|
status = check->zint->open(check);
|
||||||
*zchan = check;
|
if (status == ZAP_SUCCESS) {
|
||||||
return ZAP_SUCCESS;
|
zap_set_flag(check, ZAP_CHANNEL_OPEN);
|
||||||
|
*zchan = check;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ZAP_FAIL;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
zap_status_t zap_channel_close(zap_channel_t **zchan)
|
zap_status_t zap_channel_close(zap_channel_t **zchan)
|
||||||
{
|
{
|
||||||
zap_channel_t *check;
|
zap_channel_t *check;
|
||||||
|
zap_status_t status = ZAP_FAIL;
|
||||||
|
|
||||||
*zchan = NULL;
|
*zchan = NULL;
|
||||||
|
|
||||||
assert(zchan != NULL);
|
assert(zchan != NULL);
|
||||||
check = *zchan;
|
check = *zchan;
|
||||||
assert(check != NULL);
|
assert(check != NULL);
|
||||||
|
|
||||||
if (zap_test_flag(check, ZAP_CHANNEL_OPEN)) {
|
if (zap_test_flag(check, ZAP_CHANNEL_OPEN)) {
|
||||||
zap_clear_flag(check, ZAP_CHANNEL_OPEN);
|
status = check->zint->close(check);
|
||||||
return ZAP_SUCCESS;
|
if (status == ZAP_SUCCESS) {
|
||||||
|
zap_clear_flag(check, ZAP_CHANNEL_OPEN);
|
||||||
|
*zchan = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ZAP_FAIL;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,58 +74,6 @@ typedef unsigned __int32 u_int32_t;
|
||||||
|
|
||||||
static zap_software_interface_t wanpipe_interface;
|
static zap_software_interface_t wanpipe_interface;
|
||||||
|
|
||||||
struct wanpipe_channel {
|
|
||||||
struct zap_channel zchan;
|
|
||||||
int x;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned wp_open_lapd(zap_span_t *span, const char *name)
|
|
||||||
{
|
|
||||||
struct wan_sockaddr_ll sa;
|
|
||||||
zap_socket_t sock = -1;
|
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
sock = socket(AF_WANPIPE, SOCK_RAW, 0);
|
|
||||||
memset(&sa,0,sizeof(struct wan_sockaddr_ll));
|
|
||||||
|
|
||||||
zap_log(ZAP_LOG_DEBUG, "attempting to open lapd device socket %s\n", name);
|
|
||||||
|
|
||||||
if( sock < 0 ) {
|
|
||||||
zap_log(ZAP_LOG_ERROR, "socket error!\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
zap_copy_string(sa.sll_device, name, sizeof(sa.sll_device));
|
|
||||||
zap_copy_string(sa.sll_card, "wanpipe1", sizeof(sa.sll_card));
|
|
||||||
|
|
||||||
sa.sll_protocol = htons(PVC_PROT);
|
|
||||||
sa.sll_family = AF_WANPIPE;
|
|
||||||
|
|
||||||
if(bind(sock, (struct sockaddr *)&sa, sizeof(struct wan_sockaddr_ll)) < 0){
|
|
||||||
zap_log(ZAP_LOG_ERROR, "socket bind error!\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
unsigned customer_id;
|
|
||||||
int err = ioctl(sock,SIOC_AFT_CUSTOMER_ID,&customer_id);
|
|
||||||
if (err){
|
|
||||||
perror("Customer ID: ");
|
|
||||||
}else{
|
|
||||||
printf("Customer ID 0x%X\n",customer_id);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static zap_socket_t wp_open_device(int span, int chan)
|
static zap_socket_t wp_open_device(int span, int chan)
|
||||||
{
|
{
|
||||||
char fname[256];
|
char fname[256];
|
||||||
|
@ -186,26 +134,6 @@ static unsigned wp_configure_channel(zap_config_t *cfg, const char *str, zap_spa
|
||||||
|
|
||||||
assert(str != NULL);
|
assert(str != NULL);
|
||||||
|
|
||||||
if (type == ZAP_CHAN_TYPE_DQ921) {
|
|
||||||
char *flag, *name;
|
|
||||||
|
|
||||||
flag = str;
|
|
||||||
if ((name = strchr(flag, ':'))) {
|
|
||||||
name++;
|
|
||||||
} else {
|
|
||||||
name = flag;
|
|
||||||
flag = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flag) {
|
|
||||||
if (strstr(flag, "q931")) {
|
|
||||||
type = ZAP_CHAN_TYPE_DQ931;
|
|
||||||
configured += wp_open_lapd(span, name);
|
|
||||||
return configured;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mydata = strdup(str);
|
mydata = strdup(str);
|
||||||
assert(mydata != NULL);
|
assert(mydata != NULL);
|
||||||
|
@ -315,7 +243,14 @@ static ZINT_CONFIGURE_FUNCTION(wanpipe_configure)
|
||||||
if (d) {
|
if (d) {
|
||||||
zap_log(ZAP_LOG_WARNING, "ignoring extra d-channel\n");
|
zap_log(ZAP_LOG_WARNING, "ignoring extra d-channel\n");
|
||||||
} else {
|
} else {
|
||||||
configured += wp_configure_channel(&cfg, val, span, ZAP_CHAN_TYPE_DQ921);
|
zap_chan_type_t qtype;
|
||||||
|
if (!strncasecmp(val, "lapd:", 5)) {
|
||||||
|
qtype = ZAP_CHAN_TYPE_DQ931;
|
||||||
|
val += 5;
|
||||||
|
} else {
|
||||||
|
qtype = ZAP_CHAN_TYPE_DQ921;
|
||||||
|
}
|
||||||
|
configured += wp_configure_channel(&cfg, val, span, qtype);
|
||||||
d++;
|
d++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue