Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame^] | 1 | #ifndef _GSM_SUBSCR_H |
| 2 | #define _GSM_SUBSCR_H |
| 3 | |
| 4 | #include <sys/types.h> |
| 5 | #include "gsm_data.h" |
| 6 | #include "linuxlist.h" |
| 7 | |
| 8 | #define GSM_IMEI_LENGTH 17 |
| 9 | #define GSM_IMSI_LENGTH 17 |
| 10 | #define GSM_TMSI_LENGTH 17 |
| 11 | #define GSM_NAME_LENGTH 128 |
| 12 | #define GSM_EXTENSION_LENGTH 128 |
| 13 | |
| 14 | struct gsm_subscriber { |
| 15 | long long unsigned int id; |
| 16 | char imsi[GSM_IMSI_LENGTH]; |
| 17 | char tmsi[GSM_TMSI_LENGTH]; |
| 18 | u_int16_t lac; |
| 19 | char name[GSM_NAME_LENGTH]; |
| 20 | char extension[GSM_EXTENSION_LENGTH]; |
| 21 | int authorized; |
| 22 | |
| 23 | /* for internal management */ |
| 24 | int use_count; |
| 25 | struct llist_head entry; |
| 26 | |
| 27 | /* those are properties of the equipment, but they |
| 28 | * are applicable to the subscriber at the moment */ |
| 29 | struct gsm48_classmark1 classmark1; |
| 30 | u_int8_t classmark2_len; |
| 31 | u_int8_t classmark2[3]; |
| 32 | u_int8_t classmark3_len; |
| 33 | u_int8_t classmark3[14]; |
| 34 | }; |
| 35 | |
| 36 | enum gsm_subscriber_field { |
| 37 | GSM_SUBSCRIBER_IMSI, |
| 38 | GSM_SUBSCRIBER_TMSI, |
| 39 | GSM_SUBSCRIBER_EXTENSION, |
| 40 | }; |
| 41 | |
| 42 | enum gsm_subscriber_update_reason { |
| 43 | GSM_SUBSCRIBER_UPDATE_ATTACHED, |
| 44 | GSM_SUBSCRIBER_UPDATE_DETACHED, |
| 45 | }; |
| 46 | |
| 47 | struct gsm_subscriber *subscr_get(struct gsm_subscriber *subscr); |
| 48 | struct gsm_subscriber *subscr_put(struct gsm_subscriber *subscr); |
| 49 | struct gsm_subscriber *subscr_get_by_tmsi(const char *tmsi); |
| 50 | struct gsm_subscriber *subscr_get_by_imsi(const char *imsi); |
| 51 | struct gsm_subscriber *subscr_get_by_extension(const char *ext); |
| 52 | int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason); |
| 53 | void subscr_put_channel(struct gsm_lchan *lchan); |
| 54 | |
| 55 | /* internal */ |
| 56 | struct gsm_subscriber *subscr_alloc(void); |
| 57 | |
| 58 | #endif /* _GSM_SUBSCR_H */ |