[layer23] Updated layer23 to current L1 support and forthcomming hopping.
[osmocom-bb.git] / src / host / layer23 / include / osmocom / gsm322.h
index 7ab45a0..d9cd226 100755 (executable)
@@ -29,7 +29,8 @@
 #define        GSM322_C7_CAMPED_ANY_CELL       7
 #define        GSM322_C8_ANY_CELL_RESEL        8
 #define        GSM322_C9_CHOOSE_ANY_CELL       9
-#define GSM322_HPLMN_SEARCH            10
+#define GSM322_PLMN_SEARCH             10
+#define GSM322_HPLMN_SEARCH            11
 
 /* GSM 03.22 events */
 #define        GSM322_EVENT_SWITCH_ON          1
 #define        GSM322_EVENT_INVALID_SIM        8
 #define        GSM322_EVENT_NEW_PLMN           9
 #define        GSM322_EVENT_ON_PLMN            10
-#define        GSM322_EVENT_HPLMN_SEARCH       11
-#define        GSM322_EVENT_HPLMN_FOUND        12
-#define        GSM322_EVENT_HPLMN_NOT_FOUND    13
-#define        GSM322_EVENT_USER_RESEL         14
-#define        GSM322_EVENT_PLMN_AVAIL         15
-#define        GSM322_EVENT_CHOSE_PLMN         16
-#define        GSM322_EVENT_SEL_MANUAL         17
-#define        GSM322_EVENT_SEL_AUTO           18
-#define        GSM322_EVENT_CELL_FOUND         19
-#define        GSM322_EVENT_NO_CELL_FOUND      20
-#define        GSM322_EVENT_LEAVE_IDLE         21
-#define        GSM322_EVENT_RET_IDLE           22
-#define        GSM322_EVENT_CELL_RESEL         23
-#define        GSM322_EVENT_SYSINFO            24
+#define        GSM322_EVENT_PLMN_SEARCH_START  11
+#define        GSM322_EVENT_PLMN_SEARCH_END    12
+#define        GSM322_EVENT_USER_RESEL         13
+#define        GSM322_EVENT_PLMN_AVAIL         14
+#define        GSM322_EVENT_CHOSE_PLMN         15
+#define        GSM322_EVENT_SEL_MANUAL         16
+#define        GSM322_EVENT_SEL_AUTO           17
+#define        GSM322_EVENT_CELL_FOUND         18
+#define        GSM322_EVENT_NO_CELL_FOUND      19
+#define        GSM322_EVENT_LEAVE_IDLE         20
+#define        GSM322_EVENT_RET_IDLE           21
+#define        GSM322_EVENT_CELL_RESEL         22
+#define        GSM322_EVENT_SYSINFO            23
+#define        GSM322_EVENT_HPLMN_SEARCH       24
 
 enum {
        PLMN_MODE_MANUAL,
@@ -100,17 +101,19 @@ struct gsm322_ba_list {
 struct gsm322_cs_list {
        uint8_t                 flags; /* see GSM322_CS_FLAG_* */
        int8_t                  rxlev_db; /* rx level in real dB */
+       struct gsm48_sysinfo    *sysinfo;
+#if 0
        int8_t                  min_db; /* minimum level to enter cell */
        int8_t                  max_pwr; /* maximum power to access cell */
        uint16_t                class_barr; /* barred classes */
        uint16_t                mcc, mnc, lac; /* received mcc, mnc, lac */
+#endif
 };
 
 /* PLMN search process */
 struct gsm322_plmn {
        struct osmocom_ms       *ms;
        int                     state; /* GSM322_Ax_* or GSM322_Mx_* */
-       int                     mode; /* PLMN_MODE_* */
 
        struct llist_head       event_queue; /* event messages */
        struct llist_head       sorted_plmn; /* list of sorted PLMN */
@@ -122,13 +125,18 @@ struct gsm322_plmn {
        uint16_t                mcc, mnc; /* current network selected */
 };
 
+/* state of CCCH activation */
+#define GSM322_CCCH_ST_IDLE    0       /* no connection */
+#define GSM322_CCCH_ST_INIT    1       /* initalized */
+#define GSM322_CCCH_ST_SYNC    2       /* got sync */
+#define GSM322_CCCH_ST_DATA    3       /* receiveing data */
+
+struct gsm48_sysinfo;
 /* Cell selection process */
 struct gsm322_cellsel {
        struct osmocom_ms       *ms;
        int                     state; /* GSM322_Cx_* */
 
-       uint16_t                arfcn; /* current tuned idle mode arfcn */
-
        struct llist_head       event_queue; /* event messages */
        struct llist_head       ba_list; /* BCCH Allocation per PLMN */
 
@@ -139,6 +147,15 @@ struct gsm322_cellsel {
 
        uint8_t                 powerscan; /* currently scanning for power */
        uint32_t                scan_state; /* special state of current scan */
+       uint8_t                 ccch_state; /* special state of current ccch */
+       uint16_t                arfcn; /* current tuned idle mode arfcn */
+       uint8_t                 ccch_mode; /* curren CCCH_MODE_* */
+       struct gsm48_sysinfo    *si; /* current sysinfo */
+
+       uint8_t                 selected; /* if a cell is selected */
+       uint16_t                sel_arfcn;
+       struct gsm48_sysinfo    sel_si; /* copy of selected cell, will update */
+       uint16_t                sel_mcc, sel_mnc, sel_lac, sel_id;
 };
 
 /* GSM 03.22 message */
@@ -160,16 +177,23 @@ int gsm322_cs_sendmsg(struct osmocom_ms *ms, struct msgb *msg);
 int gsm322_c_event(struct osmocom_ms *ms, struct msgb *msg);
 int gsm322_plmn_dequeue(struct osmocom_ms *ms);
 int gsm322_cs_dequeue(struct osmocom_ms *ms);
-int gsm322_add_forbidden_plmn(struct osmocom_ms *ms, uint16_t mcc,
-       uint16_t mnc, uint8_t cause);
 int gsm322_add_forbidden_la(struct osmocom_ms *ms, uint16_t mcc,
        uint16_t mnc, uint16_t lac, uint8_t cause);
-int gsm322_del_forbidden_plmn(struct osmocom_ms *ms, uint16_t mcc,
-       uint16_t mnc);
 int gsm322_del_forbidden_la(struct osmocom_ms *ms, uint16_t mcc,
        uint16_t mnc, uint16_t lac);
-int gsm322_is_forbidden_plmn(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc);
 int gsm322_is_forbidden_la(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc,
        uint16_t lac);
+int gsm322_dump_sorted_plmn(struct osmocom_ms *ms);
+int gsm322_dump_cs_list(struct gsm322_cellsel *cs, uint8_t flags,
+                       void (*print)(void *, const char *, ...), void *priv);
+int gsm322_dump_forbidden_la(struct osmocom_ms *ms,
+                       void (*print)(void *, const char *, ...), void *priv);
+int gsm322_dump_ba_list(struct gsm322_cellsel *cs, uint16_t mcc, uint16_t mnc,
+                       void (*print)(void *, const char *, ...), void *priv);
+void start_cs_timer(struct gsm322_cellsel *cs, int sec, int micro);
+void start_loss_timer(struct gsm322_cellsel *cs, int sec, int micro);
+extern const char *plmn_a_state_names[];
+extern const char *plmn_m_state_names[];
+extern const char *cs_state_names[];
 
 #endif /* _GSM322_H */