Add pri_new_bri_cb() API - Create BRI D-channel with user defined I/O callbacks and data
There currently exists a pri_new_cb() API call that allows you to create a PRI with user-defined I/O read and write callbacks, and option userdata. Add the same capability for BRI interfaces by adding a pri_new_bri_cb() API function. (closes issue #16477) Reported by: nic_bellamy Patches: pri_new_bri_cb_api.patch uploaded by nic bellamy (license 299) (with minor cosmetic changes) git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@1836 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
parent
02c5939a33
commit
4b21faa82d
3
libpri.h
3
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);
|
||||
|
||||
|
15
pri.c
15
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;
|
||||
|
Loading…
Reference in New Issue
Block a user