Minor fix for GSM HR codec negotiation: Add missing 'break'.
[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         char interface_name[64]; /* name of interface this instance is associated to */
19         struct lcr_gsm  *gsm_ms_next;   /* list of MS instances, in case of MS */
20         char            name[16];       /* name of MS instance, in case of MS */
21         int             type;           /* LCR_GSM_TYPE_*/
22
23         struct lcr_fd   mncc_lfd;       /* Unix domain socket to OpenBSC MNCC */
24         struct mncc_q_entry *mncc_q_hd;
25         struct mncc_q_entry *mncc_q_tail;
26         struct lcr_timer socket_retry;  /* Timer to re-try connecting to BSC socket */
27         struct sockaddr_un sun;         /* Socket address of MNCC socket */
28 };
29
30 /* GSM port class */
31 class Pgsm : public Port
32 {
33         public:
34         Pgsm(int type, char *portname, struct port_settings *settings, struct interface *interface);
35         ~Pgsm();
36
37         char p_g_imsi[16]; /* imsi of current phone (used for ECT/MPTY with gsm_bs) */
38         signed short p_g_samples[160]; /* last received audi packet */
39         int p_g_tones; /* set, if tones are to be generated */
40         int p_g_earlyb; /* set, if patterns are available */
41         struct lcr_gsm *p_g_lcr_gsm; /* pointer to network/ms instance */
42         unsigned int p_g_callref; /* ref by OpenBSC/Osmocom-BB */
43         struct lcr_work p_g_delete; /* queue destruction of GSM port instance */
44         unsigned int p_g_mode; /* data/transparent mode */
45         int p_g_gsm_b_sock; /* gsm bchannel socket */
46         struct lcr_fd p_g_gsm_b_fd; /* event node */
47         int p_g_gsm_b_index; /* gsm bchannel socket index to use */
48         int p_g_gsm_b_active; /* gsm bchannel socket is activated */
49         struct lcr_msg *p_g_notify_pending;     /* queue for NOTIFY if not connected */
50         struct lcr_msg *p_g_setup_pending;      /* queue SETUP until RTP is created */
51         struct lcr_msg *p_g_connect_pending;    /* queue CONNECT until RTP is created and connected */
52         void *p_g_fr_encoder, *p_g_fr_decoder;  /* gsm handle */
53         void *p_g_hr_encoder, *p_g_hr_decoder;  /* gsm handle */
54         void *p_g_amr_encoder, *p_g_amr_decoder;/* gsm handle */
55         int p_g_amr_cmr, p_g_amr_cmr_valid;
56         signed short p_g_rxdata[160]; /* receive audio buffer */
57         int p_g_rxpos; /* position in audio buffer 0..159 */
58         int p_g_tch_connected; /* indicates if audio is connected */
59         int p_g_media_type; /* current payload type or 0 if not set */
60         int p_g_payload_type; /* current payload type */
61
62         int p_g_rtp_bridge; /* if we use a bridge */
63         unsigned int p_g_rtp_ip_remote; /* stores ip */
64         unsigned short p_g_rtp_port_remote; /* stores port */
65         int p_g_rtp_payloads;
66         int p_g_rtp_media_types[8];
67         unsigned char p_g_rtp_payload_types[8];
68
69         void frame_send(void *_frame, int len, int msg_type);
70         void frame_receive(void *_frame);
71         int audio_send(unsigned char *data, int len);
72         int bridge_rx(unsigned char *data, int len);
73
74         void send_mncc_rtp_connect(void);
75         int hunt_bchannel(void);
76         void modify_lchan(int media_type);
77         void call_proc_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
78         void alert_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
79         void setup_cnf(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
80         void setup_compl_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
81         void disc_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
82         void rel_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
83         void notify_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
84         void rtp_create_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
85         void rtp_connect_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
86         void message_notify(unsigned int epoint_id, int message_id, union parameter *param);
87         void message_progress(unsigned int epoint_id, int message_id, union parameter *param);
88         void message_alerting(unsigned int epoint_id, int message_id, union parameter *param);
89         void message_connect(unsigned int epoint_id, int message_id, union parameter *param);
90         void message_disconnect(unsigned int epoint_id, int message_id, union parameter *param);
91         void message_release(unsigned int epoint_id, int message_id, union parameter *param);
92         int message_epoint(unsigned int epoint_id, int message_id, union parameter *param);
93 };
94
95 struct gsm_mncc *create_mncc(int msg_type, unsigned int callref);
96 int send_and_free_mncc(struct lcr_gsm *lcr_gsm, unsigned int msg_type, void *data);
97 void gsm_trace_header(const char *interface_name, class Pgsm *port, unsigned int msg_type, int direction);
98 int gsm_conf(struct gsm_conf *gsm_conf, char *conf_error);
99 int gsm_exit(int rc);
100 int gsm_init(void);
101 int mncc_socket_retry_cb(struct lcr_timer *timer, void *inst, int index);
102