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