Merge branch 'master' of ssh://jolly@www.mISDN.org/var/git/lcr
[lcr.git] / gsm.h
1 extern "C" {
2 #include <openbsc/gsm_data.h>
3 }
4
5 struct gsm_conf {
6         char debug[128];                /* debug info */
7         char interface_bsc[64];         /* loopback interface BSC side */
8         char interface_lcr[64];         /* loopback interface LCR side */
9         char openbsc_cfg[128];          /* openbsc config file */
10         char short_name[64];            /* short network name */
11         char long_name[64];             /* long network name */
12         char hlr[64];                   /* database name */
13         int allow_all;                  /* accept unknown subscribers */
14         int keep_l2;                    /* keep layer 2 after exit */
15         int noemergshut;                /* don't shut down on emergency */
16         char pcapfile[128];             /* open capture file for BS11 links */
17         int reject_cause;               /* reject cause for unsubcribed IMSIs */
18 };
19
20 struct lcr_gsm {
21         void            *network;       /* OpenBSC network handle */
22         struct gsm_conf conf;           /* gsm.conf options */
23         int             gsm_sock;       /* loopback interface BSC side */
24         int             gsm_port;       /* loopback interface port number */
25 };
26
27 extern struct lcr_gsm *gsm;
28
29 /* GSM port class */
30 class Pgsm : public PmISDN
31 {
32         public:
33         Pgsm(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive, int mode);
34         ~Pgsm();
35
36         unsigned int p_m_g_callref; /* ref by OpenBSC */
37         unsigned int p_m_g_mode; /* data/transparent mode */
38         int p_m_g_gsm_b_sock; /* gsm bchannel socket */
39         int p_m_g_gsm_b_index; /* gsm bchannel socket index to use */
40         int p_m_g_gsm_b_active; /* gsm bchannel socket is activated */
41         struct lcr_msg *p_m_g_notify_pending;   /* queue for NOTIFY if not connected */
42         void *p_m_g_encoder, *p_m_g_decoder;    /* gsm handle */
43         signed short p_m_g_rxdata[160]; /* receive audio buffer */
44         int p_m_g_rxpos; /* position in audio buffer 0..159 */
45         int p_m_g_tch_connected; /* indicates if audio is connected */
46
47         void bchannel_close(void);
48         int bchannel_open(int index);
49         void bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len);
50         void bchannel_send(unsigned int prim, unsigned int id, unsigned char *data, int len);
51
52         void frame_send(void *_frame);
53         void frame_receive(void *_frame);
54
55         int hunt_bchannel(void);
56         void setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
57         void start_dtmf_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
58         void stop_dtmf_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
59         void call_conf_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *gsm);
60         void alert_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
61         void setup_cnf(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
62         void setup_compl_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
63         void disc_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
64         void rel_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
65         void notify_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
66         void hold_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
67         void retr_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
68         void message_setup(unsigned int epoint_id, int message_id, union parameter *param);
69         void message_notify(unsigned int epoint_id, int message_id, union parameter *param);
70         void message_alerting(unsigned int epoint_id, int message_id, union parameter *param);
71         void message_connect(unsigned int epoint_id, int message_id, union parameter *param);
72         void message_disconnect(unsigned int epoint_id, int message_id, union parameter *param);
73         void message_release(unsigned int epoint_id, int message_id, union parameter *param);
74         int message_epoint(unsigned int epoint_id, int message_id, union parameter *param);
75         int handler(void);
76 };
77
78 extern char *gsm_conf_error;
79 int gsm_conf(struct gsm_conf *gsm_conf);
80 int handle_gsm(void);
81 int gsm_exit(int rc);
82 int gsm_init(void);
83