Holger Hans Peter Freyther | 7127b02 | 2014-08-04 11:52:52 +0200 | [diff] [blame] | 1 | /* GPRS utility functions */ |
| 2 | |
| 3 | /* (C) 2010 by Harald Welte <laforge@gnumonks.org> |
| 4 | * (C) 2010-2014 by On-Waves |
| 5 | * (C) 2013 by Holger Hans Peter Freyther |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU Affero General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU Affero General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Affero General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | * |
| 21 | */ |
| 22 | #pragma once |
| 23 | |
| 24 | #include <stdint.h> |
| 25 | #include <sys/types.h> |
| 26 | |
Neels Hofmeyr | ee6cfdc | 2017-07-13 02:03:50 +0200 | [diff] [blame^] | 27 | #include <osmocom/core/msgb.h> |
| 28 | |
Holger Hans Peter Freyther | 7127b02 | 2014-08-04 11:52:52 +0200 | [diff] [blame] | 29 | struct msgb; |
Jacob Erlbeck | e7bcdc3 | 2016-01-04 18:43:34 +0100 | [diff] [blame] | 30 | struct gprs_ra_id; |
Holger Hans Peter Freyther | 7127b02 | 2014-08-04 11:52:52 +0200 | [diff] [blame] | 31 | |
| 32 | struct msgb *gprs_msgb_copy(const struct msgb *msg, const char *name); |
| 33 | int gprs_msgb_resize_area(struct msgb *msg, uint8_t *area, |
| 34 | size_t old_size, size_t new_size); |
Holger Hans Peter Freyther | ce1b22e | 2014-08-04 14:22:13 +0200 | [diff] [blame] | 35 | int gprs_str_to_apn(uint8_t *apn_enc, size_t max_len, const char *str); |
Jacob Erlbeck | 79af67d | 2015-01-19 08:27:34 +0100 | [diff] [blame] | 36 | |
| 37 | /* GSM 04.08, 10.5.7.3 GPRS Timer */ |
| 38 | int gprs_tmr_to_secs(uint8_t tmr); |
| 39 | uint8_t gprs_secs_to_tmr_floor(int secs); |
| 40 | |
Jacob Erlbeck | 9114bee | 2014-08-19 12:21:01 +0200 | [diff] [blame] | 41 | int gprs_is_mi_tmsi(const uint8_t *value, size_t value_len); |
| 42 | int gprs_is_mi_imsi(const uint8_t *value, size_t value_len); |
| 43 | int gprs_parse_mi_tmsi(const uint8_t *value, size_t value_len, uint32_t *tmsi); |
Jacob Erlbeck | 4938917 | 2014-10-02 16:14:47 +0200 | [diff] [blame] | 44 | void gprs_parse_tmsi(const uint8_t *value, uint32_t *tmsi); |
Jacob Erlbeck | dcfd456 | 2014-12-11 11:01:46 +0100 | [diff] [blame] | 45 | |
Jacob Erlbeck | e7bcdc3 | 2016-01-04 18:43:34 +0100 | [diff] [blame] | 46 | int gprs_ra_id_equals(const struct gprs_ra_id *id1, const struct gprs_ra_id *id2); |
Neels Hofmeyr | ee6cfdc | 2017-07-13 02:03:50 +0200 | [diff] [blame^] | 47 | |
| 48 | #define GSM48_ALLOC_SIZE 2048 |
| 49 | #define GSM48_ALLOC_HEADROOM 256 |
| 50 | |
| 51 | static inline struct msgb *gsm48_msgb_alloc_name(const char *name) |
| 52 | { |
| 53 | return msgb_alloc_headroom(GSM48_ALLOC_SIZE, GSM48_ALLOC_HEADROOM, |
| 54 | name); |
| 55 | } |