Improved and applied Wimpy's Asterisk 1.8.x support.
[lcr.git] / gsm.h
1 extern int new_callref;
2
3 struct gsm_conf {
4         char debug[128];                /* debug info */
5         char openbsc_cfg[128];          /* openbsc config file */
6         char short_name[64];            /* short network name */
7         char long_name[64];             /* long network name */
8         char hlr[64];                   /* database name */
9         int allow_all;                  /* accept unknown subscribers */
10         int keep_l2;                    /* keep layer 2 after exit */
11         char pcapfile[128];             /* open capture file for BS11 links */
12         int reject_cause;               /* reject cause for unsubcribed IMSIs */
13 };
14
15 struct lcr_gsm {
16         void            *network;       /* OpenBSC network handle */
17         struct gsm_conf conf;           /* gsm.conf options */
18 };
19
20 extern struct lcr_gsm *gsm;
21
22 /* GSM port class */
23 class Pgsm : public PmISDN
24 {
25         public:
26         Pgsm(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive, int mode);
27         ~Pgsm();
28
29         void *p_m_g_instance; /* pointer to network/ms instance */
30         unsigned int p_m_g_callref; /* ref by OpenBSC/Osmocom-BB */
31         struct lcr_work p_m_g_delete;           /* timer for audio transmission */
32         unsigned int p_m_g_mode; /* data/transparent mode */
33         int p_m_g_gsm_b_sock; /* gsm bchannel socket */
34         struct lcr_fd p_m_g_gsm_b_fd; /* event node */
35         int p_m_g_gsm_b_index; /* gsm bchannel socket index to use */
36         int p_m_g_gsm_b_active; /* gsm bchannel socket is activated */
37         struct lcr_msg *p_m_g_notify_pending;   /* queue for NOTIFY if not connected */
38         void *p_m_g_encoder, *p_m_g_decoder;    /* gsm handle */
39         signed short p_m_g_rxdata[160]; /* receive audio buffer */
40         int p_m_g_rxpos; /* position in audio buffer 0..159 */
41         int p_m_g_tch_connected; /* indicates if audio is connected */
42
43         void bchannel_close(void);
44         int bchannel_open(int index);
45         void bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len);
46         void bchannel_send(unsigned int prim, unsigned int id, unsigned char *data, int len);
47
48         void frame_send(void *_frame);
49         void frame_receive(void *_frame);
50
51         int hunt_bchannel(void);
52         void call_conf_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *gsm);
53         void call_proc_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
54         void alert_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
55         void setup_cnf(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
56         void setup_compl_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
57         void disc_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
58         void rel_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
59         void notify_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
60         void message_notify(unsigned int epoint_id, int message_id, union parameter *param);
61         void message_alerting(unsigned int epoint_id, int message_id, union parameter *param);
62         void message_connect(unsigned int epoint_id, int message_id, union parameter *param);
63         void message_disconnect(unsigned int epoint_id, int message_id, union parameter *param);
64         void message_release(unsigned int epoint_id, int message_id, union parameter *param);
65         int message_epoint(unsigned int epoint_id, int message_id, union parameter *param);
66 };
67
68 struct gsm_mncc *create_mncc(int msg_type, unsigned int callref);
69 int send_and_free_mncc(void *instance, unsigned int msg_type, void *data);
70 void gsm_trace_header(struct mISDNport *mISDNport, class PmISDN *port, unsigned int msg_type, int direction);
71 int handle_gsm(void);
72 int gsm_conf(struct gsm_conf *gsm_conf, char *conf_error);
73 int gsm_exit(int rc);
74 int gsm_init(void);
75