summaryrefslogtreecommitdiffstats
path: root/src/router/routing.h
blob: d5e43ca15585a1c1e47f72ad33884630b70d2934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
struct string_queue {
	struct string_queue	*next;
	char			*string;
};

struct call;

typedef struct routing {
	struct call		*call;

	int			routing;	/* set, if routing is performed (script runs) */

	int			envc;		/* number of environment variables */
	const char		*envp[256];	/* environment variables */
	int			envc_dialing;	/* envc index for dialing number */
	int			envc_keypad;	/* envc index for keypad */
	int			envc_complete;	/* envc index for complete */

	pid_t			script_pid;	/* pid of routing script */
	int			script_stdin;	/* pipe to stdin */
	int			script_stdout;	/* pipe from stdout */
	int			script_stdout_child;	/* child side of pipe */
	int			script_stderr;	/* pipe from stderr */
	int			script_stderr_child;	/* child side of pipe */

	struct string_queue	*stdin_queue;	/* strings to write to script */
	char			stdout_buffer[1024]; /* line buffer when reading from script */
	int			stdout_pos;	/* number of characters in buffer */
	struct string_queue	*stdout_queue;	/* strings read from script */
	char			stderr_buffer[1024]; /* line buffer when reading from script */
	int			stderr_pos;	/* number of characters in buffer */
	struct string_queue	*stderr_queue;	/* strings read from script */
} routing_t;

void env_help(void);
void routing_env_msg(routing_t *routing, osmo_cc_msg_t *msg);
void routing_env_dialing(routing_t *routing, char *number, char *keypad, int complete);
void routing_env_free(routing_t *routing);
void routing_start(routing_t *routing, const char *script, const char *shell);
void routing_stop(routing_t *routing);
void routing_send(routing_t *routing, const char *string);
int routing_handle(routing_t *routing);

/* callbacks */
void routing_receive_stdout(routing_t *routing, const char *string);
void routing_receive_stderr(routing_t *routing, const char *string);
void routing_close(routing_t *routing);