Philipp | f1f3436 | 2016-08-26 17:00:21 +0200 | [diff] [blame] | 1 | /* GPRS SNDCP header compression entity management tools */ |
| 2 | |
| 3 | /* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de> |
| 4 | * All Rights Reserved |
| 5 | * |
| 6 | * Author: Philipp Maier |
| 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 <osmocom/core/linuxlist.h> |
Neels Hofmeyr | 396f2e6 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 26 | #include <osmocom/sgsn/gprs_sndcp_xid.h> |
Philipp | f1f3436 | 2016-08-26 17:00:21 +0200 | [diff] [blame] | 27 | |
| 28 | /* Header / Data compression entity */ |
| 29 | struct gprs_sndcp_comp { |
| 30 | struct llist_head list; |
| 31 | |
| 32 | /* Serves as an ID in case we want to delete this entity later */ |
| 33 | unsigned int entity; /* see also: 6.5.1.1.3 and 6.6.1.1.3 */ |
| 34 | |
| 35 | /* Specifies to which NSAPIs the compression entity is assigned */ |
| 36 | uint8_t nsapi_len; /* Number of applicable NSAPIs (default 0) */ |
| 37 | uint8_t nsapi[MAX_NSAPI]; /* Applicable NSAPIs (default 0) */ |
| 38 | |
| 39 | /* Assigned pcomp values */ |
| 40 | uint8_t comp_len; /* Number of contained PCOMP / DCOMP values */ |
| 41 | uint8_t comp[MAX_COMP]; /* see also: 6.5.1.1.5 and 6.6.1.1.5 */ |
| 42 | |
| 43 | /* Algorithm parameters */ |
Stefan Sperling | c572154 | 2018-11-07 16:33:39 +0100 | [diff] [blame] | 44 | union gprs_sndcp_comp_algo algo; |
| 45 | enum gprs_sndcp_xid_param_types compclass; /* See gprs_sndcp_xid.h/c */ |
| 46 | void *state; /* Algorithm status and parameters */ |
Philipp | f1f3436 | 2016-08-26 17:00:21 +0200 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | #define MAX_COMP 16 /* Maximum number of possible pcomp/dcomp values */ |
| 50 | #define MAX_NSAPI 11 /* Maximum number usable NSAPIs */ |
| 51 | |
| 52 | /* Allocate a compression enitiy list */ |
| 53 | struct llist_head *gprs_sndcp_comp_alloc(const void *ctx); |
| 54 | |
| 55 | /* Free a compression entitiy list */ |
| 56 | void gprs_sndcp_comp_free(struct llist_head *comp_entities); |
| 57 | |
| 58 | /* Delete a compression entity */ |
| 59 | void gprs_sndcp_comp_delete(struct llist_head *comp_entities, unsigned int entity); |
| 60 | |
| 61 | /* Create and Add a new compression entity |
| 62 | * (returns a pointer to the compression entity that has just been created) */ |
| 63 | struct gprs_sndcp_comp *gprs_sndcp_comp_add(const void *ctx, |
| 64 | struct llist_head *comp_entities, |
| 65 | const struct gprs_sndcp_comp_field |
| 66 | *comp_field); |
| 67 | |
| 68 | /* Find which compression entity handles the specified pcomp/dcomp */ |
| 69 | struct gprs_sndcp_comp *gprs_sndcp_comp_by_comp(const struct llist_head |
| 70 | *comp_entities, uint8_t comp); |
| 71 | |
| 72 | /* Find which compression entity handles the specified nsapi */ |
| 73 | struct gprs_sndcp_comp *gprs_sndcp_comp_by_nsapi(const struct llist_head |
| 74 | *comp_entities, uint8_t nsapi); |
| 75 | |
| 76 | /* Find a comp_index for a given pcomp/dcomp value */ |
| 77 | uint8_t gprs_sndcp_comp_get_idx(const struct gprs_sndcp_comp *comp_entity, |
| 78 | uint8_t comp); |
| 79 | |
| 80 | /* Find a pcomp/dcomp value for a given comp_index */ |
| 81 | uint8_t gprs_sndcp_comp_get_comp(const struct gprs_sndcp_comp *comp_entity, |
| 82 | uint8_t comp_index); |