aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-03-04 14:05:20 +0100
committerHarald Welte <laforge@gnumonks.org>2011-03-04 14:05:20 +0100
commit4b45ae1636990a15934f77f37033cf8ed5804b57 (patch)
tree892d687a5c689fdb7813a3f94dd9a0926d80b892 /include
Import all C and Header files from jolly/bts branch of osmocom-bb.git
The BTS code shall reside in a separate git repository, thus I'm importing the C and H files here.
Diffstat (limited to 'include')
-rw-r--r--include/osmo-bts/abis.h68
-rw-r--r--include/osmo-bts/bts.h133
-rw-r--r--include/osmo-bts/oml.h9
-rw-r--r--include/osmo-bts/rsl.h12
-rw-r--r--include/osmo-bts/rtp.h47
-rw-r--r--include/osmo-bts/support.h30
6 files changed, 299 insertions, 0 deletions
diff --git a/include/osmo-bts/abis.h b/include/osmo-bts/abis.h
new file mode 100644
index 00000000..517c6e72
--- /dev/null
+++ b/include/osmo-bts/abis.h
@@ -0,0 +1,68 @@
+#ifndef _ABIS_H
+#define _ABIS_H
+
+#define IPA_TCP_PORT_OML 3002
+#define IPA_TCP_PORT_RSL 3003
+
+#define OML_RETRY_TIMER 5
+#define OML_PING_TIMER 20
+
+struct ipabis_head {
+ u_int16_t len; /* network byte order */
+ u_int8_t proto;
+ u_int8_t data[0];
+} __attribute__ ((packed));
+
+enum ipabis_proto {
+ IPA_PROTO_RSL = 0x00,
+ IPA_PROTO_IPACCESS = 0xfe,
+ IPA_PROTO_SCCP = 0xfd,
+ IPA_PROTO_OML = 0xff,
+};
+
+enum ipabis_msgtype {
+ IPA_MSGT_PING = 0x00,
+ IPA_MSGT_PONG = 0x01,
+ IPA_MSGT_ID_GET = 0x04,
+ IPA_MSGT_ID_RESP = 0x05,
+ IPA_MSGT_ID_ACK = 0x06,
+};
+
+enum ipabis_id_tags {
+ IPA_IDTAG_SERNR = 0x00,
+ IPA_IDTAG_UNITNAME = 0x01,
+ IPA_IDTAG_LOCATION1 = 0x02,
+ IPA_IDTAG_LOCATION2 = 0x03,
+ IPA_IDTAG_EQUIPVERS = 0x04,
+ IPA_IDTAG_SWVERSION = 0x05,
+ IPA_IDTAG_IPADDR = 0x06,
+ IPA_IDTAG_MACADDR = 0x07,
+ IPA_IDTAG_UNIT = 0x08,
+};
+
+struct ipabis_link {
+ int state;
+ struct osmocom_bts *bts; /* set, if OML link */
+ struct osmobts_trx *trx; /* set, if RSL link */
+ struct bsc_fd bfd;
+ struct timer_list timer;
+ struct msgb *rx_msg;
+ struct llist_head tx_queue;
+ int ping, pong, id_resp;
+ uint32_t ip;
+};
+
+enum {
+ LINK_STATE_IDLE = 0,
+ LINK_STATE_RETRYING,
+ LINK_STATE_CONNECTING,
+ LINK_STATE_CONNECT,
+};
+
+int abis_tx(struct ipabis_link *link, struct msgb *msg);
+struct msgb *abis_msgb_alloc(int headroom);
+void abis_push_ipa(struct msgb *msg, uint8_t proto);
+int abis_open(struct ipabis_link *link, uint32_t ip);
+void abis_close(struct ipabis_link *link);
+
+#endif /* _ABIS_H */
diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h
new file mode 100644
index 00000000..3e37e0bf
--- /dev/null
+++ b/include/osmo-bts/bts.h
@@ -0,0 +1,133 @@
+#ifndef _BTS_H
+#define _BTS_H
+
+#define BTS_SI_NUM 23 /* MUAR match the entries in BTS_SI_LIST */
+
+#define BTS_SI_LIST { \
+ RSL_SYSTEM_INFO_8, \
+ RSL_SYSTEM_INFO_1, \
+ RSL_SYSTEM_INFO_2, \
+ RSL_SYSTEM_INFO_3, \
+ RSL_SYSTEM_INFO_4, \
+ RSL_SYSTEM_INFO_5, \
+ RSL_SYSTEM_INFO_6, \
+ RSL_SYSTEM_INFO_7, \
+ RSL_SYSTEM_INFO_16, \
+ RSL_SYSTEM_INFO_17, \
+ RSL_SYSTEM_INFO_2bis, \
+ RSL_SYSTEM_INFO_2ter, \
+ RSL_SYSTEM_INFO_5bis, \
+ RSL_SYSTEM_INFO_5ter, \
+ RSL_SYSTEM_INFO_10, \
+ REL_EXT_MEAS_ORDER, \
+ RSL_MEAS_INFO, \
+ RSL_SYSTEM_INFO_13, \
+ RSL_SYSTEM_INFO_2quater, \
+ RSL_SYSTEM_INFO_9, \
+ RSL_SYSTEM_INFO_18, \
+ RSL_SYSTEM_INFO_19, \
+ RSL_SYSTEM_INFO_20, \
+}
+
+#define BTS_SI_NAME char *bts_si_name[] = { \
+ "RSL_SYSTEM_INFO_8", \
+ "RSL_SYSTEM_INFO_1", \
+ "RSL_SYSTEM_INFO_2", \
+ "RSL_SYSTEM_INFO_3", \
+ "RSL_SYSTEM_INFO_4", \
+ "RSL_SYSTEM_INFO_5", \
+ "RSL_SYSTEM_INFO_6", \
+ "RSL_SYSTEM_INFO_7", \
+ "RSL_SYSTEM_INFO_16", \
+ "RSL_SYSTEM_INFO_17", \
+ "RSL_SYSTEM_INFO_2bis", \
+ "RSL_SYSTEM_INFO_2ter", \
+ "RSL_SYSTEM_INFO_5bis", \
+ "RSL_SYSTEM_INFO_5ter", \
+ "RSL_SYSTEM_INFO_10", \
+ "REL_EXT_MEAS_ORDER", \
+ "RSL_MEAS_INFO", \
+ "RSL_SYSTEM_INFO_13", \
+ "RSL_SYSTEM_INFO_2quater", \
+ "RSL_SYSTEM_INFO_9", \
+ "RSL_SYSTEM_INFO_18", \
+ "RSL_SYSTEM_INFO_19", \
+ "RSL_SYSTEM_INFO_20", \
+}
+
+#define BTS_SI_USE 1
+#define BTS_SI_NEW 2
+
+/* store sysinfos of a BTS */
+struct osmobts_sysinfo {
+ uint8_t flags[BTS_SI_NUM];
+ uint8_t si[BTS_SI_NUM][23];
+ struct timer_list timer;
+};
+
+struct osmobts_slot;
+
+/* one physical radio */
+struct osmobts_ms {
+ struct llist_head entry;
+ struct osmobts_trx *trx;
+ struct osmocom_ms ms;
+};
+
+/* one logical channel instance */
+struct osmobts_lchan {
+ struct osmobts_slot *slot;
+ uint8_t lchan_nr;
+ uint8_t chan_nr; /* CBITS+TN */
+ struct osmol2_entity l2_entity;
+ struct osmobts_rtp rtp;
+};
+
+/* one timeslot instance */
+struct osmobts_slot {
+ struct osmobts_trx *trx;
+ uint8_t slot_nr;
+ uint8_t acch_type; /* TS 08.58 9.3.1 (bits 8..4) */
+ uint8_t has_bcch;
+ uint8_t chan_comb;
+ struct osmobts_lchan *lchan[8];
+ struct osmobts_ms *tx_ms, *rx_ms;
+};
+
+/* one TRX instance */
+struct osmobts_trx {
+ struct osmocom_bts *bts;
+ uint8_t trx_nr;
+ struct osmobts_slot slot[8];
+ struct llist_head ms_list;
+ struct ipabis_link link;
+ struct osmobts_sysinfo si;
+ uint8_t rf_red;
+ uint16_t arfcn_list[128];
+ int arfcn_num;
+};
+
+/* the BTS instance */
+struct osmocom_bts {
+ char *id;
+ uint8_t num_trx;
+ struct osmobts_trx *trx[8];
+ struct ipabis_link link;
+ uint8_t max_ta;
+ uint16_t bcch_arfcn;
+ uint8_t bcc, ncc;
+ uint16_t start_time;
+};
+
+struct osmocom_bts *create_bts(uint8_t num_trx, char *id);
+int create_ms(struct osmobts_trx *trx, int maskc, uint8_t *maskv_tx,
+ uint8_t *maskv_rx);
+void destroy_bts(struct osmocom_bts *bts);
+int work_bts(struct osmocom_bts *bts);
+int bts_link_estab(struct osmocom_bts *bts);
+int trx_link_estab(struct osmobts_trx *trx);
+void bts_new_si(void *arg);
+void bts_setup_slot(struct osmobts_slot *slot, uint8_t comb);
+
+#endif /* _BTS_H */
+
diff --git a/include/osmo-bts/oml.h b/include/osmo-bts/oml.h
new file mode 100644
index 00000000..09ad1abd
--- /dev/null
+++ b/include/osmo-bts/oml.h
@@ -0,0 +1,9 @@
+#ifndef _OML_H
+#define _OML_H
+
+int down_oml(struct osmocom_bts *bts, struct msgb *msg);
+int oml_tx_sw_act_rep(struct ipabis_link *link, uint8_t obj_class, uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr);
+int oml_tx_state_changed(struct ipabis_link *link, uint8_t op_state, uint8_t avail_status, uint8_t obj_class, uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr);
+
+#endif // _OML_H */
+
diff --git a/include/osmo-bts/rsl.h b/include/osmo-bts/rsl.h
new file mode 100644
index 00000000..3f9c2c9a
--- /dev/null
+++ b/include/osmo-bts/rsl.h
@@ -0,0 +1,12 @@
+#ifndef _RSL_H
+#define _RSL_H
+
+int down_rsl(struct osmobts_trx *trx, struct msgb *msg);
+int rsl_tx_rf_res(struct osmobts_trx *trx);
+int rsl_tx_chan_rqd(struct osmobts_trx *trx);
+int rsl_tx_est_ind(struct osmobts_lchan *lchan, uint8_t link_id, uint8_t *data, int len);
+int rsl_tx_rll(struct msgb *msg, struct osmol2_entity *l2_entity);
+int rsl_tx_ipac_dlcx_ind(struct osmobts_lchan *lchan, uint8_t cause);
+
+#endif // _RSL_H */
+
diff --git a/include/osmo-bts/rtp.h b/include/osmo-bts/rtp.h
new file mode 100644
index 00000000..28800fa0
--- /dev/null
+++ b/include/osmo-bts/rtp.h
@@ -0,0 +1,47 @@
+#ifndef _RTP_H
+#define _RTP_H
+
+struct osmobts_lchan *lchan;
+
+#define RTP_PT_GSM_FULL 3
+#define RTP_PT_GSM_HALF 96
+#define RTP_PT_GSM_EFR 97
+#define RTP_PT_AMR_FULL 98
+#define RTP_PT_AMR_HALF 99
+
+struct osmobts_udp {
+ struct osmobts_rtp *rtp;
+ struct bsc_fd bfd;
+ struct sockaddr_in sin_local, sin_remote;
+ struct llist_head tx_queue;
+};
+
+struct osmobts_rtp {
+ struct osmobts_lchan *lchan;
+ int socket_created;
+ struct osmobts_udp rtp_udp, rtcp_udp;
+ struct llist_head dejitter_queue;
+ int dejitter_num;
+ int dejitter_min;
+ int dejitter_check;
+ struct msgb *last_frame;
+ uint8_t payload_type;
+ uint16_t sequence;
+ uint32_t timestamp;
+ uint32_t ssrc;
+ int voice_req;
+};
+
+int rtp_create_socket(struct osmobts_lchan *lchan, struct osmobts_rtp *rtp);
+int rtp_bind_socket(struct osmobts_rtp *rtp);
+int rtp_connect_socket(struct osmobts_rtp *rtp, uint32_t ip, uint16_t port);
+int rtp_close_socket(struct osmobts_rtp *rtp);
+
+struct gsm_data_frame {
+ uint32_t timestamp;
+ uint8_t payload_type;
+ uint8_t data[0];
+};
+
+#endif /* _RTP_H */
+
diff --git a/include/osmo-bts/support.h b/include/osmo-bts/support.h
new file mode 100644
index 00000000..ed378753
--- /dev/null
+++ b/include/osmo-bts/support.h
@@ -0,0 +1,30 @@
+#ifndef _BTS_SUPPORT_H
+#define _BTS_SUPPORT_H
+
+struct bts_support {
+ /* crypto supprot */
+ uint8_t a5_1;
+ uint8_t a5_2;
+ uint8_t a5_3;
+ uint8_t a5_4;
+ uint8_t a5_5;
+ uint8_t a5_6;
+ uint8_t a5_7;
+ /* radio support */
+ uint8_t freq_map[128];
+ /* codecs */
+ uint8_t chan_comb[256];
+ uint8_t full_v1;
+ uint8_t full_v2;
+ uint8_t full_v3;
+ uint8_t half_v1;
+ uint8_t half_v3;
+};
+
+extern struct bts_support bts_support;
+void bts_support_init(void);
+char *bts_support_comb_name(uint8_t chan_comb);
+
+#endif /* _SUPPORT_H */
+
+