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