libosmogsm 1.13.1.1-afb4 Osmocom GSM library

gsm23236.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <stdint.h>
8#include <stdbool.h>
9
10#include <osmocom/core/linuxlist.h>
11
12#define OSMO_NRI_BITLEN_MIN 1
13#define OSMO_NRI_BITLEN_MAX 15
14#define OSMO_NRI_BITLEN_DEFAULT 10
15
19 struct osmo_nri_range {
20 struct llist_head entry;
21
23 int16_t first;
25 int16_t last;
26};
27
35 struct osmo_nri_ranges {
36 /* List of struct osmo_nri_range entries, talloc allocated from the parent struct osmo_nri_ranges. */
37 struct llist_head entries;
38};
39
40 int osmo_nri_v_validate(int16_t nri_v, uint8_t nri_bitlen);
41 bool osmo_nri_v_matches_ranges(int16_t nri_v, const struct osmo_nri_ranges *nri_ranges);
42 int osmo_nri_v_limit_by_ranges(int16_t *nri_v, const struct osmo_nri_ranges *nri_ranges, uint32_t nri_bitlen);
43
44 int osmo_tmsi_nri_v_get(int16_t *nri_v, uint32_t tmsi, uint8_t nri_bitlen);
45 int osmo_tmsi_nri_v_set(uint32_t *tmsi, int16_t nri_v, uint8_t nri_bitlen);
46 int osmo_tmsi_nri_v_limit_by_ranges(uint32_t *tmsi, const struct osmo_nri_ranges *nri_ranges, uint8_t nri_bitlen);
47
48 int osmo_nri_range_validate(const struct osmo_nri_range *range, uint8_t nri_bitlen);
49 bool osmo_nri_range_overlaps_ranges(const struct osmo_nri_range *range, const struct osmo_nri_ranges *nri_ranges);
50
51 struct osmo_nri_ranges *osmo_nri_ranges_alloc(void *ctx);
52 void osmo_nri_ranges_free(struct osmo_nri_ranges *nri_ranges);
53 int osmo_nri_ranges_add(struct osmo_nri_ranges *nri_ranges, const struct osmo_nri_range *add);
54 int osmo_nri_ranges_del(struct osmo_nri_ranges *nri_ranges, const struct osmo_nri_range *del);
55 int osmo_nri_ranges_vty_add(const char **message, struct osmo_nri_range *added_range,
56 struct osmo_nri_ranges *nri_ranges, int argc, const char **argv, uint8_t nri_bitlen);
57 int osmo_nri_ranges_vty_del(const char **message, struct osmo_nri_range *removed_range,
58 struct osmo_nri_ranges *nri_ranges, int argc, const char **argv);
59 int osmo_nri_ranges_to_str_buf(char *buf, size_t buflen, const struct osmo_nri_ranges *nri_ranges);
60 char *osmo_nri_ranges_to_str_c(void *ctx, const struct osmo_nri_ranges *nri_ranges);
argv
argv
argc
argc
osmo_nri_ranges_free
void osmo_nri_ranges_free(struct osmo_nri_ranges *nri_ranges)
Free a struct osmo_nri_ranges.
Definition: gsm23236.c:267
osmo_nri_ranges_to_str_c
char * osmo_nri_ranges_to_str_c(void *ctx, const struct osmo_nri_ranges *nri_ranges)
Compose a human readable representation of a list of NRI ranges in a talloc buffer,...
Definition: gsm23236.c:422
osmo_nri_v_validate
int osmo_nri_v_validate(int16_t nri_v, uint8_t nri_bitlen)
Validate that the given NRI is valid for a given nri_bitlen range.
Definition: gsm23236.c:34
osmo_nri_v_matches_ranges
bool osmo_nri_v_matches_ranges(int16_t nri_v, const struct osmo_nri_ranges *nri_ranges)
Return true when the given NRI value appears in the list of NRI ranges.
Definition: gsm23236.c:80
osmo_nri_ranges_alloc
struct osmo_nri_ranges * osmo_nri_ranges_alloc(void *ctx)
Allocate an empty struct osmo_nri_ranges (list of struct osmo_nri_range).
Definition: gsm23236.c:255
osmo_tmsi_nri_v_limit_by_ranges
int osmo_tmsi_nri_v_limit_by_ranges(uint32_t *tmsi, const struct osmo_nri_ranges *nri_ranges, uint8_t nri_bitlen)
Apply osmo_nri_v_limit_by_ranges() in-place on the NRI value included in a TMSI.
Definition: gsm23236.c:201
osmo_nri_ranges_del
int osmo_nri_ranges_del(struct osmo_nri_ranges *nri_ranges, const struct osmo_nri_range *del)
Remove a range of NRI values from a list of nri_range structs.
Definition: gsm23236.c:347
osmo_nri_range_validate
int osmo_nri_range_validate(const struct osmo_nri_range *range, uint8_t nri_bitlen)
Validate that the given NRI range is valid for a given nri_bitlen range.
Definition: gsm23236.c:220
osmo_tmsi_nri_v_get
int osmo_tmsi_nri_v_get(int16_t *nri_v, uint32_t tmsi, uint8_t nri_bitlen)
Retrieve the Network Resource Indicator bits from a TMSI or p-TMSI.
Definition: gsm23236.c:147
osmo_nri_ranges_vty_add
int osmo_nri_ranges_vty_add(const char **message, struct osmo_nri_range *added_range, struct osmo_nri_ranges *nri_ranges, int argc, const char **argv, uint8_t nri_bitlen)
VTY implementation for adding an NRI range to a list of ranges.
Definition: gsm23236.c:487
osmo_nri_v_limit_by_ranges
int osmo_nri_v_limit_by_ranges(int16_t *nri_v, const struct osmo_nri_ranges *nri_ranges, uint32_t nri_bitlen)
Modulo and shift the given NRI value so that it becomes a value present in a list of NRI ranges.
Definition: gsm23236.c:99
osmo_nri_ranges_add
int osmo_nri_ranges_add(struct osmo_nri_ranges *nri_ranges, const struct osmo_nri_range *add)
Add a range of NRI values to a list of nri_range structs.
Definition: gsm23236.c:296
osmo_nri_ranges_vty_del
int osmo_nri_ranges_vty_del(const char **message, struct osmo_nri_range *removed_range, struct osmo_nri_ranges *nri_ranges, int argc, const char **argv)
VTY implementation for removing an NRI range from a list of ranges.
Definition: gsm23236.c:523
osmo_nri_range_overlaps_ranges
bool osmo_nri_range_overlaps_ranges(const struct osmo_nri_range *range, const struct osmo_nri_ranges *nri_ranges)
Return true when the given NRI range has at least one NRI value that appears in a list of other NRI r...
Definition: gsm23236.c:239
osmo_tmsi_nri_v_set
int osmo_tmsi_nri_v_set(uint32_t *tmsi, int16_t nri_v, uint8_t nri_bitlen)
Write Network Resource Indicator bits into a TMSI or p-TMSI.
Definition: gsm23236.c:176
osmo_nri_ranges_to_str_buf
int osmo_nri_ranges_to_str_buf(char *buf, size_t buflen, const struct osmo_nri_ranges *nri_ranges)
Compose a human readable representation of a list of NRI ranges in a buffer, like "23....
Definition: gsm23236.c:402
linuxlist.h
llist_head
osmo_nri_range
One range of NRI values.
Definition: gsm23236.h:19
osmo_nri_range::entry
struct llist_head entry
Definition: gsm23236.h:20
osmo_nri_range::first
int16_t first
First value of the NRI range, i.e.
Definition: gsm23236.h:23
osmo_nri_range::last
int16_t last
Last value of the NRI range, i.e.
Definition: gsm23236.h:25
osmo_nri_ranges
A list of struct osmo_nri_range.
Definition: gsm23236.h:35
osmo_nri_ranges::entries
struct llist_head entries
Definition: gsm23236.h:37