X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=gsm.h;h=f14794fa8290a5bc5b9f79c95960b1a761079071;hp=5d126465e7f838b13cbc4419d5da20d1b57e9f05;hb=refs%2Fheads%2Fbackup2;hpb=0345a55ca7308efdcebee25ec90ef0f11f78810e;ds=sidebyside diff --git a/gsm.h b/gsm.h index 5d12646..f14794f 100644 --- a/gsm.h +++ b/gsm.h @@ -3,29 +3,22 @@ extern int new_callref; -struct gsm_conf { - char debug[128]; /* debug info */ - char openbsc_cfg[128]; /* openbsc config file */ - char short_name[64]; /* short network name */ - char long_name[64]; /* long network name */ - char hlr[64]; /* database name */ - int allow_all; /* accept unknown subscribers */ - int keep_l2; /* keep layer 2 after exit */ - char pcapfile[128]; /* open capture file for BS11 links */ - int reject_cause; /* reject cause for unsubcribed IMSIs */ -}; - struct mncc_q_entry { struct mncc_q_entry *next; unsigned int len; char data[0]; /* struct gsm_mncc */ }; +enum { + LCR_GSM_TYPE_NETWORK, + LCR_GSM_TYPE_MS, +}; + struct lcr_gsm { - void *network; /* OpenBSC network handle */ - struct gsm_conf conf; /* gsm.conf options */ - int gsm_sock; /* loopback interface GSM side */ - int gsm_port; /* loopback interface port number */ + char interface_name[64]; /* name of interface this instance is associated to */ + struct lcr_gsm *gsm_next; /* list of MS/BS instances */ + char name[16]; /* name of MS/BS instance */ + int type; /* LCR_GSM_TYPE_*/ struct lcr_fd mncc_lfd; /* Unix domain socket to OpenBSC MNCC */ struct mncc_q_entry *mncc_q_hd; @@ -34,39 +27,52 @@ struct lcr_gsm { struct sockaddr_un sun; /* Socket address of MNCC socket */ }; -extern struct lcr_gsm *gsm; - /* GSM port class */ -class Pgsm : public PmISDN +class Pgsm : public Port { public: - Pgsm(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive, int mode); + Pgsm(int type, char *portname, struct port_settings *settings, struct interface *interface); ~Pgsm(); - void *p_m_g_instance; /* pointer to network/ms instance */ - unsigned int p_m_g_callref; /* ref by OpenBSC/Osmocom-BB */ - struct lcr_work p_m_g_delete; /* timer for audio transmission */ - unsigned int p_m_g_mode; /* data/transparent mode */ - int p_m_g_gsm_b_sock; /* gsm bchannel socket */ - struct lcr_fd p_m_g_gsm_b_fd; /* event node */ - int p_m_g_gsm_b_index; /* gsm bchannel socket index to use */ - int p_m_g_gsm_b_active; /* gsm bchannel socket is activated */ - struct lcr_msg *p_m_g_notify_pending; /* queue for NOTIFY if not connected */ - void *p_m_g_encoder, *p_m_g_decoder; /* gsm handle */ - signed short p_m_g_rxdata[160]; /* receive audio buffer */ - int p_m_g_rxpos; /* position in audio buffer 0..159 */ - int p_m_g_tch_connected; /* indicates if audio is connected */ + signed short p_g_samples[160]; /* last received audi packet */ + int p_g_tones; /* set, if tones are to be generated */ + int p_g_earlyb; /* set, if patterns are available */ + struct lcr_gsm *p_g_lcr_gsm; /* pointer to network/ms instance */ + unsigned int p_g_callref; /* ref by OpenBSC/Osmocom-BB */ + struct lcr_work p_g_delete; /* queue destruction of GSM port instance */ + unsigned int p_g_mode; /* data/transparent mode */ + int p_g_gsm_b_sock; /* gsm bchannel socket */ + struct lcr_fd p_g_gsm_b_fd; /* event node */ + int p_g_gsm_b_index; /* gsm bchannel socket index to use */ + int p_g_gsm_b_active; /* gsm bchannel socket is activated */ + struct lcr_msg *p_g_notify_pending; /* queue for NOTIFY if not connected */ + struct lcr_msg *p_g_setup_pending; /* queue SETUP until RTP is created */ + struct lcr_msg *p_g_connect_pending; /* queue CONNECT until RTP is created and connected */ + void *p_g_fr_encoder, *p_g_fr_decoder; /* gsm handle */ + void *p_g_hr_encoder, *p_g_hr_decoder; /* gsm handle */ + void *p_g_amr_encoder, *p_g_amr_decoder;/* gsm handle */ + int p_g_amr_cmr, p_g_amr_cmr_valid; + signed short p_g_rxdata[160]; /* receive audio buffer */ + int p_g_rxpos; /* position in audio buffer 0..159 */ + int p_g_tch_connected; /* indicates if audio is connected */ + int p_g_media_type; /* current payload type or 0 if not set */ + int p_g_payload_type; /* current payload type */ - void bchannel_close(void); - int bchannel_open(int index); - void bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len); - void bchannel_send(unsigned int prim, unsigned int id, unsigned char *data, int len); + int p_g_rtp_bridge; /* if we use a bridge */ + unsigned int p_g_rtp_ip_remote; /* stores ip */ + unsigned short p_g_rtp_port_remote; /* stores port */ + int p_g_rtp_payloads; + int p_g_rtp_media_types[8]; + unsigned char p_g_rtp_payload_types[8]; - void frame_send(void *_frame); + void frame_send(void *_frame, int len, int msg_type); void frame_receive(void *_frame); + int audio_send(unsigned char *data, int len); + int bridge_rx(unsigned char *data, int len); + void send_mncc_rtp_connect(void); int hunt_bchannel(void); - void call_conf_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *gsm); + void modify_lchan(int media_type); void call_proc_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc); void alert_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc); void setup_cnf(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc); @@ -74,7 +80,10 @@ class Pgsm : public PmISDN void disc_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc); void rel_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc); void notify_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc); + void rtp_create_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc); + void rtp_connect_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc); void message_notify(unsigned int epoint_id, int message_id, union parameter *param); + void message_progress(unsigned int epoint_id, int message_id, union parameter *param); void message_alerting(unsigned int epoint_id, int message_id, union parameter *param); void message_connect(unsigned int epoint_id, int message_id, union parameter *param); void message_disconnect(unsigned int epoint_id, int message_id, union parameter *param); @@ -83,13 +92,10 @@ class Pgsm : public PmISDN }; struct gsm_mncc *create_mncc(int msg_type, unsigned int callref); -int send_and_free_mncc(void *instance, unsigned int msg_type, void *data); -void gsm_trace_header(struct mISDNport *mISDNport, class PmISDN *port, unsigned int msg_type, int direction); -int handle_gsm(void); +int send_and_free_mncc(struct lcr_gsm *lcr_gsm, unsigned int msg_type, void *data); +void gsm_trace_header(const char *interface_name, class Pgsm *port, unsigned int msg_type, int direction); int gsm_conf(struct gsm_conf *gsm_conf, char *conf_error); int gsm_exit(int rc); int gsm_init(void); +int mncc_socket_retry_cb(struct lcr_timer *timer, void *inst, int index); -extern "C" { -int mncc_send(struct gsm_network *instance, int msg_type, void *data); -};