spandsp  3.0.0
socket_harness.h
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * socket_harness.h
5  *
6  * Written by Steve Underwood <steveu@coppice.org>
7  *
8  * Copyright (C) 2012 Steve Underwood
9  *
10  * All rights reserved.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2, as
14  * published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25 
26 typedef int (*termio_update_func_t)(void *user_data, struct termios *termios);
27 
28 typedef int (*put_msg_free_space_func_t)(void *user_data);
29 
30 typedef void (*span_timer_handler_t)(void *user_data);
31 
32 typedef struct socket_harness_state_s
33 {
34  void *user_data;
35 
36  span_put_msg_func_t terminal_callback;
37  termio_update_func_t termios_callback;
38  span_modem_status_func_t hangup_callback;
39  put_msg_free_space_func_t terminal_free_space_callback;
40 
41  span_rx_handler_t rx_callback;
42  span_rx_fillin_handler_t rx_fillin_callback;
43  span_tx_handler_t tx_callback;
44  span_timer_handler_t timer_callback;
45 
46  int net_fd;
47  int pty_fd;
48  logging_state_t logging;
49  struct termios termios;
50 
51  unsigned int delay;
52  unsigned int started;
53  unsigned int pty_closed;
54  unsigned int close_count;
55 
58 
59 extern span_timestamp_t socket_harness_timer;
60 
61 span_timestamp_t now_us(void);
62 
63 int socket_harness_run(socket_harness_state_t *s, int kick);
64 
65 int socket_harness_terminal_write(void *user_data, const uint8_t *buf, size_t len);
66 
67 socket_harness_state_t *socket_harness_init(socket_harness_state_t *s,
68  const char *socket_name,
69  const char *tag,
70  int caller,
71  span_put_msg_func_t terminal_callback,
72  termio_update_func_t termios_callback,
73  span_modem_status_func_t hangup_callback,
74  put_msg_free_space_func_t terminal_free_space_callback,
75  span_rx_handler_t rx_callback,
76  span_rx_fillin_handler_t rx_fillin_callback,
77  span_tx_handler_t tx_callback,
78  void *user_data);
79 
80 int socket_harness_release(socket_harness_state_t *s);
81 
82 int socket_harness_free(socket_harness_state_t *s);
Definition: socket_harness.h:32
void(* span_modem_status_func_t)(void *user_data, int status)
Definition: async.h:131
void(* span_put_msg_func_t)(void *user_data, const uint8_t *msg, int len)
Definition: async.h:107
Definition: private/logging.h:33
Definition: pseudo_terminals.h:33