Hi all,
[lcr.git] / gsm.h
1 extern int new_callref;
2
3 struct gsm_conf {
4         char debug[128];                /* debug info */
5         char interface_bsc[64];         /* loopback interface BSC side */
6         char interface_lcr[64];         /* loopback interface LCR side */
7         char openbsc_cfg[128];          /* openbsc config file */
8         char short_name[64];            /* short network name */
9         char long_name[64];             /* long network name */
10         char hlr[64];                   /* database name */
11         int allow_all;                  /* accept unknown subscribers */
12         int keep_l2;                    /* keep layer 2 after exit */
13         char pcapfile[128];             /* open capture file for BS11 links */
14         int reject_cause;               /* reject cause for unsubcribed IMSIs */
15 };
16
17 struct lcr_gsm {
18         void            *network;       /* OpenBSC network handle */
19         struct gsm_conf conf;           /* gsm.conf options */
20         int             gsm_sock;       /* loopback interface GSM side */
21         int             gsm_port;       /* loopback interface port number */
22 };
23
24 extern struct lcr_gsm *gsm;
25
26 /* GSM port class */
27 class Pgsm : public PmISDN
28 {
29         public:
30         Pgsm(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive, int mode);
31         ~Pgsm();
32
33         void *p_m_g_instance; /* pointer to network/ms instance */
34         unsigned int p_m_g_callref; /* ref by OpenBSC/Osmocom-BB */
35         struct lcr_work p_m_g_delete;           /* timer for audio transmission */
36         unsigned int p_m_g_mode; /* data/transparent mode */
37         int p_m_g_gsm_b_sock; /* gsm bchannel socket */
38         struct lcr_fd p_m_g_gsm_b_fd; /* event node */
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 call_conf_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *gsm);
57         void alert_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
58         void setup_cnf(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
59         void setup_compl_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
60         void disc_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
61         void rel_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
62         void notify_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
63         void message_notify(unsigned int epoint_id, int message_id, union parameter *param);
64         void message_alerting(unsigned int epoint_id, int message_id, union parameter *param);
65         void message_connect(unsigned int epoint_id, int message_id, union parameter *param);
66         void message_disconnect(unsigned int epoint_id, int message_id, union parameter *param);
67         void message_release(unsigned int epoint_id, int message_id, union parameter *param);
68         int message_epoint(unsigned int epoint_id, int message_id, union parameter *param);
69 };
70
71 struct gsm_mncc *create_mncc(int msg_type, unsigned int callref);
72 int send_and_free_mncc(void *instance, unsigned int msg_type, void *data);
73 void gsm_trace_header(struct mISDNport *mISDNport, class PmISDN *port, unsigned int msg_type, int direction);
74 int handle_gsm(void);
75 int gsm_conf(struct gsm_conf *gsm_conf, char *conf_error);
76 int gsm_exit(int rc);
77 int gsm_init(void);
78