[ifxmips]
[openwrt.git] / package / tapi_sip / src / dialdetector.h
1 #include <linux/input.h>
2 #include <sys/epoll.h>
3 #include <stdint.h>
4 #include <stdbool.h>
5
6
7 #include <stdlib.h>
8 #include <stdio.h>
9
10 #include "events.h"
11 #include "timerfd.h"
12
13 #include "tapi-port.h"
14
15 enum dialdetector_dial_state {
16         DIALDETECTOR_DIAL_WAIT = 1,
17         DIALDETECTOR_DIAL_WAIT_TIMEOUT = 2,
18 };
19
20 enum dialdetector_port_state {
21         DIALDETECTOR_PORT_INACTIVE = 0,
22         DIALDETECTOR_PORT_ACTIVE = 1,
23         DIALDETECTOR_PORT_ACTIVE_DOWN = 2,
24 };
25
26 struct dialdetector {
27         enum dialdetector_dial_state dial_state;
28         enum dialdetector_port_state port_state;
29
30         struct tapi_port *port;
31         int timer_fd;
32         int impulse_timer_fd;
33
34         struct event_callback timeout_cb;
35         struct event_callback impulse_cb;
36         struct tapi_port_event_listener port_listener;
37
38         size_t num_digits;
39         unsigned char digits[20];
40
41         unsigned int impulses;
42
43         void (*dial_callback)(struct tapi_port *port, size_t num_digits, const unsigned char *digits);
44 };
45
46
47 struct tapi_port;
48
49 struct dialdetector *dialdetector_alloc(struct tapi_port *port);