diff --git a/libpri.h b/libpri.h index ba942dd..d8ea12f 100644 --- a/libpri.h +++ b/libpri.h @@ -1308,6 +1308,9 @@ struct pri *pri_new_bri(int fd, int ptpmode, int nodetype, int switchtype); /* Create D-channel just as above with user defined I/O callbacks and data */ struct pri *pri_new_cb(int fd, int nodetype, int switchtype, pri_io_cb io_read, pri_io_cb io_write, void *userdata); +/* Create BRI D-channel just as above with user defined I/O callbacks and data */ +struct pri *pri_new_bri_cb(int fd, int ptpmode, int nodetype, int switchtype, pri_io_cb io_read, pri_io_cb io_write, void *userdata); + /* Retrieve the user data associated with the D channel */ void *pri_get_userdata(struct pri *pri); diff --git a/pri.c b/pri.c index d46740a..53aee0e 100644 --- a/pri.c +++ b/pri.c @@ -457,6 +457,21 @@ struct pri *pri_new_cb(int fd, int nodetype, int switchtype, pri_io_cb io_read, return __pri_new_tei(fd, nodetype, switchtype, NULL, io_read, io_write, userdata, Q921_TEI_PRI, 0); } +struct pri *pri_new_bri_cb(int fd, int ptpmode, int nodetype, int switchtype, pri_io_cb io_read, pri_io_cb io_write, void *userdata) +{ + if (!io_read) { + io_read = __pri_read; + } + if (!io_write) { + io_write = __pri_write; + } + if (ptpmode) { + return __pri_new_tei(fd, nodetype, switchtype, NULL, io_read, io_write, userdata, Q921_TEI_PRI, 1); + } else { + return __pri_new_tei(fd, nodetype, switchtype, NULL, io_read, io_write, userdata, Q921_TEI_GROUP, 1); + } +} + void *pri_get_userdata(struct pri *pri) { return pri ? pri->userdata : NULL;