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