Merge branch 'develop'
[lcr.git] / gsm.h
1
2 #include <sys/un.h>
3
4 extern int new_callref;
5
6 struct mncc_q_entry {
7         struct mncc_q_entry *next;
8         unsigned int len;
9         char data[0];                   /* struct gsm_mncc */
10 };
11
12 struct lcr_gsm {
13         void            *network;       /* OpenBSC network handle */
14
15         struct lcr_fd   mncc_lfd;       /* Unix domain socket to OpenBSC MNCC */
16         struct mncc_q_entry *mncc_q_hd;
17         struct mncc_q_entry *mncc_q_tail;
18         struct lcr_timer socket_retry;  /* Timer to re-try connecting to BSC socket */
19         struct sockaddr_un sun;         /* Socket address of MNCC socket */
20 };
21
22 extern struct lcr_gsm *gsm;
23
24 /* GSM port class */
25 class Pgsm : public PmISDN
26 {
27         public:
28         Pgsm(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive, int mode);
29         ~Pgsm();
30
31         void *p_m_g_instance; /* pointer to network/ms instance */
32         unsigned int p_m_g_callref; /* ref by OpenBSC/Osmocom-BB */
33         struct lcr_work p_m_g_delete;           /* timer for audio transmission */
34         unsigned int p_m_g_mode; /* data/transparent mode */
35         int p_m_g_gsm_b_sock; /* gsm bchannel socket */
36         struct lcr_fd p_m_g_gsm_b_fd; /* event node */
37         int p_m_g_gsm_b_index; /* gsm bchannel socket index to use */
38         int p_m_g_gsm_b_active; /* gsm bchannel socket is activated */
39         struct lcr_msg *p_m_g_notify_pending;   /* queue for NOTIFY if not connected */
40         void *p_m_g_encoder, *p_m_g_decoder;    /* gsm handle */
41         signed short p_m_g_rxdata[160]; /* receive audio buffer */
42         int p_m_g_rxpos; /* position in audio buffer 0..159 */
43         int p_m_g_tch_connected; /* indicates if audio is connected */
44
45         void bchannel_close(void);
46         int bchannel_open(int index);
47         void bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len);
48         void bchannel_send(unsigned int prim, unsigned int id, unsigned char *data, int len);
49
50         void frame_send(void *_frame);
51         void frame_receive(void *_frame);
52
53         int hunt_bchannel(void);
54         void call_conf_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *gsm);
55         void call_proc_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
56         void alert_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
57         void setup_cnf(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
58         void setup_compl_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
59         void disc_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
60         void rel_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
61         void notify_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
62         void message_notify(unsigned int epoint_id, int message_id, union parameter *param);
63         void message_alerting(unsigned int epoint_id, int message_id, union parameter *param);
64         void message_connect(unsigned int epoint_id, int message_id, union parameter *param);
65         void message_disconnect(unsigned int epoint_id, int message_id, union parameter *param);
66         void message_release(unsigned int epoint_id, int message_id, union parameter *param);
67         int message_epoint(unsigned int epoint_id, int message_id, union parameter *param);
68 };
69
70 struct gsm_mncc *create_mncc(int msg_type, unsigned int callref);
71 int send_and_free_mncc(void *instance, unsigned int msg_type, void *data);
72 void gsm_trace_header(struct mISDNport *mISDNport, class PmISDN *port, unsigned int msg_type, int direction);
73 int handle_gsm(void);
74 int gsm_conf(struct gsm_conf *gsm_conf, char *conf_error);
75 int gsm_exit(int rc);
76 int gsm_init(void);
77