summaryrefslogtreecommitdiffstats
path: root/src/modem.h
blob: 43c930ca22415ed694c1585b4dcd2a8f761e4f0d (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef foomodemhfoo
#define foomodemhfoo

/* $Id$ */

/***
  This file is part of ivam2.

  ivam2 is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  
  ivam2 is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
  License for more details.
  
  You should have received a copy of the GNU General Public License
  along with ivam2; if not, write to the Free Software Foundation,
  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***/

#include "buffio.h"
#include "msntab.h"

enum modem_state {
    MODEM_STATE_INIT,
    MODEM_STATE_CALLER_NUMBER_EXPECT,
    MODEM_STATE_CALLER_NUMBER,
    MODEM_STATE_RING_EXPECT,
    MODEM_STATE_RING,
    MODEM_STATE_RINGING,
    MODEM_STATE_ATA,
    MODEM_STATE_VTXVRX,
    MODEM_STATE_CONNECTION,
    MODEM_STATE_CONNECTION_SHBUF,
    MODEM_STATE_PRE_HANGUP_HUPSEQ,
    MODEM_STATE_PRE_HANGUP_ATHSEQ,
    MODEM_STATE_HANGUP,
    MODEM_STATE_CHILD_DRAIN,      /* wait until no further data may/has to be written to the child */
    MODEM_STATE_CHILD_WAIT_EOF,   /* wait until no further data may be read from child */
    MODEM_STATE_CHILD_KILL,
    MODEM_STATE_IDLE
};

#define MODEM_BUF_LEN (10*1024)

struct modem {
    char *dev;
    char *name;

    struct buffio *buffio;
    
    enum modem_state state;
    int command_index;

    struct buffio *child_buffio;
    pid_t child_pid;

    struct dtmf_fifo *dtmf_fifo;

    struct timeval timeout;

    char *ring_number;
    char *caller_number;

    char *listen_msn;

    struct tabentry *tabentry;

    int dle_flag;
    int flush_msg;
};

struct modem *modem_open(const char *dev, const char *msn);
void modem_close(struct modem *m);

#endif