Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 1 | #ifndef _GPRS_BSSGP_H |
| 2 | #define _GPRS_BSSGP_H |
| 3 | |
Harald Welte | eaa614c | 2010-05-02 11:26:34 +0200 | [diff] [blame] | 4 | #include <stdint.h> |
| 5 | |
Harald Welte | ea34a4e | 2012-06-16 14:59:56 +0800 | [diff] [blame] | 6 | #include <osmocom/gsm/gsm48.h> |
Harald Welte | b1fd902 | 2012-06-17 12:16:31 +0800 | [diff] [blame] | 7 | #include <osmocom/gsm/prim.h> |
Harald Welte | ea34a4e | 2012-06-16 14:59:56 +0800 | [diff] [blame] | 8 | |
Harald Welte | d24566a | 2012-06-17 13:12:51 +0800 | [diff] [blame^] | 9 | #include <osmocom/gprs/protocol/gsm_08_18.h> |
| 10 | |
Harald Welte | 0a4050c | 2010-05-11 10:01:17 +0200 | [diff] [blame] | 11 | /* gprs_bssgp_util.c */ |
| 12 | extern struct gprs_ns_inst *bssgp_nsi; |
| 13 | struct msgb *bssgp_msgb_alloc(void); |
| 14 | const char *bssgp_cause_str(enum gprs_bssgp_cause cause); |
| 15 | /* Transmit a simple response such as BLOCK/UNBLOCK/RESET ACK/NACK */ |
| 16 | int bssgp_tx_simple_bvci(uint8_t pdu_type, uint16_t nsei, |
| 17 | uint16_t bvci, uint16_t ns_bvci); |
| 18 | /* Chapter 10.4.14: Status */ |
| 19 | int bssgp_tx_status(uint8_t cause, uint16_t *bvci, struct msgb *orig_msg); |
| 20 | |
Harald Welte | b1fd902 | 2012-06-17 12:16:31 +0800 | [diff] [blame] | 21 | enum bssgp_prim { |
| 22 | PRIM_BSSGP_DL_UD, |
| 23 | PRIM_BSSGP_UL_UD, |
| 24 | PRIM_BSSGP_PTM_UD, |
| 25 | |
| 26 | PRIM_BSSGP_GMM_SUSPEND, |
| 27 | PRIM_BSSGP_GMM_RESUME, |
| 28 | PRIM_BSSGP_GMM_PAGING, |
| 29 | |
| 30 | PRIM_NM_FLUSH_LL, |
| 31 | PRIM_NM_LLC_DISCARDED, |
| 32 | PRIM_NM_BVC_RESET, |
| 33 | PRIM_NM_BVC_BLOCK, |
| 34 | PRIM_NM_BVC_UNBLOCK, |
| 35 | }; |
| 36 | |
| 37 | struct osmo_bssgp_prim { |
| 38 | struct osmo_prim_hdr oph; |
| 39 | |
| 40 | /* common fields */ |
| 41 | uint16_t nsei; |
| 42 | uint16_t bvci; |
| 43 | uint32_t tlli; |
| 44 | struct tlv_parsed *tp; |
| 45 | struct gprs_ra_id *ra_id; |
| 46 | |
| 47 | /* specific fields */ |
| 48 | union { |
| 49 | struct { |
| 50 | uint8_t *suspend_ref; |
| 51 | } resume; |
| 52 | } u; |
| 53 | }; |
| 54 | |
Harald Welte | 0a4050c | 2010-05-11 10:01:17 +0200 | [diff] [blame] | 55 | /* gprs_bssgp.c */ |
| 56 | |
Harald Welte | 5c90e5c | 2010-05-17 23:02:42 +0200 | [diff] [blame] | 57 | #define BVC_S_BLOCKED 0x0001 |
| 58 | |
| 59 | /* The per-BTS context that we keep on the SGSN side of the BSSGP link */ |
| 60 | struct bssgp_bvc_ctx { |
| 61 | struct llist_head list; |
| 62 | |
Harald Welte | b52b4cf | 2011-11-25 08:15:42 +0100 | [diff] [blame] | 63 | struct gprs_ra_id ra_id; /*!< parsed RA ID of the remote BTS */ |
| 64 | uint16_t cell_id; /*!< Cell ID of the remote BTS */ |
Harald Welte | 5c90e5c | 2010-05-17 23:02:42 +0200 | [diff] [blame] | 65 | |
| 66 | /* NSEI and BVCI of underlying Gb link. Together they |
| 67 | * uniquely identify a link to a BTS (5.4.4) */ |
| 68 | uint16_t bvci; |
| 69 | uint16_t nsei; |
| 70 | |
| 71 | uint32_t state; |
| 72 | |
| 73 | struct rate_ctr_group *ctrg; |
| 74 | |
| 75 | /* we might want to add this as a shortcut later, avoiding the NSVC |
| 76 | * lookup for every packet, similar to a routing cache */ |
| 77 | //struct gprs_nsvc *nsvc; |
| 78 | }; |
| 79 | extern struct llist_head bssgp_bvc_ctxts; |
| 80 | /* Find a BTS Context based on parsed RA ID and Cell ID */ |
| 81 | struct bssgp_bvc_ctx *btsctx_by_raid_cid(const struct gprs_ra_id *raid, uint16_t cid); |
| 82 | /* Find a BTS context based on BVCI+NSEI tuple */ |
| 83 | struct bssgp_bvc_ctx *btsctx_by_bvci_nsei(uint16_t bvci, uint16_t nsei); |
| 84 | |
Harald Welte | 511bd8e | 2011-11-25 08:58:40 +0100 | [diff] [blame] | 85 | #define BVC_F_BLOCKED 0x0001 |
| 86 | |
| 87 | enum bssgp_ctr { |
| 88 | BSSGP_CTR_PKTS_IN, |
| 89 | BSSGP_CTR_PKTS_OUT, |
| 90 | BSSGP_CTR_BYTES_IN, |
| 91 | BSSGP_CTR_BYTES_OUT, |
| 92 | BSSGP_CTR_BLOCKED, |
| 93 | BSSGP_CTR_DISCARDED, |
| 94 | }; |
| 95 | |
| 96 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 97 | #include <osmocom/gsm/tlv.h> |
Harald Welte | 8645e10 | 2012-06-16 16:09:52 +0800 | [diff] [blame] | 98 | #include <osmocom/gprs/gprs_msgb.h> |
Harald Welte | 9f75c35 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 99 | |
Harald Welte | 4cc605a | 2010-05-13 19:25:59 +0200 | [diff] [blame] | 100 | /* BSSGP-UL-UNITDATA.ind */ |
Harald Welte | ce95b27 | 2012-06-17 13:04:02 +0800 | [diff] [blame] | 101 | int bssgp_rcvmsg(struct msgb *msg); |
Harald Welte | 4cc605a | 2010-05-13 19:25:59 +0200 | [diff] [blame] | 102 | |
| 103 | /* BSSGP-DL-UNITDATA.req */ |
Harald Welte | faa70ff | 2012-06-17 09:31:16 +0800 | [diff] [blame] | 104 | struct bssgp_lv { |
| 105 | uint16_t len; |
| 106 | uint8_t *v; |
| 107 | }; |
| 108 | /* parameters for BSSGP downlink userdata transmission */ |
| 109 | struct bssgp_dl_ud_par { |
| 110 | uint32_t *tlli; |
| 111 | char *imsi; |
| 112 | uint16_t drx_parms; |
| 113 | /* FIXME: priority */ |
| 114 | struct bssgp_lv ms_ra_cap; |
| 115 | uint8_t qos_profile[3]; |
| 116 | }; |
Harald Welte | ce95b27 | 2012-06-17 13:04:02 +0800 | [diff] [blame] | 117 | int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime, |
| 118 | struct bssgp_dl_ud_par *dup); |
Harald Welte | 4cc605a | 2010-05-13 19:25:59 +0200 | [diff] [blame] | 119 | |
Harald Welte | 11d7c10 | 2010-05-02 11:54:55 +0200 | [diff] [blame] | 120 | uint16_t bssgp_parse_cell_id(struct gprs_ra_id *raid, const uint8_t *buf); |
Harald Welte | 511bd8e | 2011-11-25 08:58:40 +0100 | [diff] [blame] | 121 | int bssgp_create_cell_id(uint8_t *buf, const struct gprs_ra_id *raid, |
| 122 | uint16_t cid); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 123 | |
Harald Welte | 9f75c35 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 124 | /* Wrapper around TLV parser to parse BSSGP IEs */ |
Harald Welte | eaa614c | 2010-05-02 11:26:34 +0200 | [diff] [blame] | 125 | static inline int bssgp_tlv_parse(struct tlv_parsed *tp, uint8_t *buf, int len) |
Harald Welte | 9f75c35 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 126 | { |
| 127 | return tlv_parse(tp, &tvlv_att_def, buf, len, 0, 0); |
| 128 | } |
| 129 | |
Harald Welte | b52b4cf | 2011-11-25 08:15:42 +0100 | [diff] [blame] | 130 | /*! \brief BSSGP Paging mode */ |
Harald Welte | bb35c45 | 2010-06-09 16:22:28 +0200 | [diff] [blame] | 131 | enum bssgp_paging_mode { |
| 132 | BSSGP_PAGING_PS, |
| 133 | BSSGP_PAGING_CS, |
| 134 | }; |
| 135 | |
Harald Welte | b52b4cf | 2011-11-25 08:15:42 +0100 | [diff] [blame] | 136 | /*! \brief BSSGP Paging scope */ |
Harald Welte | bb35c45 | 2010-06-09 16:22:28 +0200 | [diff] [blame] | 137 | enum bssgp_paging_scope { |
Harald Welte | b52b4cf | 2011-11-25 08:15:42 +0100 | [diff] [blame] | 138 | BSSGP_PAGING_BSS_AREA, /*!< all cells in BSS */ |
| 139 | BSSGP_PAGING_LOCATION_AREA, /*!< all cells in LA */ |
| 140 | BSSGP_PAGING_ROUTEING_AREA, /*!< all cells in RA */ |
| 141 | BSSGP_PAGING_BVCI, /*!< one cell */ |
Harald Welte | bb35c45 | 2010-06-09 16:22:28 +0200 | [diff] [blame] | 142 | }; |
| 143 | |
Harald Welte | b52b4cf | 2011-11-25 08:15:42 +0100 | [diff] [blame] | 144 | /*! \brief BSSGP paging information */ |
Harald Welte | bb35c45 | 2010-06-09 16:22:28 +0200 | [diff] [blame] | 145 | struct bssgp_paging_info { |
Harald Welte | b52b4cf | 2011-11-25 08:15:42 +0100 | [diff] [blame] | 146 | enum bssgp_paging_mode mode; /*!< CS or PS paging */ |
| 147 | enum bssgp_paging_scope scope; /*!< bssgp_paging_scope */ |
| 148 | struct gprs_ra_id raid; /*!< RA Identifier */ |
| 149 | uint16_t bvci; /*!< BVCI */ |
Harald Welte | 511bd8e | 2011-11-25 08:58:40 +0100 | [diff] [blame] | 150 | char *imsi; /*!< IMSI, if any */ |
Harald Welte | b52b4cf | 2011-11-25 08:15:42 +0100 | [diff] [blame] | 151 | uint32_t *ptmsi; /*!< P-TMSI, if any */ |
| 152 | uint16_t drx_params; /*!< DRX parameters */ |
| 153 | uint8_t qos[3]; /*!< QoS parameters */ |
Harald Welte | bb35c45 | 2010-06-09 16:22:28 +0200 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | /* Send a single GMM-PAGING.req to a given NSEI/NS-BVCI */ |
Harald Welte | ce95b27 | 2012-06-17 13:04:02 +0800 | [diff] [blame] | 157 | int bssgp_tx_paging(uint16_t nsei, uint16_t ns_bvci, |
| 158 | struct bssgp_paging_info *pinfo); |
Harald Welte | bb35c45 | 2010-06-09 16:22:28 +0200 | [diff] [blame] | 159 | |
Harald Welte | d2a9ed2 | 2010-05-18 08:02:36 +0200 | [diff] [blame] | 160 | /* gprs_bssgp_vty.c */ |
Harald Welte | ce95b27 | 2012-06-17 13:04:02 +0800 | [diff] [blame] | 161 | int bssgp_vty_init(void); |
| 162 | void bssgp_set_log_ss(int ss); |
Harald Welte | d2a9ed2 | 2010-05-18 08:02:36 +0200 | [diff] [blame] | 163 | |
Harald Welte | b1fd902 | 2012-06-17 12:16:31 +0800 | [diff] [blame] | 164 | int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx); |
| 165 | |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 166 | #endif /* _GPRS_BSSGP_H */ |