5d126465e7f838b13cbc4419d5da20d1b57e9f05
[lcr.git] / gsm.h
1
2 #include <sys/un.h>
3
4 extern int new_callref;
5
6 struct gsm_conf {
7         char debug[128];                /* debug info */
8         char openbsc_cfg[128];          /* openbsc config file */
9         char short_name[64];            /* short network name */
10         char long_name[64];             /* long network name */
11         char hlr[64];                   /* database name */
12         int allow_all;                  /* accept unknown subscribers */
13         int keep_l2;                    /* keep layer 2 after exit */
14         char pcapfile[128];             /* open capture file for BS11 links */
15         int reject_cause;               /* reject cause for unsubcribed IMSIs */
16 };
17
18 struct mncc_q_entry {
19         struct mncc_q_entry *next;
20         unsigned int len;
21         char data[0];                   /* struct gsm_mncc */
22 };
23
24 struct lcr_gsm {
25         void            *network;       /* OpenBSC network handle */
26         struct gsm_conf conf;           /* gsm.conf options */
27         int             gsm_sock;       /* loopback interface GSM side */
28         int             gsm_port;       /* loopback interface port number */
29
30         struct lcr_fd   mncc_lfd;       /* Unix domain socket to OpenBSC MNCC */
31         struct mncc_q_entry *mncc_q_hd;
32         struct mncc_q_entry *mncc_q_tail;
33         struct lcr_timer socket_retry;  /* Timer to re-try connecting to BSC socket */
34         struct sockaddr_un sun;         /* Socket address of MNCC socket */
35 };
36
37 extern struct lcr_gsm *gsm;
38
39 /* GSM port class */
40 class Pgsm : public PmISDN
41 {
42         public:
43         Pgsm(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive, int mode);
44         ~Pgsm();
45
46         void *p_m_g_instance; /* pointer to network/ms instance */
47         unsigned int p_m_g_callref; /* ref by OpenBSC/Osmocom-BB */
48         struct lcr_work p_m_g_delete;           /* timer for audio transmission */
49         unsigned int p_m_g_mode; /* data/transparent mode */
50         int p_m_g_gsm_b_sock; /* gsm bchannel socket */
51         struct lcr_fd p_m_g_gsm_b_fd; /* event node */
52         int p_m_g_gsm_b_index; /* gsm bchannel socket index to use */
53         int p_m_g_gsm_b_active; /* gsm bchannel socket is activated */
54         struct lcr_msg *p_m_g_notify_pending;   /* queue for NOTIFY if not connected */
55         void *p_m_g_encoder, *p_m_g_decoder;    /* gsm handle */
56         signed short p_m_g_rxdata[160]; /* receive audio buffer */
57         int p_m_g_rxpos; /* position in audio buffer 0..159 */
58         int p_m_g_tch_connected; /* indicates if audio is connected */
59
60         void bchannel_close(void);
61         int bchannel_open(int index);
62         void bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len);
63         void bchannel_send(unsigned int prim, unsigned int id, unsigned char *data, int len);
64
65         void frame_send(void *_frame);
66         void frame_receive(void *_frame);
67
68         int hunt_bchannel(void);
69         void call_conf_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *gsm);
70         void call_proc_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
71         void alert_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
72         void setup_cnf(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
73         void setup_compl_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
74         void disc_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
75         void rel_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
76         void notify_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
77         void message_notify(unsigned int epoint_id, int message_id, union parameter *param);
78         void message_alerting(unsigned int epoint_id, int message_id, union parameter *param);
79         void message_connect(unsigned int epoint_id, int message_id, union parameter *param);
80         void message_disconnect(unsigned int epoint_id, int message_id, union parameter *param);
81         void message_release(unsigned int epoint_id, int message_id, union parameter *param);
82         int message_epoint(unsigned int epoint_id, int message_id, union parameter *param);
83 };
84
85 struct gsm_mncc *create_mncc(int msg_type, unsigned int callref);
86 int send_and_free_mncc(void *instance, unsigned int msg_type, void *data);
87 void gsm_trace_header(struct mISDNport *mISDNport, class PmISDN *port, unsigned int msg_type, int direction);
88 int handle_gsm(void);
89 int gsm_conf(struct gsm_conf *gsm_conf, char *conf_error);
90 int gsm_exit(int rc);
91 int gsm_init(void);
92
93 extern "C" {
94 int mncc_send(struct gsm_network *instance, int msg_type, void *data);
95 };