blob: a76b4a4b388298aae3ef4af8efbed21a3df30a64 [file] [log] [blame]
Philipp73f83d52016-09-02 13:38:01 +02001/* GPRS SNDCP data compression handler */
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>
26#include <openbsc/gprs_sndcp_comp.h>
27
28/* Note: The decompressed packet may have a maximum size of:
29 * Return value * MAX_DATADECOMPR_FAC */
30#define MAX_DATADECOMPR_FAC 10
31
32/* Note: In unacknowledged mode (SN_UNITDATA), the comression state is reset
33 * for every NPDU. The compressor needs a reasonably large payload to operate
34 * effectively (yield positive compression gain). For packets shorter than 100
35 * byte, no positive compression gain can be expected so we will skip the
36 * compression for short packets. */
37#define MIN_COMPR_PAYLOAD 100
38
39/* Initalize data compression */
40int gprs_sndcp_dcomp_init(const void *ctx, struct gprs_sndcp_comp *comp_entity,
41 const struct gprs_sndcp_comp_field *comp_field);
42
43/* Terminate data compression */
44void gprs_sndcp_dcomp_term(struct gprs_sndcp_comp *comp_entity);
45
46/* Expand packet */
47int gprs_sndcp_dcomp_expand(uint8_t *data, unsigned int len, uint8_t pcomp,
48 const struct llist_head *comp_entities);
49
50/* Compress packet */
51int gprs_sndcp_dcomp_compress(uint8_t *data, unsigned int len, uint8_t *pcomp,
52 const struct llist_head *comp_entities,
53 uint8_t nsapi);