[package] busybox: Check if an SSH daemon is enabled before disabling telnet access...
[openwrt/svn-archive/archive.git] / package / libtapi / src / tapi-port.h
1 #ifndef __TAPI_PORT_H__
2 #define __TAPI_PORT_H__
3
4 #include <sys/time.h>
5
6 #include "list.h"
7 #include "events.h"
8
9 struct tapi_port;
10 struct tapi_device;
11
12 struct tapi_dtmf_event {
13 struct timeval time;
14 unsigned char code;
15 };
16
17 struct tapi_hook_event {
18 bool on;
19 };
20
21 enum tapi_event_type {
22 TAPI_EVENT_TYPE_DTMF,
23 TAPI_EVENT_TYPE_HOOK,
24 };
25
26 struct tapi_event {
27 enum tapi_event_type type;
28 union {
29 struct tapi_dtmf_event dtmf;
30 struct tapi_hook_event hook;
31 };
32 };
33
34 struct tapi_port_event_listener {
35 void (*callback)(struct tapi_port *, struct tapi_event *event, void *data);
36 void *data;
37
38 struct list_head head;
39 };
40
41 struct tapi_port {
42 int id;
43 int fd;
44 int input_fd;
45 unsigned int ep;
46
47 struct event_callback input_cb;
48
49 struct list_head event_listeners;
50 };
51
52 int tapi_port_open(struct tapi_device *dev, unsigned int id, struct tapi_port
53 *port);
54 int tapi_port_set_ring(struct tapi_port *port, bool ring);
55 int tapi_port_register_event(struct tapi_port *port,
56 struct tapi_port_event_listener *cb);
57
58 void tapi_port_unregister_event(struct tapi_port *port,
59 struct tapi_port_event_listener *cb);
60
61 static inline int tapi_port_get_endpoint(struct tapi_port *port)
62 {
63 return port->ep;
64 }
65
66 #endif